Using code generator from the OpenXR Source SDK


I am trying to use the AutomaticSourceOutputGenerator Python class from the SDK to write a script that generates code for an API layer.

I am able to write a generator that works great for core spec (I can specify a list of functions from the core spec and get code generated for them). However, I am unable to get this to work for core extensions (eg: xrGetVisibilityMaskKHR()).

My generator is here:

OpenXR-Toolkit/ at main · mbucchia/OpenXR-Toolkit (

I noticed that there are two class members, core_commands and ext_commands. However, even looking at the ext_commands dictionary, I am not able to see functions from extensions.

Down to the call to apiGen(), I don’t understand all the parameters of AutomaticSourceGeneratorOptions: what is the difference between addExtensions and emitExtensions for example? What is defaultExtensions?

I’m pretty sure it’s down to this apiGen call that I am missing something, but I just can’t figure out what it is…

    conventions = OpenXRConventions()
    featuresPat = "XR_VERSION_1_0"

            conventions       = conventions,
            filename          = 'dispatch.gen.cpp',
            directory         = cur_dir,
            apiname           = 'openxr',
            profile           = None,
            versions          = featuresPat,
            emitversions      = featuresPat,
            defaultExtensions = 'openxr',
            addExtensions     = None,
            removeExtensions  = None,
            emitExtensions    = None))

I tried setting emitExtensions to makeREstring('.*') like it is done in, but that did not make any difference.

Any help appreciated. Thanks!

CC @rpavlik.

I haven’t had a chance to dig through your code, but you might find the OpenXR-HPP generator, which also uses those scripts, to be helpful: OpenXR-Hpp/ at main · KhronosGroup/OpenXR-Hpp · GitHub It actually uses a different set of extensions depending on the file it’s generating (some extensions are fine for lower level wrappers but not higher level), and it does do that properly.

Following up: I was able to get it to work. All I was missing was to look into the ext_commands dictionary in addition to the core_commands dictionary.

Fixed code generator to properly include OpenXR extensions stubs. · mbucchia/Pimax-OpenXR@84c4224 (

Thanks for pointing me to the Hpp generator.

1 Like

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.