summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 07:02:54 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 07:02:54 +0000
commit558847a19c803cb3b255d0d9812837a564f51cf3 (patch)
treeea8a2755230554e49f7d70be990f5d691b0f9a39
parentcd8c905857cb134f7c884389dd5652731b30d51e (diff)
downloadchromium_src-558847a19c803cb3b255d0d9812837a564f51cf3.zip
chromium_src-558847a19c803cb3b255d0d9812837a564f51cf3.tar.gz
chromium_src-558847a19c803cb3b255d0d9812837a564f51cf3.tar.bz2
Adds the remaining bucket commands, switches the
GLES2Implementation to use the bucket versions of the commands and fixes a bunch of gcc warnings TEST=various unit tests BUG=none Review URL: http://codereview.chromium.org/1173001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42438 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py444
-rw-r--r--gpu/command_buffer/client/cmd_buffer_helper_test.cc2
-rw-r--r--gpu/command_buffer/client/gles2_cmd_helper.h15
-rw-r--r--gpu/command_buffer/client/gles2_cmd_helper_autogen.h12
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc69
-rw-r--r--gpu/command_buffer/client/gles2_implementation.h3
-rw-r--r--gpu/command_buffer/client/gles2_implementation_autogen.h5
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format.h111
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_autogen.h81
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_test_autogen.h35
-rw-r--r--gpu/command_buffer/common/gles2_cmd_id_test_autogen.h8
-rw-r--r--gpu/command_buffer/common/gles2_cmd_ids_autogen.h4
-rw-r--r--gpu/command_buffer/service/buffer_manager_unittest.cc3
-rw-r--r--gpu/command_buffer/service/common_decoder.cc9
-rw-r--r--gpu/command_buffer/service/common_decoder.h5
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc204
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_autogen.h38
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc477
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h65
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h11
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc17
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h6
-rw-r--r--gpu/command_buffer/service/id_manager_unittest.cc4
-rw-r--r--gpu/command_buffer/service/program_manager_unittest.cc1
-rw-r--r--gpu/command_buffer/service/texture_manager_unittest.cc9
25 files changed, 1212 insertions, 426 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index f58dbc7..16f084b 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -360,6 +360,10 @@ _CMD_ID_TABLE = {
'VertexAttribPointer': 429,
'Viewport': 430,
'SwapBuffers': 431,
+ 'BindAttribLocationBucket': 432,
+ 'GetUniformLocationBucket': 433,
+ 'GetAttribLocationBucket': 434,
+ 'ShaderSourceBucket': 435,
}
# This is a list of enum names and their valid values. It is used to map
@@ -934,6 +938,7 @@ _ENUM_LISTS = {
# immediate: Whether or not to generate an immediate command for the GL
# function. The default is if there is exactly 1 pointer argument
# in the GL function an immediate command is generated.
+# bucket: True to generate a bucket version of the command.
# impl_func: Whether or not to generate the GLES2Implementation part of this
# command.
# needs_size: If true a data_size field is added to the command.
@@ -944,7 +949,7 @@ _ENUM_LISTS = {
_FUNCTION_INFO = {
'ActiveTexture': {'decoder_func': 'DoActiveTexture', 'unit_test': False},
- 'BindAttribLocation': {'type': 'GLchar'},
+ 'BindAttribLocation': {'type': 'GLchar', 'bucket': True, 'needs_size': True},
'BindBuffer': {'decoder_func': 'DoBindBuffer'},
'BindFramebuffer': {
'decoder_func': 'DoBindFramebuffer',
@@ -1040,6 +1045,7 @@ _FUNCTION_INFO = {
'GetAttribLocation': {
'type': 'HandWritten',
'immediate': True,
+ 'bucket': True,
'needs_size': True,
'cmd_args':
'GLidProgram program, const char* name, NonImmediate GLint* location',
@@ -1122,6 +1128,7 @@ _FUNCTION_INFO = {
'GetUniformLocation': {
'type': 'HandWritten',
'immediate': True,
+ 'bucket': True,
'needs_size': True,
'cmd_args':
'GLidProgram program, const char* name, NonImmediate GLint* location',
@@ -1166,6 +1173,7 @@ _FUNCTION_INFO = {
'ShaderSource': {
'type': 'Manual',
'immediate': True,
+ 'bucket': True,
'needs_size': True,
'cmd_args':
'GLuint shader, const char* data',
@@ -1335,7 +1343,7 @@ class TypeHandler(object):
def InitFunction(self, func):
"""Add or adjust anything type specific for this function."""
if func.GetInfo('needs_size'):
- func.AddCmdArg(Argument('data_size', 'uint32'))
+ func.AddCmdArg(DataSizeArgument('data_size'))
def AddImmediateFunction(self, generator, func):
"""Adds an immediate version of a function."""
@@ -1345,6 +1353,14 @@ class TypeHandler(object):
if func.num_pointer_args == 1 or immediate:
generator.AddFunction(ImmediateFunction(func))
+ def AddBucketFunction(self, generator, func):
+ """Adds a bucket version of a function."""
+ # Generate an immediate command if there is only 1 pointer arg.
+ bucket = func.GetInfo('bucket') # can be True, False or None
+ if bucket:
+ generator.AddFunction(BucketFunction(func))
+
+
def WriteStruct(self, func, file):
"""Writes a structure that matches the arguments to a function."""
comment = func.GetInfo('cmd_comment')
@@ -1467,6 +1483,10 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d,
file.Write("}\n")
file.Write("\n")
+ def WriteBucketFormatTest(self, func, file):
+ """Writes a format test for a bucket version of a command."""
+ pass
+
def WriteGetDataSizeCode(self, func, file):
"""Writes the code to set data_size used in validation"""
pass
@@ -1481,6 +1501,11 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d,
file.Write(" %s(%s);\n" %
(func.GetGLFunctionName(), func.MakeOriginalArgString("")))
+ def WriteBucketHandlerImplementation (self, func, file):
+ """Writes the handler impl for the bucket version of a command."""
+ file.Write(" %s(%s);\n" %
+ (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
+
def WriteServiceImplementation(self, func, file):
"""Writes the service implementation for a command."""
file.Write(
@@ -1518,6 +1543,24 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d,
file.Write("}\n")
file.Write("\n")
+ def WriteBucketServiceImplementation(self, func, file):
+ """Writes the service implementation for a bucket version of command."""
+ file.Write(
+ "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
+ file.Write(
+ " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
+ last_arg = func.GetLastOriginalArg()
+ all_but_last_arg = func.GetOriginalArgs()[:-1]
+ for arg in all_but_last_arg:
+ arg.WriteGetCode(file)
+ self.WriteGetDataSizeCode(func, file)
+ last_arg.WriteGetCode(file)
+ func.WriteHandlerValidation(file)
+ func.WriteHandlerImplementation(file)
+ file.Write(" return error::kNoError;\n")
+ file.Write("}\n")
+ file.Write("\n")
+
def WriteValidUnitTest(self, func, file, test, extra = {}):
"""Writes a valid unit test."""
if func.GetInfo('expectation') == False:
@@ -1621,6 +1664,14 @@ 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 WriteBucketServiceUnitTest(self, func, file):
+ """Writes the service unit test for a bucket command."""
+ file.Write("// TODO(gman): %s\n" % func.name)
+
+ def WriteBucketValidationCode(self, func, file):
+ """Writes the validation code for a bucket version of a command."""
+ file.Write("// TODO(gman): %s\n" % func.name)
+
def WriteGLES2ImplementationDeclaration(self, func, file):
"""Writes the GLES2 Implemention declaration."""
file.Write("%s %s(%s);\n" %
@@ -1701,6 +1752,10 @@ class CustomHandler(TypeHandler):
"""Overrriden from TypeHandler."""
pass
+ def WriteImmediateServiceImplementation(self, func, file):
+ """Overrriden from TypeHandler."""
+ pass
+
def WriteServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
file.Write("// TODO(gman): %s\n\n" % func.name)
@@ -1765,6 +1820,10 @@ class HandWrittenHandler(CustomHandler):
"""Overrriden from TypeHandler."""
file.Write("// TODO(gman): %s\n\n" % func.name)
+ def WriteBucketServiceUnitTest(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write("// TODO(gman): %s\n\n" % func.name)
+
def WriteServiceImplementation(self, func, file):
"""Overrriden from TypeHandler."""
pass
@@ -1773,10 +1832,18 @@ class HandWrittenHandler(CustomHandler):
"""Overrriden from TypeHandler."""
pass
+ def WriteBucketServiceImplementation(self, func, file):
+ """Overrriden from TypeHandler."""
+ pass
+
def WriteImmediateCmdHelper(self, func, file):
"""Overrriden from TypeHandler."""
pass
+ def WriteBucketCmdHelper(self, func, file):
+ """Overrriden from TypeHandler."""
+ pass
+
def WriteCmdHelper(self, func, file):
"""Overrriden from TypeHandler."""
pass
@@ -1789,6 +1856,11 @@ class HandWrittenHandler(CustomHandler):
"""Overrriden from TypeHandler."""
file.Write("// TODO(gman): Write test for %s\n" % func.name)
+ def WriteBucketFormatTest(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write("// TODO(gman): Write test for %s\n" % func.name)
+
+
class ManualHandler(CustomHandler):
"""Handler for commands who's handlers must be written by hand."""
@@ -2530,7 +2602,7 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
%(name)s cmd;
cmd.Init(%(args)s);
EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);%(gl_error_test)s
+ EXPECT_EQ(0u, result->size);%(gl_error_test)s
}
"""
self.WriteInvalidUnitTest(func, file, invalid_test)
@@ -2894,85 +2966,11 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
file.Write("\n")
-class GLcharHandler(TypeHandler):
+class GLcharHandler(CustomHandler):
"""Handler for functions that pass a single string ."""
def __init__(self):
- TypeHandler.__init__(self)
-
- def InitFunction(self, func):
- """Overrriden from TypeHandler."""
- func.AddCmdArg(Argument('data_size', 'uint32'))
-
- def WriteServiceUnitTest(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write("// TODO(gman): %s\n\n" % func.name)
-
- 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."""
- file.Write(
- "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
- file.Write(
- " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
- last_arg = func.GetLastOriginalArg()
-
- all_but_last_arg = func.GetOriginalArgs()[:-1]
- for arg in all_but_last_arg:
- arg.WriteGetCode(file)
-
- file.Write(" uint32 name_size = c.data_size;\n")
- file.Write(" const char* name = GetSharedMemoryAs<%s>(\n" %
- last_arg.type)
- file.Write(" c.%s_shm_id, c.%s_shm_offset, name_size);\n" %
- (last_arg.name, last_arg.name))
- func.WriteHandlerValidation(file)
- arg_string = ", ".join(["%s" % arg.name for arg in all_but_last_arg])
- file.Write(" String name_str(name, name_size);\n")
- file.Write(" %s(%s, name_str.c_str());\n" %
- (func.GetGLFunctionName(), arg_string))
- file.Write(" return error::kNoError;\n")
- file.Write("}\n")
- file.Write("\n")
-
- def WriteImmediateServiceImplementation(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write(
- "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
- file.Write(
- " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
- last_arg = func.GetLastOriginalArg()
-
- all_but_last_arg = func.GetOriginalArgs()[:-1]
- for arg in all_but_last_arg:
- arg.WriteGetCode(file)
-
- file.Write(" uint32 name_size = c.data_size;\n")
- file.Write(
- " const char* name = GetImmediateDataAs<const char*>(\n")
- file.Write(" c, name_size, immediate_data_size);\n")
- func.WriteHandlerValidation(file)
- arg_string = ", ".join(["%s" % arg.name for arg in all_but_last_arg])
- file.Write(" String name_str(name, name_size);\n")
- file.Write(" %s(%s, name_str.c_str());\n" %
- (func.GetGLFunctionName(), arg_string))
- file.Write(" return error::kNoError;\n")
- file.Write("}\n")
- file.Write("\n")
-
- def WriteGLES2ImplementationHeader(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write("%s %s(%s) {\n" %
- (func.return_type, func.original_name,
- func.MakeTypedOriginalArgString("")))
- file.Write(" // TODO(gman): This needs to change to use SendString.\n")
- file.Write(" helper_->%sImmediate(%s);\n" %
- (func.name, func.MakeOriginalArgString("")))
- file.Write("}\n")
- file.Write("\n")
+ CustomHandler.__init__(self)
def WriteImmediateCmdComputeSize(self, func, file):
"""Overrriden from TypeHandler."""
@@ -3072,6 +3070,7 @@ TEST(GLES2FormatTest, %(func_name)s) {
EXPECT_EQ(static_cast<uint32>(strlen(test_str)), cmd.data_size);
EXPECT_EQ(0, memcmp(test_str, ImmediateDataAddress(&cmd), strlen(test_str)));
}
+
"""
file.Write(code % {
'func_name': func.name,
@@ -3079,180 +3078,6 @@ TEST(GLES2FormatTest, %(func_name)s) {
'check_code': "\n".join(check_code),
})
-class GetGLcharHandler(GLcharHandler):
- """Handler for glGetAttibLoc, glGetUniformLoc."""
-
- def __init__(self):
- GLcharHandler.__init__(self)
-
- def WriteServiceUnitTest(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write("// TODO(gman): %s\n\n" % func.name)
-
- 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."""
- file.Write(
- "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
- file.Write(
- " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
- last_arg = func.GetLastOriginalArg()
-
- all_but_last_arg = func.GetOriginalArgs()
- for arg in all_but_last_arg:
- arg.WriteGetCode(file)
-
- file.Write(" uint32 name_size = c.data_size;\n")
- file.Write(" const char* name = GetSharedMemoryAs<%s>(\n" %
- last_arg.type)
- file.Write(" c.%s_shm_id, c.%s_shm_offset, name_size);\n" %
- (last_arg.name, last_arg.name))
- file.Write(" GLint* location = GetSharedMemoryAs<GLint*>(\n")
- file.Write(
- " c.location_shm_id, c.location_shm_offset, sizeof(*location));\n")
- file.Write(" // TODO(gman): Validate location.\n")
- func.WriteHandlerValidation(file)
- arg_string = ", ".join(["%s" % arg.name for arg in all_but_last_arg])
- file.Write(" String name_str(name, name_size);\n")
- file.Write(" *location = %s(%s, name_str.c_str());\n" %
- (func.GetGLFunctionName(), arg_string))
- file.Write(" return error::kNoError;\n")
- file.Write("}\n")
- file.Write("\n")
-
- def WriteImmediateServiceImplementation(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write(
- "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
- file.Write(
- " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
- last_arg = func.GetLastOriginalArg()
-
- all_but_last_arg = func.GetOriginalArgs()[:-1]
- for arg in all_but_last_arg:
- arg.WriteGetCode(file)
-
- file.Write(" uint32 name_size = c.data_size;\n")
- file.Write(
- " const char* name = GetImmediateDataAs<const char*>(\n")
- file.Write(" c, name_size, immediate_data_size);\n")
- file.Write(" GLint* location = GetSharedMemoryAs<GLint*>(\n")
- file.Write(
- " c.location_shm_id, c.location_shm_offset, sizeof(*location));\n")
- file.Write(" // TODO(gman): Validate location.\n")
- func.WriteHandlerValidation(file)
- arg_string = ", ".join(["%s" % arg.name for arg in all_but_last_arg])
- file.Write(" String name_str(name, name_size);\n")
- file.Write(" *location = %s(%s, name_str.c_str());\n" %
- (func.GetGLFunctionName(), arg_string))
- file.Write(" return error::kNoError;\n")
- file.Write("}\n")
- file.Write("\n")
-
- def WriteGLES2ImplementationHeader(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write("%s %s(%s) {\n" %
- (func.return_type, func.original_name,
- func.MakeTypedOriginalArgString("")))
- file.Write(" // TODO(gman): This needs to change to use SendString.\n")
- file.Write(" GLint* result = shared_memory_.GetAddressAs<GLint*>(0);\n")
- file.Write(" DCHECK(false); // pass in shared memory\n")
- file.Write(" helper_->%sImmediate(%s);\n" %
- (func.name, func.MakeOriginalArgString("")))
- file.Write(" int32 token = helper_->InsertToken();\n")
- file.Write(" helper_->WaitForToken(token);\n")
- file.Write(" return *result;\n")
- file.Write("}\n")
- file.Write("\n")
-
- def WriteImmediateCmdComputeSize(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write(" static uint32 ComputeDataSize(const char* s) {\n")
- file.Write(" return strlen(s);\n")
- file.Write(" }\n")
- file.Write("\n")
- file.Write(" static uint32 ComputeSize(const char* s) {\n")
- file.Write(" return static_cast<uint32>(\n")
- file.Write(" sizeof(ValueType) + ComputeDataSize(s)); // NOLINT\n")
- file.Write(" }\n")
- file.Write("\n")
-
- def WriteImmediateCmdSetHeader(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write(" void SetHeader(const char* s) {\n")
- file.Write(" header.SetCmdByTotalSize<ValueType>(ComputeSize(s));\n")
- file.Write(" }\n")
- file.Write("\n")
-
- def WriteImmediateCmdInit(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write(" void Init(%s) {\n" % func.MakeTypedInitString("_"))
- file.Write(" SetHeader(_name);\n")
- args = func.GetInitArgs()
- for arg in args:
- file.Write(" %s = _%s;\n" % (arg.name, arg.name))
- file.Write(" data_size = ComputeDataSize(_name);\n")
- file.Write(" memcpy(ImmediateDataAddress(this), _name, data_size);\n")
- file.Write(" }\n")
- file.Write("\n")
-
- def WriteImmediateCmdSet(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write(" void* Set(void* cmd%s) {\n" %
- func.MakeTypedInitString("_", True))
- file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" %
- func.MakeInitString("_"))
- file.Write(" const uint32 size = ComputeSize(_name);\n")
- file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>("
- "cmd, size);\n")
- file.Write(" }\n")
- file.Write("\n")
-
- def WriteImmediateCmdHelper(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write(" void %s(%s) {\n" %
- (func.name, func.MakeTypedCmdArgString("")))
- file.Write(" const uint32 size = gles2::%s::ComputeSize(name);\n" %
- func.name)
- file.Write(" gles2::%s& c = GetImmediateCmdSpaceTotalSize<gles2::%s>("
- "size);\n" %
- (func.name, func.name))
- file.Write(" c.Init(%s);\n" % func.MakeCmdArgString(""))
- file.Write(" }\n\n")
-
- def WriteImmediateFormatTest(self, func, file):
- """Overrriden from TypeHandler."""
- file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name)
- file.Write(" int8 buf[256] = { 0, };\n")
- file.Write(" %s& cmd = *static_cast<%s*>(static_cast<void*>(&buf));\n" %
- (func.name, func.name))
- file.Write(" static const char* const test_str = \"test string\";\n")
- file.Write(" void* next_cmd = cmd.Set(\n")
- file.Write(" &cmd")
- all_but_last_arg = func.GetCmdArgs()[:-1]
- value = 11
- for arg in all_but_last_arg:
- file.Write(",\n static_cast<%s>(%d)" % (arg.type, value))
- value += 1
- file.Write(",\n test_str);\n")
- value = 11
- file.Write(" EXPECT_EQ(%s::kCmdId ^ cmd.header.command);\n" % func.name)
- file.Write(" EXPECT_EQ(sizeof(cmd)\n")
- file.Write(" RoundSizeToMultipleOfEntries(strlen(test_str)),\n")
- file.Write(" cmd.header.size * 4u);\n")
- file.Write(" EXPECT_EQ(static_cast<char*>(next_cmd),\n")
- file.Write(" reinterpret_cast<char*>(&cmd) + sizeof(cmd));\n");
- for arg in all_but_last_arg:
- file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" %
- (arg.type, value, arg.name))
- value += 1
- file.Write(" // TODO(gman): check that string got copied.\n")
- file.Write("}\n")
- file.Write("\n")
-
class IsHandler(TypeHandler):
"""Handler for glIs____ type and glGetError functions."""
@@ -3568,6 +3393,19 @@ class Argument(object):
"""Gets the immediate version of this argument."""
return self
+ def GetBucketVersion(self):
+ """Gets the bucket version of this argument."""
+ return self
+
+class DataSizeArgument(Argument):
+ """class for data_size which Bucket commands do not need."""
+
+ def __init__(self, name):
+ Argument.__init__(self, name, "uint32")
+
+ def GetBucketVersion(self):
+ return None
+
class SizeArgument(Argument):
"""class for GLsizei and GLsizeiptr."""
@@ -3769,6 +3607,42 @@ class PointerArgument(Argument):
"""Overridden from Argument."""
return ImmediatePointerArgument(self.name, self.type)
+ def GetBucketVersion(self):
+ """Overridden from Argument."""
+ if self.type == "const char*":
+ return InputStringBucketArgument(self.name, self.type)
+ return self
+
+
+class InputStringBucketArgument(Argument):
+ """An string input argument where the string is passed in a bucket."""
+
+ def __init__(self, name, type):
+ Argument.__init__(self, name + "_bucket_id", "uint32")
+
+ def WriteGetCode(self, file):
+ """Overridden from Argument."""
+ code = """
+ Bucket* %(name)s_bucket = GetBucket(c.%(name)s);
+ if (!%(name)s_bucket) {
+ return error::kInvalidArguments;
+ }
+ std::string %(name)s_str;
+ if (!%(name)s_bucket->GetAsString(&%(name)s_str)) {
+ return error::kInvalidArguments;
+ }
+ const char* %(name)s = %(name)s_str.c_str();
+"""
+ file.Write(code % {
+ 'name': self.name,
+ })
+
+ def GetValidArg(self, offset, index):
+ return "kNameBucketId"
+
+ def GetValidGLArg(self, offset, index):
+ return "_"
+
class NonImmediatePointerArgument(PointerArgument):
"""A pointer argument that stays a pointer even in an immediate cmd."""
@@ -3852,14 +3726,18 @@ class Function(object):
self.can_auto_generate = num_pointer_args == 0 and return_type == "void"
self.cmd_args = cmd_args
self.init_args = init_args
+ self.InitFunction()
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."""
return self.info.type == type_name
+ def InitFunction(self):
+ """Calls the init function for the type handler."""
+ self.type_handler.InitFunction(self)
+
def GetInfo(self, name):
"""Returns a value from the function info for this function."""
if hasattr(self.info, name):
@@ -4116,6 +3994,57 @@ class ImmediateFunction(Function):
self.type_handler.WriteImmediateFormatTest(self, file)
+class BucketFunction(Function):
+ """A class that represnets a bucket version of a function command."""
+
+ def __init__(self, func):
+ new_args = []
+ for arg in func.GetOriginalArgs():
+ new_arg = arg.GetBucketVersion()
+ if new_arg:
+ new_args.append(new_arg)
+
+ cmd_args = []
+ new_args_for_cmds = []
+ for arg in func.args_for_cmds:
+ new_arg = arg.GetBucketVersion()
+ if new_arg:
+ new_args_for_cmds.append(new_arg)
+ new_arg.AddCmdArgs(cmd_args)
+
+ new_init_args = []
+ for arg in new_args_for_cmds:
+ arg.AddInitArgs(new_init_args)
+
+ Function.__init__(
+ self,
+ func.original_name,
+ "%sBucket" % func.name,
+ func.info,
+ func.return_type,
+ new_args,
+ new_args_for_cmds,
+ cmd_args,
+ new_init_args,
+ 0)
+
+ def InitFunction(self):
+ """Overridden from Function"""
+ pass
+
+ def WriteServiceImplementation(self, file):
+ """Overridden from Function"""
+ pass
+
+ def WriteHandlerImplementation(self, file):
+ """Overridden from Function"""
+ self.type_handler.WriteBucketHandlerImplementation(self, file)
+
+ def WriteServiceUnitTest(self, file):
+ """Writes the service implementation for a command."""
+ self.type_handler.WriteBucketServiceUnitTest(self, file)
+
+
def CreateArg(arg_string):
"""Creates an Argument."""
arg_parts = arg_string.split()
@@ -4170,7 +4099,6 @@ class GLGenerator(object):
'DELn': DELnHandler(),
'GENn': GENnHandler(),
'GETn': GETnHandler(),
- 'GetGLchar': GetGLcharHandler(),
'GLchar': GLcharHandler(),
'HandWritten': HandWrittenHandler(),
'Is': IsHandler(),
@@ -4279,6 +4207,7 @@ class GLGenerator(object):
self.original_functions.append(f)
self.AddFunction(f)
f.type_handler.AddImmediateFunction(self, f)
+ f.type_handler.AddBucketFunction(self, f)
self.Log("Auto Generated Functions : %d" %
len([f for f in self.functions if f.can_auto_generate or
@@ -4296,11 +4225,14 @@ class GLGenerator(object):
"""Writes the command buffer format"""
file = CHeaderWriter(filename)
file.Write("#define GLES2_COMMAND_LIST(OP) \\\n")
+ by_id = {}
for func in self.functions:
if not func.name in _CMD_ID_TABLE:
self.Error("Command %s not in _CMD_ID_TABLE" % func.name)
+ by_id[_CMD_ID_TABLE[func.name]] = func
+ for id in sorted(by_id.keys()):
file.Write(" %-60s /* %d */ \\\n" %
- ("OP(%s)" % func.name, _CMD_ID_TABLE[func.name]))
+ ("OP(%s)" % by_id[id].name, id))
file.Write("\n")
file.Write("enum CommandId {\n")
diff --git a/gpu/command_buffer/client/cmd_buffer_helper_test.cc b/gpu/command_buffer/client/cmd_buffer_helper_test.cc
index afbb117..ffb8137 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper_test.cc
+++ b/gpu/command_buffer/client/cmd_buffer_helper_test.cc
@@ -199,7 +199,7 @@ TEST_F(CommandBufferHelperTest, TestCommandWrapping) {
// the command buffer.
TEST_F(CommandBufferHelperTest, TestCommandWrappingExactMultiple) {
const int32 kCommandSize = 5;
- const int32 kNumArgs = kCommandSize - 1;
+ const size_t kNumArgs = kCommandSize - 1;
COMPILE_ASSERT(kNumCommandEntries % kCommandSize == 0,
Not_multiple_of_num_command_entries);
CommandBufferEntry args1[kNumArgs];
diff --git a/gpu/command_buffer/client/gles2_cmd_helper.h b/gpu/command_buffer/client/gles2_cmd_helper.h
index a4f31aa..9876156 100644
--- a/gpu/command_buffer/client/gles2_cmd_helper.h
+++ b/gpu/command_buffer/client/gles2_cmd_helper.h
@@ -46,6 +46,14 @@ class GLES2CmdHelper : public CommandBufferHelper {
c.Init(program, name, location_shm_id, location_shm_offset);
}
+ void GetAttribLocationBucket(
+ GLuint program, uint32 name_bucket_id,
+ uint32 location_shm_id, uint32 location_shm_offset) {
+ gles2::GetAttribLocationBucket& c =
+ GetCmdSpace<gles2::GetAttribLocationBucket>();
+ c.Init(program, name_bucket_id, location_shm_id, location_shm_offset);
+ }
+
void GetUniformLocation(
GLuint program, uint32 name_shm_id, uint32 name_shm_offset,
uint32 location_shm_id, uint32 location_shm_offset, uint32 data_size) {
@@ -64,6 +72,13 @@ class GLES2CmdHelper : public CommandBufferHelper {
c.Init(program, name, location_shm_id, location_shm_offset);
}
+ void GetUniformLocationBucket(
+ GLuint program, uint32 name_bucket_id,
+ uint32 location_shm_id, uint32 location_shm_offset) {
+ gles2::GetUniformLocationBucket& c =
+ GetCmdSpace<gles2::GetUniformLocationBucket>();
+ c.Init(program, name_bucket_id, location_shm_id, location_shm_offset);
+ }
private:
DISALLOW_COPY_AND_ASSIGN(GLES2CmdHelper);
diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
index b450ba5..97b5e25 100644
--- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
+++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
@@ -32,6 +32,13 @@
c.Init(program, index, name, data_size);
}
+ void BindAttribLocationBucket(
+ GLuint program, GLuint index, uint32 name_bucket_id) {
+ gles2::BindAttribLocationBucket& c =
+ GetCmdSpace<gles2::BindAttribLocationBucket>();
+ c.Init(program, index, name_bucket_id);
+ }
+
void BindBuffer(GLenum target, GLuint buffer) {
gles2::BindBuffer& c = GetCmdSpace<gles2::BindBuffer>();
c.Init(target, buffer);
@@ -691,6 +698,11 @@
c.Init(shader, data_size);
}
+ void ShaderSourceBucket(GLuint shader, uint32 data_bucket_id) {
+ gles2::ShaderSourceBucket& c = GetCmdSpace<gles2::ShaderSourceBucket>();
+ c.Init(shader, data_bucket_id);
+ }
+
void StencilFunc(GLenum func, GLint ref, GLuint mask) {
gles2::StencilFunc& c = GetCmdSpace<gles2::StencilFunc>();
c.Init(func, ref, mask);
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index cded8bb..99938d5 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -144,6 +144,17 @@ void GLES2Implementation::SetBucketContents(
}
}
+void GLES2Implementation::SetBucketAsCString(
+ uint32 bucket_id, const char* 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
+ if (str) {
+ SetBucketContents(bucket_id, str, strlen(str) + 1);
+ } else {
+ helper_->SetBucketSize(bucket_id, 0);
+ }
+}
+
bool GLES2Implementation::GetBucketAsString(
uint32 bucket_id, std::string* str) {
DCHECK(str);
@@ -192,6 +203,13 @@ void GLES2Implementation::SwapBuffers() {
Flush();
}
+void GLES2Implementation::BindAttribLocation(
+ GLuint program, GLuint index, const char* name) {
+ SetBucketAsString(kResultBucketId, name);
+ helper_->BindAttribLocationBucket(program, index, kResultBucketId);
+ helper_->SetBucketSize(kResultBucketId, 0);
+}
+
void GLES2Implementation::GetVertexAttribPointerv(
GLuint index, GLenum pname, void** ptr) {
helper_->GetVertexAttribPointerv(
@@ -203,23 +221,27 @@ void GLES2Implementation::GetVertexAttribPointerv(
GLint GLES2Implementation::GetAttribLocation(
GLuint program, const char* name) {
- typedef cmd::GetBucketSize::Result Result;
+ typedef GetAttribLocationBucket::Result Result;
Result* result = GetResultAs<Result*>();
*result = -1;
- helper_->GetAttribLocationImmediate(
- program, name, result_shm_id(), result_shm_offset());
+ SetBucketAsCString(kResultBucketId, name);
+ helper_->GetAttribLocationBucket(program, kResultBucketId,
+ result_shm_id(), result_shm_offset());
WaitForCmd();
+ helper_->SetBucketSize(kResultBucketId, 0);
return *result;
}
GLint GLES2Implementation::GetUniformLocation(
GLuint program, const char* name) {
- typedef cmd::GetBucketSize::Result Result;
+ typedef GetUniformLocationBucket::Result Result;
Result* result = GetResultAs<Result*>();
*result = -1;
- helper_->GetUniformLocationImmediate(
- program, name, result_shm_id(), result_shm_offset());
+ SetBucketAsCString(kResultBucketId, name);
+ helper_->GetUniformLocationBucket(program, kResultBucketId,
+ result_shm_id(), result_shm_offset());
WaitForCmd();
+ helper_->SetBucketSize(kResultBucketId, 0);
return *result;
}
@@ -251,29 +273,38 @@ void GLES2Implementation::ShaderSource(
SetGLError(GL_INVALID_VALUE);
return;
}
- // TODO(gman): change to use buckets and check that there is enough room.
// Compute the total size.
- uint32 total_size = 0;
+ uint32 total_size = 1;
for (GLsizei ii = 0; ii < count; ++ii) {
total_size += length ? length[ii] : strlen(source[ii]);
}
- // Concatenate all the strings in to the transfer buffer.
- char* strings = transfer_buffer_.AllocTyped<char>(total_size);
+ // Concatenate all the strings in to a bucket on the service.
+ helper_->SetBucketSize(kResultBucketId, total_size);
+ uint32 max_size = transfer_buffer_.GetLargestFreeOrPendingSize();
uint32 offset = 0;
- for (GLsizei ii = 0; ii < count; ++ii) {
- uint32 len = length ? length[ii] : strlen(source[ii]);
- memcpy(strings + offset, source[ii], len);
- offset += len;
+ for (GLsizei ii = 0; ii <= count; ++ii) {
+ const char* src = ii < count ? source[ii] : "";
+ uint32 size = ii < count ? (length ? length[ii] : strlen(src)) : 1;
+ while(size) {
+ uint32 part_size = std::min(size, max_size);
+ void* buffer = transfer_buffer_.Alloc(part_size);
+ memcpy(buffer, src, part_size);
+ helper_->SetBucketData(kResultBucketId, offset, part_size,
+ transfer_buffer_id_,
+ transfer_buffer_.GetOffset(buffer));
+ transfer_buffer_.FreePendingToken(buffer, helper_->InsertToken());
+ offset += part_size;
+ src += part_size;
+ size -= part_size;
+ }
}
+
DCHECK_EQ(total_size, offset);
- helper_->ShaderSource(shader,
- transfer_buffer_id_,
- transfer_buffer_.GetOffset(strings),
- total_size);
- transfer_buffer_.FreePendingToken(strings, helper_->InsertToken());
+ helper_->ShaderSourceBucket(shader, kResultBucketId);
+ helper_->SetBucketSize(kResultBucketId, 0);
}
void GLES2Implementation::BufferData(
diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h
index bb69353..c1ee9c6 100644
--- a/gpu/command_buffer/client/gles2_implementation.h
+++ b/gpu/command_buffer/client/gles2_implementation.h
@@ -85,6 +85,9 @@ class GLES2Implementation {
// Sets the contents of a bucket.
void SetBucketContents(uint32 bucket_id, const void* data, size_t size);
+ // Sets the contents of a bucket as a string.
+ void SetBucketAsCString(uint32 bucket_id, const char* str);
+
// 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);
diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h
index 5132721..3c21aea 100644
--- a/gpu/command_buffer/client/gles2_implementation_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_autogen.h
@@ -17,10 +17,7 @@ void AttachShader(GLuint program, GLuint shader) {
helper_->AttachShader(program, shader);
}
-void BindAttribLocation(GLuint program, GLuint index, const char* name) {
- // TODO(gman): This needs to change to use SendString.
- helper_->BindAttribLocationImmediate(program, index, name);
-}
+void BindAttribLocation(GLuint program, GLuint index, const char* name);
void BindBuffer(GLenum target, GLuint buffer) {
helper_->BindBuffer(target, buffer);
diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h
index e67fe69..6935380 100644
--- a/gpu/command_buffer/common/gles2_cmd_format.h
+++ b/gpu/command_buffer/common/gles2_cmd_format.h
@@ -219,6 +219,62 @@ COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, location_shm_offset) == 12,
COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, data_size) == 16,
OffsetOf_GetAttribLocationImmediate_data_size_not_16);
+
+struct GetAttribLocationBucket {
+ typedef GetAttribLocationBucket ValueType;
+ static const CommandId kCmdId = kGetAttribLocationBucket;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+
+ typedef GLint Result;
+
+ static uint32 ComputeSize() {
+ return static_cast<uint32>(sizeof(ValueType)); // NOLINT
+ }
+
+ void SetHeader() {
+ header.SetCmd<ValueType>();
+ }
+
+ void Init(
+ GLuint _program, uint32 _name_bucket_id,
+ uint32 _location_shm_id, uint32 _location_shm_offset) {
+ SetHeader();
+ program = _program;
+ name_bucket_id = _name_bucket_id;
+ location_shm_id = _location_shm_id;
+ location_shm_offset = _location_shm_offset;
+ }
+
+ void* Set(
+ void* cmd, GLuint _program, uint32 _name_bucket_id,
+ uint32 _location_shm_id, uint32 _location_shm_offset) {
+ static_cast<ValueType*>(
+ cmd)->Init(
+ _program, _name_bucket_id, _location_shm_id,
+ _location_shm_offset);
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ CommandHeader header;
+ uint32 program;
+ uint32 name_bucket_id;
+ uint32 location_shm_id;
+ uint32 location_shm_offset;
+};
+
+COMPILE_ASSERT(sizeof(GetAttribLocationBucket) == 20,
+ Sizeof_GetAttribLocationBucket_is_not_24);
+COMPILE_ASSERT(offsetof(GetAttribLocationBucket, header) == 0,
+ OffsetOf_GetAttribLocationBucket_header_not_0);
+COMPILE_ASSERT(offsetof(GetAttribLocationBucket, program) == 4,
+ OffsetOf_GetAttribLocationBucket_program_not_4);
+COMPILE_ASSERT(offsetof(GetAttribLocationBucket, name_bucket_id) == 8,
+ OffsetOf_GetAttribLocationBucket_name_bucket_id_not_8);
+COMPILE_ASSERT(offsetof(GetAttribLocationBucket, location_shm_id) == 12,
+ OffsetOf_GetAttribLocationBucket_location_shm_id_not_12);
+COMPILE_ASSERT(offsetof(GetAttribLocationBucket, location_shm_offset) == 16,
+ OffsetOf_GetAttribLocationBucket_location_shm_offset_not_16);
+
struct GetUniformLocation {
typedef GetUniformLocation ValueType;
static const CommandId kCmdId = kGetUniformLocation;
@@ -344,6 +400,61 @@ COMPILE_ASSERT(
COMPILE_ASSERT(offsetof(GetUniformLocationImmediate, data_size) == 16,
OffsetOf_GetUniformLocationImmediate_data_size_not_16);
+struct GetUniformLocationBucket {
+ typedef GetUniformLocationBucket ValueType;
+ static const CommandId kCmdId = kGetUniformLocationBucket;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+
+ typedef GLint Result;
+
+ static uint32 ComputeSize() {
+ return static_cast<uint32>(sizeof(ValueType)); // NOLINT
+ }
+
+ void SetHeader() {
+ header.SetCmd<ValueType>();
+ }
+
+ void Init(
+ GLuint _program, uint32 _name_bucket_id,
+ uint32 _location_shm_id, uint32 _location_shm_offset) {
+ SetHeader();
+ program = _program;
+ name_bucket_id = _name_bucket_id;
+ location_shm_id = _location_shm_id;
+ location_shm_offset = _location_shm_offset;
+ }
+
+ void* Set(
+ void* cmd, GLuint _program, uint32 _name_bucket_id,
+ uint32 _location_shm_id, uint32 _location_shm_offset) {
+ static_cast<ValueType*>(
+ cmd)->Init(
+ _program, _name_bucket_id, _location_shm_id,
+ _location_shm_offset);
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ CommandHeader header;
+ uint32 program;
+ uint32 name_bucket_id;
+ uint32 location_shm_id;
+ uint32 location_shm_offset;
+};
+
+COMPILE_ASSERT(sizeof(GetUniformLocationBucket) == 20,
+ Sizeof_GetUniformLocationBucket_is_not_24);
+COMPILE_ASSERT(offsetof(GetUniformLocationBucket, header) == 0,
+ OffsetOf_GetUniformLocationBucket_header_not_0);
+COMPILE_ASSERT(offsetof(GetUniformLocationBucket, program) == 4,
+ OffsetOf_GetUniformLocationBucket_program_not_4);
+COMPILE_ASSERT(offsetof(GetUniformLocationBucket, name_bucket_id) == 8,
+ OffsetOf_GetUniformLocationBucket_name_bucket_id_not_8);
+COMPILE_ASSERT(offsetof(GetUniformLocationBucket, location_shm_id) == 12,
+ OffsetOf_GetUniformLocationBucket_location_shm_id_not_12);
+COMPILE_ASSERT(offsetof(GetUniformLocationBucket, location_shm_offset) == 16,
+ OffsetOf_GetUniformLocationBucket_location_shm_offset_not_16);
+
#pragma pack(pop)
} // namespace gles2
diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
index dfba44a..7213e1e 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
@@ -182,6 +182,49 @@ COMPILE_ASSERT(offsetof(BindAttribLocationImmediate, index) == 8,
COMPILE_ASSERT(offsetof(BindAttribLocationImmediate, data_size) == 12,
OffsetOf_BindAttribLocationImmediate_data_size_not_12);
+struct BindAttribLocationBucket {
+ typedef BindAttribLocationBucket ValueType;
+ static const CommandId kCmdId = kBindAttribLocationBucket;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+
+ static uint32 ComputeSize() {
+ return static_cast<uint32>(sizeof(ValueType)); // NOLINT
+ }
+
+ void SetHeader() {
+ header.SetCmd<ValueType>();
+ }
+
+ void Init(GLuint _program, GLuint _index, uint32 _name_bucket_id) {
+ SetHeader();
+ program = _program;
+ index = _index;
+ name_bucket_id = _name_bucket_id;
+ }
+
+ void* Set(
+ void* cmd, GLuint _program, GLuint _index, uint32 _name_bucket_id) {
+ static_cast<ValueType*>(cmd)->Init(_program, _index, _name_bucket_id);
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ gpu::CommandHeader header;
+ uint32 program;
+ uint32 index;
+ uint32 name_bucket_id;
+};
+
+COMPILE_ASSERT(sizeof(BindAttribLocationBucket) == 16,
+ Sizeof_BindAttribLocationBucket_is_not_16);
+COMPILE_ASSERT(offsetof(BindAttribLocationBucket, header) == 0,
+ OffsetOf_BindAttribLocationBucket_header_not_0);
+COMPILE_ASSERT(offsetof(BindAttribLocationBucket, program) == 4,
+ OffsetOf_BindAttribLocationBucket_program_not_4);
+COMPILE_ASSERT(offsetof(BindAttribLocationBucket, index) == 8,
+ OffsetOf_BindAttribLocationBucket_index_not_8);
+COMPILE_ASSERT(offsetof(BindAttribLocationBucket, name_bucket_id) == 12,
+ OffsetOf_BindAttribLocationBucket_name_bucket_id_not_12);
+
struct BindBuffer {
typedef BindBuffer ValueType;
static const CommandId kCmdId = kBindBuffer;
@@ -5000,6 +5043,44 @@ COMPILE_ASSERT(offsetof(ShaderSourceImmediate, shader) == 4,
COMPILE_ASSERT(offsetof(ShaderSourceImmediate, data_size) == 8,
OffsetOf_ShaderSourceImmediate_data_size_not_8);
+struct ShaderSourceBucket {
+ typedef ShaderSourceBucket ValueType;
+ static const CommandId kCmdId = kShaderSourceBucket;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+
+ static uint32 ComputeSize() {
+ return static_cast<uint32>(sizeof(ValueType)); // NOLINT
+ }
+
+ void SetHeader() {
+ header.SetCmd<ValueType>();
+ }
+
+ void Init(GLuint _shader, uint32 _data_bucket_id) {
+ SetHeader();
+ shader = _shader;
+ data_bucket_id = _data_bucket_id;
+ }
+
+ void* Set(void* cmd, GLuint _shader, uint32 _data_bucket_id) {
+ static_cast<ValueType*>(cmd)->Init(_shader, _data_bucket_id);
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ gpu::CommandHeader header;
+ uint32 shader;
+ uint32 data_bucket_id;
+};
+
+COMPILE_ASSERT(sizeof(ShaderSourceBucket) == 12,
+ Sizeof_ShaderSourceBucket_is_not_12);
+COMPILE_ASSERT(offsetof(ShaderSourceBucket, header) == 0,
+ OffsetOf_ShaderSourceBucket_header_not_0);
+COMPILE_ASSERT(offsetof(ShaderSourceBucket, shader) == 4,
+ OffsetOf_ShaderSourceBucket_shader_not_4);
+COMPILE_ASSERT(offsetof(ShaderSourceBucket, data_bucket_id) == 8,
+ OffsetOf_ShaderSourceBucket_data_bucket_id_not_8);
+
struct StencilFunc {
typedef StencilFunc ValueType;
static const CommandId kCmdId = kStencilFunc;
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 7cb1761..bb13f1d4 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
@@ -84,6 +84,24 @@ TEST(GLES2FormatTest, BindAttribLocationImmediate) {
EXPECT_EQ(static_cast<uint32>(strlen(test_str)), cmd.data_size);
EXPECT_EQ(0, memcmp(test_str, ImmediateDataAddress(&cmd), strlen(test_str)));
}
+
+TEST(GLES2FormatTest, BindAttribLocationBucket) {
+ BindAttribLocationBucket cmd = { { 0 } };
+ void* next_cmd = cmd.Set(
+ &cmd,
+ static_cast<GLuint>(11),
+ static_cast<GLuint>(12),
+ static_cast<uint32>(13));
+ EXPECT_EQ(static_cast<uint32>(BindAttribLocationBucket::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<GLuint>(12), cmd.index);
+ EXPECT_EQ(static_cast<uint32>(13), cmd.name_bucket_id);
+}
+
TEST(GLES2FormatTest, BindBuffer) {
BindBuffer cmd = { { 0 } };
void* next_cmd = cmd.Set(
@@ -1158,6 +1176,7 @@ TEST(GLES2FormatTest, GetAttachedShaders) {
// TODO(gman): Write test for GetAttribLocation
// TODO(gman): Write test for GetAttribLocationImmediate
+// TODO(gman): Write test for GetAttribLocationBucket
TEST(GLES2FormatTest, GetBooleanv) {
GetBooleanv cmd = { { 0 } };
void* next_cmd = cmd.Set(
@@ -1478,6 +1497,7 @@ TEST(GLES2FormatTest, GetUniformiv) {
// TODO(gman): Write test for GetUniformLocation
// TODO(gman): Write test for GetUniformLocationImmediate
+// TODO(gman): Write test for GetUniformLocationBucket
TEST(GLES2FormatTest, GetVertexAttribfv) {
GetVertexAttribfv cmd = { { 0 } };
void* next_cmd = cmd.Set(
@@ -1829,6 +1849,21 @@ TEST(GLES2FormatTest, ShaderSource) {
}
// TODO(gman): Implement test for ShaderSourceImmediate
+TEST(GLES2FormatTest, ShaderSourceBucket) {
+ ShaderSourceBucket cmd = { { 0 } };
+ void* next_cmd = cmd.Set(
+ &cmd,
+ static_cast<GLuint>(11),
+ static_cast<uint32>(12));
+ EXPECT_EQ(static_cast<uint32>(ShaderSourceBucket::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.data_bucket_id);
+}
+
TEST(GLES2FormatTest, StencilFunc) {
StencilFunc cmd = { { 0 } };
void* next_cmd = cmd.Set(
diff --git a/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h
index da6e161..4051f25 100644
--- a/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h
@@ -19,6 +19,8 @@ TEST(GLES2CommandIdTest, CommandIdsMatch) {
GLES2_BindAttribLocation_kCmdId_mismatch);
COMPILE_ASSERT(BindAttribLocationImmediate::kCmdId == 259,
GLES2_BindAttribLocationImmediate_kCmdId_mismatch);
+ COMPILE_ASSERT(BindAttribLocationBucket::kCmdId == 432,
+ GLES2_BindAttribLocationBucket_kCmdId_mismatch);
COMPILE_ASSERT(BindBuffer::kCmdId == 260,
GLES2_BindBuffer_kCmdId_mismatch);
COMPILE_ASSERT(BindFramebuffer::kCmdId == 261,
@@ -155,6 +157,8 @@ TEST(GLES2CommandIdTest, CommandIdsMatch) {
GLES2_GetAttribLocation_kCmdId_mismatch);
COMPILE_ASSERT(GetAttribLocationImmediate::kCmdId == 327,
GLES2_GetAttribLocationImmediate_kCmdId_mismatch);
+ COMPILE_ASSERT(GetAttribLocationBucket::kCmdId == 434,
+ GLES2_GetAttribLocationBucket_kCmdId_mismatch);
COMPILE_ASSERT(GetBooleanv::kCmdId == 328,
GLES2_GetBooleanv_kCmdId_mismatch);
COMPILE_ASSERT(GetBufferParameteriv::kCmdId == 329,
@@ -195,6 +199,8 @@ TEST(GLES2CommandIdTest, CommandIdsMatch) {
GLES2_GetUniformLocation_kCmdId_mismatch);
COMPILE_ASSERT(GetUniformLocationImmediate::kCmdId == 347,
GLES2_GetUniformLocationImmediate_kCmdId_mismatch);
+ COMPILE_ASSERT(GetUniformLocationBucket::kCmdId == 433,
+ GLES2_GetUniformLocationBucket_kCmdId_mismatch);
COMPILE_ASSERT(GetVertexAttribfv::kCmdId == 348,
GLES2_GetVertexAttribfv_kCmdId_mismatch);
COMPILE_ASSERT(GetVertexAttribiv::kCmdId == 349,
@@ -237,6 +243,8 @@ TEST(GLES2CommandIdTest, CommandIdsMatch) {
GLES2_ShaderSource_kCmdId_mismatch);
COMPILE_ASSERT(ShaderSourceImmediate::kCmdId == 368,
GLES2_ShaderSourceImmediate_kCmdId_mismatch);
+ COMPILE_ASSERT(ShaderSourceBucket::kCmdId == 435,
+ GLES2_ShaderSourceBucket_kCmdId_mismatch);
COMPILE_ASSERT(StencilFunc::kCmdId == 369,
GLES2_StencilFunc_kCmdId_mismatch);
COMPILE_ASSERT(StencilFuncSeparate::kCmdId == 370,
diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
index 8deb9d8..714069d 100644
--- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
@@ -184,6 +184,10 @@
OP(VertexAttribPointer) /* 429 */ \
OP(Viewport) /* 430 */ \
OP(SwapBuffers) /* 431 */ \
+ OP(BindAttribLocationBucket) /* 432 */ \
+ OP(GetUniformLocationBucket) /* 433 */ \
+ OP(GetAttribLocationBucket) /* 434 */ \
+ OP(ShaderSourceBucket) /* 435 */ \
enum CommandId {
kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this.
diff --git a/gpu/command_buffer/service/buffer_manager_unittest.cc b/gpu/command_buffer/service/buffer_manager_unittest.cc
index df58915..0f4dc52 100644
--- a/gpu/command_buffer/service/buffer_manager_unittest.cc
+++ b/gpu/command_buffer/service/buffer_manager_unittest.cc
@@ -37,7 +37,7 @@ TEST_F(BufferManagerTest, Basic) {
EXPECT_FALSE(info1->IsDeleted());
EXPECT_EQ(kBuffer1Id, info1->buffer_id());
info1->set_target(GL_ELEMENT_ARRAY_BUFFER);
- EXPECT_EQ(GL_ELEMENT_ARRAY_BUFFER, info1->target());
+ EXPECT_EQ(static_cast<GLenum>(GL_ELEMENT_ARRAY_BUFFER), info1->target());
// Check we and set its size.
info1->SetSize(kBuffer1Size);
EXPECT_EQ(kBuffer1Size, info1->size());
@@ -53,7 +53,6 @@ TEST_F(BufferManagerTest, Basic) {
TEST_F(BufferManagerTest, SetRange) {
const GLuint kBufferId = 1;
const uint8 data[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
- const uint8 new_data[] = {100, 120, 110};
manager_.CreateBufferInfo(kBufferId);
BufferManager::BufferInfo* info = manager_.GetBufferInfo(kBufferId);
ASSERT_TRUE(info != NULL);
diff --git a/gpu/command_buffer/service/common_decoder.cc b/gpu/command_buffer/service/common_decoder.cc
index 06d368d..feb59eb 100644
--- a/gpu/command_buffer/service/common_decoder.cc
+++ b/gpu/command_buffer/service/common_decoder.cc
@@ -39,6 +39,15 @@ void CommonDecoder::Bucket::SetFromString(const std::string& str) {
SetData(str.c_str(), 0, str.size() + 1);
}
+bool CommonDecoder::Bucket::GetAsString(std::string* str) {
+ DCHECK(str);
+ if (size_ == 0) {
+ return false;
+ }
+ str->assign(GetDataAs<const char*>(0, size_ - 1), size_ - 1);
+ return true;
+}
+
void* CommonDecoder::GetAddressAndCheckSize(unsigned int shm_id,
unsigned int offset,
unsigned int size) {
diff --git a/gpu/command_buffer/service/common_decoder.h b/gpu/command_buffer/service/common_decoder.h
index 9ea0d6f..adfdaac 100644
--- a/gpu/command_buffer/service/common_decoder.h
+++ b/gpu/command_buffer/service/common_decoder.h
@@ -75,6 +75,11 @@ class CommonDecoder : public AsyncAPIInterface {
// distinguish between empty string and no string.
void SetFromString(const std::string& str);
+ // Gets the bucket data as a string. Strings are passed NULL terminated to
+ // distrinquish between empty string and no string. Returns False if there
+ // is no string.
+ bool GetAsString(std::string* str);
+
private:
bool OffsetSizeValid(size_t offset, size_t size) const {
size_t temp = offset + size;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 4b448918..4c99bff 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -416,6 +416,14 @@ class GLES2DecoderImpl : public GLES2Decoder {
// with deleted buffers.
void RemoveBufferInfo(GLuint buffer_id);
+ error::Error GetAttribLocationHelper(
+ GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
+ const std::string& name_str);
+
+ error::Error GetUniformLocationHelper(
+ GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
+ const std::string& name_str);
+
// Helper for glShaderSource.
error::Error ShaderSourceHelper(
GLuint shader, const char* data, uint32 data_size);
@@ -1439,6 +1447,62 @@ void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) {
glGenerateMipmapEXT(target);
}
+error::Error GLES2DecoderImpl::HandleBindAttribLocation(
+ uint32 immediate_data_size, const gles2::BindAttribLocation& c) {
+ GLuint program;
+ if (!id_manager()->GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return error::kNoError;
+ }
+ GLuint index = static_cast<GLuint>(c.index);
+ uint32 name_size = c.data_size;
+ const char* name = GetSharedMemoryAs<const char*>(
+ c.name_shm_id, c.name_shm_offset, name_size);
+ if (name == NULL) {
+ return error::kOutOfBounds;
+ }
+ String name_str(name, name_size);
+ glBindAttribLocation(program, index, name_str.c_str());
+ return error::kNoError;
+}
+
+error::Error GLES2DecoderImpl::HandleBindAttribLocationImmediate(
+ uint32 immediate_data_size, const gles2::BindAttribLocationImmediate& c) {
+ GLuint program;
+ if (!id_manager()->GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return error::kNoError;
+ }
+ GLuint index = static_cast<GLuint>(c.index);
+ uint32 name_size = c.data_size;
+ const char* name = GetImmediateDataAs<const char*>(
+ c, name_size, immediate_data_size);
+ if (name == NULL) {
+ return error::kOutOfBounds;
+ }
+ String name_str(name, name_size);
+ glBindAttribLocation(program, index, name_str.c_str());
+ return error::kNoError;
+}
+
+error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket(
+ uint32 immediate_data_size, const gles2::BindAttribLocationBucket& c) {
+ GLuint program;
+ if (!id_manager()->GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return error::kNoError;
+ }
+ GLuint index = static_cast<GLuint>(c.index);
+ Bucket* bucket = GetBucket(c.name_bucket_id);
+ if (!bucket || bucket->size() == 0) {
+ return error::kInvalidArguments;
+ }
+ std::string name_str;
+ bucket->GetAsString(&name_str);
+ glBindAttribLocation(program, index, name_str.c_str());
+ return error::kNoError;
+}
+
error::Error GLES2DecoderImpl::HandleDeleteShader(
uint32 immediate_data_size, const gles2::DeleteShader& c) {
GLuint shader = c.shader;
@@ -1877,6 +1941,22 @@ error::Error GLES2DecoderImpl::HandleShaderSourceImmediate(
return ShaderSourceHelper(shader, data, data_size);
}
+error::Error GLES2DecoderImpl::HandleShaderSourceBucket(
+ uint32 immediate_data_size, const gles2::ShaderSourceBucket& c) {
+ GLuint shader;
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
+ SetGLError(GL_INVALID_VALUE);
+ return error::kNoError;
+ }
+ Bucket* bucket = GetBucket(c.data_bucket_id);
+ if (!bucket || bucket->size() == 0) {
+ return error::kInvalidArguments;
+ }
+ return ShaderSourceHelper(
+ shader, bucket->GetDataAs<const char*>(0, bucket->size() - 1),
+ bucket->size() - 1);
+}
+
void GLES2DecoderImpl::DoCompileShader(GLuint shader) {
ShaderManager::ShaderInfo* info = GetShaderInfo(shader);
if (!info) {
@@ -2168,10 +2248,11 @@ error::Error GLES2DecoderImpl::HandlePixelStorei(
return error::kNoError;
}
-error::Error GLES2DecoderImpl::HandleGetAttribLocation(
- uint32 immediate_data_size, const gles2::GetAttribLocation& c) {
+error::Error GLES2DecoderImpl::GetAttribLocationHelper(
+ GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
+ const std::string& name_str) {
GLuint program;
- if (!id_manager()->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(client_id, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2181,49 +2262,63 @@ error::Error GLES2DecoderImpl::HandleGetAttribLocation(
SetGLError(GL_INVALID_OPERATION);
return error::kNoError;
}
+ GLint* location = GetSharedMemoryAs<GLint*>(
+ location_shm_id, location_shm_offset, sizeof(GLint));
+ if (!location) {
+ return error::kOutOfBounds;
+ }
+ // Require the client to init this incase the context is lost and we are no
+ // longer executing commands.
+ if (*location != -1) {
+ return error::kGenericError;
+ }
+ *location = info->GetAttribLocation(name_str);
+ return error::kNoError;
+}
+
+error::Error GLES2DecoderImpl::HandleGetAttribLocation(
+ uint32 immediate_data_size, const gles2::GetAttribLocation& c) {
uint32 name_size = c.data_size;
const char* name = GetSharedMemoryAs<const char*>(
c.name_shm_id, c.name_shm_offset, name_size);
- GLint* location = GetSharedMemoryAs<GLint*>(
- c.location_shm_id, c.location_shm_offset, sizeof(GLint));
- if (!location || !name) {
+ if (!name) {
return error::kOutOfBounds;
}
String name_str(name, name_size);
- *location = info->GetAttribLocation(name_str);
- return error::kNoError;
+ return GetAttribLocationHelper(
+ c.program, c.location_shm_id, c.location_shm_offset, name_str);
}
error::Error GLES2DecoderImpl::HandleGetAttribLocationImmediate(
uint32 immediate_data_size, const gles2::GetAttribLocationImmediate& c) {
- GLuint program;
- if (!id_manager()->GetServiceId(c.program, &program)) {
- SetGLError(GL_INVALID_VALUE);
- return error::kNoError;
- }
- ProgramManager::ProgramInfo* info = GetProgramInfo(program);
- if (!info) {
- // Program was not linked successfully. (ie, glLinkProgram)
- SetGLError(GL_INVALID_OPERATION);
- return error::kNoError;
- }
uint32 name_size = c.data_size;
const char* name = GetImmediateDataAs<const char*>(
c, name_size, immediate_data_size);
- GLint* location = GetSharedMemoryAs<GLint*>(
- c.location_shm_id, c.location_shm_offset, sizeof(GLint));
- if (!location || !name) {
+ if (!name) {
return error::kOutOfBounds;
}
String name_str(name, name_size);
- *location = info->GetAttribLocation(name_str);
- return error::kNoError;
+ return GetAttribLocationHelper(
+ c.program, c.location_shm_id, c.location_shm_offset, name_str);
}
-error::Error GLES2DecoderImpl::HandleGetUniformLocation(
- uint32 immediate_data_size, const gles2::GetUniformLocation& c) {
+error::Error GLES2DecoderImpl::HandleGetAttribLocationBucket(
+ uint32 immediate_data_size, const gles2::GetAttribLocationBucket& c) {
+ Bucket* bucket = GetBucket(c.name_bucket_id);
+ if (!bucket) {
+ return error::kInvalidArguments;
+ }
+ std::string name_str;
+ bucket->GetAsString(&name_str);
+ return GetAttribLocationHelper(
+ c.program, c.location_shm_id, c.location_shm_offset, name_str);
+}
+
+error::Error GLES2DecoderImpl::GetUniformLocationHelper(
+ GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
+ const std::string& name_str) {
GLuint program;
- if (!id_manager()->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(client_id, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2233,43 +2328,56 @@ error::Error GLES2DecoderImpl::HandleGetUniformLocation(
SetGLError(GL_INVALID_OPERATION);
return error::kNoError;
}
+ GLint* location = GetSharedMemoryAs<GLint*>(
+ location_shm_id, location_shm_offset, sizeof(GLint));
+ if (!location) {
+ return error::kOutOfBounds;
+ }
+ // Require the client to init this incase the context is lost an we are no
+ // longer executing commands.
+ if (*location != -1) {
+ return error::kGenericError;
+ }
+ *location = info->GetUniformLocation(name_str);
+ return error::kNoError;
+}
+
+error::Error GLES2DecoderImpl::HandleGetUniformLocation(
+ uint32 immediate_data_size, const gles2::GetUniformLocation& c) {
uint32 name_size = c.data_size;
const char* name = GetSharedMemoryAs<const char*>(
c.name_shm_id, c.name_shm_offset, name_size);
- GLint* location = GetSharedMemoryAs<GLint*>(
- c.location_shm_id, c.location_shm_offset, sizeof(GLint));
- if (!location || !name) {
+ if (!name) {
return error::kOutOfBounds;
}
String name_str(name, name_size);
- *location = info->GetUniformLocation(name_str);
- return error::kNoError;
+ return GetUniformLocationHelper(
+ c.program, c.location_shm_id, c.location_shm_offset, name_str);
}
error::Error GLES2DecoderImpl::HandleGetUniformLocationImmediate(
uint32 immediate_data_size, const gles2::GetUniformLocationImmediate& c) {
- GLuint program;
- if (!id_manager()->GetServiceId(c.program, &program)) {
- SetGLError(GL_INVALID_VALUE);
- return error::kNoError;
- }
- ProgramManager::ProgramInfo* info = GetProgramInfo(program);
- if (!info) {
- // Program was not linked successfully. (ie, glLinkProgram)
- SetGLError(GL_INVALID_OPERATION);
- return error::kNoError;
- }
uint32 name_size = c.data_size;
const char* name = GetImmediateDataAs<const char*>(
c, name_size, immediate_data_size);
- GLint* location = GetSharedMemoryAs<GLint*>(
- c.location_shm_id, c.location_shm_offset, sizeof(GLint));
- if (!location || !name) {
+ if (!name) {
return error::kOutOfBounds;
}
String name_str(name, name_size);
- *location = info->GetUniformLocation(name_str);
- return error::kNoError;
+ return GetUniformLocationHelper(
+ c.program, c.location_shm_id, c.location_shm_offset, name_str);
+}
+
+error::Error GLES2DecoderImpl::HandleGetUniformLocationBucket(
+ uint32 immediate_data_size, const gles2::GetUniformLocationBucket& c) {
+ Bucket* bucket = GetBucket(c.name_bucket_id);
+ if (!bucket) {
+ return error::kInvalidArguments;
+ }
+ std::string name_str;
+ bucket->GetAsString(&name_str);
+ return GetUniformLocationHelper(
+ c.program, c.location_shm_id, c.location_shm_offset, name_str);
}
error::Error GLES2DecoderImpl::HandleGetString(
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
index c6c7071..cb534a4 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -31,44 +31,6 @@ error::Error GLES2DecoderImpl::HandleAttachShader(
return error::kNoError;
}
-error::Error GLES2DecoderImpl::HandleBindAttribLocation(
- uint32 immediate_data_size, const gles2::BindAttribLocation& c) {
- GLuint program;
- if (!id_manager()->GetServiceId(c.program, &program)) {
- SetGLError(GL_INVALID_VALUE);
- return error::kNoError;
- }
- GLuint index = static_cast<GLuint>(c.index);
- uint32 name_size = c.data_size;
- const char* name = GetSharedMemoryAs<const char*>(
- c.name_shm_id, c.name_shm_offset, name_size);
- if (name == NULL) {
- return error::kOutOfBounds;
- }
- String name_str(name, name_size);
- glBindAttribLocation(program, index, name_str.c_str());
- return error::kNoError;
-}
-
-error::Error GLES2DecoderImpl::HandleBindAttribLocationImmediate(
- uint32 immediate_data_size, const gles2::BindAttribLocationImmediate& c) {
- GLuint program;
- if (!id_manager()->GetServiceId(c.program, &program)) {
- SetGLError(GL_INVALID_VALUE);
- return error::kNoError;
- }
- GLuint index = static_cast<GLuint>(c.index);
- uint32 name_size = c.data_size;
- const char* name = GetImmediateDataAs<const char*>(
- c, name_size, immediate_data_size);
- if (name == NULL) {
- return error::kOutOfBounds;
- }
- String name_str(name, name_size);
- glBindAttribLocation(program, index, name_str.c_str());
- return error::kNoError;
-}
-
error::Error GLES2DecoderImpl::HandleBindBuffer(
uint32 immediate_data_size, const gles2::BindBuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index dc68d4e..b916f8e 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -947,6 +947,42 @@ TEST_F(GLES2DecoderTest, ShaderSourceImmediateInvalidArgs) {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
+TEST_F(GLES2DecoderTest, ShaderSourceBucketAndGetShaderSourceValidArgs) {
+ const uint32 kInBucketId = 123;
+ const uint32 kOutBucketId = 125;
+ const char kSource[] = "hello";
+ const uint32 kSourceSize = sizeof(kSource) - 1;
+ SetBucketAsCString(kInBucketId, kSource);
+ ShaderSourceBucket cmd;
+ cmd.Init(client_shader_id_, kInBucketId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ ClearSharedMemory();
+ GetShaderSource get_cmd;
+ get_cmd.Init(client_shader_id_, kOutBucketId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd));
+ CommonDecoder::Bucket* bucket = decoder_->GetBucket(kOutBucketId);
+ 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, ShaderSourceBucketInvalidArgs) {
+ const uint32 kBucketId = 123;
+ const char kSource[] = "hello";
+ const uint32 kSourceSize = sizeof(kSource) - 1;
+ memcpy(shared_memory_address_, kSource, kSourceSize);
+ ShaderSourceBucket cmd;
+ // Test no bucket.
+ cmd.Init(client_texture_id_, kBucketId);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ // Test invalid client.
+ SetBucketAsCString(kBucketId, kSource);
+ cmd.Init(kInvalidClientId, kBucketId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+}
+
TEST_F(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) {
EXPECT_CALL(*gl_, GenerateMipmapEXT(_))
.Times(0);
@@ -1051,7 +1087,7 @@ TEST_F(GLES2DecoderTest, CheckFramebufferStatusWithNoBoundTarget) {
CheckFramebufferStatus cmd;
cmd.Init(GL_FRAMEBUFFER, shared_memory_id_, shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(*result, GL_FRAMEBUFFER_COMPLETE);
+ EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), *result);
}
TEST_F(GLES2DecoderTest, FramebufferRenderbufferWithNoBoundTarget) {
@@ -1179,10 +1215,10 @@ class ReadPixelsEmulator {
return pixels_ + (width_ * y + x) * bytes_per_pixel_;
}
- GLint pack_alignment_;
- GLint bytes_per_pixel_;
GLsizei width_;
GLsizei height_;
+ GLint pack_alignment_;
+ GLint bytes_per_pixel_;
const int8* pixels_;
};
@@ -1422,9 +1458,432 @@ TEST_F(GLES2DecoderTest, ReadPixelsInvalidArgs) {
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
}
-// TODO(gman): BindAttribLocation
+TEST_F(GLES2DecoderTest, BindAttribLocation) {
+ const GLint kLocation = 2;
+ const char* kName = "testing";
+ const uint32 kNameSize = strlen(kName);
+ EXPECT_CALL(
+ *gl_, BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName)))
+ .Times(1);
+ memcpy(shared_memory_address_, kName, kNameSize);
+ BindAttribLocation cmd;
+ cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest, BindAttribLocationInvalidArgs) {
+ const GLint kLocation = 2;
+ const char* kName = "testing";
+ const uint32 kNameSize = strlen(kName);
+ EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0);
+ BindAttribLocation cmd;
+ cmd.Init(kInvalidClientId, kLocation,
+ kSharedMemoryId, kSharedMemoryOffset, kNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ cmd.Init(client_program_id_, kLocation,
+ kInvalidSharedMemoryId, kSharedMemoryOffset, kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ cmd.Init(client_program_id_, kLocation,
+ kSharedMemoryId, kInvalidSharedMemoryOffset, kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ cmd.Init(client_program_id_, kLocation,
+ kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest, BindAttribLocationImmediate) {
+ const GLint kLocation = 2;
+ const char* kName = "testing";
+ const uint32 kNameSize = strlen(kName);
+ EXPECT_CALL(
+ *gl_, BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName)))
+ .Times(1);
+ BindAttribLocationImmediate& cmd =
+ *GetImmediateAs<BindAttribLocationImmediate>();
+ cmd.Init(client_program_id_, kLocation, kName, kNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+}
+
+TEST_F(GLES2DecoderTest, BindAttribLocationImmediateInvalidArgs) {
+ const GLint kLocation = 2;
+ const char* kName = "testing";
+ const uint32 kNameSize = strlen(kName);
+ EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0);
+ BindAttribLocationImmediate& cmd =
+ *GetImmediateAs<BindAttribLocationImmediate>();
+ cmd.Init(kInvalidClientId, kLocation, kName, kNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+}
+
+TEST_F(GLES2DecoderTest, BindAttribLocationBucket) {
+ const uint32 kBucketId = 123;
+ const GLint kLocation = 2;
+ const char* kName = "testing";
+ EXPECT_CALL(
+ *gl_, BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName)))
+ .Times(1);
+ SetBucketAsCString(kBucketId, kName);
+ BindAttribLocationBucket cmd;
+ cmd.Init(client_program_id_, kLocation, kBucketId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest, BindAttribLocationBucketInvalidArgs) {
+ const uint32 kBucketId = 123;
+ const GLint kLocation = 2;
+ const char* kName = "testing";
+ EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0);
+ BindAttribLocationBucket cmd;
+ // check bucket does not exist.
+ cmd.Init(client_program_id_, kLocation, kBucketId);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ // check bucket is empty.
+ SetBucketAsCString(kBucketId, NULL);
+ cmd.Init(client_program_id_, kLocation, kBucketId);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ // Check bad program id
+ SetBucketAsCString(kBucketId, kName);
+ cmd.Init(kInvalidClientId, kLocation, kBucketId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetAttribLocation) {
+ const uint32 kNameSize = strlen(kAttrib2Name);
+ const char* kNonExistentName = "foobar";
+ const uint32 kNonExistentNameSize = strlen(kNonExistentName);
+ typedef GetAttribLocation::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result));
+ const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result);
+ memcpy(name, kAttrib2Name, kNameSize);
+ GetAttribLocation cmd;
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(kAttrib2Location, *result);
+ *result = -1;
+ memcpy(name, kNonExistentName, kNonExistentNameSize);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNonExistentNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationInvalidArgs) {
+ const uint32 kNameSize = strlen(kAttrib2Name);
+ typedef GetAttribLocation::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result));
+ const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result);
+ memcpy(name, kAttrib2Name, kNameSize);
+ GetAttribLocation cmd;
+ cmd.Init(kInvalidClientId,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ *result = -1;
+ cmd.Init(client_program_id_,
+ kInvalidSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kInvalidSharedMemoryOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kInvalidSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kInvalidSharedMemoryOffset,
+ kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kSharedBufferSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationImmediate) {
+ const uint32 kNameSize = strlen(kAttrib2Name);
+ const char* kNonExistentName = "foobar";
+ const uint32 kNonExistentNameSize = strlen(kNonExistentName);
+ typedef GetAttribLocationImmediate::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ GetAttribLocationImmediate& cmd =
+ *GetImmediateAs<GetAttribLocationImmediate>();
+ cmd.Init(client_program_id_, kAttrib2Name,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+ EXPECT_EQ(kAttrib2Location, *result);
+ *result = -1;
+ cmd.Init(client_program_id_, kNonExistentName,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kNonExistentNameSize));
+ EXPECT_EQ(-1, *result);
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationImmediateInvalidArgs) {
+ const uint32 kNameSize = strlen(kAttrib2Name);
+ typedef GetAttribLocationImmediate::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ GetAttribLocationImmediate& cmd =
+ *GetImmediateAs<GetAttribLocationImmediate>();
+ cmd.Init(kInvalidClientId, kAttrib2Name,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+ EXPECT_EQ(-1, *result);
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ *result = -1;
+ cmd.Init(client_program_id_, kAttrib2Name,
+ kInvalidSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_, kAttrib2Name,
+ kSharedMemoryId, kInvalidSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+ EXPECT_EQ(-1, *result);
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationBucket) {
+ const uint32 kBucketId = 123;
+ const char* kNonExistentName = "foobar";
+ typedef GetAttribLocationBucket::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ SetBucketAsCString(kBucketId, kAttrib2Name);
+ *result = -1;
+ GetAttribLocationBucket cmd;
+ cmd.Init(client_program_id_, kBucketId,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(kAttrib2Location, *result);
+ SetBucketAsCString(kBucketId, kNonExistentName);
+ *result = -1;
+ cmd.Init(client_program_id_, kBucketId,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationBucketInvalidArgs) {
+ const uint32 kBucketId = 123;
+ typedef GetAttribLocationBucket::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ GetAttribLocationBucket cmd;
+ // Check no bucket
+ cmd.Init(client_program_id_, kBucketId,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ // Check bad program id.
+ SetBucketAsCString(kBucketId, kAttrib2Name);
+ cmd.Init(kInvalidClientId, kBucketId,
+ kSharedMemoryId, kSharedMemoryOffset);
+ *result = -1;
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ // Check bad memory
+ cmd.Init(client_program_id_, kBucketId,
+ kInvalidSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ cmd.Init(client_program_id_, kBucketId,
+ kSharedMemoryId, kInvalidSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetUniformLocation) {
+ const uint32 kNameSize = strlen(kUniform2Name);
+ const char* kNonExistentName = "foobar";
+ const uint32 kNonExistentNameSize = strlen(kNonExistentName);
+ typedef GetUniformLocation::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result));
+ const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result);
+ memcpy(name, kUniform2Name, kNameSize);
+ GetUniformLocation cmd;
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(kUniform2Location, *result);
+ memcpy(name, kNonExistentName, kNonExistentNameSize);
+ *result = -1;
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNonExistentNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationInvalidArgs) {
+ const uint32 kNameSize = strlen(kUniform2Name);
+ typedef GetUniformLocation::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result));
+ const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result);
+ memcpy(name, kUniform2Name, kNameSize);
+ GetUniformLocation cmd;
+ cmd.Init(kInvalidClientId,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ *result = -1;
+ cmd.Init(client_program_id_,
+ kInvalidSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kInvalidSharedMemoryOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kInvalidSharedMemoryId, kSharedMemoryOffset,
+ kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kInvalidSharedMemoryOffset,
+ kNameSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_,
+ kSharedMemoryId, kNameOffset,
+ kSharedMemoryId, kSharedMemoryOffset,
+ kSharedBufferSize);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationImmediate) {
+ const uint32 kNameSize = strlen(kUniform2Name);
+ const char* kNonExistentName = "foobar";
+ const uint32 kNonExistentNameSize = strlen(kNonExistentName);
+ typedef GetUniformLocationImmediate::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ GetUniformLocationImmediate& cmd =
+ *GetImmediateAs<GetUniformLocationImmediate>();
+ cmd.Init(client_program_id_, kUniform2Name,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+ EXPECT_EQ(kUniform2Location, *result);
+ *result = -1;
+ cmd.Init(client_program_id_, kNonExistentName,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kNonExistentNameSize));
+ EXPECT_EQ(-1, *result);
+}
-// TODO(gman): BindAttribLocationImmediate
+TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationImmediateInvalidArgs) {
+ const uint32 kNameSize = strlen(kUniform2Name);
+ typedef GetUniformLocationImmediate::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ GetUniformLocationImmediate& cmd =
+ *GetImmediateAs<GetUniformLocationImmediate>();
+ cmd.Init(kInvalidClientId, kUniform2Name,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+ EXPECT_EQ(-1, *result);
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ *result = -1;
+ cmd.Init(client_program_id_, kUniform2Name,
+ kInvalidSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+ EXPECT_EQ(-1, *result);
+ cmd.Init(client_program_id_, kUniform2Name,
+ kSharedMemoryId, kInvalidSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize));
+ EXPECT_EQ(-1, *result);
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationBucket) {
+ const uint32 kBucketId = 123;
+ const char* kNonExistentName = "foobar";
+ typedef GetUniformLocationBucket::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ SetBucketAsCString(kBucketId, kUniform2Name);
+ *result = -1;
+ GetUniformLocationBucket cmd;
+ cmd.Init(client_program_id_, kBucketId,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(kUniform2Location, *result);
+ SetBucketAsCString(kBucketId, kNonExistentName);
+ *result = -1;
+ cmd.Init(client_program_id_, kBucketId,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationBucketInvalidArgs) {
+ const uint32 kBucketId = 123;
+ typedef GetUniformLocationBucket::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+ *result = -1;
+ GetUniformLocationBucket cmd;
+ // Check no bucket
+ cmd.Init(client_program_id_, kBucketId,
+ kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ // Check bad program id.
+ SetBucketAsCString(kBucketId, kUniform2Name);
+ cmd.Init(kInvalidClientId, kBucketId,
+ kSharedMemoryId, kSharedMemoryOffset);
+ *result = -1;
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(-1, *result);
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ // Check bad memory
+ cmd.Init(client_program_id_, kBucketId,
+ kInvalidSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ cmd.Init(client_program_id_, kBucketId,
+ kSharedMemoryId, kInvalidSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+}
// TODO(gman): BufferData
@@ -1446,14 +1905,6 @@ TEST_F(GLES2DecoderTest, ReadPixelsInvalidArgs) {
// TODO(gman): DeleteShader
-// TODO(gman): GetAttribLocation
-
-// TODO(gman): GetAttribLocationImmediate
-
-// TODO(gman): GetUniformLocation
-
-// TODO(gman): GetUniformLocationImmediate
-
// TODO(gman): PixelStorei
// TODO(gman): TexImage2D
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 f652358..6fb494b 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
@@ -22,6 +22,7 @@ TEST_F(GLES2DecoderTest1, AttachShaderValidArgs) {
// TODO(gman): BindAttribLocationImmediate
+// TODO(gman): BindAttribLocationBucket
TEST_F(GLES2DecoderTest1, BindBufferValidArgs) {
EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kServiceBufferId));
@@ -1030,6 +1031,8 @@ TEST_F(GLES2DecoderTest1, GenTexturesImmediateInvalidArgs) {
// TODO(gman): GetAttribLocationImmediate
+// TODO(gman): GetAttribLocationBucket
+
TEST_F(GLES2DecoderTest1, GetBooleanvValidArgs) {
EXPECT_CALL(*gl_, GetError())
@@ -1059,7 +1062,7 @@ TEST_F(GLES2DecoderTest1, GetBooleanvInvalidArgs0_0) {
GetBooleanv cmd;
cmd.Init(GL_FOG_HINT, shared_memory_id_, shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1072,7 +1075,7 @@ TEST_F(GLES2DecoderTest1, GetBooleanvInvalidArgs1_0) {
GetBooleanv cmd;
cmd.Init(GL_ACTIVE_TEXTURE, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetBooleanvInvalidArgs1_1) {
@@ -1084,7 +1087,7 @@ TEST_F(GLES2DecoderTest1, GetBooleanvInvalidArgs1_1) {
GetBooleanv cmd;
cmd.Init(GL_ACTIVE_TEXTURE, shared_memory_id_, kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetBufferParameterivValidArgs) {
@@ -1121,7 +1124,7 @@ TEST_F(GLES2DecoderTest1, GetBufferParameterivInvalidArgs0_0) {
GL_RENDERBUFFER, GL_BUFFER_SIZE, shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1136,7 +1139,7 @@ TEST_F(GLES2DecoderTest1, GetBufferParameterivInvalidArgs1_0) {
GL_ARRAY_BUFFER, GL_PIXEL_PACK_BUFFER, shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1149,7 +1152,7 @@ TEST_F(GLES2DecoderTest1, GetBufferParameterivInvalidArgs2_0) {
GetBufferParameteriv cmd;
cmd.Init(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetBufferParameterivInvalidArgs2_1) {
@@ -1163,7 +1166,7 @@ TEST_F(GLES2DecoderTest1, GetBufferParameterivInvalidArgs2_1) {
GL_ARRAY_BUFFER, GL_BUFFER_SIZE, shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetErrorValidArgs) {
@@ -1213,7 +1216,7 @@ TEST_F(GLES2DecoderTest1, GetFloatvInvalidArgs0_0) {
GetFloatv cmd;
cmd.Init(GL_FOG_HINT, shared_memory_id_, shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1226,7 +1229,7 @@ TEST_F(GLES2DecoderTest1, GetFloatvInvalidArgs1_0) {
GetFloatv cmd;
cmd.Init(GL_ACTIVE_TEXTURE, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetFloatvInvalidArgs1_1) {
@@ -1238,7 +1241,7 @@ TEST_F(GLES2DecoderTest1, GetFloatvInvalidArgs1_1) {
GetFloatv cmd;
cmd.Init(GL_ACTIVE_TEXTURE, shared_memory_id_, kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetFramebufferAttachmentParameterivValidArgs) {
@@ -1280,7 +1283,7 @@ TEST_F(GLES2DecoderTest1, GetFramebufferAttachmentParameterivInvalidArgs0_0) {
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1297,7 +1300,7 @@ TEST_F(GLES2DecoderTest1, GetFramebufferAttachmentParameterivInvalidArgs3_0) {
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetFramebufferAttachmentParameterivInvalidArgs3_1) {
@@ -1314,7 +1317,7 @@ TEST_F(GLES2DecoderTest1, GetFramebufferAttachmentParameterivInvalidArgs3_1) {
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetIntegervValidArgs) {
@@ -1345,7 +1348,7 @@ TEST_F(GLES2DecoderTest1, GetIntegervInvalidArgs0_0) {
GetIntegerv cmd;
cmd.Init(GL_FOG_HINT, shared_memory_id_, shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1358,7 +1361,7 @@ TEST_F(GLES2DecoderTest1, GetIntegervInvalidArgs1_0) {
GetIntegerv cmd;
cmd.Init(GL_ACTIVE_TEXTURE, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetIntegervInvalidArgs1_1) {
@@ -1370,7 +1373,7 @@ TEST_F(GLES2DecoderTest1, GetIntegervInvalidArgs1_1) {
GetIntegerv cmd;
cmd.Init(GL_ACTIVE_TEXTURE, shared_memory_id_, kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetProgramivValidArgs) {
@@ -1405,7 +1408,7 @@ TEST_F(GLES2DecoderTest1, GetProgramivInvalidArgs2_0) {
GetProgramiv cmd;
cmd.Init(client_program_id_, GL_DELETE_STATUS, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetProgramivInvalidArgs2_1) {
@@ -1419,7 +1422,7 @@ TEST_F(GLES2DecoderTest1, GetProgramivInvalidArgs2_1) {
client_program_id_, GL_DELETE_STATUS, shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetProgramInfoLogValidArgs) {
@@ -1487,7 +1490,7 @@ TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivInvalidArgs0_0) {
GL_FRAMEBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1500,7 +1503,7 @@ TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivInvalidArgs2_0) {
GetRenderbufferParameteriv cmd;
cmd.Init(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivInvalidArgs2_1) {
@@ -1514,7 +1517,7 @@ TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivInvalidArgs2_1) {
GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetShaderivValidArgs) {
@@ -1548,7 +1551,7 @@ TEST_F(GLES2DecoderTest1, GetShaderivInvalidArgs2_0) {
GetShaderiv cmd;
cmd.Init(client_shader_id_, GL_SHADER_TYPE, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetShaderivInvalidArgs2_1) {
@@ -1562,7 +1565,7 @@ TEST_F(GLES2DecoderTest1, GetShaderivInvalidArgs2_1) {
client_shader_id_, GL_SHADER_TYPE, shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetShaderInfoLogValidArgs) {
@@ -1635,7 +1638,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterfvInvalidArgs0_0) {
GL_PROXY_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1650,7 +1653,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterfvInvalidArgs1_0) {
GL_TEXTURE_2D, GL_GENERATE_MIPMAP, shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1663,7 +1666,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterfvInvalidArgs2_0) {
GetTexParameterfv cmd;
cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetTexParameterfvInvalidArgs2_1) {
@@ -1677,7 +1680,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterfvInvalidArgs2_1) {
GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetTexParameterivValidArgs) {
@@ -1714,7 +1717,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs0_0) {
GL_PROXY_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1729,7 +1732,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs1_0) {
GL_TEXTURE_2D, GL_GENERATE_MIPMAP, shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
@@ -1742,7 +1745,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs2_0) {
GetTexParameteriv cmd;
cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs2_1) {
@@ -1756,7 +1759,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs2_1) {
GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_1_AUTOGEN_H_
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h
index 4c1af56..3412c4b 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
@@ -16,6 +16,8 @@
// TODO(gman): GetUniformLocationImmediate
+// TODO(gman): GetUniformLocationBucket
+
TEST_F(GLES2DecoderTest2, GetVertexAttribfvValidArgs) {
EXPECT_CALL(*gl_, GetError())
@@ -50,7 +52,7 @@ TEST_F(GLES2DecoderTest2, GetVertexAttribfvInvalidArgs2_0) {
cmd.Init(
1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest2, GetVertexAttribfvInvalidArgs2_1) {
@@ -64,7 +66,7 @@ TEST_F(GLES2DecoderTest2, GetVertexAttribfvInvalidArgs2_1) {
1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest2, GetVertexAttribivValidArgs) {
@@ -100,7 +102,7 @@ TEST_F(GLES2DecoderTest2, GetVertexAttribivInvalidArgs2_0) {
cmd.Init(
1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, kInvalidSharedMemoryId, 0);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
TEST_F(GLES2DecoderTest2, GetVertexAttribivInvalidArgs2_1) {
@@ -114,7 +116,7 @@ TEST_F(GLES2DecoderTest2, GetVertexAttribivInvalidArgs2_1) {
1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
- EXPECT_EQ(0, result->size);
+ EXPECT_EQ(0u, result->size);
}
// TODO(gman): GetVertexAttribPointerv
@@ -398,6 +400,7 @@ TEST_F(GLES2DecoderTest2, ScissorInvalidArgs3_0) {
// TODO(gman): ShaderSourceImmediate
+// TODO(gman): ShaderSourceBucket
TEST_F(GLES2DecoderTest2, StencilFuncValidArgs) {
EXPECT_CALL(*gl_, StencilFunc(GL_NEVER, 2, 3));
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index 16acf9a..0bb32c6 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -140,6 +140,8 @@ void GLES2DecoderTestBase::SetUp() {
}
void GLES2DecoderTestBase::TearDown() {
+ // All Tests should have read all their GLErrors before getting here.
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
decoder_->Destroy();
decoder_.reset();
engine_.reset();
@@ -157,6 +159,21 @@ GLint GLES2DecoderTestBase::GetGLError() {
return static_cast<GLint>(*GetSharedMemoryAs<GLenum*>());
}
+void GLES2DecoderTestBase::SetBucketAsCString(
+ uint32 bucket_id, const char* str) {
+ uint32 size = str ? (strlen(str) + 1) : 0;
+ cmd::SetBucketSize cmd1;
+ cmd1.Init(bucket_id, size);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
+ if (str) {
+ memcpy(shared_memory_address_, str, size);
+ cmd::SetBucketData cmd2;
+ cmd2.Init(bucket_id, 0, size, kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
+ ClearSharedMemory();
+ }
+}
+
void GLES2DecoderTestBase::DoBindFramebuffer(
GLenum target, GLuint client_id, GLuint service_id) {
EXPECT_CALL(*gl_, BindFramebufferEXT(target, service_id))
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
index 96dc2d9..4290978 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
@@ -123,6 +123,8 @@ class GLES2DecoderTestBase : public testing::Test {
return decoder_->GetServiceIdForTesting(client_id);
}
+ void SetBucketAsCString(uint32 bucket_id, const char* str);
+
// Note that the error is returned as GLint instead of GLenum.
// This is because there is a mismatch in the types of GLenum and
// the error values GL_NO_ERROR, GL_INVALID_ENUM, etc. GLenum is
@@ -140,7 +142,7 @@ class GLES2DecoderTestBase : public testing::Test {
uint32 shared_memory_id, uint32 shared_memory_offset);
// Use StrictMock to make 100% sure we know how GL will be called.
- scoped_ptr<::testing::StrictMock<::gles2::MockGLInterface> > gl_;
+ scoped_ptr< ::testing::StrictMock< ::gles2::MockGLInterface> > gl_;
scoped_ptr<GLES2Decoder> decoder_;
GLuint client_buffer_id_;
@@ -200,7 +202,7 @@ class GLES2DecoderTestBase : public testing::Test {
Buffer invalid_buffer_;
};
- scoped_ptr<::testing::StrictMock<MockCommandBufferEngine> > engine_;
+ scoped_ptr< ::testing::StrictMock<MockCommandBufferEngine> > engine_;
ContextGroup group_;
};
diff --git a/gpu/command_buffer/service/id_manager_unittest.cc b/gpu/command_buffer/service/id_manager_unittest.cc
index 0093984..015a442 100644
--- a/gpu/command_buffer/service/id_manager_unittest.cc
+++ b/gpu/command_buffer/service/id_manager_unittest.cc
@@ -42,8 +42,8 @@ TEST_F(IdManagerTest, Basic) {
client_id = 0;
EXPECT_FALSE(manager_.GetServiceId(kClientId2, &service_id));
EXPECT_FALSE(manager_.GetClientId(kServiceId2, &client_id));
- EXPECT_EQ(0, service_id);
- EXPECT_EQ(0, client_id);
+ EXPECT_EQ(0u, service_id);
+ EXPECT_EQ(0u, client_id);
// Check we can add a second id.
EXPECT_TRUE(manager_.AddMapping(kClientId2, kServiceId2));
// Check we can get that mapping
diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc
index 0647884..b75b628 100644
--- a/gpu/command_buffer/service/program_manager_unittest.cc
+++ b/gpu/command_buffer/service/program_manager_unittest.cc
@@ -39,7 +39,6 @@ class ProgramManagerTest : public testing::Test {
TEST_F(ProgramManagerTest, Basic) {
const GLuint kProgram1Id = 1;
- const GLsizeiptr kProgram1Size = 123;
const GLuint kProgram2Id = 2;
// Check we can create program.
manager_.CreateProgramInfo(kProgram1Id);
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc
index d5c393c..d80af31 100644
--- a/gpu/command_buffer/service/texture_manager_unittest.cc
+++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -31,7 +31,6 @@ class TextureManagerTest : public testing::Test {
TEST_F(TextureManagerTest, Basic) {
const GLuint kTexture1Id = 1;
- const GLsizeiptr kTexture1Size = 123;
const GLuint kTexture2Id = 2;
// Check we can create texture.
manager_.CreateTextureInfo(kTexture1Id);
@@ -128,7 +127,7 @@ class TextureInfoTest : public testing::Test {
};
TEST_F(TextureInfoTest, Basic) {
- EXPECT_EQ(0, info_->target());
+ EXPECT_EQ(0u, info_->target());
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
EXPECT_FALSE(info_->CanGenerateMipmaps());
@@ -138,7 +137,7 @@ TEST_F(TextureInfoTest, Basic) {
TEST_F(TextureInfoTest, POT2D) {
manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
- EXPECT_EQ(GL_TEXTURE_2D, info_->target());
+ EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info_->target());
// Check Setting level 0 to POT
info_->SetLevelInfo(
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
@@ -175,7 +174,7 @@ TEST_F(TextureInfoTest, POT2D) {
TEST_F(TextureInfoTest, NPOT2D) {
manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
- EXPECT_EQ(GL_TEXTURE_2D, info_->target());
+ EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), info_->target());
// Check Setting level 0 to NPOT
info_->SetLevelInfo(
GL_TEXTURE_2D, 0, GL_RGBA, 4, 5, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
@@ -199,7 +198,7 @@ TEST_F(TextureInfoTest, NPOT2D) {
TEST_F(TextureInfoTest, POTCubeMap) {
manager_.SetInfoTarget(info_, GL_TEXTURE_CUBE_MAP);
- EXPECT_EQ(GL_TEXTURE_CUBE_MAP, info_->target());
+ EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP), info_->target());
// Check Setting level 0 each face to POT
info_->SetLevelInfo(
GL_TEXTURE_CUBE_MAP_POSITIVE_X,