Add state queries for uniform buffer object count and alignment, and enforce a large alignment.

This will allow us to force the app to bind uniform buffers with zero offset. Zero offset allows us to map uniform blocks one-to-one to uniform buffers, then subsequently map UBOs to constant buffers. TRAC #22852 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2285 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 3eeca1ec
...@@ -1499,12 +1499,14 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1499,12 +1499,14 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
case GL_BLEND_EQUATION_ALPHA: *params = mState.blend.blendEquationAlpha; break; case GL_BLEND_EQUATION_ALPHA: *params = mState.blend.blendEquationAlpha; break;
case GL_STENCIL_WRITEMASK: *params = mState.depthStencil.stencilWritemask; break; case GL_STENCIL_WRITEMASK: *params = mState.depthStencil.stencilWritemask; break;
case GL_STENCIL_BACK_WRITEMASK: *params = mState.depthStencil.stencilBackWritemask; break; case GL_STENCIL_BACK_WRITEMASK: *params = mState.depthStencil.stencilBackWritemask; break;
case GL_STENCIL_CLEAR_VALUE: *params = mState.stencilClearValue; break; case GL_STENCIL_CLEAR_VALUE: *params = mState.stencilClearValue; break;
case GL_SUBPIXEL_BITS: *params = 4; break; case GL_SUBPIXEL_BITS: *params = 4; break;
case GL_MAX_TEXTURE_SIZE: *params = getMaximum2DTextureDimension(); break; case GL_MAX_TEXTURE_SIZE: *params = getMaximum2DTextureDimension(); break;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = getMaximumCubeTextureDimension(); break; case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = getMaximumCubeTextureDimension(); break;
case GL_MAX_3D_TEXTURE_SIZE: *params = getMaximum3DTextureDimension(); break; case GL_MAX_3D_TEXTURE_SIZE: *params = getMaximum3DTextureDimension(); break;
case GL_MAX_ARRAY_TEXTURE_LAYERS: *params = getMaximum2DArrayTextureLayers(); break; case GL_MAX_ARRAY_TEXTURE_LAYERS: *params = getMaximum2DArrayTextureLayers(); break;
case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: *params = getUniformBufferOffsetAlignment(); break;
case GL_MAX_UNIFORM_BUFFER_BINDINGS: *params = getMaximumCombinedUniformBufferBindings(); break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS: case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
params[0] = mNumCompressedTextureFormats; params[0] = mNumCompressedTextureFormats;
break; break;
...@@ -1926,6 +1928,8 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1926,6 +1928,8 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
// Check for ES3.0+ parameter names // Check for ES3.0+ parameter names
switch (pname) switch (pname)
{ {
case GL_MAX_UNIFORM_BUFFER_BINDINGS:
case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
case GL_UNIFORM_BUFFER_BINDING: case GL_UNIFORM_BUFFER_BINDING:
case GL_TRANSFORM_FEEDBACK_BINDING: case GL_TRANSFORM_FEEDBACK_BINDING:
case GL_COPY_READ_BUFFER_BINDING: case GL_COPY_READ_BUFFER_BINDING:
...@@ -2415,6 +2419,12 @@ unsigned int Context::getMaxTransformFeedbackBufferBindings() const ...@@ -2415,6 +2419,12 @@ unsigned int Context::getMaxTransformFeedbackBufferBindings() const
return mRenderer->getMaxTransformFeedbackBuffers(); return mRenderer->getMaxTransformFeedbackBuffers();
} }
GLintptr Context::getUniformBufferOffsetAlignment() const
{
// setting a large alignment forces uniform buffers to bind with zero offset
return static_cast<GLintptr>(std::numeric_limits<GLint>::max());
}
unsigned int Context::getMaximumRenderTargets() const unsigned int Context::getMaximumRenderTargets() const
{ {
return mRenderer->getMaxRenderTargets(); return mRenderer->getMaxRenderTargets();
......
...@@ -430,6 +430,7 @@ class Context ...@@ -430,6 +430,7 @@ class Context
unsigned int getMaximumRenderTargets() const; unsigned int getMaximumRenderTargets() const;
GLsizei getMaxSupportedSamples() const; GLsizei getMaxSupportedSamples() const;
unsigned int getMaxTransformFeedbackBufferBindings() const; unsigned int getMaxTransformFeedbackBufferBindings() const;
GLintptr getUniformBufferOffsetAlignment() const;
const char *getExtensionString() const; const char *getExtensionString() const;
const char *getRendererString() const; const char *getRendererString() const;
bool supportsEventQueries() const; bool supportsEventQueries() const;
......
...@@ -8676,6 +8676,13 @@ void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi ...@@ -8676,6 +8676,13 @@ void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi
break; break;
case GL_UNIFORM_BUFFER: case GL_UNIFORM_BUFFER:
// it is an error to bind an offset not a multiple of the alignment
if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0)
{
return gl::error(GL_INVALID_VALUE);
}
context->bindIndexedUniformBuffer(buffer, index, offset, size); context->bindIndexedUniformBuffer(buffer, index, offset, size);
context->bindGenericUniformBuffer(buffer); context->bindGenericUniformBuffer(buffer);
break; break;
......
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