From 9a9b837519953393aa8c76dd4f6df6090fba08c7 Mon Sep 17 00:00:00 2001 From: Frank Henigman Date: Thu, 11 Apr 2019 14:52:55 +0000 Subject: [PATCH] Roll all SPIR-V dependencies together. Function name changed in shaderc. SPIRV-Cross split up into additional files. BUG=chromium:951016 Change-Id: I49abb0a163fefdd61b7d6352e57e2a10f519abd9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6440 Reviewed-by: Frank Henigman Reviewed-by: Corentin Wallez --- DEPS | 10 +++++----- src/dawn_native/ShaderModule.cpp | 5 ++++- src/dawn_native/metal/ShaderModuleMTL.mm | 9 ++++----- src/fuzzers/DawnSPIRVCrossGLSLFastFuzzer.cpp | 2 +- third_party/BUILD.gn | 9 +++++++++ 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/DEPS b/DEPS index 3587202dcf..ebc5bbb66d 100644 --- a/DEPS +++ b/DEPS @@ -50,25 +50,25 @@ deps = { # SPIRV-Cross 'third_party/spirv-cross': { - 'url': '{chromium_git}/external/github.com/KhronosGroup/SPIRV-Cross@a7697446b12666da353bb2bdafa792d988fb268c', + 'url': '{chromium_git}/external/github.com/KhronosGroup/SPIRV-Cross@f07a4e16a60e1d0231dda5d3883550761bd70a47', 'condition': 'dawn_standalone', }, # SPIRV compiler dependencies: SPIRV-Tools, SPIRV-headers, glslang and shaderc 'third_party/SPIRV-Tools': { - 'url': '{chromium_git}/external/github.com/KhronosGroup/SPIRV-Tools@20b2e2b9f599413e6197a7b84ac71216d2ac4ad0', + 'url': '{chromium_git}/external/github.com/KhronosGroup/SPIRV-Tools@12e4a7b649e6fe28683de9fc352200c82948a1f0', 'condition': 'dawn_standalone', }, 'third_party/spirv-headers': { - 'url': '{chromium_git}/external/github.com/KhronosGroup/SPIRV-Headers@79b6681aadcb53c27d1052e5f8a0e82a981dbf2f', + 'url': '{chromium_git}/external/github.com/KhronosGroup/SPIRV-Headers@111a25e4ae45e2b4d7c18415e1d6884712b958c4', 'condition': 'dawn_standalone', }, 'third_party/glslang': { - 'url': '{chromium_git}/external/github.com/KhronosGroup/glslang@0ac199df32687fe17b38cd2d0da64c3742e24fef', + 'url': '{chromium_git}/external/github.com/KhronosGroup/glslang@ef807f4bc543e061f25dbbee6cb64dd5053b2adc', 'condition': 'dawn_standalone', }, 'third_party/shaderc': { - 'url': '{chromium_git}/external/github.com/google/shaderc@634dd3545cbccb9362f16f41b3b75703f290a9fd', + 'url': '{chromium_git}/external/github.com/google/shaderc@ff9ae40e3734a264a56bba02191f5ae18c7e5e03', 'condition': 'dawn_standalone', }, diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp index ad91613375..ca6548d2bc 100644 --- a/src/dawn_native/ShaderModule.cpp +++ b/src/dawn_native/ShaderModule.cpp @@ -22,6 +22,8 @@ #include #include +#include + namespace dawn_native { MaybeError ValidateShaderModuleDescriptor(DeviceBase*, @@ -153,7 +155,8 @@ namespace dawn_native { } // Fill in bindingInfo with the SPIRV bindings - auto ExtractResourcesBinding = [this](const std::vector& resources, + auto ExtractResourcesBinding = [this](const spirv_cross::SmallVector& + resources, const spirv_cross::Compiler& compiler, dawn::BindingType bindingType) { for (const auto& resource : resources) { diff --git a/src/dawn_native/metal/ShaderModuleMTL.mm b/src/dawn_native/metal/ShaderModuleMTL.mm index 2d38d1854f..28cff586a8 100644 --- a/src/dawn_native/metal/ShaderModuleMTL.mm +++ b/src/dawn_native/metal/ShaderModuleMTL.mm @@ -60,8 +60,7 @@ namespace dawn_native { namespace metal { // By default SPIRV-Cross will give MSL resources indices in increasing order. // To make the MSL indices match the indices chosen in the PipelineLayout, we build - // a table of MSLResourceBinding to give to SPIRV-Cross - std::vector mslBindings; + // a table of MSLResourceBinding to give to SPIRV-Cross. // Reserve index 0 for buffers for the push constants buffer. for (auto stage : IterateStages(kAllStages)) { @@ -71,7 +70,7 @@ namespace dawn_native { namespace metal { binding.binding = spirv_cross::kPushConstBinding; binding.msl_buffer = 0; - mslBindings.push_back(binding); + compiler.add_msl_resource_binding(binding); } // Create one resource binding entry per stage per binding. @@ -87,7 +86,7 @@ namespace dawn_native { namespace metal { mslBinding.binding = binding; mslBinding.msl_buffer = mslBinding.msl_texture = mslBinding.msl_sampler = index; - mslBindings.push_back(mslBinding); + compiler.add_msl_resource_binding(mslBinding); } } } @@ -103,7 +102,7 @@ namespace dawn_native { namespace metal { { // SPIRV-Cross also supports re-ordering attributes but it seems to do the correct thing // by default. - std::string msl = compiler.compile(nullptr, &mslBindings); + std::string msl = compiler.compile(); NSString* mslSource = [NSString stringWithFormat:@"%s", msl.c_str()]; auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice(); diff --git a/src/fuzzers/DawnSPIRVCrossGLSLFastFuzzer.cpp b/src/fuzzers/DawnSPIRVCrossGLSLFastFuzzer.cpp index 414f23042e..8322598f27 100644 --- a/src/fuzzers/DawnSPIRVCrossGLSLFastFuzzer.cpp +++ b/src/fuzzers/DawnSPIRVCrossGLSLFastFuzzer.cpp @@ -28,7 +28,7 @@ namespace { DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler, &input]() { // Using the options that are used by Dawn, they appear in ShaderModuleGL.cpp shaderc_spvc::CompileOptions options; - options.SetOutputLanguageVersion(440); + options.SetGLSLLanguageVersion(440); options.SetFixupClipspace(true); compiler.CompileSpvToGlsl(input.data(), input.size(), options); }); diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn index a745ffbe6c..319a3dce64 100644 --- a/third_party/BUILD.gn +++ b/third_party/BUILD.gn @@ -70,6 +70,10 @@ static_library("spirv_cross") { "${spirv_cross_dir}/spirv_common.hpp", "${spirv_cross_dir}/spirv_cross.cpp", "${spirv_cross_dir}/spirv_cross.hpp", + "${spirv_cross_dir}/spirv_cross_parsed_ir.cpp", + "${spirv_cross_dir}/spirv_cross_parsed_ir.hpp", + "${spirv_cross_dir}/spirv_parser.cpp", + "${spirv_cross_dir}/spirv_parser.hpp", ] need_glsl_cross = dawn_enable_opengl @@ -110,12 +114,16 @@ static_library("spirv_cross_full_for_fuzzers") { "${spirv_cross_dir}/spirv_common.hpp", "${spirv_cross_dir}/spirv_cross.cpp", "${spirv_cross_dir}/spirv_cross.hpp", + "${spirv_cross_dir}/spirv_cross_parsed_ir.cpp", + "${spirv_cross_dir}/spirv_cross_parsed_ir.hpp", "${spirv_cross_dir}/spirv_glsl.cpp", "${spirv_cross_dir}/spirv_glsl.hpp", "${spirv_cross_dir}/spirv_hlsl.cpp", "${spirv_cross_dir}/spirv_hlsl.hpp", "${spirv_cross_dir}/spirv_msl.cpp", "${spirv_cross_dir}/spirv_msl.hpp", + "${spirv_cross_dir}/spirv_parser.cpp", + "${spirv_cross_dir}/spirv_parser.hpp", ] } @@ -342,6 +350,7 @@ if (dawn_standalone) { configs += [ "//build/config/compiler:no_chromium_code" ] public_configs = [ ":glm_public_config" ] + # GLM is header only but has too many files to list them. }