| 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 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 # gen_func: Name of function that generates GL resource for corresponding | 1169 # gen_func: Name of function that generates GL resource for corresponding |
| 1170 # bind function. | 1170 # bind function. |
| 1171 # states: array of states that get set by this function corresponding to | 1171 # states: array of states that get set by this function corresponding to |
| 1172 # the given arguments | 1172 # the given arguments |
| 1173 # state_flag: name of flag that is set to true when function is called. | 1173 # state_flag: name of flag that is set to true when function is called. |
| 1174 # no_gl: no GL function is called. | 1174 # no_gl: no GL function is called. |
| 1175 # valid_args: A dictionary of argument indices to args to use in unit tests | 1175 # valid_args: A dictionary of argument indices to args to use in unit tests |
| 1176 # when they can not be automatically determined. | 1176 # when they can not be automatically determined. |
| 1177 # pepper_interface: The pepper interface that is used for this extension | 1177 # pepper_interface: The pepper interface that is used for this extension |
| 1178 # invalid_test: False if no invalid test needed. | 1178 # invalid_test: False if no invalid test needed. |
| 1179 # shadowed: True = the value is shadowed so no glGetXXX call will be made. | |
| 1180 | 1179 |
| 1181 _FUNCTION_INFO = { | 1180 _FUNCTION_INFO = { |
| 1182 'ActiveTexture': { | 1181 'ActiveTexture': { |
| 1183 'decoder_func': 'DoActiveTexture', | 1182 'decoder_func': 'DoActiveTexture', |
| 1184 'unit_test': False, | 1183 'unit_test': False, |
| 1185 'impl_func': False, | 1184 'impl_func': False, |
| 1186 'client_test': False, | 1185 'client_test': False, |
| 1187 }, | 1186 }, |
| 1188 'AttachShader': {'decoder_func': 'DoAttachShader'}, | 1187 'AttachShader': {'decoder_func': 'DoAttachShader'}, |
| 1189 'BindAttribLocation': {'type': 'GLchar', 'bucket': True, 'needs_size': True}, | 1188 'BindAttribLocation': {'type': 'GLchar', 'bucket': True, 'needs_size': True}, |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 'cmd_args': | 1556 'cmd_args': |
| 1558 'GLidProgram program, const char* name, NonImmediate GLint* location', | 1557 'GLidProgram program, const char* name, NonImmediate GLint* location', |
| 1559 'result': ['GLint'], | 1558 'result': ['GLint'], |
| 1560 }, | 1559 }, |
| 1561 'GetBooleanv': { | 1560 'GetBooleanv': { |
| 1562 'type': 'GETn', | 1561 'type': 'GETn', |
| 1563 'result': ['SizedResult<GLboolean>'], | 1562 'result': ['SizedResult<GLboolean>'], |
| 1564 'decoder_func': 'DoGetBooleanv', | 1563 'decoder_func': 'DoGetBooleanv', |
| 1565 'gl_test_func': 'glGetBooleanv', | 1564 'gl_test_func': 'glGetBooleanv', |
| 1566 }, | 1565 }, |
| 1567 'GetBufferParameteriv': { | 1566 'GetBufferParameteriv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, |
| 1568 'type': 'GETn', | |
| 1569 'result': ['SizedResult<GLint>'], | |
| 1570 'decoder_func': 'DoGetBufferParameteriv', | |
| 1571 'expectation': False, | |
| 1572 'shadowed': True, | |
| 1573 }, | |
| 1574 'GetError': { | 1567 'GetError': { |
| 1575 'type': 'Is', | 1568 'type': 'Is', |
| 1576 'decoder_func': 'GetGLError', | 1569 'decoder_func': 'GetGLError', |
| 1577 'impl_func': False, | 1570 'impl_func': False, |
| 1578 'result': ['GLenum'], | 1571 'result': ['GLenum'], |
| 1579 'client_test': False, | 1572 'client_test': False, |
| 1580 }, | 1573 }, |
| 1581 'GetFloatv': { | 1574 'GetFloatv': { |
| 1582 'type': 'GETn', | 1575 'type': 'GETn', |
| 1583 'result': ['SizedResult<GLfloat>'], | 1576 'result': ['SizedResult<GLfloat>'], |
| (...skipping 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4345 """ | 4338 """ |
| 4346 file.Write(code % { | 4339 file.Write(code % { |
| 4347 'last_arg_type': last_arg.type, | 4340 'last_arg_type': last_arg.type, |
| 4348 'func_name': func.name, | 4341 'func_name': func.name, |
| 4349 }) | 4342 }) |
| 4350 func.WriteHandlerValidation(file) | 4343 func.WriteHandlerValidation(file) |
| 4351 code = """ // Check that the client initialized the result. | 4344 code = """ // Check that the client initialized the result. |
| 4352 if (result->size != 0) { | 4345 if (result->size != 0) { |
| 4353 return error::kInvalidArguments; | 4346 return error::kInvalidArguments; |
| 4354 } | 4347 } |
| 4348 CopyRealGLErrorsToWrapper(); |
| 4355 """ | 4349 """ |
| 4356 shadowed = func.GetInfo('shadowed') | |
| 4357 if not shadowed: | |
| 4358 file.Write(" CopyRealGLErrorsToWrapper();\n"); | |
| 4359 file.Write(code) | 4350 file.Write(code) |
| 4360 func.WriteHandlerImplementation(file) | 4351 func.WriteHandlerImplementation(file) |
| 4361 if shadowed: | 4352 code = """ GLenum error = glGetError(); |
| 4362 code = """ result->SetNumResults(num_values); | |
| 4363 return error::kNoError; | |
| 4364 } | |
| 4365 """ | |
| 4366 else: | |
| 4367 code = """ GLenum error = glGetError(); | |
| 4368 if (error == GL_NO_ERROR) { | 4353 if (error == GL_NO_ERROR) { |
| 4369 result->SetNumResults(num_values); | 4354 result->SetNumResults(num_values); |
| 4370 } else { | 4355 } else { |
| 4371 SetGLError(error, "", ""); | 4356 SetGLError(error, "", ""); |
| 4372 } | 4357 } |
| 4373 return error::kNoError; | 4358 return error::kNoError; |
| 4374 } | 4359 } |
| 4375 | 4360 |
| 4376 """ | 4361 """ |
| 4377 file.Write(code) | 4362 file.Write(code) |
| (...skipping 3234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7612 gen.WriteGLES2Header("../GLES2/gl2chromium_autogen.h") | 7597 gen.WriteGLES2Header("../GLES2/gl2chromium_autogen.h") |
| 7613 | 7598 |
| 7614 if gen.errors > 0: | 7599 if gen.errors > 0: |
| 7615 print "%d errors" % gen.errors | 7600 print "%d errors" % gen.errors |
| 7616 return 1 | 7601 return 1 |
| 7617 return 0 | 7602 return 0 |
| 7618 | 7603 |
| 7619 | 7604 |
| 7620 if __name__ == '__main__': | 7605 if __name__ == '__main__': |
| 7621 sys.exit(main(sys.argv[1:])) | 7606 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |