Skip to content

Parse constant definitions from Khronos registry and fixes wrong binding of array types #7

Open
Ybalrid wants to merge 4 commits intoEvergineTeam:mainfrom
Ybalrid:yba/XrUuid
Open

Parse constant definitions from Khronos registry and fixes wrong binding of array types #7
Ybalrid wants to merge 4 commits intoEvergineTeam:mainfrom
Ybalrid:yba/XrUuid

Conversation

@Ybalrid
Copy link

@Ybalrid Ybalrid commented Feb 27, 2026

This parses the defines in the registry, and add them as numerical constants if possible.

This also fixes the generation of struct members that are array of which the size is defined by such numerical constants.

This was mostly done to fix #6, which is a specific blocker for one of my projects.

I do not know what is the policy to update the generated bindings that are committed within the repository itself. Thus this is a separate commit, in case you did not want that.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the incorrect generation of struct members that are fixed-size arrays sized by symbolic constants (specifically #define-based constants in the Khronos registry), which caused XrUuid.data to be generated as a single byte instead of a byte[16]. It also includes updated generated bindings for new OpenXR extensions (Android face tracking, BD facial simulation).

Changes:

  • Extends StructureDefinition.cs to recognize symbolic constant names (not just literal integers) in array bracket notation (e.g., name[SYMBOL]) and stores them in ConstantValue for later resolution.
  • Adds a Defines dictionary to OpenXRSpecification populated from #define-category types in the XML, and a TryParseDefineIntValue helper in Program.cs to resolve their values; struct generation now falls back through validConstantenumCountdefineCount with a proper error throw.
  • Regenerates the committed binding files (Structs.cs, Handles.cs, Enums.cs, Constants.cs, Commands.cs) to fix the XrUuid/XrApiLayerCreateInfo bugs and include new extension types.

Reviewed changes

Copilot reviewed 3 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
OpenXRGen/OpenXRGen/StructureDefinition.cs Regex updated to match symbolic constant array indices; new logic routes them to ConstantValue
OpenXRGen/OpenXRGen/OpenXRSpecification.cs Adds Defines dictionary populated from #define XML types
OpenXRGen/OpenXRGen/Program.cs Adds TryParseDefineIntValue helper; struct generation extended with define-based constant resolution and proper error on failure; trailing blank lines added
OpenXRGen/Evergine.Bindings.OpenXR/Generated/Structs.cs Fixes XrUuid.data, XrApiLayerCreateInfo.settings_file_location, XrEyeGazesFB.gaze; adds new extension structs
OpenXRGen/Evergine.Bindings.OpenXR/Generated/Handles.cs Adds XrFaceTrackerANDROID and XrFaceTrackerBD handle types
OpenXRGen/Evergine.Bindings.OpenXR/Generated/Enums.cs Adds new enum types and values for ANDROID and BD face tracking extensions
OpenXRGen/Evergine.Bindings.OpenXR/Generated/Constants.cs Updates spec version constants, adds XR_FACE_PARAMETER_COUNT_ANDROID and related new extension constants
OpenXRGen/Evergine.Bindings.OpenXR/Generated/Commands.cs Adds function pointer declarations and load calls for new ANDROID/BD face tracking commands

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +104 to 116
if (firstIsNumeric && !secondIsPresent)
{
m.ElementCount = value1;
}
else if (firstIsNumeric && secondIsNumeric)
{
string valueString1 = match.Groups[1].Value;
string valueString2 = match.Groups[3].Value;
m.ElementCount = int.Parse(valueString1) * int.Parse(valueString2);
m.ElementCount = value1 * value2;
}
else
else if (!secondIsPresent)
{
string valueString = match.Groups[1].Value;
m.ElementCount = int.Parse(valueString);
// Handles array declarations using symbolic constants in member text.
m.ConstantValue = count1;
}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The new code handles four conditions for 2D array dimensions (numeric×numeric, numeric×missing, missing×missing), but the case where the first dimension is numeric and the second dimension is a symbolic constant (e.g., name[3][SYMBOL]) is not handled. Both ElementCount and ConstantValue will remain at their default values (0 and null), meaning the member will be silently treated as a scalar field. While this case may not exist in the current OpenXR spec, it is a latent logic gap that was not present in the original code (which only handled [numeric] or [numeric][numeric] patterns). It would be safer to throw or log a warning for this unrecognized combination so it doesn't silently produce incorrect output in the future.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

Will double check this soon

Ybalrid and others added 2 commits March 4, 2026 01:29
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

XrUuid wrapping is wrong, and only store the first byte of the 128 bit number

2 participants