diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 03:38:29 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 03:38:29 +0000 |
commit | 8eee29c0bad478d5a9e5daefc3882e11f7f26738 (patch) | |
tree | a75e0351d48f3deaec1b1a1f5de9c6903eee479d /gpu/command_buffer/client | |
parent | 10e457c06f9926bcd116e2314b6721437ee86e54 (diff) | |
download | chromium_src-8eee29c0bad478d5a9e5daefc3882e11f7f26738.zip chromium_src-8eee29c0bad478d5a9e5daefc3882e11f7f26738.tar.gz chromium_src-8eee29c0bad478d5a9e5daefc3882e11f7f26738.tar.bz2 |
Adds error messages for synthesized gl errors.
The next step would be to expose the service side
once to the client but this step just adds the
strings.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/1699022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/client')
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 63 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.h | 12 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_autogen.h | 28 |
3 files changed, 61 insertions, 42 deletions
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 7ab7c0a..0df4121 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -418,7 +418,10 @@ GLenum GLES2Implementation::GetGLError() { return error; } -void GLES2Implementation::SetGLError(GLenum error) { +void GLES2Implementation::SetGLError(GLenum error, const char* msg) { + if (msg) { + last_error_ = msg; + } error_bits_ |= GLES2Util::GLErrorToErrorBit(error); } @@ -510,7 +513,7 @@ void GLES2Implementation::SetBucketAsString( void GLES2Implementation::DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices) { if (count < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glDrawElements: count less than 0."); return; } if (count == 0) { @@ -632,8 +635,12 @@ GLint GLES2Implementation::GetUniformLocation( void GLES2Implementation::ShaderBinary( GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) { - if (n < 0 || length < 0) { - SetGLError(GL_INVALID_VALUE); + if (n < 0) { + SetGLError(GL_INVALID_VALUE, "glShaderBinary n < 0."); + return; + } + if (length < 0) { + SetGLError(GL_INVALID_VALUE, "glShaderBinary length < 0."); return; } GLsizei shader_id_size = n * sizeof(*shaders); @@ -687,8 +694,12 @@ void GLES2Implementation::VertexAttribPointer( void GLES2Implementation::ShaderSource( GLuint shader, GLsizei count, const char** source, const GLint* length) { - if (count < 0 || shader == 0) { - SetGLError(GL_INVALID_VALUE); + if (count < 0) { + SetGLError(GL_INVALID_VALUE, "glShaderSource count < 0"); + return; + } + if (shader == 0) { + SetGLError(GL_INVALID_VALUE, "glShaderSource shader == 0"); return; } @@ -697,7 +708,7 @@ void GLES2Implementation::ShaderSource( for (GLsizei ii = 0; ii < count; ++ii) { // I shouldn't have to check for this. The spec doesn't allow this if (!source[ii]) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glShaderSource: null passed for string."); return; } total_size += (length && length[ii] >= 0) ? length[ii] : strlen(source[ii]); @@ -749,7 +760,7 @@ void GLES2Implementation::BufferSubData( } if (size < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glBufferSubData: size < 0"); return; } @@ -773,7 +784,7 @@ void GLES2Implementation::CompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei image_size, const void* data) { if (width < 0 || height < 0 || level < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glCompressedTexImage2D dimension < 0"); return; } if (height == 0 || width == 0) { @@ -796,7 +807,7 @@ void GLES2Implementation::CompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei image_size, const void* data) { if (width < 0 || height < 0 || level < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D dimension < 0"); return; } // TODO(gman): Switch to use buckets always or at least if no room in shared @@ -817,13 +828,13 @@ void GLES2Implementation::TexImage2D( GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) { if (level < 0 || height < 0 || width < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glTexImage2D dimension < 0"); return; } uint32 size; if (!GLES2Util::ComputeImageDataSize( width, height, format, type, unpack_alignment_, &size)) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glTexImage2D: image size too large"); return; } helper_->TexImage2D( @@ -837,7 +848,7 @@ void GLES2Implementation::TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) { if (level < 0 || height < 0 || width < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glTexSubImage2D dimension < 0"); return; } if (height == 0 || width == 0) { @@ -848,18 +859,18 @@ void GLES2Implementation::TexSubImage2D( uint32 temp_size; if (!GLES2Util::ComputeImageDataSize( width, 1, format, type, unpack_alignment_, &temp_size)) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: size to large"); return; } GLsizeiptr unpadded_row_size = temp_size; if (!GLES2Util::ComputeImageDataSize( width, 2, format, type, unpack_alignment_, &temp_size)) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: size to large"); return; } GLsizeiptr padded_row_size = temp_size - unpadded_row_size; if (padded_row_size < 0 || unpadded_row_size < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: size to large"); return; } @@ -914,7 +925,7 @@ void GLES2Implementation::GetActiveAttrib( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { if (bufsize < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); return; } // Clear the bucket so if we the command fails nothing will be in it. @@ -954,7 +965,7 @@ void GLES2Implementation::GetActiveUniform( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { if (bufsize < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); return; } // Clear the bucket so if we the command fails nothing will be in it. @@ -993,7 +1004,7 @@ void GLES2Implementation::GetActiveUniform( void GLES2Implementation::GetAttachedShaders( GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { if (maxcount < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0"); return; } typedef gles2::GetAttachedShaders::Result Result; @@ -1081,7 +1092,7 @@ void GLES2Implementation::ReadPixels( GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) { if (width < 0 || height < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions < 0"); return; } if (width == 0 || height == 0) { @@ -1101,18 +1112,18 @@ void GLES2Implementation::ReadPixels( uint32 temp_size; if (!GLES2Util::ComputeImageDataSize( width, 1, format, type, pack_alignment_, &temp_size)) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glReadPixels: size too large."); return; } GLsizeiptr unpadded_row_size = temp_size; if (!GLES2Util::ComputeImageDataSize( width, 2, format, type, pack_alignment_, &temp_size)) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glReadPixels: size too large."); return; } GLsizeiptr padded_row_size = temp_size - unpadded_row_size; if (padded_row_size < 0 || unpadded_row_size < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glReadPixels: size too large."); return; } // Check if we have enough space to transfer at least an entire row. @@ -1205,7 +1216,7 @@ bool GLES2Implementation::IsBufferReservedId(GLuint) { // NOLINT void GLES2Implementation::BindBuffer(GLenum target, GLuint buffer) { if (IsBufferReservedId(buffer)) { - SetGLError(GL_INVALID_OPERATION); + SetGLError(GL_INVALID_OPERATION, "glBindBuffer: reserved buffer id"); return; } if (buffer != 0) { @@ -1253,7 +1264,7 @@ void GLES2Implementation::EnableVertexAttribArray(GLuint index) { void GLES2Implementation::DrawArrays(GLenum mode, GLint first, GLsizei count) { if (count < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glDrawArrays: count < 0"); return; } bool have_client_side = @@ -1299,7 +1310,7 @@ bool GLES2Implementation::GetVertexAttribHelper( case GL_CURRENT_VERTEX_ATTRIB: return false; // pass through to service side. default: - SetGLError(GL_INVALID_ENUM); + SetGLError(GL_INVALID_ENUM, "glGetVertexAttrib: invalid enum"); break; } return true; diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 7d52485..4d0e53e 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -75,7 +75,7 @@ class GLES2Implementation { #else void BindBuffer(GLenum target, GLuint buffer) { if (IsReservedId(buffer)) { - SetGLError(GL_INVALID_OPERATION); + SetGLError(GL_INVALID_OPERATION, "glBindBuffer: reserved buffer id"); return; } if (buffer != 0) { @@ -95,7 +95,7 @@ class GLES2Implementation { void DrawArrays(GLenum mode, GLint first, GLsizei count) { if (count < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glDrawArrays: count < 0"); return; } helper_->DrawArrays(mode, first, count); @@ -184,7 +184,12 @@ class GLES2Implementation { GLenum GetGLError(); // Sets our wrapper for the GLError. - void SetGLError(GLenum error); + void SetGLError(GLenum error, const char* msg); + + // Returns the last error and clears it. Useful for debugging. + const std::string& GetLastError() { + return last_error_; + } // Waits for all commands to execute. void WaitForCmd(); @@ -235,6 +240,7 @@ class GLES2Implementation { int transfer_buffer_id_; void* result_buffer_; uint32 result_shm_offset_; + std::string last_error_; // pack alignment as last set by glPixelStorei GLint pack_alignment_; diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index c755807..06bcdcc 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -21,7 +21,8 @@ void BindAttribLocation(GLuint program, GLuint index, const char* name); void BindFramebuffer(GLenum target, GLuint framebuffer) { if (IsFramebufferReservedId(framebuffer)) { - SetGLError(GL_INVALID_OPERATION); + SetGLError( + GL_INVALID_OPERATION, "BindFramebuffer: framebuffer reserved id"); return; } if (framebuffer != 0) { @@ -32,7 +33,8 @@ void BindFramebuffer(GLenum target, GLuint framebuffer) { void BindRenderbuffer(GLenum target, GLuint renderbuffer) { if (IsRenderbufferReservedId(renderbuffer)) { - SetGLError(GL_INVALID_OPERATION); + SetGLError( + GL_INVALID_OPERATION, "BindRenderbuffer: renderbuffer reserved id"); return; } if (renderbuffer != 0) { @@ -43,7 +45,7 @@ void BindRenderbuffer(GLenum target, GLuint renderbuffer) { void BindTexture(GLenum target, GLuint texture) { if (IsTextureReservedId(texture)) { - SetGLError(GL_INVALID_OPERATION); + SetGLError(GL_INVALID_OPERATION, "BindTexture: texture reserved id"); return; } if (texture != 0) { @@ -126,11 +128,11 @@ void CopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { if (width < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glCopyTexImage2D: width < 0"); return; } if (height < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glCopyTexImage2D: height < 0"); return; } helper_->CopyTexImage2D( @@ -141,11 +143,11 @@ void CopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { if (width < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glCopyTexSubImage2D: width < 0"); return; } if (height < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glCopyTexSubImage2D: height < 0"); return; } helper_->CopyTexSubImage2D( @@ -527,11 +529,11 @@ void ReleaseShaderCompiler() { void RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { if (width < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glRenderbufferStorage: width < 0"); return; } if (height < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glRenderbufferStorage: height < 0"); return; } helper_->RenderbufferStorage(target, internalformat, width, height); @@ -543,11 +545,11 @@ void SampleCoverage(GLclampf value, GLboolean invert) { void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { if (width < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glScissor: width < 0"); return; } if (height < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glScissor: height < 0"); return; } helper_->Scissor(x, y, width, height); @@ -734,11 +736,11 @@ void VertexAttribPointer( void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { if (width < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glViewport: width < 0"); return; } if (height < 0) { - SetGLError(GL_INVALID_VALUE); + SetGLError(GL_INVALID_VALUE, "glViewport: height < 0"); return; } helper_->Viewport(x, y, width, height); |