diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-02 00:44:29 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-02 00:44:29 +0000 |
commit | ddd968b875f51efee01401fd307f4c691dfd6a9a (patch) | |
tree | f9df8a06531e546b717a8fa328597e787198b142 /gpu | |
parent | 516fc39eeea5658b9aeeda0094d5817edd5ec235 (diff) | |
download | chromium_src-ddd968b875f51efee01401fd307f4c691dfd6a9a.zip chromium_src-ddd968b875f51efee01401fd307f4c691dfd6a9a.tar.gz chromium_src-ddd968b875f51efee01401fd307f4c691dfd6a9a.tar.bz2 |
Attempt to submit this CL for the 3rd time. No changes.
http://src.chromium.org/viewvc/chrome?view=rev&revision=40212
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/661309
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40329 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
18 files changed, 747 insertions, 559 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index b218208..36dd9dd 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -839,9 +839,10 @@ _ENUM_LISTS = { # data_type: The type of data the command uses. For PUTn or PUT types. # count: The number of units per element. For PUTn or PUT types. # unit_test: If False no unit test will be generated. +# expectation: If False the unit test will have no expected calls. _FUNCTION_INFO = { - 'ActiveTexture': {'decoder_func': 'DoActiveTexture'}, + 'ActiveTexture': {'decoder_func': 'DoActiveTexture', 'expectation': False}, 'BindAttribLocation': {'type': 'GLchar'}, 'BindBuffer': {'decoder_func': 'DoBindBuffer'}, 'BindFramebuffer': {'decoder_func': 'glBindFramebufferEXT'}, @@ -924,10 +925,17 @@ _FUNCTION_INFO = { 'needs_size': True, 'cmd_args': 'GLidProgram program, const char* name, NonImmediate GLint* location', + 'result': ['GLint'], }, 'GetBooleanv': {'type': 'GETn'}, 'GetBufferParameteriv': {'type': 'GETn'}, - 'GetError': {'type': 'Is', 'decoder_func': 'GetGLError'}, + 'GetError': { + 'type': 'Is', + 'decoder_func': + 'GetGLError', + 'impl_func': False, + 'result': ['GLenum'], + }, 'GetFloatv': {'type': 'GETn'}, 'GetFramebufferAttachmentParameteriv': { 'type': 'GETn', @@ -935,13 +943,21 @@ _FUNCTION_INFO = { }, 'GetIntegerv': {'type': 'GETn'}, 'GetProgramiv': {'type': 'GETn'}, - 'GetProgramInfoLog': {'type': 'STRn'}, + 'GetProgramInfoLog': { + 'type': 'STRn', + 'get_len_func': 'glGetProgramiv', + 'get_len_enum': 'GL_INFO_LOG_LENGTH', + }, 'GetRenderbufferParameteriv': { 'type': 'GETn', 'decoder_func': 'glGetRenderbufferParameterivEXT', }, - 'GetShaderiv': {'type': 'GETn'}, - 'GetShaderInfoLog': {'type': 'STRn'}, + 'GetShaderiv': {'type': 'GETn', 'decoder_func': 'DoGetShaderiv'}, + 'GetShaderInfoLog': { + 'type': 'STRn', + 'get_len_func': 'glGetShaderiv', + 'get_len_enum': 'GL_INFO_LOG_LENGTH', + }, 'GetShaderPrecisionFormat': { 'type': 'Custom', 'immediate': False, @@ -955,7 +971,17 @@ _FUNCTION_INFO = { 'int32 precision', ], }, - 'GetShaderSource': {'type': 'STRn', 'decoder_func': 'DoGetShaderSource'}, + 'GetShaderSource': { + 'type': 'STRn', + 'decoder_func': 'DoGetShaderSource', + 'get_len_func': 'DoGetShaderiv', + 'get_len_enum': 'GL_SHADER_SOURCE_LENGTH', + 'unit_test': False, + }, + 'GetString': { + 'type': 'Custom', + 'cmd_args': 'GLenumStringType name, uint32 bucket_id', + }, 'GetTexParameterfv': {'type': 'GETn'}, 'GetTexParameteriv': {'type': 'GETn'}, 'GetUniformfv': { @@ -974,6 +1000,7 @@ _FUNCTION_INFO = { 'needs_size': True, 'cmd_args': 'GLidProgram program, const char* name, NonImmediate GLint* location', + 'result': ['GLint'], }, 'GetVertexAttribfv': {'type': 'GETn'}, 'GetVertexAttribiv': {'type': 'GETn'}, @@ -1172,6 +1199,8 @@ class CHeaderWriter(CWriter): class TypeHandler(object): """This class emits code for a particular type of function.""" + _remove_expected_call_re = re.compile(r' EXPECT_CALL.*?;\n', re.S) + def __init__(self): pass @@ -1363,6 +1392,8 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d, def WriteValidUnitTest(self, func, file, test, extra = {}): """Writes a valid unit test.""" + if func.GetInfo('expectation') == False: + test = self._remove_expected_call_re.sub('', test) name = func.name arg_strings = [] count = 0 @@ -1389,7 +1420,7 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d, """Writes a invalid unit test.""" arg_index = 0 for arg in func.GetOriginalArgs(): - num_invalid_values = arg.GetNumInvalidValues() + num_invalid_values = arg.GetNumInvalidValues(func) for value_index in range(0, num_invalid_values): arg_strings = [] parse_result = "kNoError" @@ -1461,22 +1492,28 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { """Writes the validation code for an immediate version of a command.""" pass - def WriteGLES2ImplementationHeader(self, func, file): + def WriteGLES2ImplementationDeclaration(self, func, file): """Writes the GLES2 Implemention declaration.""" + file.Write("%s %s(%s);\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write("\n") + + def WriteGLES2ImplementationHeader(self, func, file): + """Writes the GLES2 Implemention.""" impl_func = func.GetInfo('impl_func') if func.can_auto_generate and (impl_func == None or impl_func == True): file.Write("%s %s(%s) {\n" % (func.return_type, func.original_name, func.MakeTypedOriginalArgString(""))) + for arg in func.GetOriginalArgs(): + arg.WriteClientSideValidationCode(file) file.Write(" helper_->%s(%s);\n" % (func.name, func.MakeOriginalArgString(""))) file.Write("}\n") file.Write("\n") else: - file.Write("%s %s(%s);\n" % - (func.return_type, func.original_name, - func.MakeTypedOriginalArgString(""))) - file.Write("\n") + self.WriteGLES2ImplementationDeclaration(func, file) def WriteImmediateCmdComputeSize(self, func, file): """Writes the size computation code for the immediate version of a cmd.""" @@ -2989,6 +3026,8 @@ class IsHandler(TypeHandler): """Overrriden from TypeHandler.""" func.AddCmdArg(Argument("result_shm_id", 'uint32')) func.AddCmdArg(Argument("result_shm_offset", 'uint32')) + if func.GetInfo('result') == None: + func.AddInfo('result', ['uint32']) def WriteServiceUnitTest(self, func, file): """Overrriden from TypeHandler.""" @@ -3044,20 +3083,26 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { def WriteGLES2ImplementationHeader(self, func, file): """Overrriden from TypeHandler.""" - file.Write("%s %s(%s) {\n" % - (func.return_type, func.original_name, - func.MakeTypedOriginalArgString(""))) - arg_string = func.MakeOriginalArgString("") - comma = "" - if len(arg_string) > 0: - comma = ", " - file.Write(" helper_->%s(%s%sresult_shm_id(), result_shm_offset());\n" % - (func.name, arg_string, comma)) - file.Write(" WaitForCmd();\n") - file.Write(" return GetResultAs<%s>();\n" % - func.return_type) - file.Write("}\n") - file.Write("\n") + impl_func = func.GetInfo('impl_func') + if impl_func == None or impl_func == True: + 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(" Result* result = GetResultAs<Result*>();\n") + file.Write(" *result = 0;\n") + arg_string = func.MakeOriginalArgString("") + comma = "" + if len(arg_string) > 0: + comma = ", " + file.Write(" helper_->%s(%s%sresult_shm_id(), result_shm_offset());\n" % + (func.name, arg_string, comma)) + file.Write(" WaitForCmd();\n") + file.Write(" return *result;\n") + file.Write("}\n") + file.Write("\n") + else: + self.WriteGLES2ImplementationDeclaration(func, file) class STRnHandler(TypeHandler): @@ -3066,18 +3111,95 @@ class STRnHandler(TypeHandler): def __init__(self): TypeHandler.__init__(self) + def InitFunction(self, func): + """Overrriden from TypeHandler.""" + # remove all but the first cmd args. + cmd_args = func.GetCmdArgs() + func.ClearCmdArgs() + func.AddCmdArg(cmd_args[0]) + # add on a bucket id. + func.AddCmdArg(Argument('bucket_id', 'uint32')) + def WriteGLES2ImplementationHeader(self, func, file): """Overrriden from TypeHandler.""" - file.Write("// TODO(gman): Implement this\n") - TypeHandler.WriteGLES2ImplementationHeader(self, func, file) + code = """%(return_type)s %(func_name)s(%(args)s) { + helper_->SetBucketSize(kResultBucketId, 0); + helper_->%(func_name)s(%(id_name)s, kResultBucketId); + std::string str; + if (GetBucketAsString(kResultBucketId, &str)) { + GLsizei max_size = + std::min(static_cast<size_t>(%(bufsize_name)s) - 1, str.size()); + if (%(length_name)s != NULL) { + *%(length_name)s = max_size; + } + memcpy(%(dest_name)s, str.c_str(), max_size); + %(dest_name)s[max_size] = '\\0'; + } +} +""" + args = func.GetOriginalArgs() + file.Write(code % { + 'return_type': func.return_type, + 'func_name': func.original_name, + 'args': func.MakeTypedOriginalArgString(""), + 'id_name': args[0].name, + 'bufsize_name': args[1].name, + 'length_name': args[2].name, + 'dest_name': args[3].name, + }) def WriteServiceUnitTest(self, func, file): """Overrriden from TypeHandler.""" - file.Write("// TODO(gman): %s\n\n" % func.name) + valid_test = """ +TEST_F(%(test_name)s, %(name)sValidArgs) { + const char* kInfo = "hello"; + const uint32 kBucketId = 123; + SpecializedSetup<%(name)s, 0>(); +%(expect_len_code)s + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)) + .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)), + SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1))); + %(name)s cmd; + cmd.Init(%(args)s); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); + ASSERT_TRUE(bucket != NULL); + EXPECT_EQ(strlen(kInfo) + 1, bucket->size()); + EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo, + bucket->size())); +} +""" + args = func.GetOriginalArgs() + id_name = args[0].GetValidGLArg(0, 0) + get_len_func = func.GetInfo('get_len_func') + get_len_enum = func.GetInfo('get_len_enum') + sub = { + 'id_name': id_name, + 'get_len_func': get_len_func, + 'get_len_enum': get_len_enum, + 'gl_args': '%s, strlen(kInfo) + 1, _, _' % args[0].GetValidGLArg(0, 0), + 'args': '%s, kBucketId' % args[0].GetValidArg(0, 0), + 'expect_len_code': '', + } + if get_len_func[0:2] == 'gl': + sub['expect_len_code'] = ( + " EXPECT_CALL(*gl_, %s(%s, %s, _))\n" + " .WillOnce(SetArgumentPointee<2>(strlen(kInfo)));") % ( + get_len_func[2:], id_name, get_len_enum) + self.WriteValidUnitTest(func, file, valid_test, sub) - def WriteImmediateServiceUnitTest(self, func, file): - """Overrriden from TypeHandler.""" - file.Write("// TODO(gman): %s\n\n" % func.name) + invalid_test = """ +TEST_F(%(test_name)s, %(name)sInvalidArgs) { + const uint32 kBucketId = 123; + EXPECT_CALL(*gl_, %(gl_func_name)s(_, _, _, _)) + .Times(0); + %(name)s cmd; + cmd.Init(kInvalidClientId, kBucketId); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); +} +""" + self.WriteValidUnitTest(func, file, invalid_test) def WriteServiceImplementation(self, func, file): """Overrriden from TypeHandler.""" @@ -3085,34 +3207,21 @@ class STRnHandler(TypeHandler): "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name) file.Write( " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name) - args = func.GetOriginalArgs() - all_but_last_2_args = args[:-2] - for arg in all_but_last_2_args: - arg.WriteGetCode(file) - self.WriteGetDataSizeCode(func, file) - size_arg = args[-2] - file.Write(" uint32 size_shm_id = c.%s_shm_id;\n" % size_arg.name) - file.Write(" uint32 size_shm_offset = c.%s_shm_offset;\n" % size_arg.name) - file.Write(" GLsizei* length = NULL;\n") - file.Write(" if (size_shm_id != 0 || size_shm_offset != 0) {\n" - " length = GetSharedMemoryAs<GLsizei*>(\n" - " size_shm_id, size_shm_offset, sizeof(*length));\n" - " if (!length) {\n" - " return error::kOutOfBounds;\n" - " }\n" - " }\n") - dest_arg = args[-1] - bufsize_arg = args[-3] - file.Write( - " %s %s = GetSharedMemoryAs<%s>(\n" % - (dest_arg.type, dest_arg.name, dest_arg.type)) + args = func.GetCmdArgs() + id_arg = args[0] + bucket_arg = args[1] + id_arg.WriteGetCode(file) + bucket_arg.WriteGetCode(file) + id_arg.WriteValidationCode(file) + file.Write(" GLint len = 0;\n") + file.Write(" %s(%s, %s, &len);\n" % ( + func.GetInfo('get_len_func'), id_arg.name, + func.GetInfo('get_len_enum'))) + file.Write(" Bucket* bucket = CreateBucket(%s);\n" % bucket_arg.name) + file.Write(" bucket->SetSize(len + 1);\n"); file.Write( - " c.%s_shm_id, c.%s_shm_offset, %s);\n" % - (dest_arg.name, dest_arg.name, bufsize_arg.name)) - for arg in all_but_last_2_args + [dest_arg]: - arg.WriteValidationCode(file) - func.WriteValidationCode(file) - func.WriteHandlerImplementation(file) + " %s(%s, len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1));\n" % + (func.GetGLFunctionName(), id_arg.name)) file.Write(" return error::kNoError;\n") file.Write("}\n") file.Write("\n") @@ -3169,7 +3278,7 @@ class Argument(object): def GetValidGLArg(self, offset, index): return str(offset + 1) - def GetNumInvalidValues(self): + def GetNumInvalidValues(self, func): """returns the number of invalid values to be tested.""" return 0 @@ -3184,11 +3293,11 @@ class Argument(object): def WriteValidationCode(self, file): """Writes the validation code for an argument.""" - if self.type == 'GLsizei' or self.type == 'GLsizeiptr': - file.Write(" if (%s < 0) {\n" % self.name) - file.Write(" SetGLError(GL_INVALID_VALUE);\n") - file.Write(" return error::kNoError;\n") - file.Write(" }\n") + pass + + def WriteClientSideValidationCode(self, file): + """Writes the validation code for an argument.""" + pass def WriteGetAddress(self, file): """Writes the code to get the address this argument refers to.""" @@ -3200,21 +3309,37 @@ class Argument(object): class SizeArgument(Argument): + """class for GLsizei and GLsizeiptr.""" def __init__(self, name, type): Argument.__init__(self, name, type) - def GetNumInvalidValues(self): + def GetNumInvalidValues(self, func): """overridden from Argument.""" + if func.is_immediate: + return 0 return 1 def GetInvalidArg(self, offset, index): - """returns an invalid value and expected parse result by index.""" + """overridden from Argument.""" return ("-1", "kNoError", "GL_INVALID_VALUE") + def WriteValidationCode(self, file): + """overridden from Argument.""" + file.Write(" if (%s < 0) {\n" % self.name) + file.Write(" SetGLError(GL_INVALID_VALUE);\n") + file.Write(" return error::kNoError;\n") + file.Write(" }\n") + + def WriteClientSideValidationCode(self, file): + """overridden from Argument.""" + file.Write(" if (%s < 0) {\n" % self.name) + file.Write(" SetGLError(GL_INVALID_VALUE);\n") + file.Write(" return;\n") + file.Write(" }\n") class EnumBaseArgument(Argument): - """Base calss for EnumArgument, IntArgument and BoolArgument""" + """Base class for EnumArgument, IntArgument and BoolArgument""" def __init__(self, name, gl_type, type, gl_error): Argument.__init__(self, name, gl_type) @@ -3242,7 +3367,7 @@ class EnumBaseArgument(Argument): def GetValidGLArg(self, offset, index): return self.GetValidArg(offset, index) - def GetNumInvalidValues(self): + def GetNumInvalidValues(self, func): """returns the number of invalid values to be tested.""" if 'invalid' in self.enum_info: invalid = self.enum_info['invalid'] @@ -3256,8 +3381,8 @@ class EnumBaseArgument(Argument): num_invalid = len(invalid) if index >= num_invalid: index = num_invalid - 1 - return (invalid[index], "kNoError", "GL_INVALID_ENUM") - return ("---ERROR1---", "kNoError", "GL_INVALID_ENUM") + return (invalid[index], "kNoError", self.gl_error) + return ("---ERROR1---", "kNoError", self.gl_error) class EnumArgument(EnumBaseArgument): @@ -3338,7 +3463,7 @@ class PointerArgument(Argument): """Overridden from Argument.""" return "reinterpret_cast<%s>(shared_memory_address_)" % self.type - def GetNumInvalidValues(self): + def GetNumInvalidValues(self, func): """Overridden from Argument.""" return 2 @@ -3440,6 +3565,7 @@ class Function(object): self.init_args = init_args self.args_for_cmds = args_for_cmds self.type_handler.InitFunction(self) + self.is_immediate = False def IsType(self, type_name): """Returns true if function is a certain type.""" @@ -3451,6 +3577,10 @@ class Function(object): return getattr(self.info, name) return None + def AddInfo(self, name, value): + """Adds an info.""" + setattr(self.info, name, value) + def GetGLFunctionName(self): """Gets the function to call to execute GL for this command.""" if self.GetInfo('decoder_func'): @@ -3475,6 +3605,10 @@ class Function(object): """Gets the command args for this function.""" return self.cmd_args + def ClearCmdArgs(self): + """Clears the command args for this function.""" + self.cmd_args = [] + def GetInitArgs(self): """Gets the init args for this function.""" return self.init_args @@ -3646,6 +3780,7 @@ class ImmediateFunction(Function): cmd_args, new_init_args, 0) + self.is_immediate = True def WriteServiceImplementation(self, file): """Overridden from Function""" diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index df3ed0e..6ae38f4 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -491,14 +491,9 @@ c.Init(program, pname, params_shm_id, params_shm_offset); } - void GetProgramInfoLog( - GLuint program, GLsizei bufsize, uint32 length_shm_id, - uint32 length_shm_offset, uint32 infolog_shm_id, - uint32 infolog_shm_offset) { + void GetProgramInfoLog(GLuint program, uint32 bucket_id) { gles2::GetProgramInfoLog& c = GetCmdSpace<gles2::GetProgramInfoLog>(); - c.Init( - program, bufsize, length_shm_id, length_shm_offset, infolog_shm_id, - infolog_shm_offset); + c.Init(program, bucket_id); } void GetRenderbufferParameteriv( @@ -516,14 +511,9 @@ c.Init(shader, pname, params_shm_id, params_shm_offset); } - void GetShaderInfoLog( - GLuint shader, GLsizei bufsize, uint32 length_shm_id, - uint32 length_shm_offset, uint32 infolog_shm_id, - uint32 infolog_shm_offset) { + void GetShaderInfoLog(GLuint shader, uint32 bucket_id) { gles2::GetShaderInfoLog& c = GetCmdSpace<gles2::GetShaderInfoLog>(); - c.Init( - shader, bufsize, length_shm_id, length_shm_offset, infolog_shm_id, - infolog_shm_offset); + c.Init(shader, bucket_id); } void GetShaderPrecisionFormat( @@ -534,19 +524,14 @@ c.Init(shadertype, precisiontype, result_shm_id, result_shm_offset); } - void GetShaderSource( - GLuint shader, GLsizei bufsize, uint32 length_shm_id, - uint32 length_shm_offset, uint32 source_shm_id, - uint32 source_shm_offset) { + void GetShaderSource(GLuint shader, uint32 bucket_id) { gles2::GetShaderSource& c = GetCmdSpace<gles2::GetShaderSource>(); - c.Init( - shader, bufsize, length_shm_id, length_shm_offset, source_shm_id, - source_shm_offset); + c.Init(shader, bucket_id); } - void GetString(GLenum name) { + void GetString(GLenum name, uint32 bucket_id) { gles2::GetString& c = GetCmdSpace<gles2::GetString>(); - c.Init(name); + c.Init(name, bucket_id); } void GetTexParameterfv( diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 450e48d..0dacb54 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -29,7 +29,8 @@ GLES2Implementation::GLES2Implementation( transfer_buffer_(transfer_buffer_size, helper, transfer_buffer), transfer_buffer_id_(transfer_buffer_id), pack_alignment_(4), - unpack_alignment_(4) { + unpack_alignment_(4), + error_bits_(0) { // Eat 1 id so we start at 1 instead of 0. GLuint eat; MakeIds(1, &eat); @@ -58,12 +59,47 @@ void GLES2Implementation::WaitForCmd() { helper_->CommandBufferHelper::Finish(); } +GLenum GLES2Implementation::GetError() { + return GetGLError(); +} + +GLenum GLES2Implementation::GetGLError() { + // Check the GL error first, then our wrapped error. + typedef gles2::GetError::Result Result; + Result* result = GetResultAs<Result*>(); + *result = GL_NO_ERROR; + helper_->GetError(result_shm_id(), result_shm_offset()); + WaitForCmd(); + GLenum error = *result; + if (error == GL_NO_ERROR && error_bits_ != 0) { + for (uint32 mask = 1; mask != 0; mask = mask << 1) { + if ((error_bits_ & mask) != 0) { + error = GLES2Util::GLErrorBitToGLError(mask); + break; + } + } + } + + if (error != GL_NO_ERROR) { + // There was an error, clear the corresponding wrapped error. + error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error); + } + return error; +} + +void GLES2Implementation::SetGLError(GLenum error) { + error_bits_ |= GLES2Util::GLErrorToErrorBit(error); +} + void GLES2Implementation::GetBucketContents(uint32 bucket_id, std::vector<int8>* data) { DCHECK(data); + typedef cmd::GetBucketSize::Result Result; + Result* result = GetResultAs<Result*>(); + *result = 0; helper_->GetBucketSize(bucket_id, result_shm_id(), result_shm_offset()); WaitForCmd(); - uint32 size = GetResultAs<cmd::GetBucketSize::Result>(); + uint32 size = *result; data->resize(size); if (size > 0u) { uint32 max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); @@ -108,15 +144,25 @@ void GLES2Implementation::SetBucketContents( } } -std::string GLES2Implementation::GetBucketAsString(uint32 bucket_id) { +bool GLES2Implementation::GetBucketAsString( + uint32 bucket_id, std::string* str) { + DCHECK(str); std::vector<int8> data; + // NOTE: strings are passed NULL terminated. That means the empty + // string will have a size of 1 and no-string will have a size of 0 GetBucketContents(bucket_id, &data); - return std::string(reinterpret_cast<char*>(&data[0]), data.size()); + if (data.empty()) { + return false; + } + str->assign(&data[0], &data[0] + data.size() - 1); + return true; } void GLES2Implementation::SetBucketAsString( uint32 bucket_id, const std::string& str) { - SetBucketContents(bucket_id, str.c_str(), str.size()); + // NOTE: strings are passed NULL terminated. That means the empty + // string will have a size of 1 and no-string will have a size of 0 + SetBucketContents(bucket_id, str.c_str(), str.size() + 1); } void GLES2Implementation::DrawElements( @@ -157,18 +203,24 @@ void GLES2Implementation::GetVertexAttribPointerv( GLint GLES2Implementation::GetAttribLocation( GLuint program, const char* name) { + typedef cmd::GetBucketSize::Result Result; + Result* result = GetResultAs<Result*>(); + *result = -1; helper_->GetAttribLocationImmediate( program, name, result_shm_id(), result_shm_offset()); WaitForCmd(); - return GetResultAs<GLint>(); + return *result; } GLint GLES2Implementation::GetUniformLocation( GLuint program, const char* name) { + typedef cmd::GetBucketSize::Result Result; + Result* result = GetResultAs<Result*>(); + *result = -1; helper_->GetUniformLocationImmediate( program, name, result_shm_id(), result_shm_offset()); WaitForCmd(); - return GetResultAs<GLint>(); + return *result; } void GLES2Implementation::PixelStorei(GLenum pname, GLint param) { @@ -195,6 +247,10 @@ void GLES2Implementation::VertexAttribPointer( void GLES2Implementation::ShaderSource( GLuint shader, GLsizei count, const char** source, const GLint* length) { + if (count < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } // TODO(gman): change to use buckets and check that there is enough room. // Compute the total size. @@ -233,6 +289,15 @@ void GLES2Implementation::BufferData( void GLES2Implementation::BufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { + if (size == 0) { + return; + } + + if (size < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + const int8* source = static_cast<const int8*>(data); GLsizeiptr max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); while (size) { @@ -252,7 +317,11 @@ void GLES2Implementation::BufferSubData( void GLES2Implementation::CompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei image_size, const void* data) { - // TODO(gman): Switch to use buckets alwayst or at least if no room in shared + if (width < 0 || height < 0 || level < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + // TODO(gman): Switch to use buckets always or at least if no room in shared // memory. DCHECK_LE(image_size, static_cast<GLsizei>( @@ -268,7 +337,11 @@ void GLES2Implementation::CompressedTexImage2D( void GLES2Implementation::CompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei image_size, const void* data) { - // TODO(gman): Switch to use buckets alwayst or at least if no room in shared + if (width < 0 || height < 0 || level < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + // TODO(gman): Switch to use buckets always or at least if no room in shared // memory. DCHECK_LE(image_size, static_cast<GLsizei>( @@ -285,6 +358,10 @@ void GLES2Implementation::TexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) { + if (level < 0 || height < 0 || width < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } helper_->TexImage2D( target, level, internalformat, width, height, border, format, type, 0, 0); if (pixels) { @@ -295,6 +372,10 @@ void GLES2Implementation::TexImage2D( void GLES2Implementation::TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) { + if (level < 0 || height < 0 || width < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } const int8* source = static_cast<const int8*>(pixels); GLsizeiptr max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); GLsizeiptr unpadded_row_size = GLES2Util::ComputeImageDataSize( @@ -355,8 +436,16 @@ GLenum GLES2Implementation::CheckFramebufferStatus(GLenum target) { void GLES2Implementation::GetActiveAttrib( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { + if (bufsize < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + // Clear the bucket so if we the command fails nothing will be in it. + helper_->SetBucketSize(kResultBucketId, 0); typedef gles2::GetActiveAttrib::Result Result; Result* result = static_cast<Result*>(result_buffer_); + // Set as failed so if the command fails we'll recover. + result->success = false; helper_->GetActiveAttrib(program, index, kResultBucketId, result_shm_id(), result_shm_offset()); WaitForCmd(); @@ -386,8 +475,16 @@ void GLES2Implementation::GetActiveAttrib( void GLES2Implementation::GetActiveUniform( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { + if (bufsize < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + // Clear the bucket so if we the command fails nothing will be in it. + helper_->SetBucketSize(kResultBucketId, 0); typedef gles2::GetActiveUniform::Result Result; Result* result = static_cast<Result*>(result_buffer_); + // Set as failed so if the command fails we'll recover. + result->success = false; helper_->GetActiveUniform(program, index, kResultBucketId, result_shm_id(), result_shm_offset()); WaitForCmd(); @@ -416,6 +513,10 @@ void GLES2Implementation::GetActiveUniform( void GLES2Implementation::GetAttachedShaders( GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { + if (maxcount < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } typedef gles2::GetAttachedShaders::Result Result; uint32 size = Result::ComputeSize(maxcount); Result* result = transfer_buffer_.AllocTyped<Result>(size); @@ -433,16 +534,6 @@ void GLES2Implementation::GetAttachedShaders( transfer_buffer_.FreePendingToken(result, token); } -void GLES2Implementation::GetProgramInfoLog( - GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { - // TODO(gman): implement. -} - -void GLES2Implementation::GetShaderInfoLog( - GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { - // TODO(gman): implement. -} - void GLES2Implementation::GetShaderPrecisionFormat( GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { typedef gles2::GetShaderPrecisionFormat::Result Result; @@ -461,14 +552,26 @@ void GLES2Implementation::GetShaderPrecisionFormat( } } -void GLES2Implementation::GetShaderSource( - GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { - // TODO(gman): implement. -} - const GLubyte* GLES2Implementation::GetString(GLenum name) { - // TODO(gman): implement. - return 0; + const char* result; + GLStringMap::const_iterator it = gl_strings_.find(name); + if (it != gl_strings_.end()) { + result = it->second.c_str(); + } else { + // Clear the bucket so if we the command fails nothing will be in it. + helper_->SetBucketSize(kResultBucketId, 0); + helper_->GetString(name, kResultBucketId); + std::string str; + if (GetBucketAsString(kResultBucketId, &str)) { + std::pair<GLStringMap::const_iterator, bool> insert_result = + gl_strings_.insert(std::make_pair(name, str)); + DCHECK(insert_result.second); + result = insert_result.first->second.c_str(); + } else { + result = NULL; + } + } + return reinterpret_cast<const GLubyte*>(result); } void GLES2Implementation::GetUniformfv( @@ -492,6 +595,10 @@ void GLES2Implementation::ReadPixels( GLenum type, void* pixels) { // Note: Negative widths and heights are not handled here but are handled // by the service side so the glGetError wrapping works. + if (width < 0 || height < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } if (width == 0 || height == 0) { return; } diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 579e0d3..339ed4b 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -5,6 +5,7 @@ #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ +#include <map> #include <string> #include <vector> #include "gpu/command_buffer/common/gles2_cmd_utils.h" @@ -62,9 +63,15 @@ class GLES2Implementation { // Gets the value of the result. template <typename T> T GetResultAs() const { - return *static_cast<T*>(result_buffer_); + return static_cast<T>(result_buffer_); } + // Gets the GLError through our wrapper. + GLenum GetGLError(); + + // Sets our wrapper for the GLError. + void SetGLError(GLenum error); + // Waits for all commands to execute. void WaitForCmd(); @@ -78,8 +85,9 @@ class GLES2Implementation { // Sets the contents of a bucket. void SetBucketContents(uint32 bucket_id, const void* data, size_t size); - // Gets the contents of a bucket as a string. - std::string GetBucketAsString(uint32 bucket_id); + // Gets the contents of a bucket as a string. Returns false if there is no + // string available which is a separate case from the empty string. + bool GetBucketAsString(uint32 bucket_id, std::string* str); // Sets the contents of a bucket as a string. void SetBucketAsString(uint32 bucket_id, const std::string& str); @@ -102,10 +110,17 @@ class GLES2Implementation { // unpack alignment as last set by glPixelStorei GLint unpack_alignment_; + // Current GL error bits. + uint32 error_bits_; + + // Map of GLenum to Strings for glGetString. We need to cache these because + // the pointer passed back to the client has to remain valid for eternity. + typedef std::map<uint32, std::string> GLStringMap; + GLStringMap gl_strings_; + DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); }; - } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index 8b30119..b758002 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -103,6 +103,14 @@ void CompressedTexSubImage2D( void CopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { + if (width < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + if (height < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } helper_->CopyTexImage2D( target, level, internalformat, x, y, width, height, border); } @@ -110,6 +118,14 @@ void CopyTexImage2D( void CopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { + if (width < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + if (height < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } helper_->CopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height); } @@ -185,6 +201,10 @@ void DisableVertexAttribArray(GLuint index) { } void DrawArrays(GLenum mode, GLint first, GLsizei count) { + if (count < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } helper_->DrawArrays(mode, first, count); } @@ -274,11 +294,7 @@ void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) { memcpy(params, result_buffer_, num_values * sizeof(*params)); } -GLenum GetError() { - helper_->GetError(result_shm_id(), result_shm_offset()); - WaitForCmd(); - return GetResultAs<GLenum>(); -} +GLenum GetError(); void GetFloatv(GLenum pname, GLfloat* params) { helper_->GetFloatv(pname, result_shm_id(), result_shm_offset()); @@ -314,10 +330,21 @@ void GetProgramiv(GLuint program, GLenum pname, GLint* params) { memcpy(params, result_buffer_, num_values * sizeof(*params)); } -// TODO(gman): Implement this void GetProgramInfoLog( - GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); - + GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { + helper_->SetBucketSize(kResultBucketId, 0); + helper_->GetProgramInfoLog(program, kResultBucketId); + std::string str; + if (GetBucketAsString(kResultBucketId, &str)) { + GLsizei max_size = + std::min(static_cast<size_t>(bufsize) - 1, str.size()); + if (length != NULL) { + *length = max_size; + } + memcpy(infolog, str.c_str(), max_size); + infolog[max_size] = '\0'; + } +} void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) { helper_->GetRenderbufferParameteriv( target, pname, result_shm_id(), result_shm_offset()); @@ -335,17 +362,39 @@ void GetShaderiv(GLuint shader, GLenum pname, GLint* params) { memcpy(params, result_buffer_, num_values * sizeof(*params)); } -// TODO(gman): Implement this void GetShaderInfoLog( - GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); - + GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { + helper_->SetBucketSize(kResultBucketId, 0); + helper_->GetShaderInfoLog(shader, kResultBucketId); + std::string str; + if (GetBucketAsString(kResultBucketId, &str)) { + GLsizei max_size = + std::min(static_cast<size_t>(bufsize) - 1, str.size()); + if (length != NULL) { + *length = max_size; + } + memcpy(infolog, str.c_str(), max_size); + infolog[max_size] = '\0'; + } +} void GetShaderPrecisionFormat( GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); -// TODO(gman): Implement this void GetShaderSource( - GLuint shader, GLsizei bufsize, GLsizei* length, char* source); - + GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { + helper_->SetBucketSize(kResultBucketId, 0); + helper_->GetShaderSource(shader, kResultBucketId); + std::string str; + if (GetBucketAsString(kResultBucketId, &str)) { + GLsizei max_size = + std::min(static_cast<size_t>(bufsize) - 1, str.size()); + if (length != NULL) { + *length = max_size; + } + memcpy(source, str.c_str(), max_size); + source[max_size] = '\0'; + } +} const GLubyte* GetString(GLenum name); void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) { @@ -397,45 +446,66 @@ void Hint(GLenum target, GLenum mode) { } GLboolean IsBuffer(GLuint buffer) { + typedef IsBuffer::Result Result; + Result* result = GetResultAs<Result*>(); + *result = 0; helper_->IsBuffer(buffer, result_shm_id(), result_shm_offset()); WaitForCmd(); - return GetResultAs<GLboolean>(); + return *result; } GLboolean IsEnabled(GLenum cap) { + typedef IsEnabled::Result Result; + Result* result = GetResultAs<Result*>(); + *result = 0; helper_->IsEnabled(cap, result_shm_id(), result_shm_offset()); WaitForCmd(); - return GetResultAs<GLboolean>(); + return *result; } GLboolean IsFramebuffer(GLuint framebuffer) { + typedef IsFramebuffer::Result Result; + Result* result = GetResultAs<Result*>(); + *result = 0; helper_->IsFramebuffer(framebuffer, result_shm_id(), result_shm_offset()); WaitForCmd(); - return GetResultAs<GLboolean>(); + return *result; } GLboolean IsProgram(GLuint program) { + typedef IsProgram::Result Result; + Result* result = GetResultAs<Result*>(); + *result = 0; helper_->IsProgram(program, result_shm_id(), result_shm_offset()); WaitForCmd(); - return GetResultAs<GLboolean>(); + return *result; } GLboolean IsRenderbuffer(GLuint renderbuffer) { + typedef IsRenderbuffer::Result Result; + Result* result = GetResultAs<Result*>(); + *result = 0; helper_->IsRenderbuffer(renderbuffer, result_shm_id(), result_shm_offset()); WaitForCmd(); - return GetResultAs<GLboolean>(); + return *result; } GLboolean IsShader(GLuint shader) { + typedef IsShader::Result Result; + Result* result = GetResultAs<Result*>(); + *result = 0; helper_->IsShader(shader, result_shm_id(), result_shm_offset()); WaitForCmd(); - return GetResultAs<GLboolean>(); + return *result; } GLboolean IsTexture(GLuint texture) { + typedef IsTexture::Result Result; + Result* result = GetResultAs<Result*>(); + *result = 0; helper_->IsTexture(texture, result_shm_id(), result_shm_offset()); WaitForCmd(); - return GetResultAs<GLboolean>(); + return *result; } void LineWidth(GLfloat width) { @@ -458,6 +528,14 @@ void ReadPixels( void RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { + if (width < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + if (height < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } helper_->RenderbufferStorage(target, internalformat, width, height); } @@ -466,6 +544,14 @@ void SampleCoverage(GLclampf value, GLboolean invert) { } void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { + if (width < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + if (height < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } helper_->Scissor(x, y, width, height); } @@ -645,6 +731,14 @@ void VertexAttribPointer( const void* ptr); void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { + if (width < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } + if (height < 0) { + SetGLError(GL_INVALID_VALUE); + return; + } helper_->Viewport(x, y, width, height); } diff --git a/gpu/command_buffer/common/GLES2/gl2types.h b/gpu/command_buffer/common/GLES2/gl2types.h index 9db8bf1..97fbe02 100644 --- a/gpu/command_buffer/common/GLES2/gl2types.h +++ b/gpu/command_buffer/common/GLES2/gl2types.h @@ -26,6 +26,7 @@ typedef unsigned int GLuint; typedef khronos_float_t GLfloat; typedef khronos_float_t GLclampf; typedef khronos_int32_t GLfixed; +typedef char GLchar; /* GL types for handling large vertex buffer objects */ typedef khronos_intptr_t GLintptr; diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h index c642892..4f6f649 100644 --- a/gpu/command_buffer/common/gles2_cmd_format.h +++ b/gpu/command_buffer/common/gles2_cmd_format.h @@ -93,6 +93,8 @@ struct GetAttribLocation { static const CommandId kCmdId = kGetAttribLocation; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef GLint Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -156,6 +158,8 @@ struct GetAttribLocationImmediate { static const CommandId kCmdId = kGetAttribLocationImmediate; static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + typedef GLint Result; + static uint32 ComputeDataSize(const char* s) { return strlen(s); } @@ -213,6 +217,8 @@ struct GetUniformLocation { static const CommandId kCmdId = kGetUniformLocation; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef GLint Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -276,6 +282,8 @@ struct GetUniformLocationImmediate { static const CommandId kCmdId = kGetUniformLocationImmediate; static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + typedef GLint Result; + static uint32 ComputeDataSize(const char* s) { return strlen(s); } diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 19824a4..245a3c8 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -3217,6 +3217,8 @@ struct GetError { static const CommandId kCmdId = kGetError; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef GLenum Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -3462,55 +3464,30 @@ struct GetProgramInfoLog { header.SetCmd<ValueType>(); } - void Init( - GLuint _program, GLsizei _bufsize, uint32 _length_shm_id, - uint32 _length_shm_offset, uint32 _infolog_shm_id, - uint32 _infolog_shm_offset) { + void Init(GLuint _program, uint32 _bucket_id) { SetHeader(); program = _program; - bufsize = _bufsize; - length_shm_id = _length_shm_id; - length_shm_offset = _length_shm_offset; - infolog_shm_id = _infolog_shm_id; - infolog_shm_offset = _infolog_shm_offset; + bucket_id = _bucket_id; } - void* Set( - void* cmd, GLuint _program, GLsizei _bufsize, uint32 _length_shm_id, - uint32 _length_shm_offset, uint32 _infolog_shm_id, - uint32 _infolog_shm_offset) { - static_cast<ValueType*>( - cmd)->Init( - _program, _bufsize, _length_shm_id, _length_shm_offset, - _infolog_shm_id, _infolog_shm_offset); + void* Set(void* cmd, GLuint _program, uint32 _bucket_id) { + static_cast<ValueType*>(cmd)->Init(_program, _bucket_id); return NextCmdAddress<ValueType>(cmd); } gpu::CommandHeader header; uint32 program; - int32 bufsize; - uint32 length_shm_id; - uint32 length_shm_offset; - uint32 infolog_shm_id; - uint32 infolog_shm_offset; + uint32 bucket_id; }; -COMPILE_ASSERT(sizeof(GetProgramInfoLog) == 28, - Sizeof_GetProgramInfoLog_is_not_28); +COMPILE_ASSERT(sizeof(GetProgramInfoLog) == 12, + Sizeof_GetProgramInfoLog_is_not_12); COMPILE_ASSERT(offsetof(GetProgramInfoLog, header) == 0, OffsetOf_GetProgramInfoLog_header_not_0); COMPILE_ASSERT(offsetof(GetProgramInfoLog, program) == 4, OffsetOf_GetProgramInfoLog_program_not_4); -COMPILE_ASSERT(offsetof(GetProgramInfoLog, bufsize) == 8, - OffsetOf_GetProgramInfoLog_bufsize_not_8); -COMPILE_ASSERT(offsetof(GetProgramInfoLog, length_shm_id) == 12, - OffsetOf_GetProgramInfoLog_length_shm_id_not_12); -COMPILE_ASSERT(offsetof(GetProgramInfoLog, length_shm_offset) == 16, - OffsetOf_GetProgramInfoLog_length_shm_offset_not_16); -COMPILE_ASSERT(offsetof(GetProgramInfoLog, infolog_shm_id) == 20, - OffsetOf_GetProgramInfoLog_infolog_shm_id_not_20); -COMPILE_ASSERT(offsetof(GetProgramInfoLog, infolog_shm_offset) == 24, - OffsetOf_GetProgramInfoLog_infolog_shm_offset_not_24); +COMPILE_ASSERT(offsetof(GetProgramInfoLog, bucket_id) == 8, + OffsetOf_GetProgramInfoLog_bucket_id_not_8); struct GetRenderbufferParameteriv { typedef GetRenderbufferParameteriv ValueType; @@ -3627,55 +3604,30 @@ struct GetShaderInfoLog { header.SetCmd<ValueType>(); } - void Init( - GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id, - uint32 _length_shm_offset, uint32 _infolog_shm_id, - uint32 _infolog_shm_offset) { + void Init(GLuint _shader, uint32 _bucket_id) { SetHeader(); shader = _shader; - bufsize = _bufsize; - length_shm_id = _length_shm_id; - length_shm_offset = _length_shm_offset; - infolog_shm_id = _infolog_shm_id; - infolog_shm_offset = _infolog_shm_offset; + bucket_id = _bucket_id; } - void* Set( - void* cmd, GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id, - uint32 _length_shm_offset, uint32 _infolog_shm_id, - uint32 _infolog_shm_offset) { - static_cast<ValueType*>( - cmd)->Init( - _shader, _bufsize, _length_shm_id, _length_shm_offset, - _infolog_shm_id, _infolog_shm_offset); + void* Set(void* cmd, GLuint _shader, uint32 _bucket_id) { + static_cast<ValueType*>(cmd)->Init(_shader, _bucket_id); return NextCmdAddress<ValueType>(cmd); } gpu::CommandHeader header; uint32 shader; - int32 bufsize; - uint32 length_shm_id; - uint32 length_shm_offset; - uint32 infolog_shm_id; - uint32 infolog_shm_offset; + uint32 bucket_id; }; -COMPILE_ASSERT(sizeof(GetShaderInfoLog) == 28, - Sizeof_GetShaderInfoLog_is_not_28); +COMPILE_ASSERT(sizeof(GetShaderInfoLog) == 12, + Sizeof_GetShaderInfoLog_is_not_12); COMPILE_ASSERT(offsetof(GetShaderInfoLog, header) == 0, OffsetOf_GetShaderInfoLog_header_not_0); COMPILE_ASSERT(offsetof(GetShaderInfoLog, shader) == 4, OffsetOf_GetShaderInfoLog_shader_not_4); -COMPILE_ASSERT(offsetof(GetShaderInfoLog, bufsize) == 8, - OffsetOf_GetShaderInfoLog_bufsize_not_8); -COMPILE_ASSERT(offsetof(GetShaderInfoLog, length_shm_id) == 12, - OffsetOf_GetShaderInfoLog_length_shm_id_not_12); -COMPILE_ASSERT(offsetof(GetShaderInfoLog, length_shm_offset) == 16, - OffsetOf_GetShaderInfoLog_length_shm_offset_not_16); -COMPILE_ASSERT(offsetof(GetShaderInfoLog, infolog_shm_id) == 20, - OffsetOf_GetShaderInfoLog_infolog_shm_id_not_20); -COMPILE_ASSERT(offsetof(GetShaderInfoLog, infolog_shm_offset) == 24, - OffsetOf_GetShaderInfoLog_infolog_shm_offset_not_24); +COMPILE_ASSERT(offsetof(GetShaderInfoLog, bucket_id) == 8, + OffsetOf_GetShaderInfoLog_bucket_id_not_8); struct GetShaderPrecisionFormat { typedef GetShaderPrecisionFormat ValueType; @@ -3757,55 +3709,30 @@ struct GetShaderSource { header.SetCmd<ValueType>(); } - void Init( - GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id, - uint32 _length_shm_offset, uint32 _source_shm_id, - uint32 _source_shm_offset) { + void Init(GLuint _shader, uint32 _bucket_id) { SetHeader(); shader = _shader; - bufsize = _bufsize; - length_shm_id = _length_shm_id; - length_shm_offset = _length_shm_offset; - source_shm_id = _source_shm_id; - source_shm_offset = _source_shm_offset; + bucket_id = _bucket_id; } - void* Set( - void* cmd, GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id, - uint32 _length_shm_offset, uint32 _source_shm_id, - uint32 _source_shm_offset) { - static_cast<ValueType*>( - cmd)->Init( - _shader, _bufsize, _length_shm_id, _length_shm_offset, - _source_shm_id, _source_shm_offset); + void* Set(void* cmd, GLuint _shader, uint32 _bucket_id) { + static_cast<ValueType*>(cmd)->Init(_shader, _bucket_id); return NextCmdAddress<ValueType>(cmd); } gpu::CommandHeader header; uint32 shader; - int32 bufsize; - uint32 length_shm_id; - uint32 length_shm_offset; - uint32 source_shm_id; - uint32 source_shm_offset; + uint32 bucket_id; }; -COMPILE_ASSERT(sizeof(GetShaderSource) == 28, - Sizeof_GetShaderSource_is_not_28); +COMPILE_ASSERT(sizeof(GetShaderSource) == 12, + Sizeof_GetShaderSource_is_not_12); COMPILE_ASSERT(offsetof(GetShaderSource, header) == 0, OffsetOf_GetShaderSource_header_not_0); COMPILE_ASSERT(offsetof(GetShaderSource, shader) == 4, OffsetOf_GetShaderSource_shader_not_4); -COMPILE_ASSERT(offsetof(GetShaderSource, bufsize) == 8, - OffsetOf_GetShaderSource_bufsize_not_8); -COMPILE_ASSERT(offsetof(GetShaderSource, length_shm_id) == 12, - OffsetOf_GetShaderSource_length_shm_id_not_12); -COMPILE_ASSERT(offsetof(GetShaderSource, length_shm_offset) == 16, - OffsetOf_GetShaderSource_length_shm_offset_not_16); -COMPILE_ASSERT(offsetof(GetShaderSource, source_shm_id) == 20, - OffsetOf_GetShaderSource_source_shm_id_not_20); -COMPILE_ASSERT(offsetof(GetShaderSource, source_shm_offset) == 24, - OffsetOf_GetShaderSource_source_shm_offset_not_24); +COMPILE_ASSERT(offsetof(GetShaderSource, bucket_id) == 8, + OffsetOf_GetShaderSource_bucket_id_not_8); struct GetString { typedef GetString ValueType; @@ -3820,26 +3747,30 @@ struct GetString { header.SetCmd<ValueType>(); } - void Init(GLenum _name) { + void Init(GLenum _name, uint32 _bucket_id) { SetHeader(); name = _name; + bucket_id = _bucket_id; } - void* Set(void* cmd, GLenum _name) { - static_cast<ValueType*>(cmd)->Init(_name); + void* Set(void* cmd, GLenum _name, uint32 _bucket_id) { + static_cast<ValueType*>(cmd)->Init(_name, _bucket_id); return NextCmdAddress<ValueType>(cmd); } gpu::CommandHeader header; uint32 name; + uint32 bucket_id; }; -COMPILE_ASSERT(sizeof(GetString) == 8, - Sizeof_GetString_is_not_8); +COMPILE_ASSERT(sizeof(GetString) == 12, + Sizeof_GetString_is_not_12); COMPILE_ASSERT(offsetof(GetString, header) == 0, OffsetOf_GetString_header_not_0); COMPILE_ASSERT(offsetof(GetString, name) == 4, OffsetOf_GetString_name_not_4); +COMPILE_ASSERT(offsetof(GetString, bucket_id) == 8, + OffsetOf_GetString_bucket_id_not_8); struct GetTexParameterfv { typedef GetTexParameterfv ValueType; @@ -4247,6 +4178,8 @@ struct IsBuffer { static const CommandId kCmdId = kIsBuffer; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef uint32 Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -4292,6 +4225,8 @@ struct IsEnabled { static const CommandId kCmdId = kIsEnabled; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef uint32 Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -4337,6 +4272,8 @@ struct IsFramebuffer { static const CommandId kCmdId = kIsFramebuffer; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef uint32 Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -4383,6 +4320,8 @@ struct IsProgram { static const CommandId kCmdId = kIsProgram; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef uint32 Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -4429,6 +4368,8 @@ struct IsRenderbuffer { static const CommandId kCmdId = kIsRenderbuffer; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef uint32 Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -4475,6 +4416,8 @@ struct IsShader { static const CommandId kCmdId = kIsShader; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef uint32 Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } @@ -4520,6 +4463,8 @@ struct IsTexture { static const CommandId kCmdId = kIsTexture; static const cmd::ArgFlags kArgFlags = cmd::kFixed; + typedef uint32 Result; + static uint32 ComputeSize() { return static_cast<uint32>(sizeof(ValueType)); // NOLINT } diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h index 381fea1..e53ac55 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -1284,22 +1284,14 @@ TEST(GLES2FormatTest, GetProgramInfoLog) { void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), - static_cast<GLsizei>(12), - static_cast<uint32>(13), - static_cast<uint32>(14), - static_cast<uint32>(15), - static_cast<uint32>(16)); + static_cast<uint32>(12)); EXPECT_EQ(static_cast<uint32>(GetProgramInfoLog::kCmdId), cmd.header.command); EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); - EXPECT_EQ(static_cast<GLsizei>(12), cmd.bufsize); - EXPECT_EQ(static_cast<uint32>(13), cmd.length_shm_id); - EXPECT_EQ(static_cast<uint32>(14), cmd.length_shm_offset); - EXPECT_EQ(static_cast<uint32>(15), cmd.infolog_shm_id); - EXPECT_EQ(static_cast<uint32>(16), cmd.infolog_shm_offset); + EXPECT_EQ(static_cast<uint32>(12), cmd.bucket_id); } TEST(GLES2FormatTest, GetRenderbufferParameteriv) { @@ -1345,22 +1337,14 @@ TEST(GLES2FormatTest, GetShaderInfoLog) { void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), - static_cast<GLsizei>(12), - static_cast<uint32>(13), - static_cast<uint32>(14), - static_cast<uint32>(15), - static_cast<uint32>(16)); + static_cast<uint32>(12)); EXPECT_EQ(static_cast<uint32>(GetShaderInfoLog::kCmdId), cmd.header.command); EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); - EXPECT_EQ(static_cast<GLsizei>(12), cmd.bufsize); - EXPECT_EQ(static_cast<uint32>(13), cmd.length_shm_id); - EXPECT_EQ(static_cast<uint32>(14), cmd.length_shm_offset); - EXPECT_EQ(static_cast<uint32>(15), cmd.infolog_shm_id); - EXPECT_EQ(static_cast<uint32>(16), cmd.infolog_shm_offset); + EXPECT_EQ(static_cast<uint32>(12), cmd.bucket_id); } TEST(GLES2FormatTest, GetShaderPrecisionFormat) { @@ -1387,35 +1371,29 @@ TEST(GLES2FormatTest, GetShaderSource) { void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), - static_cast<GLsizei>(12), - static_cast<uint32>(13), - static_cast<uint32>(14), - static_cast<uint32>(15), - static_cast<uint32>(16)); + static_cast<uint32>(12)); EXPECT_EQ(static_cast<uint32>(GetShaderSource::kCmdId), cmd.header.command); EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); - EXPECT_EQ(static_cast<GLsizei>(12), cmd.bufsize); - EXPECT_EQ(static_cast<uint32>(13), cmd.length_shm_id); - EXPECT_EQ(static_cast<uint32>(14), cmd.length_shm_offset); - EXPECT_EQ(static_cast<uint32>(15), cmd.source_shm_id); - EXPECT_EQ(static_cast<uint32>(16), cmd.source_shm_offset); + EXPECT_EQ(static_cast<uint32>(12), cmd.bucket_id); } TEST(GLES2FormatTest, GetString) { GetString cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, - static_cast<GLenum>(11)); + static_cast<GLenum>(11), + static_cast<uint32>(12)); EXPECT_EQ(static_cast<uint32>(GetString::kCmdId), cmd.header.command); EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.name); + EXPECT_EQ(static_cast<uint32>(12), cmd.bucket_id); } TEST(GLES2FormatTest, GetTexParameterfv) { diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc index 9e376270..e0fc8e6 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -11,6 +11,17 @@ namespace gpu { namespace gles2 { +namespace gl_error_bit { +enum GLErrorBit { + kNoError = 0, + kInvalidEnum = (1 << 0), + kInvalidValue = (1 << 1), + kInvalidOperation = (1 << 2), + kOutOfMemory = (1 << 3), + kInvalidFrameBufferOperation = (1 << 4), +}; +} + int GLES2Util::GLGetNumValuesReturned(int id) const { switch (id) { // -- glGetBooleanv, glGetFloatv, glGetIntergerv @@ -401,6 +412,41 @@ size_t GLES2Util::GetGLTypeSizeForTexturesAndBuffers(uint32 type) { } } +uint32 GLES2Util::GLErrorToErrorBit(uint32 error) { + switch (error) { + case GL_INVALID_ENUM: + return gl_error_bit::kInvalidEnum; + case GL_INVALID_VALUE: + return gl_error_bit::kInvalidValue; + case GL_INVALID_OPERATION: + return gl_error_bit::kInvalidOperation; + case GL_OUT_OF_MEMORY: + return gl_error_bit::kOutOfMemory; + case GL_INVALID_FRAMEBUFFER_OPERATION: + return gl_error_bit::kInvalidFrameBufferOperation; + default: + NOTREACHED(); + return gl_error_bit::kNoError; + } +} + +uint32 GLES2Util::GLErrorBitToGLError(uint32 error_bit) { + switch (error_bit) { + case gl_error_bit::kInvalidEnum: + return GL_INVALID_ENUM; + case gl_error_bit::kInvalidValue: + return GL_INVALID_VALUE; + case gl_error_bit::kInvalidOperation: + return GL_INVALID_OPERATION; + case gl_error_bit::kOutOfMemory: + return GL_OUT_OF_MEMORY; + case gl_error_bit::kInvalidFrameBufferOperation: + return GL_INVALID_FRAMEBUFFER_OPERATION; + default: + NOTREACHED(); + return GL_NO_ERROR; + } +} } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h index b2da669..99b17e5 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.h +++ b/gpu/command_buffer/common/gles2_cmd_utils.h @@ -34,6 +34,10 @@ class GLES2Util { static size_t GetGLTypeSizeForTexturesAndBuffers(uint32 type); + static uint32 GLErrorToErrorBit(uint32 gl_error); + + static uint32 GLErrorBitToGLError(uint32 error_bit); + private: int num_compressed_texture_formats_; }; diff --git a/gpu/command_buffer/service/common_decoder.cc b/gpu/command_buffer/service/common_decoder.cc index 4452e39..06d368d 100644 --- a/gpu/command_buffer/service/common_decoder.cc +++ b/gpu/command_buffer/service/common_decoder.cc @@ -8,7 +8,7 @@ namespace gpu { -const void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const { +void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const { if (OffsetSizeValid(offset, size)) { return data_.get() + offset; } @@ -33,8 +33,10 @@ bool CommonDecoder::Bucket::SetData( } void CommonDecoder::Bucket::SetFromString(const std::string& str) { - SetSize(str.size()); - SetData(str.c_str(), 0, str.size()); + // Strings are passed NULL terminated to distinguish between empty string + // and no string. + SetSize(str.size() + 1); + SetData(str.c_str(), 0, str.size() + 1); } void* CommonDecoder::GetAddressAndCheckSize(unsigned int shm_id, diff --git a/gpu/command_buffer/service/common_decoder.h b/gpu/command_buffer/service/common_decoder.h index 2300e5a..9ea0d6f 100644 --- a/gpu/command_buffer/service/common_decoder.h +++ b/gpu/command_buffer/service/common_decoder.h @@ -57,7 +57,7 @@ class CommonDecoder : public AsyncAPIInterface { // Gets a pointer to a section the bucket. Returns NULL if offset or size is // out of range. - const void* GetData(size_t offset, size_t size) const; + void* GetData(size_t offset, size_t size) const; template <typename T> T GetDataAs(size_t offset, size_t size) const { @@ -71,7 +71,8 @@ class CommonDecoder : public AsyncAPIInterface { // Returns false if offset or size is out of range. bool SetData(const void* src, size_t offset, size_t size); - // Sets the bucket data from a string. + // Sets the bucket data from a string. Strings are passed NULL terminated to + // distinguish between empty string and no string. void SetFromString(const std::string& str); private: diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 2b04de6..52f59ce 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -103,53 +103,6 @@ const CommandInfo g_command_info[] = { #undef GLES2_CMD_OP }; -namespace GLErrorBit { -enum GLErrorBit { - kNoError = 0, - kInvalidEnum = (1 << 0), - kInvalidValue = (1 << 1), - kInvalidOperation = (1 << 2), - kOutOfMemory = (1 << 3), - kInvalidFrameBufferOperation = (1 << 4), -}; -} - -uint32 GLErrorToErrorBit(GLenum error) { - switch (error) { - case GL_INVALID_ENUM: - return GLErrorBit::kInvalidEnum; - case GL_INVALID_VALUE: - return GLErrorBit::kInvalidValue; - case GL_INVALID_OPERATION: - return GLErrorBit::kInvalidOperation; - case GL_OUT_OF_MEMORY: - return GLErrorBit::kOutOfMemory; - case GL_INVALID_FRAMEBUFFER_OPERATION: - return GLErrorBit::kInvalidFrameBufferOperation; - default: - DCHECK(false); - return GLErrorBit::kNoError; - } -} - -GLenum GLErrorBitToGLError(uint32 error_bit) { - switch (error_bit) { - case GLErrorBit::kInvalidEnum: - return GL_INVALID_ENUM; - case GLErrorBit::kInvalidValue: - return GL_INVALID_VALUE; - case GLErrorBit::kInvalidOperation: - return GL_INVALID_OPERATION; - case GLErrorBit::kOutOfMemory: - return GL_OUT_OF_MEMORY; - case GLErrorBit::kInvalidFrameBufferOperation: - return GL_INVALID_FRAMEBUFFER_OPERATION; - default: - DCHECK(false); - return GL_NO_ERROR; - } -} - // } // anonymous namespace. GLES2Decoder::GLES2Decoder(ContextGroup* group) @@ -488,6 +441,9 @@ class GLES2DecoderImpl : public GLES2Decoder { // Wrapper for glGenerateMipmap void DoGenerateMipmap(GLenum target); + // Wrapper for glGetShaderiv + void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params); + // Wrapper for glGetShaderSource. void DoGetShaderSource( GLuint shader, GLsizei bufsize, GLsizei* length, char* dst); @@ -1802,7 +1758,7 @@ GLenum GLES2DecoderImpl::GetGLError() { if (error == GL_NO_ERROR && error_bits_ != 0) { for (uint32 mask = 1; mask != 0; mask = mask << 1) { if ((error_bits_ & mask) != 0) { - error = GLErrorBitToGLError(mask); + error = GLES2Util::GLErrorBitToGLError(mask); break; } } @@ -1810,13 +1766,13 @@ GLenum GLES2DecoderImpl::GetGLError() { if (error != GL_NO_ERROR) { // There was an error, clear the corresponding wrapped error. - error_bits_ &= ~GLErrorToErrorBit(error); + error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error); } return error; } void GLES2DecoderImpl::SetGLError(GLenum error) { - error_bits_ |= GLErrorToErrorBit(error); + error_bits_ |= GLES2Util::GLErrorToErrorBit(error); } void GLES2DecoderImpl::CopyRealGLErrorsToWrapper() { @@ -2048,6 +2004,20 @@ void GLES2DecoderImpl::DoCompileShader(GLuint shader) { glCompileShader(shader); }; +void GLES2DecoderImpl::DoGetShaderiv( + GLuint shader, GLenum pname, GLint* params) { + ShaderManager::ShaderInfo* info = GetShaderInfo(shader); + if (!info) { + SetGLError(GL_INVALID_OPERATION); + return; + } + if (pname == GL_SHADER_SOURCE_LENGTH) { + *params = info->source().size(); + } else { + glGetShaderiv(shader, pname, params); + } +} + void GLES2DecoderImpl::DoGetShaderSource( GLuint shader, GLsizei bufsize, GLsizei* length, char* dst) { ShaderManager::ShaderInfo* info = GetShaderInfo(shader); @@ -2277,6 +2247,18 @@ error::Error GLES2DecoderImpl::HandleGetUniformLocationImmediate( return error::kNoError; } +error::Error GLES2DecoderImpl::HandleGetString( + uint32 immediate_data_size, const gles2::GetString& c) { + GLenum name = static_cast<GLenum>(c.name); + if (!ValidateGLenumStringType(name)) { + SetGLError(GL_INVALID_ENUM); + return error::kNoError; + } + Bucket* bucket = CreateBucket(c.bucket_id); + bucket->SetFromString(reinterpret_cast<const char*>(glGetString(name))); + return error::kNoError; +} + error::Error GLES2DecoderImpl::HandleBufferData( uint32 immediate_data_size, const gles2::BufferData& c) { GLenum target = static_cast<GLenum>(c.target); @@ -2437,8 +2419,6 @@ error::Error GLES2DecoderImpl::HandleCompressedTexImage2DImmediate( target, level, internal_format, width, height, border, image_size, data); } -// TODO(gman): handle CopyTexImage2D because we need to track what was created. - error::Error GLES2DecoderImpl::DoTexImage2D( GLenum target, GLint level, diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index d22a900..c2620ac 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -1087,27 +1087,13 @@ error::Error GLES2DecoderImpl::HandleGetProgramInfoLog( SetGLError(GL_INVALID_VALUE); return error::kNoError; } - GLsizei bufsize = static_cast<GLsizei>(c.bufsize); - uint32 size_shm_id = c.length_shm_id; - uint32 size_shm_offset = c.length_shm_offset; - GLsizei* length = NULL; - if (size_shm_id != 0 || size_shm_offset != 0) { - length = GetSharedMemoryAs<GLsizei*>( - size_shm_id, size_shm_offset, sizeof(*length)); - if (!length) { - return error::kOutOfBounds; - } - } - char* infolog = GetSharedMemoryAs<char*>( - c.infolog_shm_id, c.infolog_shm_offset, bufsize); - if (bufsize < 0) { - SetGLError(GL_INVALID_VALUE); - return error::kNoError; - } - if (infolog == NULL) { - return error::kOutOfBounds; - } - glGetProgramInfoLog(program, bufsize, length, infolog); + uint32 bucket_id = static_cast<uint32>(c.bucket_id); + GLint len = 0; + glGetProgramiv(program, GL_INFO_LOG_LENGTH, &len); + Bucket* bucket = CreateBucket(bucket_id); + bucket->SetSize(len + 1); + glGetProgramInfoLog( + program, len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1)); return error::kNoError; } @@ -1155,7 +1141,7 @@ error::Error GLES2DecoderImpl::HandleGetShaderiv( if (params == NULL) { return error::kOutOfBounds; } - glGetShaderiv(shader, pname, params); + DoGetShaderiv(shader, pname, params); return error::kNoError; } @@ -1166,27 +1152,13 @@ error::Error GLES2DecoderImpl::HandleGetShaderInfoLog( SetGLError(GL_INVALID_VALUE); return error::kNoError; } - GLsizei bufsize = static_cast<GLsizei>(c.bufsize); - uint32 size_shm_id = c.length_shm_id; - uint32 size_shm_offset = c.length_shm_offset; - GLsizei* length = NULL; - if (size_shm_id != 0 || size_shm_offset != 0) { - length = GetSharedMemoryAs<GLsizei*>( - size_shm_id, size_shm_offset, sizeof(*length)); - if (!length) { - return error::kOutOfBounds; - } - } - char* infolog = GetSharedMemoryAs<char*>( - c.infolog_shm_id, c.infolog_shm_offset, bufsize); - if (bufsize < 0) { - SetGLError(GL_INVALID_VALUE); - return error::kNoError; - } - if (infolog == NULL) { - return error::kOutOfBounds; - } - glGetShaderInfoLog(shader, bufsize, length, infolog); + uint32 bucket_id = static_cast<uint32>(c.bucket_id); + GLint len = 0; + glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len); + Bucket* bucket = CreateBucket(bucket_id); + bucket->SetSize(len + 1); + glGetShaderInfoLog( + shader, len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1)); return error::kNoError; } @@ -1197,38 +1169,13 @@ error::Error GLES2DecoderImpl::HandleGetShaderSource( SetGLError(GL_INVALID_VALUE); return error::kNoError; } - GLsizei bufsize = static_cast<GLsizei>(c.bufsize); - uint32 size_shm_id = c.length_shm_id; - uint32 size_shm_offset = c.length_shm_offset; - GLsizei* length = NULL; - if (size_shm_id != 0 || size_shm_offset != 0) { - length = GetSharedMemoryAs<GLsizei*>( - size_shm_id, size_shm_offset, sizeof(*length)); - if (!length) { - return error::kOutOfBounds; - } - } - char* source = GetSharedMemoryAs<char*>( - c.source_shm_id, c.source_shm_offset, bufsize); - if (bufsize < 0) { - SetGLError(GL_INVALID_VALUE); - return error::kNoError; - } - if (source == NULL) { - return error::kOutOfBounds; - } - DoGetShaderSource(shader, bufsize, length, source); - return error::kNoError; -} - -error::Error GLES2DecoderImpl::HandleGetString( - uint32 immediate_data_size, const gles2::GetString& c) { - GLenum name = static_cast<GLenum>(c.name); - if (!ValidateGLenumStringType(name)) { - SetGLError(GL_INVALID_ENUM); - return error::kNoError; - } - glGetString(name); + uint32 bucket_id = static_cast<uint32>(c.bucket_id); + GLint len = 0; + DoGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &len); + Bucket* bucket = CreateBucket(bucket_id); + bucket->SetSize(len + 1); + DoGetShaderSource( + shader, len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1)); return error::kNoError; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 09ddc14..5f96cd5 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -853,6 +853,7 @@ TEST_F(GLES2DecoderTest, CompileShaderInvalidArgs) { } TEST_F(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) { + const uint32 kBucketId = 123; const char kSource[] = "hello"; const uint32 kSourceSize = sizeof(kSource) - 1; memcpy(shared_memory_address_, kSource, kSourceSize); @@ -861,15 +862,14 @@ TEST_F(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) { kSharedMemoryId, kSharedMemoryOffset, kSourceSize); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); memset(shared_memory_address_, 0, kSourceSize); - // TODO(gman): GetShaderSource has to change format so result is always set. GetShaderSource get_cmd; - get_cmd.Init(client_shader_id_, kSourceSize + 1, - kSharedMemoryId, kSharedMemoryOffset, - kSharedMemoryId, kSharedMemoryOffset + sizeof(kSourceSize)); + get_cmd.Init(client_shader_id_, kBucketId); EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); - EXPECT_EQ(kSourceSize, *GetSharedMemoryAs<uint32*>()); - EXPECT_EQ(0, memcmp(GetSharedMemoryAsWithOffset<void*>(sizeof(kSourceSize)), - kSource, kSourceSize)); + CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); + ASSERT_TRUE(bucket != NULL); + EXPECT_EQ(kSourceSize + 1, bucket->size()); + EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource, + bucket->size())); } TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) { @@ -897,6 +897,7 @@ TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) { } TEST_F(GLES2DecoderTest, ShaderSourceImmediateAndGetShaderSourceValidArgs) { + const uint32 kBucketId = 123; const char kSource[] = "hello"; const uint32 kSourceSize = sizeof(kSource) - 1; ShaderSourceImmediate& cmd = *GetImmediateAs<ShaderSourceImmediate>(); @@ -906,13 +907,13 @@ TEST_F(GLES2DecoderTest, ShaderSourceImmediateAndGetShaderSourceValidArgs) { memset(shared_memory_address_, 0, kSourceSize); // TODO(gman): GetShaderSource has to change format so result is always set. GetShaderSource get_cmd; - get_cmd.Init(client_shader_id_, kSourceSize + 1, - kSharedMemoryId, kSharedMemoryOffset, - kSharedMemoryId, kSharedMemoryOffset + sizeof(kSourceSize)); + get_cmd.Init(client_shader_id_, kBucketId); EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); - EXPECT_EQ(kSourceSize, *GetSharedMemoryAs<uint32*>()); - EXPECT_EQ(0, memcmp(GetSharedMemoryAsWithOffset<void*>(sizeof(kSourceSize)), - kSource, kSourceSize)); + CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); + ASSERT_TRUE(bucket != NULL); + EXPECT_EQ(kSourceSize + 1, bucket->size()); + EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource, + bucket->size())); } TEST_F(GLES2DecoderTest, ShaderSourceImmediateInvalidArgs) { 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 5b422bf..f8dc38b 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 @@ -10,7 +10,6 @@ TEST_F(GLES2DecoderTest1, ActiveTextureValidArgs) { - EXPECT_CALL(*gl_, ActiveTexture(1)); SpecializedSetup<ActiveTexture, 0>(); ActiveTexture cmd; cmd.Init(1); @@ -1113,8 +1112,38 @@ TEST_F(GLES2DecoderTest1, GetProgramivInvalidArgs2_1) { kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } -// TODO(gman): GetProgramInfoLog +TEST_F(GLES2DecoderTest1, GetProgramInfoLogValidArgs) { + const char* kInfo = "hello"; + const uint32 kBucketId = 123; + SpecializedSetup<GetProgramInfoLog, 0>(); + EXPECT_CALL( + *gl_, GetProgramiv( + kServiceProgramId, GL_INFO_LOG_LENGTH, _)) .WillOnce( + SetArgumentPointee<2>(strlen(kInfo))); + EXPECT_CALL( + *gl_, GetProgramInfoLog(kServiceProgramId, strlen(kInfo) + 1, _, _)) + .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)), + SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1))); + GetProgramInfoLog cmd; + cmd.Init(client_program_id_, kBucketId); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); + ASSERT_TRUE(bucket != NULL); + EXPECT_EQ(strlen(kInfo) + 1, bucket->size()); + EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo, + bucket->size())); +} + +TEST_F(GLES2DecoderTest1, GetProgramInfoLogInvalidArgs) { + const uint32 kBucketId = 123; + EXPECT_CALL(*gl_, GetProgramInfoLog(_, _, _, _)) + .Times(0); + GetProgramInfoLog cmd; + cmd.Init(kInvalidClientId, kBucketId); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); +} TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivValidArgs) { EXPECT_CALL( @@ -1177,21 +1206,44 @@ TEST_F(GLES2DecoderTest1, GetShaderivInvalidArgs2_1) { kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } -// TODO(gman): GetShaderInfoLog +TEST_F(GLES2DecoderTest1, GetShaderInfoLogValidArgs) { + const char* kInfo = "hello"; + const uint32 kBucketId = 123; + SpecializedSetup<GetShaderInfoLog, 0>(); + EXPECT_CALL( + *gl_, GetShaderiv( + kServiceShaderId, GL_INFO_LOG_LENGTH, _)) .WillOnce( + SetArgumentPointee<2>(strlen(kInfo))); + EXPECT_CALL( + *gl_, GetShaderInfoLog(kServiceShaderId, strlen(kInfo) + 1, _, _)) + .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)), + SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1))); + GetShaderInfoLog cmd; + cmd.Init(client_shader_id_, kBucketId); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); + ASSERT_TRUE(bucket != NULL); + EXPECT_EQ(strlen(kInfo) + 1, bucket->size()); + EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo, + bucket->size())); +} + +TEST_F(GLES2DecoderTest1, GetShaderInfoLogInvalidArgs) { + const uint32 kBucketId = 123; + EXPECT_CALL(*gl_, GetShaderInfoLog(_, _, _, _)) + .Times(0); + GetShaderInfoLog cmd; + cmd.Init(kInvalidClientId, kBucketId); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); +} // TODO(gman): GetShaderPrecisionFormat // TODO(gman): GetShaderSource +// TODO(gman): GetString -TEST_F(GLES2DecoderTest1, GetStringValidArgs) { - EXPECT_CALL(*gl_, GetString(GL_VENDOR)); - SpecializedSetup<GetString, 0>(); - GetString cmd; - cmd.Init(GL_VENDOR); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); -} - TEST_F(GLES2DecoderTest1, GetTexParameterfvValidArgs) { EXPECT_CALL( *gl_, GetTexParameterfv( 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 c0b52fa..ef5c231 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 @@ -667,17 +667,6 @@ TEST_F(GLES2DecoderTest2, Uniform1fvImmediateValidArgs) { EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); } - -TEST_F(GLES2DecoderTest2, Uniform1fvImmediateInvalidArgs1_0) { - Uniform1fvImmediate& cmd = *GetImmediateAs<Uniform1fvImmediate>(); - EXPECT_CALL(*gl_, Uniform1fv(_, _, _)).Times(0); - SpecializedSetup<Uniform1fvImmediate, 0>(); - GLfloat temp[1 * 2] = { 0, }; - cmd.Init(1, -1, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} // TODO(gman): Uniform1i // TODO(gman): Uniform1iv // TODO(gman): Uniform1ivImmediate @@ -738,17 +727,6 @@ TEST_F(GLES2DecoderTest2, Uniform2fvImmediateValidArgs) { ExecuteImmediateCmd(cmd, sizeof(temp))); } -TEST_F(GLES2DecoderTest2, Uniform2fvImmediateInvalidArgs1_0) { - Uniform2fvImmediate& cmd = *GetImmediateAs<Uniform2fvImmediate>(); - EXPECT_CALL(*gl_, Uniform2fv(_, _, _)).Times(0); - SpecializedSetup<Uniform2fvImmediate, 0>(); - GLfloat temp[2 * 2] = { 0, }; - cmd.Init(1, -1, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} - TEST_F(GLES2DecoderTest2, Uniform2iValidArgs) { EXPECT_CALL(*gl_, Uniform2i(1, 2, 3)); SpecializedSetup<Uniform2i, 0>(); @@ -805,17 +783,6 @@ TEST_F(GLES2DecoderTest2, Uniform2ivImmediateValidArgs) { ExecuteImmediateCmd(cmd, sizeof(temp))); } -TEST_F(GLES2DecoderTest2, Uniform2ivImmediateInvalidArgs1_0) { - Uniform2ivImmediate& cmd = *GetImmediateAs<Uniform2ivImmediate>(); - EXPECT_CALL(*gl_, Uniform2iv(_, _, _)).Times(0); - SpecializedSetup<Uniform2ivImmediate, 0>(); - GLint temp[2 * 2] = { 0, }; - cmd.Init(1, -1, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} - TEST_F(GLES2DecoderTest2, Uniform3fValidArgs) { EXPECT_CALL(*gl_, Uniform3f(1, 2, 3, 4)); SpecializedSetup<Uniform3f, 0>(); @@ -872,17 +839,6 @@ TEST_F(GLES2DecoderTest2, Uniform3fvImmediateValidArgs) { ExecuteImmediateCmd(cmd, sizeof(temp))); } -TEST_F(GLES2DecoderTest2, Uniform3fvImmediateInvalidArgs1_0) { - Uniform3fvImmediate& cmd = *GetImmediateAs<Uniform3fvImmediate>(); - EXPECT_CALL(*gl_, Uniform3fv(_, _, _)).Times(0); - SpecializedSetup<Uniform3fvImmediate, 0>(); - GLfloat temp[3 * 2] = { 0, }; - cmd.Init(1, -1, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} - TEST_F(GLES2DecoderTest2, Uniform3iValidArgs) { EXPECT_CALL(*gl_, Uniform3i(1, 2, 3, 4)); SpecializedSetup<Uniform3i, 0>(); @@ -939,17 +895,6 @@ TEST_F(GLES2DecoderTest2, Uniform3ivImmediateValidArgs) { ExecuteImmediateCmd(cmd, sizeof(temp))); } -TEST_F(GLES2DecoderTest2, Uniform3ivImmediateInvalidArgs1_0) { - Uniform3ivImmediate& cmd = *GetImmediateAs<Uniform3ivImmediate>(); - EXPECT_CALL(*gl_, Uniform3iv(_, _, _)).Times(0); - SpecializedSetup<Uniform3ivImmediate, 0>(); - GLint temp[3 * 2] = { 0, }; - cmd.Init(1, -1, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} - TEST_F(GLES2DecoderTest2, Uniform4fValidArgs) { EXPECT_CALL(*gl_, Uniform4f(1, 2, 3, 4, 5)); SpecializedSetup<Uniform4f, 0>(); @@ -1006,17 +951,6 @@ TEST_F(GLES2DecoderTest2, Uniform4fvImmediateValidArgs) { ExecuteImmediateCmd(cmd, sizeof(temp))); } -TEST_F(GLES2DecoderTest2, Uniform4fvImmediateInvalidArgs1_0) { - Uniform4fvImmediate& cmd = *GetImmediateAs<Uniform4fvImmediate>(); - EXPECT_CALL(*gl_, Uniform4fv(_, _, _)).Times(0); - SpecializedSetup<Uniform4fvImmediate, 0>(); - GLfloat temp[4 * 2] = { 0, }; - cmd.Init(1, -1, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} - TEST_F(GLES2DecoderTest2, Uniform4iValidArgs) { EXPECT_CALL(*gl_, Uniform4i(1, 2, 3, 4, 5)); SpecializedSetup<Uniform4i, 0>(); @@ -1073,17 +1007,6 @@ TEST_F(GLES2DecoderTest2, Uniform4ivImmediateValidArgs) { ExecuteImmediateCmd(cmd, sizeof(temp))); } -TEST_F(GLES2DecoderTest2, Uniform4ivImmediateInvalidArgs1_0) { - Uniform4ivImmediate& cmd = *GetImmediateAs<Uniform4ivImmediate>(); - EXPECT_CALL(*gl_, Uniform4iv(_, _, _)).Times(0); - SpecializedSetup<Uniform4ivImmediate, 0>(); - GLint temp[4 * 2] = { 0, }; - cmd.Init(1, -1, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} - TEST_F(GLES2DecoderTest2, UniformMatrix2fvValidArgs) { EXPECT_CALL( *gl_, UniformMatrix2fv( @@ -1110,7 +1033,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs2_0) { UniformMatrix2fv cmd; cmd.Init(1, 2, true, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs3_0) { @@ -1143,18 +1066,6 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvImmediateValidArgs) { ExecuteImmediateCmd(cmd, sizeof(temp))); } -TEST_F(GLES2DecoderTest2, UniformMatrix2fvImmediateInvalidArgs1_0) { - UniformMatrix2fvImmediate& cmd = - *GetImmediateAs<UniformMatrix2fvImmediate>(); - EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); - SpecializedSetup<UniformMatrix2fvImmediate, 0>(); - GLfloat temp[4 * 2] = { 0, }; - cmd.Init(1, -1, false, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} - TEST_F(GLES2DecoderTest2, UniformMatrix2fvImmediateInvalidArgs2_0) { UniformMatrix2fvImmediate& cmd = *GetImmediateAs<UniformMatrix2fvImmediate>(); @@ -1164,7 +1075,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvImmediateInvalidArgs2_0) { cmd.Init(1, 2, true, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } TEST_F(GLES2DecoderTest2, UniformMatrix3fvValidArgs) { @@ -1193,7 +1104,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs2_0) { UniformMatrix3fv cmd; cmd.Init(1, 2, true, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs3_0) { @@ -1226,18 +1137,6 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvImmediateValidArgs) { ExecuteImmediateCmd(cmd, sizeof(temp))); } -TEST_F(GLES2DecoderTest2, UniformMatrix3fvImmediateInvalidArgs1_0) { - UniformMatrix3fvImmediate& cmd = - *GetImmediateAs<UniformMatrix3fvImmediate>(); - EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); - SpecializedSetup<UniformMatrix3fvImmediate, 0>(); - GLfloat temp[9 * 2] = { 0, }; - cmd.Init(1, -1, false, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} - TEST_F(GLES2DecoderTest2, UniformMatrix3fvImmediateInvalidArgs2_0) { UniformMatrix3fvImmediate& cmd = *GetImmediateAs<UniformMatrix3fvImmediate>(); @@ -1247,7 +1146,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvImmediateInvalidArgs2_0) { cmd.Init(1, 2, true, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } TEST_F(GLES2DecoderTest2, UniformMatrix4fvValidArgs) { @@ -1276,7 +1175,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs2_0) { UniformMatrix4fv cmd; cmd.Init(1, 2, true, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs3_0) { @@ -1309,18 +1208,6 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvImmediateValidArgs) { ExecuteImmediateCmd(cmd, sizeof(temp))); } -TEST_F(GLES2DecoderTest2, UniformMatrix4fvImmediateInvalidArgs1_0) { - UniformMatrix4fvImmediate& cmd = - *GetImmediateAs<UniformMatrix4fvImmediate>(); - EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); - SpecializedSetup<UniformMatrix4fvImmediate, 0>(); - GLfloat temp[16 * 2] = { 0, }; - cmd.Init(1, -1, false, &temp[0]); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); -} - TEST_F(GLES2DecoderTest2, UniformMatrix4fvImmediateInvalidArgs2_0) { UniformMatrix4fvImmediate& cmd = *GetImmediateAs<UniformMatrix4fvImmediate>(); @@ -1330,7 +1217,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvImmediateInvalidArgs2_0) { cmd.Init(1, 2, true, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } // TODO(gman): UseProgram |