Chromium Code Reviews| 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 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 6042 """ IdAllocator* id_allocator = GetIdAllocator(id_namespaces::k%s); | 6045 """ IdAllocator* id_allocator = GetIdAllocator(ToInt(IdNamespaces::k%s)); |
|
Zhenyao Mo
2017/05/11 22:10:57
This defeats the purpose of using enum classes. Th
Chandan
2017/05/12 12:30:31
Acknowledged.
| |
| 6043 for (GLsizei ii = 0; ii < n; ++ii) | 6046 for (GLsizei ii = 0; ii < n; ++ii) |
| 6044 %s[ii] = id_allocator->AllocateID();""" % | 6047 %s[ii] = id_allocator->AllocateID();""" % |
| 6045 (func.GetInfo('resource_types'), func.GetOriginalArgs()[1].name)) | 6048 (func.GetInfo('resource_types'), func.GetOriginalArgs()[1].name)) |
| 6046 else: | 6049 else: |
| 6047 alloc_code = (""" GetIdHandler(id_namespaces::k%(resource_types)s)-> | 6050 alloc_code = (""" GetIdHandler(ToInt(SharedIdNamespaces::k%(resource_type s)s))-> |
|
Chandan
2017/05/10 14:47:37
How do we format python files in chromium?
Zhenyao Mo
2017/05/11 22:10:57
You can move """... to the next line
Zhenyao Mo
2017/05/11 22:10:57
Same here.
Chandan
2017/05/12 12:30:31
Done.
| |
| 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 = """ GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 6052 %(alloc_code)s | 6055 %(alloc_code)s |
| 6053 %(name)sHelper(%(args)s); | 6056 %(name)sHelper(%(args)s); |
| 6054 helper_->%(name)sImmediate(%(args)s); | 6057 helper_->%(name)sImmediate(%(args)s); |
| 6055 if (share_group_->bind_generates_resource()) | 6058 if (share_group_->bind_generates_resource()) |
| 6056 helper_->CommandBufferHelper::Flush(); | 6059 helper_->CommandBufferHelper::Flush(); |
| 6057 %(log_code)s | 6060 %(log_code)s |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6341 (func.return_type, func.original_name, | 6344 (func.return_type, func.original_name, |
| 6342 func.MakeTypedOriginalArgString(""))) | 6345 func.MakeTypedOriginalArgString(""))) |
| 6343 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") | 6346 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") |
| 6344 func.WriteDestinationInitalizationValidation(f) | 6347 func.WriteDestinationInitalizationValidation(f) |
| 6345 self.WriteClientGLCallLog(func, f) | 6348 self.WriteClientGLCallLog(func, f) |
| 6346 for arg in func.GetOriginalArgs(): | 6349 for arg in func.GetOriginalArgs(): |
| 6347 arg.WriteClientSideValidationCode(f, func) | 6350 arg.WriteClientSideValidationCode(f, func) |
| 6348 f.write(" GLuint client_id;\n") | 6351 f.write(" GLuint client_id;\n") |
| 6349 if func.return_type == "GLsync": | 6352 if func.return_type == "GLsync": |
| 6350 f.write( | 6353 f.write( |
| 6351 " GetIdHandler(id_namespaces::kSyncs)->\n") | 6354 " GetIdHandler(ToInt(SharedIdNamespaces::kSyncs))->\n") |
| 6352 else: | 6355 else: |
| 6353 f.write( | 6356 f.write( |
| 6354 " GetIdHandler(id_namespaces::kProgramsAndShaders)->\n") | 6357 " GetIdHandler(ToInt(SharedIdNamespaces::kProgramsAndShaders))->\n") |
| 6355 f.write(" MakeIds(this, 0, 1, &client_id);\n") | 6358 f.write(" MakeIds(this, 0, 1, &client_id);\n") |
| 6356 f.write(" helper_->%s(%s);\n" % | 6359 f.write(" helper_->%s(%s);\n" % |
| 6357 (func.name, func.MakeCmdArgString(""))) | 6360 (func.name, func.MakeCmdArgString(""))) |
| 6358 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n') | 6361 f.write(' GPU_CLIENT_LOG("returned " << client_id);\n') |
| 6359 f.write(" CheckGLError();\n") | 6362 f.write(" CheckGLError();\n") |
| 6360 if func.return_type == "GLsync": | 6363 if func.return_type == "GLsync": |
| 6361 f.write(" return reinterpret_cast<GLsync>(client_id);\n") | 6364 f.write(" return reinterpret_cast<GLsync>(client_id);\n") |
| 6362 else: | 6365 else: |
| 6363 f.write(" return client_id;\n") | 6366 f.write(" return client_id;\n") |
| 6364 f.write("}\n") | 6367 f.write("}\n") |
| (...skipping 4909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11274 Format(gen.generated_cpp_filenames) | 11277 Format(gen.generated_cpp_filenames) |
| 11275 | 11278 |
| 11276 if gen.errors > 0: | 11279 if gen.errors > 0: |
| 11277 print "%d errors" % gen.errors | 11280 print "%d errors" % gen.errors |
| 11278 return 1 | 11281 return 1 |
| 11279 return 0 | 11282 return 0 |
| 11280 | 11283 |
| 11281 | 11284 |
| 11282 if __name__ == '__main__': | 11285 if __name__ == '__main__': |
| 11283 sys.exit(main(sys.argv[1:])) | 11286 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |