Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 12545014: Implement EXT_draw_buffers WebGL extention support in command buffer. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/GLES2/gl2extchromium.h ('k') | gpu/command_buffer/client/gles2_c_lib_autogen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """code generator for GLES2 command buffers.""" 6 """code generator for GLES2 command buffers."""
7 7
8 import itertools 8 import itertools
9 import os 9 import os
10 import os.path 10 import os.path
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 }, 2145 },
2146 'DrawArraysInstancedANGLE': { 2146 'DrawArraysInstancedANGLE': {
2147 'type': 'Manual', 2147 'type': 'Manual',
2148 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count, ' 2148 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count, '
2149 'GLsizei primcount', 2149 'GLsizei primcount',
2150 'extension': True, 2150 'extension': True,
2151 'unit_test': False, 2151 'unit_test': False,
2152 'pepper_interface': 'InstancedArrays', 2152 'pepper_interface': 'InstancedArrays',
2153 'defer_draws': True, 2153 'defer_draws': True,
2154 }, 2154 },
2155 'DrawBuffersEXT': {
2156 'type': 'PUTn',
2157 'decoder_func': 'DoDrawBuffersEXT',
2158 'data_type': 'GLenum',
2159 'count': 1,
2160 'client_test': False,
2161 'unit_test': False,
2162 'extension': True,
2163 },
2155 'DrawElementsInstancedANGLE': { 2164 'DrawElementsInstancedANGLE': {
2156 'type': 'Manual', 2165 'type': 'Manual',
2157 'cmd_args': 'GLenumDrawMode mode, GLsizei count, ' 2166 'cmd_args': 'GLenumDrawMode mode, GLsizei count, '
2158 'GLenumIndexType type, GLuint index_offset, GLsizei primcount', 2167 'GLenumIndexType type, GLuint index_offset, GLsizei primcount',
2159 'extension': True, 2168 'extension': True,
2160 'unit_test': False, 2169 'unit_test': False,
2161 'client_test': False, 2170 'client_test': False,
2162 'pepper_interface': 'InstancedArrays', 2171 'pepper_interface': 'InstancedArrays',
2163 'defer_draws': True, 2172 'defer_draws': True,
2164 }, 2173 },
(...skipping 2755 matching lines...) Expand 10 before | Expand all | Expand 10 after
4920 file.Write(" CheckGLError();\n") 4929 file.Write(" CheckGLError();\n")
4921 file.Write("}\n") 4930 file.Write("}\n")
4922 file.Write("\n") 4931 file.Write("\n")
4923 4932
4924 def WriteGLES2ImplementationUnitTest(self, func, file): 4933 def WriteGLES2ImplementationUnitTest(self, func, file):
4925 """Writes the GLES2 Implemention unit test.""" 4934 """Writes the GLES2 Implemention unit test."""
4926 code = """ 4935 code = """
4927 TEST_F(GLES2ImplementationTest, %(name)s) { 4936 TEST_F(GLES2ImplementationTest, %(name)s) {
4928 struct Cmds { 4937 struct Cmds {
4929 cmds::%(name)sImmediate cmd; 4938 cmds::%(name)sImmediate cmd;
4930 %(type)s data[2][%(count)d]; 4939 %(type)s data[%(count_param)d][%(count)d];
4931 }; 4940 };
4932 4941
4933 Cmds expected; 4942 Cmds expected;
4934 for (int ii = 0; ii < 2; ++ii) { 4943 for (int ii = 0; ii < %(count_param)d; ++ii) {
4935 for (int jj = 0; jj < %(count)d; ++jj) { 4944 for (int jj = 0; jj < %(count)d; ++jj) {
4936 expected.data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj); 4945 expected.data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj);
4937 } 4946 }
4938 } 4947 }
4939 expected.cmd.Init(%(cmd_args)s, &expected.data[0][0]); 4948 expected.cmd.Init(%(cmd_args)s, &expected.data[0][0]);
4940 gl_->%(name)s(%(args)s, &expected.data[0][0]); 4949 gl_->%(name)s(%(args)s, &expected.data[0][0]);
4941 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 4950 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
4942 } 4951 }
4943 """ 4952 """
4944 cmd_arg_strings = [] 4953 cmd_arg_strings = []
4945 for count, arg in enumerate(func.GetCmdArgs()[0:-2]): 4954 for count, arg in enumerate(func.GetCmdArgs()[0:-2]):
4946 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) 4955 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0))
4947 gl_arg_strings = [] 4956 gl_arg_strings = []
4957 count_param = 0
4948 for count, arg in enumerate(func.GetOriginalArgs()[0:-1]): 4958 for count, arg in enumerate(func.GetOriginalArgs()[0:-1]):
4949 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) 4959 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0))
4960 if arg.name == "count":
4961 count_param = int(arg.GetValidClientSideArg(func, count, 0))
4950 file.Write(code % { 4962 file.Write(code % {
4951 'name': func.name, 4963 'name': func.name,
4952 'type': func.GetInfo('data_type'), 4964 'type': func.GetInfo('data_type'),
4953 'count': func.GetInfo('count'), 4965 'count': func.GetInfo('count'),
4954 'args': ", ".join(gl_arg_strings), 4966 'args': ", ".join(gl_arg_strings),
4955 'cmd_args': ", ".join(cmd_arg_strings), 4967 'cmd_args': ", ".join(cmd_arg_strings),
4968 'count_param': count_param,
4956 }) 4969 })
4957 4970
4958 def WriteImmediateCmdComputeSize(self, func, file): 4971 def WriteImmediateCmdComputeSize(self, func, file):
4959 """Overrriden from TypeHandler.""" 4972 """Overrriden from TypeHandler."""
4960 file.Write(" static uint32 ComputeDataSize(GLsizei count) {\n") 4973 file.Write(" static uint32 ComputeDataSize(GLsizei count) {\n")
4961 file.Write(" return static_cast<uint32>(\n") 4974 file.Write(" return static_cast<uint32>(\n")
4962 file.Write(" sizeof(%s) * %d * count); // NOLINT\n" % 4975 file.Write(" sizeof(%s) * %d * count); // NOLINT\n" %
4963 (func.info.data_type, func.info.count)) 4976 (func.info.data_type, func.info.count))
4964 file.Write(" }\n") 4977 file.Write(" }\n")
4965 file.Write("\n") 4978 file.Write("\n")
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 5034
5022 """ 5035 """
5023 file.Write(code % { 5036 file.Write(code % {
5024 "name": func.name, 5037 "name": func.name,
5025 "typed_args": func.MakeTypedOriginalArgString(""), 5038 "typed_args": func.MakeTypedOriginalArgString(""),
5026 "args": func.MakeOriginalArgString(""), 5039 "args": func.MakeOriginalArgString(""),
5027 }) 5040 })
5028 5041
5029 def WriteImmediateFormatTest(self, func, file): 5042 def WriteImmediateFormatTest(self, func, file):
5030 """Overrriden from TypeHandler.""" 5043 """Overrriden from TypeHandler."""
5044 args = func.GetCmdArgs()
5045 count_param = 0
5046 for value, arg in enumerate(args):
5047 if arg.name == "count":
5048 count_param = int(arg.GetValidClientSideArg(func, value, 0))
5031 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name) 5049 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name)
5032 file.Write(" const int kSomeBaseValueToTestWith = 51;\n") 5050 file.Write(" const int kSomeBaseValueToTestWith = 51;\n")
5033 file.Write(" static %s data[] = {\n" % func.info.data_type) 5051 file.Write(" static %s data[] = {\n" % func.info.data_type)
5034 for v in range(0, func.info.count * 2): 5052 for v in range(0, func.info.count * count_param):
5035 file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" % 5053 file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" %
5036 (func.info.data_type, v)) 5054 (func.info.data_type, v))
5037 file.Write(" };\n") 5055 file.Write(" };\n")
5038 file.Write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" % 5056 file.Write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" %
5039 (func.name, func.name)) 5057 (func.name, func.name))
5040 file.Write(" const GLsizei kNumElements = 2;\n") 5058 file.Write(" const GLsizei kNumElements = %d;\n" % count_param)
5041 file.Write(" const size_t kExpectedCmdSize =\n") 5059 file.Write(" const size_t kExpectedCmdSize =\n")
5042 file.Write(" sizeof(cmd) + kNumElements * sizeof(%s) * %d;\n" % 5060 file.Write(" sizeof(cmd) + kNumElements * sizeof(%s) * %d;\n" %
5043 (func.info.data_type, func.info.count)) 5061 (func.info.data_type, func.info.count))
5044 file.Write(" void* next_cmd = cmd.Set(\n") 5062 file.Write(" void* next_cmd = cmd.Set(\n")
5045 file.Write(" &cmd") 5063 file.Write(" &cmd")
5046 args = func.GetCmdArgs()
5047 for value, arg in enumerate(args): 5064 for value, arg in enumerate(args):
5048 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value + 1)) 5065 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value + 1))
5049 file.Write(",\n data);\n") 5066 file.Write(",\n data);\n")
5050 args = func.GetCmdArgs()
5051 file.Write(" EXPECT_EQ(static_cast<uint32>(cmds::%s::kCmdId),\n" % 5067 file.Write(" EXPECT_EQ(static_cast<uint32>(cmds::%s::kCmdId),\n" %
5052 func.name) 5068 func.name)
5053 file.Write(" cmd.header.command);\n") 5069 file.Write(" cmd.header.command);\n")
5054 file.Write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n") 5070 file.Write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n")
5055 for value, arg in enumerate(args): 5071 for value, arg in enumerate(args):
5056 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % 5072 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" %
5057 (arg.type, value + 1, arg.name)) 5073 (arg.type, value + 1, arg.name))
5058 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n") 5074 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n")
5059 file.Write(" next_cmd, sizeof(cmd) +\n") 5075 file.Write(" next_cmd, sizeof(cmd) +\n")
5060 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n") 5076 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n")
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after
7645 gen.WriteGLES2Header("../GLES2/gl2chromium_autogen.h") 7661 gen.WriteGLES2Header("../GLES2/gl2chromium_autogen.h")
7646 7662
7647 if gen.errors > 0: 7663 if gen.errors > 0:
7648 print "%d errors" % gen.errors 7664 print "%d errors" % gen.errors
7649 return 1 7665 return 1
7650 return 0 7666 return 0
7651 7667
7652 7668
7653 if __name__ == '__main__': 7669 if __name__ == '__main__':
7654 sys.exit(main(sys.argv[1:])) 7670 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « gpu/GLES2/gl2extchromium.h ('k') | gpu/command_buffer/client/gles2_c_lib_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698