| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """code generator for GLES2 command buffers.""" | 7 """code generator for GLES2 command buffers.""" |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import os.path | 10 import os.path |
| (...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 'IsShader': { | 1471 'IsShader': { |
| 1472 'type': 'Is', | 1472 'type': 'Is', |
| 1473 'decoder_func': 'DoIsShader', | 1473 'decoder_func': 'DoIsShader', |
| 1474 'expectation': False, | 1474 'expectation': False, |
| 1475 }, | 1475 }, |
| 1476 'IsTexture': { | 1476 'IsTexture': { |
| 1477 'type': 'Is', | 1477 'type': 'Is', |
| 1478 'decoder_func': 'DoIsTexture', | 1478 'decoder_func': 'DoIsTexture', |
| 1479 'expectation': False, | 1479 'expectation': False, |
| 1480 }, | 1480 }, |
| 1481 'LinkProgram': {'decoder_func': 'DoLinkProgram'}, | 1481 'LinkProgram': { |
| 1482 'decoder_func': 'DoLinkProgram', |
| 1483 'impl_func': False, |
| 1484 }, |
| 1482 'MapBufferSubDataCHROMIUM': { | 1485 'MapBufferSubDataCHROMIUM': { |
| 1483 'gen_cmd': False, | 1486 'gen_cmd': False, |
| 1484 'extension': True, | 1487 'extension': True, |
| 1485 'chromium': True, | 1488 'chromium': True, |
| 1486 }, | 1489 }, |
| 1487 'MapTexSubImage2DCHROMIUM': { | 1490 'MapTexSubImage2DCHROMIUM': { |
| 1488 'gen_cmd': False, | 1491 'gen_cmd': False, |
| 1489 'extension': True, | 1492 'extension': True, |
| 1490 'chromium': True, | 1493 'chromium': True, |
| 1491 }, | 1494 }, |
| (...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3064 """Overrriden from TypeHandler.""" | 3067 """Overrriden from TypeHandler.""" |
| 3065 file.Write("%s %s(%s) {\n" % | 3068 file.Write("%s %s(%s) {\n" % |
| 3066 (func.return_type, func.original_name, | 3069 (func.return_type, func.original_name, |
| 3067 func.MakeTypedOriginalArgString(""))) | 3070 func.MakeTypedOriginalArgString(""))) |
| 3068 func.WriteDestinationInitalizationValidation(file) | 3071 func.WriteDestinationInitalizationValidation(file) |
| 3069 self.WriteClientGLCallLog(func, file) | 3072 self.WriteClientGLCallLog(func, file) |
| 3070 for arg in func.GetOriginalArgs(): | 3073 for arg in func.GetOriginalArgs(): |
| 3071 arg.WriteClientSideValidationCode(file, func) | 3074 arg.WriteClientSideValidationCode(file, func) |
| 3072 file.Write( | 3075 file.Write( |
| 3073 " GPU_CLIENT_DCHECK(%s != 0);\n" % func.GetOriginalArgs()[-1].name) | 3076 " GPU_CLIENT_DCHECK(%s != 0);\n" % func.GetOriginalArgs()[-1].name) |
| 3074 file.Write(" program_and_shader_id_handler_->FreeIds(1, &%s);\n" % | 3077 file.Write(" %sHelper(%s);\n" % |
| 3075 func.GetOriginalArgs()[-1].name) | 3078 (func.original_name, func.GetOriginalArgs()[-1].name)) |
| 3076 file.Write(" helper_->%s(%s);\n" % | |
| 3077 (func.name, func.MakeCmdArgString(""))) | |
| 3078 file.Write(" Flush();\n") | |
| 3079 file.Write("}\n") | 3079 file.Write("}\n") |
| 3080 file.Write("\n") | 3080 file.Write("\n") |
| 3081 | 3081 |
| 3082 | 3082 |
| 3083 class DELnHandler(TypeHandler): | 3083 class DELnHandler(TypeHandler): |
| 3084 """Handler for glDelete___ type functions.""" | 3084 """Handler for glDelete___ type functions.""" |
| 3085 | 3085 |
| 3086 def __init__(self): | 3086 def __init__(self): |
| 3087 TypeHandler.__init__(self) | 3087 TypeHandler.__init__(self) |
| 3088 | 3088 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 """ % func.GetOriginalArgs()[1].name) | 3197 """ % func.GetOriginalArgs()[1].name) |
| 3198 file.Write(""" GPU_CLIENT_DCHECK_CODE_BLOCK({ | 3198 file.Write(""" GPU_CLIENT_DCHECK_CODE_BLOCK({ |
| 3199 for (GLsizei i = 0; i < n; ++i) { | 3199 for (GLsizei i = 0; i < n; ++i) { |
| 3200 GPU_DCHECK(%s[i] != 0); | 3200 GPU_DCHECK(%s[i] != 0); |
| 3201 } | 3201 } |
| 3202 }); | 3202 }); |
| 3203 """ % func.GetOriginalArgs()[1].name) | 3203 """ % func.GetOriginalArgs()[1].name) |
| 3204 for arg in func.GetOriginalArgs(): | 3204 for arg in func.GetOriginalArgs(): |
| 3205 arg.WriteClientSideValidationCode(file, func) | 3205 arg.WriteClientSideValidationCode(file, func) |
| 3206 code = """ %(name)sHelper(%(args)s); | 3206 code = """ %(name)sHelper(%(args)s); |
| 3207 helper_->%(name)sImmediate(%(args)s); | |
| 3208 Flush(); | |
| 3209 } | 3207 } |
| 3210 | 3208 |
| 3211 """ | 3209 """ |
| 3212 file.Write(code % args) | 3210 file.Write(code % args) |
| 3213 | 3211 |
| 3214 def WriteImmediateCmdComputeSize(self, func, file): | 3212 def WriteImmediateCmdComputeSize(self, func, file): |
| 3215 """Overrriden from TypeHandler.""" | 3213 """Overrriden from TypeHandler.""" |
| 3216 file.Write(" static uint32 ComputeDataSize(GLsizei n) {\n") | 3214 file.Write(" static uint32 ComputeDataSize(GLsizei n) {\n") |
| 3217 file.Write( | 3215 file.Write( |
| 3218 " return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT\n") | 3216 " return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT\n") |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4208 def WriteGLES2ImplementationHeader(self, func, file): | 4206 def WriteGLES2ImplementationHeader(self, func, file): |
| 4209 """Overrriden from TypeHandler.""" | 4207 """Overrriden from TypeHandler.""" |
| 4210 code_1 = "%(return_type)s %(func_name)s(%(args)s) {\n" | 4208 code_1 = "%(return_type)s %(func_name)s(%(args)s) {\n" |
| 4211 code_2 = """ GPU_CLIENT_LOG("[" << this << "] gl%(func_name)s" << "(" | 4209 code_2 = """ GPU_CLIENT_LOG("[" << this << "] gl%(func_name)s" << "(" |
| 4212 << %(arg0)s << ", " | 4210 << %(arg0)s << ", " |
| 4213 << %(arg1)s << ", " | 4211 << %(arg1)s << ", " |
| 4214 << static_cast<void*>(%(arg2)s) << ", " | 4212 << static_cast<void*>(%(arg2)s) << ", " |
| 4215 << static_cast<void*>(%(arg3)s) << ")"); | 4213 << static_cast<void*>(%(arg3)s) << ")"); |
| 4216 helper_->SetBucketSize(kResultBucketId, 0); | 4214 helper_->SetBucketSize(kResultBucketId, 0); |
| 4217 helper_->%(func_name)s(%(id_name)s, kResultBucketId); | 4215 helper_->%(func_name)s(%(id_name)s, kResultBucketId); |
| 4218 if (bufsize > 0) { | 4216 std::string str; |
| 4219 std::string str; | 4217 GLsizei max_size = 0; |
| 4220 if (GetBucketAsString(kResultBucketId, &str)) { | 4218 if (GetBucketAsString(kResultBucketId, &str)) { |
| 4221 GLsizei max_size = | 4219 if (bufsize > 0) { |
| 4220 max_size = |
| 4222 std::min(static_cast<size_t>(%(bufsize_name)s) - 1, str.size()); | 4221 std::min(static_cast<size_t>(%(bufsize_name)s) - 1, str.size()); |
| 4223 if (%(length_name)s != NULL) { | |
| 4224 *%(length_name)s = max_size; | |
| 4225 } | |
| 4226 memcpy(%(dest_name)s, str.c_str(), max_size); | 4222 memcpy(%(dest_name)s, str.c_str(), max_size); |
| 4227 %(dest_name)s[max_size] = '\\0'; | 4223 %(dest_name)s[max_size] = '\\0'; |
| 4228 GPU_CLIENT_LOG("------\\n" << %(dest_name)s << "\\n------"); | 4224 GPU_CLIENT_LOG("------\\n" << %(dest_name)s << "\\n------"); |
| 4229 } | 4225 } |
| 4230 } | 4226 } |
| 4227 if (%(length_name)s != NULL) { |
| 4228 *%(length_name)s = max_size; |
| 4229 } |
| 4231 } | 4230 } |
| 4232 """ | 4231 """ |
| 4233 args = func.GetOriginalArgs() | 4232 args = func.GetOriginalArgs() |
| 4234 str_args = { | 4233 str_args = { |
| 4235 'return_type': func.return_type, | 4234 'return_type': func.return_type, |
| 4236 'func_name': func.original_name, | 4235 'func_name': func.original_name, |
| 4237 'args': func.MakeTypedOriginalArgString(""), | 4236 'args': func.MakeTypedOriginalArgString(""), |
| 4238 'id_name': args[0].name, | 4237 'id_name': args[0].name, |
| 4239 'bufsize_name': args[1].name, | 4238 'bufsize_name': args[1].name, |
| 4240 'length_name': args[2].name, | 4239 'length_name': args[2].name, |
| (...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5978 | 5977 |
| 5979 if options.generate_docs: | 5978 if options.generate_docs: |
| 5980 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") | 5979 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") |
| 5981 | 5980 |
| 5982 if gen.errors > 0: | 5981 if gen.errors > 0: |
| 5983 print "%d errors" % gen.errors | 5982 print "%d errors" % gen.errors |
| 5984 sys.exit(1) | 5983 sys.exit(1) |
| 5985 | 5984 |
| 5986 if __name__ == '__main__': | 5985 if __name__ == '__main__': |
| 5987 main(sys.argv[1:]) | 5986 main(sys.argv[1:]) |
| OLD | NEW |