mesa: Use correct enum conversion function.
[mesa.git] / src / mesa / main / get_hash_generator.py
index 4b3f5f490a37f336a5d2052bc0523a1a48db6d7c..96bc4958797e2e886f7b4d819f7cbf494472edd5 100644 (file)
@@ -44,7 +44,7 @@ prime_factor = 89
 prime_step = 281
 hash_table_size = 1024
 
-gl_apis=set(["GL", "GL_CORE", "GLES", "GLES2"])
+gl_apis=set(["GL", "GL_CORE", "GLES", "GLES2", "GLES3"])
 
 def print_header():
    print "typedef const unsigned short table_t[%d];\n" % (hash_table_size)
@@ -67,6 +67,7 @@ api_enum = [
    'GLES',
    'GLES2',
    'GL_CORE',
+   'GLES3', # Not in gl_api enum in mtypes.h
 ]
 
 def api_index(api):
@@ -166,6 +167,9 @@ 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 hash table
+            if api == "GLES2":
+               add_to_hash_table(tables["GLES3"], hash_val, len(params))
 
          params.append(["GL_" + enum_name, param[1]])
 
@@ -175,52 +179,34 @@ def generate_hash_tables(enum_list, enabled_apis, param_descriptors):
 
    return params, merge_tables(sorted_tables)
 
-def opt_to_apis(feature):
-   _map = {"ES1": "GLES", "ES2": "GLES2", "GL": "GL"}
-   if feature not in _map:
-      return None
-
-   apis = set([_map[feature]])
-   if "GL" in apis:
-      apis.add("GL_CORE")
-
-   return apis
 
 def show_usage():
    sys.stderr.write(
 """Usage: %s [OPTIONS]
   -f <file>          specify GL API XML file
-  -a [GL|ES1|ES2]    specify APIs to generate hash tables for
 """ % (program))
    exit(1)
 
 if __name__ == '__main__':
    try:
-      (opts, args) = getopt.getopt(sys.argv[1:], "f:a:")
+      (opts, args) = getopt.getopt(sys.argv[1:], "f:")
    except Exception,e:
       show_usage()
 
    if len(args) != 0:
       show_usage()
 
-   enabled_apis = set([])
    api_desc_file = ""
 
    for opt_name, opt_val in opts:
       if opt_name == "-f":
          api_desc_file = opt_val
-      if opt_name == "-a":
-         apis = opt_to_apis(opt_val.upper())
-         if not apis:
-            die("invalid API %s\n" % opt_val)
-
-         enabled_apis |= apis
 
    if not api_desc_file:
       die("missing descriptor file (-f)\n")
 
-   if len(enabled_apis) == 0:
-      die("need at least a single enabled API\n")
+   # generate the code for all APIs
+   enabled_apis = set(["GLES", "GLES2", "GLES3", "GL", "GL_CORE"])
 
    try:
       api_desc = gl_XML.parse_GL_API(api_desc_file)