-
Notifications
You must be signed in to change notification settings - Fork 38
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
Output reflection data with resource binding info? #1
Comments
@tgjones Sorry that I didn't respond to this issue. We did chat about this briefly in gitter, and I'm definitely interested in exposing the sort of information that the |
I came here looking for the same thing too. I'd vote this solution as better than the ShaderGen one anyday because this solves the "glue code" problem elegantly. |
After looking into SPIR-V code standard and trying to use the reflection for a project I can contribute to the conversation. Subset of SPIR-V byte codes useful for reflection is quite small. You can use native code to do that but it won't tell you any more useful information. I would recommend to stick with fully managed code for the parser. Each SPIR-V instruction has size embedded into byte code so it's trivial to skip unknown instructions. I bet that the byte code won't change much here with upcoming Vulkan 1.1. So from the code you can get Uniforms and Uniform Constants. Textures and Samplers are passed as Uniform Constants and every thing else I've encountered are Uniforms. For our purpose it doesn't matter and both could be treated the same way. Through OpDecorate command we can learn Set and Binding values for each uniform. This is very useful as we can detect what resources are actually used in what stages of the shader. This becomes critical for Direct3D 11 compatibility as we need to remap the uniforms to registers. As Pipeline includes both Shaders and ResourceLayout we can easily mark sets in the layout using the reflection data. This alone would be a great progress for the library. Through optinal OpName command we can get name of the uniform (it's not that straight forward for uniform buffer with a structure but it's just one hop away in the type info). As this info isn't available we can use an external resolver to get a name by set, binding and kind. All it need is resource layout information. At the same time it can check that set inf binding are valid indices and ResourceKind match the one provided via reflection. Overall it doesn't look like a big change to the API but it could be very useful. |
@gleblebedev I recently added reflection info into the VertexFragmentCompilationResult class. You will now get a The implementation of this doesn't used a managed SPIR-V parser, and just piggy-backs onto the resource scanning that the native cross-compiler already has to do. You could write a managed SPIR-V parser and output the same information that Veldrid.SPIRV does, and use it to fill in the "Reflected" data in a PipelineDescription. |
It looks like you've already implemented the feature so I have nothing to do :) |
Fix libveldrid-spirv.dylib not working on macOS 11
Hello again! I'm just having a little look at this library. Does it already generate some sort of resource reflection data? I saw some code for iterating resources but I'm not sure if that was doing something different.
spirv-cross
has a nice--reflection
flag now. I assume the same thing is available when using the API - would you be interested in having it exposed by this library?The text was updated successfully, but these errors were encountered: