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

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

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

Powered by Google App Engine
This is Rietveld 408576698