summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorjungjik.lee@samsung.com <jungjik.lee@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 20:46:09 +0000
committerjungjik.lee@samsung.com <jungjik.lee@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 20:46:09 +0000
commit4860ead2ee60c12b5e0097a690699f6cb241bec4 (patch)
tree9057e12d524b304dd97ca491da7461ffa570ea9f /gpu
parentd2eb7f4b4f7f31df9bd02150412c3f2a4c162336 (diff)
downloadchromium_src-4860ead2ee60c12b5e0097a690699f6cb241bec4.zip
chromium_src-4860ead2ee60c12b5e0097a690699f6cb241bec4.tar.gz
chromium_src-4860ead2ee60c12b5e0097a690699f6cb241bec4.tar.bz2
generate GetAttribLocation/GetUniformLocation by build_gles2_cmd_buffer.py
change to generate GetAttribLocation/GetUniformLocation functions by build_gles2_cmd_buffer.py and remove HandWritten code. Bug=None TEST=gpu_tests --gtest_filter="GLES2FormatTest.*" Review URL: https://codereview.chromium.org/333303002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283494 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py40
-rw-r--r--gpu/command_buffer/client/gles2_cmd_helper.h20
-rw-r--r--gpu/command_buffer/client/gles2_cmd_helper_autogen.h22
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format.h111
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_autogen.h110
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_test_autogen.h36
6 files changed, 175 insertions, 164 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index a9e13bc..d74d64a 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -1239,8 +1239,6 @@ _PEPPER_INTERFACES = [
# gl_test_func: GL function that is expected to be called when testing.
# cmd_args: The arguments to use for the command. This overrides generating
# them based on the GL function arguments.
-# a NonImmediate type is a type that stays a pointer even in
-# and immediate version of acommand.
# gen_cmd: Whether or not this function geneates a command. Default = True.
# data_transfer_methods: Array of methods that are used for transfering the
# pointer data. Possible values: 'immediate', 'shm', 'bucket'.
@@ -1709,10 +1707,10 @@ _FUNCTION_INFO = {
'result': ['SizedResult<GLuint>'],
},
'GetAttribLocation': {
- 'type': 'HandWritten',
- 'needs_size': True,
+ 'type': 'Custom',
+ 'data_transfer_methods': ['shm'],
'cmd_args':
- 'GLidProgram program, const char* name, NonImmediate GLint* location',
+ 'GLidProgram program, uint32_t name_bucket_id, GLint* location',
'result': ['GLint'],
'error_return': -1, # http://www.opengl.org/sdk/docs/man/xhtml/glGetAttribLocation.xml
},
@@ -1866,10 +1864,10 @@ _FUNCTION_INFO = {
'result': ['SizedResult<GLint>'],
},
'GetUniformLocation': {
- 'type': 'HandWritten',
- 'needs_size': True,
+ 'type': 'Custom',
+ 'data_transfer_methods': ['shm'],
'cmd_args':
- 'GLidProgram program, const char* name, NonImmediate GLint* location',
+ 'GLidProgram program, uint32_t name_bucket_id, GLint* location',
'result': ['GLint'],
'error_return': -1, # http://www.opengl.org/sdk/docs/man/xhtml/glGetUniformLocation.xml
},
@@ -6530,21 +6528,6 @@ class InputStringBucketArgument(Argument):
return "_"
-class NonImmediatePointerArgument(PointerArgument):
- """A pointer argument that stays a pointer even in an immediate cmd."""
-
- def __init__(self, name, type):
- PointerArgument.__init__(self, name, type)
-
- def IsPointer(self):
- """Returns true if argument is a pointer."""
- return False
-
- def GetImmediateVersion(self):
- """Overridden from Argument."""
- return self
-
-
class ResourceIdArgument(Argument):
"""A class that represents a resource id argument to a function."""
@@ -7202,14 +7185,9 @@ def CreateArg(arg_string):
return None
# Is this a pointer argument?
elif arg_string.find('*') >= 0:
- if arg_parts[0] == 'NonImmediate':
- return NonImmediatePointerArgument(
- arg_parts[-1],
- " ".join(arg_parts[1:-1]))
- else:
- return PointerArgument(
- arg_parts[-1],
- " ".join(arg_parts[0:-1]))
+ return PointerArgument(
+ arg_parts[-1],
+ " ".join(arg_parts[0:-1]))
# Is this a resource argument? Must come after pointer check.
elif arg_parts[0].startswith('GLidBind'):
return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1]))
diff --git a/gpu/command_buffer/client/gles2_cmd_helper.h b/gpu/command_buffer/client/gles2_cmd_helper.h
index 0726fbb..af6cc5d 100644
--- a/gpu/command_buffer/client/gles2_cmd_helper.h
+++ b/gpu/command_buffer/client/gles2_cmd_helper.h
@@ -25,26 +25,6 @@ class GPU_EXPORT GLES2CmdHelper : public CommandBufferHelper {
// Helpers that could not be auto-generated.
// TODO(gman): Auto generate these.
- void GetAttribLocation(
- GLuint program, uint32 name_bucket_id,
- uint32 location_shm_id, uint32 location_shm_offset) {
- gles2::cmds::GetAttribLocation* c =
- GetCmdSpace<gles2::cmds::GetAttribLocation>();
- if (c) {
- c->Init(program, name_bucket_id, location_shm_id, location_shm_offset);
- }
- }
-
- void GetUniformLocation(
- GLuint program, uint32 name_bucket_id,
- uint32 location_shm_id, uint32 location_shm_offset) {
- gles2::cmds::GetUniformLocation* c =
- GetCmdSpace<gles2::cmds::GetUniformLocation>();
- if (c) {
- c->Init(program, name_bucket_id, location_shm_id, location_shm_offset);
- }
- }
-
void CreateAndConsumeTextureCHROMIUMImmediate(GLenum target,
uint32_t client_id,
const GLbyte* _mailbox) {
diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
index 49d0336..baba8d3 100644
--- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
+++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
@@ -557,6 +557,17 @@ void GetAttachedShaders(GLuint program,
}
}
+void GetAttribLocation(GLuint program,
+ uint32_t name_bucket_id,
+ uint32_t location_shm_id,
+ uint32_t location_shm_offset) {
+ gles2::cmds::GetAttribLocation* c =
+ GetCmdSpace<gles2::cmds::GetAttribLocation>();
+ if (c) {
+ c->Init(program, name_bucket_id, location_shm_id, location_shm_offset);
+ }
+}
+
void GetBooleanv(GLenum pname,
uint32_t params_shm_id,
uint32_t params_shm_offset) {
@@ -728,6 +739,17 @@ void GetUniformiv(GLuint program,
}
}
+void GetUniformLocation(GLuint program,
+ uint32_t name_bucket_id,
+ uint32_t location_shm_id,
+ uint32_t location_shm_offset) {
+ gles2::cmds::GetUniformLocation* c =
+ GetCmdSpace<gles2::cmds::GetUniformLocation>();
+ if (c) {
+ c->Init(program, name_bucket_id, location_shm_id, location_shm_offset);
+ }
+}
+
void GetVertexAttribfv(GLuint index,
GLenum pname,
uint32_t params_shm_id,
diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h
index e8051b4..393303e 100644
--- a/gpu/command_buffer/common/gles2_cmd_format.h
+++ b/gpu/command_buffer/common/gles2_cmd_format.h
@@ -199,117 +199,6 @@ namespace cmds {
// These are hand written commands.
// TODO(gman): Attempt to make these auto-generated.
-struct GetAttribLocation {
- typedef GetAttribLocation ValueType;
- static const CommandId kCmdId = kGetAttribLocation;
- static const cmd::ArgFlags kArgFlags = cmd::kFixed;
- static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
-
- 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(GetAttribLocation) == 20,
- Sizeof_GetAttribLocation_is_not_24);
-COMPILE_ASSERT(offsetof(GetAttribLocation, header) == 0,
- OffsetOf_GetAttribLocation_header_not_0);
-COMPILE_ASSERT(offsetof(GetAttribLocation, program) == 4,
- OffsetOf_GetAttribLocation_program_not_4);
-COMPILE_ASSERT(offsetof(GetAttribLocation, name_bucket_id) == 8,
- OffsetOf_GetAttribLocation_name_bucket_id_not_8);
-COMPILE_ASSERT(offsetof(GetAttribLocation, location_shm_id) == 12,
- OffsetOf_GetAttribLocation_location_shm_id_not_12);
-COMPILE_ASSERT(offsetof(GetAttribLocation, location_shm_offset) == 16,
- OffsetOf_GetAttribLocation_location_shm_offset_not_16);
-
-struct GetUniformLocation {
- typedef GetUniformLocation ValueType;
- static const CommandId kCmdId = kGetUniformLocation;
- static const cmd::ArgFlags kArgFlags = cmd::kFixed;
- static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
-
- 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(GetUniformLocation) == 20,
- Sizeof_GetUniformLocation_is_not_24);
-COMPILE_ASSERT(offsetof(GetUniformLocation, header) == 0,
- OffsetOf_GetUniformLocation_header_not_0);
-COMPILE_ASSERT(offsetof(GetUniformLocation, program) == 4,
- OffsetOf_GetUniformLocation_program_not_4);
-COMPILE_ASSERT(offsetof(GetUniformLocation, name_bucket_id) == 8,
- OffsetOf_GetUniformLocation_name_bucket_id_not_8);
-COMPILE_ASSERT(offsetof(GetUniformLocation, location_shm_id) == 12,
- OffsetOf_GetUniformLocation_location_shm_id_not_12);
-COMPILE_ASSERT(offsetof(GetUniformLocation, location_shm_offset) == 16,
- OffsetOf_GetUniformLocation_location_shm_offset_not_16);
struct GenMailboxCHROMIUM {
typedef GenMailboxCHROMIUM ValueType;
diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
index 35b7c8b..d87dc8b 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
@@ -2595,6 +2595,61 @@ COMPILE_ASSERT(offsetof(GetAttachedShaders, result_shm_offset) == 12,
COMPILE_ASSERT(offsetof(GetAttachedShaders, result_size) == 16,
OffsetOf_GetAttachedShaders_result_size_not_16);
+struct GetAttribLocation {
+ typedef GetAttribLocation ValueType;
+ static const CommandId kCmdId = kGetAttribLocation;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+ static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
+
+ typedef GLint Result;
+
+ static uint32_t ComputeSize() {
+ return static_cast<uint32_t>(sizeof(ValueType)); // NOLINT
+ }
+
+ void SetHeader() { header.SetCmd<ValueType>(); }
+
+ void Init(GLuint _program,
+ uint32_t _name_bucket_id,
+ uint32_t _location_shm_id,
+ uint32_t _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_t _name_bucket_id,
+ uint32_t _location_shm_id,
+ uint32_t _location_shm_offset) {
+ static_cast<ValueType*>(cmd)->Init(
+ _program, _name_bucket_id, _location_shm_id, _location_shm_offset);
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ gpu::CommandHeader header;
+ uint32_t program;
+ uint32_t name_bucket_id;
+ uint32_t location_shm_id;
+ uint32_t location_shm_offset;
+};
+
+COMPILE_ASSERT(sizeof(GetAttribLocation) == 20,
+ Sizeof_GetAttribLocation_is_not_20);
+COMPILE_ASSERT(offsetof(GetAttribLocation, header) == 0,
+ OffsetOf_GetAttribLocation_header_not_0);
+COMPILE_ASSERT(offsetof(GetAttribLocation, program) == 4,
+ OffsetOf_GetAttribLocation_program_not_4);
+COMPILE_ASSERT(offsetof(GetAttribLocation, name_bucket_id) == 8,
+ OffsetOf_GetAttribLocation_name_bucket_id_not_8);
+COMPILE_ASSERT(offsetof(GetAttribLocation, location_shm_id) == 12,
+ OffsetOf_GetAttribLocation_location_shm_id_not_12);
+COMPILE_ASSERT(offsetof(GetAttribLocation, location_shm_offset) == 16,
+ OffsetOf_GetAttribLocation_location_shm_offset_not_16);
+
struct GetBooleanv {
typedef GetBooleanv ValueType;
static const CommandId kCmdId = kGetBooleanv;
@@ -3487,6 +3542,61 @@ COMPILE_ASSERT(offsetof(GetUniformiv, params_shm_id) == 12,
COMPILE_ASSERT(offsetof(GetUniformiv, params_shm_offset) == 16,
OffsetOf_GetUniformiv_params_shm_offset_not_16);
+struct GetUniformLocation {
+ typedef GetUniformLocation ValueType;
+ static const CommandId kCmdId = kGetUniformLocation;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+ static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
+
+ typedef GLint Result;
+
+ static uint32_t ComputeSize() {
+ return static_cast<uint32_t>(sizeof(ValueType)); // NOLINT
+ }
+
+ void SetHeader() { header.SetCmd<ValueType>(); }
+
+ void Init(GLuint _program,
+ uint32_t _name_bucket_id,
+ uint32_t _location_shm_id,
+ uint32_t _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_t _name_bucket_id,
+ uint32_t _location_shm_id,
+ uint32_t _location_shm_offset) {
+ static_cast<ValueType*>(cmd)->Init(
+ _program, _name_bucket_id, _location_shm_id, _location_shm_offset);
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ gpu::CommandHeader header;
+ uint32_t program;
+ uint32_t name_bucket_id;
+ uint32_t location_shm_id;
+ uint32_t location_shm_offset;
+};
+
+COMPILE_ASSERT(sizeof(GetUniformLocation) == 20,
+ Sizeof_GetUniformLocation_is_not_20);
+COMPILE_ASSERT(offsetof(GetUniformLocation, header) == 0,
+ OffsetOf_GetUniformLocation_header_not_0);
+COMPILE_ASSERT(offsetof(GetUniformLocation, program) == 4,
+ OffsetOf_GetUniformLocation_program_not_4);
+COMPILE_ASSERT(offsetof(GetUniformLocation, name_bucket_id) == 8,
+ OffsetOf_GetUniformLocation_name_bucket_id_not_8);
+COMPILE_ASSERT(offsetof(GetUniformLocation, location_shm_id) == 12,
+ OffsetOf_GetUniformLocation_location_shm_id_not_12);
+COMPILE_ASSERT(offsetof(GetUniformLocation, location_shm_offset) == 16,
+ OffsetOf_GetUniformLocation_location_shm_offset_not_16);
+
struct GetVertexAttribfv {
typedef GetVertexAttribfv ValueType;
static const CommandId kCmdId = kGetVertexAttribfv;
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 071bde2..d19c9c6 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
@@ -877,7 +877,23 @@ TEST_F(GLES2FormatTest, GetAttachedShaders) {
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
-// TODO(gman): Write test for GetAttribLocation
+TEST_F(GLES2FormatTest, GetAttribLocation) {
+ cmds::GetAttribLocation& cmd = *GetBufferAs<cmds::GetAttribLocation>();
+ void* next_cmd = cmd.Set(&cmd,
+ static_cast<GLuint>(11),
+ static_cast<uint32_t>(12),
+ static_cast<uint32_t>(13),
+ static_cast<uint32_t>(14));
+ EXPECT_EQ(static_cast<uint32_t>(cmds::GetAttribLocation::kCmdId),
+ cmd.header.command);
+ EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
+ EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
+ EXPECT_EQ(static_cast<uint32_t>(12), cmd.name_bucket_id);
+ EXPECT_EQ(static_cast<uint32_t>(13), cmd.location_shm_id);
+ EXPECT_EQ(static_cast<uint32_t>(14), cmd.location_shm_offset);
+ CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
+}
+
TEST_F(GLES2FormatTest, GetBooleanv) {
cmds::GetBooleanv& cmd = *GetBufferAs<cmds::GetBooleanv>();
void* next_cmd = cmd.Set(&cmd,
@@ -1156,7 +1172,23 @@ TEST_F(GLES2FormatTest, GetUniformiv) {
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
-// TODO(gman): Write test for GetUniformLocation
+TEST_F(GLES2FormatTest, GetUniformLocation) {
+ cmds::GetUniformLocation& cmd = *GetBufferAs<cmds::GetUniformLocation>();
+ void* next_cmd = cmd.Set(&cmd,
+ static_cast<GLuint>(11),
+ static_cast<uint32_t>(12),
+ static_cast<uint32_t>(13),
+ static_cast<uint32_t>(14));
+ EXPECT_EQ(static_cast<uint32_t>(cmds::GetUniformLocation::kCmdId),
+ cmd.header.command);
+ EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
+ EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
+ EXPECT_EQ(static_cast<uint32_t>(12), cmd.name_bucket_id);
+ EXPECT_EQ(static_cast<uint32_t>(13), cmd.location_shm_id);
+ EXPECT_EQ(static_cast<uint32_t>(14), cmd.location_shm_offset);
+ CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
+}
+
TEST_F(GLES2FormatTest, GetVertexAttribfv) {
cmds::GetVertexAttribfv& cmd = *GetBufferAs<cmds::GetVertexAttribfv>();
void* next_cmd = cmd.Set(&cmd,