vulkano-rs / vulkano

Safe and rich Rust wrapper around the Vulkan API
Apache License 2.0
4.45k stars 435 forks source link

SPIR-V shader module validation #1428

Open KeyboardDanni opened 3 years ago

KeyboardDanni commented 3 years ago

Use case scenario: Imagine a game or other virtual space where users can create and share user content in the form of maps or character models, etc. This content might include custom shaders to enhance its appearance.

Currently all the functions in vulkano::pipeline::shader::ShaderModule are marked unsafe because they do not do any validation of the incoming SPIR-V shader data. Thus it's possible that a dangerous shader might be automatically downloaded and then loaded by the renderer.

It'd be nice if we had some sort of add-on library that could validate the shaders coming in. Perhaps it could wrap the unsafe functions in ShaderModule inside safe functions that perform the validation.

AustinJ235 commented 3 years ago

I personally think this falls outside the realm of vulkano. This seems like some another crate should handle. In this view I think it'd be better to use some standard form of attachment layouts and such and just have the user created content use glsl. There it could be validated and go through the normal shader processes of vulkano.

Rua commented 2 years ago

Vulkano doesn't do full validation of shaders yet, but it does make it easier to load them at runtime now.