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 os | 8 import os |
9 import os.path | 9 import os.path |
10 import sys | 10 import sys |
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 'client_test': False, | 1707 'client_test': False, |
1708 'gl_test_func': 'glGetQueryObjectuiv', | 1708 'gl_test_func': 'glGetQueryObjectuiv', |
1709 'pepper_interface': 'Query', | 1709 'pepper_interface': 'Query', |
1710 }, | 1710 }, |
1711 'BindUniformLocationCHROMIUM': { | 1711 'BindUniformLocationCHROMIUM': { |
1712 'type': 'GLchar', | 1712 'type': 'GLchar', |
1713 'bucket': True, | 1713 'bucket': True, |
1714 'needs_size': True, | 1714 'needs_size': True, |
1715 'gl_test_func': 'DoBindUniformLocationCHROMIUM', | 1715 'gl_test_func': 'DoBindUniformLocationCHROMIUM', |
1716 }, | 1716 }, |
| 1717 'InsertEventMarkerEXT': { |
| 1718 'type': 'GLcharN', |
| 1719 'decoder_func': 'DoInsertEventMarkerEXT', |
| 1720 'expectation': False, |
| 1721 }, |
| 1722 'PushGroupMarkerEXT': { |
| 1723 'type': 'GLcharN', |
| 1724 'decoder_func': 'DoPushGroupMarkerEXT', |
| 1725 'expectation': False, |
| 1726 }, |
| 1727 'PopGroupMarkerEXT': { |
| 1728 'decoder_func': 'DoPopGroupMarkerEXT', |
| 1729 'expectation': False, |
| 1730 'impl_func': False, |
| 1731 }, |
1717 } | 1732 } |
1718 | 1733 |
1719 | 1734 |
1720 def SplitWords(input_string): | 1735 def SplitWords(input_string): |
1721 """Transforms a input_string into a list of lower-case components. | 1736 """Transforms a input_string into a list of lower-case components. |
1722 | 1737 |
1723 Args: | 1738 Args: |
1724 input_string: the input string. | 1739 input_string: the input string. |
1725 | 1740 |
1726 Returns: | 1741 Returns: |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2220 (result_string, func.original_name, | 2235 (result_string, func.original_name, |
2221 func.MakeOriginalArgString(""))) | 2236 func.MakeOriginalArgString(""))) |
2222 file.Write("}\n") | 2237 file.Write("}\n") |
2223 | 2238 |
2224 def WriteClientGLCallLog(self, func, file): | 2239 def WriteClientGLCallLog(self, func, file): |
2225 """Writes a logging macro for the client side code.""" | 2240 """Writes a logging macro for the client side code.""" |
2226 comma = "" | 2241 comma = "" |
2227 if len(func.GetOriginalArgs()): | 2242 if len(func.GetOriginalArgs()): |
2228 comma = " << " | 2243 comma = " << " |
2229 file.Write( | 2244 file.Write( |
2230 ' GPU_CLIENT_LOG("[" << this << "] gl%s("%s%s << ")");\n' % | 2245 ' GPU_CLIENT_LOG("[" << GetLogPrefix() << "] gl%s("%s%s << ")");\n' % |
2231 (func.original_name, comma, func.MakeLogArgString())) | 2246 (func.original_name, comma, func.MakeLogArgString())) |
2232 | 2247 |
2233 def WriteClientGLReturnLog(self, func, file): | 2248 def WriteClientGLReturnLog(self, func, file): |
2234 """Writes the return value logging code.""" | 2249 """Writes the return value logging code.""" |
2235 if func.return_type != "void": | 2250 if func.return_type != "void": |
2236 file.Write(' GPU_CLIENT_LOG("return:" << result)\n') | 2251 file.Write(' GPU_CLIENT_LOG("return:" << result)\n') |
2237 | 2252 |
2238 def WriteGLES2ImplementationHeader(self, func, file): | 2253 def WriteGLES2ImplementationHeader(self, func, file): |
2239 """Writes the GLES2 Implemention.""" | 2254 """Writes the GLES2 Implemention.""" |
2240 impl_func = func.GetInfo('impl_func') | 2255 impl_func = func.GetInfo('impl_func') |
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4269 } | 4284 } |
4270 | 4285 |
4271 """ | 4286 """ |
4272 file.Write(code % { | 4287 file.Write(code % { |
4273 'func_name': func.name, | 4288 'func_name': func.name, |
4274 'init_code': "\n".join(init_code), | 4289 'init_code': "\n".join(init_code), |
4275 'check_code': "\n".join(check_code), | 4290 'check_code': "\n".join(check_code), |
4276 }) | 4291 }) |
4277 | 4292 |
4278 | 4293 |
| 4294 class GLcharNHandler(CustomHandler): |
| 4295 """Handler for functions that pass a single string with an optional len.""" |
| 4296 |
| 4297 def __init__(self): |
| 4298 CustomHandler.__init__(self) |
| 4299 |
| 4300 def InitFunction(self, func): |
| 4301 """Overrriden from TypeHandler.""" |
| 4302 func.cmd_args = [] |
| 4303 func.AddCmdArg(Argument('bucket_id', 'GLuint')) |
| 4304 |
| 4305 def AddImmediateFunction(self, generator, func): |
| 4306 """Overrriden from TypeHandler.""" |
| 4307 pass |
| 4308 |
| 4309 def AddBucketFunction(self, generator, func): |
| 4310 """Overrriden from TypeHandler.""" |
| 4311 pass |
| 4312 |
| 4313 def WriteServiceImplementation(self, func, file): |
| 4314 """Overrriden from TypeHandler.""" |
| 4315 file.Write("""error::Error GLES2DecoderImpl::Handle%(name)s( |
| 4316 uint32 immediate_data_size, const gles2::%(name)s& c) { |
| 4317 GLuint bucket_id = static_cast<GLuint>(c.%(bucket_id)s); |
| 4318 Bucket* bucket = GetBucket(bucket_id); |
| 4319 if (!bucket || bucket->size() == 0) { |
| 4320 return error::kInvalidArguments; |
| 4321 } |
| 4322 std::string str; |
| 4323 if (!bucket->GetAsString(&str)) { |
| 4324 return error::kInvalidArguments; |
| 4325 } |
| 4326 %(gl_func_name)s(0, str.c_str()); |
| 4327 return error::kNoError; |
| 4328 } |
| 4329 |
| 4330 """ % { |
| 4331 'name': func.name, |
| 4332 'gl_func_name': func.GetGLFunctionName(), |
| 4333 'bucket_id': func.cmd_args[0].name, |
| 4334 }) |
| 4335 |
| 4336 |
4279 class IsHandler(TypeHandler): | 4337 class IsHandler(TypeHandler): |
4280 """Handler for glIs____ type and glGetError functions.""" | 4338 """Handler for glIs____ type and glGetError functions.""" |
4281 | 4339 |
4282 def __init__(self): | 4340 def __init__(self): |
4283 TypeHandler.__init__(self) | 4341 TypeHandler.__init__(self) |
4284 | 4342 |
4285 def InitFunction(self, func): | 4343 def InitFunction(self, func): |
4286 """Overrriden from TypeHandler.""" | 4344 """Overrriden from TypeHandler.""" |
4287 func.AddCmdArg(Argument("result_shm_id", 'uint32')) | 4345 func.AddCmdArg(Argument("result_shm_id", 'uint32')) |
4288 func.AddCmdArg(Argument("result_shm_offset", 'uint32')) | 4346 func.AddCmdArg(Argument("result_shm_offset", 'uint32')) |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4437 func.ClearCmdArgs() | 4495 func.ClearCmdArgs() |
4438 func.AddCmdArg(cmd_args[0]) | 4496 func.AddCmdArg(cmd_args[0]) |
4439 # add on a bucket id. | 4497 # add on a bucket id. |
4440 func.AddCmdArg(Argument('bucket_id', 'uint32')) | 4498 func.AddCmdArg(Argument('bucket_id', 'uint32')) |
4441 | 4499 |
4442 def WriteGLES2ImplementationHeader(self, func, file): | 4500 def WriteGLES2ImplementationHeader(self, func, file): |
4443 """Overrriden from TypeHandler.""" | 4501 """Overrriden from TypeHandler.""" |
4444 code_1 = """%(return_type)s %(func_name)s(%(args)s) { | 4502 code_1 = """%(return_type)s %(func_name)s(%(args)s) { |
4445 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 4503 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
4446 """ | 4504 """ |
4447 code_2 = """ GPU_CLIENT_LOG("[" << this << "] gl%(func_name)s" << "(" | 4505 code_2 = """ GPU_CLIENT_LOG("[" << GetLogPrefix() |
| 4506 << "] gl%(func_name)s" << "(" |
4448 << %(arg0)s << ", " | 4507 << %(arg0)s << ", " |
4449 << %(arg1)s << ", " | 4508 << %(arg1)s << ", " |
4450 << static_cast<void*>(%(arg2)s) << ", " | 4509 << static_cast<void*>(%(arg2)s) << ", " |
4451 << static_cast<void*>(%(arg3)s) << ")"); | 4510 << static_cast<void*>(%(arg3)s) << ")"); |
4452 helper_->SetBucketSize(kResultBucketId, 0); | 4511 helper_->SetBucketSize(kResultBucketId, 0); |
4453 helper_->%(func_name)s(%(id_name)s, kResultBucketId); | 4512 helper_->%(func_name)s(%(id_name)s, kResultBucketId); |
4454 std::string str; | 4513 std::string str; |
4455 GLsizei max_size = 0; | 4514 GLsizei max_size = 0; |
4456 if (GetBucketAsString(kResultBucketId, &str)) { | 4515 if (GetBucketAsString(kResultBucketId, &str)) { |
4457 if (bufsize > 0) { | 4516 if (bufsize > 0) { |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5615 self._type_handlers = { | 5674 self._type_handlers = { |
5616 'Bind': BindHandler(), | 5675 'Bind': BindHandler(), |
5617 'Create': CreateHandler(), | 5676 'Create': CreateHandler(), |
5618 'Custom': CustomHandler(), | 5677 'Custom': CustomHandler(), |
5619 'Data': DataHandler(), | 5678 'Data': DataHandler(), |
5620 'Delete': DeleteHandler(), | 5679 'Delete': DeleteHandler(), |
5621 'DELn': DELnHandler(), | 5680 'DELn': DELnHandler(), |
5622 'GENn': GENnHandler(), | 5681 'GENn': GENnHandler(), |
5623 'GETn': GETnHandler(), | 5682 'GETn': GETnHandler(), |
5624 'GLchar': GLcharHandler(), | 5683 'GLchar': GLcharHandler(), |
| 5684 'GLcharN': GLcharNHandler(), |
5625 'HandWritten': HandWrittenHandler(), | 5685 'HandWritten': HandWrittenHandler(), |
5626 'Is': IsHandler(), | 5686 'Is': IsHandler(), |
5627 'Manual': ManualHandler(), | 5687 'Manual': ManualHandler(), |
5628 'PUT': PUTHandler(), | 5688 'PUT': PUTHandler(), |
5629 'PUTn': PUTnHandler(), | 5689 'PUTn': PUTnHandler(), |
5630 'PUTXn': PUTXnHandler(), | 5690 'PUTXn': PUTXnHandler(), |
5631 'STRn': STRnHandler(), | 5691 'STRn': STRnHandler(), |
5632 'Todo': TodoHandler(), | 5692 'Todo': TodoHandler(), |
5633 } | 5693 } |
5634 | 5694 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6277 gen.WriteCommonUtilsImpl("common/gles2_cmd_utils_implementation_autogen.h") | 6337 gen.WriteCommonUtilsImpl("common/gles2_cmd_utils_implementation_autogen.h") |
6278 | 6338 |
6279 if gen.errors > 0: | 6339 if gen.errors > 0: |
6280 print "%d errors" % gen.errors | 6340 print "%d errors" % gen.errors |
6281 return 1 | 6341 return 1 |
6282 return 0 | 6342 return 0 |
6283 | 6343 |
6284 | 6344 |
6285 if __name__ == '__main__': | 6345 if __name__ == '__main__': |
6286 sys.exit(main(sys.argv[1:])) | 6346 sys.exit(main(sys.argv[1:])) |
OLD | NEW |