diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-27 01:33:44 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-27 01:33:44 +0000 |
commit | 8e2a5abe106158df74caad4c6fbd988d8d900b7c (patch) | |
tree | 882455dbf8a278cc8274aaa3ec2df67cf7981c2c /gpu/command_buffer/common/gles2_cmd_utils.cc | |
parent | 1e7cd2c7c0e52296e9c25a71d652bc6a53413eb7 (diff) | |
download | chromium_src-8e2a5abe106158df74caad4c6fbd988d8d900b7c.zip chromium_src-8e2a5abe106158df74caad4c6fbd988d8d900b7c.tar.gz chromium_src-8e2a5abe106158df74caad4c6fbd988d8d900b7c.tar.bz2 |
Added support for glGetString, glGetShaderSource,
glGetProgramInfoLog and glGetShaderInfoLog
This turned up lots of issues.
* glGetShaderiv needed to be wrapped so it
returns the size of the shader the user passed
in. Not the munged shader sent to GL.
* Another issue that came up is that client
side validation is needed to ensure that
the client side GLES2Implementation does not
generate bad commands. For example, calling
glUniform1iv with a negative count would
generate a bad command. The service side
would see that and think the program was
malicious and stop processing commands.
So, that means I had to add some client side
validation and wrap glGetError on the client
side so I can synthisize GL errors there.
TEST=lots of unit tests.
BUG=none
Review URL: http://codereview.chromium.org/661220
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/common/gles2_cmd_utils.cc')
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_utils.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc index 9e376270..e0fc8e6 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -11,6 +11,17 @@ namespace gpu { namespace gles2 { +namespace gl_error_bit { +enum GLErrorBit { + kNoError = 0, + kInvalidEnum = (1 << 0), + kInvalidValue = (1 << 1), + kInvalidOperation = (1 << 2), + kOutOfMemory = (1 << 3), + kInvalidFrameBufferOperation = (1 << 4), +}; +} + int GLES2Util::GLGetNumValuesReturned(int id) const { switch (id) { // -- glGetBooleanv, glGetFloatv, glGetIntergerv @@ -401,6 +412,41 @@ size_t GLES2Util::GetGLTypeSizeForTexturesAndBuffers(uint32 type) { } } +uint32 GLES2Util::GLErrorToErrorBit(uint32 error) { + switch (error) { + case GL_INVALID_ENUM: + return gl_error_bit::kInvalidEnum; + case GL_INVALID_VALUE: + return gl_error_bit::kInvalidValue; + case GL_INVALID_OPERATION: + return gl_error_bit::kInvalidOperation; + case GL_OUT_OF_MEMORY: + return gl_error_bit::kOutOfMemory; + case GL_INVALID_FRAMEBUFFER_OPERATION: + return gl_error_bit::kInvalidFrameBufferOperation; + default: + NOTREACHED(); + return gl_error_bit::kNoError; + } +} + +uint32 GLES2Util::GLErrorBitToGLError(uint32 error_bit) { + switch (error_bit) { + case gl_error_bit::kInvalidEnum: + return GL_INVALID_ENUM; + case gl_error_bit::kInvalidValue: + return GL_INVALID_VALUE; + case gl_error_bit::kInvalidOperation: + return GL_INVALID_OPERATION; + case gl_error_bit::kOutOfMemory: + return GL_OUT_OF_MEMORY; + case gl_error_bit::kInvalidFrameBufferOperation: + return GL_INVALID_FRAMEBUFFER_OPERATION; + default: + NOTREACHED(); + return GL_NO_ERROR; + } +} } // namespace gles2 } // namespace gpu |