Added methods to Context to get and set the current (non-indexed) bound uniform…

Added methods to Context to get and set the current (non-indexed) bound uniform and transform feedback buffers. TRAC #22811 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2129 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 7948c5f6
...@@ -151,6 +151,18 @@ Context::Context(int clientVersion, const gl::Context *shareContext, rx::Rendere ...@@ -151,6 +151,18 @@ Context::Context(int clientVersion, const gl::Context *shareContext, rx::Rendere
bindDrawFramebuffer(0); bindDrawFramebuffer(0);
bindRenderbuffer(0); bindRenderbuffer(0);
bindGenericUniformBuffer(0);
for (int i = 0; i < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS; i++)
{
bindIndexedUniformBuffer(0, i, 0, -1);
}
bindGenericTransformFeedbackBuffer(0);
for (int i = 0; i < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
{
bindIndexedTransformFeedbackBuffer(0, i, 0, -1);
}
mState.currentProgram = 0; mState.currentProgram = 0;
mCurrentProgramBinary.set(NULL); mCurrentProgramBinary.set(NULL);
...@@ -240,11 +252,13 @@ Context::~Context() ...@@ -240,11 +252,13 @@ Context::~Context()
mTexture2DZero.set(NULL); mTexture2DZero.set(NULL);
mTextureCubeMapZero.set(NULL); mTextureCubeMapZero.set(NULL);
mState.genericUniformBuffer.set(NULL);
for (int i = 0; i < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS; i++) for (int i = 0; i < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS; i++)
{ {
mState.uniformBuffers[i].set(NULL); mState.uniformBuffers[i].set(NULL);
} }
mState.genericTransformFeedbackBuffer.set(NULL);
for (int i = 0; i < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++) for (int i = 0; i < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
{ {
mState.transformFeedbackBuffers[i].set(NULL); mState.transformFeedbackBuffers[i].set(NULL);
...@@ -926,14 +940,28 @@ void Context::bindRenderbuffer(GLuint renderbuffer) ...@@ -926,14 +940,28 @@ void Context::bindRenderbuffer(GLuint renderbuffer)
mState.renderbuffer.set(getRenderbuffer(renderbuffer)); mState.renderbuffer.set(getRenderbuffer(renderbuffer));
} }
void Context::bindUniformBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size) void Context::bindGenericUniformBuffer(GLuint buffer)
{
mResourceManager->checkBufferAllocation(buffer);
mState.genericUniformBuffer.set(getBuffer(buffer));
}
void Context::bindIndexedUniformBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size)
{ {
mResourceManager->checkBufferAllocation(buffer); mResourceManager->checkBufferAllocation(buffer);
mState.uniformBuffers[index].set(getBuffer(buffer), offset, size); mState.uniformBuffers[index].set(getBuffer(buffer), offset, size);
} }
void Context::bindTransformFeedbackBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size) void Context::bindGenericTransformFeedbackBuffer(GLuint buffer)
{
mResourceManager->checkBufferAllocation(buffer);
mState.genericTransformFeedbackBuffer.set(getBuffer(buffer));
}
void Context::bindIndexedTransformFeedbackBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size)
{ {
mResourceManager->checkBufferAllocation(buffer); mResourceManager->checkBufferAllocation(buffer);
...@@ -1193,6 +1221,16 @@ TextureCubeMap *Context::getTextureCubeMap() ...@@ -1193,6 +1221,16 @@ TextureCubeMap *Context::getTextureCubeMap()
return static_cast<TextureCubeMap*>(getSamplerTexture(mState.activeSampler, TEXTURE_CUBE)); return static_cast<TextureCubeMap*>(getSamplerTexture(mState.activeSampler, TEXTURE_CUBE));
} }
Buffer *Context::getGenericUniformBuffer()
{
return mState.genericUniformBuffer.get();
}
Buffer *Context::getGenericTransformFeedbackBuffer()
{
return mState.genericTransformFeedbackBuffer.get();
}
Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type) Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type)
{ {
GLuint texid = mState.samplerTexture[type][sampler].id(); GLuint texid = mState.samplerTexture[type][sampler].id();
...@@ -1547,6 +1585,12 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1547,6 +1585,12 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
case GL_PROGRAM_BINARY_FORMATS_OES: case GL_PROGRAM_BINARY_FORMATS_OES:
*params = GL_PROGRAM_BINARY_ANGLE; *params = GL_PROGRAM_BINARY_ANGLE;
break; break;
case GL_UNIFORM_BUFFER_BINDING:
*params = mState.genericUniformBuffer.id();
break;
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
*params = mState.genericTransformFeedbackBuffer.id();
break;
default: default:
return false; return false;
} }
...@@ -1577,13 +1621,13 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1577,13 +1621,13 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_INT; *type = GL_INT;
*numParams = mNumCompressedTextureFormats; *numParams = mNumCompressedTextureFormats;
} }
break; return true;
case GL_SHADER_BINARY_FORMATS: case GL_SHADER_BINARY_FORMATS:
{ {
*type = GL_INT; *type = GL_INT;
*numParams = 0; *numParams = 0;
} }
break; return true;
case GL_MAX_VERTEX_ATTRIBS: case GL_MAX_VERTEX_ATTRIBS:
case GL_MAX_VERTEX_UNIFORM_VECTORS: case GL_MAX_VERTEX_UNIFORM_VECTORS:
case GL_MAX_VARYING_VECTORS: case GL_MAX_VARYING_VECTORS:
...@@ -1653,7 +1697,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1653,7 +1697,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_INT; *type = GL_INT;
*numParams = 1; *numParams = 1;
} }
break; return true;
case GL_MAX_SAMPLES_ANGLE: case GL_MAX_SAMPLES_ANGLE:
{ {
if (getMaxSupportedSamples() != 0) if (getMaxSupportedSamples() != 0)
...@@ -1666,20 +1710,20 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1666,20 +1710,20 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
return false; return false;
} }
} }
break; return true;
case GL_MAX_VIEWPORT_DIMS: case GL_MAX_VIEWPORT_DIMS:
{ {
*type = GL_INT; *type = GL_INT;
*numParams = 2; *numParams = 2;
} }
break; return true;
case GL_VIEWPORT: case GL_VIEWPORT:
case GL_SCISSOR_BOX: case GL_SCISSOR_BOX:
{ {
*type = GL_INT; *type = GL_INT;
*numParams = 4; *numParams = 4;
} }
break; return true;
case GL_SHADER_COMPILER: case GL_SHADER_COMPILER:
case GL_SAMPLE_COVERAGE_INVERT: case GL_SAMPLE_COVERAGE_INVERT:
case GL_DEPTH_WRITEMASK: case GL_DEPTH_WRITEMASK:
...@@ -1697,13 +1741,13 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1697,13 +1741,13 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_BOOL; *type = GL_BOOL;
*numParams = 1; *numParams = 1;
} }
break; return true;
case GL_COLOR_WRITEMASK: case GL_COLOR_WRITEMASK:
{ {
*type = GL_BOOL; *type = GL_BOOL;
*numParams = 4; *numParams = 4;
} }
break; return true;
case GL_POLYGON_OFFSET_FACTOR: case GL_POLYGON_OFFSET_FACTOR:
case GL_POLYGON_OFFSET_UNITS: case GL_POLYGON_OFFSET_UNITS:
case GL_SAMPLE_COVERAGE_VALUE: case GL_SAMPLE_COVERAGE_VALUE:
...@@ -1713,7 +1757,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1713,7 +1757,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_FLOAT; *type = GL_FLOAT;
*numParams = 1; *numParams = 1;
} }
break; return true;
case GL_ALIASED_LINE_WIDTH_RANGE: case GL_ALIASED_LINE_WIDTH_RANGE:
case GL_ALIASED_POINT_SIZE_RANGE: case GL_ALIASED_POINT_SIZE_RANGE:
case GL_DEPTH_RANGE: case GL_DEPTH_RANGE:
...@@ -1721,14 +1765,14 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1721,14 +1765,14 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_FLOAT; *type = GL_FLOAT;
*numParams = 2; *numParams = 2;
} }
break; return true;
case GL_COLOR_CLEAR_VALUE: case GL_COLOR_CLEAR_VALUE:
case GL_BLEND_COLOR: case GL_BLEND_COLOR:
{ {
*type = GL_FLOAT; *type = GL_FLOAT;
*numParams = 4; *numParams = 4;
} }
break; return true;
case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
if (!supportsTextureFilterAnisotropy()) if (!supportsTextureFilterAnisotropy())
{ {
...@@ -1736,12 +1780,27 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1736,12 +1780,27 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
} }
*type = GL_FLOAT; *type = GL_FLOAT;
*numParams = 1; *numParams = 1;
break; return true;
default: }
if (mClientVersion < 3)
{
return false; return false;
} }
// Check for ES3.0+ parameter names
switch (pname)
{
case GL_UNIFORM_BUFFER_BINDING:
case GL_TRANSFORM_FEEDBACK_BINDING:
{
*type = GL_INT;
*numParams = 1;
}
return true; return true;
}
return false;
} }
// Applies the render target surface, depth stencil surface, viewport rectangle and // Applies the render target surface, depth stencil surface, viewport rectangle and
......
...@@ -183,8 +183,10 @@ struct State ...@@ -183,8 +183,10 @@ struct State
BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS]; BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS];
BindingPointer<Query> activeQuery[QUERY_TYPE_COUNT]; BindingPointer<Query> activeQuery[QUERY_TYPE_COUNT];
BindingPointer<Buffer> genericUniformBuffer;
OffsetBindingPointer<Buffer> uniformBuffers[IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS]; OffsetBindingPointer<Buffer> uniformBuffers[IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS];
BindingPointer<Buffer> genericTransformFeedbackBuffer;
OffsetBindingPointer<Buffer> transformFeedbackBuffers[IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS]; OffsetBindingPointer<Buffer> transformFeedbackBuffers[IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
GLint unpackAlignment; GLint unpackAlignment;
...@@ -331,8 +333,10 @@ class Context ...@@ -331,8 +333,10 @@ class Context
void bindReadFramebuffer(GLuint framebuffer); void bindReadFramebuffer(GLuint framebuffer);
void bindDrawFramebuffer(GLuint framebuffer); void bindDrawFramebuffer(GLuint framebuffer);
void bindRenderbuffer(GLuint renderbuffer); void bindRenderbuffer(GLuint renderbuffer);
void bindUniformBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size); void bindGenericUniformBuffer(GLuint buffer);
void bindTransformFeedbackBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size); void bindIndexedUniformBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size);
void bindGenericTransformFeedbackBuffer(GLuint buffer);
void bindIndexedTransformFeedbackBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size);
void useProgram(GLuint program); void useProgram(GLuint program);
void linkProgram(GLuint program); void linkProgram(GLuint program);
void setProgramBinary(GLuint program, const void *binary, GLint length); void setProgramBinary(GLuint program, const void *binary, GLint length);
...@@ -363,6 +367,8 @@ class Context ...@@ -363,6 +367,8 @@ class Context
ProgramBinary *getCurrentProgramBinary(); ProgramBinary *getCurrentProgramBinary();
Texture2D *getTexture2D(); Texture2D *getTexture2D();
TextureCubeMap *getTextureCubeMap(); TextureCubeMap *getTextureCubeMap();
Buffer *getGenericUniformBuffer();
Buffer *getGenericTransformFeedbackBuffer();
Texture *getSamplerTexture(unsigned int sampler, TextureType type); Texture *getSamplerTexture(unsigned int sampler, TextureType type);
Framebuffer *getReadFramebuffer(); Framebuffer *getReadFramebuffer();
Framebuffer *getDrawFramebuffer(); Framebuffer *getDrawFramebuffer();
......
...@@ -417,6 +417,17 @@ void __stdcall glBindBuffer(GLenum target, GLuint buffer) ...@@ -417,6 +417,17 @@ void __stdcall glBindBuffer(GLenum target, GLuint buffer)
if (context) if (context)
{ {
// Check ES3 specific targets
switch (target)
{
case GL_UNIFORM_BUFFER:
case GL_TRANSFORM_FEEDBACK_BUFFER:
if (context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_ENUM);
}
}
switch (target) switch (target)
{ {
case GL_ARRAY_BUFFER: case GL_ARRAY_BUFFER:
...@@ -425,6 +436,12 @@ void __stdcall glBindBuffer(GLenum target, GLuint buffer) ...@@ -425,6 +436,12 @@ void __stdcall glBindBuffer(GLenum target, GLuint buffer)
case GL_ELEMENT_ARRAY_BUFFER: case GL_ELEMENT_ARRAY_BUFFER:
context->bindElementArrayBuffer(buffer); context->bindElementArrayBuffer(buffer);
return; return;
case GL_UNIFORM_BUFFER:
context->bindGenericUniformBuffer(buffer);
return;
case GL_TRANSFORM_FEEDBACK_BUFFER:
context->bindGenericUniformBuffer(buffer);
return;
default: default:
return gl::error(GL_INVALID_ENUM); return gl::error(GL_INVALID_ENUM);
} }
...@@ -772,6 +789,17 @@ void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, ...@@ -772,6 +789,17 @@ void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data,
if (context) if (context)
{ {
// Check ES3 specific targets
switch (target)
{
case GL_UNIFORM_BUFFER:
case GL_TRANSFORM_FEEDBACK_BUFFER:
if (context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_ENUM);
}
}
gl::Buffer *buffer; gl::Buffer *buffer;
switch (target) switch (target)
...@@ -782,6 +810,12 @@ void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, ...@@ -782,6 +810,12 @@ void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data,
case GL_ELEMENT_ARRAY_BUFFER: case GL_ELEMENT_ARRAY_BUFFER:
buffer = context->getElementArrayBuffer(); buffer = context->getElementArrayBuffer();
break; break;
case GL_TRANSFORM_FEEDBACK_BUFFER:
buffer = context->getGenericTransformFeedbackBuffer();
break;
case GL_UNIFORM_BUFFER:
buffer = context->getGenericUniformBuffer();
break;
default: default:
return gl::error(GL_INVALID_ENUM); return gl::error(GL_INVALID_ENUM);
} }
...@@ -821,6 +855,17 @@ void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, ...@@ -821,6 +855,17 @@ void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
if (context) if (context)
{ {
// Check ES3 specific targets
switch (target)
{
case GL_UNIFORM_BUFFER:
case GL_TRANSFORM_FEEDBACK_BUFFER:
if (context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_ENUM);
}
}
gl::Buffer *buffer; gl::Buffer *buffer;
switch (target) switch (target)
...@@ -831,6 +876,12 @@ void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, ...@@ -831,6 +876,12 @@ void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
case GL_ELEMENT_ARRAY_BUFFER: case GL_ELEMENT_ARRAY_BUFFER:
buffer = context->getElementArrayBuffer(); buffer = context->getElementArrayBuffer();
break; break;
case GL_TRANSFORM_FEEDBACK_BUFFER:
buffer = context->getGenericTransformFeedbackBuffer();
break;
case GL_UNIFORM_BUFFER:
buffer = context->getGenericUniformBuffer();
break;
default: default:
return gl::error(GL_INVALID_ENUM); return gl::error(GL_INVALID_ENUM);
} }
...@@ -7804,11 +7855,13 @@ void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi ...@@ -7804,11 +7855,13 @@ void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi
switch (target) switch (target)
{ {
case GL_TRANSFORM_FEEDBACK_BUFFER: case GL_TRANSFORM_FEEDBACK_BUFFER:
context->bindTransformFeedbackBuffer(buffer, index, offset, size); context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
context->bindGenericTransformFeedbackBuffer(buffer);
break; break;
case GL_UNIFORM_BUFFER: case GL_UNIFORM_BUFFER:
context->bindUniformBuffer(buffer, index, offset, size); context->bindIndexedUniformBuffer(buffer, index, offset, size);
context->bindGenericUniformBuffer(buffer);
break; break;
default: default:
...@@ -7868,11 +7921,13 @@ void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) ...@@ -7868,11 +7921,13 @@ void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
switch (target) switch (target)
{ {
case GL_TRANSFORM_FEEDBACK_BUFFER: case GL_TRANSFORM_FEEDBACK_BUFFER:
context->bindTransformFeedbackBuffer(buffer, index, 0, -1); context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, -1);
context->bindGenericTransformFeedbackBuffer(buffer);
break; break;
case GL_UNIFORM_BUFFER: case GL_UNIFORM_BUFFER:
context->bindUniformBuffer(buffer, index, 0, -1); context->bindIndexedUniformBuffer(buffer, index, 0, -1);
context->bindGenericUniformBuffer(buffer);
break; break;
default: default:
......
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