Skip to content

Commit

Permalink
glad: fixes alias extension resolution
Browse files Browse the repository at this point in the history
we cannot limit the result set of `get_requirements` to
the list of already existing commands from the feature set,
this way we will not get any new commands to resolve aliases
for -> there wont be any new aliases

closes: Dav1dde#334
  • Loading branch information
Dav1dde committed Jul 19, 2021
1 parent 4532065 commit cab4e15
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions glad/generator/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ def find_extensions_with_aliases(spec, api, version, profile, extensions):
"""
feature_set = spec.select(api, version, profile, extensions)

command_names = [command.name for command in feature_set.commands]
command_names = set(command.name for command in feature_set.commands)

new_extensions = set()
for extension in spec.extensions[api].values():
if extension in feature_set.extensions:
continue

for command in extension.get_requirements(spec, api, profile, feature_set=feature_set).commands:
for command in extension.get_requirements(spec, api, profile).commands:
# find all extensions which have an alias to a selected function
if command.alias and command.alias in command_names:
new_extensions.add(extension.name)
Expand Down
14 changes: 14 additions & 0 deletions test/c/compile/gl/alias/007/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* GL 4.6 No extensions, with aliasing
*
* GLAD: $GLAD --out-path=$tmp --api="gl:core=4.6" --extensions="" c --alias
* COMPILE: $GCC $test -o $tmp/test -I$tmp/include $tmp/src/gl.c -ldl
* RUN: $tmp/test
*/

#include <glad/gl.h>

int main(void) {
(void) glActiveTextureARB;
return 0;
}
16 changes: 16 additions & 0 deletions test/c/compile/gles2/alias/001/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* GLES2 No extensions, with aliasing
*
* Issue: https://github.com/Dav1dde/glad/issues/334
*
* GLAD: $GLAD --out-path=$tmp --api="gles2=3.2" --extensions="" c --alias
* COMPILE: $GCC $test -o $tmp/test -I$tmp/include $tmp/src/gles2.c -ldl
* RUN: $tmp/test
*/

#include <glad/gles2.h>

int main(void) {
(void) glGenVertexArraysOES;
return 0;
}

0 comments on commit cab4e15

Please sign in to comment.