]> git.tdb.fi Git - libs/gl.git/commitdiff
Detect deprecation versions for extensions
authorMikko Rasa <tdb@tdb.fi>
Sat, 5 Nov 2016 23:37:55 +0000 (01:37 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 6 Nov 2016 10:45:55 +0000 (12:45 +0200)
If the core profile is in use, deprecated extensions will be made
unavailable unless the driver explicitly advertises them.  In particular,
MSP_legacy_features is made unavailable so code that tries to access
legacy features with a core profile context will throw an exception.
Additionally no enable/disable calls will be generated for textures, as
they are only used for legacy texture units.

scripts/extgen.py

index 7526b271d39e72b042598a64fb81c82420f40712..e6edd42bf944aad566c811202873282dc730f072 100755 (executable)
@@ -32,6 +32,7 @@ if sys.argv[i].startswith("gl"):
 
 target_ext = sys.argv[i]
 backport_ext = None
+deprecated_version = None
 out_base = None
 ignore_things = []
 if target_ext.endswith(".glext"):
@@ -46,6 +47,9 @@ if target_ext.endswith(".glext"):
                elif parts[0]=="core_version":
                        if parts[1]==target_api:
                                core_version = parts[2]
+               elif parts[0]=="deprecated":
+                       if parts[1]==target_api:
+                               deprecated_version = parts[2]
                elif parts[0]=="secondary":
                        secondary.append(parts[1])
                elif parts[0]=="backport":
@@ -65,6 +69,9 @@ ext_type = target_ext.split('_')[0]
 if core_version:
        core_version = map(int, core_version.split('.'))
 
+if deprecated_version:
+       deprecated_version = map(int, deprecated_version.split('.'))
+
 if not out_base:
        out_base = target_ext.lower()
 
@@ -78,8 +85,10 @@ class Thing:
                self.name = name
                self.kind = kind
                self.version = None
+               self.deprecated_version = None
                self.extension = None
                self.supported_apis = {}
+               self.deprecated = {}
                self.aliases = []
                self.sources = []
 
@@ -193,8 +202,11 @@ def parse_feature(feat):
 
                        for t in itertools.chain(commands, enums):
                                name = t.getAttribute("name")
-                               if profile!="core" and name in things:
-                                       del things[name]
+                               if name in things:
+                                       if profile!="core":
+                                               del things[name]
+                                       else:
+                                               things[name].deprecated.setdefault(api, version)
 
 def parse_extension(ext):
        ext_name = ext.getAttribute("name")
@@ -326,6 +338,7 @@ enums.sort(key=(lambda e: e.value))
 
 # Some final preparations for creating the files
 core_version_candidates = {}
+min_deprecated_version = [999, 0]
 backport_ext_candidates = []
 for t in itertools.chain(funcs, enums):
        if target_api in t.supported_apis and t.supported_apis[target_api]!="ext":
@@ -334,6 +347,12 @@ for t in itertools.chain(funcs, enums):
                        ver_tuple = tuple(t.version)
                        core_version_candidates[ver_tuple] = core_version_candidates.get(ver_tuple, 0)+1
 
+       if target_api in t.deprecated:
+               t.deprecated_version = t.deprecated[target_api]
+               min_deprecated_version = min(min_deprecated_version, t.deprecated_version)
+       else:
+               min_deprecated_version = None
+
        # Things in backport extensions don't acquire an extension suffix
        if t.extension and not t.name.endswith(ext_type) and target_api in t.supported_apis:
                if t.extension not in backport_ext_candidates:
@@ -349,6 +368,9 @@ if not core_version and core_version_candidates:
                        print "Warning: multiple likely core version candidates: %d.%d %d.%d"%(ver0[0], ver0[1], ver1[0], ver1[1])
        core_version = core_version_candidates[0][1]
 
+if not deprecated_version:
+       deprecated_version = min_deprecated_version
+
 if backport_ext:
        if backport_ext=="none":
                backport_ext = None
@@ -495,7 +517,14 @@ for f in funcs:
 
 out.write("\nExtension::SupportLevel init_%s()\n{\n"%target_ext.name.lower())
 if core_version:
-       out.write("\tif(is_version_at_least(%d, %d)"%tuple(core_version))
+       out.write("\tif(")
+       if deprecated_version and backport_ext:
+               out.write("(")
+       out.write("is_version_at_least(%d, %d)"%tuple(core_version))
+       if deprecated_version:
+               out.write(" && (get_gl_profile()!=CORE_PROFILE || !is_version_at_least(%d, %d))"%tuple(deprecated_version))
+               if backport_ext:
+                       out.write(")")
        if backport_ext:
                out.write(" || is_supported(\"GL_%s\")"%backport_ext.name)
        out.write(")\n\t{\n")