summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2012-10-10 12:25:06 +0100
committerJosé Fonseca <[email protected]>2012-10-10 17:55:04 +0100
commit856464979bb50c9209c19b66147c8f94cdf5be43 (patch)
tree112cd36afff6a0e3b0075594255f72d341b57d7a /src
parent3f228ed0907f1eff46e1afa3fe3ac961c532bc5f (diff)
mesa: Avoid C99 indexed initializers.
Not supported by MSVC. Reviewed-by: Imre Deak <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/get_hash_generator.py31
-rw-r--r--src/mesa/main/mtypes.h3
2 files changed, 29 insertions, 5 deletions
diff --git a/src/mesa/main/get_hash_generator.py b/src/mesa/main/get_hash_generator.py
index 770093cc47b..4b3f5f490a3 100644
--- a/src/mesa/main/get_hash_generator.py
+++ b/src/mesa/main/get_hash_generator.py
@@ -61,16 +61,32 @@ def print_params(params):
def api_name(api):
return "API_OPEN%s" % api
+# This must match gl_api enum in src/mesa/main/mtypes.h
+api_enum = [
+ 'GL',
+ 'GLES',
+ 'GLES2',
+ 'GL_CORE',
+]
+
+def api_index(api):
+ return api_enum.index(api)
+
def table_name(api):
return "table_" + api_name(api)
def print_table(api, table):
print "static table_t %s = {" % (table_name(api))
+ # convert sparse (index, value) table into a dense table
+ dense_table = [0] * hash_table_size
+ for i, v in table:
+ dense_table[i] = v
+
row_size = 4
- for i in range(0, len(table), row_size):
- row = table[i : i + row_size]
- idx_val = ["[%4d] = %4d" % iv for iv in row]
+ 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 "};\n"
@@ -79,11 +95,16 @@ def print_tables(tables):
for table in tables:
print_table(table["apis"][0], table["indices"])
- print "static table_t *table_set[] = {"
+ dense_tables = ['NULL'] * len(api_enum)
for table in tables:
tname = table_name(table["apis"][0])
for api in table["apis"]:
- print " [%s] = &%s," % (api_name(api), tname)
+ i = api_index(api)
+ dense_tables[i] = "&%s" % (tname)
+
+ print "static table_t *table_set[] = {"
+ for expr in dense_tables:
+ print " %s," % expr
print "};\n"
print "#define table(api) (*table_set[api])"
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 40a802f52e6..b154b952775 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3334,6 +3334,9 @@ struct gl_debug_state
/**
* Enum for the OpenGL APIs we know about and may support.
+ *
+ * NOTE: This must match the api_enum table in
+ * src/mesa/main/get_hash_generator.py
*/
typedef enum
{