summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-04 16:06:33 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-04 16:06:33 +0000
commit1fd26d8cdd166ec84c06bb7d4a8557293428fc0e (patch)
tree0b13a905aca8eadaa69f7b0a7c246d937e51a5a3 /gpu
parent162ac0f02a2a7a6f1909a85a222ab5da3d280d12 (diff)
downloadchromium_src-1fd26d8cdd166ec84c06bb7d4a8557293428fc0e.zip
chromium_src-1fd26d8cdd166ec84c06bb7d4a8557293428fc0e.tar.gz
chromium_src-1fd26d8cdd166ec84c06bb7d4a8557293428fc0e.tar.bz2
Fix a bug with count on commands that take a count
and add some more DCHECKs Some commands should never have a negative count since the count refers to how much memory to access. So, made those commands check for negative count on the client side and kill the GPU process if they are negative on the service side. Note: Someone (me?) checked in a version of build_gles2_cmd_buffer.py that generates a Finish handler that actually calls glFinish but didn't check in the generated code. Should I put that back to glFlush? TEST=ran unit tests and opengl es 2.0 conformance tests BUG=none Review URL: http://codereview.chromium.org/4461001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65063 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py141
-rw-r--r--gpu/command_buffer/client/gles2_implementation_autogen.h50
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc9
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_autogen.h198
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h2
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h40
-rw-r--r--gpu/command_buffer/service/program_manager.cc25
7 files changed, 199 insertions, 266 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 5b5aec1..cf88bd9 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -80,12 +80,12 @@ GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenumTextureTarget tar
GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenumShaderType type);
GL_APICALL void GL_APIENTRY glCullFace (GLenumFaceType mode);
-GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
-GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
+GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizeiNotNegative n, const GLuint* buffers);
+GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizeiNotNegative n, const GLuint* framebuffers);
GL_APICALL void GL_APIENTRY glDeleteProgram (GLidProgram program);
-GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
+GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizeiNotNegative n, const GLuint* renderbuffers);
GL_APICALL void GL_APIENTRY glDeleteShader (GLidShader shader);
-GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
+GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizeiNotNegative n, const GLuint* textures);
GL_APICALL void GL_APIENTRY glDepthFunc (GLenumCmpFunction func);
GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
@@ -101,14 +101,14 @@ GL_APICALL void GL_APIENTRY glFlush (void);
GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenumFrameBufferTarget target, GLenumAttachment attachment, GLenumRenderBufferTarget renderbuffertarget, GLidRenderbuffer renderbuffer);
GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenumFrameBufferTarget target, GLenumAttachment attachment, GLenumTextureTarget textarget, GLidTexture texture, GLint level);
GL_APICALL void GL_APIENTRY glFrontFace (GLenumFaceMode mode);
-GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
+GL_APICALL void GL_APIENTRY glGenBuffers (GLsizeiNotNegative n, GLuint* buffers);
GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenumTextureBindTarget target);
-GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
-GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
-GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
-GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLidProgram program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
-GL_APICALL void GL_APIENTRY glGetActiveUniform (GLidProgram program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
-GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLidProgram program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizeiNotNegative n, GLuint* framebuffers);
+GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizeiNotNegative n, GLuint* renderbuffers);
+GL_APICALL void GL_APIENTRY glGenTextures (GLsizeiNotNegative n, GLuint* textures);
+GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLidProgram program, GLuint index, GLsizeiNotNegative bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+GL_APICALL void GL_APIENTRY glGetActiveUniform (GLidProgram program, GLuint index, GLsizeiNotNegative bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLidProgram program, GLsizeiNotNegative maxcount, GLsizei* count, GLuint* shaders);
GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLidProgram program, const char* name);
GL_APICALL void GL_APIENTRY glGetBooleanv (GLenumGLState pname, GLboolean* params);
GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenumBufferTarget target, GLenumBufferParameter pname, GLint* params);
@@ -117,12 +117,12 @@ GL_APICALL void GL_APIENTRY glGetFloatv (GLenumGLState pname, GLfloat* p
GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenumFrameBufferTarget target, GLenumAttachment attachment, GLenumFrameBufferParameter pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetIntegerv (GLenumGLState pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetProgramiv (GLidProgram program, GLenumProgramParameter pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLidProgram program, GLsizei bufsize, GLsizei* length, char* infolog);
+GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLidProgram program, GLsizeiNotNegative bufsize, GLsizei* length, char* infolog);
GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenumRenderBufferTarget target, GLenumRenderBufferParameter pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetShaderiv (GLidShader shader, GLenumShaderParameter pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLidShader shader, GLsizei bufsize, GLsizei* length, char* infolog);
+GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLidShader shader, GLsizeiNotNegative bufsize, GLsizei* length, char* infolog);
GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenumShaderType shadertype, GLenumShaderPrecision precisiontype, GLint* range, GLint* precision);
-GL_APICALL void GL_APIENTRY glGetShaderSource (GLidShader shader, GLsizei bufsize, GLsizei* length, char* source);
+GL_APICALL void GL_APIENTRY glGetShaderSource (GLidShader shader, GLsizeiNotNegative bufsize, GLsizei* length, char* source);
GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenumStringType name);
GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenumTextureTarget target, GLenumTextureParameter pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenumTextureTarget target, GLenumTextureParameter pname, GLint* params);
@@ -149,8 +149,8 @@ GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenumRenderBufferTarget target, GLenumRenderBufferFormat internalformat, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length);
-GL_APICALL void GL_APIENTRY glShaderSource (GLidShader shader, GLsizei count, const char** str, const GLint* length);
+GL_APICALL void GL_APIENTRY glShaderBinary (GLsizeiNotNegative n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizeiNotNegative length);
+GL_APICALL void GL_APIENTRY glShaderSource (GLidShader shader, GLsizeiNotNegative count, const char** str, const GLint* length);
GL_APICALL void GL_APIENTRY glStencilFunc (GLenumCmpFunction func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenumFaceType face, GLenumCmpFunction func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
@@ -164,24 +164,24 @@ GL_APICALL void GL_APIENTRY glTexParameteri (GLenumTextureBindTarget tar
GL_APICALL void GL_APIENTRY glTexParameteriv (GLenumTextureBindTarget target, GLenumTextureParameter pname, const GLint* params);
GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenumTextureTarget target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenumTextureFormat format, GLenumPixelType type, const void* pixels);
GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x);
-GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizeiNotNegative count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x);
-GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizeiNotNegative count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
-GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizeiNotNegative count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
-GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizeiNotNegative count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
-GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizeiNotNegative count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
-GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizeiNotNegative count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizeiNotNegative count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
-GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
-GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLbooleanFalseOnly transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLbooleanFalseOnly transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLbooleanFalseOnly transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizeiNotNegative count, const GLint* v);
+GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizeiNotNegative count, GLbooleanFalseOnly transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizeiNotNegative count, GLbooleanFalseOnly transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizeiNotNegative count, GLbooleanFalseOnly transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUseProgram (GLidZeroProgram program);
GL_APICALL void GL_APIENTRY glValidateProgram (GLidProgram program);
GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
@@ -199,9 +199,9 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenumR
// Non-GL commands.
GL_APICALL void GL_APIENTRY glSwapBuffers (void);
GL_APICALL GLuint GL_APIENTRY glGetMaxValueInBuffer (GLidBuffer buffer_id, GLsizei count, GLenumGetMaxIndexType type, GLuint offset);
-GL_APICALL void GL_APIENTRY glGenSharedIds (GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids);
-GL_APICALL void GL_APIENTRY glDeleteSharedIds (GLuint namespace_id, GLsizei n, const GLuint* ids);
-GL_APICALL void GL_APIENTRY glRegisterSharedIds (GLuint namespace_id, GLsizei n, const GLuint* ids);
+GL_APICALL void GL_APIENTRY glGenSharedIds (GLuint namespace_id, GLuint id_offset, GLsizeiNotNegative n, GLuint* ids);
+GL_APICALL void GL_APIENTRY glDeleteSharedIds (GLuint namespace_id, GLsizeiNotNegative n, const GLuint* ids);
+GL_APICALL void GL_APIENTRY glRegisterSharedIds (GLuint namespace_id, GLsizeiNotNegative n, const GLuint* ids);
GL_APICALL GLboolean GL_APIENTRY glCommandBufferEnable (const char* feature);
GL_APICALL void* GL_APIENTRY glMapBufferSubData (GLuint target, GLintptr offset, GLsizeiptr size, GLenum access);
GL_APICALL void GL_APIENTRY glUnmapBufferSubData (const void* mem);
@@ -2551,24 +2551,23 @@ class GENnHandler(TypeHandler):
def WriteGLES2ImplementationHeader(self, func, file):
"""Overrriden from TypeHandler."""
- code = """%(return_type)s %(name)s(%(typed_args)s) {
- if (%(count_name)s < 0) {
- SetGLError(GL_INVALID_VALUE, "gl%(name)s: n < 0");
- return;
- }
- %(resource_type)s_id_handler_->MakeIds(0, %(args)s);
- helper_->%(name)sImmediate(%(args)s);
-}
-
-"""
- file.Write(code % {
+ args = {
'return_type': func.return_type,
'name': func.original_name,
'typed_args': func.MakeTypedOriginalArgString(""),
'args': func.MakeOriginalArgString(""),
'resource_type': func.name[3:-1].lower(),
'count_name': func.GetOriginalArgs()[0].name,
- })
+ }
+ file.Write("%(return_type)s %(name)s(%(typed_args)s) {\n" % args)
+ for arg in func.GetOriginalArgs():
+ arg.WriteClientSideValidationCode(file, func)
+ code = """ %(resource_type)s_id_handler_->MakeIds(0, %(args)s);
+ helper_->%(name)sImmediate(%(args)s);
+}
+
+"""
+ file.Write(code % args)
def WriteServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
@@ -2789,6 +2788,8 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
file.Write("%s %s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
+ for arg in func.GetOriginalArgs():
+ arg.WriteClientSideValidationCode(file, func)
file.Write(" GLuint client_id;\n")
file.Write(" program_and_shader_id_handler_->MakeIds(0, 1, &client_id);\n")
file.Write(" helper_->%s(%s);\n" %
@@ -2813,6 +2814,8 @@ class DeleteHandler(TypeHandler):
file.Write("%s %s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
+ for arg in func.GetOriginalArgs():
+ arg.WriteClientSideValidationCode(file, func)
file.Write(" program_and_shader_id_handler_->FreeIds(1, &%s);\n" %
func.GetOriginalArgs()[-1].name)
file.Write(" helper_->%s(%s);\n" %
@@ -2919,24 +2922,23 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs) {
"""Overrriden from TypeHandler."""
impl_decl = func.GetInfo('impl_decl')
if impl_decl == None or impl_decl == True:
- code = """%(return_type)s %(name)s(%(typed_args)s) {
- if (%(count_name)s < 0) {
- SetGLError(GL_INVALID_VALUE, "gl%(name)s: n < 0");
- return;
- }
- %(resource_type)s_id_handler_->FreeIds(%(args)s);
- helper_->%(name)sImmediate(%(args)s);
-}
-
-"""
- file.Write(code % {
+ args = {
'return_type': func.return_type,
'name': func.original_name,
'typed_args': func.MakeTypedOriginalArgString(""),
'args': func.MakeOriginalArgString(""),
'resource_type': func.name[6:-1].lower(),
'count_name': func.GetOriginalArgs()[0].name,
- })
+ }
+ file.Write("%(return_type)s %(name)s(%(typed_args)s) {\n" % args)
+ for arg in func.GetOriginalArgs():
+ arg.WriteClientSideValidationCode(file, func)
+ code = """%(resource_type)s_id_handler_->FreeIds(%(args)s);
+ helper_->%(name)sImmediate(%(args)s);
+}
+
+"""
+ file.Write(code % args)
def WriteImmediateCmdComputeSize(self, func, file):
"""Overrriden from TypeHandler."""
@@ -3096,6 +3098,8 @@ class GETnHandler(TypeHandler):
file.Write("%s %s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
+ for arg in func.GetOriginalArgs():
+ arg.WriteClientSideValidationCode(file, func)
all_but_last_args = func.GetOriginalArgs()[:-1]
arg_string = (
", ".join(["%s" % arg.name for arg in all_but_last_args]))
@@ -3239,6 +3243,8 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
file.Write("%s %s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
+ for arg in func.GetOriginalArgs():
+ arg.WriteClientSideValidationCode(file, func)
file.Write(" helper_->%sImmediate(%s);\n" %
(func.name, func.MakeOriginalArgString("")))
file.Write("}\n")
@@ -3403,7 +3409,7 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
def WriteGetDataSizeCode(self, func, file):
"""Overrriden from TypeHandler."""
code = """ uint32 data_size;
- if (!ComputeDataSize(1, sizeof(%s), %d, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(%s), %d, &data_size)) {
return error::kOutOfBounds;
}
"""
@@ -3418,6 +3424,8 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
file.Write("%s %s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
+ for arg in func.GetOriginalArgs():
+ arg.WriteClientSideValidationCode(file, func)
file.Write(" helper_->%sImmediate(%s);\n" %
(func.name, func.MakeOriginalArgString("")))
file.Write("}\n")
@@ -4037,6 +4045,27 @@ class SizeArgument(Argument):
file.Write(" return;\n")
file.Write(" }\n")
+
+class SizeNotNegativeArgument(SizeArgument):
+ """class for GLsizeiNotNegative. It's NEVER allowed to be negative"""
+
+ def __init__(self, name, type):
+ SizeArgument.__init__(self, name, "GLsizei")
+
+ def GetInvalidArg(self, offset, index):
+ """overridden from SizeArgument."""
+ return ("-1", "kOutOfBounds", "GL_NO_ERROR")
+
+ def WriteValidationCode(self, file, func):
+ """overridden from SizeArgument."""
+ pass
+ #file.Write(" if (%s < 0) {\n" % self.name)
+ #file.Write(" SetGLError(GL_INVALID_VALUE, \"gl%s: %s < 0\");\n" %
+ # (func.original_name, self.name))
+ #file.Write(" return error::kNoError;\n")
+ #file.Write(" }\n")
+
+
class EnumBaseArgument(Argument):
"""Base class for EnumArgument, IntArgument and BoolArgument"""
@@ -4737,6 +4766,8 @@ def CreateArg(arg_string):
elif (arg_parts[0].startswith('GLint') and len(arg_parts[0]) > 5 and
arg_parts[0] != "GLintptr"):
return IntArgument(arg_parts[-1], " ".join(arg_parts[0:-1]))
+ elif arg_parts[0].startswith('GLsizeiNotNegative'):
+ return SizeNotNegativeArgument(arg_parts[-1], " ".join(arg_parts[0:-1]))
elif arg_parts[0].startswith('GLsize'):
return SizeArgument(arg_parts[-1], " ".join(arg_parts[0:-1]))
else:
diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h
index 813dbce..16ef2ee 100644
--- a/gpu/command_buffer/client/gles2_implementation_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_autogen.h
@@ -171,7 +171,7 @@ void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) {
SetGLError(GL_INVALID_VALUE, "glDeleteFramebuffers: n < 0");
return;
}
- framebuffer_id_handler_->FreeIds(n, framebuffers);
+framebuffer_id_handler_->FreeIds(n, framebuffers);
helper_->DeleteFramebuffersImmediate(n, framebuffers);
}
@@ -185,7 +185,7 @@ void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) {
SetGLError(GL_INVALID_VALUE, "glDeleteRenderbuffers: n < 0");
return;
}
- renderbuffer_id_handler_->FreeIds(n, renderbuffers);
+renderbuffer_id_handler_->FreeIds(n, renderbuffers);
helper_->DeleteRenderbuffersImmediate(n, renderbuffers);
}
@@ -199,7 +199,7 @@ void DeleteTextures(GLsizei n, const GLuint* textures) {
SetGLError(GL_INVALID_VALUE, "glDeleteTextures: n < 0");
return;
}
- texture_id_handler_->FreeIds(n, textures);
+texture_id_handler_->FreeIds(n, textures);
helper_->DeleteTexturesImmediate(n, textures);
}
@@ -640,6 +640,10 @@ void Uniform1f(GLint location, GLfloat x) {
}
void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniform1fv: count < 0");
+ return;
+ }
helper_->Uniform1fvImmediate(location, count, v);
}
@@ -648,6 +652,10 @@ void Uniform1i(GLint location, GLint x) {
}
void Uniform1iv(GLint location, GLsizei count, const GLint* v) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniform1iv: count < 0");
+ return;
+ }
helper_->Uniform1ivImmediate(location, count, v);
}
@@ -656,6 +664,10 @@ void Uniform2f(GLint location, GLfloat x, GLfloat y) {
}
void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniform2fv: count < 0");
+ return;
+ }
helper_->Uniform2fvImmediate(location, count, v);
}
@@ -664,6 +676,10 @@ void Uniform2i(GLint location, GLint x, GLint y) {
}
void Uniform2iv(GLint location, GLsizei count, const GLint* v) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniform2iv: count < 0");
+ return;
+ }
helper_->Uniform2ivImmediate(location, count, v);
}
@@ -672,6 +688,10 @@ void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) {
}
void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniform3fv: count < 0");
+ return;
+ }
helper_->Uniform3fvImmediate(location, count, v);
}
@@ -680,6 +700,10 @@ void Uniform3i(GLint location, GLint x, GLint y, GLint z) {
}
void Uniform3iv(GLint location, GLsizei count, const GLint* v) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniform3iv: count < 0");
+ return;
+ }
helper_->Uniform3ivImmediate(location, count, v);
}
@@ -688,6 +712,10 @@ void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
}
void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniform4fv: count < 0");
+ return;
+ }
helper_->Uniform4fvImmediate(location, count, v);
}
@@ -696,21 +724,37 @@ void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) {
}
void Uniform4iv(GLint location, GLsizei count, const GLint* v) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniform4iv: count < 0");
+ return;
+ }
helper_->Uniform4ivImmediate(location, count, v);
}
void UniformMatrix2fv(
GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniformMatrix2fv: count < 0");
+ return;
+ }
helper_->UniformMatrix2fvImmediate(location, count, transpose, value);
}
void UniformMatrix3fv(
GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniformMatrix3fv: count < 0");
+ return;
+ }
helper_->UniformMatrix3fvImmediate(location, count, transpose, value);
}
void UniformMatrix4fv(
GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glUniformMatrix4fv: count < 0");
+ return;
+ }
helper_->UniformMatrix4fvImmediate(location, count, transpose, value);
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 4d2cf89..8f0d96b 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -4072,10 +4072,13 @@ void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
// All translated shaders must compile.
LOG_IF(ERROR, use_shader_translator_)
<< "Shader translator allowed/produced an invalid shader.";
+ GLint max_len = 0;
+ glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &max_len);
+ scoped_array<char> temp(new char[max_len]);
GLint len = 0;
- glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &len);
- scoped_array<char> temp(new char[len]);
- glGetShaderInfoLog(info->service_id(), len, &len, temp.get());
+ glGetShaderInfoLog(info->service_id(), max_len, &len, temp.get());
+ DCHECK(max_len == 0 || len < max_len);
+ DCHECK(len ==0 || temp[len] == '\0');
info->SetStatus(false, std::string(temp.get(), len));
}
};
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
index 1c38459..9ca83c5 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -453,10 +453,6 @@ error::Error GLES2DecoderImpl::HandleDeleteBuffers(
}
const GLuint* buffers = GetSharedMemoryAs<const GLuint*>(
c.buffers_shm_id, c.buffers_shm_offset, data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glDeleteBuffers: n < 0");
- return error::kNoError;
- }
if (buffers == NULL) {
return error::kOutOfBounds;
}
@@ -473,10 +469,6 @@ error::Error GLES2DecoderImpl::HandleDeleteBuffersImmediate(
}
const GLuint* buffers = GetImmediateDataAs<const GLuint*>(
c, data_size, immediate_data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glDeleteBuffers: n < 0");
- return error::kNoError;
- }
if (buffers == NULL) {
return error::kOutOfBounds;
}
@@ -493,10 +485,6 @@ error::Error GLES2DecoderImpl::HandleDeleteFramebuffers(
}
const GLuint* framebuffers = GetSharedMemoryAs<const GLuint*>(
c.framebuffers_shm_id, c.framebuffers_shm_offset, data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glDeleteFramebuffers: n < 0");
- return error::kNoError;
- }
if (framebuffers == NULL) {
return error::kOutOfBounds;
}
@@ -513,10 +501,6 @@ error::Error GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
}
const GLuint* framebuffers = GetImmediateDataAs<const GLuint*>(
c, data_size, immediate_data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glDeleteFramebuffers: n < 0");
- return error::kNoError;
- }
if (framebuffers == NULL) {
return error::kOutOfBounds;
}
@@ -533,10 +517,6 @@ error::Error GLES2DecoderImpl::HandleDeleteRenderbuffers(
}
const GLuint* renderbuffers = GetSharedMemoryAs<const GLuint*>(
c.renderbuffers_shm_id, c.renderbuffers_shm_offset, data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glDeleteRenderbuffers: n < 0");
- return error::kNoError;
- }
if (renderbuffers == NULL) {
return error::kOutOfBounds;
}
@@ -553,10 +533,6 @@ error::Error GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
}
const GLuint* renderbuffers = GetImmediateDataAs<const GLuint*>(
c, data_size, immediate_data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glDeleteRenderbuffers: n < 0");
- return error::kNoError;
- }
if (renderbuffers == NULL) {
return error::kOutOfBounds;
}
@@ -573,10 +549,6 @@ error::Error GLES2DecoderImpl::HandleDeleteTextures(
}
const GLuint* textures = GetSharedMemoryAs<const GLuint*>(
c.textures_shm_id, c.textures_shm_offset, data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glDeleteTextures: n < 0");
- return error::kNoError;
- }
if (textures == NULL) {
return error::kOutOfBounds;
}
@@ -593,10 +565,6 @@ error::Error GLES2DecoderImpl::HandleDeleteTexturesImmediate(
}
const GLuint* textures = GetImmediateDataAs<const GLuint*>(
c, data_size, immediate_data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glDeleteTextures: n < 0");
- return error::kNoError;
- }
if (textures == NULL) {
return error::kOutOfBounds;
}
@@ -693,7 +661,7 @@ error::Error GLES2DecoderImpl::HandleEnableVertexAttribArray(
error::Error GLES2DecoderImpl::HandleFinish(
uint32 immediate_data_size, const gles2::Finish& c) {
- glFlush();
+ glFinish();
return error::kNoError;
}
@@ -777,10 +745,6 @@ error::Error GLES2DecoderImpl::HandleGenBuffers(
}
GLuint* buffers = GetSharedMemoryAs<GLuint*>(
c.buffers_shm_id, c.buffers_shm_offset, data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glGenBuffers: n < 0");
- return error::kNoError;
- }
if (buffers == NULL) {
return error::kOutOfBounds;
}
@@ -799,10 +763,6 @@ error::Error GLES2DecoderImpl::HandleGenBuffersImmediate(
}
GLuint* buffers = GetImmediateDataAs<GLuint*>(
c, data_size, immediate_data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glGenBuffers: n < 0");
- return error::kNoError;
- }
if (buffers == NULL) {
return error::kOutOfBounds;
}
@@ -832,10 +792,6 @@ error::Error GLES2DecoderImpl::HandleGenFramebuffers(
}
GLuint* framebuffers = GetSharedMemoryAs<GLuint*>(
c.framebuffers_shm_id, c.framebuffers_shm_offset, data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glGenFramebuffers: n < 0");
- return error::kNoError;
- }
if (framebuffers == NULL) {
return error::kOutOfBounds;
}
@@ -854,10 +810,6 @@ error::Error GLES2DecoderImpl::HandleGenFramebuffersImmediate(
}
GLuint* framebuffers = GetImmediateDataAs<GLuint*>(
c, data_size, immediate_data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glGenFramebuffers: n < 0");
- return error::kNoError;
- }
if (framebuffers == NULL) {
return error::kOutOfBounds;
}
@@ -876,10 +828,6 @@ error::Error GLES2DecoderImpl::HandleGenRenderbuffers(
}
GLuint* renderbuffers = GetSharedMemoryAs<GLuint*>(
c.renderbuffers_shm_id, c.renderbuffers_shm_offset, data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glGenRenderbuffers: n < 0");
- return error::kNoError;
- }
if (renderbuffers == NULL) {
return error::kOutOfBounds;
}
@@ -898,10 +846,6 @@ error::Error GLES2DecoderImpl::HandleGenRenderbuffersImmediate(
}
GLuint* renderbuffers = GetImmediateDataAs<GLuint*>(
c, data_size, immediate_data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glGenRenderbuffers: n < 0");
- return error::kNoError;
- }
if (renderbuffers == NULL) {
return error::kOutOfBounds;
}
@@ -920,10 +864,6 @@ error::Error GLES2DecoderImpl::HandleGenTextures(
}
GLuint* textures = GetSharedMemoryAs<GLuint*>(
c.textures_shm_id, c.textures_shm_offset, data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glGenTextures: n < 0");
- return error::kNoError;
- }
if (textures == NULL) {
return error::kOutOfBounds;
}
@@ -942,10 +882,6 @@ error::Error GLES2DecoderImpl::HandleGenTexturesImmediate(
}
GLuint* textures = GetImmediateDataAs<GLuint*>(
c, data_size, immediate_data_size);
- if (n < 0) {
- SetGLError(GL_INVALID_VALUE, "glGenTextures: n < 0");
- return error::kNoError;
- }
if (textures == NULL) {
return error::kOutOfBounds;
}
@@ -1921,15 +1857,11 @@ error::Error GLES2DecoderImpl::HandleUniform1fv(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) {
return error::kOutOfBounds;
}
const GLfloat* v = GetSharedMemoryAs<const GLfloat*>(
c.v_shm_id, c.v_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform1fv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -1942,7 +1874,7 @@ error::Error GLES2DecoderImpl::HandleUniform1fvImmediate(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -1950,10 +1882,6 @@ error::Error GLES2DecoderImpl::HandleUniform1fvImmediate(
}
const GLfloat* v = GetImmediateDataAs<const GLfloat*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform1fv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -1974,15 +1902,11 @@ error::Error GLES2DecoderImpl::HandleUniform1iv(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) {
return error::kOutOfBounds;
}
const GLint* v = GetSharedMemoryAs<const GLint*>(
c.v_shm_id, c.v_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform1iv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -1995,7 +1919,7 @@ error::Error GLES2DecoderImpl::HandleUniform1ivImmediate(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2003,10 +1927,6 @@ error::Error GLES2DecoderImpl::HandleUniform1ivImmediate(
}
const GLint* v = GetImmediateDataAs<const GLint*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform1iv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2029,15 +1949,11 @@ error::Error GLES2DecoderImpl::HandleUniform2fv(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 2, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) {
return error::kOutOfBounds;
}
const GLfloat* v = GetSharedMemoryAs<const GLfloat*>(
c.v_shm_id, c.v_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform2fv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2050,7 +1966,7 @@ error::Error GLES2DecoderImpl::HandleUniform2fvImmediate(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 2, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2058,10 +1974,6 @@ error::Error GLES2DecoderImpl::HandleUniform2fvImmediate(
}
const GLfloat* v = GetImmediateDataAs<const GLfloat*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform2fv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2083,15 +1995,11 @@ error::Error GLES2DecoderImpl::HandleUniform2iv(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLint), 2, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLint), 2, &data_size)) {
return error::kOutOfBounds;
}
const GLint* v = GetSharedMemoryAs<const GLint*>(
c.v_shm_id, c.v_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform2iv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2104,7 +2012,7 @@ error::Error GLES2DecoderImpl::HandleUniform2ivImmediate(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLint), 2, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLint), 2, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2112,10 +2020,6 @@ error::Error GLES2DecoderImpl::HandleUniform2ivImmediate(
}
const GLint* v = GetImmediateDataAs<const GLint*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform2iv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2139,15 +2043,11 @@ error::Error GLES2DecoderImpl::HandleUniform3fv(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 3, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) {
return error::kOutOfBounds;
}
const GLfloat* v = GetSharedMemoryAs<const GLfloat*>(
c.v_shm_id, c.v_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform3fv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2160,7 +2060,7 @@ error::Error GLES2DecoderImpl::HandleUniform3fvImmediate(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 3, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2168,10 +2068,6 @@ error::Error GLES2DecoderImpl::HandleUniform3fvImmediate(
}
const GLfloat* v = GetImmediateDataAs<const GLfloat*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform3fv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2194,15 +2090,11 @@ error::Error GLES2DecoderImpl::HandleUniform3iv(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLint), 3, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) {
return error::kOutOfBounds;
}
const GLint* v = GetSharedMemoryAs<const GLint*>(
c.v_shm_id, c.v_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform3iv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2215,7 +2107,7 @@ error::Error GLES2DecoderImpl::HandleUniform3ivImmediate(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLint), 3, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2223,10 +2115,6 @@ error::Error GLES2DecoderImpl::HandleUniform3ivImmediate(
}
const GLint* v = GetImmediateDataAs<const GLint*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform3iv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2251,15 +2139,11 @@ error::Error GLES2DecoderImpl::HandleUniform4fv(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
return error::kOutOfBounds;
}
const GLfloat* v = GetSharedMemoryAs<const GLfloat*>(
c.v_shm_id, c.v_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform4fv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2272,7 +2156,7 @@ error::Error GLES2DecoderImpl::HandleUniform4fvImmediate(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2280,10 +2164,6 @@ error::Error GLES2DecoderImpl::HandleUniform4fvImmediate(
}
const GLfloat* v = GetImmediateDataAs<const GLfloat*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform4fv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2307,15 +2187,11 @@ error::Error GLES2DecoderImpl::HandleUniform4iv(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) {
return error::kOutOfBounds;
}
const GLint* v = GetSharedMemoryAs<const GLint*>(
c.v_shm_id, c.v_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform4iv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2328,7 +2204,7 @@ error::Error GLES2DecoderImpl::HandleUniform4ivImmediate(
GLint location = static_cast<GLint>(c.location);
GLsizei count = static_cast<GLsizei>(c.count);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2336,10 +2212,6 @@ error::Error GLES2DecoderImpl::HandleUniform4ivImmediate(
}
const GLint* v = GetImmediateDataAs<const GLint*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniform4iv: count < 0");
- return error::kNoError;
- }
if (v == NULL) {
return error::kOutOfBounds;
}
@@ -2353,15 +2225,11 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix2fv(
GLsizei count = static_cast<GLsizei>(c.count);
GLboolean transpose = static_cast<GLboolean>(c.transpose);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
return error::kOutOfBounds;
}
const GLfloat* value = GetSharedMemoryAs<const GLfloat*>(
c.value_shm_id, c.value_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniformMatrix2fv: count < 0");
- return error::kNoError;
- }
if (!validators_->false_only.IsValid(transpose)) {
SetGLError(
GL_INVALID_VALUE, "glUniformMatrix2fv: transpose GL_INVALID_VALUE");
@@ -2380,7 +2248,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
GLsizei count = static_cast<GLsizei>(c.count);
GLboolean transpose = static_cast<GLboolean>(c.transpose);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2388,10 +2256,6 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
}
const GLfloat* value = GetImmediateDataAs<const GLfloat*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniformMatrix2fv: count < 0");
- return error::kNoError;
- }
if (!validators_->false_only.IsValid(transpose)) {
SetGLError(
GL_INVALID_VALUE, "glUniformMatrix2fv: transpose GL_INVALID_VALUE");
@@ -2410,15 +2274,11 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix3fv(
GLsizei count = static_cast<GLsizei>(c.count);
GLboolean transpose = static_cast<GLboolean>(c.transpose);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 9, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 9, &data_size)) {
return error::kOutOfBounds;
}
const GLfloat* value = GetSharedMemoryAs<const GLfloat*>(
c.value_shm_id, c.value_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniformMatrix3fv: count < 0");
- return error::kNoError;
- }
if (!validators_->false_only.IsValid(transpose)) {
SetGLError(
GL_INVALID_VALUE, "glUniformMatrix3fv: transpose GL_INVALID_VALUE");
@@ -2437,7 +2297,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
GLsizei count = static_cast<GLsizei>(c.count);
GLboolean transpose = static_cast<GLboolean>(c.transpose);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 9, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 9, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2445,10 +2305,6 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
}
const GLfloat* value = GetImmediateDataAs<const GLfloat*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniformMatrix3fv: count < 0");
- return error::kNoError;
- }
if (!validators_->false_only.IsValid(transpose)) {
SetGLError(
GL_INVALID_VALUE, "glUniformMatrix3fv: transpose GL_INVALID_VALUE");
@@ -2467,15 +2323,11 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix4fv(
GLsizei count = static_cast<GLsizei>(c.count);
GLboolean transpose = static_cast<GLboolean>(c.transpose);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 16, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 16, &data_size)) {
return error::kOutOfBounds;
}
const GLfloat* value = GetSharedMemoryAs<const GLfloat*>(
c.value_shm_id, c.value_shm_offset, data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniformMatrix4fv: count < 0");
- return error::kNoError;
- }
if (!validators_->false_only.IsValid(transpose)) {
SetGLError(
GL_INVALID_VALUE, "glUniformMatrix4fv: transpose GL_INVALID_VALUE");
@@ -2494,7 +2346,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
GLsizei count = static_cast<GLsizei>(c.count);
GLboolean transpose = static_cast<GLboolean>(c.transpose);
uint32 data_size;
- if (!ComputeDataSize(1, sizeof(GLfloat), 16, &data_size)) {
+ if (!ComputeDataSize(count, sizeof(GLfloat), 16, &data_size)) {
return error::kOutOfBounds;
}
if (data_size > immediate_data_size) {
@@ -2502,10 +2354,6 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
}
const GLfloat* value = GetImmediateDataAs<const GLfloat*>(
c, data_size, immediate_data_size);
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glUniformMatrix4fv: count < 0");
- return error::kNoError;
- }
if (!validators_->false_only.IsValid(transpose)) {
SetGLError(
GL_INVALID_VALUE, "glUniformMatrix4fv: transpose GL_INVALID_VALUE");
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
index dc65d58..83f11ba 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
@@ -744,7 +744,7 @@ TEST_F(GLES2DecoderTest1, EnableVertexAttribArrayValidArgs) {
}
TEST_F(GLES2DecoderTest1, FinishValidArgs) {
- EXPECT_CALL(*gl_, Flush());
+ EXPECT_CALL(*gl_, Finish());
SpecializedSetup<Finish, 0>(true);
Finish cmd;
cmd.Init();
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h
index 2c2dc74..9b82306 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h
@@ -751,8 +751,8 @@ TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs1_0) {
SpecializedSetup<Uniform1fv, 0>(false);
Uniform1fv cmd;
cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs2_0) {
@@ -813,8 +813,8 @@ TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs1_0) {
SpecializedSetup<Uniform2fv, 0>(false);
Uniform2fv cmd;
cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs2_0) {
@@ -872,8 +872,8 @@ TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs1_0) {
SpecializedSetup<Uniform2iv, 0>(false);
Uniform2iv cmd;
cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs2_0) {
@@ -931,8 +931,8 @@ TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs1_0) {
SpecializedSetup<Uniform3fv, 0>(false);
Uniform3fv cmd;
cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs2_0) {
@@ -990,8 +990,8 @@ TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs1_0) {
SpecializedSetup<Uniform3iv, 0>(false);
Uniform3iv cmd;
cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs2_0) {
@@ -1049,8 +1049,8 @@ TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs1_0) {
SpecializedSetup<Uniform4fv, 0>(false);
Uniform4fv cmd;
cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs2_0) {
@@ -1108,8 +1108,8 @@ TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs1_0) {
SpecializedSetup<Uniform4iv, 0>(false);
Uniform4iv cmd;
cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs2_0) {
@@ -1159,8 +1159,8 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs1_0) {
SpecializedSetup<UniformMatrix2fv, 0>(false);
UniformMatrix2fv cmd;
cmd.Init(1, -1, false, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs2_0) {
@@ -1232,8 +1232,8 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs1_0) {
SpecializedSetup<UniformMatrix3fv, 0>(false);
UniformMatrix3fv cmd;
cmd.Init(1, -1, false, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs2_0) {
@@ -1305,8 +1305,8 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs1_0) {
SpecializedSetup<UniformMatrix4fv, 0>(false);
UniformMatrix4fv cmd;
cmd.Init(1, -1, false, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs2_0) {
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc
index c19806a..c94bd9b 100644
--- a/gpu/command_buffer/service/program_manager.cc
+++ b/gpu/command_buffer/service/program_manager.cc
@@ -64,10 +64,13 @@ void ProgramManager::ProgramInfo::Reset() {
}
void ProgramManager::ProgramInfo::UpdateLogInfo() {
+ GLint max_len = 0;
+ glGetProgramiv(service_id_, GL_INFO_LOG_LENGTH, &max_len);
+ scoped_array<char> temp(new char[max_len]);
GLint len = 0;
- glGetProgramiv(service_id_, GL_INFO_LOG_LENGTH, &len);
- scoped_array<char> temp(new char[len]);
- glGetProgramInfoLog(service_id_, len, &len, temp.get());
+ glGetProgramInfoLog(service_id_, max_len, &len, temp.get());
+ DCHECK(max_len == 0 || len < max_len);
+ DCHECK(len == 0 || temp[len] == '\0');
set_log_info(std::string(temp.get(), len));
}
@@ -81,11 +84,13 @@ void ProgramManager::ProgramInfo::Update() {
// TODO(gman): Should we check for error?
scoped_array<char> name_buffer(new char[max_len]);
for (GLint ii = 0; ii < num_attribs; ++ii) {
- GLsizei length;
- GLsizei size;
- GLenum type;
+ GLsizei length = 0;
+ GLsizei size = 0;
+ GLenum type = 0;
glGetActiveAttrib(
service_id_, ii, max_len, &length, &size, &type, name_buffer.get());
+ DCHECK(max_len == 0 || length < max_len);
+ DCHECK(length == 0 || name_buffer[length] == '\0');
if (!IsInvalidPrefix(name_buffer.get(), length)) {
// TODO(gman): Should we check for error?
GLint location = glGetAttribLocation(service_id_, name_buffer.get());
@@ -116,11 +121,13 @@ void ProgramManager::ProgramInfo::Update() {
max_location = -1;
int index = 0; // this index tracks valid uniforms.
for (GLint ii = 0; ii < num_uniforms; ++ii) {
- GLsizei length;
- GLsizei size;
- GLenum type;
+ GLsizei length = 0;
+ GLsizei size = 0;
+ GLenum type = 0;
glGetActiveUniform(
service_id_, ii, max_len, &length, &size, &type, name_buffer.get());
+ DCHECK(max_len == 0 || length < max_len);
+ DCHECK(length == 0 || name_buffer[length] == '\0');
// TODO(gman): Should we check for error?
if (!IsInvalidPrefix(name_buffer.get(), length)) {
GLint location = glGetUniformLocation(service_id_, name_buffer.get());