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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 } | 540 } |
| 541 | 541 |
| 542 # Named type info object represents a named type that is used in OpenGL call | 542 # Named type info object represents a named type that is used in OpenGL call |
| 543 # arguments. Each named type defines a set of valid OpenGL call arguments. The | 543 # arguments. Each named type defines a set of valid OpenGL call arguments. The |
| 544 # named types are used in 'cmd_buffer_functions.txt'. | 544 # named types are used in 'cmd_buffer_functions.txt'. |
| 545 # type: The actual GL type of the named type. | 545 # type: The actual GL type of the named type. |
| 546 # valid: The list of values that are valid for both the client and the service. | 546 # valid: The list of values that are valid for both the client and the service. |
| 547 # valid_es3: The list of values that are valid in OpenGL ES 3, but not ES 2. | 547 # valid_es3: The list of values that are valid in OpenGL ES 3, but not ES 2. |
| 548 # invalid: Examples of invalid values for the type. At least these values | 548 # invalid: Examples of invalid values for the type. At least these values |
| 549 # should be tested to be invalid. | 549 # should be tested to be invalid. |
| 550 # invalid_es3: The list of values that are valid in OpenGL ES2, but not ES3. | |
| 550 # is_complete: The list of valid values of type are final and will not be | 551 # is_complete: The list of valid values of type are final and will not be |
| 551 # modified during runtime. | 552 # modified during runtime. |
| 552 _NAMED_TYPE_INFO = { | 553 _NAMED_TYPE_INFO = { |
| 553 'BlitFilter': { | 554 'BlitFilter': { |
| 554 'type': 'GLenum', | 555 'type': 'GLenum', |
| 555 'valid': [ | 556 'valid': [ |
| 556 'GL_NEAREST', | 557 'GL_NEAREST', |
| 557 'GL_LINEAR', | 558 'GL_LINEAR', |
| 558 ], | 559 ], |
| 559 'invalid': [ | 560 'invalid': [ |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1361 'GL_RGBA4', | 1362 'GL_RGBA4', |
| 1362 'GL_RGB10_A2', | 1363 'GL_RGB10_A2', |
| 1363 'GL_RGBA16F', | 1364 'GL_RGBA16F', |
| 1364 'GL_RGBA32F', | 1365 'GL_RGBA32F', |
| 1365 'GL_RGBA8UI', | 1366 'GL_RGBA8UI', |
| 1366 'GL_RGBA8I', | 1367 'GL_RGBA8I', |
| 1367 'GL_RGB10_A2UI', | 1368 'GL_RGB10_A2UI', |
| 1368 'GL_RGBA16UI', | 1369 'GL_RGBA16UI', |
| 1369 'GL_RGBA16I', | 1370 'GL_RGBA16I', |
| 1370 'GL_RGBA32UI', | 1371 'GL_RGBA32UI', |
| 1371 'GL_RGBA32I', | 1372 'GL_RGBA32I', |
|
no sievers
2015/03/12 22:37:05
maybe put a comment that these are not supported f
Zhenyao Mo
2015/03/12 22:39:17
Done.
| |
| 1372 'GL_DEPTH_COMPONENT16', | 1373 'GL_DEPTH_COMPONENT16', |
| 1373 'GL_DEPTH_COMPONENT24', | 1374 'GL_DEPTH_COMPONENT24', |
| 1374 'GL_DEPTH_COMPONENT32F', | 1375 'GL_DEPTH_COMPONENT32F', |
| 1375 'GL_DEPTH24_STENCIL8', | 1376 'GL_DEPTH24_STENCIL8', |
| 1376 'GL_DEPTH32F_STENCIL8', | 1377 'GL_DEPTH32F_STENCIL8', |
| 1377 ], | 1378 ], |
| 1378 'invalid': [ | 1379 'invalid': [ |
| 1379 'GL_BGRA', | 1380 'GL_BGRA', |
| 1380 'GL_BGR', | 1381 'GL_BGR', |
| 1381 ], | 1382 ], |
| 1382 }, | 1383 }, |
| 1383 'CopyTextureInternalFormat': { | 1384 'TextureInternalFormatStorage': { |
| 1384 'type': 'GLenum', | 1385 'type': 'GLenum', |
| 1385 'valid': [ | 1386 'valid': [ |
| 1386 'GL_ALPHA', | 1387 'GL_RGB565', |
| 1387 'GL_LUMINANCE', | 1388 'GL_RGBA4', |
| 1388 'GL_LUMINANCE_ALPHA', | 1389 'GL_RGB5_A1', |
| 1389 'GL_RGB', | 1390 'GL_ALPHA8_EXT', |
| 1390 'GL_RGBA', | 1391 'GL_LUMINANCE8_EXT', |
| 1392 'GL_LUMINANCE8_ALPHA8_EXT', | |
| 1393 'GL_RGB8_OES', | |
| 1394 'GL_RGBA8_OES', | |
| 1391 ], | 1395 ], |
| 1392 'valid_es3': [ | 1396 'valid_es3': [ |
| 1393 'GL_R8', | 1397 'GL_R8', |
| 1394 'GL_R8_SNORM', | 1398 'GL_R8_SNORM', |
| 1395 'GL_R16F', | 1399 'GL_R16F', |
| 1396 'GL_R32F', | 1400 'GL_R32F', |
| 1397 'GL_R8UI', | 1401 'GL_R8UI', |
| 1398 'GL_R8I', | 1402 'GL_R8I', |
| 1399 'GL_R16UI', | 1403 'GL_R16UI', |
| 1400 'GL_R16I', | 1404 'GL_R16I', |
| 1401 'GL_R32UI', | 1405 'GL_R32UI', |
| 1402 'GL_R32I', | 1406 'GL_R32I', |
| 1403 'GL_RG8', | 1407 'GL_RG8', |
| 1404 'GL_RG8_SNORM', | 1408 'GL_RG8_SNORM', |
| 1405 'GL_RG16F', | 1409 'GL_RG16F', |
| 1406 'GL_RG32F', | 1410 'GL_RG32F', |
| 1407 'GL_RG8UI', | 1411 'GL_RG8UI', |
| 1408 'GL_RG8I', | 1412 'GL_RG8I', |
| 1409 'GL_RG16UI', | 1413 'GL_RG16UI', |
| 1410 'GL_RG16I', | 1414 'GL_RG16I', |
| 1411 'GL_RG32UI', | 1415 'GL_RG32UI', |
| 1412 'GL_RG32I', | 1416 'GL_RG32I', |
| 1413 'GL_RGB8', | |
| 1414 'GL_SRGB8', | 1417 'GL_SRGB8', |
| 1415 'GL_RGB565', | |
| 1416 'GL_RGB8_SNORM', | 1418 'GL_RGB8_SNORM', |
| 1417 'GL_R11F_G11F_B10F', | 1419 'GL_R11F_G11F_B10F', |
| 1418 'GL_RGB9_E5', | 1420 'GL_RGB9_E5', |
| 1419 'GL_RGB16F', | 1421 'GL_RGB16F', |
| 1420 'GL_RGB32F', | 1422 'GL_RGB32F', |
| 1421 'GL_RGB8UI', | 1423 'GL_RGB8UI', |
| 1422 'GL_RGB8I', | 1424 'GL_RGB8I', |
| 1423 'GL_RGB16UI', | 1425 'GL_RGB16UI', |
| 1424 'GL_RGB16I', | 1426 'GL_RGB16I', |
| 1425 'GL_RGB32UI', | 1427 'GL_RGB32UI', |
| 1426 'GL_RGB32I', | 1428 'GL_RGB32I', |
| 1427 'GL_RGBA8', | |
| 1428 'GL_SRGB8_ALPHA8', | 1429 'GL_SRGB8_ALPHA8', |
| 1429 'GL_RGBA8_SNORM', | 1430 'GL_RGBA8_SNORM', |
| 1430 'GL_RGB5_A1', | |
| 1431 'GL_RGBA4', | |
| 1432 'GL_RGB10_A2', | 1431 'GL_RGB10_A2', |
| 1433 'GL_RGBA16F', | 1432 'GL_RGBA16F', |
| 1434 'GL_RGBA32F', | 1433 'GL_RGBA32F', |
| 1435 'GL_RGBA8UI', | 1434 'GL_RGBA8UI', |
| 1436 'GL_RGBA8I', | 1435 'GL_RGBA8I', |
| 1437 'GL_RGB10_A2UI', | 1436 'GL_RGB10_A2UI', |
| 1438 'GL_RGBA16UI', | 1437 'GL_RGBA16UI', |
| 1439 'GL_RGBA16I', | 1438 'GL_RGBA16I', |
| 1440 'GL_RGBA32UI', | 1439 'GL_RGBA32UI', |
| 1441 'GL_RGBA32I', | 1440 'GL_RGBA32I', |
| 1441 'GL_DEPTH_COMPONENT16', | |
| 1442 'GL_DEPTH_COMPONENT24', | |
| 1443 'GL_DEPTH_COMPONENT32F', | |
| 1444 'GL_DEPTH24_STENCIL8', | |
| 1445 'GL_DEPTH32F_STENCIL8', | |
| 1446 'GL_COMPRESSED_R11_EAC', | |
| 1447 'GL_COMPRESSED_SIGNED_R11_EAC', | |
| 1448 'GL_COMPRESSED_RG11_EAC', | |
| 1449 'GL_COMPRESSED_SIGNED_RG11_EAC', | |
| 1450 'GL_COMPRESSED_RGB8_ETC2', | |
| 1451 'GL_COMPRESSED_SRGB8_ETC2', | |
| 1452 'GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2', | |
| 1453 'GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2', | |
| 1454 'GL_COMPRESSED_RGBA8_ETC2_EAC', | |
| 1455 'GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC', | |
| 1442 ], | 1456 ], |
| 1443 'invalid': [ | 1457 'invalid_es3': [ |
| 1444 'GL_BGRA', | |
| 1445 'GL_BGR', | |
| 1446 ], | |
| 1447 }, | |
| 1448 'TextureInternalFormatStorage': { | |
| 1449 'type': 'GLenum', | |
| 1450 'valid': [ | |
| 1451 'GL_RGB565', | |
| 1452 'GL_RGBA4', | |
| 1453 'GL_RGB5_A1', | |
| 1454 'GL_ALPHA8_EXT', | 1458 'GL_ALPHA8_EXT', |
| 1455 'GL_LUMINANCE8_EXT', | 1459 'GL_LUMINANCE8_EXT', |
| 1456 'GL_LUMINANCE8_ALPHA8_EXT', | 1460 'GL_LUMINANCE8_ALPHA8_EXT', |
| 1457 'GL_RGB8_OES', | 1461 'GL_ALPHA16F_EXT', |
| 1458 'GL_RGBA8_OES', | 1462 'GL_LUMINANCE16F_EXT', |
| 1463 'GL_LUMINANCE_ALPHA16F_EXT', | |
| 1464 'GL_ALPHA32F_EXT', | |
| 1465 'GL_LUMINANCE32F_EXT', | |
| 1466 'GL_LUMINANCE_ALPHA32F_EXT', | |
| 1459 ], | 1467 ], |
| 1460 }, | 1468 }, |
| 1461 'ImageInternalFormat': { | 1469 'ImageInternalFormat': { |
| 1462 'type': 'GLenum', | 1470 'type': 'GLenum', |
| 1463 'valid': [ | 1471 'valid': [ |
| 1464 'GL_RGB', | 1472 'GL_RGB', |
| 1465 'GL_RGBA', | 1473 'GL_RGBA', |
| 1466 ], | 1474 ], |
| 1467 }, | 1475 }, |
| 1468 'ImageUsage': { | 1476 'ImageUsage': { |
| (...skipping 6225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7694 self.info = info | 7702 self.info = info |
| 7695 self.valid = info['valid'] | 7703 self.valid = info['valid'] |
| 7696 if 'invalid' in info: | 7704 if 'invalid' in info: |
| 7697 self.invalid = info['invalid'] | 7705 self.invalid = info['invalid'] |
| 7698 else: | 7706 else: |
| 7699 self.invalid = [] | 7707 self.invalid = [] |
| 7700 if 'valid_es3' in info: | 7708 if 'valid_es3' in info: |
| 7701 self.valid_es3 = info['valid_es3'] | 7709 self.valid_es3 = info['valid_es3'] |
| 7702 else: | 7710 else: |
| 7703 self.valid_es3 = [] | 7711 self.valid_es3 = [] |
| 7712 if 'invalid_es3' in info: | |
| 7713 self.invalid_es3 = info['invalid_es3'] | |
| 7714 else: | |
| 7715 self.invalid_es3 = [] | |
| 7704 | 7716 |
| 7705 def GetType(self): | 7717 def GetType(self): |
| 7706 return self.info['type'] | 7718 return self.info['type'] |
| 7707 | 7719 |
| 7708 def GetInvalidValues(self): | 7720 def GetInvalidValues(self): |
| 7709 return self.invalid | 7721 return self.invalid |
| 7710 | 7722 |
| 7711 def GetValidValues(self): | 7723 def GetValidValues(self): |
| 7712 return self.valid | 7724 return self.valid |
| 7713 | 7725 |
| 7714 def GetValidValuesES3(self): | 7726 def GetValidValuesES3(self): |
| 7715 return self.valid_es3 | 7727 return self.valid_es3 |
| 7716 | 7728 |
| 7729 def GetInvalidValuesES3(self): | |
| 7730 return self.invalid_es3 | |
| 7731 | |
| 7717 def IsConstant(self): | 7732 def IsConstant(self): |
| 7718 if not 'is_complete' in self.info: | 7733 if not 'is_complete' in self.info: |
| 7719 return False | 7734 return False |
| 7720 | 7735 |
| 7721 return len(self.GetValidValues()) == 1 | 7736 return len(self.GetValidValues()) == 1 |
| 7722 | 7737 |
| 7723 def GetConstantValue(self): | 7738 def GetConstantValue(self): |
| 7724 return self.GetValidValues()[0] | 7739 return self.GetValidValues()[0] |
| 7725 | 7740 |
| 7726 class Argument(object): | 7741 class Argument(object): |
| (...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10013 file.Write(" %s,\n" % value) | 10028 file.Write(" %s,\n" % value) |
| 10014 file.Write("};\n") | 10029 file.Write("};\n") |
| 10015 file.Write("\n") | 10030 file.Write("\n") |
| 10016 if named_type.GetValidValuesES3(): | 10031 if named_type.GetValidValuesES3(): |
| 10017 file.Write("static const %s valid_%s_table_es3[] = {\n" % | 10032 file.Write("static const %s valid_%s_table_es3[] = {\n" % |
| 10018 (named_type.GetType(), ToUnderscore(name))) | 10033 (named_type.GetType(), ToUnderscore(name))) |
| 10019 for value in named_type.GetValidValuesES3(): | 10034 for value in named_type.GetValidValuesES3(): |
| 10020 file.Write(" %s,\n" % value) | 10035 file.Write(" %s,\n" % value) |
| 10021 file.Write("};\n") | 10036 file.Write("};\n") |
| 10022 file.Write("\n") | 10037 file.Write("\n") |
| 10038 if named_type.GetInvalidValuesES3(): | |
| 10039 file.Write("static const %s invalid_%s_table_es3[] = {\n" % | |
| 10040 (named_type.GetType(), ToUnderscore(name))) | |
| 10041 for value in named_type.GetInvalidValuesES3(): | |
| 10042 file.Write(" %s,\n" % value) | |
| 10043 file.Write("};\n") | |
| 10044 file.Write("\n") | |
| 10023 file.Write("Validators::Validators()") | 10045 file.Write("Validators::Validators()") |
| 10024 pre = ' : ' | 10046 pre = ' : ' |
| 10025 for count, name in enumerate(names): | 10047 for count, name in enumerate(names): |
| 10026 named_type = NamedType(_NAMED_TYPE_INFO[name]) | 10048 named_type = NamedType(_NAMED_TYPE_INFO[name]) |
| 10027 if named_type.IsConstant(): | 10049 if named_type.IsConstant(): |
| 10028 continue | 10050 continue |
| 10029 if named_type.GetValidValues(): | 10051 if named_type.GetValidValues(): |
| 10030 code = """%(pre)s%(name)s( | 10052 code = """%(pre)s%(name)s( |
| 10031 valid_%(name)s_table, arraysize(valid_%(name)s_table))""" | 10053 valid_%(name)s_table, arraysize(valid_%(name)s_table))""" |
| 10032 else: | 10054 else: |
| 10033 code = "%(pre)s%(name)s()" | 10055 code = "%(pre)s%(name)s()" |
| 10034 file.Write(code % { | 10056 file.Write(code % { |
| 10035 'name': ToUnderscore(name), | 10057 'name': ToUnderscore(name), |
| 10036 'pre': pre, | 10058 'pre': pre, |
| 10037 }) | 10059 }) |
| 10038 pre = ',\n ' | 10060 pre = ',\n ' |
| 10039 file.Write(" {\n"); | 10061 file.Write(" {\n"); |
| 10040 file.Write("}\n\n"); | 10062 file.Write("}\n\n"); |
| 10041 | 10063 |
| 10042 file.Write("void Validators::AddES3Values() {\n") | 10064 file.Write("void Validators::UpdateValuesES3() {\n") |
| 10043 for name in names: | 10065 for name in names: |
| 10044 named_type = NamedType(_NAMED_TYPE_INFO[name]) | 10066 named_type = NamedType(_NAMED_TYPE_INFO[name]) |
| 10067 if named_type.GetInvalidValuesES3(): | |
| 10068 code = """ %(name)s.RemoveValues( | |
| 10069 invalid_%(name)s_table_es3, arraysize(invalid_%(name)s_table_es3)); | |
| 10070 """ | |
| 10071 file.Write(code % { | |
| 10072 'name': ToUnderscore(name), | |
| 10073 }) | |
| 10045 if named_type.GetValidValuesES3(): | 10074 if named_type.GetValidValuesES3(): |
| 10046 code = """ %(name)s.AddValues( | 10075 code = """ %(name)s.AddValues( |
| 10047 valid_%(name)s_table_es3, arraysize(valid_%(name)s_table_es3)); | 10076 valid_%(name)s_table_es3, arraysize(valid_%(name)s_table_es3)); |
| 10048 """ | 10077 """ |
| 10049 file.Write(code % { | 10078 file.Write(code % { |
| 10050 'name': ToUnderscore(name), | 10079 'name': ToUnderscore(name), |
| 10051 }) | 10080 }) |
| 10052 file.Write("}\n\n"); | 10081 file.Write("}\n\n"); |
| 10053 file.Close() | 10082 file.Close() |
| 10054 self.generated_cpp_filenames.append(file.filename) | 10083 self.generated_cpp_filenames.append(file.filename) |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10472 Format(gen.generated_cpp_filenames) | 10501 Format(gen.generated_cpp_filenames) |
| 10473 | 10502 |
| 10474 if gen.errors > 0: | 10503 if gen.errors > 0: |
| 10475 print "%d errors" % gen.errors | 10504 print "%d errors" % gen.errors |
| 10476 return 1 | 10505 return 1 |
| 10477 return 0 | 10506 return 0 |
| 10478 | 10507 |
| 10479 | 10508 |
| 10480 if __name__ == '__main__': | 10509 if __name__ == '__main__': |
| 10481 sys.exit(main(sys.argv[1:])) | 10510 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |