OLD | NEW |
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 |
11 import sys | 11 import sys |
12 import re | 12 import re |
| 13 import platform |
13 from optparse import OptionParser | 14 from optparse import OptionParser |
14 from subprocess import call | 15 from subprocess import call |
15 | 16 |
16 _SIZE_OF_UINT32 = 4 | 17 _SIZE_OF_UINT32 = 4 |
17 _SIZE_OF_COMMAND_HEADER = 4 | 18 _SIZE_OF_COMMAND_HEADER = 4 |
18 _FIRST_SPECIFIC_COMMAND_ID = 256 | 19 _FIRST_SPECIFIC_COMMAND_ID = 256 |
19 | 20 |
20 _LICENSE = """// Copyright 2014 The Chromium Authors. All rights reserved. | 21 _LICENSE = """// Copyright 2014 The Chromium Authors. All rights reserved. |
21 // Use of this source code is governed by a BSD-style license that can be | 22 // Use of this source code is governed by a BSD-style license that can be |
22 // found in the LICENSE file. | 23 // found in the LICENSE file. |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 'type': 'GLenum', | 703 'type': 'GLenum', |
703 'valid': [ | 704 'valid': [ |
704 'GL_TEXTURE_2D', | 705 'GL_TEXTURE_2D', |
705 'GL_TEXTURE_CUBE_MAP', | 706 'GL_TEXTURE_CUBE_MAP', |
706 ], | 707 ], |
707 'invalid': [ | 708 'invalid': [ |
708 'GL_TEXTURE_1D', | 709 'GL_TEXTURE_1D', |
709 'GL_TEXTURE_3D', | 710 'GL_TEXTURE_3D', |
710 ], | 711 ], |
711 }, | 712 }, |
| 713 'TransformFeedbackBindTarget': { |
| 714 'type': 'GLenum', |
| 715 'valid': [ |
| 716 'GL_TRANSFORM_FEEDBACK', |
| 717 ], |
| 718 'invalid': [ |
| 719 'GL_TEXTURE_2D', |
| 720 ], |
| 721 }, |
| 722 'TransformFeedbackPrimitiveMode': { |
| 723 'type': 'GLenum', |
| 724 'valid': [ |
| 725 'GL_POINTS', |
| 726 'GL_LINES', |
| 727 'GL_TRIANGLES', |
| 728 ], |
| 729 'invalid': [ |
| 730 'GL_LINE_LOOP', |
| 731 ], |
| 732 }, |
712 'ShaderType': { | 733 'ShaderType': { |
713 'type': 'GLenum', | 734 'type': 'GLenum', |
714 'valid': [ | 735 'valid': [ |
715 'GL_VERTEX_SHADER', | 736 'GL_VERTEX_SHADER', |
716 'GL_FRAGMENT_SHADER', | 737 'GL_FRAGMENT_SHADER', |
717 ], | 738 ], |
718 'invalid': [ | 739 'invalid': [ |
719 'GL_GEOMETRY_SHADER', | 740 'GL_GEOMETRY_SHADER', |
720 ], | 741 ], |
721 }, | 742 }, |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 'GL_RENDERBUFFER_GREEN_SIZE', | 953 'GL_RENDERBUFFER_GREEN_SIZE', |
933 'GL_RENDERBUFFER_BLUE_SIZE', | 954 'GL_RENDERBUFFER_BLUE_SIZE', |
934 'GL_RENDERBUFFER_ALPHA_SIZE', | 955 'GL_RENDERBUFFER_ALPHA_SIZE', |
935 'GL_RENDERBUFFER_DEPTH_SIZE', | 956 'GL_RENDERBUFFER_DEPTH_SIZE', |
936 'GL_RENDERBUFFER_STENCIL_SIZE', | 957 'GL_RENDERBUFFER_STENCIL_SIZE', |
937 'GL_RENDERBUFFER_WIDTH', | 958 'GL_RENDERBUFFER_WIDTH', |
938 'GL_RENDERBUFFER_HEIGHT', | 959 'GL_RENDERBUFFER_HEIGHT', |
939 'GL_RENDERBUFFER_INTERNAL_FORMAT', | 960 'GL_RENDERBUFFER_INTERNAL_FORMAT', |
940 ], | 961 ], |
941 }, | 962 }, |
| 963 'SamplerParameter': { |
| 964 'type': 'GLenum', |
| 965 'valid': [ |
| 966 'GL_TEXTURE_MAG_FILTER', |
| 967 'GL_TEXTURE_MIN_FILTER', |
| 968 'GL_TEXTURE_MIN_LOD', |
| 969 'GL_TEXTURE_MAX_LOD', |
| 970 'GL_TEXTURE_WRAP_S', |
| 971 'GL_TEXTURE_WRAP_T', |
| 972 'GL_TEXTURE_WRAP_R', |
| 973 'GL_TEXTURE_COMPARE_MODE', |
| 974 'GL_TEXTURE_COMPARE_FUNC', |
| 975 ], |
| 976 'invalid': [ |
| 977 'GL_GENERATE_MIPMAP', |
| 978 ], |
| 979 }, |
942 'ShaderParameter': { | 980 'ShaderParameter': { |
943 'type': 'GLenum', | 981 'type': 'GLenum', |
944 'valid': [ | 982 'valid': [ |
945 'GL_SHADER_TYPE', | 983 'GL_SHADER_TYPE', |
946 'GL_DELETE_STATUS', | 984 'GL_DELETE_STATUS', |
947 'GL_COMPILE_STATUS', | 985 'GL_COMPILE_STATUS', |
948 'GL_INFO_LOG_LENGTH', | 986 'GL_INFO_LOG_LENGTH', |
949 'GL_SHADER_SOURCE_LENGTH', | 987 'GL_SHADER_SOURCE_LENGTH', |
950 'GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE', | 988 'GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE', |
951 ], | 989 ], |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 # The default is 'immediate' if the command has one pointer | 1358 # The default is 'immediate' if the command has one pointer |
1321 # argument, otherwise 'shm'. One command is generated for each | 1359 # argument, otherwise 'shm'. One command is generated for each |
1322 # transfer method. Affects only commands which are not of type | 1360 # transfer method. Affects only commands which are not of type |
1323 # 'HandWritten', 'GETn' or 'GLcharN'. | 1361 # 'HandWritten', 'GETn' or 'GLcharN'. |
1324 # Note: the command arguments that affect this are the final args, | 1362 # Note: the command arguments that affect this are the final args, |
1325 # taking cmd_args override into consideration. | 1363 # taking cmd_args override into consideration. |
1326 # impl_func: Whether or not to generate the GLES2Implementation part of this | 1364 # impl_func: Whether or not to generate the GLES2Implementation part of this |
1327 # command. | 1365 # command. |
1328 # impl_decl: Whether or not to generate the GLES2Implementation declaration | 1366 # impl_decl: Whether or not to generate the GLES2Implementation declaration |
1329 # for this command. | 1367 # for this command. |
1330 # needs_size: If true a data_size field is added to the command. | 1368 # needs_size: If True a data_size field is added to the command. |
1331 # count: The number of units per element. For PUTn or PUT types. | 1369 # count: The number of units per element. For PUTn or PUT types. |
1332 # unit_test: If False no service side unit test will be generated. | 1370 # unit_test: If False no service side unit test will be generated. |
1333 # client_test: If False no client side unit test will be generated. | 1371 # client_test: If False no client side unit test will be generated. |
1334 # expectation: If False the unit test will have no expected calls. | 1372 # expectation: If False the unit test will have no expected calls. |
1335 # gen_func: Name of function that generates GL resource for corresponding | 1373 # gen_func: Name of function that generates GL resource for corresponding |
1336 # bind function. | 1374 # bind function. |
1337 # states: array of states that get set by this function corresponding to | 1375 # states: array of states that get set by this function corresponding to |
1338 # the given arguments | 1376 # the given arguments |
1339 # state_flag: name of flag that is set to true when function is called. | 1377 # state_flag: name of flag that is set to true when function is called. |
1340 # no_gl: no GL function is called. | 1378 # no_gl: no GL function is called. |
(...skipping 11 matching lines...) Expand all Loading... |
1352 # array is used and we end up calling the single value | 1390 # array is used and we end up calling the single value |
1353 # corresponding function. eg. TexParameteriv -> TexParameteri | 1391 # corresponding function. eg. TexParameteriv -> TexParameteri |
1354 # extension: Function is an extension to GL and should not be exposed to | 1392 # extension: Function is an extension to GL and should not be exposed to |
1355 # pepper unless pepper_interface is defined. | 1393 # pepper unless pepper_interface is defined. |
1356 # extension_flag: Function is an extension and should be enabled only when | 1394 # extension_flag: Function is an extension and should be enabled only when |
1357 # the corresponding feature info flag is enabled. Implies | 1395 # the corresponding feature info flag is enabled. Implies |
1358 # 'extension': True. | 1396 # 'extension': True. |
1359 # not_shared: For GENn types, True if objects can't be shared between contexts | 1397 # not_shared: For GENn types, True if objects can't be shared between contexts |
1360 # unsafe: True = no validation is implemented on the service side and the | 1398 # unsafe: True = no validation is implemented on the service side and the |
1361 # command is only available with --enable-unsafe-es3-apis. | 1399 # command is only available with --enable-unsafe-es3-apis. |
| 1400 # id_mapping: A list of resource type names whose client side IDs need to be |
| 1401 # mapped to service side IDs. This is only used for unsafe APIs. |
1362 | 1402 |
1363 _FUNCTION_INFO = { | 1403 _FUNCTION_INFO = { |
1364 'ActiveTexture': { | 1404 'ActiveTexture': { |
1365 'decoder_func': 'DoActiveTexture', | 1405 'decoder_func': 'DoActiveTexture', |
1366 'unit_test': False, | 1406 'unit_test': False, |
1367 'impl_func': False, | 1407 'impl_func': False, |
1368 'client_test': False, | 1408 'client_test': False, |
1369 }, | 1409 }, |
1370 'AttachShader': {'decoder_func': 'DoAttachShader'}, | 1410 'AttachShader': {'decoder_func': 'DoAttachShader'}, |
1371 'BindAttribLocation': { | 1411 'BindAttribLocation': { |
(...skipping 12 matching lines...) Expand all Loading... |
1384 'gl_test_func': 'glBindFramebufferEXT', | 1424 'gl_test_func': 'glBindFramebufferEXT', |
1385 'gen_func': 'GenFramebuffersEXT', | 1425 'gen_func': 'GenFramebuffersEXT', |
1386 'trace_level': 1, | 1426 'trace_level': 1, |
1387 }, | 1427 }, |
1388 'BindRenderbuffer': { | 1428 'BindRenderbuffer': { |
1389 'type': 'Bind', | 1429 'type': 'Bind', |
1390 'decoder_func': 'DoBindRenderbuffer', | 1430 'decoder_func': 'DoBindRenderbuffer', |
1391 'gl_test_func': 'glBindRenderbufferEXT', | 1431 'gl_test_func': 'glBindRenderbufferEXT', |
1392 'gen_func': 'GenRenderbuffersEXT', | 1432 'gen_func': 'GenRenderbuffersEXT', |
1393 }, | 1433 }, |
| 1434 'BindSampler': { |
| 1435 'type': 'Bind', |
| 1436 'id_mapping': [ 'Sampler' ], |
| 1437 'unsafe': True, |
| 1438 }, |
1394 'BindTexture': { | 1439 'BindTexture': { |
1395 'type': 'Bind', | 1440 'type': 'Bind', |
1396 'decoder_func': 'DoBindTexture', | 1441 'decoder_func': 'DoBindTexture', |
1397 'gen_func': 'GenTextures', | 1442 'gen_func': 'GenTextures', |
1398 # TODO(gman): remove this once client side caching works. | 1443 # TODO(gman): remove this once client side caching works. |
1399 'client_test': False, | 1444 'client_test': False, |
1400 'trace_level': 1, | 1445 'trace_level': 1, |
1401 }, | 1446 }, |
| 1447 'BindTransformFeedback': { |
| 1448 'type': 'Bind', |
| 1449 'id_mapping': [ 'TransformFeedback' ], |
| 1450 'unsafe': True, |
| 1451 }, |
1402 'BlitFramebufferCHROMIUM': { | 1452 'BlitFramebufferCHROMIUM': { |
1403 'decoder_func': 'DoBlitFramebufferCHROMIUM', | 1453 'decoder_func': 'DoBlitFramebufferCHROMIUM', |
1404 'unit_test': False, | 1454 'unit_test': False, |
1405 'extension_flag': 'chromium_framebuffer_multisample', | 1455 'extension_flag': 'chromium_framebuffer_multisample', |
1406 'pepper_interface': 'FramebufferBlit', | 1456 'pepper_interface': 'FramebufferBlit', |
1407 'pepper_name': 'BlitFramebufferEXT', | 1457 'pepper_name': 'BlitFramebufferEXT', |
1408 'defer_reads': True, | 1458 'defer_reads': True, |
1409 'defer_draws': True, | 1459 'defer_draws': True, |
1410 'trace_level': 1, | 1460 'trace_level': 1, |
1411 }, | 1461 }, |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1683 'resource_type': 'Framebuffer', | 1733 'resource_type': 'Framebuffer', |
1684 'resource_types': 'Framebuffers', | 1734 'resource_types': 'Framebuffers', |
1685 }, | 1735 }, |
1686 'DeleteProgram': {'type': 'Delete', 'decoder_func': 'DoDeleteProgram'}, | 1736 'DeleteProgram': {'type': 'Delete', 'decoder_func': 'DoDeleteProgram'}, |
1687 'DeleteRenderbuffers': { | 1737 'DeleteRenderbuffers': { |
1688 'type': 'DELn', | 1738 'type': 'DELn', |
1689 'gl_test_func': 'glDeleteRenderbuffersEXT', | 1739 'gl_test_func': 'glDeleteRenderbuffersEXT', |
1690 'resource_type': 'Renderbuffer', | 1740 'resource_type': 'Renderbuffer', |
1691 'resource_types': 'Renderbuffers', | 1741 'resource_types': 'Renderbuffers', |
1692 }, | 1742 }, |
| 1743 'DeleteSamplers': { |
| 1744 'type': 'DELn', |
| 1745 'resource_type': 'Sampler', |
| 1746 'resource_types': 'Samplers', |
| 1747 'unsafe': True, |
| 1748 }, |
1693 'DeleteShader': {'type': 'Delete', 'decoder_func': 'DoDeleteShader'}, | 1749 'DeleteShader': {'type': 'Delete', 'decoder_func': 'DoDeleteShader'}, |
1694 'DeleteTextures': { | 1750 'DeleteTextures': { |
1695 'type': 'DELn', | 1751 'type': 'DELn', |
1696 'resource_type': 'Texture', | 1752 'resource_type': 'Texture', |
1697 'resource_types': 'Textures', | 1753 'resource_types': 'Textures', |
1698 }, | 1754 }, |
| 1755 'DeleteTransformFeedbacks': { |
| 1756 'type': 'DELn', |
| 1757 'resource_type': 'TransformFeedback', |
| 1758 'resource_types': 'TransformFeedbacks', |
| 1759 'unsafe': True, |
| 1760 }, |
1699 'DepthRangef': { | 1761 'DepthRangef': { |
1700 'decoder_func': 'DoDepthRangef', | 1762 'decoder_func': 'DoDepthRangef', |
1701 'gl_test_func': 'glDepthRange', | 1763 'gl_test_func': 'glDepthRange', |
1702 }, | 1764 }, |
1703 'DepthMask': { | 1765 'DepthMask': { |
1704 'type': 'StateSet', | 1766 'type': 'StateSet', |
1705 'state': 'DepthMask', | 1767 'state': 'DepthMask', |
1706 'no_gl': True, | 1768 'no_gl': True, |
1707 'expectation': False, | 1769 'expectation': False, |
1708 }, | 1770 }, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 'type': 'GENn', | 1852 'type': 'GENn', |
1791 'gl_test_func': 'glGenFramebuffersEXT', | 1853 'gl_test_func': 'glGenFramebuffersEXT', |
1792 'resource_type': 'Framebuffer', | 1854 'resource_type': 'Framebuffer', |
1793 'resource_types': 'Framebuffers', | 1855 'resource_types': 'Framebuffers', |
1794 }, | 1856 }, |
1795 'GenRenderbuffers': { | 1857 'GenRenderbuffers': { |
1796 'type': 'GENn', 'gl_test_func': 'glGenRenderbuffersEXT', | 1858 'type': 'GENn', 'gl_test_func': 'glGenRenderbuffersEXT', |
1797 'resource_type': 'Renderbuffer', | 1859 'resource_type': 'Renderbuffer', |
1798 'resource_types': 'Renderbuffers', | 1860 'resource_types': 'Renderbuffers', |
1799 }, | 1861 }, |
| 1862 'GenSamplers': { |
| 1863 'type': 'GENn', |
| 1864 'gl_test_func': 'glGenSamplers', |
| 1865 'resource_type': 'Sampler', |
| 1866 'resource_types': 'Samplers', |
| 1867 'unsafe': True, |
| 1868 }, |
1800 'GenTextures': { | 1869 'GenTextures': { |
1801 'type': 'GENn', | 1870 'type': 'GENn', |
1802 'gl_test_func': 'glGenTextures', | 1871 'gl_test_func': 'glGenTextures', |
1803 'resource_type': 'Texture', | 1872 'resource_type': 'Texture', |
1804 'resource_types': 'Textures', | 1873 'resource_types': 'Textures', |
1805 }, | 1874 }, |
| 1875 'GenTransformFeedbacks': { |
| 1876 'type': 'GENn', |
| 1877 'gl_test_func': 'glGenTransformFeedbacks', |
| 1878 'resource_type': 'TransformFeedback', |
| 1879 'resource_types': 'TransformFeedbacks', |
| 1880 'unsafe': True, |
| 1881 }, |
1806 'GetActiveAttrib': { | 1882 'GetActiveAttrib': { |
1807 'type': 'Custom', | 1883 'type': 'Custom', |
1808 'data_transfer_methods': ['shm'], | 1884 'data_transfer_methods': ['shm'], |
1809 'cmd_args': | 1885 'cmd_args': |
1810 'GLidProgram program, GLuint index, uint32_t name_bucket_id, ' | 1886 'GLidProgram program, GLuint index, uint32_t name_bucket_id, ' |
1811 'void* result', | 1887 'void* result', |
1812 'result': [ | 1888 'result': [ |
1813 'int32_t success', | 1889 'int32_t success', |
1814 'int32_t size', | 1890 'int32_t size', |
1815 'uint32_t type', | 1891 'uint32_t type', |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 'GetProgramInfoLog': { | 1993 'GetProgramInfoLog': { |
1918 'type': 'STRn', | 1994 'type': 'STRn', |
1919 'expectation': False, | 1995 'expectation': False, |
1920 }, | 1996 }, |
1921 'GetRenderbufferParameteriv': { | 1997 'GetRenderbufferParameteriv': { |
1922 'type': 'GETn', | 1998 'type': 'GETn', |
1923 'decoder_func': 'DoGetRenderbufferParameteriv', | 1999 'decoder_func': 'DoGetRenderbufferParameteriv', |
1924 'gl_test_func': 'glGetRenderbufferParameterivEXT', | 2000 'gl_test_func': 'glGetRenderbufferParameterivEXT', |
1925 'result': ['SizedResult<GLint>'], | 2001 'result': ['SizedResult<GLint>'], |
1926 }, | 2002 }, |
| 2003 'GetSamplerParameterfv': { |
| 2004 'type': 'GETn', |
| 2005 'result': ['SizedResult<GLfloat>'], |
| 2006 'id_mapping': [ 'Sampler' ], |
| 2007 'unsafe': True, |
| 2008 }, |
| 2009 'GetSamplerParameteriv': { |
| 2010 'type': 'GETn', |
| 2011 'result': ['SizedResult<GLint>'], |
| 2012 'id_mapping': [ 'Sampler' ], |
| 2013 'unsafe': True, |
| 2014 }, |
1927 'GetShaderiv': { | 2015 'GetShaderiv': { |
1928 'type': 'GETn', | 2016 'type': 'GETn', |
1929 'decoder_func': 'DoGetShaderiv', | 2017 'decoder_func': 'DoGetShaderiv', |
1930 'result': ['SizedResult<GLint>'], | 2018 'result': ['SizedResult<GLint>'], |
1931 }, | 2019 }, |
1932 'GetShaderInfoLog': { | 2020 'GetShaderInfoLog': { |
1933 'type': 'STRn', | 2021 'type': 'STRn', |
1934 'get_len_func': 'glGetShaderiv', | 2022 'get_len_func': 'glGetShaderiv', |
1935 'get_len_enum': 'GL_INFO_LOG_LENGTH', | 2023 'get_len_enum': 'GL_INFO_LOG_LENGTH', |
1936 'unit_test': False, | 2024 'unit_test': False, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2055 'IsRenderbuffer': { | 2143 'IsRenderbuffer': { |
2056 'type': 'Is', | 2144 'type': 'Is', |
2057 'decoder_func': 'DoIsRenderbuffer', | 2145 'decoder_func': 'DoIsRenderbuffer', |
2058 'expectation': False, | 2146 'expectation': False, |
2059 }, | 2147 }, |
2060 'IsShader': { | 2148 'IsShader': { |
2061 'type': 'Is', | 2149 'type': 'Is', |
2062 'decoder_func': 'DoIsShader', | 2150 'decoder_func': 'DoIsShader', |
2063 'expectation': False, | 2151 'expectation': False, |
2064 }, | 2152 }, |
| 2153 'IsSampler': { |
| 2154 'type': 'Is', |
| 2155 'id_mapping': [ 'Sampler' ], |
| 2156 'unsafe': True, |
| 2157 }, |
2065 'IsTexture': { | 2158 'IsTexture': { |
2066 'type': 'Is', | 2159 'type': 'Is', |
2067 'decoder_func': 'DoIsTexture', | 2160 'decoder_func': 'DoIsTexture', |
2068 'expectation': False, | 2161 'expectation': False, |
2069 }, | 2162 }, |
| 2163 'IsTransformFeedback': { |
| 2164 'type': 'Is', |
| 2165 'id_mapping': [ 'TransformFeedback' ], |
| 2166 'unsafe': True, |
| 2167 }, |
2070 'LinkProgram': { | 2168 'LinkProgram': { |
2071 'decoder_func': 'DoLinkProgram', | 2169 'decoder_func': 'DoLinkProgram', |
2072 'impl_func': False, | 2170 'impl_func': False, |
2073 }, | 2171 }, |
2074 'MapBufferCHROMIUM': { | 2172 'MapBufferCHROMIUM': { |
2075 'gen_cmd': False, | 2173 'gen_cmd': False, |
2076 'extension': True, | 2174 'extension': True, |
2077 'chromium': True, | 2175 'chromium': True, |
2078 'client_test': False, | 2176 'client_test': False, |
2079 }, | 2177 }, |
2080 'MapBufferSubDataCHROMIUM': { | 2178 'MapBufferSubDataCHROMIUM': { |
2081 'gen_cmd': False, | 2179 'gen_cmd': False, |
2082 'extension': True, | 2180 'extension': True, |
2083 'chromium': True, | 2181 'chromium': True, |
2084 'client_test': False, | 2182 'client_test': False, |
2085 'pepper_interface': 'ChromiumMapSub', | 2183 'pepper_interface': 'ChromiumMapSub', |
2086 }, | 2184 }, |
2087 'MapTexSubImage2DCHROMIUM': { | 2185 'MapTexSubImage2DCHROMIUM': { |
2088 'gen_cmd': False, | 2186 'gen_cmd': False, |
2089 'extension': True, | 2187 'extension': True, |
2090 'chromium': True, | 2188 'chromium': True, |
2091 'client_test': False, | 2189 'client_test': False, |
2092 'pepper_interface': 'ChromiumMapSub', | 2190 'pepper_interface': 'ChromiumMapSub', |
2093 }, | 2191 }, |
| 2192 'PauseTransformFeedback': { |
| 2193 'unsafe': True, |
| 2194 }, |
2094 'PixelStorei': {'type': 'Manual'}, | 2195 'PixelStorei': {'type': 'Manual'}, |
2095 'PostSubBufferCHROMIUM': { | 2196 'PostSubBufferCHROMIUM': { |
2096 'type': 'Custom', | 2197 'type': 'Custom', |
2097 'impl_func': False, | 2198 'impl_func': False, |
2098 'unit_test': False, | 2199 'unit_test': False, |
2099 'client_test': False, | 2200 'client_test': False, |
2100 'extension': True, | 2201 'extension': True, |
2101 'chromium': True, | 2202 'chromium': True, |
2102 }, | 2203 }, |
2103 'ProduceTextureCHROMIUM': { | 2204 'ProduceTextureCHROMIUM': { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2165 'uint32_t pixels_shm_id, uint32_t pixels_shm_offset, ' | 2266 'uint32_t pixels_shm_id, uint32_t pixels_shm_offset, ' |
2166 'uint32_t result_shm_id, uint32_t result_shm_offset, ' | 2267 'uint32_t result_shm_id, uint32_t result_shm_offset, ' |
2167 'GLboolean async', | 2268 'GLboolean async', |
2168 'result': ['uint32_t'], | 2269 'result': ['uint32_t'], |
2169 'defer_reads': True, | 2270 'defer_reads': True, |
2170 }, | 2271 }, |
2171 'ReleaseShaderCompiler': { | 2272 'ReleaseShaderCompiler': { |
2172 'decoder_func': 'DoReleaseShaderCompiler', | 2273 'decoder_func': 'DoReleaseShaderCompiler', |
2173 'unit_test': False, | 2274 'unit_test': False, |
2174 }, | 2275 }, |
| 2276 'ResumeTransformFeedback': { |
| 2277 'unsafe': True, |
| 2278 }, |
| 2279 'SamplerParameterf': { |
| 2280 'valid_args': { |
| 2281 '2': 'GL_NEAREST' |
| 2282 }, |
| 2283 'id_mapping': [ 'Sampler' ], |
| 2284 'unsafe': True, |
| 2285 }, |
| 2286 'SamplerParameterfv': { |
| 2287 'type': 'PUT', |
| 2288 'data_value': 'GL_NEAREST', |
| 2289 'count': 1, |
| 2290 'gl_test_func': 'glSamplerParameterf', |
| 2291 'decoder_func': 'DoSamplerParameterfv', |
| 2292 'first_element_only': True, |
| 2293 'id_mapping': [ 'Sampler' ], |
| 2294 'unsafe': True, |
| 2295 }, |
| 2296 'SamplerParameteri': { |
| 2297 'valid_args': { |
| 2298 '2': 'GL_NEAREST' |
| 2299 }, |
| 2300 'id_mapping': [ 'Sampler' ], |
| 2301 'unsafe': True, |
| 2302 }, |
| 2303 'SamplerParameteriv': { |
| 2304 'type': 'PUT', |
| 2305 'data_value': 'GL_NEAREST', |
| 2306 'count': 1, |
| 2307 'gl_test_func': 'glSamplerParameteri', |
| 2308 'decoder_func': 'DoSamplerParameteriv', |
| 2309 'first_element_only': True, |
| 2310 'unsafe': True, |
| 2311 }, |
2175 'ShaderBinary': { | 2312 'ShaderBinary': { |
2176 'type': 'Custom', | 2313 'type': 'Custom', |
2177 'client_test': False, | 2314 'client_test': False, |
2178 }, | 2315 }, |
2179 'ShaderSource': { | 2316 'ShaderSource': { |
2180 'type': 'Manual', | 2317 'type': 'Manual', |
2181 'data_transfer_methods': ['bucket'], | 2318 'data_transfer_methods': ['bucket'], |
2182 'needs_size': True, | 2319 'needs_size': True, |
2183 'client_test': False, | 2320 'client_test': False, |
2184 'cmd_args': | 2321 'cmd_args': |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2592 'client_test': False, | 2729 'client_test': False, |
2593 'pepper_interface': 'Query', | 2730 'pepper_interface': 'Query', |
2594 }, | 2731 }, |
2595 'BeginQueryEXT': { | 2732 'BeginQueryEXT': { |
2596 'type': 'Manual', | 2733 'type': 'Manual', |
2597 'cmd_args': 'GLenumQueryTarget target, GLidQuery id, void* sync_data', | 2734 'cmd_args': 'GLenumQueryTarget target, GLidQuery id, void* sync_data', |
2598 'data_transfer_methods': ['shm'], | 2735 'data_transfer_methods': ['shm'], |
2599 'gl_test_func': 'glBeginQuery', | 2736 'gl_test_func': 'glBeginQuery', |
2600 'pepper_interface': 'Query', | 2737 'pepper_interface': 'Query', |
2601 }, | 2738 }, |
| 2739 'BeginTransformFeedback': { |
| 2740 'unsafe': True, |
| 2741 }, |
2602 'EndQueryEXT': { | 2742 'EndQueryEXT': { |
2603 'type': 'Manual', | 2743 'type': 'Manual', |
2604 'cmd_args': 'GLenumQueryTarget target, GLuint submit_count', | 2744 'cmd_args': 'GLenumQueryTarget target, GLuint submit_count', |
2605 'gl_test_func': 'glEndnQuery', | 2745 'gl_test_func': 'glEndnQuery', |
2606 'client_test': False, | 2746 'client_test': False, |
2607 'pepper_interface': 'Query', | 2747 'pepper_interface': 'Query', |
2608 }, | 2748 }, |
| 2749 'EndTransformFeedback': { |
| 2750 'unsafe': True, |
| 2751 }, |
2609 'GetQueryivEXT': { | 2752 'GetQueryivEXT': { |
2610 'gen_cmd': False, | 2753 'gen_cmd': False, |
2611 'client_test': False, | 2754 'client_test': False, |
2612 'gl_test_func': 'glGetQueryiv', | 2755 'gl_test_func': 'glGetQueryiv', |
2613 'pepper_interface': 'Query', | 2756 'pepper_interface': 'Query', |
2614 }, | 2757 }, |
2615 'GetQueryObjectuivEXT': { | 2758 'GetQueryObjectuivEXT': { |
2616 'gen_cmd': False, | 2759 'gen_cmd': False, |
2617 'client_test': False, | 2760 'client_test': False, |
2618 'gl_test_func': 'glGetQueryObjectuiv', | 2761 'gl_test_func': 'glGetQueryObjectuiv', |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3054 file.Write((check.strip() + "\n") % { | 3197 file.Write((check.strip() + "\n") % { |
3055 'cmd_name': func.name, | 3198 'cmd_name': func.name, |
3056 'field_name': name, | 3199 'field_name': name, |
3057 'offset': offset, | 3200 'offset': offset, |
3058 }) | 3201 }) |
3059 offset += _SIZE_OF_UINT32 | 3202 offset += _SIZE_OF_UINT32 |
3060 file.Write("\n") | 3203 file.Write("\n") |
3061 | 3204 |
3062 def WriteHandlerImplementation(self, func, file): | 3205 def WriteHandlerImplementation(self, func, file): |
3063 """Writes the handler implementation for this command.""" | 3206 """Writes the handler implementation for this command.""" |
| 3207 if func.IsUnsafe() and func.GetInfo('id_mapping'): |
| 3208 for id_type in func.GetInfo('id_mapping'): |
| 3209 file.Write(" group_->Get%sServiceId(%s, &%s);\n" % |
| 3210 (id_type, id_type.lower(), id_type.lower())) |
3064 file.Write(" %s(%s);\n" % | 3211 file.Write(" %s(%s);\n" % |
3065 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 3212 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
3066 | 3213 |
3067 def WriteCmdSizeTest(self, func, file): | 3214 def WriteCmdSizeTest(self, func, file): |
3068 """Writes the size test for a command.""" | 3215 """Writes the size test for a command.""" |
3069 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") | 3216 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") |
3070 | 3217 |
3071 def WriteFormatTest(self, func, file): | 3218 def WriteFormatTest(self, func, file): |
3072 """Writes a format test for a command.""" | 3219 """Writes a format test for a command.""" |
3073 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name) | 3220 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name) |
(...skipping 29 matching lines...) Expand all Loading... |
3103 """Writes the code to set data_size used in validation""" | 3250 """Writes the code to set data_size used in validation""" |
3104 pass | 3251 pass |
3105 | 3252 |
3106 def WriteImmediateCmdSizeTest(self, func, file): | 3253 def WriteImmediateCmdSizeTest(self, func, file): |
3107 """Writes a size test for an immediate version of a command.""" | 3254 """Writes a size test for an immediate version of a command.""" |
3108 file.Write(" // TODO(gman): Compute correct size.\n") | 3255 file.Write(" // TODO(gman): Compute correct size.\n") |
3109 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") | 3256 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") |
3110 | 3257 |
3111 def WriteImmediateHandlerImplementation (self, func, file): | 3258 def WriteImmediateHandlerImplementation (self, func, file): |
3112 """Writes the handler impl for the immediate version of a command.""" | 3259 """Writes the handler impl for the immediate version of a command.""" |
| 3260 if func.IsUnsafe() and func.GetInfo('id_mapping'): |
| 3261 for id_type in func.GetInfo('id_mapping'): |
| 3262 file.Write(" group_->Get%sServiceId(%s, &%s);\n" % |
| 3263 (id_type, id_type.lower(), id_type.lower())) |
3113 file.Write(" %s(%s);\n" % | 3264 file.Write(" %s(%s);\n" % |
3114 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 3265 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
3115 | 3266 |
3116 def WriteBucketHandlerImplementation (self, func, file): | 3267 def WriteBucketHandlerImplementation (self, func, file): |
3117 """Writes the handler impl for the bucket version of a command.""" | 3268 """Writes the handler impl for the bucket version of a command.""" |
3118 file.Write(" %s(%s);\n" % | 3269 file.Write(" %s(%s);\n" % |
3119 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 3270 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
3120 | 3271 |
3121 def WriteServiceHandlerFunctionHeader(self, func, file): | 3272 def WriteServiceHandlerFunctionHeader(self, func, file): |
3122 """Writes function header for service implementation handlers.""" | 3273 """Writes function header for service implementation handlers.""" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3226 for extra in extras: | 3377 for extra in extras: |
3227 vars.update(extra) | 3378 vars.update(extra) |
3228 old_test = "" | 3379 old_test = "" |
3229 while (old_test != test): | 3380 while (old_test != test): |
3230 old_test = test | 3381 old_test = test |
3231 test = test % vars | 3382 test = test % vars |
3232 file.Write(test % vars) | 3383 file.Write(test % vars) |
3233 | 3384 |
3234 def WriteInvalidUnitTest(self, func, file, test, *extras): | 3385 def WriteInvalidUnitTest(self, func, file, test, *extras): |
3235 """Writes an invalid unit test for the service implementation.""" | 3386 """Writes an invalid unit test for the service implementation.""" |
| 3387 if func.IsUnsafe(): |
| 3388 return |
3236 for invalid_arg_index, invalid_arg in enumerate(func.GetOriginalArgs()): | 3389 for invalid_arg_index, invalid_arg in enumerate(func.GetOriginalArgs()): |
3237 # Service implementation does not test constants, as they are not part of | 3390 # Service implementation does not test constants, as they are not part of |
3238 # the call in the service side. | 3391 # the call in the service side. |
3239 if invalid_arg.IsConstant(): | 3392 if invalid_arg.IsConstant(): |
3240 continue | 3393 continue |
3241 | 3394 |
3242 num_invalid_values = invalid_arg.GetNumInvalidValues(func) | 3395 num_invalid_values = invalid_arg.GetNumInvalidValues(func) |
3243 for value_index in range(0, num_invalid_values): | 3396 for value_index in range(0, num_invalid_values): |
3244 arg_strings = [] | 3397 arg_strings = [] |
3245 parse_result = "kNoError" | 3398 parse_result = "kNoError" |
(...skipping 17 matching lines...) Expand all Loading... |
3263 | 3416 |
3264 vars = { | 3417 vars = { |
3265 'name': func.name, | 3418 'name': func.name, |
3266 'arg_index': invalid_arg_index, | 3419 'arg_index': invalid_arg_index, |
3267 'value_index': value_index, | 3420 'value_index': value_index, |
3268 'gl_func_name': gl_func_name, | 3421 'gl_func_name': gl_func_name, |
3269 'args': ", ".join(arg_strings), | 3422 'args': ", ".join(arg_strings), |
3270 'all_but_last_args': ", ".join(arg_strings[:-1]), | 3423 'all_but_last_args': ", ".join(arg_strings[:-1]), |
3271 'gl_args': ", ".join(gl_arg_strings), | 3424 'gl_args': ", ".join(gl_arg_strings), |
3272 'parse_result': parse_result, | 3425 'parse_result': parse_result, |
3273 'gl_error_test': gl_error_test, | 3426 'gl_error_test': gl_error_test, |
3274 } | 3427 } |
3275 for extra in extras: | 3428 for extra in extras: |
3276 vars.update(extra) | 3429 vars.update(extra) |
3277 file.Write(test % vars) | 3430 file.Write(test % vars) |
3278 | 3431 |
3279 def WriteServiceUnitTest(self, func, file, *extras): | 3432 def WriteServiceUnitTest(self, func, file, *extras): |
3280 """Writes the service unit test for a command.""" | 3433 """Writes the service unit test for a command.""" |
3281 | 3434 |
3282 if func.name == 'Enable': | 3435 if func.name == 'Enable': |
3283 valid_test = """ | 3436 valid_test = """ |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4147 | 4300 |
4148 def WriteServiceUnitTest(self, func, file, *extras): | 4301 def WriteServiceUnitTest(self, func, file, *extras): |
4149 """Overrriden from TypeHandler.""" | 4302 """Overrriden from TypeHandler.""" |
4150 | 4303 |
4151 if len(func.GetOriginalArgs()) == 1: | 4304 if len(func.GetOriginalArgs()) == 1: |
4152 valid_test = """ | 4305 valid_test = """ |
4153 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4306 TEST_P(%(test_name)s, %(name)sValidArgs) { |
4154 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); | 4307 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); |
4155 SpecializedSetup<cmds::%(name)s, 0>(true); | 4308 SpecializedSetup<cmds::%(name)s, 0>(true); |
4156 cmds::%(name)s cmd; | 4309 cmds::%(name)s cmd; |
4157 cmd.Init(%(args)s); | 4310 cmd.Init(%(args)s);""" |
| 4311 if func.IsUnsafe(): |
| 4312 valid_test += """ |
| 4313 decoder_->set_unsafe_es3_apis_enabled(true); |
| 4314 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4315 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4316 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4317 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 4318 } |
| 4319 """ |
| 4320 else: |
| 4321 valid_test += """ |
4158 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4322 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
4159 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4323 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
4160 } | 4324 } |
4161 """ | 4325 """ |
4162 if func.GetInfo("gen_func"): | 4326 if func.GetInfo("gen_func"): |
4163 valid_test += """ | 4327 valid_test += """ |
4164 TEST_P(%(test_name)s, %(name)sValidArgsNewId) { | 4328 TEST_P(%(test_name)s, %(name)sValidArgsNewId) { |
4165 EXPECT_CALL(*gl_, %(gl_func_name)s(kNewServiceId)); | 4329 EXPECT_CALL(*gl_, %(gl_func_name)s(kNewServiceId)); |
4166 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _)) | 4330 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _)) |
4167 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | 4331 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
4168 SpecializedSetup<cmds::%(name)s, 0>(true); | 4332 SpecializedSetup<cmds::%(name)s, 0>(true); |
4169 cmds::%(name)s cmd; | 4333 cmds::%(name)s cmd; |
4170 cmd.Init(kNewClientId); | 4334 cmd.Init(kNewClientId); |
4171 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4335 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
4172 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4336 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
4173 EXPECT_TRUE(Get%(resource_type)s(kNewClientId) != NULL); | 4337 EXPECT_TRUE(Get%(resource_type)s(kNewClientId) != NULL); |
4174 } | 4338 } |
4175 """ | 4339 """ |
4176 self.WriteValidUnitTest(func, file, valid_test, { | 4340 self.WriteValidUnitTest(func, file, valid_test, { |
4177 'resource_type': func.GetOriginalArgs()[0].resource_type, | 4341 'resource_type': func.GetOriginalArgs()[0].resource_type, |
4178 'gl_gen_func_name': func.GetInfo("gen_func"), | 4342 'gl_gen_func_name': func.GetInfo("gen_func"), |
4179 }, *extras) | 4343 }, *extras) |
4180 else: | 4344 else: |
4181 valid_test = """ | 4345 valid_test = """ |
4182 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4346 TEST_P(%(test_name)s, %(name)sValidArgs) { |
4183 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); | 4347 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); |
4184 SpecializedSetup<cmds::%(name)s, 0>(true); | 4348 SpecializedSetup<cmds::%(name)s, 0>(true); |
4185 cmds::%(name)s cmd; | 4349 cmds::%(name)s cmd; |
4186 cmd.Init(%(args)s); | 4350 cmd.Init(%(args)s);""" |
| 4351 if func.IsUnsafe(): |
| 4352 valid_test += """ |
| 4353 decoder_->set_unsafe_es3_apis_enabled(true); |
| 4354 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4355 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4356 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4357 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 4358 } |
| 4359 """ |
| 4360 else: |
| 4361 valid_test += """ |
4187 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4362 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
4188 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4363 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
4189 } | 4364 } |
4190 """ | 4365 """ |
4191 if func.GetInfo("gen_func"): | 4366 if func.GetInfo("gen_func"): |
4192 valid_test += """ | 4367 valid_test += """ |
4193 TEST_P(%(test_name)s, %(name)sValidArgsNewId) { | 4368 TEST_P(%(test_name)s, %(name)sValidArgsNewId) { |
4194 EXPECT_CALL(*gl_, %(gl_func_name)s(%(first_gl_arg)s, kNewServiceId)); | 4369 EXPECT_CALL(*gl_, %(gl_func_name)s(%(first_gl_arg)s, kNewServiceId)); |
4195 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _)) | 4370 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _)) |
4196 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | 4371 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4232 | 4407 |
4233 file.Write("%s GLES2Implementation::%s(%s) {\n" % | 4408 file.Write("%s GLES2Implementation::%s(%s) {\n" % |
4234 (func.return_type, func.original_name, | 4409 (func.return_type, func.original_name, |
4235 func.MakeTypedOriginalArgString(""))) | 4410 func.MakeTypedOriginalArgString(""))) |
4236 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") | 4411 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") |
4237 func.WriteDestinationInitalizationValidation(file) | 4412 func.WriteDestinationInitalizationValidation(file) |
4238 self.WriteClientGLCallLog(func, file) | 4413 self.WriteClientGLCallLog(func, file) |
4239 for arg in func.GetOriginalArgs(): | 4414 for arg in func.GetOriginalArgs(): |
4240 arg.WriteClientSideValidationCode(file, func) | 4415 arg.WriteClientSideValidationCode(file, func) |
4241 | 4416 |
4242 code = """ if (Is%(type)sReservedId(%(id)s)) { | 4417 if func.IsUnsafe(): |
| 4418 code = """ helper_->%(name)s(%(arg_string)s); |
| 4419 CheckGLError(); |
| 4420 } |
| 4421 |
| 4422 """ |
| 4423 else: |
| 4424 code = """ if (Is%(type)sReservedId(%(id)s)) { |
4243 SetGLError(GL_INVALID_OPERATION, "%(name)s\", \"%(id)s reserved id"); | 4425 SetGLError(GL_INVALID_OPERATION, "%(name)s\", \"%(id)s reserved id"); |
4244 return; | 4426 return; |
4245 } | 4427 } |
4246 %(name)sHelper(%(arg_string)s); | 4428 %(name)sHelper(%(arg_string)s); |
4247 CheckGLError(); | 4429 CheckGLError(); |
4248 } | 4430 } |
4249 | 4431 |
4250 """ | 4432 """ |
4251 name_arg = None | 4433 name_arg = None |
4252 if len(func.GetOriginalArgs()) == 1: | 4434 if len(func.GetOriginalArgs()) == 1: |
(...skipping 18 matching lines...) Expand all Loading... |
4271 return | 4453 return |
4272 code = """ | 4454 code = """ |
4273 TEST_F(GLES2ImplementationTest, %(name)s) { | 4455 TEST_F(GLES2ImplementationTest, %(name)s) { |
4274 struct Cmds { | 4456 struct Cmds { |
4275 cmds::%(name)s cmd; | 4457 cmds::%(name)s cmd; |
4276 }; | 4458 }; |
4277 Cmds expected; | 4459 Cmds expected; |
4278 expected.cmd.Init(%(cmd_args)s); | 4460 expected.cmd.Init(%(cmd_args)s); |
4279 | 4461 |
4280 gl_->%(name)s(%(args)s); | 4462 gl_->%(name)s(%(args)s); |
4281 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 4463 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));""" |
| 4464 if not func.IsUnsafe(): |
| 4465 code += """ |
4282 ClearCommands(); | 4466 ClearCommands(); |
4283 gl_->%(name)s(%(args)s); | 4467 gl_->%(name)s(%(args)s); |
4284 EXPECT_TRUE(NoCommandsWritten()); | 4468 EXPECT_TRUE(NoCommandsWritten());""" |
| 4469 code += """ |
4285 } | 4470 } |
4286 """ | 4471 """ |
4287 cmd_arg_strings = [ | 4472 cmd_arg_strings = [ |
4288 arg.GetValidClientSideCmdArg(func) for arg in func.GetCmdArgs() | 4473 arg.GetValidClientSideCmdArg(func) for arg in func.GetCmdArgs() |
4289 ] | 4474 ] |
4290 gl_arg_strings = [ | 4475 gl_arg_strings = [ |
4291 arg.GetValidClientSideArg(func) for arg in func.GetOriginalArgs() | 4476 arg.GetValidClientSideArg(func) for arg in func.GetOriginalArgs() |
4292 ] | 4477 ] |
4293 | 4478 |
4294 file.Write(code % { | 4479 file.Write(code % { |
(...skipping 24 matching lines...) Expand all Loading... |
4319 | 4504 |
4320 def WriteHandlerImplementation (self, func, file): | 4505 def WriteHandlerImplementation (self, func, file): |
4321 """Overrriden from TypeHandler.""" | 4506 """Overrriden from TypeHandler.""" |
4322 file.Write(" if (!%sHelper(n, %s)) {\n" | 4507 file.Write(" if (!%sHelper(n, %s)) {\n" |
4323 " return error::kInvalidArguments;\n" | 4508 " return error::kInvalidArguments;\n" |
4324 " }\n" % | 4509 " }\n" % |
4325 (func.name, func.GetLastOriginalArg().name)) | 4510 (func.name, func.GetLastOriginalArg().name)) |
4326 | 4511 |
4327 def WriteImmediateHandlerImplementation(self, func, file): | 4512 def WriteImmediateHandlerImplementation(self, func, file): |
4328 """Overrriden from TypeHandler.""" | 4513 """Overrriden from TypeHandler.""" |
4329 file.Write(" if (!%sHelper(n, %s)) {\n" | 4514 if func.IsUnsafe(): |
4330 " return error::kInvalidArguments;\n" | 4515 file.Write(""" for (GLsizei ii = 0; ii < n; ++ii) { |
4331 " }\n" % | 4516 if (group_->Get%(resource_name)sServiceId(%(last_arg_name)s[ii], NULL)) { |
4332 (func.original_name, func.GetLastOriginalArg().name)) | 4517 return error::kInvalidArguments; |
| 4518 } |
| 4519 } |
| 4520 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
| 4521 gl%(func_name)s(n, service_ids.get()); |
| 4522 for (GLsizei ii = 0; ii < n; ++ii) { |
| 4523 group_->Add%(resource_name)sId(%(last_arg_name)s[ii], service_ids[ii]); |
| 4524 } |
| 4525 """ % { 'func_name': func.original_name, |
| 4526 'last_arg_name': func.GetLastOriginalArg().name, |
| 4527 'resource_name': func.GetInfo('resource_type') }) |
| 4528 else: |
| 4529 file.Write(" if (!%sHelper(n, %s)) {\n" |
| 4530 " return error::kInvalidArguments;\n" |
| 4531 " }\n" % |
| 4532 (func.original_name, func.GetLastOriginalArg().name)) |
4333 | 4533 |
4334 def WriteGLES2Implementation(self, func, file): | 4534 def WriteGLES2Implementation(self, func, file): |
4335 """Overrriden from TypeHandler.""" | 4535 """Overrriden from TypeHandler.""" |
4336 log_code = (""" GPU_CLIENT_LOG_CODE_BLOCK({ | 4536 log_code = (""" GPU_CLIENT_LOG_CODE_BLOCK({ |
4337 for (GLsizei i = 0; i < n; ++i) { | 4537 for (GLsizei i = 0; i < n; ++i) { |
4338 GPU_CLIENT_LOG(" " << i << ": " << %s[i]); | 4538 GPU_CLIENT_LOG(" " << i << ": " << %s[i]); |
4339 } | 4539 } |
4340 });""" % func.GetOriginalArgs()[1].name) | 4540 });""" % func.GetOriginalArgs()[1].name) |
4341 args = { | 4541 args = { |
4342 'log_code': log_code, | 4542 'log_code': log_code, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4408 """Overrriden from TypeHandler.""" | 4608 """Overrriden from TypeHandler.""" |
4409 valid_test = """ | 4609 valid_test = """ |
4410 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4610 TEST_P(%(test_name)s, %(name)sValidArgs) { |
4411 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) | 4611 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) |
4412 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | 4612 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
4413 GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; | 4613 GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; |
4414 SpecializedSetup<cmds::%(name)s, 0>(true); | 4614 SpecializedSetup<cmds::%(name)s, 0>(true); |
4415 cmds::%(name)s cmd; | 4615 cmds::%(name)s cmd; |
4416 cmd.Init(%(args)s); | 4616 cmd.Init(%(args)s); |
4417 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4617 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
4418 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4618 EXPECT_EQ(GL_NO_ERROR, GetGLError());""" |
4419 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) != NULL); | 4619 if func.IsUnsafe(): |
| 4620 valid_test += """ |
| 4621 GLuint service_id; |
| 4622 EXPECT_TRUE(Get%(resource_name)sServiceId(kNewClientId, &service_id)); |
| 4623 EXPECT_EQ(kNewServiceId, service_id) |
| 4624 } |
| 4625 """ |
| 4626 else: |
| 4627 valid_test += """ |
| 4628 EXPECT_TRUE(Get%(resource_name)s(kNewClientId, &service_id) != NULL); |
4420 } | 4629 } |
4421 """ | 4630 """ |
4422 self.WriteValidUnitTest(func, file, valid_test, { | 4631 self.WriteValidUnitTest(func, file, valid_test, { |
4423 'resource_name': func.GetInfo('resource_type'), | 4632 'resource_name': func.GetInfo('resource_type'), |
4424 }, *extras) | 4633 }, *extras) |
4425 invalid_test = """ | 4634 invalid_test = """ |
4426 TEST_P(%(test_name)s, %(name)sInvalidArgs) { | 4635 TEST_P(%(test_name)s, %(name)sInvalidArgs) { |
4427 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); | 4636 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); |
4428 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_; | 4637 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_; |
4429 SpecializedSetup<cmds::%(name)s, 0>(false); | 4638 SpecializedSetup<cmds::%(name)s, 0>(false); |
4430 cmds::%(name)s cmd; | 4639 cmds::%(name)s cmd; |
4431 cmd.Init(%(args)s); | 4640 cmd.Init(%(args)s); |
4432 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); | 4641 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); |
4433 } | 4642 } |
4434 """ | 4643 """ |
4435 self.WriteValidUnitTest(func, file, invalid_test, { | 4644 self.WriteValidUnitTest(func, file, invalid_test, { |
4436 'resource_name': func.GetInfo('resource_type').lower(), | 4645 'resource_name': func.GetInfo('resource_type').lower(), |
4437 }, *extras) | 4646 }, *extras) |
4438 | 4647 |
4439 def WriteImmediateServiceUnitTest(self, func, file, *extras): | 4648 def WriteImmediateServiceUnitTest(self, func, file, *extras): |
4440 """Overrriden from TypeHandler.""" | 4649 """Overrriden from TypeHandler.""" |
4441 valid_test = """ | 4650 valid_test = """ |
4442 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4651 TEST_P(%(test_name)s, %(name)sValidArgs) { |
4443 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) | 4652 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) |
4444 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | 4653 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
4445 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); | 4654 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); |
4446 GLuint temp = kNewClientId; | 4655 GLuint temp = kNewClientId; |
4447 SpecializedSetup<cmds::%(name)s, 0>(true); | 4656 SpecializedSetup<cmds::%(name)s, 0>(true);""" |
| 4657 if func.IsUnsafe(): |
| 4658 valid_test += """ |
| 4659 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 4660 valid_test += """ |
4448 cmd->Init(1, &temp); | 4661 cmd->Init(1, &temp); |
4449 EXPECT_EQ(error::kNoError, | 4662 EXPECT_EQ(error::kNoError, |
4450 ExecuteImmediateCmd(*cmd, sizeof(temp))); | 4663 ExecuteImmediateCmd(*cmd, sizeof(temp))); |
4451 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4664 EXPECT_EQ(GL_NO_ERROR, GetGLError());""" |
| 4665 if func.IsUnsafe(): |
| 4666 valid_test += """ |
| 4667 GLuint service_id; |
| 4668 EXPECT_TRUE(Get%(resource_name)sServiceId(kNewClientId, &service_id)); |
| 4669 EXPECT_EQ(kNewServiceId, service_id); |
| 4670 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4671 EXPECT_EQ(error::kUnknownCommand, |
| 4672 ExecuteImmediateCmd(*cmd, sizeof(temp))); |
| 4673 } |
| 4674 """ |
| 4675 else: |
| 4676 valid_test += """ |
4452 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) != NULL); | 4677 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) != NULL); |
4453 } | 4678 } |
4454 """ | 4679 """ |
4455 self.WriteValidUnitTest(func, file, valid_test, { | 4680 self.WriteValidUnitTest(func, file, valid_test, { |
4456 'resource_name': func.GetInfo('resource_type'), | 4681 'resource_name': func.GetInfo('resource_type'), |
4457 }, *extras) | 4682 }, *extras) |
4458 invalid_test = """ | 4683 invalid_test = """ |
4459 TEST_P(%(test_name)s, %(name)sInvalidArgs) { | 4684 TEST_P(%(test_name)s, %(name)sInvalidArgs) { |
4460 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); | 4685 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); |
4461 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); | 4686 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); |
4462 SpecializedSetup<cmds::%(name)s, 0>(false); | 4687 SpecializedSetup<cmds::%(name)s, 0>(false); |
4463 cmd->Init(1, &client_%(resource_name)s_id_); | 4688 cmd->Init(1, &client_%(resource_name)s_id_);""" |
| 4689 if func.IsUnsafe(): |
| 4690 invalid_test += """ |
| 4691 decoder_->set_unsafe_es3_apis_enabled(true); |
| 4692 EXPECT_EQ(error::kInvalidArguments, |
| 4693 ExecuteImmediateCmd(*cmd, sizeof(&client_%(resource_name)s_id_))); |
| 4694 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4695 } |
| 4696 """ |
| 4697 else: |
| 4698 invalid_test += """ |
4464 EXPECT_EQ(error::kInvalidArguments, | 4699 EXPECT_EQ(error::kInvalidArguments, |
4465 ExecuteImmediateCmd(*cmd, sizeof(&client_%(resource_name)s_id_))); | 4700 ExecuteImmediateCmd(*cmd, sizeof(&client_%(resource_name)s_id_))); |
4466 } | 4701 } |
4467 """ | 4702 """ |
4468 self.WriteValidUnitTest(func, file, invalid_test, { | 4703 self.WriteValidUnitTest(func, file, invalid_test, { |
4469 'resource_name': func.GetInfo('resource_type').lower(), | 4704 'resource_name': func.GetInfo('resource_type').lower(), |
4470 }, *extras) | 4705 }, *extras) |
4471 | 4706 |
4472 def WriteImmediateCmdComputeSize(self, func, file): | 4707 def WriteImmediateCmdComputeSize(self, func, file): |
4473 """Overrriden from TypeHandler.""" | 4708 """Overrriden from TypeHandler.""" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4737 def WriteImmediateServiceUnitTest(self, func, file, *extras): | 4972 def WriteImmediateServiceUnitTest(self, func, file, *extras): |
4738 """Overrriden from TypeHandler.""" | 4973 """Overrriden from TypeHandler.""" |
4739 valid_test = """ | 4974 valid_test = """ |
4740 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4975 TEST_P(%(test_name)s, %(name)sValidArgs) { |
4741 EXPECT_CALL( | 4976 EXPECT_CALL( |
4742 *gl_, | 4977 *gl_, |
4743 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId))) | 4978 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId))) |
4744 .Times(1); | 4979 .Times(1); |
4745 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); | 4980 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); |
4746 SpecializedSetup<cmds::%(name)s, 0>(true); | 4981 SpecializedSetup<cmds::%(name)s, 0>(true); |
4747 cmd.Init(1, &client_%(resource_name)s_id_); | 4982 cmd.Init(1, &client_%(resource_name)s_id_);""" |
| 4983 if func.IsUnsafe(): |
| 4984 valid_test += """ |
| 4985 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 4986 valid_test += """ |
4748 EXPECT_EQ(error::kNoError, | 4987 EXPECT_EQ(error::kNoError, |
4749 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_))); | 4988 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_))); |
4750 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4989 EXPECT_EQ(GL_NO_ERROR, GetGLError());""" |
| 4990 if func.IsUnsafe(): |
| 4991 valid_test += """ |
| 4992 EXPECT_FALSE(Get%(upper_resource_name)sServiceId( |
| 4993 client_%(resource_name)s_id_, NULL)); |
| 4994 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4995 EXPECT_EQ(error::kUnknownCommand, |
| 4996 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_))); |
| 4997 } |
| 4998 """ |
| 4999 else: |
| 5000 valid_test += """ |
4751 EXPECT_TRUE( | 5001 EXPECT_TRUE( |
4752 Get%(upper_resource_name)s(client_%(resource_name)s_id_) == NULL); | 5002 Get%(upper_resource_name)s(client_%(resource_name)s_id_) == NULL); |
4753 } | 5003 } |
4754 """ | 5004 """ |
4755 self.WriteValidUnitTest(func, file, valid_test, { | 5005 self.WriteValidUnitTest(func, file, valid_test, { |
4756 'resource_name': func.GetInfo('resource_type').lower(), | 5006 'resource_name': func.GetInfo('resource_type').lower(), |
4757 'upper_resource_name': func.GetInfo('resource_type'), | 5007 'upper_resource_name': func.GetInfo('resource_type'), |
4758 }, *extras) | 5008 }, *extras) |
4759 invalid_test = """ | 5009 invalid_test = """ |
4760 TEST_P(%(test_name)s, %(name)sInvalidArgs) { | 5010 TEST_P(%(test_name)s, %(name)sInvalidArgs) { |
4761 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); | 5011 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); |
4762 SpecializedSetup<cmds::%(name)s, 0>(false); | 5012 SpecializedSetup<cmds::%(name)s, 0>(false); |
4763 GLuint temp = kInvalidClientId; | 5013 GLuint temp = kInvalidClientId; |
4764 cmd.Init(1, &temp); | 5014 cmd.Init(1, &temp);""" |
| 5015 if func.IsUnsafe(): |
| 5016 invalid_test += """ |
| 5017 decoder_->set_unsafe_es3_apis_enabled(true); |
| 5018 EXPECT_EQ(error::kNoError, |
| 5019 ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 5020 decoder_->set_unsafe_es3_apis_enabled(false); |
| 5021 EXPECT_EQ(error::kUnknownCommand, |
| 5022 ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 5023 } |
| 5024 """ |
| 5025 else: |
| 5026 invalid_test += """ |
4765 EXPECT_EQ(error::kNoError, | 5027 EXPECT_EQ(error::kNoError, |
4766 ExecuteImmediateCmd(cmd, sizeof(temp))); | 5028 ExecuteImmediateCmd(cmd, sizeof(temp))); |
4767 } | 5029 } |
4768 """ | 5030 """ |
4769 self.WriteValidUnitTest(func, file, invalid_test, *extras) | 5031 self.WriteValidUnitTest(func, file, invalid_test, *extras) |
4770 | 5032 |
4771 def WriteHandlerImplementation (self, func, file): | 5033 def WriteHandlerImplementation (self, func, file): |
4772 """Overrriden from TypeHandler.""" | 5034 """Overrriden from TypeHandler.""" |
4773 file.Write(" %sHelper(n, %s);\n" % | 5035 file.Write(" %sHelper(n, %s);\n" % |
4774 (func.name, func.GetLastOriginalArg().name)) | 5036 (func.name, func.GetLastOriginalArg().name)) |
4775 | 5037 |
4776 def WriteImmediateHandlerImplementation (self, func, file): | 5038 def WriteImmediateHandlerImplementation (self, func, file): |
4777 """Overrriden from TypeHandler.""" | 5039 """Overrriden from TypeHandler.""" |
4778 file.Write(" %sHelper(n, %s);\n" % | 5040 if func.IsUnsafe(): |
4779 (func.original_name, func.GetLastOriginalArg().name)) | 5041 file.Write(""" for (GLsizei ii = 0; ii < n; ++ii) { |
| 5042 GLuint service_id = 0; |
| 5043 if (group_->Get%(resource_type)sServiceId( |
| 5044 %(last_arg_name)s[ii], &service_id)) { |
| 5045 glDelete%(resource_type)ss(1, &service_id); |
| 5046 group_->Remove%(resource_type)sId(%(last_arg_name)s[ii]); |
| 5047 } |
| 5048 } |
| 5049 """ % { 'resource_type': func.GetInfo('resource_type'), |
| 5050 'last_arg_name': func.GetLastOriginalArg().name }) |
| 5051 else: |
| 5052 file.Write(" %sHelper(n, %s);\n" % |
| 5053 (func.original_name, func.GetLastOriginalArg().name)) |
4780 | 5054 |
4781 def WriteGLES2Implementation(self, func, file): | 5055 def WriteGLES2Implementation(self, func, file): |
4782 """Overrriden from TypeHandler.""" | 5056 """Overrriden from TypeHandler.""" |
4783 impl_decl = func.GetInfo('impl_decl') | 5057 impl_decl = func.GetInfo('impl_decl') |
4784 if impl_decl == None or impl_decl == True: | 5058 if impl_decl == None or impl_decl == True: |
4785 args = { | 5059 args = { |
4786 'return_type': func.return_type, | 5060 'return_type': func.return_type, |
4787 'name': func.original_name, | 5061 'name': func.original_name, |
4788 'typed_args': func.MakeTypedOriginalArgString(""), | 5062 'typed_args': func.MakeTypedOriginalArgString(""), |
4789 'args': func.MakeOriginalArgString(""), | 5063 'args': func.MakeOriginalArgString(""), |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5223 'data_type': self.GetArrayType(func), | 5497 'data_type': self.GetArrayType(func), |
5224 'data_count': self.GetArrayCount(func), | 5498 'data_count': self.GetArrayCount(func), |
5225 'data_value': func.GetInfo('data_value') or '0', | 5499 'data_value': func.GetInfo('data_value') or '0', |
5226 'gl_args': ", ".join(gl_arg_strings), | 5500 'gl_args': ", ".join(gl_arg_strings), |
5227 'gl_any_args': ", ".join(gl_any_strings), | 5501 'gl_any_args': ", ".join(gl_any_strings), |
5228 } | 5502 } |
5229 self.WriteValidUnitTest(func, file, valid_test, extra, *extras) | 5503 self.WriteValidUnitTest(func, file, valid_test, extra, *extras) |
5230 | 5504 |
5231 invalid_test = """ | 5505 invalid_test = """ |
5232 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { | 5506 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { |
5233 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); | 5507 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>();""" |
| 5508 if func.IsUnsafe(): |
| 5509 invalid_test += """ |
| 5510 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(1); |
| 5511 """ |
| 5512 else: |
| 5513 invalid_test += """ |
5234 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(0); | 5514 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(0); |
| 5515 """ |
| 5516 invalid_test += """ |
5235 SpecializedSetup<cmds::%(name)s, 0>(false); | 5517 SpecializedSetup<cmds::%(name)s, 0>(false); |
5236 %(data_type)s temp[%(data_count)s] = { %(data_value)s, }; | 5518 %(data_type)s temp[%(data_count)s] = { %(data_value)s, }; |
5237 cmd.Init(%(all_but_last_args)s, &temp[0]); | 5519 cmd.Init(%(all_but_last_args)s, &temp[0]);""" |
| 5520 if func.IsUnsafe(): |
| 5521 invalid_test += """ |
| 5522 decoder_->set_unsafe_es3_apis_enabled(true); |
5238 EXPECT_EQ(error::%(parse_result)s, | 5523 EXPECT_EQ(error::%(parse_result)s, |
5239 ExecuteImmediateCmd(cmd, sizeof(temp)));%(gl_error_test)s | 5524 ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 5525 decoder_->set_unsafe_es3_apis_enabled(false); |
| 5526 } |
| 5527 """ |
| 5528 else: |
| 5529 invalid_test += """ |
| 5530 EXPECT_EQ(error::%(parse_result)s, |
| 5531 ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 5532 %(gl_error_test)s |
5240 } | 5533 } |
5241 """ | 5534 """ |
5242 self.WriteInvalidUnitTest(func, file, invalid_test, extra, *extras) | 5535 self.WriteInvalidUnitTest(func, file, invalid_test, extra, *extras) |
5243 | 5536 |
5244 def WriteGetDataSizeCode(self, func, file): | 5537 def WriteGetDataSizeCode(self, func, file): |
5245 """Overrriden from TypeHandler.""" | 5538 """Overrriden from TypeHandler.""" |
5246 code = """ uint32_t data_size; | 5539 code = """ uint32_t data_size; |
5247 if (!ComputeDataSize(1, sizeof(%s), %d, &data_size)) { | 5540 if (!ComputeDataSize(1, sizeof(%s), %d, &data_size)) { |
5248 return error::kOutOfBounds; | 5541 return error::kOutOfBounds; |
5249 } | 5542 } |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6019 if func.GetInfo('result') == None: | 6312 if func.GetInfo('result') == None: |
6020 func.AddInfo('result', ['uint32_t']) | 6313 func.AddInfo('result', ['uint32_t']) |
6021 | 6314 |
6022 def WriteServiceUnitTest(self, func, file, *extras): | 6315 def WriteServiceUnitTest(self, func, file, *extras): |
6023 """Overrriden from TypeHandler.""" | 6316 """Overrriden from TypeHandler.""" |
6024 valid_test = """ | 6317 valid_test = """ |
6025 TEST_P(%(test_name)s, %(name)sValidArgs) { | 6318 TEST_P(%(test_name)s, %(name)sValidArgs) { |
6026 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); | 6319 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); |
6027 SpecializedSetup<cmds::%(name)s, 0>(true); | 6320 SpecializedSetup<cmds::%(name)s, 0>(true); |
6028 cmds::%(name)s cmd; | 6321 cmds::%(name)s cmd; |
6029 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); | 6322 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);""" |
| 6323 if func.IsUnsafe(): |
| 6324 valid_test += """ |
| 6325 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 6326 valid_test += """ |
6030 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 6327 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
6031 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 6328 EXPECT_EQ(GL_NO_ERROR, GetGLError());""" |
| 6329 if func.IsUnsafe(): |
| 6330 valid_test += """ |
| 6331 decoder_->set_unsafe_es3_apis_enabled(false); |
| 6332 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));""" |
| 6333 valid_test += """ |
6032 } | 6334 } |
6033 """ | 6335 """ |
6034 comma = "" | 6336 comma = "" |
6035 if len(func.GetOriginalArgs()): | 6337 if len(func.GetOriginalArgs()): |
6036 comma =", " | 6338 comma =", " |
6037 self.WriteValidUnitTest(func, file, valid_test, { | 6339 self.WriteValidUnitTest(func, file, valid_test, { |
6038 'comma': comma, | 6340 'comma': comma, |
6039 }, *extras) | 6341 }, *extras) |
6040 | 6342 |
6041 invalid_test = """ | 6343 invalid_test = """ |
6042 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { | 6344 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { |
6043 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); | 6345 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); |
6044 SpecializedSetup<cmds::%(name)s, 0>(false); | 6346 SpecializedSetup<cmds::%(name)s, 0>(false); |
6045 cmds::%(name)s cmd; | 6347 cmds::%(name)s cmd; |
6046 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); | 6348 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); |
6047 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s | 6349 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s |
6048 } | 6350 } |
6049 """ | 6351 """ |
6050 self.WriteInvalidUnitTest(func, file, invalid_test, { | 6352 self.WriteInvalidUnitTest(func, file, invalid_test, { |
6051 'comma': comma, | 6353 'comma': comma, |
6052 }, *extras) | 6354 }, *extras) |
6053 | 6355 |
6054 invalid_test = """ | 6356 invalid_test = """ |
6055 TEST_P(%(test_name)s, %(name)sInvalidArgsBadSharedMemoryId) { | 6357 TEST_P(%(test_name)s, %(name)sInvalidArgsBadSharedMemoryId) { |
6056 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); | 6358 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); |
6057 SpecializedSetup<cmds::%(name)s, 0>(false); | 6359 SpecializedSetup<cmds::%(name)s, 0>(false);""" |
| 6360 if func.IsUnsafe(): |
| 6361 invalid_test += """ |
| 6362 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 6363 invalid_test += """ |
6058 cmds::%(name)s cmd; | 6364 cmds::%(name)s cmd; |
6059 cmd.Init(%(args)s%(comma)skInvalidSharedMemoryId, shared_memory_offset_); | 6365 cmd.Init(%(args)s%(comma)skInvalidSharedMemoryId, shared_memory_offset_); |
6060 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | 6366 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
6061 cmd.Init(%(args)s%(comma)sshared_memory_id_, kInvalidSharedMemoryOffset); | 6367 cmd.Init(%(args)s%(comma)sshared_memory_id_, kInvalidSharedMemoryOffset); |
6062 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | 6368 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));""" |
| 6369 if func.IsUnsafe(): |
| 6370 invalid_test += """ |
| 6371 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 6372 invalid_test += """ |
6063 } | 6373 } |
6064 """ | 6374 """ |
6065 self.WriteValidUnitTest(func, file, invalid_test, { | 6375 self.WriteValidUnitTest(func, file, invalid_test, { |
6066 'comma': comma, | 6376 'comma': comma, |
6067 }, *extras) | 6377 }, *extras) |
6068 | 6378 |
6069 def WriteServiceImplementation(self, func, file): | 6379 def WriteServiceImplementation(self, func, file): |
6070 """Overrriden from TypeHandler.""" | 6380 """Overrriden from TypeHandler.""" |
6071 self.WriteServiceHandlerFunctionHeader(func, file) | 6381 self.WriteServiceHandlerFunctionHeader(func, file) |
6072 args = func.GetOriginalArgs() | 6382 args = func.GetOriginalArgs() |
6073 for arg in args: | 6383 for arg in args: |
6074 arg.WriteGetCode(file) | 6384 arg.WriteGetCode(file) |
6075 | 6385 |
6076 code = """ typedef cmds::%(func_name)s::Result Result; | 6386 code = """ typedef cmds::%(func_name)s::Result Result; |
6077 Result* result_dst = GetSharedMemoryAs<Result*>( | 6387 Result* result_dst = GetSharedMemoryAs<Result*>( |
6078 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); | 6388 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); |
6079 if (!result_dst) { | 6389 if (!result_dst) { |
6080 return error::kOutOfBounds; | 6390 return error::kOutOfBounds; |
6081 } | 6391 } |
6082 """ | 6392 """ |
6083 file.Write(code % {'func_name': func.name}) | 6393 file.Write(code % {'func_name': func.name}) |
6084 func.WriteHandlerValidation(file) | 6394 func.WriteHandlerValidation(file) |
| 6395 if func.IsUnsafe() and func.GetInfo('id_mapping'): |
| 6396 for id_type in func.GetInfo('id_mapping'): |
| 6397 file.Write(" group_->Get%sServiceId(%s, &%s);\n" % |
| 6398 (id_type, id_type.lower(), id_type.lower())) |
6085 file.Write(" *result_dst = %s(%s);\n" % | 6399 file.Write(" *result_dst = %s(%s);\n" % |
6086 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 6400 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
6087 file.Write(" return error::kNoError;\n") | 6401 file.Write(" return error::kNoError;\n") |
6088 file.Write("}\n") | 6402 file.Write("}\n") |
6089 file.Write("\n") | 6403 file.Write("\n") |
6090 | 6404 |
6091 def WriteGLES2Implementation(self, func, file): | 6405 def WriteGLES2Implementation(self, func, file): |
6092 """Overrriden from TypeHandler.""" | 6406 """Overrriden from TypeHandler.""" |
6093 impl_func = func.GetInfo('impl_func') | 6407 impl_func = func.GetInfo('impl_func') |
6094 if impl_func == None or impl_func == True: | 6408 if impl_func == None or impl_func == True: |
(...skipping 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8796 continue | 9110 continue |
8797 file.Write("VISIT_GL_CALL(%s, %s, (%s), (%s))\n" % | 9111 file.Write("VISIT_GL_CALL(%s, %s, (%s), (%s))\n" % |
8798 (func.name, func.return_type, | 9112 (func.name, func.return_type, |
8799 func.MakeTypedOriginalArgString(""), | 9113 func.MakeTypedOriginalArgString(""), |
8800 func.MakeOriginalArgString(""))) | 9114 func.MakeOriginalArgString(""))) |
8801 | 9115 |
8802 file.Close() | 9116 file.Close() |
8803 self.generated_cpp_filenames.append(file.filename) | 9117 self.generated_cpp_filenames.append(file.filename) |
8804 | 9118 |
8805 def Format(generated_files): | 9119 def Format(generated_files): |
| 9120 formatter = "clang-format" |
| 9121 if platform.system() == "Windows": |
| 9122 formatter += ".bat" |
8806 for filename in generated_files: | 9123 for filename in generated_files: |
8807 call(["clang-format", "-i", "-style=chromium", filename]) | 9124 call([formatter, "-i", "-style=chromium", filename]) |
8808 | 9125 |
8809 def main(argv): | 9126 def main(argv): |
8810 """This is the main function.""" | 9127 """This is the main function.""" |
8811 parser = OptionParser() | 9128 parser = OptionParser() |
8812 parser.add_option( | 9129 parser.add_option( |
8813 "--output-dir", | 9130 "--output-dir", |
8814 help="base directory for resulting files, under chrome/src. default is " | 9131 help="base directory for resulting files, under chrome/src. default is " |
8815 "empty. Use this if you want the result stored under gen.") | 9132 "empty. Use this if you want the result stored under gen.") |
8816 parser.add_option( | 9133 parser.add_option( |
8817 "-v", "--verbose", action="store_true", | 9134 "-v", "--verbose", action="store_true", |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8916 Format(gen.generated_cpp_filenames) | 9233 Format(gen.generated_cpp_filenames) |
8917 | 9234 |
8918 if gen.errors > 0: | 9235 if gen.errors > 0: |
8919 print "%d errors" % gen.errors | 9236 print "%d errors" % gen.errors |
8920 return 1 | 9237 return 1 |
8921 return 0 | 9238 return 0 |
8922 | 9239 |
8923 | 9240 |
8924 if __name__ == '__main__': | 9241 if __name__ == '__main__': |
8925 sys.exit(main(sys.argv[1:])) | 9242 sys.exit(main(sys.argv[1:])) |
OLD | NEW |