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 2899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2910 }, | 2910 }, |
2911 'GenMailboxCHROMIUM': { | 2911 'GenMailboxCHROMIUM': { |
2912 'type': 'NoCommand', | 2912 'type': 'NoCommand', |
2913 'extension': "CHROMIUM_texture_mailbox", | 2913 'extension': "CHROMIUM_texture_mailbox", |
2914 }, | 2914 }, |
2915 'GenFramebuffers': { | 2915 'GenFramebuffers': { |
2916 'type': 'GENn', | 2916 'type': 'GENn', |
2917 'gl_test_func': 'glGenFramebuffersEXT', | 2917 'gl_test_func': 'glGenFramebuffersEXT', |
2918 'resource_type': 'Framebuffer', | 2918 'resource_type': 'Framebuffer', |
2919 'resource_types': 'Framebuffers', | 2919 'resource_types': 'Framebuffers', |
| 2920 'not_shared': 'True', |
2920 }, | 2921 }, |
2921 'GenRenderbuffers': { | 2922 'GenRenderbuffers': { |
2922 'type': 'GENn', 'gl_test_func': 'glGenRenderbuffersEXT', | 2923 'type': 'GENn', 'gl_test_func': 'glGenRenderbuffersEXT', |
2923 'resource_type': 'Renderbuffer', | 2924 'resource_type': 'Renderbuffer', |
2924 'resource_types': 'Renderbuffers', | 2925 'resource_types': 'Renderbuffers', |
2925 }, | 2926 }, |
2926 'GenSamplers': { | 2927 'GenSamplers': { |
2927 'type': 'GENn', | 2928 'type': 'GENn', |
2928 'gl_test_func': 'glGenSamplers', | 2929 'gl_test_func': 'glGenSamplers', |
2929 'resource_type': 'Sampler', | 2930 'resource_type': 'Sampler', |
2930 'resource_types': 'Samplers', | 2931 'resource_types': 'Samplers', |
2931 'es3': True, | 2932 'es3': True, |
2932 }, | 2933 }, |
2933 'GenTextures': { | 2934 'GenTextures': { |
2934 'type': 'GENn', | 2935 'type': 'GENn', |
2935 'gl_test_func': 'glGenTextures', | 2936 'gl_test_func': 'glGenTextures', |
2936 'resource_type': 'Texture', | 2937 'resource_type': 'Texture', |
2937 'resource_types': 'Textures', | 2938 'resource_types': 'Textures', |
2938 }, | 2939 }, |
2939 'GenTransformFeedbacks': { | 2940 'GenTransformFeedbacks': { |
2940 'type': 'GENn', | 2941 'type': 'GENn', |
2941 'gl_test_func': 'glGenTransformFeedbacks', | 2942 'gl_test_func': 'glGenTransformFeedbacks', |
2942 'resource_type': 'TransformFeedback', | 2943 'resource_type': 'TransformFeedback', |
2943 'resource_types': 'TransformFeedbacks', | 2944 'resource_types': 'TransformFeedbacks', |
2944 'es3': True, | 2945 'es3': True, |
| 2946 'not_shared': 'True', |
2945 }, | 2947 }, |
2946 'GetActiveAttrib': { | 2948 'GetActiveAttrib': { |
2947 'type': 'Custom', | 2949 'type': 'Custom', |
2948 'data_transfer_methods': ['shm'], | 2950 'data_transfer_methods': ['shm'], |
2949 'cmd_args': | 2951 'cmd_args': |
2950 'GLidProgram program, GLuint index, uint32_t name_bucket_id, ' | 2952 'GLidProgram program, GLuint index, uint32_t name_bucket_id, ' |
2951 'void* result', | 2953 'void* result', |
2952 'result': [ | 2954 'result': [ |
2953 'int32_t success', | 2955 'int32_t success', |
2954 'int32_t size', | 2956 'int32_t size', |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4238 }, | 4240 }, |
4239 | 4241 |
4240 'GenVertexArraysOES': { | 4242 'GenVertexArraysOES': { |
4241 'type': 'GENn', | 4243 'type': 'GENn', |
4242 'extension': 'OES_vertex_array_object', | 4244 'extension': 'OES_vertex_array_object', |
4243 'gl_test_func': 'glGenVertexArraysOES', | 4245 'gl_test_func': 'glGenVertexArraysOES', |
4244 'resource_type': 'VertexArray', | 4246 'resource_type': 'VertexArray', |
4245 'resource_types': 'VertexArrays', | 4247 'resource_types': 'VertexArrays', |
4246 'unit_test': False, | 4248 'unit_test': False, |
4247 'pepper_interface': 'VertexArrayObject', | 4249 'pepper_interface': 'VertexArrayObject', |
| 4250 'not_shared': 'True', |
4248 }, | 4251 }, |
4249 'BindVertexArrayOES': { | 4252 'BindVertexArrayOES': { |
4250 'type': 'Bind', | 4253 'type': 'Bind', |
4251 'extension': 'OES_vertex_array_object', | 4254 'extension': 'OES_vertex_array_object', |
4252 'gl_test_func': 'glBindVertexArrayOES', | 4255 'gl_test_func': 'glBindVertexArrayOES', |
4253 'decoder_func': 'DoBindVertexArrayOES', | 4256 'decoder_func': 'DoBindVertexArrayOES', |
4254 'gen_func': 'GenVertexArraysOES', | 4257 'gen_func': 'GenVertexArraysOES', |
4255 'unit_test': False, | 4258 'unit_test': False, |
4256 'client_test': False, | 4259 'client_test': False, |
4257 'pepper_interface': 'VertexArrayObject', | 4260 'pepper_interface': 'VertexArrayObject', |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6030 } | 6033 } |
6031 f.write( | 6034 f.write( |
6032 "%(return_type)s GLES2Implementation::%(name)s(%(typed_args)s) {\n" % | 6035 "%(return_type)s GLES2Implementation::%(name)s(%(typed_args)s) {\n" % |
6033 args) | 6036 args) |
6034 func.WriteDestinationInitalizationValidation(f) | 6037 func.WriteDestinationInitalizationValidation(f) |
6035 self.WriteClientGLCallLog(func, f) | 6038 self.WriteClientGLCallLog(func, f) |
6036 for arg in func.GetOriginalArgs(): | 6039 for arg in func.GetOriginalArgs(): |
6037 arg.WriteClientSideValidationCode(f, func) | 6040 arg.WriteClientSideValidationCode(f, func) |
6038 not_shared = func.GetInfo('not_shared') | 6041 not_shared = func.GetInfo('not_shared') |
6039 if not_shared: | 6042 if not_shared: |
6040 alloc_code = ( | 6043 alloc_code = ("""\ |
6041 | 6044 IdAllocator* id_allocator = GetIdAllocator(IdNamespaces::k%s); |
6042 """ IdAllocator* id_allocator = GetIdAllocator(id_namespaces::k%s); | 6045 for (GLsizei ii = 0; ii < n; ++ii) |
6043 for (GLsizei ii = 0; ii < n; ++ii) | 6046 %s[ii] = id_allocator->AllocateID();""" % |
6044 %s[ii] = id_allocator->AllocateID();""" % | 6047 (func.GetInfo('resource_types'), func.GetOriginalArgs()[1].name)) |
6045 (func.GetInfo('resource_types'), func.GetOriginalArgs()[1].name)) | |
6046 else: | 6048 else: |
6047 alloc_code = (""" GetIdHandler(id_namespaces::k%(resource_types)s)-> | 6049 alloc_code = ("""\ |
| 6050 GetIdHandler(SharedIdNamespaces::k%(resource_types)s)-> |
6048 MakeIds(this, 0, %(args)s);""" % args) | 6051 MakeIds(this, 0, %(args)s);""" % args) |
6049 args['alloc_code'] = alloc_code | 6052 args['alloc_code'] = alloc_code |
6050 | 6053 |
6051 code = """ GPU_CLIENT_SINGLE_THREAD_CHECK(); | 6054 code = """\ |
6052 %(alloc_code)s | 6055 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
6053 %(name)sHelper(%(args)s); | 6056 %(alloc_code)s |
6054 helper_->%(name)sImmediate(%(args)s); | 6057 %(name)sHelper(%(args)s); |
6055 if (share_group_->bind_generates_resource()) | 6058 helper_->%(name)sImmediate(%(args)s); |
6056 helper_->CommandBufferHelper::Flush(); | 6059 """ |
6057 %(log_code)s | 6060 if not not_shared: |
6058 CheckGLError(); | 6061 code += """\ |
6059 } | 6062 if (share_group_->bind_generates_resource()) |
| 6063 helper_->CommandBufferHelper::Flush(); |
| 6064 """ |
| 6065 code += """\ |
| 6066 %(log_code)s |
| 6067 CheckGLError(); |
| 6068 } |
6060 | 6069 |
6061 """ | 6070 """ |
6062 f.write(code % args) | 6071 f.write(code % args) |
6063 | 6072 |
6064 def WriteGLES2ImplementationUnitTest(self, func, f): | 6073 def WriteGLES2ImplementationUnitTest(self, func, f): |
6065 """Overrriden from TypeHandler.""" | 6074 """Overrriden from TypeHandler.""" |
6066 code = """ | 6075 code = """ |
6067 TEST_F(GLES2ImplementationTest, %(name)s) { | 6076 TEST_F(GLES2ImplementationTest, %(name)s) { |
6068 GLuint ids[2] = { 0, }; | 6077 GLuint ids[2] = { 0, }; |
6069 struct Cmds { | 6078 struct Cmds { |
6070 cmds::%(name)sImmediate gen; | 6079 cmds::%(name)sImmediate gen; |
6071 GLuint data[2]; | 6080 GLuint data[2]; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6341 (func.return_type, func.original_name, | 6350 (func.return_type, func.original_name, |
6342 func.MakeTypedOriginalArgString(""))) | 6351 func.MakeTypedOriginalArgString(""))) |
6343 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") | 6352 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") |
6344 func.WriteDestinationInitalizationValidation(f) | 6353 func.WriteDestinationInitalizationValidation(f) |
6345 self.WriteClientGLCallLog(func, f) | 6354 self.WriteClientGLCallLog(func, f) |
6346 for arg in func.GetOriginalArgs(): | 6355 for arg in func.GetOriginalArgs(): |
6347 arg.WriteClientSideValidationCode(f, func) | 6356 arg.WriteClientSideValidationCode(f, func) |
6348 f.write(" GLuint client_id;\n") | 6357 f.write(" GLuint client_id;\n") |
6349 if func.return_type == "GLsync": | 6358 if func.return_type == "GLsync": |
6350 f.write( | 6359 f.write( |
6351 " GetIdHandler(id_namespaces::kSyncs)->\n") | 6360 " GetIdHandler(SharedIdNamespaces::kSyncs)->\n") |
6352 else: | 6361 else: |
6353 f.write( | 6362 f.write( |
6354 " GetIdHandler(id_namespaces::kProgramsAndShaders)->\n") | 6363 " GetIdHandler(SharedIdNamespaces::kProgramsAndShaders)->\n") |
6355 f.write(" MakeIds(this, 0, 1, &client_id);\n") | 6364 f.write(" MakeIds(this, 0, 1, &client_id);\n") |
6356 f.write(" helper_->%s(%s);\n" % | 6365 f.write(" helper_->%s(%s);\n" % |
6357 (func.name, func.MakeCmdArgString(""))) | 6366 (func.name, func.MakeCmdArgString(""))) |
6358 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n') | 6367 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n') |
6359 f.write(" CheckGLError();\n") | 6368 f.write(" CheckGLError();\n") |
6360 if func.return_type == "GLsync": | 6369 if func.return_type == "GLsync": |
6361 f.write(" return reinterpret_cast<GLsync>(client_id);\n") | 6370 f.write(" return reinterpret_cast<GLsync>(client_id);\n") |
6362 else: | 6371 else: |
6363 f.write(" return client_id;\n") | 6372 f.write(" return client_id;\n") |
6364 f.write("}\n") | 6373 f.write("}\n") |
(...skipping 4909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11274 Format(gen.generated_cpp_filenames) | 11283 Format(gen.generated_cpp_filenames) |
11275 | 11284 |
11276 if gen.errors > 0: | 11285 if gen.errors > 0: |
11277 print "%d errors" % gen.errors | 11286 print "%d errors" % gen.errors |
11278 return 1 | 11287 return 1 |
11279 return 0 | 11288 return 0 |
11280 | 11289 |
11281 | 11290 |
11282 if __name__ == '__main__': | 11291 if __name__ == '__main__': |
11283 sys.exit(main(sys.argv[1:])) | 11292 sys.exit(main(sys.argv[1:])) |
OLD | NEW |