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

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

Issue 2175043002: Add command buffer function glScheduleCALayerFilterEffectsCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix autogenerated tests. Created 4 years, 5 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
« 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 4407 matching lines...) Expand 10 before | Expand all | Expand 10 after
4418 }, 4418 },
4419 'ScheduleCALayerSharedStateCHROMIUM': { 4419 'ScheduleCALayerSharedStateCHROMIUM': {
4420 'type': 'Custom', 4420 'type': 'Custom',
4421 'impl_func': False, 4421 'impl_func': False,
4422 'client_test': False, 4422 'client_test': False,
4423 'cmd_args': 'GLfloat opacity, GLboolean is_clipped, ' 4423 'cmd_args': 'GLfloat opacity, GLboolean is_clipped, '
4424 'GLint sorting_context_id, GLuint shm_id, GLuint shm_offset', 4424 'GLint sorting_context_id, GLuint shm_id, GLuint shm_offset',
4425 'extension': 'CHROMIUM_schedule_ca_layer', 4425 'extension': 'CHROMIUM_schedule_ca_layer',
4426 'chromium': True, 4426 'chromium': True,
4427 }, 4427 },
4428 'ScheduleCALayerFilterEffectsCHROMIUM': {
4429 'type': 'PUTn',
4430 'count': 1,
4431 'impl_func': False,
4432 'client_test': False,
4433 'decoder_func': 'DoScheduleCALayerFilterEffectsCHROMIUM',
4434 'cmd_args': 'GLsizei count, const GLCALayerFilterEffect* effects',
4435 'extension': 'CHROMIUM_schedule_ca_layer',
4436 'chromium': True,
4437 'unit_test': False,
4438 },
4428 'ScheduleCALayerCHROMIUM': { 4439 'ScheduleCALayerCHROMIUM': {
4429 'type': 'Custom', 4440 'type': 'Custom',
4430 'impl_func': False, 4441 'impl_func': False,
4431 'client_test': False, 4442 'client_test': False,
4432 'cmd_args': 'GLuint contents_texture_id, GLuint background_color, ' 4443 'cmd_args': 'GLuint contents_texture_id, GLuint background_color, '
4433 'GLuint edge_aa_mask, GLuint filter, GLuint shm_id, ' 4444 'GLuint edge_aa_mask, GLuint filter, GLuint shm_id, '
4434 'GLuint shm_offset', 4445 'GLuint shm_offset',
4435 'extension': 'CHROMIUM_schedule_ca_layer', 4446 'extension': 'CHROMIUM_schedule_ca_layer',
4436 'chromium': True, 4447 'chromium': True,
4437 }, 4448 },
(...skipping 3188 matching lines...) Expand 10 before | Expand all | Expand 10 after
7626 """ 7637 """
7627 f.write(code % (self.GetArrayType(func), 7638 f.write(code % (self.GetArrayType(func),
7628 self.GetArrayCount(func))) 7639 self.GetArrayCount(func)))
7629 if func.IsImmediate(): 7640 if func.IsImmediate():
7630 f.write(" if (data_size > immediate_data_size) {\n") 7641 f.write(" if (data_size > immediate_data_size) {\n")
7631 f.write(" return error::kOutOfBounds;\n") 7642 f.write(" return error::kOutOfBounds;\n")
7632 f.write(" }\n") 7643 f.write(" }\n")
7633 7644
7634 def WriteGLES2Implementation(self, func, f): 7645 def WriteGLES2Implementation(self, func, f):
7635 """Overrriden from TypeHandler.""" 7646 """Overrriden from TypeHandler."""
7636 f.write("%s GLES2Implementation::%s(%s) {\n" % 7647 impl_func = func.GetInfo('impl_func')
7637 (func.return_type, func.original_name, 7648 if impl_func == None or impl_func == True:
7638 func.MakeTypedOriginalArgString(""))) 7649 f.write("%s GLES2Implementation::%s(%s) {\n" %
7639 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") 7650 (func.return_type, func.original_name,
7640 func.WriteDestinationInitalizationValidation(f) 7651 func.MakeTypedOriginalArgString("")))
7641 self.WriteClientGLCallLog(func, f) 7652 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
7642 last_pointer_name = func.GetLastOriginalPointerArg().name 7653 func.WriteDestinationInitalizationValidation(f)
7643 f.write(""" GPU_CLIENT_LOG_CODE_BLOCK({ 7654 self.WriteClientGLCallLog(func, f)
7644 for (GLsizei i = 0; i < count; ++i) { 7655 last_pointer_name = func.GetLastOriginalPointerArg().name
7645 """) 7656 f.write(""" GPU_CLIENT_LOG_CODE_BLOCK({
7646 values_str = ' << ", " << '.join( 7657 for (GLsizei i = 0; i < count; ++i) {
7647 ["%s[%d + i * %d]" % ( 7658 """)
7648 last_pointer_name, ndx, self.GetArrayCount(func)) for ndx in range( 7659 values_str = ' << ", " << '.join(
7649 0, self.GetArrayCount(func))]) 7660 ["%s[%d + i * %d]" % (
7650 f.write(' GPU_CLIENT_LOG(" " << i << ": " << %s);\n' % values_str) 7661 last_pointer_name, ndx, self.GetArrayCount(func)) for ndx in
7651 f.write(" }\n });\n") 7662 range(0, self.GetArrayCount(func))])
7652 for arg in func.GetOriginalArgs(): 7663 f.write(' GPU_CLIENT_LOG(" " << i << ": " << %s);\n' % values_str)
7653 arg.WriteClientSideValidationCode(f, func) 7664 f.write(" }\n });\n")
7654 f.write(" helper_->%sImmediate(%s);\n" % 7665 for arg in func.GetOriginalArgs():
7655 (func.name, func.MakeInitString(""))) 7666 arg.WriteClientSideValidationCode(f, func)
7656 f.write(" CheckGLError();\n") 7667 f.write(" helper_->%sImmediate(%s);\n" %
7657 f.write("}\n") 7668 (func.name, func.MakeInitString("")))
7658 f.write("\n") 7669 f.write(" CheckGLError();\n")
7670 f.write("}\n")
7671 f.write("\n")
7659 7672
7660 def WriteGLES2ImplementationUnitTest(self, func, f): 7673 def WriteGLES2ImplementationUnitTest(self, func, f):
7661 """Writes the GLES2 Implemention unit test.""" 7674 """Writes the GLES2 Implemention unit test."""
7675 client_test = func.GetInfo('client_test')
7676 if client_test is not None and client_test == False:
7677 return
7662 code = """ 7678 code = """
7663 TEST_F(GLES2ImplementationTest, %(name)s) { 7679 TEST_F(GLES2ImplementationTest, %(name)s) {
7664 %(type)s data[%(count_param)d][%(count)d] = {{0}}; 7680 %(type)s data[%(count_param)d][%(count)d] = {{0}};
7665 struct Cmds { 7681 struct Cmds {
7666 cmds::%(name)sImmediate cmd; 7682 cmds::%(name)sImmediate cmd;
7667 %(type)s data[%(count_param)d][%(count)d]; 7683 %(type)s data[%(count_param)d][%(count)d];
7668 }; 7684 };
7669 7685
7670 Cmds expected; 7686 Cmds expected;
7671 for (int ii = 0; ii < %(count_param)d; ++ii) { 7687 for (int ii = 0; ii < %(count_param)d; ++ii) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
7820 7836
7821 def WriteImmediateFormatTest(self, func, f): 7837 def WriteImmediateFormatTest(self, func, f):
7822 """Overrriden from TypeHandler.""" 7838 """Overrriden from TypeHandler."""
7823 args = func.GetOriginalArgs() 7839 args = func.GetOriginalArgs()
7824 count_param = 0 7840 count_param = 0
7825 for arg in args: 7841 for arg in args:
7826 if arg.name == "count": 7842 if arg.name == "count":
7827 count_param = int(arg.GetValidClientSideCmdArg(func)) 7843 count_param = int(arg.GetValidClientSideCmdArg(func))
7828 f.write("TEST_F(GLES2FormatTest, %s) {\n" % func.name) 7844 f.write("TEST_F(GLES2FormatTest, %s) {\n" % func.name)
7829 f.write(" const int kSomeBaseValueToTestWith = 51;\n") 7845 f.write(" const int kSomeBaseValueToTestWith = 51;\n")
7830 f.write(" static %s data[] = {\n" % self.GetArrayType(func)) 7846 f.write(" const GLsizei kNumElements = %d;\n" % count_param)
7831 for v in range(0, self.GetArrayCount(func) * count_param): 7847 f.write(" std::vector<%s> vec;\n" % self.GetArrayType(func))
7832 f.write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" % 7848 f.write(" vec.resize(kNumElements * %d);\n" % self.GetArrayCount(func))
7833 (self.GetArrayType(func), v)) 7849 f.write(" memset(vec.data(), kSomeBaseValueToTestWith, \n")
7834 f.write(" };\n") 7850 f.write(" sizeof(%s) * vec.size());\n" % self.GetArrayType(func))
7835 f.write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" % 7851 f.write(" cmds::%s& cmd = *GetBufferAs<cmds::%s>();\n" %
7836 (func.name, func.name)) 7852 (func.name, func.name))
7837 f.write(" const GLsizei kNumElements = %d;\n" % count_param)
7838 f.write(" const size_t kExpectedCmdSize =\n") 7853 f.write(" const size_t kExpectedCmdSize =\n")
7839 f.write(" sizeof(cmd) + kNumElements * sizeof(%s) * %d;\n" % 7854 f.write(" sizeof(cmd) + kNumElements * sizeof(%s) * %d;\n" %
7840 (self.GetArrayType(func), self.GetArrayCount(func))) 7855 (self.GetArrayType(func), self.GetArrayCount(func)))
7841 f.write(" void* next_cmd = cmd.Set(\n") 7856 f.write(" void* next_cmd = cmd.Set(\n")
7842 f.write(" &cmd") 7857 f.write(" &cmd")
7843 for value, arg in enumerate(args): 7858 for value, arg in enumerate(args):
7844 if arg.IsPointer(): 7859 if arg.IsPointer():
7845 f.write(",\n data") 7860 f.write(",\n vec.data()")
7846 elif arg.IsConstant(): 7861 elif arg.IsConstant():
7847 continue 7862 continue
7848 else: 7863 else:
7849 f.write(",\n static_cast<%s>(%d)" % (arg.type, value + 1)) 7864 f.write(",\n static_cast<%s>(%d)" % (arg.type, value + 1))
7850 f.write(");\n") 7865 f.write(");\n")
7851 f.write(" EXPECT_EQ(static_cast<uint32_t>(cmds::%s::kCmdId),\n" % 7866 f.write(" EXPECT_EQ(static_cast<uint32_t>(cmds::%s::kCmdId),\n" %
7852 func.name) 7867 func.name)
7853 f.write(" cmd.header.command);\n") 7868 f.write(" cmd.header.command);\n")
7854 f.write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n") 7869 f.write(" EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);\n")
7855 for value, arg in enumerate(args): 7870 for value, arg in enumerate(args):
7856 if arg.IsPointer() or arg.IsConstant(): 7871 if arg.IsPointer() or arg.IsConstant():
7857 continue 7872 continue
7858 f.write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % 7873 f.write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" %
7859 (arg.type, value + 1, arg.name)) 7874 (arg.type, value + 1, arg.name))
7860 f.write(" CheckBytesWrittenMatchesExpectedSize(\n") 7875 f.write(" CheckBytesWrittenMatchesExpectedSize(\n")
7861 f.write(" next_cmd, sizeof(cmd) +\n") 7876 f.write(" next_cmd, sizeof(cmd) +\n")
7862 f.write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n") 7877 f.write(" RoundSizeToMultipleOfEntries(sizeof(\n")
7878 f.write(" %s) * vec.size()));\n" % self.GetArrayType(func))
7863 # TODO: Check that data was inserted 7879 # TODO: Check that data was inserted
7864 f.write("}\n") 7880 f.write("}\n")
7865 f.write("\n") 7881 f.write("\n")
7866 7882
7867 class PUTSTRHandler(ArrayArgTypeHandler): 7883 class PUTSTRHandler(ArrayArgTypeHandler):
7868 """Handler for functions that pass a string array.""" 7884 """Handler for functions that pass a string array."""
7869 7885
7870 def __GetDataArg(self, func): 7886 def __GetDataArg(self, func):
7871 """Return the argument that points to the 2D char arrays""" 7887 """Return the argument that points to the 2D char arrays"""
7872 for arg in func.GetOriginalArgs(): 7888 for arg in func.GetOriginalArgs():
(...skipping 3660 matching lines...) Expand 10 before | Expand all | Expand 10 after
11533 Format(gen.generated_cpp_filenames) 11549 Format(gen.generated_cpp_filenames)
11534 11550
11535 if gen.errors > 0: 11551 if gen.errors > 0:
11536 print "%d errors" % gen.errors 11552 print "%d errors" % gen.errors
11537 return 1 11553 return 1
11538 return 0 11554 return 0
11539 11555
11540 11556
11541 if __name__ == '__main__': 11557 if __name__ == '__main__':
11542 sys.exit(main(sys.argv[1:])) 11558 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