summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-27 07:43:43 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-27 07:43:43 +0000
commit4f0c32d419b2a9783e1458192f5c0d3d79813764 (patch)
tree937023c99cbd754e9e9a6e0b5300f16ffca9aebf /gpu
parent8c809a36b0ba392460822306392ee0b1be2e84c8 (diff)
downloadchromium_src-4f0c32d419b2a9783e1458192f5c0d3d79813764.zip
chromium_src-4f0c32d419b2a9783e1458192f5c0d3d79813764.tar.gz
chromium_src-4f0c32d419b2a9783e1458192f5c0d3d79813764.tar.bz2
Revert http://codereview.chromium.org/660238
TEST=none BUG=none TBR=gman@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40217 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py279
-rw-r--r--gpu/command_buffer/client/gles2_cmd_helper_autogen.h31
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc159
-rw-r--r--gpu/command_buffer/client/gles2_implementation.h23
-rw-r--r--gpu/command_buffer/client/gles2_implementation_autogen.h136
-rw-r--r--gpu/command_buffer/common/GLES2/gl2types.h1
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format.h8
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_autogen.h159
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_test_autogen.h40
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.cc46
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.h4
-rw-r--r--gpu/command_buffer/service/common_decoder.cc8
-rw-r--r--gpu/command_buffer/service/common_decoder.h5
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc84
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_autogen.h97
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc27
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h74
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h125
18 files changed, 559 insertions, 747 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 64213e9..f406c47 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -839,10 +839,9 @@ _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', 'expectation': False},
+ 'ActiveTexture': {'decoder_func': 'DoActiveTexture'},
'BindAttribLocation': {'type': 'GLchar'},
'BindBuffer': {'decoder_func': 'DoBindBuffer'},
'BindFramebuffer': {'decoder_func': 'glBindFramebufferEXT'},
@@ -925,17 +924,10 @@ _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',
- 'impl_func': False,
- 'result': ['GLenum'],
- },
+ 'GetError': {'type': 'Is', 'decoder_func': 'GetGLError'},
'GetFloatv': {'type': 'GETn'},
'GetFramebufferAttachmentParameteriv': {
'type': 'GETn',
@@ -943,21 +935,13 @@ _FUNCTION_INFO = {
},
'GetIntegerv': {'type': 'GETn'},
'GetProgramiv': {'type': 'GETn'},
- 'GetProgramInfoLog': {
- 'type': 'STRn',
- 'get_len_func': 'glGetProgramiv',
- 'get_len_enum': 'GL_INFO_LOG_LENGTH',
- },
+ 'GetProgramInfoLog': {'type': 'STRn'},
'GetRenderbufferParameteriv': {
'type': 'GETn',
'decoder_func': 'glGetRenderbufferParameterivEXT',
},
- 'GetShaderiv': {'type': 'GETn', 'decoder_func': 'DoGetShaderiv'},
- 'GetShaderInfoLog': {
- 'type': 'STRn',
- 'get_len_func': 'glGetShaderiv',
- 'get_len_enum': 'GL_INFO_LOG_LENGTH',
- },
+ 'GetShaderiv': {'type': 'GETn'},
+ 'GetShaderInfoLog': {'type': 'STRn'},
'GetShaderPrecisionFormat': {
'type': 'Custom',
'immediate': False,
@@ -971,17 +955,7 @@ _FUNCTION_INFO = {
'int32 precision',
],
},
- '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',
- },
+ 'GetShaderSource': {'type': 'STRn', 'decoder_func': 'DoGetShaderSource'},
'GetTexParameterfv': {'type': 'GETn'},
'GetTexParameteriv': {'type': 'GETn'},
'GetUniformfv': {
@@ -1000,7 +974,6 @@ _FUNCTION_INFO = {
'needs_size': True,
'cmd_args':
'GLidProgram program, const char* name, NonImmediate GLint* location',
- 'result': ['GLint'],
},
'GetVertexAttribfv': {'type': 'GETn'},
'GetVertexAttribiv': {'type': 'GETn'},
@@ -1199,8 +1172,6 @@ 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
@@ -1392,8 +1363,6 @@ 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
@@ -1420,7 +1389,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(func)
+ num_invalid_values = arg.GetNumInvalidValues()
for value_index in range(0, num_invalid_values):
arg_strings = []
parse_result = "kNoError"
@@ -1492,28 +1461,22 @@ 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 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."""
+ """Writes the GLES2 Implemention declaration."""
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:
- self.WriteGLES2ImplementationDeclaration(func, file)
+ file.Write("%s %s(%s);\n" %
+ (func.return_type, func.original_name,
+ func.MakeTypedOriginalArgString("")))
+ file.Write("\n")
def WriteImmediateCmdComputeSize(self, func, file):
"""Writes the size computation code for the immediate version of a cmd."""
@@ -3026,8 +2989,6 @@ 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."""
@@ -3083,26 +3044,20 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
def WriteGLES2ImplementationHeader(self, func, file):
"""Overrriden from TypeHandler."""
- 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)
+ 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")
class STRnHandler(TypeHandler):
@@ -3111,95 +3066,18 @@ 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."""
- 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,
- })
+ file.Write("// TODO(gman): Implement this\n")
+ TypeHandler.WriteGLES2ImplementationHeader(self, func, file)
def WriteServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
- 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)
+ 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 WriteImmediateServiceUnitTest(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write("// TODO(gman): %s\n\n" % func.name)
def WriteServiceImplementation(self, func, file):
"""Overrriden from TypeHandler."""
@@ -3207,21 +3085,34 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs) {
"error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
file.Write(
" uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
- 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");
+ 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, len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1));\n" %
- (func.GetGLFunctionName(), id_arg.name))
+ " %s %s = GetSharedMemoryAs<%s>(\n" %
+ (dest_arg.type, dest_arg.name, dest_arg.type))
+ 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)
file.Write(" return error::kNoError;\n")
file.Write("}\n")
file.Write("\n")
@@ -3278,7 +3169,7 @@ class Argument(object):
def GetValidGLArg(self, offset, index):
return str(offset + 1)
- def GetNumInvalidValues(self, func):
+ def GetNumInvalidValues(self):
"""returns the number of invalid values to be tested."""
return 0
@@ -3293,11 +3184,11 @@ class Argument(object):
def WriteValidationCode(self, file):
"""Writes the validation code for an argument."""
- pass
-
- def WriteClientSideValidationCode(self, file):
- """Writes the validation code for an argument."""
- pass
+ 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")
def WriteGetAddress(self, file):
"""Writes the code to get the address this argument refers to."""
@@ -3309,37 +3200,21 @@ class Argument(object):
class SizeArgument(Argument):
- """class for GLsizei and GLsizeiptr."""
def __init__(self, name, type):
Argument.__init__(self, name, type)
- def GetNumInvalidValues(self, func):
+ def GetNumInvalidValues(self):
"""overridden from Argument."""
- if func.is_immediate:
- return 0
return 1
def GetInvalidArg(self, offset, index):
- """overridden from Argument."""
+ """returns an invalid value and expected parse result by index."""
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 class for EnumArgument, IntArgument and BoolArgument"""
+ """Base calss for EnumArgument, IntArgument and BoolArgument"""
def __init__(self, name, gl_type, type, gl_error):
Argument.__init__(self, name, gl_type)
@@ -3367,7 +3242,7 @@ class EnumBaseArgument(Argument):
def GetValidGLArg(self, offset, index):
return self.GetValidArg(offset, index)
- def GetNumInvalidValues(self, func):
+ def GetNumInvalidValues(self):
"""returns the number of invalid values to be tested."""
if 'invalid' in self.enum_info:
invalid = self.enum_info['invalid']
@@ -3381,8 +3256,8 @@ class EnumBaseArgument(Argument):
num_invalid = len(invalid)
if index >= num_invalid:
index = num_invalid - 1
- return (invalid[index], "kNoError", self.gl_error)
- return ("---ERROR1---", "kNoError", self.gl_error)
+ return (invalid[index], "kNoError", "GL_INVALID_ENUM")
+ return ("---ERROR1---", "kNoError", "GL_INVALID_ENUM")
class EnumArgument(EnumBaseArgument):
@@ -3463,7 +3338,7 @@ class PointerArgument(Argument):
"""Overridden from Argument."""
return "reinterpret_cast<%s>(shared_memory_address_)" % self.type
- def GetNumInvalidValues(self, func):
+ def GetNumInvalidValues(self):
"""Overridden from Argument."""
return 2
@@ -3565,7 +3440,6 @@ 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."""
@@ -3577,10 +3451,6 @@ 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'):
@@ -3605,10 +3475,6 @@ 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
@@ -3780,7 +3646,6 @@ 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 6ae38f4..df3ed0e 100644
--- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
+++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
@@ -491,9 +491,14 @@
c.Init(program, pname, params_shm_id, params_shm_offset);
}
- void GetProgramInfoLog(GLuint program, uint32 bucket_id) {
+ void GetProgramInfoLog(
+ GLuint program, GLsizei bufsize, uint32 length_shm_id,
+ uint32 length_shm_offset, uint32 infolog_shm_id,
+ uint32 infolog_shm_offset) {
gles2::GetProgramInfoLog& c = GetCmdSpace<gles2::GetProgramInfoLog>();
- c.Init(program, bucket_id);
+ c.Init(
+ program, bufsize, length_shm_id, length_shm_offset, infolog_shm_id,
+ infolog_shm_offset);
}
void GetRenderbufferParameteriv(
@@ -511,9 +516,14 @@
c.Init(shader, pname, params_shm_id, params_shm_offset);
}
- void GetShaderInfoLog(GLuint shader, uint32 bucket_id) {
+ void GetShaderInfoLog(
+ GLuint shader, GLsizei bufsize, uint32 length_shm_id,
+ uint32 length_shm_offset, uint32 infolog_shm_id,
+ uint32 infolog_shm_offset) {
gles2::GetShaderInfoLog& c = GetCmdSpace<gles2::GetShaderInfoLog>();
- c.Init(shader, bucket_id);
+ c.Init(
+ shader, bufsize, length_shm_id, length_shm_offset, infolog_shm_id,
+ infolog_shm_offset);
}
void GetShaderPrecisionFormat(
@@ -524,14 +534,19 @@
c.Init(shadertype, precisiontype, result_shm_id, result_shm_offset);
}
- void GetShaderSource(GLuint shader, uint32 bucket_id) {
+ void GetShaderSource(
+ GLuint shader, GLsizei bufsize, uint32 length_shm_id,
+ uint32 length_shm_offset, uint32 source_shm_id,
+ uint32 source_shm_offset) {
gles2::GetShaderSource& c = GetCmdSpace<gles2::GetShaderSource>();
- c.Init(shader, bucket_id);
+ c.Init(
+ shader, bufsize, length_shm_id, length_shm_offset, source_shm_id,
+ source_shm_offset);
}
- void GetString(GLenum name, uint32 bucket_id) {
+ void GetString(GLenum name) {
gles2::GetString& c = GetCmdSpace<gles2::GetString>();
- c.Init(name, bucket_id);
+ c.Init(name);
}
void GetTexParameterfv(
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 0dacb54..450e48d 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -29,8 +29,7 @@ GLES2Implementation::GLES2Implementation(
transfer_buffer_(transfer_buffer_size, helper, transfer_buffer),
transfer_buffer_id_(transfer_buffer_id),
pack_alignment_(4),
- unpack_alignment_(4),
- error_bits_(0) {
+ unpack_alignment_(4) {
// Eat 1 id so we start at 1 instead of 0.
GLuint eat;
MakeIds(1, &eat);
@@ -59,47 +58,12 @@ 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 = *result;
+ uint32 size = GetResultAs<cmd::GetBucketSize::Result>();
data->resize(size);
if (size > 0u) {
uint32 max_size = transfer_buffer_.GetLargestFreeOrPendingSize();
@@ -144,25 +108,15 @@ void GLES2Implementation::SetBucketContents(
}
}
-bool GLES2Implementation::GetBucketAsString(
- uint32 bucket_id, std::string* str) {
- DCHECK(str);
+std::string GLES2Implementation::GetBucketAsString(uint32 bucket_id) {
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);
- if (data.empty()) {
- return false;
- }
- str->assign(&data[0], &data[0] + data.size() - 1);
- return true;
+ return std::string(reinterpret_cast<char*>(&data[0]), data.size());
}
void GLES2Implementation::SetBucketAsString(
uint32 bucket_id, const std::string& str) {
- // 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);
+ SetBucketContents(bucket_id, str.c_str(), str.size());
}
void GLES2Implementation::DrawElements(
@@ -203,24 +157,18 @@ 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 *result;
+ return GetResultAs<GLint>();
}
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 *result;
+ return GetResultAs<GLint>();
}
void GLES2Implementation::PixelStorei(GLenum pname, GLint param) {
@@ -247,10 +195,6 @@ 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.
@@ -289,15 +233,6 @@ 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) {
@@ -317,11 +252,7 @@ void GLES2Implementation::BufferSubData(
void GLES2Implementation::CompressedTexImage2D(
GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLsizei image_size, const void* data) {
- if (width < 0 || height < 0 || level < 0) {
- SetGLError(GL_INVALID_VALUE);
- return;
- }
- // TODO(gman): Switch to use buckets always or at least if no room in shared
+ // TODO(gman): Switch to use buckets alwayst or at least if no room in shared
// memory.
DCHECK_LE(image_size,
static_cast<GLsizei>(
@@ -337,11 +268,7 @@ 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) {
- 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
+ // TODO(gman): Switch to use buckets alwayst or at least if no room in shared
// memory.
DCHECK_LE(image_size,
static_cast<GLsizei>(
@@ -358,10 +285,6 @@ 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) {
@@ -372,10 +295,6 @@ 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(
@@ -436,16 +355,8 @@ 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();
@@ -475,16 +386,8 @@ 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();
@@ -513,10 +416,6 @@ 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);
@@ -534,6 +433,16 @@ 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;
@@ -552,26 +461,14 @@ void GLES2Implementation::GetShaderPrecisionFormat(
}
}
+void GLES2Implementation::GetShaderSource(
+ GLuint shader, GLsizei bufsize, GLsizei* length, char* source) {
+ // TODO(gman): implement.
+}
+
const GLubyte* GLES2Implementation::GetString(GLenum name) {
- 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);
+ // TODO(gman): implement.
+ return 0;
}
void GLES2Implementation::GetUniformfv(
@@ -595,10 +492,6 @@ 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 339ed4b..579e0d3 100644
--- a/gpu/command_buffer/client/gles2_implementation.h
+++ b/gpu/command_buffer/client/gles2_implementation.h
@@ -5,7 +5,6 @@
#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"
@@ -63,15 +62,9 @@ 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();
@@ -85,9 +78,8 @@ 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. 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);
+ // Gets the contents of a bucket as a string.
+ std::string GetBucketAsString(uint32 bucket_id);
// Sets the contents of a bucket as a string.
void SetBucketAsString(uint32 bucket_id, const std::string& str);
@@ -110,17 +102,10 @@ 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 b758002..8b30119 100644
--- a/gpu/command_buffer/client/gles2_implementation_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_autogen.h
@@ -103,14 +103,6 @@ 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);
}
@@ -118,14 +110,6 @@ 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);
}
@@ -201,10 +185,6 @@ 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);
}
@@ -294,7 +274,11 @@ void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
memcpy(params, result_buffer_, num_values * sizeof(*params));
}
-GLenum GetError();
+GLenum GetError() {
+ helper_->GetError(result_shm_id(), result_shm_offset());
+ WaitForCmd();
+ return GetResultAs<GLenum>();
+}
void GetFloatv(GLenum pname, GLfloat* params) {
helper_->GetFloatv(pname, result_shm_id(), result_shm_offset());
@@ -330,21 +314,10 @@ 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) {
- 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';
- }
-}
+ GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
+
void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) {
helper_->GetRenderbufferParameteriv(
target, pname, result_shm_id(), result_shm_offset());
@@ -362,39 +335,17 @@ 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) {
- 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';
- }
-}
+ GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
+
void GetShaderPrecisionFormat(
GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+// TODO(gman): Implement this
void GetShaderSource(
- 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';
- }
-}
+ GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
+
const GLubyte* GetString(GLenum name);
void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) {
@@ -446,66 +397,45 @@ 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 *result;
+ return GetResultAs<GLboolean>();
}
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 *result;
+ return GetResultAs<GLboolean>();
}
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 *result;
+ return GetResultAs<GLboolean>();
}
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 *result;
+ return GetResultAs<GLboolean>();
}
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 *result;
+ return GetResultAs<GLboolean>();
}
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 *result;
+ return GetResultAs<GLboolean>();
}
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 *result;
+ return GetResultAs<GLboolean>();
}
void LineWidth(GLfloat width) {
@@ -528,14 +458,6 @@ 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);
}
@@ -544,14 +466,6 @@ 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);
}
@@ -731,14 +645,6 @@ 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 97fbe02..9db8bf1 100644
--- a/gpu/command_buffer/common/GLES2/gl2types.h
+++ b/gpu/command_buffer/common/GLES2/gl2types.h
@@ -26,7 +26,6 @@ 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 4f6f649..c642892 100644
--- a/gpu/command_buffer/common/gles2_cmd_format.h
+++ b/gpu/command_buffer/common/gles2_cmd_format.h
@@ -93,8 +93,6 @@ 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
}
@@ -158,8 +156,6 @@ 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);
}
@@ -217,8 +213,6 @@ 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
}
@@ -282,8 +276,6 @@ 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 245a3c8..19824a4 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
@@ -3217,8 +3217,6 @@ 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
}
@@ -3464,30 +3462,55 @@ struct GetProgramInfoLog {
header.SetCmd<ValueType>();
}
- void Init(GLuint _program, uint32 _bucket_id) {
+ void Init(
+ GLuint _program, GLsizei _bufsize, uint32 _length_shm_id,
+ uint32 _length_shm_offset, uint32 _infolog_shm_id,
+ uint32 _infolog_shm_offset) {
SetHeader();
program = _program;
- bucket_id = _bucket_id;
+ 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;
}
- void* Set(void* cmd, GLuint _program, uint32 _bucket_id) {
- static_cast<ValueType*>(cmd)->Init(_program, _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);
return NextCmdAddress<ValueType>(cmd);
}
gpu::CommandHeader header;
uint32 program;
- uint32 bucket_id;
+ int32 bufsize;
+ uint32 length_shm_id;
+ uint32 length_shm_offset;
+ uint32 infolog_shm_id;
+ uint32 infolog_shm_offset;
};
-COMPILE_ASSERT(sizeof(GetProgramInfoLog) == 12,
- Sizeof_GetProgramInfoLog_is_not_12);
+COMPILE_ASSERT(sizeof(GetProgramInfoLog) == 28,
+ Sizeof_GetProgramInfoLog_is_not_28);
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, bucket_id) == 8,
- OffsetOf_GetProgramInfoLog_bucket_id_not_8);
+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);
struct GetRenderbufferParameteriv {
typedef GetRenderbufferParameteriv ValueType;
@@ -3604,30 +3627,55 @@ struct GetShaderInfoLog {
header.SetCmd<ValueType>();
}
- void Init(GLuint _shader, uint32 _bucket_id) {
+ void Init(
+ GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id,
+ uint32 _length_shm_offset, uint32 _infolog_shm_id,
+ uint32 _infolog_shm_offset) {
SetHeader();
shader = _shader;
- bucket_id = _bucket_id;
+ 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;
}
- void* Set(void* cmd, GLuint _shader, uint32 _bucket_id) {
- static_cast<ValueType*>(cmd)->Init(_shader, _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);
return NextCmdAddress<ValueType>(cmd);
}
gpu::CommandHeader header;
uint32 shader;
- uint32 bucket_id;
+ int32 bufsize;
+ uint32 length_shm_id;
+ uint32 length_shm_offset;
+ uint32 infolog_shm_id;
+ uint32 infolog_shm_offset;
};
-COMPILE_ASSERT(sizeof(GetShaderInfoLog) == 12,
- Sizeof_GetShaderInfoLog_is_not_12);
+COMPILE_ASSERT(sizeof(GetShaderInfoLog) == 28,
+ Sizeof_GetShaderInfoLog_is_not_28);
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, bucket_id) == 8,
- OffsetOf_GetShaderInfoLog_bucket_id_not_8);
+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);
struct GetShaderPrecisionFormat {
typedef GetShaderPrecisionFormat ValueType;
@@ -3709,30 +3757,55 @@ struct GetShaderSource {
header.SetCmd<ValueType>();
}
- void Init(GLuint _shader, uint32 _bucket_id) {
+ void Init(
+ GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id,
+ uint32 _length_shm_offset, uint32 _source_shm_id,
+ uint32 _source_shm_offset) {
SetHeader();
shader = _shader;
- bucket_id = _bucket_id;
+ 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;
}
- void* Set(void* cmd, GLuint _shader, uint32 _bucket_id) {
- static_cast<ValueType*>(cmd)->Init(_shader, _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);
return NextCmdAddress<ValueType>(cmd);
}
gpu::CommandHeader header;
uint32 shader;
- uint32 bucket_id;
+ int32 bufsize;
+ uint32 length_shm_id;
+ uint32 length_shm_offset;
+ uint32 source_shm_id;
+ uint32 source_shm_offset;
};
-COMPILE_ASSERT(sizeof(GetShaderSource) == 12,
- Sizeof_GetShaderSource_is_not_12);
+COMPILE_ASSERT(sizeof(GetShaderSource) == 28,
+ Sizeof_GetShaderSource_is_not_28);
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, bucket_id) == 8,
- OffsetOf_GetShaderSource_bucket_id_not_8);
+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);
struct GetString {
typedef GetString ValueType;
@@ -3747,30 +3820,26 @@ struct GetString {
header.SetCmd<ValueType>();
}
- void Init(GLenum _name, uint32 _bucket_id) {
+ void Init(GLenum _name) {
SetHeader();
name = _name;
- bucket_id = _bucket_id;
}
- void* Set(void* cmd, GLenum _name, uint32 _bucket_id) {
- static_cast<ValueType*>(cmd)->Init(_name, _bucket_id);
+ void* Set(void* cmd, GLenum _name) {
+ static_cast<ValueType*>(cmd)->Init(_name);
return NextCmdAddress<ValueType>(cmd);
}
gpu::CommandHeader header;
uint32 name;
- uint32 bucket_id;
};
-COMPILE_ASSERT(sizeof(GetString) == 12,
- Sizeof_GetString_is_not_12);
+COMPILE_ASSERT(sizeof(GetString) == 8,
+ Sizeof_GetString_is_not_8);
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;
@@ -4178,8 +4247,6 @@ 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
}
@@ -4225,8 +4292,6 @@ 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
}
@@ -4272,8 +4337,6 @@ 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
}
@@ -4320,8 +4383,6 @@ 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
}
@@ -4368,8 +4429,6 @@ 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
}
@@ -4416,8 +4475,6 @@ 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
}
@@ -4463,8 +4520,6 @@ 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 e53ac55..381fea1 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
@@ -1284,14 +1284,22 @@ TEST(GLES2FormatTest, GetProgramInfoLog) {
void* next_cmd = cmd.Set(
&cmd,
static_cast<GLuint>(11),
- static_cast<uint32>(12));
+ static_cast<GLsizei>(12),
+ static_cast<uint32>(13),
+ static_cast<uint32>(14),
+ static_cast<uint32>(15),
+ static_cast<uint32>(16));
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<uint32>(12), cmd.bucket_id);
+ 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);
}
TEST(GLES2FormatTest, GetRenderbufferParameteriv) {
@@ -1337,14 +1345,22 @@ TEST(GLES2FormatTest, GetShaderInfoLog) {
void* next_cmd = cmd.Set(
&cmd,
static_cast<GLuint>(11),
- static_cast<uint32>(12));
+ static_cast<GLsizei>(12),
+ static_cast<uint32>(13),
+ static_cast<uint32>(14),
+ static_cast<uint32>(15),
+ static_cast<uint32>(16));
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<uint32>(12), cmd.bucket_id);
+ 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);
}
TEST(GLES2FormatTest, GetShaderPrecisionFormat) {
@@ -1371,29 +1387,35 @@ TEST(GLES2FormatTest, GetShaderSource) {
void* next_cmd = cmd.Set(
&cmd,
static_cast<GLuint>(11),
- static_cast<uint32>(12));
+ static_cast<GLsizei>(12),
+ static_cast<uint32>(13),
+ static_cast<uint32>(14),
+ static_cast<uint32>(15),
+ static_cast<uint32>(16));
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<uint32>(12), cmd.bucket_id);
+ 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);
}
TEST(GLES2FormatTest, GetString) {
GetString cmd = { { 0 } };
void* next_cmd = cmd.Set(
&cmd,
- static_cast<GLenum>(11),
- static_cast<uint32>(12));
+ static_cast<GLenum>(11));
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 e0fc8e6..9e376270 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -11,17 +11,6 @@
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
@@ -412,41 +401,6 @@ 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 99b17e5..b2da669 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.h
+++ b/gpu/command_buffer/common/gles2_cmd_utils.h
@@ -34,10 +34,6 @@ 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 06d368d..4452e39 100644
--- a/gpu/command_buffer/service/common_decoder.cc
+++ b/gpu/command_buffer/service/common_decoder.cc
@@ -8,7 +8,7 @@
namespace gpu {
-void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const {
+const void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const {
if (OffsetSizeValid(offset, size)) {
return data_.get() + offset;
}
@@ -33,10 +33,8 @@ bool CommonDecoder::Bucket::SetData(
}
void CommonDecoder::Bucket::SetFromString(const std::string& str) {
- // 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);
+ SetSize(str.size());
+ SetData(str.c_str(), 0, str.size());
}
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 9ea0d6f..2300e5a 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.
- void* GetData(size_t offset, size_t size) const;
+ const void* GetData(size_t offset, size_t size) const;
template <typename T>
T GetDataAs(size_t offset, size_t size) const {
@@ -71,8 +71,7 @@ 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. Strings are passed NULL terminated to
- // distinguish between empty string and no string.
+ // Sets the bucket data from a 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 52f59ce..2b04de6 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -103,6 +103,53 @@ 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)
@@ -441,9 +488,6 @@ 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);
@@ -1758,7 +1802,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 = GLES2Util::GLErrorBitToGLError(mask);
+ error = GLErrorBitToGLError(mask);
break;
}
}
@@ -1766,13 +1810,13 @@ GLenum GLES2DecoderImpl::GetGLError() {
if (error != GL_NO_ERROR) {
// There was an error, clear the corresponding wrapped error.
- error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error);
+ error_bits_ &= ~GLErrorToErrorBit(error);
}
return error;
}
void GLES2DecoderImpl::SetGLError(GLenum error) {
- error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
+ error_bits_ |= GLErrorToErrorBit(error);
}
void GLES2DecoderImpl::CopyRealGLErrorsToWrapper() {
@@ -2004,20 +2048,6 @@ 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);
@@ -2247,18 +2277,6 @@ 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);
@@ -2419,6 +2437,8 @@ 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 c2620ac..d22a900 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -1087,13 +1087,27 @@ error::Error GLES2DecoderImpl::HandleGetProgramInfoLog(
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
- 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));
+ 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);
return error::kNoError;
}
@@ -1141,7 +1155,7 @@ error::Error GLES2DecoderImpl::HandleGetShaderiv(
if (params == NULL) {
return error::kOutOfBounds;
}
- DoGetShaderiv(shader, pname, params);
+ glGetShaderiv(shader, pname, params);
return error::kNoError;
}
@@ -1152,13 +1166,27 @@ error::Error GLES2DecoderImpl::HandleGetShaderInfoLog(
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
- 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));
+ 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);
return error::kNoError;
}
@@ -1169,13 +1197,38 @@ error::Error GLES2DecoderImpl::HandleGetShaderSource(
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
- 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));
+ 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);
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 5f96cd5..09ddc14 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -853,7 +853,6 @@ 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);
@@ -862,14 +861,15 @@ 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_, kBucketId);
+ get_cmd.Init(client_shader_id_, kSourceSize + 1,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kSharedMemoryId, kSharedMemoryOffset + sizeof(kSourceSize));
EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd));
- 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()));
+ EXPECT_EQ(kSourceSize, *GetSharedMemoryAs<uint32*>());
+ EXPECT_EQ(0, memcmp(GetSharedMemoryAsWithOffset<void*>(sizeof(kSourceSize)),
+ kSource, kSourceSize));
}
TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) {
@@ -897,7 +897,6 @@ 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>();
@@ -907,13 +906,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_, kBucketId);
+ get_cmd.Init(client_shader_id_, kSourceSize + 1,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kSharedMemoryId, kSharedMemoryOffset + sizeof(kSourceSize));
EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd));
- 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()));
+ EXPECT_EQ(kSourceSize, *GetSharedMemoryAs<uint32*>());
+ EXPECT_EQ(0, memcmp(GetSharedMemoryAsWithOffset<void*>(sizeof(kSourceSize)),
+ kSource, kSourceSize));
}
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 f8dc38b..5b422bf 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,6 +10,7 @@
TEST_F(GLES2DecoderTest1, ActiveTextureValidArgs) {
+ EXPECT_CALL(*gl_, ActiveTexture(1));
SpecializedSetup<ActiveTexture, 0>();
ActiveTexture cmd;
cmd.Init(1);
@@ -1112,38 +1113,8 @@ 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(
@@ -1206,44 +1177,21 @@ 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 ef5c231..c0b52fa 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,6 +667,17 @@ 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
@@ -727,6 +738,17 @@ 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>();
@@ -783,6 +805,17 @@ 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>();
@@ -839,6 +872,17 @@ 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>();
@@ -895,6 +939,17 @@ 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>();
@@ -951,6 +1006,17 @@ 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>();
@@ -1007,6 +1073,17 @@ 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(
@@ -1033,7 +1110,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_VALUE, GetGLError());
+ EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs3_0) {
@@ -1066,6 +1143,18 @@ 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>();
@@ -1075,7 +1164,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_VALUE, GetGLError());
+ EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
TEST_F(GLES2DecoderTest2, UniformMatrix3fvValidArgs) {
@@ -1104,7 +1193,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_VALUE, GetGLError());
+ EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs3_0) {
@@ -1137,6 +1226,18 @@ 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>();
@@ -1146,7 +1247,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_VALUE, GetGLError());
+ EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
TEST_F(GLES2DecoderTest2, UniformMatrix4fvValidArgs) {
@@ -1175,7 +1276,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_VALUE, GetGLError());
+ EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs3_0) {
@@ -1208,6 +1309,18 @@ 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>();
@@ -1217,7 +1330,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_VALUE, GetGLError());
+ EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
// TODO(gman): UseProgram