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 |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 ], | 1361 ], |
1362 }, | 1362 }, |
1363 'ResetStatus': { | 1363 'ResetStatus': { |
1364 'type': 'GLenum', | 1364 'type': 'GLenum', |
1365 'valid': [ | 1365 'valid': [ |
1366 'GL_GUILTY_CONTEXT_RESET_ARB', | 1366 'GL_GUILTY_CONTEXT_RESET_ARB', |
1367 'GL_INNOCENT_CONTEXT_RESET_ARB', | 1367 'GL_INNOCENT_CONTEXT_RESET_ARB', |
1368 'GL_UNKNOWN_CONTEXT_RESET_ARB', | 1368 'GL_UNKNOWN_CONTEXT_RESET_ARB', |
1369 ], | 1369 ], |
1370 }, | 1370 }, |
| 1371 'SyncCondition': { |
| 1372 'type': 'GLenum', |
| 1373 'is_complete': True, |
| 1374 'valid': [ |
| 1375 #TODO(zmo): avoid using the direct number. |
| 1376 '0x9117', # GL_SYNC_GPU_COMMANDS_COMPLETE |
| 1377 ], |
| 1378 'invalid': [ |
| 1379 '0', |
| 1380 ], |
| 1381 }, |
| 1382 'SyncFlags': { |
| 1383 'type': 'GLbitfield', |
| 1384 'is_complete': True, |
| 1385 'valid': [ |
| 1386 '0', |
| 1387 ], |
| 1388 'invalid': [ |
| 1389 '1', |
| 1390 ], |
| 1391 }, |
1371 } | 1392 } |
1372 | 1393 |
1373 # This table specifies the different pepper interfaces that are supported for | 1394 # This table specifies the different pepper interfaces that are supported for |
1374 # GL commands. 'dev' is true if it's a dev interface. | 1395 # GL commands. 'dev' is true if it's a dev interface. |
1375 _PEPPER_INTERFACES = [ | 1396 _PEPPER_INTERFACES = [ |
1376 {'name': '', 'dev': False}, | 1397 {'name': '', 'dev': False}, |
1377 {'name': 'InstancedArrays', 'dev': False}, | 1398 {'name': 'InstancedArrays', 'dev': False}, |
1378 {'name': 'FramebufferBlit', 'dev': False}, | 1399 {'name': 'FramebufferBlit', 'dev': False}, |
1379 {'name': 'FramebufferMultisample', 'dev': False}, | 1400 {'name': 'FramebufferMultisample', 'dev': False}, |
1380 {'name': 'ChromiumEnableFeature', 'dev': False}, | 1401 {'name': 'ChromiumEnableFeature', 'dev': False}, |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1808 'gl_test_func': 'glDeleteBuffersARB', | 1829 'gl_test_func': 'glDeleteBuffersARB', |
1809 'resource_type': 'Buffer', | 1830 'resource_type': 'Buffer', |
1810 'resource_types': 'Buffers', | 1831 'resource_types': 'Buffers', |
1811 }, | 1832 }, |
1812 'DeleteFramebuffers': { | 1833 'DeleteFramebuffers': { |
1813 'type': 'DELn', | 1834 'type': 'DELn', |
1814 'gl_test_func': 'glDeleteFramebuffersEXT', | 1835 'gl_test_func': 'glDeleteFramebuffersEXT', |
1815 'resource_type': 'Framebuffer', | 1836 'resource_type': 'Framebuffer', |
1816 'resource_types': 'Framebuffers', | 1837 'resource_types': 'Framebuffers', |
1817 }, | 1838 }, |
1818 'DeleteProgram': {'type': 'Delete', 'decoder_func': 'DoDeleteProgram'}, | 1839 'DeleteProgram': { 'type': 'Delete' }, |
1819 'DeleteRenderbuffers': { | 1840 'DeleteRenderbuffers': { |
1820 'type': 'DELn', | 1841 'type': 'DELn', |
1821 'gl_test_func': 'glDeleteRenderbuffersEXT', | 1842 'gl_test_func': 'glDeleteRenderbuffersEXT', |
1822 'resource_type': 'Renderbuffer', | 1843 'resource_type': 'Renderbuffer', |
1823 'resource_types': 'Renderbuffers', | 1844 'resource_types': 'Renderbuffers', |
1824 }, | 1845 }, |
1825 'DeleteSamplers': { | 1846 'DeleteSamplers': { |
1826 'type': 'DELn', | 1847 'type': 'DELn', |
1827 'resource_type': 'Sampler', | 1848 'resource_type': 'Sampler', |
1828 'resource_types': 'Samplers', | 1849 'resource_types': 'Samplers', |
1829 'unsafe': True, | 1850 'unsafe': True, |
1830 }, | 1851 }, |
1831 'DeleteShader': {'type': 'Delete', 'decoder_func': 'DoDeleteShader'}, | 1852 'DeleteShader': { 'type': 'Delete' }, |
| 1853 'DeleteSync': { |
| 1854 'type': 'Delete', |
| 1855 'cmd_args': 'GLuint sync', |
| 1856 'resource_type': 'Sync', |
| 1857 'unsafe': True, |
| 1858 }, |
1832 'DeleteTextures': { | 1859 'DeleteTextures': { |
1833 'type': 'DELn', | 1860 'type': 'DELn', |
1834 'resource_type': 'Texture', | 1861 'resource_type': 'Texture', |
1835 'resource_types': 'Textures', | 1862 'resource_types': 'Textures', |
1836 }, | 1863 }, |
1837 'DeleteTransformFeedbacks': { | 1864 'DeleteTransformFeedbacks': { |
1838 'type': 'DELn', | 1865 'type': 'DELn', |
1839 'resource_type': 'TransformFeedback', | 1866 'resource_type': 'TransformFeedback', |
1840 'resource_types': 'TransformFeedbacks', | 1867 'resource_types': 'TransformFeedbacks', |
1841 'unsafe': True, | 1868 'unsafe': True, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 }, | 1903 }, |
1877 'Enable': { | 1904 'Enable': { |
1878 'decoder_func': 'DoEnable', | 1905 'decoder_func': 'DoEnable', |
1879 'impl_func': False, | 1906 'impl_func': False, |
1880 'client_test': False, | 1907 'client_test': False, |
1881 }, | 1908 }, |
1882 'EnableVertexAttribArray': { | 1909 'EnableVertexAttribArray': { |
1883 'decoder_func': 'DoEnableVertexAttribArray', | 1910 'decoder_func': 'DoEnableVertexAttribArray', |
1884 'impl_decl': False, | 1911 'impl_decl': False, |
1885 }, | 1912 }, |
| 1913 'FenceSync': { |
| 1914 'type': 'Create', |
| 1915 'client_test': False, |
| 1916 'unsafe': True, |
| 1917 }, |
1886 'Finish': { | 1918 'Finish': { |
1887 'impl_func': False, | 1919 'impl_func': False, |
1888 'client_test': False, | 1920 'client_test': False, |
1889 'decoder_func': 'DoFinish', | 1921 'decoder_func': 'DoFinish', |
1890 'defer_reads': True, | 1922 'defer_reads': True, |
1891 }, | 1923 }, |
1892 'Flush': { | 1924 'Flush': { |
1893 'impl_func': False, | 1925 'impl_func': False, |
1894 'decoder_func': 'DoFlush', | 1926 'decoder_func': 'DoFlush', |
1895 }, | 1927 }, |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2202 'unsafe': True, | 2234 'unsafe': True, |
2203 }, | 2235 }, |
2204 'IsBuffer': { | 2236 'IsBuffer': { |
2205 'type': 'Is', | 2237 'type': 'Is', |
2206 'decoder_func': 'DoIsBuffer', | 2238 'decoder_func': 'DoIsBuffer', |
2207 'expectation': False, | 2239 'expectation': False, |
2208 }, | 2240 }, |
2209 'IsEnabled': { | 2241 'IsEnabled': { |
2210 'type': 'Is', | 2242 'type': 'Is', |
2211 'decoder_func': 'DoIsEnabled', | 2243 'decoder_func': 'DoIsEnabled', |
| 2244 'client_test': False, |
2212 'impl_func': False, | 2245 'impl_func': False, |
2213 'expectation': False, | 2246 'expectation': False, |
2214 }, | 2247 }, |
2215 'IsFramebuffer': { | 2248 'IsFramebuffer': { |
2216 'type': 'Is', | 2249 'type': 'Is', |
2217 'decoder_func': 'DoIsFramebuffer', | 2250 'decoder_func': 'DoIsFramebuffer', |
2218 'expectation': False, | 2251 'expectation': False, |
2219 }, | 2252 }, |
2220 'IsProgram': { | 2253 'IsProgram': { |
2221 'type': 'Is', | 2254 'type': 'Is', |
2222 'decoder_func': 'DoIsProgram', | 2255 'decoder_func': 'DoIsProgram', |
2223 'expectation': False, | 2256 'expectation': False, |
2224 }, | 2257 }, |
2225 'IsRenderbuffer': { | 2258 'IsRenderbuffer': { |
2226 'type': 'Is', | 2259 'type': 'Is', |
2227 'decoder_func': 'DoIsRenderbuffer', | 2260 'decoder_func': 'DoIsRenderbuffer', |
2228 'expectation': False, | 2261 'expectation': False, |
2229 }, | 2262 }, |
2230 'IsShader': { | 2263 'IsShader': { |
2231 'type': 'Is', | 2264 'type': 'Is', |
2232 'decoder_func': 'DoIsShader', | 2265 'decoder_func': 'DoIsShader', |
2233 'expectation': False, | 2266 'expectation': False, |
2234 }, | 2267 }, |
2235 'IsSampler': { | 2268 'IsSampler': { |
2236 'type': 'Is', | 2269 'type': 'Is', |
2237 'id_mapping': [ 'Sampler' ], | 2270 'id_mapping': [ 'Sampler' ], |
2238 'expectation': False, | 2271 'expectation': False, |
2239 'unsafe': True, | 2272 'unsafe': True, |
2240 }, | 2273 }, |
| 2274 'IsSync': { |
| 2275 'type': 'Is', |
| 2276 'id_mapping': [ 'Sync' ], |
| 2277 'cmd_args': 'GLuint sync', |
| 2278 'expectation': False, |
| 2279 'unsafe': True, |
| 2280 }, |
2241 'IsTexture': { | 2281 'IsTexture': { |
2242 'type': 'Is', | 2282 'type': 'Is', |
2243 'decoder_func': 'DoIsTexture', | 2283 'decoder_func': 'DoIsTexture', |
2244 'expectation': False, | 2284 'expectation': False, |
2245 }, | 2285 }, |
2246 'IsTransformFeedback': { | 2286 'IsTransformFeedback': { |
2247 'type': 'Is', | 2287 'type': 'Is', |
2248 'id_mapping': [ 'TransformFeedback' ], | 2288 'id_mapping': [ 'TransformFeedback' ], |
2249 'expectation': False, | 2289 'expectation': False, |
2250 'unsafe': True, | 2290 'unsafe': True, |
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4935 class CreateHandler(TypeHandler): | 4975 class CreateHandler(TypeHandler): |
4936 """Handler for glCreate___ type functions.""" | 4976 """Handler for glCreate___ type functions.""" |
4937 | 4977 |
4938 def __init__(self): | 4978 def __init__(self): |
4939 TypeHandler.__init__(self) | 4979 TypeHandler.__init__(self) |
4940 | 4980 |
4941 def InitFunction(self, func): | 4981 def InitFunction(self, func): |
4942 """Overrriden from TypeHandler.""" | 4982 """Overrriden from TypeHandler.""" |
4943 func.AddCmdArg(Argument("client_id", 'uint32_t')) | 4983 func.AddCmdArg(Argument("client_id", 'uint32_t')) |
4944 | 4984 |
| 4985 def __GetResourceType(self, func): |
| 4986 if func.return_type == "GLsync": |
| 4987 return "Sync" |
| 4988 else: |
| 4989 return func.name[6:] # Create* |
| 4990 |
4945 def WriteServiceUnitTest(self, func, file, *extras): | 4991 def WriteServiceUnitTest(self, func, file, *extras): |
4946 """Overrriden from TypeHandler.""" | 4992 """Overrriden from TypeHandler.""" |
4947 valid_test = """ | 4993 valid_test = """ |
4948 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4994 TEST_P(%(test_name)s, %(name)sValidArgs) { |
4949 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)) | 4995 %(id_type_cast)sEXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)) |
4950 .WillOnce(Return(kNewServiceId)); | 4996 .WillOnce(Return(%(const_service_id)s)); |
4951 SpecializedSetup<cmds::%(name)s, 0>(true); | 4997 SpecializedSetup<cmds::%(name)s, 0>(true); |
4952 cmds::%(name)s cmd; | 4998 cmds::%(name)s cmd; |
4953 cmd.Init(%(args)s%(comma)skNewClientId); | 4999 cmd.Init(%(args)s%(comma)skNewClientId);""" |
| 5000 if func.IsUnsafe(): |
| 5001 valid_test += """ |
| 5002 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 5003 valid_test += """ |
4954 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 5004 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
4955 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 5005 EXPECT_EQ(GL_NO_ERROR, GetGLError());""" |
4956 EXPECT_TRUE(Get%(resource_type)s(kNewClientId) != NULL); | 5006 if func.IsUnsafe(): |
| 5007 valid_test += """ |
| 5008 %(return_type)s service_id = 0; |
| 5009 EXPECT_TRUE(Get%(resource_type)sServiceId(kNewClientId, &service_id)); |
| 5010 EXPECT_EQ(%(const_service_id)s, service_id); |
| 5011 decoder_->set_unsafe_es3_apis_enabled(false); |
| 5012 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 5013 } |
| 5014 """ |
| 5015 else: |
| 5016 valid_test += """ |
| 5017 EXPECT_TRUE(Get%(resource_type)s(kNewClientId)); |
4957 } | 5018 } |
4958 """ | 5019 """ |
4959 comma = "" | 5020 comma = "" |
4960 if len(func.GetOriginalArgs()): | 5021 cmd_arg_count = 0 |
4961 comma =", " | 5022 for arg in func.GetOriginalArgs(): |
| 5023 if not arg.IsConstant(): |
| 5024 cmd_arg_count += 1 |
| 5025 if cmd_arg_count: |
| 5026 comma = ", " |
| 5027 if func.return_type == 'GLsync': |
| 5028 id_type_cast = ("const GLsync kNewServiceIdGLuint = reinterpret_cast" |
| 5029 "<GLsync>(kNewServiceId);\n ") |
| 5030 const_service_id = "kNewServiceIdGLuint" |
| 5031 else: |
| 5032 id_type_cast = "" |
| 5033 const_service_id = "kNewServiceId" |
4962 self.WriteValidUnitTest(func, file, valid_test, { | 5034 self.WriteValidUnitTest(func, file, valid_test, { |
4963 'comma': comma, | 5035 'comma': comma, |
4964 'resource_type': func.name[6:], | 5036 'resource_type': self.__GetResourceType(func), |
| 5037 'return_type': func.return_type, |
| 5038 'id_type_cast': id_type_cast, |
| 5039 'const_service_id': const_service_id, |
4965 }, *extras) | 5040 }, *extras) |
4966 invalid_test = """ | 5041 invalid_test = """ |
4967 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { | 5042 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { |
4968 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); | 5043 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); |
4969 SpecializedSetup<cmds::%(name)s, 0>(false); | 5044 SpecializedSetup<cmds::%(name)s, 0>(false); |
4970 cmds::%(name)s cmd; | 5045 cmds::%(name)s cmd; |
4971 cmd.Init(%(args)s%(comma)skNewClientId); | 5046 cmd.Init(%(args)s%(comma)skNewClientId); |
4972 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));%(gl_error_test)s | 5047 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));%(gl_error_test)s |
4973 } | 5048 } |
4974 """ | 5049 """ |
4975 self.WriteInvalidUnitTest(func, file, invalid_test, { | 5050 self.WriteInvalidUnitTest(func, file, invalid_test, { |
4976 'comma': comma, | 5051 'comma': comma, |
4977 }, *extras) | 5052 }, *extras) |
4978 | 5053 |
4979 def WriteHandlerImplementation (self, func, file): | 5054 def WriteHandlerImplementation (self, func, file): |
4980 """Overrriden from TypeHandler.""" | 5055 """Overrriden from TypeHandler.""" |
4981 file.Write(" uint32_t client_id = c.client_id;\n") | 5056 if func.IsUnsafe(): |
4982 file.Write(" if (!%sHelper(%s)) {\n" % | 5057 code = """ uint32_t client_id = c.client_id; |
4983 (func.name, func.MakeCmdArgString(""))) | 5058 %(return_type)s service_id = 0; |
4984 file.Write(" return error::kInvalidArguments;\n") | 5059 if (group_->Get%(resource_name)sServiceId(client_id, &service_id)) { |
4985 file.Write(" }\n") | 5060 return error::kInvalidArguments; |
| 5061 } |
| 5062 service_id = %(gl_func_name)s(%(gl_args)s); |
| 5063 if (service_id) { |
| 5064 group_->Add%(resource_name)sId(client_id, service_id); |
| 5065 } |
| 5066 """ |
| 5067 else: |
| 5068 code = """ uint32_t client_id = c.client_id; |
| 5069 if (Get%(resource_name)s(client_id)) { |
| 5070 return error::kInvalidArguments; |
| 5071 } |
| 5072 %(return_type)s service_id = %(gl_func_name)s(%(gl_args)s); |
| 5073 if (service_id) { |
| 5074 Create%(resource_name)s(client_id, service_id%(gl_args_with_comma)s); |
| 5075 } |
| 5076 """ |
| 5077 file.Write(code % { |
| 5078 'resource_name': self.__GetResourceType(func), |
| 5079 'return_type': func.return_type, |
| 5080 'gl_func_name': func.GetGLFunctionName(), |
| 5081 'gl_args': func.MakeOriginalArgString(""), |
| 5082 'gl_args_with_comma': func.MakeOriginalArgString("", True) }) |
4986 | 5083 |
4987 def WriteGLES2Implementation(self, func, file): | 5084 def WriteGLES2Implementation(self, func, file): |
4988 """Overrriden from TypeHandler.""" | 5085 """Overrriden from TypeHandler.""" |
4989 file.Write("%s GLES2Implementation::%s(%s) {\n" % | 5086 file.Write("%s GLES2Implementation::%s(%s) {\n" % |
4990 (func.return_type, func.original_name, | 5087 (func.return_type, func.original_name, |
4991 func.MakeTypedOriginalArgString(""))) | 5088 func.MakeTypedOriginalArgString(""))) |
4992 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") | 5089 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") |
4993 func.WriteDestinationInitalizationValidation(file) | 5090 func.WriteDestinationInitalizationValidation(file) |
4994 self.WriteClientGLCallLog(func, file) | 5091 self.WriteClientGLCallLog(func, file) |
4995 for arg in func.GetOriginalArgs(): | 5092 for arg in func.GetOriginalArgs(): |
4996 arg.WriteClientSideValidationCode(file, func) | 5093 arg.WriteClientSideValidationCode(file, func) |
4997 file.Write(" GLuint client_id;\n") | 5094 file.Write(" GLuint client_id;\n") |
4998 file.Write( | 5095 if func.return_type == "GLsync": |
4999 " GetIdHandler(id_namespaces::kProgramsAndShaders)->\n") | 5096 file.Write( |
| 5097 " GetIdHandler(id_namespaces::kSyncs)->\n") |
| 5098 else: |
| 5099 file.Write( |
| 5100 " GetIdHandler(id_namespaces::kProgramsAndShaders)->\n") |
5000 file.Write(" MakeIds(this, 0, 1, &client_id);\n") | 5101 file.Write(" MakeIds(this, 0, 1, &client_id);\n") |
5001 file.Write(" helper_->%s(%s);\n" % | 5102 file.Write(" helper_->%s(%s);\n" % |
5002 (func.name, func.MakeCmdArgString(""))) | 5103 (func.name, func.MakeCmdArgString(""))) |
5003 file.Write(' GPU_CLIENT_LOG("returned " << client_id);\n') | 5104 file.Write(' GPU_CLIENT_LOG("returned " << client_id);\n') |
5004 file.Write(" CheckGLError();\n") | 5105 file.Write(" CheckGLError();\n") |
5005 file.Write(" return client_id;\n") | 5106 if func.return_type == "GLsync": |
| 5107 file.Write(" return reinterpret_cast<GLsync>(client_id);\n") |
| 5108 else: |
| 5109 file.Write(" return client_id;\n") |
5006 file.Write("}\n") | 5110 file.Write("}\n") |
5007 file.Write("\n") | 5111 file.Write("\n") |
5008 | 5112 |
5009 | 5113 |
5010 class DeleteHandler(TypeHandler): | 5114 class DeleteHandler(TypeHandler): |
5011 """Handler for glDelete___ single resource type functions.""" | 5115 """Handler for glDelete___ single resource type functions.""" |
5012 | 5116 |
5013 def __init__(self): | 5117 def __init__(self): |
5014 TypeHandler.__init__(self) | 5118 TypeHandler.__init__(self) |
5015 | 5119 |
5016 def WriteServiceImplementation(self, func, file): | 5120 def WriteServiceImplementation(self, func, file): |
5017 """Overrriden from TypeHandler.""" | 5121 """Overrriden from TypeHandler.""" |
| 5122 if func.IsUnsafe(): |
| 5123 TypeHandler.WriteServiceImplementation(self, func, file) |
| 5124 # HandleDeleteShader and HandleDeleteProgram are manually written. |
5018 pass | 5125 pass |
5019 | 5126 |
5020 def WriteGLES2Implementation(self, func, file): | 5127 def WriteGLES2Implementation(self, func, file): |
5021 """Overrriden from TypeHandler.""" | 5128 """Overrriden from TypeHandler.""" |
5022 file.Write("%s GLES2Implementation::%s(%s) {\n" % | 5129 file.Write("%s GLES2Implementation::%s(%s) {\n" % |
5023 (func.return_type, func.original_name, | 5130 (func.return_type, func.original_name, |
5024 func.MakeTypedOriginalArgString(""))) | 5131 func.MakeTypedOriginalArgString(""))) |
5025 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") | 5132 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") |
5026 func.WriteDestinationInitalizationValidation(file) | 5133 func.WriteDestinationInitalizationValidation(file) |
5027 self.WriteClientGLCallLog(func, file) | 5134 self.WriteClientGLCallLog(func, file) |
5028 for arg in func.GetOriginalArgs(): | 5135 for arg in func.GetOriginalArgs(): |
5029 arg.WriteClientSideValidationCode(file, func) | 5136 arg.WriteClientSideValidationCode(file, func) |
5030 file.Write( | 5137 file.Write( |
5031 " GPU_CLIENT_DCHECK(%s != 0);\n" % func.GetOriginalArgs()[-1].name) | 5138 " GPU_CLIENT_DCHECK(%s != 0);\n" % func.GetOriginalArgs()[-1].name) |
5032 file.Write(" %sHelper(%s);\n" % | 5139 file.Write(" %sHelper(%s);\n" % |
5033 (func.original_name, func.GetOriginalArgs()[-1].name)) | 5140 (func.original_name, func.GetOriginalArgs()[-1].name)) |
5034 file.Write(" CheckGLError();\n") | 5141 file.Write(" CheckGLError();\n") |
5035 file.Write("}\n") | 5142 file.Write("}\n") |
5036 file.Write("\n") | 5143 file.Write("\n") |
5037 | 5144 |
| 5145 def WriteHandlerImplementation (self, func, file): |
| 5146 """Overrriden from TypeHandler.""" |
| 5147 assert len(func.GetOriginalArgs()) == 1 |
| 5148 arg = func.GetOriginalArgs()[0] |
| 5149 if func.IsUnsafe(): |
| 5150 file.Write(""" %(arg_type)s service_id = 0; |
| 5151 if (group_->Get%(resource_type)sServiceId(%(arg_name)s, &service_id)) { |
| 5152 glDelete%(resource_type)s(service_id); |
| 5153 group_->Remove%(resource_type)sId(%(arg_name)s); |
| 5154 } else { |
| 5155 LOCAL_SET_GL_ERROR( |
| 5156 GL_INVALID_VALUE, "gl%(func_name)s", "unknown %(arg_name)s"); |
| 5157 } |
| 5158 """ % { 'resource_type': func.GetInfo('resource_type'), |
| 5159 'arg_name': arg.name, |
| 5160 'arg_type': arg.type, |
| 5161 'func_name': func.original_name }) |
| 5162 else: |
| 5163 file.Write(" %sHelper(%s);\n" % (func.original_name, arg.name)) |
5038 | 5164 |
5039 class DELnHandler(TypeHandler): | 5165 class DELnHandler(TypeHandler): |
5040 """Handler for glDelete___ type functions.""" | 5166 """Handler for glDelete___ type functions.""" |
5041 | 5167 |
5042 def __init__(self): | 5168 def __init__(self): |
5043 TypeHandler.__init__(self) | 5169 TypeHandler.__init__(self) |
5044 | 5170 |
5045 def WriteGetDataSizeCode(self, func, file): | 5171 def WriteGetDataSizeCode(self, func, file): |
5046 """Overrriden from TypeHandler.""" | 5172 """Overrriden from TypeHandler.""" |
5047 code = """ uint32_t data_size; | 5173 code = """ uint32_t data_size; |
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6708 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); | 6834 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); |
6709 if (!result_dst) { | 6835 if (!result_dst) { |
6710 return error::kOutOfBounds; | 6836 return error::kOutOfBounds; |
6711 } | 6837 } |
6712 """ | 6838 """ |
6713 file.Write(code % {'func_name': func.name}) | 6839 file.Write(code % {'func_name': func.name}) |
6714 func.WriteHandlerValidation(file) | 6840 func.WriteHandlerValidation(file) |
6715 if func.IsUnsafe(): | 6841 if func.IsUnsafe(): |
6716 assert func.GetInfo('id_mapping') | 6842 assert func.GetInfo('id_mapping') |
6717 assert len(func.GetInfo('id_mapping')) == 1 | 6843 assert len(func.GetInfo('id_mapping')) == 1 |
| 6844 assert len(args) == 1 |
6718 id_type = func.GetInfo('id_mapping')[0] | 6845 id_type = func.GetInfo('id_mapping')[0] |
6719 file.Write(" *result_dst = group_->Get%sServiceId(%s, &%s);\n" % | 6846 file.Write(" %s service_%s = 0;\n" % (args[0].type, id_type.lower())) |
| 6847 file.Write(" *result_dst = group_->Get%sServiceId(%s, &service_%s);\n" % |
6720 (id_type, id_type.lower(), id_type.lower())) | 6848 (id_type, id_type.lower(), id_type.lower())) |
6721 else: | 6849 else: |
6722 file.Write(" *result_dst = %s(%s);\n" % | 6850 file.Write(" *result_dst = %s(%s);\n" % |
6723 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 6851 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
6724 file.Write(" return error::kNoError;\n") | 6852 file.Write(" return error::kNoError;\n") |
6725 file.Write("}\n") | 6853 file.Write("}\n") |
6726 file.Write("\n") | 6854 file.Write("\n") |
6727 | 6855 |
6728 def WriteGLES2Implementation(self, func, file): | 6856 def WriteGLES2Implementation(self, func, file): |
6729 """Overrriden from TypeHandler.""" | 6857 """Overrriden from TypeHandler.""" |
6730 impl_func = func.GetInfo('impl_func') | 6858 impl_func = func.GetInfo('impl_func') |
6731 if impl_func == None or impl_func == True: | 6859 if impl_func == None or impl_func == True: |
6732 error_value = func.GetInfo("error_value") or "GL_FALSE" | 6860 error_value = func.GetInfo("error_value") or "GL_FALSE" |
6733 file.Write("%s GLES2Implementation::%s(%s) {\n" % | 6861 file.Write("%s GLES2Implementation::%s(%s) {\n" % |
6734 (func.return_type, func.original_name, | 6862 (func.return_type, func.original_name, |
6735 func.MakeTypedOriginalArgString(""))) | 6863 func.MakeTypedOriginalArgString(""))) |
6736 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") | 6864 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") |
6737 self.WriteTraceEvent(func, file) | 6865 self.WriteTraceEvent(func, file) |
6738 func.WriteDestinationInitalizationValidation(file) | 6866 func.WriteDestinationInitalizationValidation(file) |
6739 self.WriteClientGLCallLog(func, file) | 6867 self.WriteClientGLCallLog(func, file) |
6740 file.Write(" typedef cmds::%s::Result Result;\n" % func.name) | 6868 file.Write(" typedef cmds::%s::Result Result;\n" % func.name) |
6741 file.Write(" Result* result = GetResultAs<Result*>();\n") | 6869 file.Write(" Result* result = GetResultAs<Result*>();\n") |
6742 file.Write(" if (!result) {\n") | 6870 file.Write(" if (!result) {\n") |
6743 file.Write(" return %s;\n" % error_value) | 6871 file.Write(" return %s;\n" % error_value) |
6744 file.Write(" }\n") | 6872 file.Write(" }\n") |
6745 file.Write(" *result = 0;\n") | 6873 file.Write(" *result = 0;\n") |
6746 arg_string = func.MakeOriginalArgString("") | 6874 assert len(func.GetOriginalArgs()) == 1 |
6747 comma = "" | 6875 id_arg = func.GetOriginalArgs()[0] |
6748 if len(arg_string) > 0: | 6876 if id_arg.type == 'GLsync': |
6749 comma = ", " | 6877 arg_string = "ToGLuint(%s)" % func.MakeOriginalArgString("") |
| 6878 else: |
| 6879 arg_string = func.MakeOriginalArgString("") |
6750 file.Write( | 6880 file.Write( |
6751 " helper_->%s(%s%sGetResultShmId(), GetResultShmOffset());\n" % | 6881 " helper_->%s(%s, GetResultShmId(), GetResultShmOffset());\n" % |
6752 (func.name, arg_string, comma)) | 6882 (func.name, arg_string)) |
6753 file.Write(" WaitForCmd();\n") | 6883 file.Write(" WaitForCmd();\n") |
6754 file.Write(" %s result_value = *result" % func.return_type) | 6884 file.Write(" %s result_value = *result" % func.return_type) |
6755 if func.return_type == "GLboolean": | 6885 if func.return_type == "GLboolean": |
6756 file.Write(" != 0") | 6886 file.Write(" != 0") |
6757 file.Write(';\n GPU_CLIENT_LOG("returned " << result_value);\n') | 6887 file.Write(';\n GPU_CLIENT_LOG("returned " << result_value);\n') |
6758 file.Write(" CheckGLError();\n") | 6888 file.Write(" CheckGLError();\n") |
6759 file.Write(" return result_value;\n") | 6889 file.Write(" return result_value;\n") |
6760 file.Write("}\n") | 6890 file.Write("}\n") |
6761 file.Write("\n") | 6891 file.Write("\n") |
6762 | 6892 |
6763 def WriteGLES2ImplementationUnitTest(self, func, file): | 6893 def WriteGLES2ImplementationUnitTest(self, func, file): |
6764 """Overrriden from TypeHandler.""" | 6894 """Overrriden from TypeHandler.""" |
6765 client_test = func.GetInfo('client_test') | 6895 client_test = func.GetInfo('client_test') |
6766 if client_test == None or client_test == True: | 6896 if client_test == None or client_test == True: |
6767 code = """ | 6897 code = """ |
6768 TEST_F(GLES2ImplementationTest, %(name)s) { | 6898 TEST_F(GLES2ImplementationTest, %(name)s) { |
6769 struct Cmds { | 6899 struct Cmds { |
6770 cmds::%(name)s cmd; | 6900 cmds::%(name)s cmd; |
6771 }; | 6901 }; |
6772 | 6902 |
6773 Cmds expected; | 6903 Cmds expected; |
6774 ExpectedMemoryInfo result1 = | 6904 ExpectedMemoryInfo result1 = |
6775 GetExpectedResultMemory(sizeof(cmds::%(name)s::Result)); | 6905 GetExpectedResultMemory(sizeof(cmds::%(name)s::Result)); |
6776 expected.cmd.Init(1, result1.id, result1.offset); | 6906 expected.cmd.Init(%(cmd_id_value)s, result1.id, result1.offset); |
6777 | 6907 |
6778 EXPECT_CALL(*command_buffer(), OnFlush()) | 6908 EXPECT_CALL(*command_buffer(), OnFlush()) |
6779 .WillOnce(SetMemory(result1.ptr, uint32_t(1))) | 6909 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
6780 .RetiresOnSaturation(); | 6910 .RetiresOnSaturation(); |
6781 | 6911 |
6782 GLboolean result = gl_->%(name)s(1); | 6912 GLboolean result = gl_->%(name)s(%(gl_id_value)s); |
6783 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 6913 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
6784 EXPECT_TRUE(result); | 6914 EXPECT_TRUE(result); |
6785 } | 6915 } |
6786 """ | 6916 """ |
| 6917 args = func.GetOriginalArgs() |
| 6918 assert len(args) == 1 |
6787 file.Write(code % { | 6919 file.Write(code % { |
6788 'name': func.name, | 6920 'name': func.name, |
6789 }) | 6921 'cmd_id_value': args[0].GetValidClientSideCmdArg(func), |
| 6922 'gl_id_value': args[0].GetValidClientSideArg(func) }) |
6790 | 6923 |
6791 | 6924 |
6792 class STRnHandler(TypeHandler): | 6925 class STRnHandler(TypeHandler): |
6793 """Handler for GetProgramInfoLog, GetShaderInfoLog, GetShaderSource, and | 6926 """Handler for GetProgramInfoLog, GetShaderInfoLog, GetShaderSource, and |
6794 GetTranslatedShaderSourceANGLE.""" | 6927 GetTranslatedShaderSourceANGLE.""" |
6795 | 6928 |
6796 def __init__(self): | 6929 def __init__(self): |
6797 TypeHandler.__init__(self) | 6930 TypeHandler.__init__(self) |
6798 | 6931 |
6799 def InitFunction(self, func): | 6932 def InitFunction(self, func): |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7004 index = func.GetOriginalArgs().index(self) | 7137 index = func.GetOriginalArgs().index(self) |
7005 return str(index + 1) | 7138 return str(index + 1) |
7006 | 7139 |
7007 def GetValidClientSideArg(self, func): | 7140 def GetValidClientSideArg(self, func): |
7008 """Gets a valid value for this argument.""" | 7141 """Gets a valid value for this argument.""" |
7009 valid_arg = func.GetValidArg(self) | 7142 valid_arg = func.GetValidArg(self) |
7010 if valid_arg != None: | 7143 if valid_arg != None: |
7011 return valid_arg | 7144 return valid_arg |
7012 | 7145 |
7013 index = func.GetOriginalArgs().index(self) | 7146 index = func.GetOriginalArgs().index(self) |
| 7147 if self.type == 'GLsync': |
| 7148 return ("reinterpret_cast<GLsync>(%d)" % (index + 1)) |
7014 return str(index + 1) | 7149 return str(index + 1) |
7015 | 7150 |
7016 def GetValidClientSideCmdArg(self, func): | 7151 def GetValidClientSideCmdArg(self, func): |
7017 """Gets a valid value for this argument.""" | 7152 """Gets a valid value for this argument.""" |
7018 valid_arg = func.GetValidArg(self) | 7153 valid_arg = func.GetValidArg(self) |
7019 if valid_arg != None: | 7154 if valid_arg != None: |
7020 return valid_arg | 7155 return valid_arg |
7021 try: | 7156 try: |
7022 index = func.GetOriginalArgs().index(self) | 7157 index = func.GetOriginalArgs().index(self) |
7023 return str(index + 1) | 7158 return str(index + 1) |
7024 except ValueError: | 7159 except ValueError: |
7025 pass | 7160 pass |
7026 index = func.GetCmdArgs().index(self) | 7161 index = func.GetCmdArgs().index(self) |
7027 return str(index + 1) | 7162 return str(index + 1) |
7028 | 7163 |
7029 def GetValidGLArg(self, func): | 7164 def GetValidGLArg(self, func): |
7030 """Gets a valid GL value for this argument.""" | 7165 """Gets a valid GL value for this argument.""" |
7031 return self.GetValidArg(func) | 7166 value = self.GetValidArg(func) |
| 7167 if self.type == 'GLsync': |
| 7168 return ("reinterpret_cast<GLsync>(%s)" % value) |
| 7169 return value |
7032 | 7170 |
7033 def GetValidNonCachedClientSideArg(self, func): | 7171 def GetValidNonCachedClientSideArg(self, func): |
7034 """Returns a valid value for this argument in a GL call. | 7172 """Returns a valid value for this argument in a GL call. |
7035 Using the value will produce a command buffer service invocation. | 7173 Using the value will produce a command buffer service invocation. |
7036 Returns None if there is no such value.""" | 7174 Returns None if there is no such value.""" |
7037 return '123' | 7175 return '123' |
7038 | 7176 |
7039 def GetValidNonCachedClientSideCmdArg(self, func): | 7177 def GetValidNonCachedClientSideCmdArg(self, func): |
7040 """Returns a valid value for this argument in a command buffer command. | 7178 """Returns a valid value for this argument in a command buffer command. |
7041 Calling the GL function with the value returned by | 7179 Calling the GL function with the value returned by |
(...skipping 12 matching lines...) Expand all Loading... |
7054 def GetLogArg(self): | 7192 def GetLogArg(self): |
7055 """Get argument appropriate for LOG macro.""" | 7193 """Get argument appropriate for LOG macro.""" |
7056 if self.type == 'GLboolean': | 7194 if self.type == 'GLboolean': |
7057 return 'GLES2Util::GetStringBool(%s)' % self.name | 7195 return 'GLES2Util::GetStringBool(%s)' % self.name |
7058 if self.type == 'GLenum': | 7196 if self.type == 'GLenum': |
7059 return 'GLES2Util::GetStringEnum(%s)' % self.name | 7197 return 'GLES2Util::GetStringEnum(%s)' % self.name |
7060 return self.name | 7198 return self.name |
7061 | 7199 |
7062 def WriteGetCode(self, file): | 7200 def WriteGetCode(self, file): |
7063 """Writes the code to get an argument from a command structure.""" | 7201 """Writes the code to get an argument from a command structure.""" |
| 7202 if self.type == 'GLsync': |
| 7203 my_type = 'GLuint' |
| 7204 else: |
| 7205 my_type = self.type |
7064 file.Write(" %s %s = static_cast<%s>(c.%s);\n" % | 7206 file.Write(" %s %s = static_cast<%s>(c.%s);\n" % |
7065 (self.type, self.name, self.type, self.name)) | 7207 (my_type, self.name, my_type, self.name)) |
7066 | 7208 |
7067 def WriteValidationCode(self, file, func): | 7209 def WriteValidationCode(self, file, func): |
7068 """Writes the validation code for an argument.""" | 7210 """Writes the validation code for an argument.""" |
7069 pass | 7211 pass |
7070 | 7212 |
7071 def WriteClientSideValidationCode(self, file, func): | 7213 def WriteClientSideValidationCode(self, file, func): |
7072 """Writes the validation code for an argument.""" | 7214 """Writes the validation code for an argument.""" |
7073 pass | 7215 pass |
7074 | 7216 |
7075 def WriteDestinationInitalizationValidation(self, file, func): | 7217 def WriteDestinationInitalizationValidation(self, file, func): |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7189 def GetInvalidArg(self, index): | 7331 def GetInvalidArg(self, index): |
7190 """overridden from SizeArgument.""" | 7332 """overridden from SizeArgument.""" |
7191 return ("-1", "kOutOfBounds", "GL_NO_ERROR") | 7333 return ("-1", "kOutOfBounds", "GL_NO_ERROR") |
7192 | 7334 |
7193 def WriteValidationCode(self, file, func): | 7335 def WriteValidationCode(self, file, func): |
7194 """overridden from SizeArgument.""" | 7336 """overridden from SizeArgument.""" |
7195 pass | 7337 pass |
7196 | 7338 |
7197 | 7339 |
7198 class EnumBaseArgument(Argument): | 7340 class EnumBaseArgument(Argument): |
7199 """Base class for EnumArgument, IntArgument and ValidatedBoolArgument""" | 7341 """Base class for EnumArgument, IntArgument, BitfieldArgument, and |
| 7342 ValidatedBoolArgument.""" |
7200 | 7343 |
7201 def __init__(self, name, gl_type, type, gl_error): | 7344 def __init__(self, name, gl_type, type, gl_error): |
7202 Argument.__init__(self, name, gl_type) | 7345 Argument.__init__(self, name, gl_type) |
7203 | 7346 |
7204 self.local_type = type | 7347 self.local_type = type |
7205 self.gl_error = gl_error | 7348 self.gl_error = gl_error |
7206 name = type[len(gl_type):] | 7349 name = type[len(gl_type):] |
7207 self.type_name = name | 7350 self.type_name = name |
7208 self.named_type = NamedType(_NAMED_TYPE_INFO[name]) | 7351 self.named_type = NamedType(_NAMED_TYPE_INFO[name]) |
7209 | 7352 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7305 def __init__(self, name, type): | 7448 def __init__(self, name, type): |
7306 EnumBaseArgument.__init__(self, name, "GLenum", type, "GL_INVALID_ENUM") | 7449 EnumBaseArgument.__init__(self, name, "GLenum", type, "GL_INVALID_ENUM") |
7307 | 7450 |
7308 def GetLogArg(self): | 7451 def GetLogArg(self): |
7309 """Overridden from Argument.""" | 7452 """Overridden from Argument.""" |
7310 return ("GLES2Util::GetString%s(%s)" % | 7453 return ("GLES2Util::GetString%s(%s)" % |
7311 (self.type_name, self.name)) | 7454 (self.type_name, self.name)) |
7312 | 7455 |
7313 | 7456 |
7314 class IntArgument(EnumBaseArgument): | 7457 class IntArgument(EnumBaseArgument): |
7315 """A class for a GLint argument that can only except specific values. | 7458 """A class for a GLint argument that can only accept specific values. |
7316 | 7459 |
7317 For example glTexImage2D takes a GLint for its internalformat | 7460 For example glTexImage2D takes a GLint for its internalformat |
7318 argument instead of a GLenum. | 7461 argument instead of a GLenum. |
7319 """ | 7462 """ |
7320 | 7463 |
7321 def __init__(self, name, type): | 7464 def __init__(self, name, type): |
7322 EnumBaseArgument.__init__(self, name, "GLint", type, "GL_INVALID_VALUE") | 7465 EnumBaseArgument.__init__(self, name, "GLint", type, "GL_INVALID_VALUE") |
7323 | 7466 |
7324 | 7467 |
7325 class ValidatedBoolArgument(EnumBaseArgument): | 7468 class ValidatedBoolArgument(EnumBaseArgument): |
7326 """A class for a GLboolean argument that can only except specific values. | 7469 """A class for a GLboolean argument that can only accept specific values. |
7327 | 7470 |
7328 For example glUniformMatrix takes a GLboolean for it's transpose but it | 7471 For example glUniformMatrix takes a GLboolean for it's transpose but it |
7329 must be false. | 7472 must be false. |
7330 """ | 7473 """ |
7331 | 7474 |
7332 def __init__(self, name, type): | 7475 def __init__(self, name, type): |
7333 EnumBaseArgument.__init__(self, name, "GLboolean", type, "GL_INVALID_VALUE") | 7476 EnumBaseArgument.__init__(self, name, "GLboolean", type, "GL_INVALID_VALUE") |
7334 | 7477 |
7335 def GetLogArg(self): | 7478 def GetLogArg(self): |
7336 """Overridden from Argument.""" | 7479 """Overridden from Argument.""" |
7337 return 'GLES2Util::GetStringBool(%s)' % self.name | 7480 return 'GLES2Util::GetStringBool(%s)' % self.name |
7338 | 7481 |
7339 | 7482 |
| 7483 class BitFieldArgument(EnumBaseArgument): |
| 7484 """A class for a GLbitfield argument that can only accept specific values. |
| 7485 |
| 7486 For example glFenceSync takes a GLbitfield for its flags argument bit it |
| 7487 must be 0. |
| 7488 """ |
| 7489 |
| 7490 def __init__(self, name, type): |
| 7491 EnumBaseArgument.__init__(self, name, "GLbitfield", type, |
| 7492 "GL_INVALID_VALUE") |
| 7493 |
| 7494 |
7340 class ImmediatePointerArgument(Argument): | 7495 class ImmediatePointerArgument(Argument): |
7341 """A class that represents an immediate argument to a function. | 7496 """A class that represents an immediate argument to a function. |
7342 | 7497 |
7343 An immediate argument is one where the data follows the command. | 7498 An immediate argument is one where the data follows the command. |
7344 """ | 7499 """ |
7345 | 7500 |
7346 def __init__(self, name, type): | 7501 def __init__(self, name, type): |
7347 Argument.__init__(self, name, type) | 7502 Argument.__init__(self, name, type) |
7348 | 7503 |
7349 def IsPointer(self): | 7504 def IsPointer(self): |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7577 def GetValidGLArg(self, func): | 7732 def GetValidGLArg(self, func): |
7578 return "_" | 7733 return "_" |
7579 | 7734 |
7580 | 7735 |
7581 class ResourceIdArgument(Argument): | 7736 class ResourceIdArgument(Argument): |
7582 """A class that represents a resource id argument to a function.""" | 7737 """A class that represents a resource id argument to a function.""" |
7583 | 7738 |
7584 def __init__(self, name, type): | 7739 def __init__(self, name, type): |
7585 match = re.match("(GLid\w+)", type) | 7740 match = re.match("(GLid\w+)", type) |
7586 self.resource_type = match.group(1)[4:] | 7741 self.resource_type = match.group(1)[4:] |
7587 type = type.replace(match.group(1), "GLuint") | 7742 if self.resource_type == "Sync": |
| 7743 type = type.replace(match.group(1), "GLsync") |
| 7744 else: |
| 7745 type = type.replace(match.group(1), "GLuint") |
7588 Argument.__init__(self, name, type) | 7746 Argument.__init__(self, name, type) |
7589 | 7747 |
7590 def WriteGetCode(self, file): | 7748 def WriteGetCode(self, file): |
7591 """Overridden from Argument.""" | 7749 """Overridden from Argument.""" |
7592 file.Write(" %s %s = c.%s;\n" % (self.type, self.name, self.name)) | 7750 if self.type == "GLsync": |
| 7751 my_type = "GLuint" |
| 7752 else: |
| 7753 my_type = self.type |
| 7754 file.Write(" %s %s = c.%s;\n" % (my_type, self.name, self.name)) |
7593 | 7755 |
7594 def GetValidArg(self, func): | 7756 def GetValidArg(self, func): |
7595 return "client_%s_id_" % self.resource_type.lower() | 7757 return "client_%s_id_" % self.resource_type.lower() |
7596 | 7758 |
7597 def GetValidGLArg(self, func): | 7759 def GetValidGLArg(self, func): |
| 7760 if self.resource_type == "Sync": |
| 7761 return "reinterpret_cast<GLsync>(kService%sId)" % self.resource_type |
7598 return "kService%sId" % self.resource_type | 7762 return "kService%sId" % self.resource_type |
7599 | 7763 |
7600 | 7764 |
7601 class ResourceIdBindArgument(Argument): | 7765 class ResourceIdBindArgument(Argument): |
7602 """Represents a resource id argument to a bind function.""" | 7766 """Represents a resource id argument to a bind function.""" |
7603 | 7767 |
7604 def __init__(self, name, type): | 7768 def __init__(self, name, type): |
7605 match = re.match("(GLidBind\w+)", type) | 7769 match = re.match("(GLidBind\w+)", type) |
7606 self.resource_type = match.group(1)[8:] | 7770 self.resource_type = match.group(1)[8:] |
7607 type = type.replace(match.group(1), "GLuint") | 7771 type = type.replace(match.group(1), "GLuint") |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8300 " ".join(arg_parts[0:-1])) | 8464 " ".join(arg_parts[0:-1])) |
8301 # Is this a resource argument? Must come after pointer check. | 8465 # Is this a resource argument? Must come after pointer check. |
8302 elif arg_parts[0].startswith('GLidBind'): | 8466 elif arg_parts[0].startswith('GLidBind'): |
8303 return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 8467 return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
8304 elif arg_parts[0].startswith('GLidZero'): | 8468 elif arg_parts[0].startswith('GLidZero'): |
8305 return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 8469 return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
8306 elif arg_parts[0].startswith('GLid'): | 8470 elif arg_parts[0].startswith('GLid'): |
8307 return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 8471 return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
8308 elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: | 8472 elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: |
8309 return EnumArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 8473 return EnumArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
| 8474 elif arg_parts[0].startswith('GLbitfield') and len(arg_parts[0]) > 10: |
| 8475 return BitFieldArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
8310 elif arg_parts[0].startswith('GLboolean') and len(arg_parts[0]) > 9: | 8476 elif arg_parts[0].startswith('GLboolean') and len(arg_parts[0]) > 9: |
8311 return ValidatedBoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 8477 return ValidatedBoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
8312 elif arg_parts[0].startswith('GLboolean'): | 8478 elif arg_parts[0].startswith('GLboolean'): |
8313 return BoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 8479 return BoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
8314 elif arg_parts[0].startswith('GLintUniformLocation'): | 8480 elif arg_parts[0].startswith('GLintUniformLocation'): |
8315 return UniformLocationArgument(arg_parts[-1]) | 8481 return UniformLocationArgument(arg_parts[-1]) |
8316 elif (arg_parts[0].startswith('GLint') and len(arg_parts[0]) > 5 and | 8482 elif (arg_parts[0].startswith('GLint') and len(arg_parts[0]) > 5 and |
8317 not arg_parts[0].startswith('GLintptr')): | 8483 not arg_parts[0].startswith('GLintptr')): |
8318 return IntArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 8484 return IntArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
8319 elif (arg_parts[0].startswith('GLsizeiNotNegative') or | 8485 elif (arg_parts[0].startswith('GLsizeiNotNegative') or |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9624 Format(gen.generated_cpp_filenames) | 9790 Format(gen.generated_cpp_filenames) |
9625 | 9791 |
9626 if gen.errors > 0: | 9792 if gen.errors > 0: |
9627 print "%d errors" % gen.errors | 9793 print "%d errors" % gen.errors |
9628 return 1 | 9794 return 1 |
9629 return 0 | 9795 return 0 |
9630 | 9796 |
9631 | 9797 |
9632 if __name__ == '__main__': | 9798 if __name__ == '__main__': |
9633 sys.exit(main(sys.argv[1:])) | 9799 sys.exit(main(sys.argv[1:])) |
OLD | NEW |