diff options
Diffstat (limited to 'gpu')
13 files changed, 1099 insertions, 226 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index ae96c63..f58dbc7 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -90,12 +90,12 @@ GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLidProgram program, GLui 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 GLint GL_APIENTRY glGetAttribLocation (GLidProgram program, const char* name); -GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenumGLState pname, GLboolean* params); GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenumBufferTarget target, GLenumBufferParameter pname, GLint* params); GL_APICALL GLenum GL_APIENTRY glGetError (void); -GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenumGLState pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenumFrameBufferTarget target, GLenumAttachment attachment, GLenumFrameBufferParameter pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum 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 glGetRenderbufferParameteriv (GLenumRenderBufferTarget target, GLenumRenderBufferParameter pname, GLint* params); @@ -404,6 +404,98 @@ _ENUM_LISTS = { 'GL_STATIC_READ', ], }, + 'GLState': { + 'type': 'GLenum', + 'valid': [ + 'GL_ACTIVE_TEXTURE', + 'GL_ALIASED_LINE_WIDTH_RANGE', + 'GL_ALIASED_POINT_SIZE_RANGE', + 'GL_ALPHA_BITS', + 'GL_ARRAY_BUFFER_BINDING', + 'GL_BLEND', + 'GL_BLEND_COLOR', + 'GL_BLEND_DST_ALPHA', + 'GL_BLEND_DST_RGB', + 'GL_BLEND_EQUATION_ALPHA', + 'GL_BLEND_EQUATION_RGB', + 'GL_BLEND_SRC_ALPHA', + 'GL_BLEND_SRC_RGB', + 'GL_BLUE_BITS', + 'GL_COLOR_CLEAR_VALUE', + 'GL_COLOR_WRITEMASK', + 'GL_COMPRESSED_TEXTURE_FORMATS', + 'GL_CULL_FACE', + 'GL_CULL_FACE_MODE', + 'GL_CURRENT_PROGRAM', + 'GL_DEPTH_BITS', + 'GL_DEPTH_CLEAR_VALUE', + 'GL_DEPTH_FUNC', + 'GL_DEPTH_RANGE', + 'GL_DEPTH_TEST', + 'GL_DEPTH_WRITEMASK', + 'GL_DITHER', + 'GL_ELEMENT_ARRAY_BUFFER_BINDING', + 'GL_FRAMEBUFFER_BINDING', + 'GL_FRONT_FACE', + 'GL_GENERATE_MIPMAP_HINT', + 'GL_GREEN_BITS', + 'GL_IMPLEMENTATION_COLOR_READ_FORMAT', + 'GL_IMPLEMENTATION_COLOR_READ_TYPE', + 'GL_LINE_WIDTH', + 'GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS', + 'GL_MAX_CUBE_MAP_TEXTURE_SIZE', + 'GL_MAX_FRAGMENT_UNIFORM_VECTORS', + 'GL_MAX_RENDERBUFFER_SIZE', + 'GL_MAX_TEXTURE_IMAGE_UNITS', + 'GL_MAX_TEXTURE_SIZE', + 'GL_MAX_VARYING_VECTORS', + 'GL_MAX_VERTEX_ATTRIBS', + 'GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS', + 'GL_MAX_VERTEX_UNIFORM_VECTORS', + 'GL_MAX_VIEWPORT_DIMS', + 'GL_NUM_COMPRESSED_TEXTURE_FORMATS', + 'GL_NUM_SHADER_BINARY_FORMATS', + 'GL_PACK_ALIGNMENT', + 'GL_POLYGON_OFFSET_FACTOR', + 'GL_POLYGON_OFFSET_FILL', + 'GL_POLYGON_OFFSET_UNITS', + 'GL_RED_BITS', + 'GL_RENDERBUFFER_BINDING', + 'GL_SAMPLE_BUFFERS', + 'GL_SAMPLE_COVERAGE_INVERT', + 'GL_SAMPLE_COVERAGE_VALUE', + 'GL_SAMPLES', + 'GL_SCISSOR_BOX', + 'GL_SCISSOR_TEST', + 'GL_SHADER_BINARY_FORMATS', + 'GL_SHADER_COMPILER', + 'GL_STENCIL_BACK_FAIL', + 'GL_STENCIL_BACK_FUNC', + 'GL_STENCIL_BACK_PASS_DEPTH_FAIL', + 'GL_STENCIL_BACK_PASS_DEPTH_PASS', + 'GL_STENCIL_BACK_REF', + 'GL_STENCIL_BACK_VALUE_MASK', + 'GL_STENCIL_BACK_WRITEMASK', + 'GL_STENCIL_BITS', + 'GL_STENCIL_CLEAR_VALUE', + 'GL_STENCIL_FAIL', + 'GL_STENCIL_FUNC', + 'GL_STENCIL_PASS_DEPTH_FAIL', + 'GL_STENCIL_PASS_DEPTH_PASS', + 'GL_STENCIL_REF', + 'GL_STENCIL_TEST', + 'GL_STENCIL_VALUE_MASK', + 'GL_STENCIL_WRITEMASK', + 'GL_SUBPIXEL_BITS', + 'GL_TEXTURE_BINDING_2D', + 'GL_TEXTURE_BINDING_CUBE_MAP', + 'GL_UNPACK_ALIGNMENT', + 'GL_VIEWPORT', + ], + 'invalid': [ + 'GL_FOG_HINT', + ], + }, 'TextureTarget': { 'type': 'GLenum', 'valid': [ @@ -953,22 +1045,23 @@ _FUNCTION_INFO = { 'GLidProgram program, const char* name, NonImmediate GLint* location', 'result': ['GLint'], }, - 'GetBooleanv': {'type': 'GETn'}, - 'GetBufferParameteriv': {'type': 'GETn'}, + 'GetBooleanv': {'type': 'GETn', 'result': ['SizedResult<GLboolean>']}, + 'GetBufferParameteriv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, 'GetError': { 'type': 'Is', 'decoder_func': 'GetGLError', 'impl_func': False, 'result': ['GLenum'], }, - 'GetFloatv': {'type': 'GETn'}, + 'GetFloatv': {'type': 'GETn', 'result': ['SizedResult<GLfloat>']}, 'GetFramebufferAttachmentParameteriv': { 'type': 'GETn', 'decoder_func': 'DoGetFramebufferAttachmentParameteriv', 'gl_test_func': 'glGetFramebufferAttachmentParameterivEXT', + 'result': ['SizedResult<GLint>'], }, - 'GetIntegerv': {'type': 'GETn'}, - 'GetProgramiv': {'type': 'GETn'}, + 'GetIntegerv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, + 'GetProgramiv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, 'GetProgramInfoLog': { 'type': 'STRn', 'get_len_func': 'glGetProgramiv', @@ -978,8 +1071,13 @@ _FUNCTION_INFO = { 'type': 'GETn', 'decoder_func': 'DoGetRenderbufferParameteriv', 'gl_test_func': 'glGetRenderbufferParameterivEXT', + 'result': ['SizedResult<GLint>'], + }, + 'GetShaderiv': { + 'type': 'GETn', + 'decoder_func': 'DoGetShaderiv', + 'result': ['SizedResult<GLint>'], }, - 'GetShaderiv': {'type': 'GETn', 'decoder_func': 'DoGetShaderiv'}, 'GetShaderInfoLog': { 'type': 'STRn', 'get_len_func': 'glGetShaderiv', @@ -1009,8 +1107,8 @@ _FUNCTION_INFO = { 'type': 'Custom', 'cmd_args': 'GLenumStringType name, uint32 bucket_id', }, - 'GetTexParameterfv': {'type': 'GETn'}, - 'GetTexParameteriv': {'type': 'GETn'}, + 'GetTexParameterfv': {'type': 'GETn', 'result': ['SizedResult<GLfloat>']}, + 'GetTexParameteriv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, 'GetUniformfv': { 'type': 'Custom', 'immediate': False, @@ -1029,8 +1127,8 @@ _FUNCTION_INFO = { 'GLidProgram program, const char* name, NonImmediate GLint* location', 'result': ['GLint'], }, - 'GetVertexAttribfv': {'type': 'GETn'}, - 'GetVertexAttribiv': {'type': 'GETn'}, + 'GetVertexAttribfv': {'type': 'GETn', 'result': ['SizedResult<GLfloat>']}, + 'GetVertexAttribiv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, 'GetVertexAttribPointerv': { 'type': 'Custom', 'immediate': False, @@ -2328,22 +2426,40 @@ class GETnHandler(TypeHandler): for arg in all_but_last_args: arg.WriteGetCode(file) - code = """ - %(last_arg_type)s params; + code = """ typedef %(func_name)s::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<%(last_arg_type)s>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + %(last_arg_type)s params = result ? result->GetData() : NULL; """ - file.Write(code % {'last_arg_type': last_arg.type}) + file.Write(code % { + 'last_arg_type': last_arg.type, + 'func_name': func.name, + }) func.WriteHandlerValidation(file) + code = """ // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); +""" + file.Write(code) func.WriteHandlerImplementation(file) - file.Write(" return error::kNoError;\n") - file.Write("}\n") - file.Write("\n") + code = """ GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } + return error::kNoError; +} + +""" + file.Write(code) def WriteGLES2ImplementationHeader(self, func, file): """Overrriden from TypeHandler.""" @@ -2353,16 +2469,71 @@ class GETnHandler(TypeHandler): all_but_last_args = func.GetOriginalArgs()[:-1] arg_string = ( ", ".join(["%s" % arg.name for arg in all_but_last_args])) - file.Write(" helper_->%s(%s, result_shm_id(), result_shm_offset());\n" % - (func.name, arg_string)) - file.Write(" WaitForCmd();\n") - file.Write(" GLsizei num_values = util_.GLGetNumValuesReturned(pname);\n") - file.Write( - " DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult);\n") - file.Write( - " memcpy(params, result_buffer_, num_values * sizeof(*params));\n") - file.Write("}\n") - file.Write("\n") + code = """ typedef %(func_name)s::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); + helper_->%(func_name)s(%(arg_string)s, result_shm_id(), result_shm_offset()); + WaitForCmd(); + result->CopyResult(params); +} +""" + file.Write(code % { + 'func_name': func.name, + 'arg_string': arg_string, + }) + + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + valid_test = """ +TEST_F(%(test_name)s, %(name)sValidArgs) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + SpecializedSetup<%(name)s, 0>(); + typedef %(name)s::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + EXPECT_CALL(*gl_, %(gl_func_name)s(%(local_gl_args)s)); + result->size = 0; + %(name)s cmd; + cmd.Init(%(args)s); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + %(valid_pname)s), + result->GetNumResults()); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); +} +""" + gl_arg_strings = [] + valid_pname = '' + count = 0 + for arg in func.GetOriginalArgs()[:-1]: + arg_value = arg.GetValidGLArg(count, 0) + gl_arg_strings.append(arg_value) + if arg.name == 'pname': + valid_pname = arg_value + count += 1 + gl_arg_strings.append("result->GetData()") + + self.WriteValidUnitTest(func, file, valid_test, { + 'local_gl_args': ", ".join(gl_arg_strings), + 'valid_pname': valid_pname, + }) + + invalid_test = """ +TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); + SpecializedSetup<%(name)s, 0>(); + %(name)s::Result* result = + static_cast<%(name)s::Result*>(shared_memory_address_); + result->size = 0; + %(name)s cmd; + cmd.Init(%(args)s); + EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size);%(gl_error_test)s +} +""" + self.WriteInvalidUnitTest(func, file, invalid_test) class PUTHandler(TypeHandler): @@ -3128,6 +3299,21 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { 'comma': comma, }) + invalid_test = """ +TEST_F(%(test_name)s, %(name)sInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s%(comma)skInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init(%(args)s%(comma)sshared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} +""" + self.WriteValidUnitTest(func, file, invalid_test, { + 'comma': comma, + }) + def WriteServiceImplementation(self, func, file): """Overrriden from TypeHandler.""" file.Write( @@ -3138,10 +3324,14 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { for arg in args: arg.WriteGetCode(file) - file.Write(" %s* result_dst = GetSharedMemoryAs<%s*>(\n" % - (func.return_type, func.return_type)) - file.Write( - " c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));\n") + code = """ typedef %(func_name)s::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( + c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } +""" + file.Write(code % {'func_name': func.name}) func.WriteHandlerValidation(file) file.Write(" *result_dst = %s(%s);\n" % (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) @@ -3156,7 +3346,7 @@ 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(""))) - file.Write(" typedef %s::Result Result;\n" % func.original_name) + file.Write(" typedef %s::Result Result;\n" % func.name) file.Write(" Result* result = GetResultAs<Result*>();\n") file.Write(" *result = 0;\n") arg_string = func.MakeOriginalArgString("") @@ -4068,8 +4258,9 @@ class GLGenerator(object): return_type = match.group(1).strip() arg_string = match.group(3) (args, num_pointer_args, is_gl_enum) = self.ParseArgs(arg_string) - if is_gl_enum: - self.Log("%s uses bare GLenum" % func_name) + # comment in to find out which functions use bare enums. + # if is_gl_enum: + # self.Log("%s uses bare GLenum" % func_name) args_for_cmds = args if hasattr(func_info, 'cmd_args'): (args_for_cmds, num_pointer_args, is_gl_enum) = ( diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index 1f78ead..5132721 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -286,58 +286,58 @@ void GetAttachedShaders( GLint GetAttribLocation(GLuint program, const char* name); void GetBooleanv(GLenum pname, GLboolean* params) { + typedef GetBooleanv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetBooleanv(pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) { + typedef GetBufferParameteriv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetBufferParameteriv( target, pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - GLenum GetError(); void GetFloatv(GLenum pname, GLfloat* params) { + typedef GetFloatv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetFloatv(pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetFramebufferAttachmentParameteriv( GLenum target, GLenum attachment, GLenum pname, GLint* params) { + typedef GetFramebufferAttachmentParameteriv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetFramebufferAttachmentParameteriv( target, attachment, pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetIntegerv(GLenum pname, GLint* params) { + typedef GetIntegerv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetIntegerv(pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetProgramiv(GLuint program, GLenum pname, GLint* params) { + typedef GetProgramiv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetProgramiv(program, pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetProgramInfoLog( GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { helper_->SetBucketSize(kResultBucketId, 0); @@ -356,22 +356,22 @@ void GetProgramInfoLog( } } void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) { + typedef GetRenderbufferParameteriv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetRenderbufferParameteriv( target, pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetShaderiv(GLuint shader, GLenum pname, GLint* params) { + typedef GetShaderiv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetShaderiv(shader, pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetShaderInfoLog( GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { helper_->SetBucketSize(kResultBucketId, 0); @@ -412,23 +412,23 @@ void GetShaderSource( const GLubyte* GetString(GLenum name); void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) { + typedef GetTexParameterfv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetTexParameterfv( target, pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) { + typedef GetTexParameteriv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetTexParameteriv( target, pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetUniformfv(GLuint program, GLint location, GLfloat* params); void GetUniformiv(GLuint program, GLint location, GLint* params); @@ -436,23 +436,23 @@ void GetUniformiv(GLuint program, GLint location, GLint* params); GLint GetUniformLocation(GLuint program, const char* name); void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) { + typedef GetVertexAttribfv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetVertexAttribfv( index, pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) { + typedef GetVertexAttribiv::Result Result; + Result* result = GetResultAs<Result*>(); + result->SetNumResults(0); helper_->GetVertexAttribiv( index, pname, result_shm_id(), result_shm_offset()); WaitForCmd(); - GLsizei num_values = util_.GLGetNumValuesReturned(pname); - DCHECK_LE(num_values * sizeof(*params), kMaxSizeOfSimpleResult); - memcpy(params, result_buffer_, num_values * sizeof(*params)); + result->CopyResult(params); } - void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer); void Hint(GLenum target, GLenum mode) { diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 20db822..dfba44a 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -3134,6 +3134,8 @@ struct GetBooleanv { static const CommandId kCmdId = kGetBooleanv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLboolean> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3179,6 +3181,8 @@ struct GetBufferParameteriv { static const CommandId kCmdId = kGetBufferParameteriv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLint> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3270,6 +3274,8 @@ struct GetFloatv { static const CommandId kCmdId = kGetFloatv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLfloat> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3315,6 +3321,8 @@ struct GetFramebufferAttachmentParameteriv { static const CommandId kCmdId = kGetFramebufferAttachmentParameteriv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLint> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3373,6 +3381,8 @@ struct GetIntegerv { static const CommandId kCmdId = kGetIntegerv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLint> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3418,6 +3428,8 @@ struct GetProgramiv { static const CommandId kCmdId = kGetProgramiv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLint> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3507,6 +3519,8 @@ struct GetRenderbufferParameteriv { static const CommandId kCmdId = kGetRenderbufferParameteriv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLint> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3558,6 +3572,8 @@ struct GetShaderiv { static const CommandId kCmdId = kGetShaderiv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLint> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3790,6 +3806,8 @@ struct GetTexParameterfv { static const CommandId kCmdId = kGetTexParameterfv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLfloat> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3841,6 +3859,8 @@ struct GetTexParameteriv { static const CommandId kCmdId = kGetTexParameteriv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLint> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3998,6 +4018,8 @@ struct GetVertexAttribfv { static const CommandId kCmdId = kGetVertexAttribfv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLfloat> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -4049,6 +4071,8 @@ struct GetVertexAttribiv { static const CommandId kCmdId = kGetVertexAttribiv; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef SizedResult<GLint> Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } diff --git a/gpu/command_buffer/service/gl_interface.h b/gpu/command_buffer/service/gl_interface.h index 32d2ae3..139dff2 100644 --- a/gpu/command_buffer/service/gl_interface.h +++ b/gpu/command_buffer/service/gl_interface.h @@ -32,6 +32,7 @@ #define GL_TEXTURE_3D 0x806F #define GL_DOUBLE 0x140A #define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_FOG_HINT 0x0C54 namespace gles2 { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 67e7433..47f6609 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -212,6 +212,7 @@ class GLES2DecoderImpl : public GLES2Decoder { virtual void Destroy(); virtual bool MakeCurrent(); virtual uint32 GetServiceIdForTesting(uint32 client_id); + virtual GLES2Util* GetGLES2Util() { return &util_; } #if defined(OS_MACOSX) // Overridden from GLES2Decoder. diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index cfa4c66..fae1af0 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -26,6 +26,7 @@ class XWindowWrapper; namespace gles2 { class ContextGroup; +class GLES2Util; // This class implements the AsyncAPIInterface interface, decoding GLES2 // commands and calling GL. @@ -84,6 +85,9 @@ class GLES2Decoder : public CommonDecoder { // Gets a service id by client id. virtual uint32 GetServiceIdForTesting(uint32 client_id) = 0; + // Gets the GLES2 Util which holds info. + virtual GLES2Util* GetGLES2Util() = 0; + // Sets a callback which is called when a SwapBuffers command is processed. virtual void SetSwapBuffersCallback(Callback0::Type* callback) = 0; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index 3d866a3..c6c7071 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -265,8 +265,12 @@ error::Error GLES2DecoderImpl::HandleBufferSubDataImmediate( error::Error GLES2DecoderImpl::HandleCheckFramebufferStatus( uint32 immediate_data_size, const gles2::CheckFramebufferStatus& c) { GLenum target = static_cast<GLenum>(c.target); - GLenum* result_dst = GetSharedMemoryAs<GLenum*>( + typedef CheckFramebufferStatus::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } if (!ValidateGLenumFrameBufferTarget(target)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1006,19 +1010,34 @@ error::Error GLES2DecoderImpl::HandleGenTexturesImmediate( error::Error GLES2DecoderImpl::HandleGetBooleanv( uint32 immediate_data_size, const gles2::GetBooleanv& c) { GLenum pname = static_cast<GLenum>(c.pname); - - GLboolean* params; + typedef GetBooleanv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; + } + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLboolean* params = result ? result->GetData() : NULL; + if (!ValidateGLenumGLState(pname)) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLboolean*>( - c.params_shm_id, c.params_shm_offset, params_size); if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); glGetBooleanv(pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1026,15 +1045,15 @@ error::Error GLES2DecoderImpl::HandleGetBufferParameteriv( uint32 immediate_data_size, const gles2::GetBufferParameteriv& c) { GLenum target = static_cast<GLenum>(c.target); GLenum pname = static_cast<GLenum>(c.pname); - - GLint* params; + typedef GetBufferParameteriv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLint*>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLint* params = result ? result->GetData() : NULL; if (!ValidateGLenumBufferTarget(target)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1046,14 +1065,29 @@ error::Error GLES2DecoderImpl::HandleGetBufferParameteriv( if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); glGetBufferParameteriv(target, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } error::Error GLES2DecoderImpl::HandleGetError( uint32 immediate_data_size, const gles2::GetError& c) { - GLenum* result_dst = GetSharedMemoryAs<GLenum*>( + typedef GetError::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } *result_dst = GetGLError(); return error::kNoError; } @@ -1061,19 +1095,34 @@ error::Error GLES2DecoderImpl::HandleGetError( error::Error GLES2DecoderImpl::HandleGetFloatv( uint32 immediate_data_size, const gles2::GetFloatv& c) { GLenum pname = static_cast<GLenum>(c.pname); - - GLfloat* params; + typedef GetFloatv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; + } + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLfloat* params = result ? result->GetData() : NULL; + if (!ValidateGLenumGLState(pname)) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLfloat*>( - c.params_shm_id, c.params_shm_offset, params_size); if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); glGetFloatv(pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1083,15 +1132,15 @@ error::Error GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv( GLenum target = static_cast<GLenum>(c.target); GLenum attachment = static_cast<GLenum>(c.attachment); GLenum pname = static_cast<GLenum>(c.pname); - - GLint* params; + typedef GetFramebufferAttachmentParameteriv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLint*>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLint* params = result ? result->GetData() : NULL; if (!ValidateGLenumFrameBufferTarget(target)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1107,26 +1156,52 @@ error::Error GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv( if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); DoGetFramebufferAttachmentParameteriv(target, attachment, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } error::Error GLES2DecoderImpl::HandleGetIntegerv( uint32 immediate_data_size, const gles2::GetIntegerv& c) { GLenum pname = static_cast<GLenum>(c.pname); - - GLint* params; + typedef GetIntegerv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; + } + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLint* params = result ? result->GetData() : NULL; + if (!ValidateGLenumGLState(pname)) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLint*>( - c.params_shm_id, c.params_shm_offset, params_size); if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); glGetIntegerv(pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1138,15 +1213,15 @@ error::Error GLES2DecoderImpl::HandleGetProgramiv( return error::kNoError; } GLenum pname = static_cast<GLenum>(c.pname); - - GLint* params; + typedef GetProgramiv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLint*>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLint* params = result ? result->GetData() : NULL; if (!ValidateGLenumProgramParameter(pname)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1154,7 +1229,18 @@ error::Error GLES2DecoderImpl::HandleGetProgramiv( if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); glGetProgramiv(program, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1179,15 +1265,15 @@ error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv( uint32 immediate_data_size, const gles2::GetRenderbufferParameteriv& c) { GLenum target = static_cast<GLenum>(c.target); GLenum pname = static_cast<GLenum>(c.pname); - - GLint* params; + typedef GetRenderbufferParameteriv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLint*>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLint* params = result ? result->GetData() : NULL; if (!ValidateGLenumRenderBufferTarget(target)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1199,7 +1285,18 @@ error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv( if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); DoGetRenderbufferParameteriv(target, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1211,15 +1308,15 @@ error::Error GLES2DecoderImpl::HandleGetShaderiv( return error::kNoError; } GLenum pname = static_cast<GLenum>(c.pname); - - GLint* params; + typedef GetShaderiv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLint*>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLint* params = result ? result->GetData() : NULL; if (!ValidateGLenumShaderParameter(pname)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1227,7 +1324,18 @@ error::Error GLES2DecoderImpl::HandleGetShaderiv( if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); DoGetShaderiv(shader, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1269,15 +1377,15 @@ error::Error GLES2DecoderImpl::HandleGetTexParameterfv( uint32 immediate_data_size, const gles2::GetTexParameterfv& c) { GLenum target = static_cast<GLenum>(c.target); GLenum pname = static_cast<GLenum>(c.pname); - - GLfloat* params; + typedef GetTexParameterfv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLfloat*>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLfloat* params = result ? result->GetData() : NULL; if (!ValidateGLenumTextureTarget(target)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1289,7 +1397,18 @@ error::Error GLES2DecoderImpl::HandleGetTexParameterfv( if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); glGetTexParameterfv(target, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1297,15 +1416,15 @@ error::Error GLES2DecoderImpl::HandleGetTexParameteriv( uint32 immediate_data_size, const gles2::GetTexParameteriv& c) { GLenum target = static_cast<GLenum>(c.target); GLenum pname = static_cast<GLenum>(c.pname); - - GLint* params; + typedef GetTexParameteriv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLint*>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLint* params = result ? result->GetData() : NULL; if (!ValidateGLenumTextureTarget(target)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1317,7 +1436,18 @@ error::Error GLES2DecoderImpl::HandleGetTexParameteriv( if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); glGetTexParameteriv(target, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1325,15 +1455,15 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribfv( uint32 immediate_data_size, const gles2::GetVertexAttribfv& c) { GLuint index = static_cast<GLuint>(c.index); GLenum pname = static_cast<GLenum>(c.pname); - - GLfloat* params; + typedef GetVertexAttribfv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLfloat*>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLfloat* params = result ? result->GetData() : NULL; if (!ValidateGLenumVertexAttribute(pname)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1341,7 +1471,18 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribfv( if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); glGetVertexAttribfv(index, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1349,15 +1490,15 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribiv( uint32 immediate_data_size, const gles2::GetVertexAttribiv& c) { GLuint index = static_cast<GLuint>(c.index); GLenum pname = static_cast<GLenum>(c.pname); - - GLint* params; + typedef GetVertexAttribiv::Result Result; GLsizei num_values = util_.GLGetNumValuesReturned(pname); - uint32 params_size; - if (!SafeMultiplyUint32(num_values, sizeof(*params), ¶ms_size)) { - return error::kOutOfBounds; + if (num_values == 0) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; } - params = GetSharedMemoryAs<GLint*>( - c.params_shm_id, c.params_shm_offset, params_size); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLint* params = result ? result->GetData() : NULL; if (!ValidateGLenumVertexAttribute(pname)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1365,7 +1506,18 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribiv( if (params == NULL) { return error::kOutOfBounds; } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + CopyRealGLErrorsToWrapper(); glGetVertexAttribiv(index, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + SetGLError(error); + } return error::kNoError; } @@ -1392,8 +1544,12 @@ error::Error GLES2DecoderImpl::HandleIsBuffer( SetGLError(GL_INVALID_VALUE); return error::kNoError; } - GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + typedef IsBuffer::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } *result_dst = glIsBuffer(buffer); return error::kNoError; } @@ -1401,8 +1557,12 @@ error::Error GLES2DecoderImpl::HandleIsBuffer( error::Error GLES2DecoderImpl::HandleIsEnabled( uint32 immediate_data_size, const gles2::IsEnabled& c) { GLenum cap = static_cast<GLenum>(c.cap); - GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + typedef IsEnabled::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } if (!ValidateGLenumCapability(cap)) { SetGLError(GL_INVALID_ENUM); return error::kNoError; @@ -1418,8 +1578,12 @@ error::Error GLES2DecoderImpl::HandleIsFramebuffer( SetGLError(GL_INVALID_VALUE); return error::kNoError; } - GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + typedef IsFramebuffer::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } *result_dst = glIsFramebufferEXT(framebuffer); return error::kNoError; } @@ -1431,8 +1595,12 @@ error::Error GLES2DecoderImpl::HandleIsProgram( SetGLError(GL_INVALID_VALUE); return error::kNoError; } - GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + typedef IsProgram::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } *result_dst = glIsProgram(program); return error::kNoError; } @@ -1444,8 +1612,12 @@ error::Error GLES2DecoderImpl::HandleIsRenderbuffer( SetGLError(GL_INVALID_VALUE); return error::kNoError; } - GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + typedef IsRenderbuffer::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } *result_dst = glIsRenderbufferEXT(renderbuffer); return error::kNoError; } @@ -1457,8 +1629,12 @@ error::Error GLES2DecoderImpl::HandleIsShader( SetGLError(GL_INVALID_VALUE); return error::kNoError; } - GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + typedef IsShader::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } *result_dst = glIsShader(shader); return error::kNoError; } @@ -1470,8 +1646,12 @@ error::Error GLES2DecoderImpl::HandleIsTexture( SetGLError(GL_INVALID_VALUE); return error::kNoError; } - GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + typedef IsTexture::Result Result; + Result* result_dst = GetSharedMemoryAs<Result*>( c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + if (!result_dst) { + return error::kOutOfBounds; + } *result_dst = glIsTexture(texture); return error::kNoError; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h index 2beff5a..2ef2d2d 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h @@ -32,6 +32,7 @@ class MockGLES2Decoder : public GLES2Decoder { MOCK_METHOD0(Destroy, void()); MOCK_METHOD0(MakeCurrent, bool()); MOCK_METHOD1(GetServiceIdForTesting, uint32(uint32 client_id)); + MOCK_METHOD0(GetGLES2Util, GLES2Util*()); MOCK_METHOD1(SetSwapBuffersCallback, void(Callback0::Type*)); MOCK_METHOD3(DoCommand, error::Error(unsigned int command, unsigned int arg_count, diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 11eef37..5653e57 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -1070,6 +1070,10 @@ TEST_F(GLES2DecoderTest, FramebufferTexture2DWithNoBoundTarget) { } TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) .Times(0); GetFramebufferAttachmentParameteriv cmd; @@ -1082,6 +1086,10 @@ TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) { } TEST_F(GLES2DecoderTest, GetRenderbufferParameterivWithNoBoundTarget) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _)) .Times(0); GetRenderbufferParameteriv cmd; 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 2cd8da8..f652358 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 @@ -230,6 +230,16 @@ TEST_F(GLES2DecoderTest1, CheckFramebufferStatusInvalidArgs0_0) { EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } +TEST_F(GLES2DecoderTest1, CheckFramebufferStatusInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)).Times(0); + SpecializedSetup<CheckFramebufferStatus, 0>(); + CheckFramebufferStatus cmd; + cmd.Init(GL_FRAMEBUFFER, kInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init(GL_FRAMEBUFFER, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} + TEST_F(GLES2DecoderTest1, ClearValidArgs) { EXPECT_CALL(*gl_, Clear(1)); SpecializedSetup<Clear, 0>(); @@ -1022,84 +1032,138 @@ TEST_F(GLES2DecoderTest1, GenTexturesImmediateInvalidArgs) { TEST_F(GLES2DecoderTest1, GetBooleanvValidArgs) { - EXPECT_CALL( - *gl_, GetBooleanv( - 1, reinterpret_cast<GLboolean*>(shared_memory_address_))); + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); SpecializedSetup<GetBooleanv, 0>(); + typedef GetBooleanv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + EXPECT_CALL(*gl_, GetBooleanv(GL_ACTIVE_TEXTURE, result->GetData())); + result->size = 0; GetBooleanv cmd; - cmd.Init(1, shared_memory_id_, shared_memory_offset_); + cmd.Init(GL_ACTIVE_TEXTURE, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_ACTIVE_TEXTURE), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest1, GetBooleanvInvalidArgs0_0) { + EXPECT_CALL(*gl_, GetBooleanv(_, _)).Times(0); + SpecializedSetup<GetBooleanv, 0>(); + GetBooleanv::Result* result = + static_cast<GetBooleanv::Result*>(shared_memory_address_); + result->size = 0; + GetBooleanv cmd; + cmd.Init(GL_FOG_HINT, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); + EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); +} + TEST_F(GLES2DecoderTest1, GetBooleanvInvalidArgs1_0) { EXPECT_CALL(*gl_, GetBooleanv(_, _)).Times(0); SpecializedSetup<GetBooleanv, 0>(); + GetBooleanv::Result* result = + static_cast<GetBooleanv::Result*>(shared_memory_address_); + result->size = 0; GetBooleanv cmd; - cmd.Init(1, kInvalidSharedMemoryId, 0); + cmd.Init(GL_ACTIVE_TEXTURE, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetBooleanvInvalidArgs1_1) { EXPECT_CALL(*gl_, GetBooleanv(_, _)).Times(0); SpecializedSetup<GetBooleanv, 0>(); + GetBooleanv::Result* result = + static_cast<GetBooleanv::Result*>(shared_memory_address_); + result->size = 0; GetBooleanv cmd; - cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(GL_ACTIVE_TEXTURE, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetBufferParameterivValidArgs) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + SpecializedSetup<GetBufferParameteriv, 0>(); + typedef GetBufferParameteriv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); EXPECT_CALL( *gl_, GetBufferParameteriv( - GL_ARRAY_BUFFER, GL_BUFFER_SIZE, reinterpret_cast<GLint*>( - shared_memory_address_))); - SpecializedSetup<GetBufferParameteriv, 0>(); + GL_ARRAY_BUFFER, GL_BUFFER_SIZE, result->GetData())); + result->size = 0; GetBufferParameteriv cmd; cmd.Init( GL_ARRAY_BUFFER, GL_BUFFER_SIZE, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_BUFFER_SIZE), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest1, GetBufferParameterivInvalidArgs0_0) { EXPECT_CALL(*gl_, GetBufferParameteriv(_, _, _)).Times(0); SpecializedSetup<GetBufferParameteriv, 0>(); + GetBufferParameteriv::Result* result = + static_cast<GetBufferParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetBufferParameteriv cmd; cmd.Init( GL_RENDERBUFFER, GL_BUFFER_SIZE, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } TEST_F(GLES2DecoderTest1, GetBufferParameterivInvalidArgs1_0) { EXPECT_CALL(*gl_, GetBufferParameteriv(_, _, _)).Times(0); SpecializedSetup<GetBufferParameteriv, 0>(); + GetBufferParameteriv::Result* result = + static_cast<GetBufferParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetBufferParameteriv cmd; cmd.Init( GL_ARRAY_BUFFER, GL_PIXEL_PACK_BUFFER, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } TEST_F(GLES2DecoderTest1, GetBufferParameterivInvalidArgs2_0) { EXPECT_CALL(*gl_, GetBufferParameteriv(_, _, _)).Times(0); SpecializedSetup<GetBufferParameteriv, 0>(); + GetBufferParameteriv::Result* result = + static_cast<GetBufferParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetBufferParameteriv cmd; cmd.Init(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetBufferParameterivInvalidArgs2_1) { EXPECT_CALL(*gl_, GetBufferParameteriv(_, _, _)).Times(0); SpecializedSetup<GetBufferParameteriv, 0>(); + GetBufferParameteriv::Result* result = + static_cast<GetBufferParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetBufferParameteriv cmd; cmd.Init( GL_ARRAY_BUFFER, GL_BUFFER_SIZE, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetErrorValidArgs) { @@ -1111,45 +1175,94 @@ TEST_F(GLES2DecoderTest1, GetErrorValidArgs) { EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest1, GetErrorInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, GetError()).Times(0); + SpecializedSetup<GetError, 0>(); + GetError cmd; + cmd.Init(kInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init(shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} + TEST_F(GLES2DecoderTest1, GetFloatvValidArgs) { - EXPECT_CALL( - *gl_, GetFloatv(1, reinterpret_cast<GLfloat*>(shared_memory_address_))); + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); SpecializedSetup<GetFloatv, 0>(); + typedef GetFloatv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + EXPECT_CALL(*gl_, GetFloatv(GL_ACTIVE_TEXTURE, result->GetData())); + result->size = 0; GetFloatv cmd; - cmd.Init(1, shared_memory_id_, shared_memory_offset_); + cmd.Init(GL_ACTIVE_TEXTURE, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_ACTIVE_TEXTURE), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest1, GetFloatvInvalidArgs0_0) { + EXPECT_CALL(*gl_, GetFloatv(_, _)).Times(0); + SpecializedSetup<GetFloatv, 0>(); + GetFloatv::Result* result = + static_cast<GetFloatv::Result*>(shared_memory_address_); + result->size = 0; + GetFloatv cmd; + cmd.Init(GL_FOG_HINT, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); + EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); +} + TEST_F(GLES2DecoderTest1, GetFloatvInvalidArgs1_0) { EXPECT_CALL(*gl_, GetFloatv(_, _)).Times(0); SpecializedSetup<GetFloatv, 0>(); + GetFloatv::Result* result = + static_cast<GetFloatv::Result*>(shared_memory_address_); + result->size = 0; GetFloatv cmd; - cmd.Init(1, kInvalidSharedMemoryId, 0); + cmd.Init(GL_ACTIVE_TEXTURE, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetFloatvInvalidArgs1_1) { EXPECT_CALL(*gl_, GetFloatv(_, _)).Times(0); SpecializedSetup<GetFloatv, 0>(); + GetFloatv::Result* result = + static_cast<GetFloatv::Result*>(shared_memory_address_); + result->size = 0; GetFloatv cmd; - cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(GL_ACTIVE_TEXTURE, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetFramebufferAttachmentParameterivValidArgs) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + SpecializedSetup<GetFramebufferAttachmentParameteriv, 0>(); + typedef GetFramebufferAttachmentParameteriv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); EXPECT_CALL( *gl_, GetFramebufferAttachmentParameterivEXT( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, reinterpret_cast<GLint*>( - shared_memory_address_))); - SpecializedSetup<GetFramebufferAttachmentParameteriv, 0>(); + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, result->GetData())); + result->size = 0; GetFramebufferAttachmentParameteriv cmd; cmd.Init( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1157,12 +1270,17 @@ TEST_F(GLES2DecoderTest1, GetFramebufferAttachmentParameterivInvalidArgs0_0) { EXPECT_CALL( *gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)).Times(0); SpecializedSetup<GetFramebufferAttachmentParameteriv, 0>(); + GetFramebufferAttachmentParameteriv::Result* result = + static_cast<GetFramebufferAttachmentParameteriv::Result*>( + shared_memory_address_); + result->size = 0; GetFramebufferAttachmentParameteriv cmd; cmd.Init( GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } @@ -1170,81 +1288,138 @@ TEST_F(GLES2DecoderTest1, GetFramebufferAttachmentParameterivInvalidArgs3_0) { EXPECT_CALL( *gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)).Times(0); SpecializedSetup<GetFramebufferAttachmentParameteriv, 0>(); + GetFramebufferAttachmentParameteriv::Result* result = + static_cast<GetFramebufferAttachmentParameteriv::Result*>( + shared_memory_address_); + result->size = 0; GetFramebufferAttachmentParameteriv cmd; cmd.Init( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetFramebufferAttachmentParameterivInvalidArgs3_1) { EXPECT_CALL( *gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)).Times(0); SpecializedSetup<GetFramebufferAttachmentParameteriv, 0>(); + GetFramebufferAttachmentParameteriv::Result* result = + static_cast<GetFramebufferAttachmentParameteriv::Result*>( + shared_memory_address_); + result->size = 0; GetFramebufferAttachmentParameteriv cmd; cmd.Init( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetIntegervValidArgs) { - EXPECT_CALL( - *gl_, GetIntegerv(1, reinterpret_cast<GLint*>(shared_memory_address_))); + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); SpecializedSetup<GetIntegerv, 0>(); + typedef GetIntegerv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + EXPECT_CALL(*gl_, GetIntegerv(GL_ACTIVE_TEXTURE, result->GetData())); + result->size = 0; GetIntegerv cmd; - cmd.Init(1, shared_memory_id_, shared_memory_offset_); + cmd.Init(GL_ACTIVE_TEXTURE, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_ACTIVE_TEXTURE), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest1, GetIntegervInvalidArgs0_0) { + EXPECT_CALL(*gl_, GetIntegerv(_, _)).Times(0); + SpecializedSetup<GetIntegerv, 0>(); + GetIntegerv::Result* result = + static_cast<GetIntegerv::Result*>(shared_memory_address_); + result->size = 0; + GetIntegerv cmd; + cmd.Init(GL_FOG_HINT, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); + EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); +} + TEST_F(GLES2DecoderTest1, GetIntegervInvalidArgs1_0) { EXPECT_CALL(*gl_, GetIntegerv(_, _)).Times(0); SpecializedSetup<GetIntegerv, 0>(); + GetIntegerv::Result* result = + static_cast<GetIntegerv::Result*>(shared_memory_address_); + result->size = 0; GetIntegerv cmd; - cmd.Init(1, kInvalidSharedMemoryId, 0); + cmd.Init(GL_ACTIVE_TEXTURE, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetIntegervInvalidArgs1_1) { EXPECT_CALL(*gl_, GetIntegerv(_, _)).Times(0); SpecializedSetup<GetIntegerv, 0>(); + GetIntegerv::Result* result = + static_cast<GetIntegerv::Result*>(shared_memory_address_); + result->size = 0; GetIntegerv cmd; - cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(GL_ACTIVE_TEXTURE, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetProgramivValidArgs) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + SpecializedSetup<GetProgramiv, 0>(); + typedef GetProgramiv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); EXPECT_CALL( *gl_, GetProgramiv( - kServiceProgramId, GL_DELETE_STATUS, reinterpret_cast<GLint*>( - shared_memory_address_))); - SpecializedSetup<GetProgramiv, 0>(); + kServiceProgramId, GL_DELETE_STATUS, result->GetData())); + result->size = 0; GetProgramiv cmd; cmd.Init( client_program_id_, GL_DELETE_STATUS, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_DELETE_STATUS), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest1, GetProgramivInvalidArgs2_0) { EXPECT_CALL(*gl_, GetProgramiv(_, _, _)).Times(0); SpecializedSetup<GetProgramiv, 0>(); + GetProgramiv::Result* result = + static_cast<GetProgramiv::Result*>(shared_memory_address_); + result->size = 0; GetProgramiv cmd; cmd.Init(client_program_id_, GL_DELETE_STATUS, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetProgramivInvalidArgs2_1) { EXPECT_CALL(*gl_, GetProgramiv(_, _, _)).Times(0); SpecializedSetup<GetProgramiv, 0>(); + GetProgramiv::Result* result = + static_cast<GetProgramiv::Result*>(shared_memory_address_); + result->size = 0; GetProgramiv cmd; cmd.Init( client_program_id_, GL_DELETE_STATUS, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetProgramInfoLogValidArgs) { @@ -1279,78 +1454,115 @@ TEST_F(GLES2DecoderTest1, GetProgramInfoLogInvalidArgs) { } TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivValidArgs) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + SpecializedSetup<GetRenderbufferParameteriv, 0>(); + typedef GetRenderbufferParameteriv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); EXPECT_CALL( *gl_, GetRenderbufferParameterivEXT( - GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, reinterpret_cast<GLint*>( - shared_memory_address_))); - SpecializedSetup<GetRenderbufferParameteriv, 0>(); + GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, result->GetData())); + result->size = 0; GetRenderbufferParameteriv cmd; cmd.Init( GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_RENDERBUFFER_WIDTH), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivInvalidArgs0_0) { EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _)).Times(0); SpecializedSetup<GetRenderbufferParameteriv, 0>(); + GetRenderbufferParameteriv::Result* result = + static_cast<GetRenderbufferParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetRenderbufferParameteriv cmd; cmd.Init( GL_FRAMEBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivInvalidArgs2_0) { EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _)).Times(0); SpecializedSetup<GetRenderbufferParameteriv, 0>(); + GetRenderbufferParameteriv::Result* result = + static_cast<GetRenderbufferParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetRenderbufferParameteriv cmd; cmd.Init(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivInvalidArgs2_1) { EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _)).Times(0); SpecializedSetup<GetRenderbufferParameteriv, 0>(); + GetRenderbufferParameteriv::Result* result = + static_cast<GetRenderbufferParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetRenderbufferParameteriv cmd; cmd.Init( GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetShaderivValidArgs) { - EXPECT_CALL( - *gl_, GetShaderiv( - kServiceShaderId, GL_SHADER_TYPE, reinterpret_cast<GLint*>( - shared_memory_address_))); + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); SpecializedSetup<GetShaderiv, 0>(); + typedef GetShaderiv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + EXPECT_CALL( + *gl_, GetShaderiv(kServiceShaderId, GL_SHADER_TYPE, result->GetData())); + result->size = 0; GetShaderiv cmd; cmd.Init( client_shader_id_, GL_SHADER_TYPE, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_SHADER_TYPE), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest1, GetShaderivInvalidArgs2_0) { EXPECT_CALL(*gl_, GetShaderiv(_, _, _)).Times(0); SpecializedSetup<GetShaderiv, 0>(); + GetShaderiv::Result* result = + static_cast<GetShaderiv::Result*>(shared_memory_address_); + result->size = 0; GetShaderiv cmd; cmd.Init(client_shader_id_, GL_SHADER_TYPE, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetShaderivInvalidArgs2_1) { EXPECT_CALL(*gl_, GetShaderiv(_, _, _)).Times(0); SpecializedSetup<GetShaderiv, 0>(); + GetShaderiv::Result* result = + static_cast<GetShaderiv::Result*>(shared_memory_address_); + result->size = 0; GetShaderiv cmd; cmd.Init( client_shader_id_, GL_SHADER_TYPE, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetShaderInfoLogValidArgs) { @@ -1390,111 +1602,161 @@ TEST_F(GLES2DecoderTest1, GetShaderInfoLogInvalidArgs) { TEST_F(GLES2DecoderTest1, GetTexParameterfvValidArgs) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + SpecializedSetup<GetTexParameterfv, 0>(); + typedef GetTexParameterfv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); EXPECT_CALL( *gl_, GetTexParameterfv( - GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, reinterpret_cast<GLfloat*>( - shared_memory_address_))); - SpecializedSetup<GetTexParameterfv, 0>(); + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, result->GetData())); + result->size = 0; GetTexParameterfv cmd; cmd.Init( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_TEXTURE_MAG_FILTER), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest1, GetTexParameterfvInvalidArgs0_0) { EXPECT_CALL(*gl_, GetTexParameterfv(_, _, _)).Times(0); SpecializedSetup<GetTexParameterfv, 0>(); + GetTexParameterfv::Result* result = + static_cast<GetTexParameterfv::Result*>(shared_memory_address_); + result->size = 0; GetTexParameterfv cmd; cmd.Init( GL_PROXY_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } TEST_F(GLES2DecoderTest1, GetTexParameterfvInvalidArgs1_0) { EXPECT_CALL(*gl_, GetTexParameterfv(_, _, _)).Times(0); SpecializedSetup<GetTexParameterfv, 0>(); + GetTexParameterfv::Result* result = + static_cast<GetTexParameterfv::Result*>(shared_memory_address_); + result->size = 0; GetTexParameterfv cmd; cmd.Init( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } TEST_F(GLES2DecoderTest1, GetTexParameterfvInvalidArgs2_0) { EXPECT_CALL(*gl_, GetTexParameterfv(_, _, _)).Times(0); SpecializedSetup<GetTexParameterfv, 0>(); + GetTexParameterfv::Result* result = + static_cast<GetTexParameterfv::Result*>(shared_memory_address_); + result->size = 0; GetTexParameterfv cmd; cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetTexParameterfvInvalidArgs2_1) { EXPECT_CALL(*gl_, GetTexParameterfv(_, _, _)).Times(0); SpecializedSetup<GetTexParameterfv, 0>(); + GetTexParameterfv::Result* result = + static_cast<GetTexParameterfv::Result*>(shared_memory_address_); + result->size = 0; GetTexParameterfv cmd; cmd.Init( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetTexParameterivValidArgs) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + SpecializedSetup<GetTexParameteriv, 0>(); + typedef GetTexParameteriv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); EXPECT_CALL( *gl_, GetTexParameteriv( - GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, reinterpret_cast<GLint*>( - shared_memory_address_))); - SpecializedSetup<GetTexParameteriv, 0>(); + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, result->GetData())); + result->size = 0; GetTexParameteriv cmd; cmd.Init( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_TEXTURE_MAG_FILTER), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs0_0) { EXPECT_CALL(*gl_, GetTexParameteriv(_, _, _)).Times(0); SpecializedSetup<GetTexParameteriv, 0>(); + GetTexParameteriv::Result* result = + static_cast<GetTexParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetTexParameteriv cmd; cmd.Init( GL_PROXY_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs1_0) { EXPECT_CALL(*gl_, GetTexParameteriv(_, _, _)).Times(0); SpecializedSetup<GetTexParameteriv, 0>(); + GetTexParameteriv::Result* result = + static_cast<GetTexParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetTexParameteriv cmd; cmd.Init( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs2_0) { EXPECT_CALL(*gl_, GetTexParameteriv(_, _, _)).Times(0); SpecializedSetup<GetTexParameteriv, 0>(); + GetTexParameteriv::Result* result = + static_cast<GetTexParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetTexParameteriv cmd; cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs2_1) { EXPECT_CALL(*gl_, GetTexParameteriv(_, _, _)).Times(0); SpecializedSetup<GetTexParameteriv, 0>(); + GetTexParameteriv::Result* result = + static_cast<GetTexParameteriv::Result*>(shared_memory_address_); + result->size = 0; GetTexParameteriv cmd; cmd.Init( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_1_AUTOGEN_H_ 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 f83c61a..4c1af56 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 @@ -18,69 +18,103 @@ TEST_F(GLES2DecoderTest2, GetVertexAttribfvValidArgs) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + SpecializedSetup<GetVertexAttribfv, 0>(); + typedef GetVertexAttribfv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); EXPECT_CALL( *gl_, GetVertexAttribfv( - 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, reinterpret_cast<GLfloat*>( - shared_memory_address_))); - SpecializedSetup<GetVertexAttribfv, 0>(); + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, result->GetData())); + result->size = 0; GetVertexAttribfv cmd; cmd.Init( 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest2, GetVertexAttribfvInvalidArgs2_0) { EXPECT_CALL(*gl_, GetVertexAttribfv(_, _, _)).Times(0); SpecializedSetup<GetVertexAttribfv, 0>(); + GetVertexAttribfv::Result* result = + static_cast<GetVertexAttribfv::Result*>(shared_memory_address_); + result->size = 0; GetVertexAttribfv cmd; cmd.Init( 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest2, GetVertexAttribfvInvalidArgs2_1) { EXPECT_CALL(*gl_, GetVertexAttribfv(_, _, _)).Times(0); SpecializedSetup<GetVertexAttribfv, 0>(); + GetVertexAttribfv::Result* result = + static_cast<GetVertexAttribfv::Result*>(shared_memory_address_); + result->size = 0; GetVertexAttribfv cmd; cmd.Init( 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest2, GetVertexAttribivValidArgs) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + SpecializedSetup<GetVertexAttribiv, 0>(); + typedef GetVertexAttribiv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); EXPECT_CALL( *gl_, GetVertexAttribiv( - 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, reinterpret_cast<GLint*>( - shared_memory_address_))); - SpecializedSetup<GetVertexAttribiv, 0>(); + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, result->GetData())); + result->size = 0; GetVertexAttribiv cmd; cmd.Init( 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING), + result->GetNumResults()); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } TEST_F(GLES2DecoderTest2, GetVertexAttribivInvalidArgs2_0) { EXPECT_CALL(*gl_, GetVertexAttribiv(_, _, _)).Times(0); SpecializedSetup<GetVertexAttribiv, 0>(); + GetVertexAttribiv::Result* result = + static_cast<GetVertexAttribiv::Result*>(shared_memory_address_); + result->size = 0; GetVertexAttribiv cmd; cmd.Init( 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } TEST_F(GLES2DecoderTest2, GetVertexAttribivInvalidArgs2_1) { EXPECT_CALL(*gl_, GetVertexAttribiv(_, _, _)).Times(0); SpecializedSetup<GetVertexAttribiv, 0>(); + GetVertexAttribiv::Result* result = + static_cast<GetVertexAttribiv::Result*>(shared_memory_address_); + result->size = 0; GetVertexAttribiv cmd; cmd.Init( 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + EXPECT_EQ(0, result->size); } // TODO(gman): GetVertexAttribPointerv @@ -112,6 +146,16 @@ TEST_F(GLES2DecoderTest2, IsBufferValidArgs) { EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest2, IsBufferInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, IsBuffer(kServiceBufferId)).Times(0); + SpecializedSetup<IsBuffer, 0>(); + IsBuffer cmd; + cmd.Init(client_buffer_id_, kInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init(client_buffer_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} + TEST_F(GLES2DecoderTest2, IsEnabledValidArgs) { EXPECT_CALL(*gl_, IsEnabled(GL_BLEND)); SpecializedSetup<IsEnabled, 0>(); @@ -139,6 +183,16 @@ TEST_F(GLES2DecoderTest2, IsEnabledInvalidArgs0_1) { EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); } +TEST_F(GLES2DecoderTest2, IsEnabledInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, IsEnabled(GL_BLEND)).Times(0); + SpecializedSetup<IsEnabled, 0>(); + IsEnabled cmd; + cmd.Init(GL_BLEND, kInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init(GL_BLEND, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} + TEST_F(GLES2DecoderTest2, IsFramebufferValidArgs) { EXPECT_CALL(*gl_, IsFramebufferEXT(kServiceFramebufferId)); SpecializedSetup<IsFramebuffer, 0>(); @@ -148,6 +202,18 @@ TEST_F(GLES2DecoderTest2, IsFramebufferValidArgs) { EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest2, IsFramebufferInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, IsFramebufferEXT(kServiceFramebufferId)).Times(0); + SpecializedSetup<IsFramebuffer, 0>(); + IsFramebuffer cmd; + cmd.Init( + client_framebuffer_id_, kInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init( + client_framebuffer_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} + TEST_F(GLES2DecoderTest2, IsProgramValidArgs) { EXPECT_CALL(*gl_, IsProgram(kServiceProgramId)); SpecializedSetup<IsProgram, 0>(); @@ -157,6 +223,16 @@ TEST_F(GLES2DecoderTest2, IsProgramValidArgs) { EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest2, IsProgramInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, IsProgram(kServiceProgramId)).Times(0); + SpecializedSetup<IsProgram, 0>(); + IsProgram cmd; + cmd.Init(client_program_id_, kInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init(client_program_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} + TEST_F(GLES2DecoderTest2, IsRenderbufferValidArgs) { EXPECT_CALL(*gl_, IsRenderbufferEXT(kServiceRenderbufferId)); SpecializedSetup<IsRenderbuffer, 0>(); @@ -166,6 +242,18 @@ TEST_F(GLES2DecoderTest2, IsRenderbufferValidArgs) { EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest2, IsRenderbufferInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, IsRenderbufferEXT(kServiceRenderbufferId)).Times(0); + SpecializedSetup<IsRenderbuffer, 0>(); + IsRenderbuffer cmd; + cmd.Init( + client_renderbuffer_id_, kInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init( + client_renderbuffer_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} + TEST_F(GLES2DecoderTest2, IsShaderValidArgs) { EXPECT_CALL(*gl_, IsShader(kServiceShaderId)); SpecializedSetup<IsShader, 0>(); @@ -175,6 +263,16 @@ TEST_F(GLES2DecoderTest2, IsShaderValidArgs) { EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest2, IsShaderInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, IsShader(kServiceShaderId)).Times(0); + SpecializedSetup<IsShader, 0>(); + IsShader cmd; + cmd.Init(client_shader_id_, kInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init(client_shader_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} + TEST_F(GLES2DecoderTest2, IsTextureValidArgs) { EXPECT_CALL(*gl_, IsTexture(kServiceTextureId)); SpecializedSetup<IsTexture, 0>(); @@ -184,6 +282,16 @@ TEST_F(GLES2DecoderTest2, IsTextureValidArgs) { EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderTest2, IsTextureInvalidArgsBadSharedMemoryId) { + EXPECT_CALL(*gl_, IsTexture(kServiceTextureId)).Times(0); + SpecializedSetup<IsTexture, 0>(); + IsTexture cmd; + cmd.Init(client_texture_id_, kInvalidSharedMemoryId, shared_memory_offset_); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); + cmd.Init(client_texture_id_, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); +} + TEST_F(GLES2DecoderTest2, LineWidthValidArgs) { EXPECT_CALL(*gl_, LineWidth(1)); SpecializedSetup<LineWidth, 0>(); diff --git a/gpu/command_buffer/service/gles2_cmd_validation_autogen.h b/gpu/command_buffer/service/gles2_cmd_validation_autogen.h index 0573e3c..b2368a2 100644 --- a/gpu/command_buffer/service/gles2_cmd_validation_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_validation_autogen.h @@ -21,6 +21,7 @@ bool ValidateGLenumFaceType(GLenum value); bool ValidateGLbooleanFalse(GLenum value); bool ValidateGLenumFrameBufferParameter(GLenum value); bool ValidateGLenumFrameBufferTarget(GLenum value); +bool ValidateGLenumGLState(GLenum value); bool ValidateGLenumHintMode(GLenum value); bool ValidateGLenumHintTarget(GLenum value); bool ValidateGLenumIndexType(GLenum value); diff --git a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h index b082c09..eed18cd 100644 --- a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h @@ -181,6 +181,98 @@ bool ValidateGLenumFrameBufferTarget(GLenum value) { } } +bool ValidateGLenumGLState(GLenum value) { + switch (value) { + case GL_ACTIVE_TEXTURE: + case GL_ALIASED_LINE_WIDTH_RANGE: + case GL_ALIASED_POINT_SIZE_RANGE: + case GL_ALPHA_BITS: + case GL_ARRAY_BUFFER_BINDING: + case GL_BLEND: + case GL_BLEND_COLOR: + case GL_BLEND_DST_ALPHA: + case GL_BLEND_DST_RGB: + case GL_BLEND_EQUATION_ALPHA: + case GL_BLEND_EQUATION_RGB: + case GL_BLEND_SRC_ALPHA: + case GL_BLEND_SRC_RGB: + case GL_BLUE_BITS: + case GL_COLOR_CLEAR_VALUE: + case GL_COLOR_WRITEMASK: + case GL_COMPRESSED_TEXTURE_FORMATS: + case GL_CULL_FACE: + case GL_CULL_FACE_MODE: + case GL_CURRENT_PROGRAM: + case GL_DEPTH_BITS: + case GL_DEPTH_CLEAR_VALUE: + case GL_DEPTH_FUNC: + case GL_DEPTH_RANGE: + case GL_DEPTH_TEST: + case GL_DEPTH_WRITEMASK: + case GL_DITHER: + case GL_ELEMENT_ARRAY_BUFFER_BINDING: + case GL_FRAMEBUFFER_BINDING: + case GL_FRONT_FACE: + case GL_GENERATE_MIPMAP_HINT: + case GL_GREEN_BITS: + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + case GL_LINE_WIDTH: + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + case GL_MAX_RENDERBUFFER_SIZE: + case GL_MAX_TEXTURE_IMAGE_UNITS: + case GL_MAX_TEXTURE_SIZE: + case GL_MAX_VARYING_VECTORS: + case GL_MAX_VERTEX_ATTRIBS: + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + case GL_MAX_VERTEX_UNIFORM_VECTORS: + case GL_MAX_VIEWPORT_DIMS: + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + case GL_NUM_SHADER_BINARY_FORMATS: + case GL_PACK_ALIGNMENT: + case GL_POLYGON_OFFSET_FACTOR: + case GL_POLYGON_OFFSET_FILL: + case GL_POLYGON_OFFSET_UNITS: + case GL_RED_BITS: + case GL_RENDERBUFFER_BINDING: + case GL_SAMPLE_BUFFERS: + case GL_SAMPLE_COVERAGE_INVERT: + case GL_SAMPLE_COVERAGE_VALUE: + case GL_SAMPLES: + case GL_SCISSOR_BOX: + case GL_SCISSOR_TEST: + case GL_SHADER_BINARY_FORMATS: + case GL_SHADER_COMPILER: + case GL_STENCIL_BACK_FAIL: + case GL_STENCIL_BACK_FUNC: + case GL_STENCIL_BACK_PASS_DEPTH_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_PASS: + case GL_STENCIL_BACK_REF: + case GL_STENCIL_BACK_VALUE_MASK: + case GL_STENCIL_BACK_WRITEMASK: + case GL_STENCIL_BITS: + case GL_STENCIL_CLEAR_VALUE: + case GL_STENCIL_FAIL: + case GL_STENCIL_FUNC: + case GL_STENCIL_PASS_DEPTH_FAIL: + case GL_STENCIL_PASS_DEPTH_PASS: + case GL_STENCIL_REF: + case GL_STENCIL_TEST: + case GL_STENCIL_VALUE_MASK: + case GL_STENCIL_WRITEMASK: + case GL_SUBPIXEL_BITS: + case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_CUBE_MAP: + case GL_UNPACK_ALIGNMENT: + case GL_VIEWPORT: + return true; + default: + return false; + } +} + bool ValidateGLenumHintMode(GLenum value) { switch (value) { case GL_FASTEST: |