[Mesa-dev] [PATCH 3/6] glapi: use gl_and_es_API.xml to generate GLES headers

Chia-I Wu olvaffe at gmail.com
Thu Aug 11 02:45:23 PDT 2011


From: Chia-I Wu <olv at lunarg.com>

glapi/gen-es/ defines two sets of GLAPI XMLs for OpenGL ES 1.1
(es1_API.xml) and 2.0 (es2_API.xml) respectively.  They are used to
generate dispatch.h and remap_helper.h for GLES.  Together with
gl_and_es_API.xml, we have to maintain three sets of GLAPI XMLs.

This commit makes dispatch.h and remap_helper.h for GLES be generated
from gl_and_es_API.xml.
---
 src/mapi/glapi/gen-es/Makefile     |   10 ++++++----
 src/mapi/glapi/gen/Makefile        |    6 ++----
 src/mapi/glapi/gen/gl_table.py     |   20 +++++++++++++++-----
 src/mapi/glapi/gen/remap_helper.py |   18 ++++++++++++++++--
 src/mesa/SConscript                |   16 ++++++++--------
 5 files changed, 47 insertions(+), 23 deletions(-)

diff --git a/src/mapi/glapi/gen-es/Makefile b/src/mapi/glapi/gen-es/Makefile
index bf66ec0..3fd539d 100644
--- a/src/mapi/glapi/gen-es/Makefile
+++ b/src/mapi/glapi/gen-es/Makefile
@@ -11,8 +11,8 @@ OUTPUTS :=			\
 COMMON = gl_and_es_API.xml gl_XML.py glX_XML.py license.py typeexpr.py
 COMMON := $(addprefix $(GLAPI)/, $(COMMON))
 
-ES1_APIXML := es1_API.xml
-ES2_APIXML := es2_API.xml
+ES1_APIXML := $(GLAPI)/gl_and_es_API.xml
+ES2_APIXML := $(GLAPI)/gl_and_es_API.xml
 ES1_OUTPUT_DIR := $(TOP)/src/mapi/es1api
 ES2_OUTPUT_DIR := $(TOP)/src/mapi/es2api
 
@@ -37,10 +37,12 @@ shared-glapi: $(SHARED_GLAPI_OUTPUTS)
 
 $(ES1_OUTPUTS): APIXML := $(ES1_APIXML)
 $(ES1_OUTPUTS): PRINTER := es1api
+$(ES1_OUTPUTS): GLES_VER := es1
 $(ES1_OUTPUTS): $(ES1_DEPS)
 
 $(ES2_OUTPUTS): APIXML := $(ES2_APIXML)
 $(ES2_OUTPUTS): PRINTER := es2api
+$(ES2_OUTPUTS): GLES_VER := es2
 $(ES2_OUTPUTS): $(ES2_DEPS)
 
 $(SHARED_GLAPI_OUTPUTS): APIXML := $(SHARED_GLAPI_APIXML)
@@ -49,7 +51,7 @@ $(SHARED_GLAPI_OUTPUTS): $(SHARED_GLAPI_DEPS)
 
 define gen-glapi
 	@mkdir -p $(dir $@)
-	$(PYTHON2) $(PYTHON_FLAGS) $< -f $(APIXML) $(1) > $@
+	$(PYTHON2) $(PYTHON_FLAGS) $< -f $(APIXML) -c $(GLES_VER) $(1) > $@
 endef
 
 %/glapi_mapi_tmp.h: $(MAPI)/mapi_abi.py $(COMMON)
@@ -58,7 +60,7 @@ endef
 		--printer $(PRINTER) --mode lib $(GLAPI)/gl_and_es_API.xml > $@
 
 %/main/dispatch.h: $(GLAPI)/gl_table.py $(COMMON)
-	$(call gen-glapi,-c -m remap_table)
+	$(call gen-glapi,-m remap_table)
 
 %/main/remap_helper.h: $(GLAPI)/remap_helper.py $(COMMON)
 	$(call gen-glapi)
diff --git a/src/mapi/glapi/gen/Makefile b/src/mapi/glapi/gen/Makefile
index 3e101f3..c386b87 100644
--- a/src/mapi/glapi/gen/Makefile
+++ b/src/mapi/glapi/gen/Makefile
@@ -180,10 +180,8 @@ $(MESA_GLAPI_DIR)/glapi_sparc.S: gl_SPARC_asm.py $(COMMON)
 
 ######################################################################
 
-$(MESA_DIR)/main/enums.c: gl_enums.py $(COMMON) $(ES_API)
-	$(PYTHON2) $(PYTHON_FLAGS) $< -f gl_API.xml \
-		-f $(MESA_GLAPI_DIR)/gen-es/es1_API.xml \
-		-f $(MESA_GLAPI_DIR)/gen-es/es2_API.xml > $@
+$(MESA_DIR)/main/enums.c: gl_enums.py $(COMMON_ES)
+	$(PYTHON2) $(PYTHON_FLAGS) $< -f gl_and_es_API.xml > $@
 
 $(MESA_DIR)/main/dispatch.h: gl_table.py $(COMMON)
 	$(PYTHON2) $(PYTHON_FLAGS) $< -m remap_table > $@
diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py
index 05979e3..2cbbd97 100644
--- a/src/mapi/glapi/gen/gl_table.py
+++ b/src/mapi/glapi/gen/gl_table.py
@@ -211,28 +211,28 @@ class PrintRemapTable(gl_XML.gl_print_base):
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0]
+	print "Usage: %s [-f input_file_name] [-m mode] [-c ver]" % sys.argv[0]
 	print "    -m mode   Mode can be 'table' or 'remap_table'."
-	print "    -c        Enable compatibility with OpenGL ES."
+	print "    -c ver    Version can be 'es1' or 'es2'."
 	sys.exit(1)
 
 if __name__ == '__main__':
 	file_name = "gl_API.xml"
     
 	try:
-		(args, trail) = getopt.getopt(sys.argv[1:], "f:m:c")
+		(args, trail) = getopt.getopt(sys.argv[1:], "f:m:c:")
 	except Exception,e:
 		show_usage()
 
 	mode = "table"
-	es = False
+	es = None
 	for (arg,val) in args:
 		if arg == "-f":
 			file_name = val
 		elif arg == "-m":
 			mode = val
 		elif arg == "-c":
-			es = True
+			es = val
 
 	if mode == "table":
 		printer = PrintGlTable(es)
@@ -243,4 +243,14 @@ if __name__ == '__main__':
 
 	api = gl_XML.parse_GL_API( file_name )
 
+	if es is not None:
+		import gles_api
+
+		api_map = {
+			'es1': gles_api.es1_api,
+			'es2': gles_api.es2_api,
+		}
+
+		api.filter_functions(api_map[es])
+
 	printer.Print( api )
diff --git a/src/mapi/glapi/gen/remap_helper.py b/src/mapi/glapi/gen/remap_helper.py
index 69b8e5e..367ae24 100644
--- a/src/mapi/glapi/gen/remap_helper.py
+++ b/src/mapi/glapi/gen/remap_helper.py
@@ -197,22 +197,36 @@ class PrintGlRemap(gl_XML.gl_print_base):
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name]" % sys.argv[0]
+	print "Usage: %s [-f input_file_name] [-c ver]" % sys.argv[0]
+	print "    -c ver    Version can be 'es1' or 'es2'."
 	sys.exit(1)
 
 if __name__ == '__main__':
 	file_name = "gl_API.xml"
 
 	try:
-		(args, trail) = getopt.getopt(sys.argv[1:], "f:")
+		(args, trail) = getopt.getopt(sys.argv[1:], "f:c:")
 	except Exception,e:
 		show_usage()
 
+	es = None
 	for (arg,val) in args:
 		if arg == "-f":
 			file_name = val
+		elif arg == "-c":
+			es = val
 
 	api = gl_XML.parse_GL_API( file_name )
 
+	if es is not None:
+		import gles_api
+
+		api_map = {
+			'es1': gles_api.es1_api,
+			'es2': gles_api.es2_api,
+		}
+
+		api.filter_functions(api_map[es])
+
 	printer = PrintGlRemap()
 	printer.Print( api )
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index cbd1662..ac85a3e 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -349,26 +349,26 @@ if env['gles']:
     gles_headers += env.CodeGenerate(
         target = 'es1api/main/dispatch.h',
         script = GLAPI + 'gen/gl_table.py',
-        source = GLAPI + 'gen-es/es1_API.xml',
-        command = python_cmd + ' $SCRIPT -c -m remap_table -f $SOURCE > $TARGET',
+        source = GLAPI + 'gen/gl_and_es_API.xml',
+        command = python_cmd + ' $SCRIPT -c es1 -m remap_table -f $SOURCE > $TARGET',
     )
     gles_headers += env.CodeGenerate(
         target = 'es1api/main/remap_helper.h',
         script = GLAPI + 'gen/remap_helper.py',
-        source = GLAPI + 'gen-es/es1_API.xml',
-        command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET',
+        source = GLAPI + 'gen/gl_and_es_API.xml',
+        command = python_cmd + ' $SCRIPT -c es1 -f $SOURCE > $TARGET',
     )
     gles_headers += env.CodeGenerate(
         target = 'es2api/main/dispatch.h',
         script = GLAPI + 'gen/gl_table.py',
-        source = GLAPI + 'gen-es/es2_API.xml',
-        command = python_cmd + ' $SCRIPT -c -m remap_table -f $SOURCE > $TARGET',
+        source = GLAPI + 'gen/gl_and_es_API.xml',
+        command = python_cmd + ' $SCRIPT -c es2 -m remap_table -f $SOURCE > $TARGET',
     )
     gles_headers += env.CodeGenerate(
         target = 'es2api/main/remap_helper.h',
         script = GLAPI + 'gen/remap_helper.py',
-        source = GLAPI + 'gen-es/es2_API.xml',
-        command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET',
+        source = GLAPI + 'gen/gl_and_es_API.xml',
+        command = python_cmd + ' $SCRIPT -c es2 -f $SOURCE > $TARGET',
     )
 
     env.Depends(gles_sources, gles_headers)
-- 
1.7.5.4



More information about the mesa-dev mailing list