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

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
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 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 }, 2137 },
2138 'DrawArraysInstancedANGLE': { 2138 'DrawArraysInstancedANGLE': {
2139 'type': 'Manual', 2139 'type': 'Manual',
2140 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count, ' 2140 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count, '
2141 'GLsizei primcount', 2141 'GLsizei primcount',
2142 'extension': True, 2142 'extension': True,
2143 'unit_test': False, 2143 'unit_test': False,
2144 'pepper_interface': 'InstancedArrays', 2144 'pepper_interface': 'InstancedArrays',
2145 'defer_draws': True, 2145 'defer_draws': True,
2146 }, 2146 },
2147 'DrawBuffersEXT': {
2148 'type': 'PUTn',
2149 'decoder_func': 'DoDrawBuffersEXT',
2150 'data_type': 'GLenum',
2151 'count': 1,
2152 'client_test': False,
2153 'unit_test': False,
2154 'extension': True,
2155 },
2147 'DrawElementsInstancedANGLE': { 2156 'DrawElementsInstancedANGLE': {
2148 'type': 'Manual', 2157 'type': 'Manual',
2149 'cmd_args': 'GLenumDrawMode mode, GLsizei count, ' 2158 'cmd_args': 'GLenumDrawMode mode, GLsizei count, '
2150 'GLenumIndexType type, GLuint index_offset, GLsizei primcount', 2159 'GLenumIndexType type, GLuint index_offset, GLsizei primcount',
2151 'extension': True, 2160 'extension': True,
2152 'unit_test': False, 2161 'unit_test': False,
2153 'client_test': False, 2162 'client_test': False,
2154 'pepper_interface': 'InstancedArrays', 2163 'pepper_interface': 'InstancedArrays',
2155 'defer_draws': True, 2164 'defer_draws': True,
2156 }, 2165 },
(...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after
4889 file.Write(" CheckGLError();\n") 4898 file.Write(" CheckGLError();\n")
4890 file.Write("}\n") 4899 file.Write("}\n")
4891 file.Write("\n") 4900 file.Write("\n")
4892 4901
4893 def WriteGLES2ImplementationUnitTest(self, func, file): 4902 def WriteGLES2ImplementationUnitTest(self, func, file):
4894 """Writes the GLES2 Implemention unit test.""" 4903 """Writes the GLES2 Implemention unit test."""
4895 code = """ 4904 code = """
4896 TEST_F(GLES2ImplementationTest, %(name)s) { 4905 TEST_F(GLES2ImplementationTest, %(name)s) {
4897 struct Cmds { 4906 struct Cmds {
4898 cmds::%(name)sImmediate cmd; 4907 cmds::%(name)sImmediate cmd;
4899 %(type)s data[2][%(count)d]; 4908 %(type)s data[%(count_param)d][%(count)d];
4900 }; 4909 };
4901 4910
4902 Cmds expected; 4911 Cmds expected;
4903 for (int ii = 0; ii < 2; ++ii) { 4912 for (int ii = 0; ii < %(count_param)d; ++ii) {
4904 for (int jj = 0; jj < %(count)d; ++jj) { 4913 for (int jj = 0; jj < %(count)d; ++jj) {
4905 expected.data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj); 4914 expected.data[ii][jj] = static_cast<%(type)s>(ii * %(count)d + jj);
4906 } 4915 }
4907 } 4916 }
4908 expected.cmd.Init(%(cmd_args)s, &expected.data[0][0]); 4917 expected.cmd.Init(%(cmd_args)s, &expected.data[0][0]);
4909 gl_->%(name)s(%(args)s, &expected.data[0][0]); 4918 gl_->%(name)s(%(args)s, &expected.data[0][0]);
4910 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 4919 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
4911 } 4920 }
4912 """ 4921 """
4913 cmd_arg_strings = [] 4922 cmd_arg_strings = []
4914 for count, arg in enumerate(func.GetCmdArgs()[0:-2]): 4923 for count, arg in enumerate(func.GetCmdArgs()[0:-2]):
4915 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) 4924 cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0))
4916 gl_arg_strings = [] 4925 gl_arg_strings = []
4926 count_param = 0
4917 for count, arg in enumerate(func.GetOriginalArgs()[0:-1]): 4927 for count, arg in enumerate(func.GetOriginalArgs()[0:-1]):
4918 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) 4928 gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0))
4929 if arg.name == "count":
4930 count_param = int(arg.GetValidClientSideArg(func, count, 0))
4919 file.Write(code % { 4931 file.Write(code % {
4920 'name': func.name, 4932 'name': func.name,
4921 'type': func.GetInfo('data_type'), 4933 'type': func.GetInfo('data_type'),
4922 'count': func.GetInfo('count'), 4934 'count': func.GetInfo('count'),
4923 'args': ", ".join(gl_arg_strings), 4935 'args': ", ".join(gl_arg_strings),
4924 'cmd_args': ", ".join(cmd_arg_strings), 4936 'cmd_args': ", ".join(cmd_arg_strings),
4937 'count_param': count_param,
4925 }) 4938 })
4926 4939
4927 def WriteImmediateCmdComputeSize(self, func, file): 4940 def WriteImmediateCmdComputeSize(self, func, file):
4928 """Overrriden from TypeHandler.""" 4941 """Overrriden from TypeHandler."""
4929 file.Write(" static uint32 ComputeDataSize(GLsizei count) {\n") 4942 file.Write(" static uint32 ComputeDataSize(GLsizei count) {\n")
4930 file.Write(" return static_cast<uint32>(\n") 4943 file.Write(" return static_cast<uint32>(\n")
4931 file.Write(" sizeof(%s) * %d * count); // NOLINT\n" % 4944 file.Write(" sizeof(%s) * %d * count); // NOLINT\n" %
4932 (func.info.data_type, func.info.count)) 4945 (func.info.data_type, func.info.count))
4933 file.Write(" }\n") 4946 file.Write(" }\n")
4934 file.Write("\n") 4947 file.Write("\n")
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4990 5003
4991 """ 5004 """
4992 file.Write(code % { 5005 file.Write(code % {
4993 "name": func.name, 5006 "name": func.name,
4994 "typed_args": func.MakeTypedOriginalArgString(""), 5007 "typed_args": func.MakeTypedOriginalArgString(""),
4995 "args": func.MakeOriginalArgString(""), 5008 "args": func.MakeOriginalArgString(""),
4996 }) 5009 })
4997 5010
4998 def WriteImmediateFormatTest(self, func, file): 5011 def WriteImmediateFormatTest(self, func, file):
4999 """Overrriden from TypeHandler.""" 5012 """Overrriden from TypeHandler."""
5013 args = func.GetCmdArgs()
5014 count_param = 0
5015 for value, arg in enumerate(args):
5016 if arg.name == "count":
5017 count_param = int(arg.GetValidClientSideArg(func, value, 0))
5000 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name) 5018 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name)
5001 file.Write(" const int kSomeBaseValueToTestWith = 51;\n") 5019 file.Write(" const int kSomeBaseValueToTestWith = 51;\n")
5002 file.Write(" static %s data[] = {\n" % func.info.data_type) 5020 file.Write(" static %s data[] = {\n" % func.info.data_type)
5003 for v in range(0, func.info.count * 2): 5021 for v in range(0, func.info.count * count_param):
5004 file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" % 5022 file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" %
5005 (func.info.data_type, v)) 5023 (func.info.data_type, v))
5006 file.Write(" };\n") 5024 file.Write(" };\n")
5007 file.Write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" % 5025 file.Write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" %
5008 (func.name, func.name)) 5026 (func.name, func.name))
5009 file.Write(" const GLsizei kNumElements = 2;\n") 5027 file.Write(" const GLsizei kNumElements = %d;\n" % count_param)
5010 file.Write(" const size_t kExpectedCmdSize =\n") 5028 file.Write(" const size_t kExpectedCmdSize =\n")
5011 file.Write(" sizeof(cmd) + kNumElements * sizeof(%s) * %d;\n" % 5029 file.Write(" sizeof(cmd) + kNumElements * sizeof(%s) * %d;\n" %
5012 (func.info.data_type, func.info.count)) 5030 (func.info.data_type, func.info.count))
5013 file.Write(" void* next_cmd = cmd.Set(\n") 5031 file.Write(" void* next_cmd = cmd.Set(\n")
5014 file.Write(" &cmd") 5032 file.Write(" &cmd")
5015 args = func.GetCmdArgs()
5016 for value, arg in enumerate(args): 5033 for value, arg in enumerate(args):
5017 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value + 1)) 5034 file.Write(",\n static_cast<%s>(%d)" % (arg.type, value + 1))
5018 file.Write(",\n data);\n") 5035 file.Write(",\n data);\n")
5019 args = func.GetCmdArgs()
5020 file.Write(" EXPECT_EQ(static_cast<uint32>(cmds::%s::kCmdId),\n" % 5036 file.Write(" EXPECT_EQ(static_cast<uint32>(cmds::%s::kCmdId),\n" %
5021 func.name) 5037 func.name)
5022 file.Write(" cmd.header.command);\n") 5038 file.Write(" cmd.header.command);\n")
5023 file.Write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n") 5039 file.Write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n")
5024 for value, arg in enumerate(args): 5040 for value, arg in enumerate(args):
5025 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % 5041 file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" %
5026 (arg.type, value + 1, arg.name)) 5042 (arg.type, value + 1, arg.name))
5027 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n") 5043 file.Write(" CheckBytesWrittenMatchesExpectedSize(\n")
5028 file.Write(" next_cmd, sizeof(cmd) +\n") 5044 file.Write(" next_cmd, sizeof(cmd) +\n")
5029 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n") 5045 file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n")
(...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after
7612 gen.WriteGLES2Header("../GLES2/gl2chromium_autogen.h") 7628 gen.WriteGLES2Header("../GLES2/gl2chromium_autogen.h")
7613 7629
7614 if gen.errors > 0: 7630 if gen.errors > 0:
7615 print "%d errors" % gen.errors 7631 print "%d errors" % gen.errors
7616 return 1 7632 return 1
7617 return 0 7633 return 0
7618 7634
7619 7635
7620 if __name__ == '__main__': 7636 if __name__ == '__main__':
7621 sys.exit(main(sys.argv[1:])) 7637 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698