| 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 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3366 'GetVertexAttribPointerv': { | 3366 'GetVertexAttribPointerv': { |
| 3367 'type': 'Custom', | 3367 'type': 'Custom', |
| 3368 'data_transfer_methods': ['shm'], | 3368 'data_transfer_methods': ['shm'], |
| 3369 'result': ['SizedResult<GLuint>'], | 3369 'result': ['SizedResult<GLuint>'], |
| 3370 'client_test': False, | 3370 'client_test': False, |
| 3371 }, | 3371 }, |
| 3372 'InvalidateFramebuffer': { | 3372 'InvalidateFramebuffer': { |
| 3373 'type': 'PUTn', | 3373 'type': 'PUTn', |
| 3374 'count': 1, | 3374 'count': 1, |
| 3375 'decoder_func': 'DoInvalidateFramebuffer', | 3375 'decoder_func': 'DoInvalidateFramebuffer', |
| 3376 'client_test': False, | |
| 3377 'unit_test': False, | 3376 'unit_test': False, |
| 3378 'es3': True, | 3377 'es3': True, |
| 3379 }, | 3378 }, |
| 3380 'InvalidateSubFramebuffer': { | 3379 'InvalidateSubFramebuffer': { |
| 3381 'type': 'PUTn', | 3380 'type': 'PUTn', |
| 3382 'count': 1, | 3381 'count': 1, |
| 3383 'decoder_func': 'DoInvalidateSubFramebuffer', | 3382 'decoder_func': 'DoInvalidateSubFramebuffer', |
| 3384 'client_test': False, | |
| 3385 'unit_test': False, | 3383 'unit_test': False, |
| 3386 'es3': True, | 3384 'es3': True, |
| 3387 }, | 3385 }, |
| 3388 'IsBuffer': { | 3386 'IsBuffer': { |
| 3389 'type': 'Is', | 3387 'type': 'Is', |
| 3390 'decoder_func': 'DoIsBuffer', | 3388 'decoder_func': 'DoIsBuffer', |
| 3391 'expectation': False, | 3389 'expectation': False, |
| 3392 }, | 3390 }, |
| 3393 'IsEnabled': { | 3391 'IsEnabled': { |
| 3394 'type': 'Is', | 3392 'type': 'Is', |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3647 'expectation': False, | 3645 'expectation': False, |
| 3648 }, | 3646 }, |
| 3649 'SwapBuffers': { | 3647 'SwapBuffers': { |
| 3650 'impl_func': False, | 3648 'impl_func': False, |
| 3651 'decoder_func': 'DoSwapBuffers', | 3649 'decoder_func': 'DoSwapBuffers', |
| 3652 'client_test': False, | 3650 'client_test': False, |
| 3653 'expectation': False, | 3651 'expectation': False, |
| 3654 'extension': True, | 3652 'extension': True, |
| 3655 'trace_level': 1, | 3653 'trace_level': 1, |
| 3656 }, | 3654 }, |
| 3657 'SwapBuffersWithDamageCHROMIUM': { | 3655 'SwapBuffersWithBoundsCHROMIUM': { |
| 3658 'type': 'Custom', | 3656 'type': 'PUTn', |
| 3657 'count': 4, |
| 3658 'decoder_func': 'DoSwapBuffersWithBoundsCHROMIUM', |
| 3659 'impl_func': False, | 3659 'impl_func': False, |
| 3660 'client_test': False, | 3660 'client_test': False, |
| 3661 'extension': True, | 3661 'extension': True, |
| 3662 }, | 3662 }, |
| 3663 'SwapInterval': { | 3663 'SwapInterval': { |
| 3664 'impl_func': False, | 3664 'impl_func': False, |
| 3665 'decoder_func': 'DoSwapInterval', | 3665 'decoder_func': 'DoSwapInterval', |
| 3666 'client_test': False, | 3666 'client_test': False, |
| 3667 'expectation': False, | 3667 'expectation': False, |
| 3668 'extension': True, | 3668 'extension': True, |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4074 'GLsizei primcount', | 4074 'GLsizei primcount', |
| 4075 'extension': 'ANGLE_instanced_arrays', | 4075 'extension': 'ANGLE_instanced_arrays', |
| 4076 'pepper_interface': 'InstancedArrays', | 4076 'pepper_interface': 'InstancedArrays', |
| 4077 'defer_draws': True, | 4077 'defer_draws': True, |
| 4078 'trace_level': 2, | 4078 'trace_level': 2, |
| 4079 }, | 4079 }, |
| 4080 'DrawBuffersEXT': { | 4080 'DrawBuffersEXT': { |
| 4081 'type': 'PUTn', | 4081 'type': 'PUTn', |
| 4082 'decoder_func': 'DoDrawBuffersEXT', | 4082 'decoder_func': 'DoDrawBuffersEXT', |
| 4083 'count': 1, | 4083 'count': 1, |
| 4084 'client_test': False, | |
| 4085 'unit_test': False, | 4084 'unit_test': False, |
| 4086 # could use 'extension_flag': 'ext_draw_buffers' but currently expected to | 4085 # could use 'extension_flag': 'ext_draw_buffers' but currently expected to |
| 4087 # work without. | 4086 # work without. |
| 4088 'extension': 'EXT_draw_buffers', | 4087 'extension': 'EXT_draw_buffers', |
| 4089 'pepper_interface': 'DrawBuffers', | 4088 'pepper_interface': 'DrawBuffers', |
| 4090 'trace_level': 2, | 4089 'trace_level': 2, |
| 4091 }, | 4090 }, |
| 4092 'DrawElementsInstancedANGLE': { | 4091 'DrawElementsInstancedANGLE': { |
| 4093 'type': 'Custom', | 4092 'type': 'Custom', |
| 4094 'impl_func': False, | 4093 'impl_func': False, |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4321 'client_test': False, | 4320 'client_test': False, |
| 4322 'decoder_func': 'DoTraceEndCHROMIUM', | 4321 'decoder_func': 'DoTraceEndCHROMIUM', |
| 4323 'unit_test': False, | 4322 'unit_test': False, |
| 4324 'extension': 'CHROMIUM_trace_marker', | 4323 'extension': 'CHROMIUM_trace_marker', |
| 4325 }, | 4324 }, |
| 4326 'DiscardFramebufferEXT': { | 4325 'DiscardFramebufferEXT': { |
| 4327 'type': 'PUTn', | 4326 'type': 'PUTn', |
| 4328 'count': 1, | 4327 'count': 1, |
| 4329 'decoder_func': 'DoDiscardFramebufferEXT', | 4328 'decoder_func': 'DoDiscardFramebufferEXT', |
| 4330 'unit_test': False, | 4329 'unit_test': False, |
| 4331 'client_test': False, | |
| 4332 'extension': 'EXT_discard_framebuffer', | 4330 'extension': 'EXT_discard_framebuffer', |
| 4333 'extension_flag': 'ext_discard_framebuffer', | 4331 'extension_flag': 'ext_discard_framebuffer', |
| 4334 'trace_level': 2, | 4332 'trace_level': 2, |
| 4335 }, | 4333 }, |
| 4336 'LoseContextCHROMIUM': { | 4334 'LoseContextCHROMIUM': { |
| 4337 'decoder_func': 'DoLoseContextCHROMIUM', | 4335 'decoder_func': 'DoLoseContextCHROMIUM', |
| 4338 'unit_test': False, | 4336 'unit_test': False, |
| 4339 'extension': 'CHROMIUM_lose_context', | 4337 'extension': 'CHROMIUM_lose_context', |
| 4340 'trace_level': 1, | 4338 'trace_level': 1, |
| 4341 }, | 4339 }, |
| (...skipping 2986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7328 """ | 7326 """ |
| 7329 f.write(code % (self.GetArrayType(func), | 7327 f.write(code % (self.GetArrayType(func), |
| 7330 self.GetArrayCount(func))) | 7328 self.GetArrayCount(func))) |
| 7331 if func.IsImmediate(): | 7329 if func.IsImmediate(): |
| 7332 f.write(" if (data_size > immediate_data_size) {\n") | 7330 f.write(" if (data_size > immediate_data_size) {\n") |
| 7333 f.write(" return error::kOutOfBounds;\n") | 7331 f.write(" return error::kOutOfBounds;\n") |
| 7334 f.write(" }\n") | 7332 f.write(" }\n") |
| 7335 | 7333 |
| 7336 def WriteGLES2Implementation(self, func, f): | 7334 def WriteGLES2Implementation(self, func, f): |
| 7337 """Overrriden from TypeHandler.""" | 7335 """Overrriden from TypeHandler.""" |
| 7336 impl_func = func.GetInfo('impl_func') |
| 7337 if (impl_func != None and impl_func != True): |
| 7338 return; |
| 7338 f.write("%s GLES2Implementation::%s(%s) {\n" % | 7339 f.write("%s GLES2Implementation::%s(%s) {\n" % |
| 7339 (func.return_type, func.original_name, | 7340 (func.return_type, func.original_name, |
| 7340 func.MakeTypedOriginalArgString(""))) | 7341 func.MakeTypedOriginalArgString(""))) |
| 7341 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") | 7342 f.write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") |
| 7342 func.WriteDestinationInitalizationValidation(f) | 7343 func.WriteDestinationInitalizationValidation(f) |
| 7343 self.WriteClientGLCallLog(func, f) | 7344 self.WriteClientGLCallLog(func, f) |
| 7344 last_pointer_name = func.GetLastOriginalPointerArg().name | 7345 last_pointer_name = func.GetLastOriginalPointerArg().name |
| 7345 f.write(""" GPU_CLIENT_LOG_CODE_BLOCK({ | 7346 f.write(""" GPU_CLIENT_LOG_CODE_BLOCK({ |
| 7346 for (GLsizei i = 0; i < count; ++i) { | 7347 for (GLsizei i = 0; i < count; ++i) { |
| 7347 """) | 7348 """) |
| 7348 values_str = ' << ", " << '.join( | 7349 values_str = ' << ", " << '.join( |
| 7349 ["%s[%d + i * %d]" % ( | 7350 ["%s[%d + i * %d]" % ( |
| 7350 last_pointer_name, ndx, self.GetArrayCount(func)) for ndx in range( | 7351 last_pointer_name, ndx, self.GetArrayCount(func)) for ndx in range( |
| 7351 0, self.GetArrayCount(func))]) | 7352 0, self.GetArrayCount(func))]) |
| 7352 f.write(' GPU_CLIENT_LOG(" " << i << ": " << %s);\n' % values_str) | 7353 f.write(' GPU_CLIENT_LOG(" " << i << ": " << %s);\n' % values_str) |
| 7353 f.write(" }\n });\n") | 7354 f.write(" }\n });\n") |
| 7354 for arg in func.GetOriginalArgs(): | 7355 for arg in func.GetOriginalArgs(): |
| 7355 arg.WriteClientSideValidationCode(f, func) | 7356 arg.WriteClientSideValidationCode(f, func) |
| 7356 f.write(" helper_->%sImmediate(%s);\n" % | 7357 f.write(" helper_->%sImmediate(%s);\n" % |
| 7357 (func.name, func.MakeInitString(""))) | 7358 (func.name, func.MakeInitString(""))) |
| 7358 f.write(" CheckGLError();\n") | 7359 f.write(" CheckGLError();\n") |
| 7359 f.write("}\n") | 7360 f.write("}\n") |
| 7360 f.write("\n") | 7361 f.write("\n") |
| 7361 | 7362 |
| 7362 def WriteGLES2ImplementationUnitTest(self, func, f): | 7363 def WriteGLES2ImplementationUnitTest(self, func, f): |
| 7363 """Writes the GLES2 Implemention unit test.""" | 7364 """Writes the GLES2 Implemention unit test.""" |
| 7365 client_test = func.GetInfo('client_test', True) |
| 7366 if not client_test: |
| 7367 return; |
| 7368 |
| 7364 code = """ | 7369 code = """ |
| 7365 TEST_F(GLES2ImplementationTest, %(name)s) { | 7370 TEST_F(GLES2ImplementationTest, %(name)s) { |
| 7366 %(type)s data[%(count_param)d][%(count)d] = {{0}}; | 7371 %(type)s data[%(count_param)d][%(count)d] = {{0}}; |
| 7367 struct Cmds { | 7372 struct Cmds { |
| 7368 cmds::%(name)sImmediate cmd; | 7373 cmds::%(name)sImmediate cmd; |
| 7369 %(type)s data[%(count_param)d][%(count)d]; | 7374 %(type)s data[%(count_param)d][%(count)d]; |
| 7370 }; | 7375 }; |
| 7371 | 7376 |
| 7372 Cmds expected; | 7377 Cmds expected; |
| 7373 for (int ii = 0; ii < %(count_param)d; ++ii) { | 7378 for (int ii = 0; ii < %(count_param)d; ++ii) { |
| (...skipping 3838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11212 Format(gen.generated_cpp_filenames) | 11217 Format(gen.generated_cpp_filenames) |
| 11213 | 11218 |
| 11214 if gen.errors > 0: | 11219 if gen.errors > 0: |
| 11215 print "%d errors" % gen.errors | 11220 print "%d errors" % gen.errors |
| 11216 return 1 | 11221 return 1 |
| 11217 return 0 | 11222 return 0 |
| 11218 | 11223 |
| 11219 | 11224 |
| 11220 if __name__ == '__main__': | 11225 if __name__ == '__main__': |
| 11221 sys.exit(main(sys.argv[1:])) | 11226 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |