diff --git a/DEPS b/DEPS index 61b97218e7..9387d500e6 100644 --- a/DEPS +++ b/DEPS @@ -69,7 +69,7 @@ deps = { 'condition': 'dawn_standalone', }, 'third_party/shaderc': { - 'url': '{chromium_git}/external/github.com/google/shaderc@c6a2ef12dffcd0c13f4d8c90b1a2f23ccda7931a', + 'url': '{chromium_git}/external/github.com/google/shaderc@a4f9acedf3c042537db8b28065728df484ca5663', 'condition': 'dawn_standalone', }, diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp index 1049ed902a..f6fefff819 100644 --- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp @@ -56,8 +56,9 @@ namespace dawn_native { namespace d3d12 { mSpvcContext.InitializeForHlsl(descriptor->code, descriptor->codeSize, options), "Unable to initialize instance of spvc")); - spirv_cross::Compiler* compiler = - reinterpret_cast(mSpvcContext.GetCompiler()); + spirv_cross::Compiler* compiler; + DAWN_TRY(CheckSpvcSuccess(mSpvcContext.GetCompiler(reinterpret_cast(&compiler)), + "Unable to get cross compiler")); DAWN_TRY(ExtractSpirvInfo(*compiler)); } else { spirv_cross::CompilerHLSL compiler(descriptor->code, descriptor->codeSize); @@ -116,8 +117,9 @@ namespace dawn_native { namespace d3d12 { shaderc_spvc::CompilationResult result; DAWN_TRY(CheckSpvcSuccess(mSpvcContext.CompileShader(&result), "Unable to generate HLSL shader w/ spvc")); - std::string result_string = - result.GetStringOutput(); // Stripping const for ResultOrError + std::string result_string; + DAWN_TRY(CheckSpvcSuccess(result.GetStringOutput(&result_string), + "Unable to get HLSL shader text")); return result_string; } else { return compiler->compile(); diff --git a/src/dawn_native/metal/ShaderModuleMTL.mm b/src/dawn_native/metal/ShaderModuleMTL.mm index d817321626..679ea021e6 100644 --- a/src/dawn_native/metal/ShaderModuleMTL.mm +++ b/src/dawn_native/metal/ShaderModuleMTL.mm @@ -95,8 +95,9 @@ namespace dawn_native { namespace metal { GetMSLCompileOptions()), "Unable to initialize instance of spvc")); - spirv_cross::CompilerMSL* compiler = - reinterpret_cast(mSpvcContext.GetCompiler()); + spirv_cross::CompilerMSL* compiler; + DAWN_TRY(CheckSpvcSuccess(mSpvcContext.GetCompiler(reinterpret_cast(&compiler)), + "Unable to get cross compiler")); DAWN_TRY(ExtractSpirvInfo(*compiler)); } else { spirv_cross::CompilerMSL compiler(mSpirv); @@ -119,7 +120,8 @@ namespace dawn_native { namespace metal { DAWN_TRY(CheckSpvcSuccess( mSpvcContext.InitializeForMsl(mSpirv.data(), mSpirv.size(), GetMSLCompileOptions()), "Unable to initialize instance of spvc")); - compiler = reinterpret_cast(mSpvcContext.GetCompiler()); + DAWN_TRY(CheckSpvcSuccess(mSpvcContext.GetCompiler(reinterpret_cast(&compiler)), + "Unable to get cross compiler")); } else { // If these options are changed, the values in DawnSPIRVCrossMSLFastFuzzer.cpp need to // be updated. @@ -196,9 +198,11 @@ namespace dawn_native { namespace metal { if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) { shaderc_spvc::CompilationResult result; DAWN_TRY(CheckSpvcSuccess(mSpvcContext.CompileShader(&result), - "Unable to compile shader")); - - mslSource = [NSString stringWithFormat:@"%s", result.GetStringOutput().c_str()]; + "Unable to compile MSL shader")); + std::string result_str; + DAWN_TRY(CheckSpvcSuccess(result.GetStringOutput(&result_str), + "Unable to get MSL shader text")); + mslSource = [NSString stringWithFormat:@"%s", result_str.c_str()]; } else { std::string msl = compiler->compile(); mslSource = [NSString stringWithFormat:@"%s", msl.c_str()]; diff --git a/src/dawn_native/null/DeviceNull.cpp b/src/dawn_native/null/DeviceNull.cpp index 9d8dd0b77c..579aec1939 100644 --- a/src/dawn_native/null/DeviceNull.cpp +++ b/src/dawn_native/null/DeviceNull.cpp @@ -137,8 +137,11 @@ namespace dawn_native { namespace null { return DAWN_VALIDATION_ERROR("Unable to initialize instance of spvc"); } - spirv_cross::Compiler* compiler = - reinterpret_cast(context.GetCompiler()); + spirv_cross::Compiler* compiler; + status = context.GetCompiler(reinterpret_cast(&compiler)); + if (status != shaderc_spvc_status_success) { + return DAWN_VALIDATION_ERROR("Unable to get cross compiler"); + } DAWN_TRY(module->ExtractSpirvInfo(*compiler)); } else { spirv_cross::Compiler compiler(descriptor->code, descriptor->codeSize); diff --git a/src/dawn_native/opengl/ShaderModuleGL.cpp b/src/dawn_native/opengl/ShaderModuleGL.cpp index f8cde6d979..ac2f52269f 100644 --- a/src/dawn_native/opengl/ShaderModuleGL.cpp +++ b/src/dawn_native/opengl/ShaderModuleGL.cpp @@ -94,7 +94,8 @@ namespace dawn_native { namespace opengl { DAWN_TRY(CheckSpvcSuccess( mSpvcContext.InitializeForGlsl(descriptor->code, descriptor->codeSize, options), "Unable to initialize instance of spvc")); - compiler = reinterpret_cast(mSpvcContext.GetCompiler()); + DAWN_TRY(CheckSpvcSuccess(mSpvcContext.GetCompiler(reinterpret_cast(&compiler)), + "Unable to get cross compiler")); } else { // If these options are changed, the values in DawnSPIRVCrossGLSLFastFuzzer.cpp need to // be updated. @@ -192,8 +193,9 @@ namespace dawn_native { namespace opengl { if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) { shaderc_spvc::CompilationResult result; DAWN_TRY(CheckSpvcSuccess(mSpvcContext.CompileShader(&result), - "Unable to compile shader using spvc")); - mGlslSource = result.GetStringOutput(); + "Unable to compile GLSL shader using spvc")); + DAWN_TRY(CheckSpvcSuccess(result.GetStringOutput(&mGlslSource), + "Unable to get GLSL shader text")); } else { mGlslSource = compiler->compile(); } diff --git a/src/dawn_native/vulkan/ShaderModuleVk.cpp b/src/dawn_native/vulkan/ShaderModuleVk.cpp index 8c94f702ea..e756852a9e 100644 --- a/src/dawn_native/vulkan/ShaderModuleVk.cpp +++ b/src/dawn_native/vulkan/ShaderModuleVk.cpp @@ -45,8 +45,9 @@ namespace dawn_native { namespace vulkan { mSpvcContext.InitializeForGlsl(descriptor->code, descriptor->codeSize, options), "Unable to initialize instance of spvc")); - spirv_cross::Compiler* compiler = - reinterpret_cast(mSpvcContext.GetCompiler()); + spirv_cross::Compiler* compiler; + DAWN_TRY(CheckSpvcSuccess(mSpvcContext.GetCompiler(reinterpret_cast(&compiler)), + "Unable to get cross compiler")); DAWN_TRY(ExtractSpirvInfo(*compiler)); } else { spirv_cross::Compiler compiler(descriptor->code, descriptor->codeSize);