GameFoundry / bsf

Modern C++14 library for the development of real-time graphical applications
https://www.bsframework.io
MIT License
1.75k stars 195 forks source link

[Vulkan] Using precompiled SPIR-V (1.3) instead of sources? #131

Open unit-404 opened 6 years ago

unit-404 commented 6 years ago

I want ask about direct support of precompiled (i.e. from .spv files) SPIR-V for Vulkan API 1.1, and probably, support SPIRV-Cross for compilation to other API (HLSL, GLSL, "VKSL").

BearishSun commented 6 years ago

Adding direct support for SPIR-V shouldn't be too difficult. Design wise it is just a matter of registering a new GpuProgramFactory, similar to the current VulkanGLSLProgramFactory. Do you have a specific use-case for this feature or is it just a general request?

I'm wondering what would be the purpose of integrating SPIRV-Cross? If its used for just pure translation purposes, then it should be easy enough for developers to include it in their project on a case-by-case basis rather than integrating it. Or would it be used similarly to the current BSL and used for generating high-level Shader that works on all platforms? But in that case we are lacking a lot of information to generate a complete Shader. Plus if you are doing that you lose the (only?) benefit of using SPIRV directly, which is the ability to fully optimize and tweak the code - so you might just want to use a higher level language straight away.

unit-404 commented 6 years ago

SPIRV-Cross idea suggested for backward compatibility with other API (if possible), in my use case SPIR-V I could to use in Vulkan API 1.1 backend only.

Fishrock123 commented 5 years ago

Isn't the use case here to avoid doing shader source compiles at runtime and to instead just turn it all into SPIR-V at build time?

BearishSun commented 5 years ago

SPIR-V is cached at build/import time under the current system.