diff --git a/.gitmodules b/.gitmodules index 20d3720e48..55f2c0c990 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,7 +18,7 @@ url = https://github.com/KhronosGroup/SPIRV-Headers.git [submodule "external/spirv-cross"] path = third_party/spirv-cross - url = https://github.com/Kangz/SPIRV-Cross.git + url = https://github.com/KhronosGroup/SPIRV-Cross.git [submodule "external/stb"] path = third_party/stb url = https://github.com/nothings/stb.git diff --git a/DEPS b/DEPS index 7c0da945ba..0a4ad1ad50 100644 --- a/DEPS +++ b/DEPS @@ -43,7 +43,7 @@ deps = { # SPIRV-Cross '{dawn_root}/third_party/spirv-cross': { - 'url': '{github_git}/Kangz/SPIRV-Cross.git@694cad533296df02b4562f4a5a20cba1d1a9dbaf', + 'url': '{github_git}/KhronosGroup/SPIRV-Cross.git@a7697446b12666da353bb2bdafa792d988fb268c', 'condition': 'dawn_standalone', }, diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp index 457bafe9e3..f7f7a24a6e 100644 --- a/src/dawn_native/ShaderModule.cpp +++ b/src/dawn_native/ShaderModule.cpp @@ -71,8 +71,9 @@ namespace dawn_native { ASSERT(blockType.basetype == spirv_cross::SPIRType::Struct); for (uint32_t i = 0; i < blockType.member_types.size(); i++) { - ASSERT(compiler.get_member_decoration_mask(blockType.self, i) & - 1ull << spv::DecorationOffset); + ASSERT(compiler.get_member_decoration_bitset(blockType.self, i) + .get(spv::DecorationOffset)); + uint32_t offset = compiler.get_member_decoration(blockType.self, i, spv::DecorationOffset); ASSERT(offset % 4 == 0); @@ -114,12 +115,11 @@ namespace dawn_native { auto ExtractResourcesBinding = [this](const std::vector& resources, const spirv_cross::Compiler& compiler, dawn::BindingType bindingType) { - constexpr uint64_t requiredBindingDecorationMask = - (1ull << spv::DecorationBinding) | (1ull << spv::DecorationDescriptorSet); - for (const auto& resource : resources) { - ASSERT((compiler.get_decoration_mask(resource.id) & - requiredBindingDecorationMask) == requiredBindingDecorationMask); + ASSERT(compiler.get_decoration_bitset(resource.id).get(spv::DecorationBinding)); + ASSERT( + compiler.get_decoration_bitset(resource.id).get(spv::DecorationDescriptorSet)); + uint32_t binding = compiler.get_decoration(resource.id, spv::DecorationBinding); uint32_t set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet); @@ -147,7 +147,7 @@ namespace dawn_native { // Extract the vertex attributes if (mExecutionModel == dawn::ShaderStage::Vertex) { for (const auto& attrib : resources.stage_inputs) { - ASSERT(compiler.get_decoration_mask(attrib.id) & (1ull << spv::DecorationLocation)); + ASSERT(compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)); uint32_t location = compiler.get_decoration(attrib.id, spv::DecorationLocation); if (location >= kMaxVertexAttributes) { @@ -161,8 +161,7 @@ namespace dawn_native { // Without a location qualifier on vertex outputs, spirv_cross::CompilerMSL gives them // all the location 0, causing a compile error. for (const auto& attrib : resources.stage_outputs) { - if (!(compiler.get_decoration_mask(attrib.id) & - (1ull << spv::DecorationLocation))) { + if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) { mDevice->HandleError("Need location qualifier on vertex output"); return; } @@ -173,8 +172,7 @@ namespace dawn_native { // Without a location qualifier on vertex inputs, spirv_cross::CompilerMSL gives them // all the location 0, causing a compile error. for (const auto& attrib : resources.stage_inputs) { - if (!(compiler.get_decoration_mask(attrib.id) & - (1ull << spv::DecorationLocation))) { + if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) { mDevice->HandleError("Need location qualifier on fragment input"); return; } diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp index 5a9c829c46..f9c971e7f9 100644 --- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp @@ -52,11 +52,11 @@ namespace dawn_native { namespace d3d12 { spirv_cross::CompilerGLSL::Options options_glsl; options_glsl.vertex.fixup_clipspace = true; options_glsl.vertex.flip_vert_y = true; - compiler.spirv_cross::CompilerGLSL::set_options(options_glsl); + compiler.set_common_options(options_glsl); spirv_cross::CompilerHLSL::Options options_hlsl; options_hlsl.shader_model = 51; - compiler.spirv_cross::CompilerHLSL::set_options(options_hlsl); + compiler.set_hlsl_options(options_hlsl); ExtractSpirvInfo(compiler); diff --git a/src/dawn_native/metal/ComputePipelineMTL.mm b/src/dawn_native/metal/ComputePipelineMTL.mm index 3ac7ba1dce..026f5248b6 100644 --- a/src/dawn_native/metal/ComputePipelineMTL.mm +++ b/src/dawn_native/metal/ComputePipelineMTL.mm @@ -26,7 +26,8 @@ namespace dawn_native { namespace metal { const auto& module = ToBackend(builder->GetStageInfo(dawn::ShaderStage::Compute).module); const auto& entryPoint = builder->GetStageInfo(dawn::ShaderStage::Compute).entryPoint; - auto compilationData = module->GetFunction(entryPoint.c_str(), ToBackend(GetLayout())); + auto compilationData = module->GetFunction(entryPoint.c_str(), dawn::ShaderStage::Compute, + ToBackend(GetLayout())); NSError* error = nil; mMtlComputePipelineState = diff --git a/src/dawn_native/metal/RenderPipelineMTL.mm b/src/dawn_native/metal/RenderPipelineMTL.mm index 4fc08b9235..2b38e0389b 100644 --- a/src/dawn_native/metal/RenderPipelineMTL.mm +++ b/src/dawn_native/metal/RenderPipelineMTL.mm @@ -77,7 +77,7 @@ namespace dawn_native { namespace metal { const auto& entryPoint = builder->GetStageInfo(stage).entryPoint; ShaderModule::MetalFunctionData data = - module->GetFunction(entryPoint.c_str(), ToBackend(GetLayout())); + module->GetFunction(entryPoint.c_str(), stage, ToBackend(GetLayout())); id function = data.function; switch (stage) { diff --git a/src/dawn_native/metal/ShaderModuleMTL.h b/src/dawn_native/metal/ShaderModuleMTL.h index a021e4249c..1e3a7262d9 100644 --- a/src/dawn_native/metal/ShaderModuleMTL.h +++ b/src/dawn_native/metal/ShaderModuleMTL.h @@ -39,7 +39,9 @@ namespace dawn_native { namespace metal { [function release]; } }; - MetalFunctionData GetFunction(const char* functionName, const PipelineLayout* layout) const; + MetalFunctionData GetFunction(const char* functionName, + dawn::ShaderStage functionStage, + const PipelineLayout* layout) const; private: // Calling compile on CompilerMSL somehow changes internal state that makes subsequent diff --git a/src/dawn_native/metal/ShaderModuleMTL.mm b/src/dawn_native/metal/ShaderModuleMTL.mm index 8e2a59ac94..bf55ca8ec7 100644 --- a/src/dawn_native/metal/ShaderModuleMTL.mm +++ b/src/dawn_native/metal/ShaderModuleMTL.mm @@ -48,12 +48,13 @@ namespace dawn_native { namespace metal { } ShaderModule::MetalFunctionData ShaderModule::GetFunction(const char* functionName, + dawn::ShaderStage functionStage, const PipelineLayout* layout) const { spirv_cross::CompilerMSL compiler(mSpirv); spirv_cross::CompilerGLSL::Options options_glsl; options_glsl.vertex.flip_vert_y = true; - compiler.spirv_cross::CompilerGLSL::set_options(options_glsl); + compiler.spirv_cross::CompilerGLSL::set_common_options(options_glsl); // 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 @@ -92,7 +93,8 @@ namespace dawn_native { namespace metal { MetalFunctionData result; { - auto size = compiler.get_entry_point(functionName).workgroup_size; + spv::ExecutionModel executionModel = SpirvExecutionModelForStage(functionStage); + auto size = compiler.get_entry_point(functionName, executionModel).workgroup_size; result.localWorkgroupSize = MTLSizeMake(size.x, size.y, size.z); } diff --git a/src/dawn_native/opengl/ShaderModuleGL.cpp b/src/dawn_native/opengl/ShaderModuleGL.cpp index 84226a34ff..d607bef1cb 100644 --- a/src/dawn_native/opengl/ShaderModuleGL.cpp +++ b/src/dawn_native/opengl/ShaderModuleGL.cpp @@ -58,7 +58,7 @@ namespace dawn_native { namespace opengl { #else options.version = 440; #endif - compiler.set_options(options); + compiler.set_common_options(options); // Rename the push constant block to be prefixed with the shader stage type so that uniform // names don't match between the FS and the VS. diff --git a/third_party/spirv-cross b/third_party/spirv-cross index 694cad5332..a7697446b1 160000 --- a/third_party/spirv-cross +++ b/third_party/spirv-cross @@ -1 +1 @@ -Subproject commit 694cad533296df02b4562f4a5a20cba1d1a9dbaf +Subproject commit a7697446b12666da353bb2bdafa792d988fb268c