Expose internals for library consumption
Opened this issue · 2 comments
I am currently working on a library which uses naga_oil to generate bindings of shaders utilizing naga oil's features. The library statically generates rust bindings given the shader entry points.
There are few things which would have been nicer if naga_oil exposed
for consumption.
- Path parsing basically given a shader content, figure out what are the imports of the file. At the moment, it is a semi handwritten + uses
parse_imports
from naga to parse further. - Demangle functions. Basically had to reduplicate the logic to figure out the original import path, so I can generate the equivalent bindings preserving the heirarchy.
for path parsing, i'm not sure i understood exactly what you're asking for, but just want to make sure you're aware of the static get_preprocessor_data function which tells you the required imports (file names and items within them) for a given shader string.
demangle functions: we can certainly make Composer::decorate
and Composer::undecorate
pub, is that all you need?
Thank you, I wasn't aware of get_preprocessor_data
. It does appear to be exactly what I want.
Only caveat being that if imports are unused, it doesn't show up at all. Would be nicer if there was a flag to toggle it. (I'd like to generate bindings for all imports and simply replace the entry point especially for testing shaders).
Is there a way to simply generate all unused structs optionally including bindings?
Yeah and exposing those 2 functions will suffice my need.