Pass uniform buffers active bound to uniform blocks of the active program to HLSL/D3D constant buffers.
TRAC #22892
Signed-off-by: Nicolas Capens
Signed-off-by: Shannon Woods
Author: Jamie Madill
git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2339 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 2665072..b39bd6b 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -2094,6 +2094,33 @@
}
}
+bool Context::applyUniformBuffers()
+{
+ Program *programObject = getProgram(mState.currentProgram);
+ ProgramBinary *programBinary = programObject->getProgramBinary();
+
+ std::vector<gl::Buffer*> boundBuffers;
+
+ for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < programBinary->getActiveUniformBlockCount(); uniformBlockIndex++)
+ {
+ GLuint blockBinding = programObject->getUniformBlockBinding(uniformBlockIndex);
+ const OffsetBindingPointer<Buffer>& boundBuffer = mState.uniformBuffers[blockBinding];
+ if (boundBuffer.id() == 0)
+ {
+ // undefined behaviour
+ return false;
+ }
+ else
+ {
+ gl::Buffer *uniformBuffer = boundBuffer.get();
+ ASSERT(uniformBuffer);
+ boundBuffers.push_back(uniformBuffer);
+ }
+ }
+
+ return programBinary->applyUniformBuffers(boundBuffers);
+}
+
void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLsizei *bufSize, void* pixels)
{
@@ -2230,6 +2257,11 @@
applyShaders();
applyTextures();
+ if (!applyUniformBuffers())
+ {
+ return;
+ }
+
if (!programBinary->validateSamplers(NULL))
{
return gl::error(GL_INVALID_OPERATION);
@@ -2284,6 +2316,11 @@
applyShaders();
applyTextures();
+ if (!applyUniformBuffers())
+ {
+ return;
+ }
+
if (!programBinary->validateSamplers(NULL))
{
return gl::error(GL_INVALID_OPERATION);