From 010676412ef819ed7a2a6eece1f02f88e9666016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sat, 28 Sep 2019 19:30:23 +0200 Subject: [PATCH] Fixed issue #1894. --- tools/shaderc/shaderc_metal.cpp | 22 ++++++++++++++++------ tools/shaderc/shaderc_spirv.cpp | 8 +++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tools/shaderc/shaderc_metal.cpp b/tools/shaderc/shaderc_metal.cpp index 5c51c9ebf..6260ef1ef 100644 --- a/tools/shaderc/shaderc_metal.cpp +++ b/tools/shaderc/shaderc_metal.cpp @@ -819,7 +819,17 @@ namespace bgfx { namespace metal opt.SetMessageConsumer(print_msg_to_stderr); opt.RegisterLegalizationPasses(); - if (!opt.Run(spirv.data(), spirv.size(), &spirv)) + + spvtools::ValidatorOptions validatorOptions; + validatorOptions.SetBeforeHlslLegalization(true); + + if (!opt.Run( + spirv.data() + , spirv.size() + , &spirv + , validatorOptions + , false + ) ) { compiled = false; } @@ -862,7 +872,7 @@ namespace bgfx { namespace metal } spirv_cross::CompilerMSL msl(std::move(spirv)); - + auto executionModel = msl.get_execution_model(); spirv_cross::MSLResourceBinding newBinding; newBinding.stage = executionModel; @@ -911,7 +921,7 @@ namespace bgfx { namespace metal std::string name = msl.get_name(resource.id); if (name.size() > 7 && 0 == bx::strCmp(name.c_str() + name.length() - 7, "Texture") ) msl.set_name(resource.id, name.substr(0, name.length() - 7)); - + unsigned set = msl.get_decoration( resource.id, spv::DecorationDescriptorSet ); unsigned binding = msl.get_decoration( resource.id, spv::DecorationBinding ); newBinding.desc_set = set; @@ -920,13 +930,13 @@ namespace bgfx { namespace metal newBinding.msl_sampler = binding - textureBindingOffset; msl.add_msl_resource_binding( newBinding ); } - + for (auto &resource : resources.storage_images) { std::string name = msl.get_name(resource.id); if (name.size() > 7 && 0 == bx::strCmp(name.c_str() + name.length() - 7, "Texture") ) msl.set_name(resource.id, name.substr(0, name.length() - 7)); - + unsigned set = msl.get_decoration( resource.id, spv::DecorationDescriptorSet ); unsigned binding = msl.get_decoration( resource.id, spv::DecorationBinding ); newBinding.desc_set = set; @@ -935,7 +945,7 @@ namespace bgfx { namespace metal newBinding.msl_sampler = binding - textureBindingOffset; msl.add_msl_resource_binding( newBinding ); } - + std::string source = msl.compile(); if ('c' == _options.shaderType) diff --git a/tools/shaderc/shaderc_spirv.cpp b/tools/shaderc/shaderc_spirv.cpp index b81749e31..002d67719 100644 --- a/tools/shaderc/shaderc_spirv.cpp +++ b/tools/shaderc/shaderc_spirv.cpp @@ -983,7 +983,13 @@ namespace bgfx { namespace spirv spvtools::ValidatorOptions validatorOptions; validatorOptions.SetBeforeHlslLegalization(true); - if (!opt.Run(spirv.data(), spirv.size(), &spirv, validatorOptions, false) ) + if (!opt.Run( + spirv.data() + , spirv.size() + , &spirv + , validatorOptions + , false + ) ) { compiled = false; }