Implement instancing support in D3D11.
TRAC #22414
Signed-off-by: Geoff Lang
Signed-off-by: Nicolas Capens
Author: Jamie Madill
git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1791 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp
index 76ddc9e..912f342 100644
--- a/src/libGLESv2/renderer/Renderer11.cpp
+++ b/src/libGLESv2/renderer/Renderer11.cpp
@@ -819,12 +819,11 @@
}
else if (mode == GL_TRIANGLE_FAN)
{
- drawTriangleFan(count, GL_NONE, NULL, 0, NULL);
+ drawTriangleFan(count, GL_NONE, NULL, 0, NULL, instances);
}
else if (instances > 0)
{
- // TODO
- UNIMPLEMENTED();
+ mDeviceContext->DrawInstanced(count, instances, 0, 0);
}
else
{
@@ -832,7 +831,7 @@
}
}
-void Renderer11::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo)
+void Renderer11::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances)
{
if (mode == GL_LINE_LOOP)
{
@@ -840,7 +839,11 @@
}
else if (mode == GL_TRIANGLE_FAN)
{
- drawTriangleFan(count, type, indices, indexInfo.minIndex, elementArrayBuffer);
+ drawTriangleFan(count, type, indices, indexInfo.minIndex, elementArrayBuffer, instances);
+ }
+ else if (instances > 0)
+ {
+ mDeviceContext->DrawIndexedInstanced(count, instances, 0, -static_cast<int>(indexInfo.minIndex), 0);
}
else
{
@@ -940,7 +943,7 @@
mDeviceContext->DrawIndexed(count + 1, 0, -minIndex);
}
-void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer)
+void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances)
{
// Get the raw indices for an indexed draw
if (type != GL_NONE && elementArrayBuffer)
@@ -1034,7 +1037,14 @@
mAppliedIBOffset = indexBufferOffset;
}
- mDeviceContext->DrawIndexed(numTris * 3, 0, -minIndex);
+ if (instances > 0)
+ {
+ mDeviceContext->DrawIndexedInstanced(numTris * 3, instances, 0, -minIndex, 0);
+ }
+ else
+ {
+ mDeviceContext->DrawIndexed(numTris * 3, 0, -minIndex);
+ }
}
void Renderer11::applyShaders(gl::ProgramBinary *programBinary)
@@ -1937,9 +1947,7 @@
bool Renderer11::getInstancingSupport() const
{
- // TODO
- // UNIMPLEMENTED();
- return false;
+ return true;
}
bool Renderer11::getShareHandleSupport() const