From: Dave Airlie Date: Thu, 20 Aug 2020 00:54:16 +0000 (+1000) Subject: gallium/nir/tgsi: fix nir->tgsi info conversion for samplers/image X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=87a638dc1f65c4de4317f9cea2d28e73438f46e0;p=mesa.git gallium/nir/tgsi: fix nir->tgsi info conversion for samplers/image for sampler image arrays this code wasn't getting the correct values. Fixes: EQP-VK.binding_model.shader_access.primary_cmd_buf.sampler_immutable.*.descriptor_array* Reviewed-by: Roland Scheidegger Part-of: --- diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c index 8d15a426230..299523f4b6a 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c @@ -749,18 +749,26 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir, } } + uint32_t sampler_mask = 0, image_mask = 0; + nir_foreach_uniform_variable(var, nir) { + uint32_t sampler_count = glsl_type_get_sampler_count(var->type); + uint32_t image_count = glsl_type_get_image_count(var->type); + sampler_mask |= ((1ull << sampler_count) - 1) << var->data.binding; + image_mask |= ((1ull << image_count) - 1) << var->data.binding; + } info->num_outputs = num_outputs; info->const_file_max[0] = nir->num_uniforms - 1; info->const_buffers_declared = u_bit_consecutive(1, nir->info.num_ubos); if (nir->num_uniforms > 0) - info->const_buffers_declared |= 1; - info->images_declared = u_bit_consecutive(0, nir->info.num_images); - info->samplers_declared = nir->info.textures_used; + info->const_buffers_declared |= 1; + info->images_declared = image_mask; + info->samplers_declared = sampler_mask; info->file_max[TGSI_FILE_SAMPLER] = util_last_bit(info->samplers_declared) - 1; - info->file_max[TGSI_FILE_SAMPLER_VIEW] = info->file_max[TGSI_FILE_SAMPLER]; - info->file_mask[TGSI_FILE_SAMPLER] = info->file_mask[TGSI_FILE_SAMPLER_VIEW] = info->samplers_declared; + info->file_max[TGSI_FILE_SAMPLER_VIEW] = util_last_bit(nir->info.textures_used) - 1; + info->file_mask[TGSI_FILE_SAMPLER] = info->samplers_declared; + info->file_mask[TGSI_FILE_SAMPLER_VIEW] = nir->info.textures_used; info->file_max[TGSI_FILE_IMAGE] = util_last_bit(info->images_declared) - 1; info->file_mask[TGSI_FILE_IMAGE] = info->images_declared;