Index: gpu/command_buffer/build_gles2_cmd_buffer.py |
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py |
index 7a3db588b06608f405379b08e392844918a8af31..b0574771ebd0de38ecab1a961701f40392a80f58 100755 |
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py |
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py |
@@ -2017,6 +2017,20 @@ _FUNCTION_INFO = { |
'result': ['SizedResult<GLuint>'], |
'client_test': False, |
}, |
+ 'InvalidateFramebuffer': { |
+ 'type': 'PUTn', |
+ 'count': 1, |
+ 'client_test': False, |
+ 'unit_test': False, |
+ 'unsafe': True, |
+ }, |
+ 'InvalidateSubFramebuffer': { |
+ 'type': 'PUTn', |
+ 'count': 1, |
+ 'client_test': False, |
+ 'unit_test': False, |
+ 'unsafe': True, |
+ }, |
'IsBuffer': { |
'type': 'Is', |
'decoder_func': 'DoIsBuffer', |
@@ -2133,6 +2147,9 @@ _FUNCTION_INFO = { |
'unit_test': False, |
'extension_flag': 'multisampled_render_to_texture', |
}, |
+ 'ReadBuffer': { |
+ 'unsafe': True, |
+ }, |
'ReadPixels': { |
'cmd_comment': |
'// ReadPixels has the result separated from the pixel buffer so that\n' |
@@ -2742,8 +2759,6 @@ _FUNCTION_INFO = { |
'DiscardFramebufferEXT': { |
'type': 'PUTn', |
'count': 1, |
- 'cmd_args': 'GLenum target, GLsizei count, ' |
- 'const GLenum* attachments', |
'decoder_func': 'DoDiscardFramebufferEXT', |
'unit_test': False, |
'client_test': False, |
@@ -3132,12 +3147,10 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d, |
self.WriteServiceHandlerFunctionHeader(func, file) |
self.WriteHandlerExtensionCheck(func, file) |
self.WriteHandlerDeferReadWrite(func, file); |
- last_arg = func.GetLastOriginalArg() |
- all_but_last_arg = func.GetOriginalArgs()[:-1] |
- for arg in all_but_last_arg: |
+ for arg in func.GetOriginalArgs(): |
+ if arg.IsPointer(): |
+ self.WriteGetDataSizeCode(func, file) |
arg.WriteGetCode(file) |
- self.WriteGetDataSizeCode(func, file) |
- last_arg.WriteGetCode(file) |
func.WriteHandlerValidation(file) |
func.WriteHandlerImplementation(file) |
file.Write(" return error::kNoError;\n") |
@@ -3149,12 +3162,10 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d, |
self.WriteServiceHandlerFunctionHeader(func, file) |
self.WriteHandlerExtensionCheck(func, file) |
self.WriteHandlerDeferReadWrite(func, file); |
- last_arg = func.GetLastOriginalArg() |
- all_but_last_arg = func.GetOriginalArgs()[:-1] |
- for arg in all_but_last_arg: |
+ for arg in func.GetOriginalArgs(): |
+ if arg.IsPointer(): |
+ self.WriteGetDataSizeCode(func, file) |
arg.WriteGetCode(file) |
- self.WriteGetDataSizeCode(func, file) |
- last_arg.WriteGetCode(file) |
func.WriteHandlerValidation(file) |
func.WriteHandlerImplementation(file) |
file.Write(" return error::kNoError;\n") |
@@ -4224,9 +4235,7 @@ TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { |
SetGLError(GL_INVALID_OPERATION, "%(name)s\", \"%(id)s reserved id"); |
return; |
} |
- if (%(name)sHelper(%(arg_string)s)) { |
- helper_->%(name)s(%(arg_string)s); |
- } |
+ %(name)sHelper(%(arg_string)s); |
CheckGLError(); |
} |
@@ -5526,13 +5535,13 @@ TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { |
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") |
func.WriteDestinationInitalizationValidation(file) |
self.WriteClientGLCallLog(func, file) |
- last_arg_name = func.GetLastOriginalArg().name |
+ last_pointer_name = func.GetLastOriginalPointerArg().name |
file.Write(""" GPU_CLIENT_LOG_CODE_BLOCK({ |
for (GLsizei i = 0; i < count; ++i) { |
""") |
values_str = ' << ", " << '.join( |
["%s[%d + i * %d]" % ( |
- last_arg_name, ndx, self.GetArrayCount(func)) for ndx in range( |
+ last_pointer_name, ndx, self.GetArrayCount(func)) for ndx in range( |
0, self.GetArrayCount(func))]) |
file.Write(' GPU_CLIENT_LOG(" " << i << ": " << %s);\n' % values_str) |
file.Write(" }\n });\n") |
@@ -5560,18 +5569,26 @@ TEST_F(GLES2ImplementationTest, %(name)s) { |
data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj); |
} |
} |
- expected.cmd.Init(%(cmd_args)s, &data[0][0]); |
- gl_->%(name)s(%(args)s, &data[0][0]); |
+ expected.cmd.Init(%(cmd_args)s); |
+ gl_->%(name)s(%(args)s); |
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
} |
""" |
- cmd_arg_strings = [ |
- arg.GetValidClientSideCmdArg(func) for arg in func.GetCmdArgs()[0:-2] |
- ] |
+ cmd_arg_strings = [] |
+ for arg in func.GetCmdArgs(): |
+ if arg.name.endswith("_shm_id"): |
+ cmd_arg_strings.append("&data[0][0]") |
+ elif arg.name.endswith("_shm_offset"): |
+ continue |
+ else: |
+ cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func)) |
gl_arg_strings = [] |
count_param = 0 |
- for arg in func.GetOriginalArgs()[0:-1]: |
- valid_value = arg.GetValidClientSideArg(func) |
+ for arg in func.GetOriginalArgs(): |
+ if arg.IsPointer(): |
+ valid_value = "&data[0][0]" |
+ else: |
+ valid_value = arg.GetValidClientSideArg(func) |
gl_arg_strings.append(valid_value) |
if arg.name == "count": |
count_param = int(valid_value) |
@@ -5600,7 +5617,7 @@ TEST_F(GLES2ImplementationTest, %(name)sInvalidConstantArg%(invalid_index)d) { |
data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj); |
} |
} |
- gl_->%(name)s(%(args)s, &data[0][0]); |
+ gl_->%(name)s(%(args)s); |
EXPECT_TRUE(NoCommandsWritten()); |
EXPECT_EQ(%(gl_error)s, CheckError()); |
} |
@@ -5608,9 +5625,11 @@ TEST_F(GLES2ImplementationTest, %(name)sInvalidConstantArg%(invalid_index)d) { |
for invalid_arg in constants: |
gl_arg_strings = [] |
invalid = invalid_arg.GetInvalidArg(func) |
- for arg in func.GetOriginalArgs()[0:-1]: |
+ for arg in func.GetOriginalArgs(): |
if arg is invalid_arg: |
gl_arg_strings.append(invalid[0]) |
+ elif arg.IsPointer(): |
+ gl_arg_strings.append("&data[0][0]") |
else: |
valid_value = arg.GetValidClientSideArg(func) |
gl_arg_strings.append(valid_value) |
@@ -5653,28 +5672,24 @@ TEST_F(GLES2ImplementationTest, %(name)sInvalidConstantArg%(invalid_index)d) { |
def WriteImmediateCmdInit(self, func, file): |
"""Overrriden from TypeHandler.""" |
- last_arg = func.GetLastOriginalArg() |
- file.Write(" void Init(%s, %s _%s) {\n" % |
- (func.MakeTypedCmdArgString("_"), |
- last_arg.type, last_arg.name)) |
+ file.Write(" void Init(%s) {\n" % |
+ func.MakeTypedInitString("_")) |
file.Write(" SetHeader(_count);\n") |
args = func.GetCmdArgs() |
for arg in args: |
file.Write(" %s = _%s;\n" % (arg.name, arg.name)) |
file.Write(" memcpy(ImmediateDataAddress(this),\n") |
- file.Write(" _%s, ComputeDataSize(_count));\n" % last_arg.name) |
+ pointer_arg = func.GetLastOriginalPointerArg() |
+ file.Write(" _%s, ComputeDataSize(_count));\n" % pointer_arg.name) |
file.Write(" }\n") |
file.Write("\n") |
def WriteImmediateCmdSet(self, func, file): |
"""Overrriden from TypeHandler.""" |
- last_arg = func.GetLastOriginalArg() |
- copy_args = func.MakeCmdArgString("_", False) |
- file.Write(" void* Set(void* cmd%s, %s _%s) {\n" % |
- (func.MakeTypedCmdArgString("_", True), |
- last_arg.type, last_arg.name)) |
- file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _%s);\n" % |
- (copy_args, last_arg.name)) |
+ 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_t size = ComputeSize(_count);\n") |
file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" |
"cmd, size);\n") |
@@ -5701,7 +5716,7 @@ TEST_F(GLES2ImplementationTest, %(name)sInvalidConstantArg%(invalid_index)d) { |
def WriteImmediateFormatTest(self, func, file): |
"""Overrriden from TypeHandler.""" |
- args = func.GetCmdArgs() |
+ args = func.GetOriginalArgs() |
count_param = 0 |
for arg in args: |
if arg.name == "count": |
@@ -5722,13 +5737,20 @@ TEST_F(GLES2ImplementationTest, %(name)sInvalidConstantArg%(invalid_index)d) { |
file.Write(" void* next_cmd = cmd.Set(\n") |
file.Write(" &cmd") |
for value, arg in enumerate(args): |
- file.Write(",\n static_cast<%s>(%d)" % (arg.type, value + 1)) |
- file.Write(",\n data);\n") |
+ if arg.IsPointer(): |
+ file.Write(",\n data") |
+ elif arg.IsConstant(): |
+ continue |
+ else: |
+ file.Write(",\n static_cast<%s>(%d)" % (arg.type, value + 1)) |
+ file.Write(");\n") |
file.Write(" EXPECT_EQ(static_cast<uint32_t>(cmds::%s::kCmdId),\n" % |
func.name) |
file.Write(" cmd.header.command);\n") |
file.Write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n") |
for value, arg in enumerate(args): |
+ if arg.IsPointer() or arg.IsConstant(): |
+ continue |
file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % |
(arg.type, value + 1, arg.name)) |
file.Write(" CheckBytesWrittenMatchesExpectedSize(\n") |
@@ -6978,6 +7000,13 @@ class Function(object): |
self.num_pointer_args = sum( |
[1 for arg in self.args_for_cmds if arg.IsPointer()]) |
+ if self.num_pointer_args > 0: |
+ for arg in reversed(self.original_args): |
+ if arg.IsPointer(): |
+ self.last_original_pointer_arg = arg |
+ break |
+ else: |
+ self.last_original_pointer_arg = None |
self.info = info |
self.type_handler = self.type_handlers[info['type']] |
self.can_auto_generate = (self.num_pointer_args == 0 and |
@@ -7124,6 +7153,9 @@ class Function(object): |
"""Gets the last original argument to this function.""" |
return self.original_args[len(self.original_args) - 1] |
+ def GetLastOriginalPointerArg(self): |
+ return self.last_original_pointer_arg |
+ |
def __MaybePrependComma(self, arg_string, add_comma): |
"""Adds a comma if arg_string is not empty and add_comma is true.""" |
comma = "" |