From 1d036f776698b607763aa025d4bce5df5c867ac1 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 24 Jan 2020 16:16:59 +0000 Subject: [PATCH] Removing deprecated spvc API usages Roll third_party/shaderc/ c6a2ef12d..a4f9acedf (5 commits) https://chromium.googlesource.com/external/github.com/google/shaderc/+log/c6a2ef12dffc..a4f9acedf3c0 $ git log c6a2ef12d..a4f9acedf --date=short --no-merges --format='%ad %ae %s' 2020-01-23 rharrison Big cleanup to normalize API behaviour (#967) 2020-01-22 rharrison Start v2020.0 (#970) 2020-01-22 rharrison Fix the version string (#971) 2020-01-22 rharrison Finalize v2019.1 (#969) 2020-01-20 rharrison Rolling 3 dependencies and updating expectations (#966) Created with: roll-dep third_party/shaderc BUG=dawn:324 Change-Id: I3c3900dcccc317054f035e21a6863f068ce417c9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15421 Commit-Queue: Ryan Harrison Reviewed-by: Corentin Wallez --- DEPS | 2 +- src/dawn_native/d3d12/ShaderModuleD3D12.cpp | 10 ++++++---- src/dawn_native/metal/ShaderModuleMTL.mm | 16 ++++++++++------ src/dawn_native/null/DeviceNull.cpp | 7 +++++-- src/dawn_native/opengl/ShaderModuleGL.cpp | 8 +++++--- src/dawn_native/vulkan/ShaderModuleVk.cpp | 5 +++-- 6 files changed, 30 insertions(+), 18 deletions(-) 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);