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

Querying struct member info #13

Open
drjaydenm opened this issue Feb 25, 2020 · 1 comment
Open

Querying struct member info #13

drjaydenm opened this issue Feb 25, 2020 · 1 comment

Comments

@drjaydenm
Copy link

Hi there,
I was looking at building out a dynamic material binding system for my game, which basically would use the reflection to find the struct members by name and allow the game code to set values to these members using string references - something along the lines of this:

material.SetVector("SunColor", new Vector4(1, 1, 1, 1));

Which in the shader could correspond to something like this

layout(set = 1, binding = 0) uniform SkyboxParameters
{
    vec4 SkyColor;
    vec4 SunColor;
    vec4 HorizonColor;
};

I can get enough information out of the reflection to find the resource sets and bindings, but can't seem to drill down deep enough to find the members of the structs, aka SunColor in this example. Am I just missing something in the existing API, or is this not currently exposed through the Veldrid SPIRV library? It looks to be possible using SPIRV Cross https://github.com/KhronosGroup/SPIRV-Cross/wiki/Reflection-API-user-guide#struct-member-reflection

If it is missing, I would be happy to have a go at adding this functionality if you would consider it for a PR.
Thanks

@mellinoe
Copy link
Collaborator

This is missing, but it’s something I have wanted to add. The reflection info that is currently returned is kind of a minimal viable product — there’s a lot more useful stuff that could be exposed but isn’t at the moment.

Keep in mind that while you might be able to reflect over all of the fields always, I suspect that useful names will only be possible if the module was compiled with debug info to begin with.

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

No branches or pull requests

2 participants