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

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

Issue 2076213002: Decompress ETC texture data when there is no native support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Validate PBOs 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
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 2306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 # file. These function info objects can be augmented and their values can be 2317 # file. These function info objects can be augmented and their values can be
2318 # overridden by adding an object to the table below. 2318 # overridden by adding an object to the table below.
2319 # 2319 #
2320 # Must match function names specified in "cmd_buffer_functions.txt". 2320 # Must match function names specified in "cmd_buffer_functions.txt".
2321 # 2321 #
2322 # cmd_comment: A comment added to the cmd format. 2322 # cmd_comment: A comment added to the cmd format.
2323 # type: defines which handler will be used to generate code. 2323 # type: defines which handler will be used to generate code.
2324 # decoder_func: defines which function to call in the decoder to execute the 2324 # decoder_func: defines which function to call in the decoder to execute the
2325 # corresponding GL command. If not specified the GL command will 2325 # corresponding GL command. If not specified the GL command will
2326 # be called directly. 2326 # be called directly.
2327 # check_decoder_func_result: Signals that the decoder_func returns an error
2328 # that should be checked. Defaults to False.
2327 # gl_test_func: GL function that is expected to be called when testing. 2329 # gl_test_func: GL function that is expected to be called when testing.
2328 # cmd_args: The arguments to use for the command. This overrides generating 2330 # cmd_args: The arguments to use for the command. This overrides generating
2329 # them based on the GL function arguments. 2331 # them based on the GL function arguments.
2330 # gen_cmd: Whether or not this function geneates a command. Default = True. 2332 # gen_cmd: Whether or not this function geneates a command. Default = True.
2331 # data_transfer_methods: Array of methods that are used for transfering the 2333 # data_transfer_methods: Array of methods that are used for transfering the
2332 # pointer data. Possible values: 'immediate', 'shm', 'bucket'. 2334 # pointer data. Possible values: 'immediate', 'shm', 'bucket'.
2333 # The default is 'immediate' if the command has one pointer 2335 # The default is 'immediate' if the command has one pointer
2334 # argument, otherwise 'shm'. One command is generated for each 2336 # argument, otherwise 'shm'. One command is generated for each
2335 # transfer method. Affects only commands which are not of type 2337 # transfer method. Affects only commands which are not of type
2336 # 'HandWritten', 'GETn' or 'GLcharN'. 2338 # 'HandWritten', 'GETn' or 'GLcharN'.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 'result': ['GLint'], 2597 'result': ['GLint'],
2596 'extension': 'GL_CHROMIUM_enable_feature', 2598 'extension': 'GL_CHROMIUM_enable_feature',
2597 'chromium': True, 2599 'chromium': True,
2598 'pepper_interface': 'ChromiumEnableFeature', 2600 'pepper_interface': 'ChromiumEnableFeature',
2599 }, 2601 },
2600 'CompileShader': {'decoder_func': 'DoCompileShader', 'unit_test': False}, 2602 'CompileShader': {'decoder_func': 'DoCompileShader', 'unit_test': False},
2601 'CompressedTexImage2D': { 2603 'CompressedTexImage2D': {
2602 'type': 'Data', 2604 'type': 'Data',
2603 'data_transfer_methods': ['bucket', 'shm'], 2605 'data_transfer_methods': ['bucket', 'shm'],
2604 'decoder_func': 'DoCompressedTexImage2D', 2606 'decoder_func': 'DoCompressedTexImage2D',
2607 'check_decoder_func_result': True,
2605 'trace_level': 1, 2608 'trace_level': 1,
2606 }, 2609 },
2607 'CompressedTexSubImage2D': { 2610 'CompressedTexSubImage2D': {
2608 'type': 'Data', 2611 'type': 'Data',
2609 'data_transfer_methods': ['bucket', 'shm'], 2612 'data_transfer_methods': ['bucket', 'shm'],
2610 'decoder_func': 'DoCompressedTexSubImage2D', 2613 'decoder_func': 'DoCompressedTexSubImage2D',
2614 'check_decoder_func_result': True,
2611 'trace_level': 1, 2615 'trace_level': 1,
2612 }, 2616 },
2613 'CopyTexImage2D': { 2617 'CopyTexImage2D': {
2614 'decoder_func': 'DoCopyTexImage2D', 2618 'decoder_func': 'DoCopyTexImage2D',
2615 'unit_test': False, 2619 'unit_test': False,
2616 'defer_reads': True, 2620 'defer_reads': True,
2617 'trace_level': 1, 2621 'trace_level': 1,
2618 }, 2622 },
2619 'CopyTexSubImage2D': { 2623 'CopyTexSubImage2D': {
2620 'decoder_func': 'DoCopyTexSubImage2D', 2624 'decoder_func': 'DoCopyTexSubImage2D',
2621 'defer_reads': True, 2625 'defer_reads': True,
2622 'trace_level': 1, 2626 'trace_level': 1,
2623 }, 2627 },
2624 'CompressedTexImage3D': { 2628 'CompressedTexImage3D': {
2625 'type': 'Data', 2629 'type': 'Data',
2626 'data_transfer_methods': ['bucket', 'shm'], 2630 'data_transfer_methods': ['bucket', 'shm'],
2627 'decoder_func': 'DoCompressedTexImage3D', 2631 'decoder_func': 'DoCompressedTexImage3D',
2632 'check_decoder_func_result': True,
2628 'unsafe': True, 2633 'unsafe': True,
2629 'trace_level': 1, 2634 'trace_level': 1,
2630 }, 2635 },
2631 'CompressedTexSubImage3D': { 2636 'CompressedTexSubImage3D': {
2632 'type': 'Data', 2637 'type': 'Data',
2633 'data_transfer_methods': ['bucket', 'shm'], 2638 'data_transfer_methods': ['bucket', 'shm'],
2634 'decoder_func': 'DoCompressedTexSubImage3D', 2639 'decoder_func': 'DoCompressedTexSubImage3D',
2640 'check_decoder_func_result': True,
2635 'unsafe': True, 2641 'unsafe': True,
2636 'trace_level': 1, 2642 'trace_level': 1,
2637 }, 2643 },
2638 'CopyTexSubImage3D': { 2644 'CopyTexSubImage3D': {
2639 'defer_reads': True, 2645 'defer_reads': True,
2640 'unsafe': True, 2646 'unsafe': True,
2641 'trace_level': 1, 2647 'trace_level': 1,
2642 }, 2648 },
2643 'CreateImageCHROMIUM': { 2649 'CreateImageCHROMIUM': {
2644 'type': 'Manual', 2650 'type': 'Manual',
(...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after
4946 pass 4952 pass
4947 4953
4948 def __WriteIdMapping(self, func, f): 4954 def __WriteIdMapping(self, func, f):
4949 """Writes client side / service side ID mapping.""" 4955 """Writes client side / service side ID mapping."""
4950 if not func.IsUnsafe() or not func.GetInfo('id_mapping'): 4956 if not func.IsUnsafe() or not func.GetInfo('id_mapping'):
4951 return 4957 return
4952 for id_type in func.GetInfo('id_mapping'): 4958 for id_type in func.GetInfo('id_mapping'):
4953 f.write(" group_->Get%sServiceId(%s, &%s);\n" % 4959 f.write(" group_->Get%sServiceId(%s, &%s);\n" %
4954 (id_type, id_type.lower(), id_type.lower())) 4960 (id_type, id_type.lower(), id_type.lower()))
4955 4961
4962 def WriteGLFunctionCallCode(self, func, f):
4963 """Writes the call to the GL function."""
4964 if func.ShouldCheckGLFunctionResult():
4965 f.write(" error::Error error = ")
4966 f.write(" %s(%s);\n" %
4967 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
4968 if func.ShouldCheckGLFunctionResult():
4969 f.write(" if (error != error::kNoError)")
4970 f.write(" return error;")
4971
4956 def WriteImmediateHandlerImplementation (self, func, f): 4972 def WriteImmediateHandlerImplementation (self, func, f):
4957 """Writes the handler impl for the immediate version of a command.""" 4973 """Writes the handler impl for the immediate version of a command."""
4958 self.__WriteIdMapping(func, f) 4974 self.__WriteIdMapping(func, f)
4959 f.write(" %s(%s);\n" % 4975 self.WriteGLFunctionCallCode(func, f)
4960 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
4961 4976
4962 def WriteBucketHandlerImplementation (self, func, f): 4977 def WriteBucketHandlerImplementation (self, func, f):
4963 """Writes the handler impl for the bucket version of a command.""" 4978 """Writes the handler impl for the bucket version of a command."""
4964 self.__WriteIdMapping(func, f) 4979 self.__WriteIdMapping(func, f)
4965 f.write(" %s(%s);\n" % 4980 self.WriteGLFunctionCallCode(func, f)
4966 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
4967 4981
4968 def WriteServiceHandlerFunctionHeader(self, func, f): 4982 def WriteServiceHandlerFunctionHeader(self, func, f):
4969 """Writes function header for service implementation handlers.""" 4983 """Writes function header for service implementation handlers."""
4970 f.write("""error::Error GLES2DecoderImpl::Handle%(name)s( 4984 f.write("""error::Error GLES2DecoderImpl::Handle%(name)s(
4971 uint32_t immediate_data_size, const void* cmd_data) { 4985 uint32_t immediate_data_size, const void* cmd_data) {
4972 """ % {'name': func.name}) 4986 """ % {'name': func.name})
4973 if func.IsUnsafe(): 4987 if func.IsUnsafe():
4974 f.write("""if (!unsafe_es3_apis_enabled()) 4988 f.write("""if (!unsafe_es3_apis_enabled())
4975 return error::kUnknownCommand; 4989 return error::kUnknownCommand;
4976 """) 4990 """)
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
5520 f.write(" if (%s) {\n" % " ||\n ".join(code)) 5534 f.write(" if (%s) {\n" % " ||\n ".join(code))
5521 for ndx,item in enumerate(states): 5535 for ndx,item in enumerate(states):
5522 f.write(" state_.%s = %s;\n" % (item['name'], args[ndx].name)) 5536 f.write(" state_.%s = %s;\n" % (item['name'], args[ndx].name))
5523 if 'state_flag' in state: 5537 if 'state_flag' in state:
5524 f.write(" %s = true;\n" % state['state_flag']) 5538 f.write(" %s = true;\n" % state['state_flag'])
5525 if not func.GetInfo("no_gl"): 5539 if not func.GetInfo("no_gl"):
5526 for ndx,item in enumerate(states): 5540 for ndx,item in enumerate(states):
5527 if item.get('cached', False): 5541 if item.get('cached', False):
5528 f.write(" state_.%s = %s;\n" % 5542 f.write(" state_.%s = %s;\n" %
5529 (CachedStateName(item), args[ndx].name)) 5543 (CachedStateName(item), args[ndx].name))
5530 f.write(" %s(%s);\n" % 5544 self.WriteGLFunctionCallCode(func, f)
5531 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
5532 f.write(" }\n") 5545 f.write(" }\n")
5533 5546
5534 def WriteServiceUnitTest(self, func, f, *extras): 5547 def WriteServiceUnitTest(self, func, f, *extras):
5535 """Overrriden from TypeHandler.""" 5548 """Overrriden from TypeHandler."""
5536 TypeHandler.WriteServiceUnitTest(self, func, f, *extras) 5549 TypeHandler.WriteServiceUnitTest(self, func, f, *extras)
5537 state_name = func.GetInfo('state') 5550 state_name = func.GetInfo('state')
5538 state = _STATES[state_name] 5551 state = _STATES[state_name]
5539 states = state['states'] 5552 states = state['states']
5540 for ndx,item in enumerate(states): 5553 for ndx,item in enumerate(states):
5541 if 'range_checks' in item: 5554 if 'range_checks' in item:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
5605 code = [] 5618 code = []
5606 for ndx,item in enumerate(states): 5619 for ndx,item in enumerate(states):
5607 code.append("state_.%s != %s" % (item['name'], args[ndx % num_args].name)) 5620 code.append("state_.%s != %s" % (item['name'], args[ndx % num_args].name))
5608 f.write(" if (%s) {\n" % " ||\n ".join(code)) 5621 f.write(" if (%s) {\n" % " ||\n ".join(code))
5609 for ndx, item in enumerate(states): 5622 for ndx, item in enumerate(states):
5610 f.write(" state_.%s = %s;\n" % 5623 f.write(" state_.%s = %s;\n" %
5611 (item['name'], args[ndx % num_args].name)) 5624 (item['name'], args[ndx % num_args].name))
5612 if 'state_flag' in state: 5625 if 'state_flag' in state:
5613 f.write(" %s = true;\n" % state['state_flag']) 5626 f.write(" %s = true;\n" % state['state_flag'])
5614 if not func.GetInfo("no_gl"): 5627 if not func.GetInfo("no_gl"):
5615 f.write(" %s(%s);\n" % 5628 self.WriteGLFunctionCallCode(func, f)
5616 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
5617 f.write(" }\n") 5629 f.write(" }\n")
5618 5630
5619 5631
5620 class StateSetFrontBackSeparateHandler(TypeHandler): 5632 class StateSetFrontBackSeparateHandler(TypeHandler):
5621 """Handler for commands that simply set state that have front/back.""" 5633 """Handler for commands that simply set state that have front/back."""
5622 5634
5623 def WriteHandlerImplementation(self, func, f): 5635 def WriteHandlerImplementation(self, func, f):
5624 """Overrriden from TypeHandler.""" 5636 """Overrriden from TypeHandler."""
5625 state_name = func.GetInfo('state') 5637 state_name = func.GetInfo('state')
5626 state = _STATES[state_name] 5638 state = _STATES[state_name]
(...skipping 14 matching lines...) Expand all
5641 for group_ndx, group in enumerate(Grouper(num_args - 1, states)): 5653 for group_ndx, group in enumerate(Grouper(num_args - 1, states)):
5642 f.write(" if (%s == %s || %s == GL_FRONT_AND_BACK) {\n" % 5654 f.write(" if (%s == %s || %s == GL_FRONT_AND_BACK) {\n" %
5643 (face, ('GL_FRONT', 'GL_BACK')[group_ndx], face)) 5655 (face, ('GL_FRONT', 'GL_BACK')[group_ndx], face))
5644 for ndx, item in enumerate(group): 5656 for ndx, item in enumerate(group):
5645 f.write(" state_.%s = %s;\n" % 5657 f.write(" state_.%s = %s;\n" %
5646 (item['name'], args[ndx + 1].name)) 5658 (item['name'], args[ndx + 1].name))
5647 f.write(" }\n") 5659 f.write(" }\n")
5648 if 'state_flag' in state: 5660 if 'state_flag' in state:
5649 f.write(" %s = true;\n" % state['state_flag']) 5661 f.write(" %s = true;\n" % state['state_flag'])
5650 if not func.GetInfo("no_gl"): 5662 if not func.GetInfo("no_gl"):
5651 f.write(" %s(%s);\n" % 5663 self.WriteGLFunctionCallCode(func, f)
5652 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
5653 f.write(" }\n") 5664 f.write(" }\n")
5654 5665
5655 5666
5656 class StateSetFrontBackHandler(TypeHandler): 5667 class StateSetFrontBackHandler(TypeHandler):
5657 """Handler for commands that simply set state that set both front/back.""" 5668 """Handler for commands that simply set state that set both front/back."""
5658 5669
5659 def WriteHandlerImplementation(self, func, f): 5670 def WriteHandlerImplementation(self, func, f):
5660 """Overrriden from TypeHandler.""" 5671 """Overrriden from TypeHandler."""
5661 state_name = func.GetInfo('state') 5672 state_name = func.GetInfo('state')
5662 state = _STATES[state_name] 5673 state = _STATES[state_name]
5663 states = state['states'] 5674 states = state['states']
5664 args = func.GetOriginalArgs() 5675 args = func.GetOriginalArgs()
5665 num_args = len(args) 5676 num_args = len(args)
5666 code = [] 5677 code = []
5667 for group_ndx, group in enumerate(Grouper(num_args, states)): 5678 for group_ndx, group in enumerate(Grouper(num_args, states)):
5668 for ndx, item in enumerate(group): 5679 for ndx, item in enumerate(group):
5669 code.append("state_.%s != %s" % (item['name'], args[ndx].name)) 5680 code.append("state_.%s != %s" % (item['name'], args[ndx].name))
5670 f.write(" if (%s) {\n" % " ||\n ".join(code)) 5681 f.write(" if (%s) {\n" % " ||\n ".join(code))
5671 for group_ndx, group in enumerate(Grouper(num_args, states)): 5682 for group_ndx, group in enumerate(Grouper(num_args, states)):
5672 for ndx, item in enumerate(group): 5683 for ndx, item in enumerate(group):
5673 f.write(" state_.%s = %s;\n" % (item['name'], args[ndx].name)) 5684 f.write(" state_.%s = %s;\n" % (item['name'], args[ndx].name))
5674 if 'state_flag' in state: 5685 if 'state_flag' in state:
5675 f.write(" %s = true;\n" % state['state_flag']) 5686 f.write(" %s = true;\n" % state['state_flag'])
5676 if not func.GetInfo("no_gl"): 5687 if not func.GetInfo("no_gl"):
5677 f.write(" %s(%s);\n" % 5688 self.WriteGLFunctionCallCode(func, f)
5678 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
5679 f.write(" }\n") 5689 f.write(" }\n")
5680 5690
5681 5691
5682 class StateSetNamedParameter(TypeHandler): 5692 class StateSetNamedParameter(TypeHandler):
5683 """Handler for commands that set a state chosen with an enum parameter.""" 5693 """Handler for commands that set a state chosen with an enum parameter."""
5684 5694
5685 def WriteHandlerImplementation(self, func, f): 5695 def WriteHandlerImplementation(self, func, f):
5686 """Overridden from TypeHandler.""" 5696 """Overridden from TypeHandler."""
5687 state_name = func.GetInfo('state') 5697 state_name = func.GetInfo('state')
5688 state = _STATES[state_name] 5698 state = _STATES[state_name]
(...skipping 3967 matching lines...) Expand 10 before | Expand all | Expand 10 after
9656 elif "*" in self.return_type: 9666 elif "*" in self.return_type:
9657 return "NULL" 9667 return "NULL"
9658 return "0" 9668 return "0"
9659 9669
9660 def GetGLFunctionName(self): 9670 def GetGLFunctionName(self):
9661 """Gets the function to call to execute GL for this command.""" 9671 """Gets the function to call to execute GL for this command."""
9662 if self.GetInfo('decoder_func'): 9672 if self.GetInfo('decoder_func'):
9663 return self.GetInfo('decoder_func') 9673 return self.GetInfo('decoder_func')
9664 return "gl%s" % self.original_name 9674 return "gl%s" % self.original_name
9665 9675
9676 def ShouldCheckGLFunctionResult(self):
9677 return self.GetInfo('check_decoder_func_result', False)
9678
9666 def GetGLTestFunctionName(self): 9679 def GetGLTestFunctionName(self):
9667 gl_func_name = self.GetInfo('gl_test_func') 9680 gl_func_name = self.GetInfo('gl_test_func')
9668 if gl_func_name == None: 9681 if gl_func_name == None:
9669 gl_func_name = self.GetGLFunctionName() 9682 gl_func_name = self.GetGLFunctionName()
9670 if gl_func_name.startswith("gl"): 9683 if gl_func_name.startswith("gl"):
9671 gl_func_name = gl_func_name[2:] 9684 gl_func_name = gl_func_name[2:]
9672 else: 9685 else:
9673 gl_func_name = self.original_name 9686 gl_func_name = self.original_name
9674 return gl_func_name 9687 return gl_func_name
9675 9688
(...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after
11524 Format(gen.generated_cpp_filenames) 11537 Format(gen.generated_cpp_filenames)
11525 11538
11526 if gen.errors > 0: 11539 if gen.errors > 0:
11527 print "%d errors" % gen.errors 11540 print "%d errors" % gen.errors
11528 return 1 11541 return 1
11529 return 0 11542 return 0
11530 11543
11531 11544
11532 if __name__ == '__main__': 11545 if __name__ == '__main__':
11533 sys.exit(main(sys.argv[1:])) 11546 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698