Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort new extensions programmatically #236

Merged

Conversation

bashbaug
Copy link
Contributor

The generated extension headers maintained an ordered list of older extensions to minimize diffs with the non-generated extension headers, but there is no reason to require this for new extensions. If a new extension is not found in the list, sort it at the end automatically. Note, Khronos (KHR) extensions will also be sorted before multi-vendor (EXT) extensions, and before vendor extensions.

The generated extension headers maintained an ordered list of older
extensions to minimize diffs with the non-generated extension headers,
but there is no reason to require this for new extensions.  If a new
extension is not found in the list, sort it at the end automatically.
Note, Khronos (KHR) extensions will also be sorted before multi-vendor
(EXT) extensions, and before vendor extensions.
Copy link
Contributor

@kpet kpet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did wonder about doing this after adding an extension to that list. Maybe we could even reduce or remove the existing list of special cases.

index = orderedExtensions.index(name)
except ValueError:
if name.startswith('cl_khr'):
index = 10000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the behaviour when the same index is returned multiple times? Are definitions for extensions ordered following the order in which they appear in the XML?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to look this up. The sort is stable if they have the same key:
https://docs.python.org/3/howto/sorting.html#sort-stability-and-complex-sorts

However, the sort key is actually a tuple consisting of the index and the name, so the end result should be that the new extensions are ordered after the older manually ordered extensions and alphabetized. This is the order I'd like to see for all extensions eventually - see getExtensionSortKey_ideal below.

@bashbaug
Copy link
Contributor Author

Merging as discussed in the September 12th teleconference.

@bashbaug bashbaug merged commit dd1b340 into KhronosGroup:main Sep 12, 2023
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants