|
|
@@ -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)
|