diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 5ac19bb5..f5fa1c36 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -89,6 +89,15 @@ VkResult VulkanExampleBase::createInstance() } } + // Shaders generated by Slang require a certain SPIR-V environment that can't be satisfied by Vulkan 1.0, so we need to expliclity up that to at least 1.1 and enable some required extensions + if (shaderDir == "slang") { + if (apiVersion < VK_API_VERSION_1_1) { + apiVersion = VK_API_VERSION_1_1; + } + enabledDeviceExtensions.push_back(VK_KHR_SPIRV_1_4_EXTENSION_NAME); + enabledDeviceExtensions.push_back(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME); + } + VkApplicationInfo appInfo{}; appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; appInfo.pApplicationName = name.c_str(); diff --git a/shaders/README.md b/shaders/README.md index e8b75831..4ddffc4a 100644 --- a/shaders/README.md +++ b/shaders/README.md @@ -2,4 +2,6 @@ This folder contains the shaders used by the samples. Source files are available in GLSL, HLSL and [slang](https://shader-slang.org/) and also come with precompiled SPIR-V files that are consumed by the samples. To recompile shaders you can use the `compileshaders.py` scripts in the respective folders or any other means that can generate Vulkan SPIR-V from GLSL, HLSL or slang. One such option is [this extension for Visual Studio](https://github.com/SaschaWillems/SPIRV-VSExtension). -Note that not all samples may come with all shading language variants. So some samples that have GLSL source files might not come with HLSL and/or slang source files. \ No newline at end of file +Note that not all samples may come with all shading language variants. So some samples that have GLSL source files might not come with HLSL and/or slang source files. + +A note for using **slang** shaders: These require a different SPIR-V environment than glsl/hlsl. When selecting slang shaders, the base requirement for all samples is raised to at least Vulkan 1.1 with the SPIRV 1.4 extension. \ No newline at end of file