diff options
Diffstat (limited to 'spirv_msl.cpp')
-rw-r--r-- | spirv_msl.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/spirv_msl.cpp b/spirv_msl.cpp index daca7c76..1060bb27 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -11723,10 +11723,18 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base if (has_extended_decoration(var.self, resource_decoration)) return get_extended_decoration(var.self, resource_decoration); - // Allow user to enable decoration binding - if (msl_options.enable_decoration_binding) + auto &type = get<SPIRType>(var.basetype); + + if (type_is_msl_framebuffer_fetch(type)) + { + // Frame-buffer fetch gets its fallback resource index from the input attachment index, + // which is then treated as color index. + return get_decoration(var.self, DecorationInputAttachmentIndex); + } + else if (msl_options.enable_decoration_binding) { - // If there is no explicit mapping of bindings to MSL, use the declared binding. + // Allow user to enable decoration binding. + // If there is no explicit mapping of bindings to MSL, use the declared binding as a fallback. if (has_decoration(var.self, DecorationBinding)) { var_binding = get_decoration(var.self, DecorationBinding); @@ -11745,7 +11753,6 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base allocate_argument_buffer_ids = descriptor_set_is_argument_buffer(var_desc_set); uint32_t binding_stride = 1; - auto &type = get<SPIRType>(var.basetype); for (uint32_t i = 0; i < uint32_t(type.array.size()); i++) binding_stride *= to_array_size_literal(type, i); @@ -11754,13 +11761,7 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base // If a binding has not been specified, revert to incrementing resource indices. uint32_t resource_index; - if (type_is_msl_framebuffer_fetch(type)) - { - // Frame-buffer fetch gets its fallback resource index from the input attachment index, - // which is then treated as color index. - resource_index = get_decoration(var.self, DecorationInputAttachmentIndex); - } - else if (allocate_argument_buffer_ids) + if (allocate_argument_buffer_ids) { // Allocate from a flat ID binding space. resource_index = next_metal_resource_ids[var_desc_set]; |