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/199345
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp b/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp
index 00cc0ed..6f53fd4 100644
--- a/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp
+++ b/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp
@@ -184,6 +184,9 @@
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++)
{
ID3D11Buffer *buffer = NULL;
@@ -203,13 +206,23 @@
if (buffer != mCurrentBuffers[i] || vertexStride != mCurrentVertexStrides[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;
mCurrentVertexStrides[i] = vertexStride;
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;
}