Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/BUILD.gn ('k') | gpu/command_buffer/client/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 # deprecated_es3: The list of values that are valid in OpenGL ES 2, but
551 # deprecated in ES 3.
550 # is_complete: The list of valid values of type are final and will not be 552 # is_complete: The list of valid values of type are final and will not be
551 # modified during runtime. 553 # modified during runtime.
552 _NAMED_TYPE_INFO = { 554 _NAMED_TYPE_INFO = {
553 'BlitFilter': { 555 'BlitFilter': {
554 'type': 'GLenum', 556 'type': 'GLenum',
555 'valid': [ 557 'valid': [
556 'GL_NEAREST', 558 'GL_NEAREST',
557 'GL_LINEAR', 559 'GL_LINEAR',
558 ], 560 ],
559 'invalid': [ 561 'invalid': [
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 'invalid': [ 771 'invalid': [
770 'GL_TEXTURE_2D', 772 'GL_TEXTURE_2D',
771 ] 773 ]
772 }, 774 },
773 'TextureBindTarget': { 775 'TextureBindTarget': {
774 'type': 'GLenum', 776 'type': 'GLenum',
775 'valid': [ 777 'valid': [
776 'GL_TEXTURE_2D', 778 'GL_TEXTURE_2D',
777 'GL_TEXTURE_CUBE_MAP', 779 'GL_TEXTURE_CUBE_MAP',
778 ], 780 ],
781 'valid_es3': [
782 'GL_TEXTURE_3D',
783 'GL_TEXTURE_2D_ARRAY',
784 ],
779 'invalid': [ 785 'invalid': [
780 'GL_TEXTURE_1D', 786 'GL_TEXTURE_1D',
781 'GL_TEXTURE_3D', 787 'GL_TEXTURE_3D',
782 ], 788 ],
783 }, 789 },
784 'TransformFeedbackBindTarget': { 790 'TransformFeedbackBindTarget': {
785 'type': 'GLenum', 791 'type': 'GLenum',
786 'valid': [ 792 'valid': [
787 'GL_TRANSFORM_FEEDBACK', 793 'GL_TRANSFORM_FEEDBACK',
788 ], 794 ],
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 ], 1222 ],
1217 }, 1223 },
1218 'PixelType': { 1224 'PixelType': {
1219 'type': 'GLenum', 1225 'type': 'GLenum',
1220 'valid': [ 1226 'valid': [
1221 'GL_UNSIGNED_BYTE', 1227 'GL_UNSIGNED_BYTE',
1222 'GL_UNSIGNED_SHORT_5_6_5', 1228 'GL_UNSIGNED_SHORT_5_6_5',
1223 'GL_UNSIGNED_SHORT_4_4_4_4', 1229 'GL_UNSIGNED_SHORT_4_4_4_4',
1224 'GL_UNSIGNED_SHORT_5_5_5_1', 1230 'GL_UNSIGNED_SHORT_5_5_5_1',
1225 ], 1231 ],
1232 'valid_es3': [
1233 'GL_BYTE',
1234 'GL_UNSIGNED_SHORT',
1235 'GL_SHORT',
1236 'GL_UNSIGNED_INT',
1237 'GL_INT',
1238 'GL_HALF_FLOAT',
1239 'GL_FLOAT',
1240 'GL_UNSIGNED_INT_2_10_10_10_REV',
1241 'GL_UNSIGNED_INT_10F_11F_11F_REV',
1242 'GL_UNSIGNED_INT_5_9_9_9_REV',
1243 'GL_UNSIGNED_INT_24_8',
1244 'GL_FLOAT_32_UNSIGNED_INT_24_8_REV',
1245 ],
1226 'invalid': [ 1246 'invalid': [
1227 'GL_SHORT', 1247 'GL_UNSIGNED_BYTE_3_3_2',
1228 'GL_INT',
1229 ], 1248 ],
1230 }, 1249 },
1231 'ReadPixelType': { 1250 'ReadPixelType': {
1232 'type': 'GLenum', 1251 'type': 'GLenum',
1233 'valid': [ 1252 'valid': [
1234 'GL_UNSIGNED_BYTE', 1253 'GL_UNSIGNED_BYTE',
1235 'GL_UNSIGNED_SHORT_5_6_5', 1254 'GL_UNSIGNED_SHORT_5_6_5',
1236 'GL_UNSIGNED_SHORT_4_4_4_4', 1255 'GL_UNSIGNED_SHORT_4_4_4_4',
1237 'GL_UNSIGNED_SHORT_5_5_5_1', 1256 'GL_UNSIGNED_SHORT_5_5_5_1',
1238 ], 1257 ],
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 }, 1290 },
1272 'TextureFormat': { 1291 'TextureFormat': {
1273 'type': 'GLenum', 1292 'type': 'GLenum',
1274 'valid': [ 1293 'valid': [
1275 'GL_ALPHA', 1294 'GL_ALPHA',
1276 'GL_LUMINANCE', 1295 'GL_LUMINANCE',
1277 'GL_LUMINANCE_ALPHA', 1296 'GL_LUMINANCE_ALPHA',
1278 'GL_RGB', 1297 'GL_RGB',
1279 'GL_RGBA', 1298 'GL_RGBA',
1280 ], 1299 ],
1300 'valid_es3': [
1301 'GL_RED',
1302 'GL_RED_INTEGER',
1303 'GL_RG',
1304 'GL_RG_INTEGER',
1305 'GL_RGB_INTEGER',
1306 'GL_RGBA_INTEGER',
1307 'GL_DEPTH_COMPONENT',
1308 'GL_DEPTH_STENCIL',
1309 ],
1281 'invalid': [ 1310 'invalid': [
1282 'GL_BGRA', 1311 'GL_BGRA',
1283 'GL_BGR', 1312 'GL_BGR',
1284 ], 1313 ],
1285 }, 1314 },
1286 'TextureInternalFormat': { 1315 'TextureInternalFormat': {
1287 'type': 'GLenum', 1316 'type': 'GLenum',
1288 'valid': [ 1317 'valid': [
1289 'GL_ALPHA', 1318 'GL_ALPHA',
1290 'GL_LUMINANCE', 1319 'GL_LUMINANCE',
1291 'GL_LUMINANCE_ALPHA', 1320 'GL_LUMINANCE_ALPHA',
1292 'GL_RGB', 1321 'GL_RGB',
1293 'GL_RGBA', 1322 'GL_RGBA',
1294 ], 1323 ],
1324 'valid_es3': [
1325 'GL_R8',
1326 'GL_R8_SNORM',
1327 'GL_R16F',
1328 'GL_R32F',
1329 'GL_R8UI',
1330 'GL_R8I',
1331 'GL_R16UI',
1332 'GL_R16I',
1333 'GL_R32UI',
1334 'GL_R32I',
1335 'GL_RG8',
1336 'GL_RG8_SNORM',
1337 'GL_RG16F',
1338 'GL_RG32F',
1339 'GL_RG8UI',
1340 'GL_RG8I',
1341 'GL_RG16UI',
1342 'GL_RG16I',
1343 'GL_RG32UI',
1344 'GL_RG32I',
1345 'GL_RGB8',
1346 'GL_SRGB8',
1347 'GL_RGB565',
1348 'GL_RGB8_SNORM',
1349 'GL_R11F_G11F_B10F',
1350 'GL_RGB9_E5',
1351 'GL_RGB16F',
1352 'GL_RGB32F',
1353 'GL_RGB8UI',
1354 'GL_RGB8I',
1355 'GL_RGB16UI',
1356 'GL_RGB16I',
1357 'GL_RGB32UI',
1358 'GL_RGB32I',
1359 'GL_RGBA8',
1360 'GL_SRGB8_ALPHA8',
1361 'GL_RGBA8_SNORM',
1362 'GL_RGB5_A1',
1363 'GL_RGBA4',
1364 'GL_RGB10_A2',
1365 'GL_RGBA16F',
1366 'GL_RGBA32F',
1367 'GL_RGBA8UI',
1368 'GL_RGBA8I',
1369 'GL_RGB10_A2UI',
1370 'GL_RGBA16UI',
1371 'GL_RGBA16I',
1372 'GL_RGBA32UI',
1373 'GL_RGBA32I',
1374 # The DEPTH/STENCIL formats are not supported in CopyTexImage2D.
1375 # We will reject them dynamically in GPU command buffer.
1376 'GL_DEPTH_COMPONENT16',
1377 'GL_DEPTH_COMPONENT24',
1378 'GL_DEPTH_COMPONENT32F',
1379 'GL_DEPTH24_STENCIL8',
1380 'GL_DEPTH32F_STENCIL8',
1381 ],
1295 'invalid': [ 1382 'invalid': [
1296 'GL_BGRA', 1383 'GL_BGRA',
1297 'GL_BGR', 1384 'GL_BGR',
1298 ], 1385 ],
1299 }, 1386 },
1300 'TextureInternalFormatStorage': { 1387 'TextureInternalFormatStorage': {
1301 'type': 'GLenum', 1388 'type': 'GLenum',
1302 'valid': [ 1389 'valid': [
1303 'GL_RGB565', 1390 'GL_RGB565',
1304 'GL_RGBA4', 1391 'GL_RGBA4',
1305 'GL_RGB5_A1', 1392 'GL_RGB5_A1',
1306 'GL_ALPHA8_EXT', 1393 'GL_ALPHA8_EXT',
1307 'GL_LUMINANCE8_EXT', 1394 'GL_LUMINANCE8_EXT',
1308 'GL_LUMINANCE8_ALPHA8_EXT', 1395 'GL_LUMINANCE8_ALPHA8_EXT',
1309 'GL_RGB8_OES', 1396 'GL_RGB8_OES',
1310 'GL_RGBA8_OES', 1397 'GL_RGBA8_OES',
1311 ], 1398 ],
1399 'valid_es3': [
1400 'GL_R8',
1401 'GL_R8_SNORM',
1402 'GL_R16F',
1403 'GL_R32F',
1404 'GL_R8UI',
1405 'GL_R8I',
1406 'GL_R16UI',
1407 'GL_R16I',
1408 'GL_R32UI',
1409 'GL_R32I',
1410 'GL_RG8',
1411 'GL_RG8_SNORM',
1412 'GL_RG16F',
1413 'GL_RG32F',
1414 'GL_RG8UI',
1415 'GL_RG8I',
1416 'GL_RG16UI',
1417 'GL_RG16I',
1418 'GL_RG32UI',
1419 'GL_RG32I',
1420 'GL_SRGB8',
1421 'GL_RGB8_SNORM',
1422 'GL_R11F_G11F_B10F',
1423 'GL_RGB9_E5',
1424 'GL_RGB16F',
1425 'GL_RGB32F',
1426 'GL_RGB8UI',
1427 'GL_RGB8I',
1428 'GL_RGB16UI',
1429 'GL_RGB16I',
1430 'GL_RGB32UI',
1431 'GL_RGB32I',
1432 'GL_SRGB8_ALPHA8',
1433 'GL_RGBA8_SNORM',
1434 'GL_RGB10_A2',
1435 'GL_RGBA16F',
1436 'GL_RGBA32F',
1437 'GL_RGBA8UI',
1438 'GL_RGBA8I',
1439 'GL_RGB10_A2UI',
1440 'GL_RGBA16UI',
1441 'GL_RGBA16I',
1442 'GL_RGBA32UI',
1443 'GL_RGBA32I',
1444 'GL_DEPTH_COMPONENT16',
1445 'GL_DEPTH_COMPONENT24',
1446 'GL_DEPTH_COMPONENT32F',
1447 'GL_DEPTH24_STENCIL8',
1448 'GL_DEPTH32F_STENCIL8',
1449 'GL_COMPRESSED_R11_EAC',
1450 'GL_COMPRESSED_SIGNED_R11_EAC',
1451 'GL_COMPRESSED_RG11_EAC',
1452 'GL_COMPRESSED_SIGNED_RG11_EAC',
1453 'GL_COMPRESSED_RGB8_ETC2',
1454 'GL_COMPRESSED_SRGB8_ETC2',
1455 'GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2',
1456 'GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2',
1457 'GL_COMPRESSED_RGBA8_ETC2_EAC',
1458 'GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC',
1459 ],
1460 'deprecated_es3': [
1461 'GL_ALPHA8_EXT',
1462 'GL_LUMINANCE8_EXT',
1463 'GL_LUMINANCE8_ALPHA8_EXT',
1464 'GL_ALPHA16F_EXT',
1465 'GL_LUMINANCE16F_EXT',
1466 'GL_LUMINANCE_ALPHA16F_EXT',
1467 'GL_ALPHA32F_EXT',
1468 'GL_LUMINANCE32F_EXT',
1469 'GL_LUMINANCE_ALPHA32F_EXT',
1470 ],
1312 }, 1471 },
1313 'ImageInternalFormat': { 1472 'ImageInternalFormat': {
1314 'type': 'GLenum', 1473 'type': 'GLenum',
1315 'valid': [ 1474 'valid': [
1316 'GL_RGB', 1475 'GL_RGB',
1317 'GL_RGBA', 1476 'GL_RGBA',
1318 ], 1477 ],
1319 }, 1478 },
1320 'ImageUsage': { 1479 'ImageUsage': {
1321 'type': 'GLenum', 1480 'type': 'GLenum',
(...skipping 6224 matching lines...) Expand 10 before | Expand all | Expand 10 after
7546 self.info = info 7705 self.info = info
7547 self.valid = info['valid'] 7706 self.valid = info['valid']
7548 if 'invalid' in info: 7707 if 'invalid' in info:
7549 self.invalid = info['invalid'] 7708 self.invalid = info['invalid']
7550 else: 7709 else:
7551 self.invalid = [] 7710 self.invalid = []
7552 if 'valid_es3' in info: 7711 if 'valid_es3' in info:
7553 self.valid_es3 = info['valid_es3'] 7712 self.valid_es3 = info['valid_es3']
7554 else: 7713 else:
7555 self.valid_es3 = [] 7714 self.valid_es3 = []
7715 if 'deprecated_es3' in info:
7716 self.deprecated_es3 = info['deprecated_es3']
7717 else:
7718 self.deprecated_es3 = []
7556 7719
7557 def GetType(self): 7720 def GetType(self):
7558 return self.info['type'] 7721 return self.info['type']
7559 7722
7560 def GetInvalidValues(self): 7723 def GetInvalidValues(self):
7561 return self.invalid 7724 return self.invalid
7562 7725
7563 def GetValidValues(self): 7726 def GetValidValues(self):
7564 return self.valid 7727 return self.valid
7565 7728
7566 def GetValidValuesES3(self): 7729 def GetValidValuesES3(self):
7567 return self.valid_es3 7730 return self.valid_es3
7568 7731
7732 def GetDeprecatedValuesES3(self):
7733 return self.deprecated_es3
7734
7569 def IsConstant(self): 7735 def IsConstant(self):
7570 if not 'is_complete' in self.info: 7736 if not 'is_complete' in self.info:
7571 return False 7737 return False
7572 7738
7573 return len(self.GetValidValues()) == 1 7739 return len(self.GetValidValues()) == 1
7574 7740
7575 def GetConstantValue(self): 7741 def GetConstantValue(self):
7576 return self.GetValidValues()[0] 7742 return self.GetValidValues()[0]
7577 7743
7578 class Argument(object): 7744 class Argument(object):
(...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after
9865 file.Write(" %s,\n" % value) 10031 file.Write(" %s,\n" % value)
9866 file.Write("};\n") 10032 file.Write("};\n")
9867 file.Write("\n") 10033 file.Write("\n")
9868 if named_type.GetValidValuesES3(): 10034 if named_type.GetValidValuesES3():
9869 file.Write("static const %s valid_%s_table_es3[] = {\n" % 10035 file.Write("static const %s valid_%s_table_es3[] = {\n" %
9870 (named_type.GetType(), ToUnderscore(name))) 10036 (named_type.GetType(), ToUnderscore(name)))
9871 for value in named_type.GetValidValuesES3(): 10037 for value in named_type.GetValidValuesES3():
9872 file.Write(" %s,\n" % value) 10038 file.Write(" %s,\n" % value)
9873 file.Write("};\n") 10039 file.Write("};\n")
9874 file.Write("\n") 10040 file.Write("\n")
10041 if named_type.GetDeprecatedValuesES3():
10042 file.Write("static const %s deprecated_%s_table_es3[] = {\n" %
10043 (named_type.GetType(), ToUnderscore(name)))
10044 for value in named_type.GetDeprecatedValuesES3():
10045 file.Write(" %s,\n" % value)
10046 file.Write("};\n")
10047 file.Write("\n")
9875 file.Write("Validators::Validators()") 10048 file.Write("Validators::Validators()")
9876 pre = ' : ' 10049 pre = ' : '
9877 for count, name in enumerate(names): 10050 for count, name in enumerate(names):
9878 named_type = NamedType(_NAMED_TYPE_INFO[name]) 10051 named_type = NamedType(_NAMED_TYPE_INFO[name])
9879 if named_type.IsConstant(): 10052 if named_type.IsConstant():
9880 continue 10053 continue
9881 if named_type.GetValidValues(): 10054 if named_type.GetValidValues():
9882 code = """%(pre)s%(name)s( 10055 code = """%(pre)s%(name)s(
9883 valid_%(name)s_table, arraysize(valid_%(name)s_table))""" 10056 valid_%(name)s_table, arraysize(valid_%(name)s_table))"""
9884 else: 10057 else:
9885 code = "%(pre)s%(name)s()" 10058 code = "%(pre)s%(name)s()"
9886 file.Write(code % { 10059 file.Write(code % {
9887 'name': ToUnderscore(name), 10060 'name': ToUnderscore(name),
9888 'pre': pre, 10061 'pre': pre,
9889 }) 10062 })
9890 pre = ',\n ' 10063 pre = ',\n '
9891 file.Write(" {\n"); 10064 file.Write(" {\n");
9892 file.Write("}\n\n"); 10065 file.Write("}\n\n");
9893 10066
9894 file.Write("void Validators::AddES3Values() {\n") 10067 file.Write("void Validators::UpdateValuesES3() {\n")
9895 for name in names: 10068 for name in names:
9896 named_type = NamedType(_NAMED_TYPE_INFO[name]) 10069 named_type = NamedType(_NAMED_TYPE_INFO[name])
10070 if named_type.GetDeprecatedValuesES3():
10071 code = """ %(name)s.RemoveValues(
10072 deprecated_%(name)s_table_es3, arraysize(deprecated_%(name)s_table_es3));
10073 """
10074 file.Write(code % {
10075 'name': ToUnderscore(name),
10076 })
9897 if named_type.GetValidValuesES3(): 10077 if named_type.GetValidValuesES3():
9898 code = """ %(name)s.AddValues( 10078 code = """ %(name)s.AddValues(
9899 valid_%(name)s_table_es3, arraysize(valid_%(name)s_table_es3)); 10079 valid_%(name)s_table_es3, arraysize(valid_%(name)s_table_es3));
9900 """ 10080 """
9901 file.Write(code % { 10081 file.Write(code % {
9902 'name': ToUnderscore(name), 10082 'name': ToUnderscore(name),
9903 }) 10083 })
9904 file.Write("}\n\n"); 10084 file.Write("}\n\n");
9905 file.Close() 10085 file.Close()
9906 self.generated_cpp_filenames.append(file.filename) 10086 self.generated_cpp_filenames.append(file.filename)
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
10324 Format(gen.generated_cpp_filenames) 10504 Format(gen.generated_cpp_filenames)
10325 10505
10326 if gen.errors > 0: 10506 if gen.errors > 0:
10327 print "%d errors" % gen.errors 10507 print "%d errors" % gen.errors
10328 return 1 10508 return 1
10329 return 0 10509 return 0
10330 10510
10331 10511
10332 if __name__ == '__main__': 10512 if __name__ == '__main__':
10333 sys.exit(main(sys.argv[1:])) 10513 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « gpu/BUILD.gn ('k') | gpu/command_buffer/client/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698