summaryrefslogtreecommitdiff
path: root/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp')
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp37
1 files changed, 24 insertions, 13 deletions
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp
index 96e31270d5d..60c6ba6e19a 100644
--- a/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp
@@ -40,31 +40,42 @@ namespace dawn_native { namespace vulkan {
// Use SPIRV-Cross to extract info from the SPIRV even if Vulkan consumes SPIRV. We want to
// have a translation step eventually anyway.
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
- shaderc_spvc::CompileOptions options;
- shaderc_spvc_status status =
- mSpvcContext.InitializeForGlsl(descriptor->code, descriptor->codeSize, options);
- if (status != shaderc_spvc_status_success) {
- return DAWN_VALIDATION_ERROR("Unable to initialize instance of spvc");
- }
+ shaderc_spvc::CompileOptions options = GetCompileOptions();
- spirv_cross::Compiler* compiler =
- reinterpret_cast<spirv_cross::Compiler*>(mSpvcContext.GetCompiler());
- ExtractSpirvInfo(*compiler);
+ DAWN_TRY(CheckSpvcSuccess(
+ mSpvcContext.InitializeForVulkan(descriptor->code, descriptor->codeSize, options),
+ "Unable to initialize instance of spvc"));
+
+ spirv_cross::Compiler* compiler;
+ DAWN_TRY(CheckSpvcSuccess(mSpvcContext.GetCompiler(reinterpret_cast<void**>(&compiler)),
+ "Unable to get cross compiler"));
+ DAWN_TRY(ExtractSpirvInfo(*compiler));
} else {
spirv_cross::Compiler compiler(descriptor->code, descriptor->codeSize);
- ExtractSpirvInfo(compiler);
+ DAWN_TRY(ExtractSpirvInfo(compiler));
}
VkShaderModuleCreateInfo createInfo;
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<uint32_t> 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(
- device->fn.CreateShaderModule(device->GetVkDevice(), &createInfo, nullptr, &mHandle),
+ device->fn.CreateShaderModule(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreateShaderModule");
}