mesa: implement glGet for AMD_framebuffer_multisample_advanced
[mesa.git] / src / mesa / main / get_hash_generator.py
index c777b7824429e6024a5317031b64a2cfbd113eec..facdccd8a53f3637686dbc2a145baf9f31bf06f0 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/python2
 # coding=utf-8
 # -*- Mode: Python; py-indent-offset: 4 -*-
 #
@@ -29,6 +28,8 @@
 # Generate a C header file containing hash tables of glGet parameter
 # names for each GL API. The generated file is to be included by glGet.c
 
+from __future__ import print_function
+
 import os, sys, imp, getopt
 from collections import defaultdict
 import get_hash_params
@@ -44,19 +45,19 @@ prime_factor = 89
 prime_step = 281
 hash_table_size = 1024
 
-gl_apis=set(["GL", "GL_CORE", "GLES", "GLES2", "GLES3", "GLES31"])
+gl_apis=set(["GL", "GL_CORE", "GLES", "GLES2", "GLES3", "GLES31", "GLES32"])
 
 def print_header():
-   print "typedef const unsigned short table_t[%d];\n" % (hash_table_size)
-   print "static const int prime_factor = %d, prime_step = %d;\n" % \
-          (prime_factor, prime_step)
+   print("typedef const unsigned short table_t[%d];\n" % (hash_table_size))
+   print("static const int prime_factor = %d, prime_step = %d;\n" % \
+          (prime_factor, prime_step))
 
 def print_params(params):
-   print "static const struct value_desc values[] = {"
+   print("static const struct value_desc values[] = {")
    for p in params:
-      print "    { %s, %s }," % (p[0], p[1])
+      print("    { %s, %s }," % (p[0], p[1]))
 
-   print "};\n"
+   print("};\n")
 
 def api_name(api):
    return "API_OPEN%s" % api
@@ -69,6 +70,7 @@ api_enum = [
    'GL_CORE',
    'GLES3', # Not in gl_api enum in mtypes.h
    'GLES31', # Not in gl_api enum in mtypes.h
+   'GLES32', # Not in gl_api enum in mtypes.h
 ]
 
 def api_index(api):
@@ -78,7 +80,7 @@ def table_name(api):
    return "table_" + api_name(api)
 
 def print_table(api, table):
-   print "static table_t %s = {" % (table_name(api))
+   print("static table_t %s = {" % (table_name(api)))
 
    # convert sparse (index, value) table into a dense table
    dense_table = [0] * hash_table_size
@@ -89,9 +91,9 @@ def print_table(api, table):
    for i in range(0, hash_table_size, row_size):
       row = dense_table[i : i + row_size]
       idx_val = ["%4d" % v for v in row]
-      print " " * 4 + ", ".join(idx_val) + ","
+      print(" " * 4 + ", ".join(idx_val) + ",")
 
-   print "};\n"
+   print("};\n")
 
 def print_tables(tables):
    for table in tables:
@@ -104,12 +106,12 @@ def print_tables(tables):
          i = api_index(api)
          dense_tables[i] = "&%s" % (tname)
 
-   print "static table_t *table_set[] = {"
+   print("static table_t *table_set[] = {")
    for expr in dense_tables:
-      print "   %s," % expr
-   print "};\n"
+      print("   %s," % expr)
+   print("};\n")
 
-   print "#define table(api) (*table_set[api])"
+   print("#define table(api) (*table_set[api])")
 
 # Merge tables with matching parameter lists (i.e. GL and GL_CORE)
 def merge_tables(tables):
@@ -168,13 +170,18 @@ def generate_hash_tables(enum_list, enabled_apis, param_descriptors):
 
          for api in valid_apis:
             add_to_hash_table(tables[api], hash_val, len(params))
-            # Also add GLES2 items to the GLES3 and GLES31 hash table
+            # Also add GLES2 items to the GLES3+ hash tables
             if api == "GLES2":
                add_to_hash_table(tables["GLES3"], hash_val, len(params))
                add_to_hash_table(tables["GLES31"], hash_val, len(params))
-            # Also add GLES3 items to the GLES31 hash table
+               add_to_hash_table(tables["GLES32"], hash_val, len(params))
+            # Also add GLES3 items to the GLES31+ hash tables
             if api == "GLES3":
                add_to_hash_table(tables["GLES31"], hash_val, len(params))
+               add_to_hash_table(tables["GLES32"], hash_val, len(params))
+            # Also add GLES31 items to the GLES32+ hash tables
+            if api == "GLES31":
+               add_to_hash_table(tables["GLES32"], hash_val, len(params))
          params.append(["GL_" + enum_name, param[1]])
 
    sorted_tables={}
@@ -194,7 +201,7 @@ def show_usage():
 if __name__ == '__main__':
    try:
       (opts, args) = getopt.getopt(sys.argv[1:], "f:")
-   except Exception,e:
+   except Exception:
       show_usage()
 
    if len(args) != 0:
@@ -210,7 +217,8 @@ if __name__ == '__main__':
       die("missing descriptor file (-f)\n")
 
    # generate the code for all APIs
-   enabled_apis = set(["GLES", "GLES2", "GLES3", "GLES31", "GL", "GL_CORE"])
+   enabled_apis = set(["GLES", "GLES2", "GLES3", "GLES31", "GLES32",
+                       "GL", "GL_CORE"])
 
    try:
       api_desc = gl_XML.parse_GL_API(api_desc_file)