Reuse the constant buffers of the shader executable.

TRAC #22327
Signed-off-by: Daniel Koch
Signed-off-by: Geoff Lang
Author: Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1767 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/renderer/ShaderExecutable11.cpp b/src/libGLESv2/renderer/ShaderExecutable11.cpp
index 1db66b1..d0903be 100644
--- a/src/libGLESv2/renderer/ShaderExecutable11.cpp
+++ b/src/libGLESv2/renderer/ShaderExecutable11.cpp
@@ -65,8 +65,22 @@
     return mPixelExecutable;
 }
 
-ID3D11Buffer *ShaderExecutable11::getConstantBuffer()
+ID3D11Buffer *ShaderExecutable11::getConstantBuffer(ID3D11Device *device, unsigned int registerCount)
 {
+    if (!mConstantBuffer && registerCount > 0)
+    {
+        D3D11_BUFFER_DESC constantBufferDescription = {0};
+        constantBufferDescription.ByteWidth = registerCount * sizeof(float[4]);
+        constantBufferDescription.Usage = D3D11_USAGE_DEFAULT;
+        constantBufferDescription.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+        constantBufferDescription.CPUAccessFlags = 0;
+        constantBufferDescription.MiscFlags = 0;
+        constantBufferDescription.StructureByteStride = 0;
+
+        HRESULT result = device->CreateBuffer(&constantBufferDescription, NULL, &mConstantBuffer);
+        ASSERT(SUCCEEDED(result));
+    }
+
     return mConstantBuffer;
 }