-
Notifications
You must be signed in to change notification settings - Fork 33
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
use spirv-cross for generate some shader related vkCreateInfo in Vulkan.Util? #260
Comments
It's definitely worth investigating what information can be extracted from a shader or shader pipeline which would allow for automation of Vulkan operations (such as creation of a graphics pipeline and binding of appropriate resources). Given that Vulkan is based on You might be interested in the approach I took here for handling descriptor sets. You specify a bunch of different descriptors and it will go ahead and figure out everything it needs to handle
See for instance this example in which I declare the kind of descriptor sets I want, and then later on the shader stage flags and the data to use for initialisation. The functions from |
@sheaf FIR seems directly generate spirv code from AST, why there is a example/CreateDirs which helps to compile shader to a spv file. This weird me a bit. I thought it could use a temporary directory for storage spv file or directly pass spv code to vulkan api. Or maybe this is just for better generated spirv debug experience? Thy way FIR use to write shader is a |
The data directory thing is just a way of writing the shader files to disk in a portable way. I'm using it to implement live shader reloading (by watching the files change on disk), and it's also useful to have the I wrote the |
Thanks! In general this kind of stuff seems like a really good fit for
This is certainly true, but as long as there's some "escape hatch" then covering the simple cases is very handy. Whatever ends up in utils would have to have some good documentation and an example due to the trickyness of this in vulkan. |
There can be a package that has only the base types for SPIR-V derived data (and maybe code generation build-tools). Shader-producing packages (vulkan-utils, FIR, shader libraries) then can provide types and values to shader-consuming packages (vulkan examples, frameworks and projects) with compile-time compatibility checks. There is jQuery on hackage, why not bloom postprocessing code? Same energy: https://github.com/embarkstudios/rust-gpu#why-embark |
@dpwiz What is a SPIR-V derived data? Does it means types for the json of spirv-cross reflection? |
Yes, the reflection data. |
Is anyone works on this? I am not sure how to contribute it due to the example I wrote only support the few part of reflection data now. Should I put the WIP stuff into Vulkan.Utils module though the feature is still weak? Or just put it into the examples? |
I'd suggest sending a PR with the code packaged as |
note The api in current example makeDescriptorInfo :: Vector (Shader, Reflection) -> Vector (DescriptorSetLayoutCreateInfo '[])
-- ^ not rely `vulkan` ^ rely on `vulkan`
-- ^ not rely `vulkan` And in this data DescriptorSetLayout = ...
-- ^ not rely `vulkan`
makeDescriptorInfo :: Vector (Shader, Reflection) -> (DescriptorSetLayout -> a) -> Vector a
-- ^ not rely `vulkan`
-- ^ not rely `vulkan` |
@dpwiz I noticed that |
I imagine some CLI or web tool that can be used to inspect shader binaries and maybe generate code. They may not need to actually instantiate Vulkan data or use any But things like "just give me an appropriate CreateInfo" can be a great addition to |
I make a vulkan-reflect branch locally https://github.com/ukari/vulkan/tree/vulkan-reflect some stuffs might need to be done
|
You can start a PR so we can post comments attached to actual code. I may be wrong, but it seems you decode from Aeson's data EntryPoint = EntryPoint
{ name :: Text
, mode :: ShaderStage
} deriving (Show, Generic, FromJSON, ToJSON) |
BTW, there are now 2 packages to query
I haven't tried to generate haskell types, but it contains a bit more information about types and their layouts. |
I write a example https://gist.github.com/ukari/6b9d94b04c3c26ff63ffd4663914c7da
and inlined some examples which could easily run by excute
test2
(formakeShaderInfo
),test3
(formakeDescriptorInfo
),test4
(formakeInputInfo
)now this only support single binding for input vertex, which let all input vertex attribute have a default binding = 0.
maybe can provide a binding map parameter to specify individual binding by name, like
foo [(1, ["inPos", "inColor"]) (2, ["texCoord"])]
speficies that(binding = 1) inPos, (binding = 1) inColor, (binding = 2) texCoord
here is some related references:
SaschaWillems - Multiple Vulkan buffer binding points
island pipeline
The text was updated successfully, but these errors were encountered: