Commit f98e63a5 by Geoff Lang

Minimize the API calls done by InputLayoutCache::applyVertexBuffers.

Reduce the number of IASetInputLayout calls to 1 in all cases and set the fewest number of buffers at once. BUG=260069 Change-Id: I059337fc6601ecefd801ef37546935becaa0d355 Reviewed-on: https://chromium-review.googlesource.com/199345Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 946b948d
...@@ -184,6 +184,9 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M ...@@ -184,6 +184,9 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
mCurrentIL = inputLayout; mCurrentIL = inputLayout;
} }
bool dirtyBuffers = false;
size_t minDiff = gl::MAX_VERTEX_ATTRIBS;
size_t maxDiff = 0;
for (unsigned int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) for (unsigned int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{ {
ID3D11Buffer *buffer = NULL; ID3D11Buffer *buffer = NULL;
...@@ -203,13 +206,23 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M ...@@ -203,13 +206,23 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
if (buffer != mCurrentBuffers[i] || vertexStride != mCurrentVertexStrides[i] || if (buffer != mCurrentBuffers[i] || vertexStride != mCurrentVertexStrides[i] ||
vertexOffset != mCurrentVertexOffsets[i]) vertexOffset != mCurrentVertexOffsets[i])
{ {
mDeviceContext->IASetVertexBuffers(i, 1, &buffer, &vertexStride, &vertexOffset); dirtyBuffers = true;
minDiff = std::min(minDiff, i);
maxDiff = std::max(maxDiff, i);
mCurrentBuffers[i] = buffer; mCurrentBuffers[i] = buffer;
mCurrentVertexStrides[i] = vertexStride; mCurrentVertexStrides[i] = vertexStride;
mCurrentVertexOffsets[i] = vertexOffset; mCurrentVertexOffsets[i] = vertexOffset;
} }
} }
if (dirtyBuffers)
{
ASSERT(minDiff <= maxDiff && maxDiff < gl::MAX_VERTEX_ATTRIBS);
mDeviceContext->IASetVertexBuffers(minDiff, maxDiff - minDiff + 1, mCurrentBuffers + minDiff,
mCurrentVertexStrides + minDiff, mCurrentVertexOffsets + minDiff);
}
return GL_NO_ERROR; return GL_NO_ERROR;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment