diff --git a/src/dawn_native/vulkan/ShaderModuleVk.cpp b/src/dawn_native/vulkan/ShaderModuleVk.cpp index e756852a9e..140abba098 100644 --- a/src/dawn_native/vulkan/ShaderModuleVk.cpp +++ b/src/dawn_native/vulkan/ShaderModuleVk.cpp @@ -42,7 +42,7 @@ namespace dawn_native { namespace vulkan { if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) { shaderc_spvc::CompileOptions options; DAWN_TRY(CheckSpvcSuccess( - mSpvcContext.InitializeForGlsl(descriptor->code, descriptor->codeSize, options), + mSpvcContext.InitializeForVulkan(descriptor->code, descriptor->codeSize, options), "Unable to initialize instance of spvc")); spirv_cross::Compiler* compiler; @@ -58,8 +58,19 @@ namespace dawn_native { namespace vulkan { createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; createInfo.pNext = nullptr; createInfo.flags = 0; - createInfo.codeSize = descriptor->codeSize * sizeof(uint32_t); - createInfo.pCode = descriptor->code; + std::vector vulkanSource; + if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) { + shaderc_spvc::CompilationResult result; + DAWN_TRY(CheckSpvcSuccess(mSpvcContext.CompileShader(&result), + "Unable to generate Vulkan shader")); + DAWN_TRY(CheckSpvcSuccess(result.GetBinaryOutput(&vulkanSource), + "Unable to get binary output of Vulkan shader")); + createInfo.codeSize = vulkanSource.size() * sizeof(uint32_t); + createInfo.pCode = vulkanSource.data(); + } else { + createInfo.codeSize = descriptor->codeSize * sizeof(uint32_t); + createInfo.pCode = descriptor->code; + } Device* device = ToBackend(GetDevice()); return CheckVkSuccess(