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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 'IndexedBufferTarget': { 591 'IndexedBufferTarget': {
592 'type': 'GLenum', 592 'type': 'GLenum',
593 'valid': [ 593 'valid': [
594 'GL_TRANSFORM_FEEDBACK_BUFFER', 594 'GL_TRANSFORM_FEEDBACK_BUFFER',
595 'GL_UNIFORM_BUFFER', 595 'GL_UNIFORM_BUFFER',
596 ], 596 ],
597 'invalid': [ 597 'invalid': [
598 'GL_RENDERBUFFER', 598 'GL_RENDERBUFFER',
599 ], 599 ],
600 }, 600 },
601 'Bufferiv': {
602 'type': 'GLenum',
603 'valid': [
604 'GL_COLOR',
605 'GL_STENCIL',
606 ],
607 'invalid': [
608 'GL_RENDERBUFFER',
609 ],
610 },
611 'Bufferuiv': {
612 'type': 'GLenum',
613 'valid': [
614 'GL_COLOR',
615 ],
616 'invalid': [
617 'GL_RENDERBUFFER',
618 ],
619 },
620 'Bufferfv': {
621 'type': 'GLenum',
622 'valid': [
623 'GL_COLOR',
624 'GL_DEPTH',
625 ],
626 'invalid': [
627 'GL_RENDERBUFFER',
628 ],
629 },
630 'Bufferfi': {
631 'type': 'GLenum',
632 'valid': [
633 'GL_DEPTH_STENCIL',
634 ],
635 'invalid': [
636 'GL_RENDERBUFFER',
637 ],
638 },
601 'BufferUsage': { 639 'BufferUsage': {
602 'type': 'GLenum', 640 'type': 'GLenum',
603 'valid': [ 641 'valid': [
604 'GL_STREAM_DRAW', 642 'GL_STREAM_DRAW',
605 'GL_STATIC_DRAW', 643 'GL_STATIC_DRAW',
606 'GL_DYNAMIC_DRAW', 644 'GL_DYNAMIC_DRAW',
607 ], 645 ],
608 'invalid': [ 646 'invalid': [
609 'GL_STATIC_READ', 647 'GL_STATIC_READ',
610 ], 648 ],
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 # transfer method. Affects only commands which are not of type 1408 # transfer method. Affects only commands which are not of type
1371 # 'HandWritten', 'GETn' or 'GLcharN'. 1409 # 'HandWritten', 'GETn' or 'GLcharN'.
1372 # Note: the command arguments that affect this are the final args, 1410 # Note: the command arguments that affect this are the final args,
1373 # taking cmd_args override into consideration. 1411 # taking cmd_args override into consideration.
1374 # impl_func: Whether or not to generate the GLES2Implementation part of this 1412 # impl_func: Whether or not to generate the GLES2Implementation part of this
1375 # command. 1413 # command.
1376 # impl_decl: Whether or not to generate the GLES2Implementation declaration 1414 # impl_decl: Whether or not to generate the GLES2Implementation declaration
1377 # for this command. 1415 # for this command.
1378 # needs_size: If True a data_size field is added to the command. 1416 # needs_size: If True a data_size field is added to the command.
1379 # count: The number of units per element. For PUTn or PUT types. 1417 # count: The number of units per element. For PUTn or PUT types.
1418 # use_count_func: If True the actual data count needs to be computed; the count
1419 # argument specifies the maximum count.
1380 # unit_test: If False no service side unit test will be generated. 1420 # unit_test: If False no service side unit test will be generated.
1381 # client_test: If False no client side unit test will be generated. 1421 # client_test: If False no client side unit test will be generated.
1382 # expectation: If False the unit test will have no expected calls. 1422 # expectation: If False the unit test will have no expected calls.
1383 # gen_func: Name of function that generates GL resource for corresponding 1423 # gen_func: Name of function that generates GL resource for corresponding
1384 # bind function. 1424 # bind function.
1385 # states: array of states that get set by this function corresponding to 1425 # states: array of states that get set by this function corresponding to
1386 # the given arguments 1426 # the given arguments
1387 # state_flag: name of flag that is set to true when function is called. 1427 # state_flag: name of flag that is set to true when function is called.
1388 # no_gl: no GL function is called. 1428 # no_gl: no GL function is called.
1389 # valid_args: A dictionary of argument indices to args to use in unit tests 1429 # valid_args: A dictionary of argument indices to args to use in unit tests
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 'decoder_func': 'DoCheckFramebufferStatus', 1537 'decoder_func': 'DoCheckFramebufferStatus',
1498 'gl_test_func': 'glCheckFramebufferStatusEXT', 1538 'gl_test_func': 'glCheckFramebufferStatusEXT',
1499 'error_value': 'GL_FRAMEBUFFER_UNSUPPORTED', 1539 'error_value': 'GL_FRAMEBUFFER_UNSUPPORTED',
1500 'result': ['GLenum'], 1540 'result': ['GLenum'],
1501 }, 1541 },
1502 'Clear': { 1542 'Clear': {
1503 'decoder_func': 'DoClear', 1543 'decoder_func': 'DoClear',
1504 'defer_draws': True, 1544 'defer_draws': True,
1505 'trace_level': 1, 1545 'trace_level': 1,
1506 }, 1546 },
1547 'ClearBufferiv': {
1548 'type': 'PUT',
1549 'use_count_func': True,
1550 'count': 4,
1551 'unsafe': True,
1552 },
1553 'ClearBufferuiv': {
1554 'type': 'PUT',
1555 'count': 4,
1556 'unsafe': True,
1557 },
1558 'ClearBufferfv': {
1559 'type': 'PUT',
1560 'use_count_func': True,
1561 'count': 4,
1562 'unsafe': True,
1563 },
1564 'ClearBufferfi': {
1565 'unsafe': True,
1566 },
1507 'ClearColor': { 1567 'ClearColor': {
1508 'type': 'StateSet', 1568 'type': 'StateSet',
1509 'state': 'ClearColor', 1569 'state': 'ClearColor',
1510 }, 1570 },
1511 'ClearDepthf': { 1571 'ClearDepthf': {
1512 'type': 'StateSet', 1572 'type': 'StateSet',
1513 'state': 'ClearDepthf', 1573 'state': 'ClearDepthf',
1514 'decoder_func': 'glClearDepth', 1574 'decoder_func': 'glClearDepth',
1515 'gl_test_func': 'glClearDepth', 1575 'gl_test_func': 'glClearDepth',
1516 'valid_args': { 1576 'valid_args': {
(...skipping 4100 matching lines...) Expand 10 before | Expand all | Expand 10 after
5617 if (!ComputeDataSize(1, sizeof(%s), %d, &data_size)) { 5677 if (!ComputeDataSize(1, sizeof(%s), %d, &data_size)) {
5618 return error::kOutOfBounds; 5678 return error::kOutOfBounds;
5619 } 5679 }
5620 """ 5680 """
5621 file.Write(code % (self.GetArrayType(func), self.GetArrayCount(func))) 5681 file.Write(code % (self.GetArrayType(func), self.GetArrayCount(func)))
5622 if func.IsImmediate(): 5682 if func.IsImmediate():
5623 file.Write(" if (data_size > immediate_data_size) {\n") 5683 file.Write(" if (data_size > immediate_data_size) {\n")
5624 file.Write(" return error::kOutOfBounds;\n") 5684 file.Write(" return error::kOutOfBounds;\n")
5625 file.Write(" }\n") 5685 file.Write(" }\n")
5626 5686
5687 def __NeedsToCalcDataCount(self, func):
5688 use_count_func = func.GetInfo('use_count_func')
5689 return use_count_func != None and use_count_func != False
5690
5627 def WriteGLES2Implementation(self, func, file): 5691 def WriteGLES2Implementation(self, func, file):
5628 """Overrriden from TypeHandler.""" 5692 """Overrriden from TypeHandler."""
5629 impl_func = func.GetInfo('impl_func') 5693 impl_func = func.GetInfo('impl_func')
5630 if (impl_func != None and impl_func != True): 5694 if (impl_func != None and impl_func != True):
5631 return; 5695 return;
5632 file.Write("%s GLES2Implementation::%s(%s) {\n" % 5696 file.Write("%s GLES2Implementation::%s(%s) {\n" %
5633 (func.return_type, func.original_name, 5697 (func.return_type, func.original_name,
5634 func.MakeTypedOriginalArgString(""))) 5698 func.MakeTypedOriginalArgString("")))
5635 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") 5699 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
5636 func.WriteDestinationInitalizationValidation(file) 5700 func.WriteDestinationInitalizationValidation(file)
5637 self.WriteClientGLCallLog(func, file) 5701 self.WriteClientGLCallLog(func, file)
5638 last_arg_name = func.GetLastOriginalArg().name 5702
5639 values_str = ' << ", " << '.join( 5703 if self.__NeedsToCalcDataCount(func):
5640 ["%s[%d]" % (last_arg_name, ndx) \ 5704 file.Write(" size_t count = GLES2Util::Calc%sDataCount(%s);\n" %
5641 for ndx in range(0, self.GetArrayCount(func))]) 5705 (func.name, func.GetOriginalArgs()[0].name))
5642 file.Write(' GPU_CLIENT_LOG("values: " << %s);\n' % values_str) 5706 file.Write(" DCHECK_LE(count, %du);\n" % self.GetArrayCount(func))
5707 else:
5708 file.Write(" size_t count = %d;" % self.GetArrayCount(func))
5709 file.Write(" for (size_t ii = 0; ii < count; ++ii)\n")
5710 file.Write(' GPU_CLIENT_LOG("value[" << ii << "]: " << %s[ii]);\n' %
5711 func.GetLastOriginalArg().name)
5643 for arg in func.GetOriginalArgs(): 5712 for arg in func.GetOriginalArgs():
5644 arg.WriteClientSideValidationCode(file, func) 5713 arg.WriteClientSideValidationCode(file, func)
5645 file.Write(" helper_->%sImmediate(%s);\n" % 5714 file.Write(" helper_->%sImmediate(%s);\n" %
5646 (func.name, func.MakeOriginalArgString(""))) 5715 (func.name, func.MakeOriginalArgString("")))
5647 file.Write(" CheckGLError();\n") 5716 file.Write(" CheckGLError();\n")
5648 file.Write("}\n") 5717 file.Write("}\n")
5649 file.Write("\n") 5718 file.Write("\n")
5650 5719
5651 def WriteGLES2ImplementationUnitTest(self, func, file): 5720 def WriteGLES2ImplementationUnitTest(self, func, file):
5652 """Writes the GLES2 Implemention unit test.""" 5721 """Writes the GLES2 Implemention unit test."""
(...skipping 29 matching lines...) Expand all
5682 'type': self.GetArrayType(func), 5751 'type': self.GetArrayType(func),
5683 'count': self.GetArrayCount(func), 5752 'count': self.GetArrayCount(func),
5684 'args': ", ".join(gl_arg_strings), 5753 'args': ", ".join(gl_arg_strings),
5685 'cmd_args': ", ".join(cmd_arg_strings), 5754 'cmd_args': ", ".join(cmd_arg_strings),
5686 }) 5755 })
5687 5756
5688 def WriteImmediateCmdComputeSize(self, func, file): 5757 def WriteImmediateCmdComputeSize(self, func, file):
5689 """Overrriden from TypeHandler.""" 5758 """Overrriden from TypeHandler."""
5690 file.Write(" static uint32_t ComputeDataSize() {\n") 5759 file.Write(" static uint32_t ComputeDataSize() {\n")
5691 file.Write(" return static_cast<uint32_t>(\n") 5760 file.Write(" return static_cast<uint32_t>(\n")
5692 file.Write(" sizeof(%s) * %d); // NOLINT\n" % 5761 file.Write(" sizeof(%s) * %d);\n" %
5693 (self.GetArrayType(func), self.GetArrayCount(func))) 5762 (self.GetArrayType(func), self.GetArrayCount(func)))
5694 file.Write(" }\n") 5763 file.Write(" }\n")
5695 file.Write("\n") 5764 file.Write("\n")
5765 if self.__NeedsToCalcDataCount(func):
5766 file.Write(" static uint32_t ComputeEffectiveDataSize(%s %s) {\n" %
5767 (func.GetOriginalArgs()[0].type,
5768 func.GetOriginalArgs()[0].name))
5769 file.Write(" return static_cast<uint32_t>(\n")
5770 file.Write(" sizeof(%s) * GLES2Util::Calc%sDataCount(%s));\n" %
5771 (self.GetArrayType(func), func.original_name,
5772 func.GetOriginalArgs()[0].name))
5773 file.Write(" }\n")
5774 file.Write("\n")
5696 file.Write(" static uint32_t ComputeSize() {\n") 5775 file.Write(" static uint32_t ComputeSize() {\n")
5697 file.Write(" return static_cast<uint32_t>(\n") 5776 file.Write(" return static_cast<uint32_t>(\n")
5698 file.Write( 5777 file.Write(
5699 " sizeof(ValueType) + ComputeDataSize()); // NOLINT\n") 5778 " sizeof(ValueType) + ComputeDataSize());\n")
5700 file.Write(" }\n") 5779 file.Write(" }\n")
5701 file.Write("\n") 5780 file.Write("\n")
5702 5781
5703 def WriteImmediateCmdSetHeader(self, func, file): 5782 def WriteImmediateCmdSetHeader(self, func, file):
5704 """Overrriden from TypeHandler.""" 5783 """Overrriden from TypeHandler."""
5705 file.Write(" void SetHeader() {\n") 5784 file.Write(" void SetHeader() {\n")
5706 file.Write( 5785 file.Write(
5707 " header.SetCmdByTotalSize<ValueType>(ComputeSize());\n") 5786 " header.SetCmdByTotalSize<ValueType>(ComputeSize());\n")
5708 file.Write(" }\n") 5787 file.Write(" }\n")
5709 file.Write("\n") 5788 file.Write("\n")
5710 5789
5711 def WriteImmediateCmdInit(self, func, file): 5790 def WriteImmediateCmdInit(self, func, file):
5712 """Overrriden from TypeHandler.""" 5791 """Overrriden from TypeHandler."""
5713 last_arg = func.GetLastOriginalArg() 5792 last_arg = func.GetLastOriginalArg()
5714 file.Write(" void Init(%s, %s _%s) {\n" % 5793 file.Write(" void Init(%s, %s _%s) {\n" %
5715 (func.MakeTypedCmdArgString("_"), 5794 (func.MakeTypedCmdArgString("_"),
5716 last_arg.type, last_arg.name)) 5795 last_arg.type, last_arg.name))
5717 file.Write(" SetHeader();\n") 5796 file.Write(" SetHeader();\n")
5718 args = func.GetCmdArgs() 5797 args = func.GetCmdArgs()
5719 for arg in args: 5798 for arg in args:
5720 file.Write(" %s = _%s;\n" % (arg.name, arg.name)) 5799 file.Write(" %s = _%s;\n" % (arg.name, arg.name))
5721 file.Write(" memcpy(ImmediateDataAddress(this),\n") 5800 file.Write(" memcpy(ImmediateDataAddress(this),\n")
5722 file.Write(" _%s, ComputeDataSize());\n" % last_arg.name) 5801 if self.__NeedsToCalcDataCount(func):
5802 file.Write(" _%s, ComputeEffectiveDataSize(%s));" %
5803 (last_arg.name, func.GetOriginalArgs()[0].name))
5804 file.Write("""
5805 DCHECK_GE(ComputeDataSize(), ComputeEffectiveDataSize(%(arg)s));
5806 char* pointer = reinterpret_cast<char*>(ImmediateDataAddress(this)) +
5807 ComputeEffectiveDataSize(%(arg)s);
5808 memset(pointer, 0, ComputeDataSize() - ComputeEffectiveDataSize(%(arg)s));
5809 """ % { 'arg': func.GetOriginalArgs()[0].name, })
5810 else:
5811 file.Write(" _%s, ComputeDataSize());\n" % last_arg.name)
5723 file.Write(" }\n") 5812 file.Write(" }\n")
5724 file.Write("\n") 5813 file.Write("\n")
5725 5814
5726 def WriteImmediateCmdSet(self, func, file): 5815 def WriteImmediateCmdSet(self, func, file):
5727 """Overrriden from TypeHandler.""" 5816 """Overrriden from TypeHandler."""
5728 last_arg = func.GetLastOriginalArg() 5817 last_arg = func.GetLastOriginalArg()
5729 copy_args = func.MakeCmdArgString("_", False) 5818 copy_args = func.MakeCmdArgString("_", False)
5730 file.Write(" void* Set(void* cmd%s, %s _%s) {\n" % 5819 file.Write(" void* Set(void* cmd%s, %s _%s) {\n" %
5731 (func.MakeTypedCmdArgString("_", True), 5820 (func.MakeTypedCmdArgString("_", True),
5732 last_arg.type, last_arg.name)) 5821 last_arg.type, last_arg.name))
(...skipping 3567 matching lines...) Expand 10 before | Expand all | Expand 10 after
9300 gen.WriteServiceUtilsHeader( 9389 gen.WriteServiceUtilsHeader(
9301 "gpu/command_buffer/service/gles2_cmd_validation_autogen.h") 9390 "gpu/command_buffer/service/gles2_cmd_validation_autogen.h")
9302 gen.WriteServiceUtilsImplementation( 9391 gen.WriteServiceUtilsImplementation(
9303 "gpu/command_buffer/service/" 9392 "gpu/command_buffer/service/"
9304 "gles2_cmd_validation_implementation_autogen.h") 9393 "gles2_cmd_validation_implementation_autogen.h")
9305 gen.WriteCommonUtilsHeader( 9394 gen.WriteCommonUtilsHeader(
9306 "gpu/command_buffer/common/gles2_cmd_utils_autogen.h") 9395 "gpu/command_buffer/common/gles2_cmd_utils_autogen.h")
9307 gen.WriteCommonUtilsImpl( 9396 gen.WriteCommonUtilsImpl(
9308 "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h") 9397 "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h")
9309 gen.WriteGLES2Header("gpu/GLES2/gl2chromium_autogen.h") 9398 gen.WriteGLES2Header("gpu/GLES2/gl2chromium_autogen.h")
9310 mojo_gles2_prefix = "mojo/public/c/gles2/gles2_call_visitor" 9399 mojo_gles2_prefix = ("third_party/mojo/src/mojo/public/c/gles2/"
9400 "gles2_call_visitor")
9311 gen.WriteMojoGLCallVisitor(mojo_gles2_prefix + "_autogen.h") 9401 gen.WriteMojoGLCallVisitor(mojo_gles2_prefix + "_autogen.h")
9312 gen.WriteMojoGLCallVisitorForExtension( 9402 gen.WriteMojoGLCallVisitorForExtension(
9313 mojo_gles2_prefix + "_chromium_texture_mailbox_autogen.h", 9403 mojo_gles2_prefix + "_chromium_texture_mailbox_autogen.h",
9314 "CHROMIUM_texture_mailbox") 9404 "CHROMIUM_texture_mailbox")
9315 gen.WriteMojoGLCallVisitorForExtension( 9405 gen.WriteMojoGLCallVisitorForExtension(
9316 mojo_gles2_prefix + "_chromium_sync_point_autogen.h", 9406 mojo_gles2_prefix + "_chromium_sync_point_autogen.h",
9317 "CHROMIUM_sync_point") 9407 "CHROMIUM_sync_point")
9318 9408
9319 Format(gen.generated_cpp_filenames) 9409 Format(gen.generated_cpp_filenames)
9320 9410
9321 if gen.errors > 0: 9411 if gen.errors > 0:
9322 print "%d errors" % gen.errors 9412 print "%d errors" % gen.errors
9323 return 1 9413 return 1
9324 return 0 9414 return 0
9325 9415
9326 9416
9327 if __name__ == '__main__': 9417 if __name__ == '__main__':
9328 sys.exit(main(sys.argv[1:])) 9418 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698