Use spvc API for calls in ShaderModuleD3D12
BUG=dawn:291
Change-Id: I0c467d1d7b213872ec0bc1e3924ab89f7786aeba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14281
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
index 3f841d1..c542586 100644
--- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
+++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
@@ -71,10 +71,7 @@
const std::string ShaderModule::GetHLSLSource(PipelineLayout* layout) {
std::unique_ptr<spirv_cross::CompilerHLSL> compiler_impl;
spirv_cross::CompilerHLSL* compiler;
- if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
- compiler = reinterpret_cast<spirv_cross::CompilerHLSL*>(mSpvcContext.GetCompiler());
- // TODO(rharrison): Check status & have some sort of meaningful error path
- } else {
+ if (!GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
// If these options are changed, the values in DawnSPIRVCrossHLSLFastFuzzer.cpp need to
// be updated.
spirv_cross::CompilerGLSL::Options options_glsl;
@@ -104,14 +101,21 @@
const BindingInfo& bindingInfo = groupBindingInfo[binding];
if (bindingInfo.used) {
uint32_t bindingOffset = bindingOffsets[binding];
- compiler->set_decoration(bindingInfo.id, spv::DecorationBinding, bindingOffset);
+ if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
+ mSpvcContext.SetDecoration(bindingInfo.id, SHADERC_SPVC_DECORATION_BINDING,
+ bindingOffset);
+ // TODO(dawn:301): Check status & have some sort of meaningful error path
+ } else {
+ compiler->set_decoration(bindingInfo.id, spv::DecorationBinding,
+ bindingOffset);
+ }
}
}
}
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
shaderc_spvc::CompilationResult result;
mSpvcContext.CompileShader(&result);
- // TODO(rharrison): Check status & have some sort of meaningful error path
+ // TODO(dawn:301): Check status & have some sort of meaningful error path
return result.GetStringOutput();
} else {
return compiler->compile();