shader_info: Make images_used a bitset
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15988>
This commit is contained in:
@@ -128,16 +128,20 @@ record_images_used(struct shader_info *info,
|
||||
/* Structs have been lowered already, so get_aoa_size is sufficient. */
|
||||
const unsigned size =
|
||||
glsl_type_is_array(var->type) ? glsl_get_aoa_size(var->type) : 1;
|
||||
unsigned mask = ((1ull << MAX2(size, 1)) - 1) << var->data.binding;
|
||||
|
||||
info->images_used |= mask;
|
||||
BITSET_SET_RANGE(info->images_used, var->data.binding,
|
||||
var->data.binding + (MAX2(size, 1) - 1));
|
||||
|
||||
enum glsl_sampler_dim sampler_dim =
|
||||
glsl_get_sampler_dim(glsl_without_array(var->type));
|
||||
if (sampler_dim == GLSL_SAMPLER_DIM_BUF)
|
||||
info->image_buffers |= mask;
|
||||
if (sampler_dim == GLSL_SAMPLER_DIM_MS)
|
||||
info->msaa_images |= mask;
|
||||
if (sampler_dim == GLSL_SAMPLER_DIM_BUF) {
|
||||
BITSET_SET_RANGE(info->image_buffers, var->data.binding,
|
||||
var->data.binding + (MAX2(size, 1) - 1));
|
||||
}
|
||||
if (sampler_dim == GLSL_SAMPLER_DIM_MS) {
|
||||
BITSET_SET_RANGE(info->msaa_images, var->data.binding,
|
||||
var->data.binding + (MAX2(size, 1) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -203,11 +203,11 @@ typedef struct shader_info {
|
||||
BITSET_DECLARE(textures_used_by_txf, 32);
|
||||
|
||||
/** Bitfield of which images are used */
|
||||
uint32_t images_used;
|
||||
BITSET_DECLARE(images_used, 32);
|
||||
/** Bitfield of which images are buffers. */
|
||||
uint32_t image_buffers;
|
||||
BITSET_DECLARE(image_buffers, 32);
|
||||
/** Bitfield of which images are MSAA. */
|
||||
uint32_t msaa_images;
|
||||
BITSET_DECLARE(msaa_images, 32);
|
||||
|
||||
/* SPV_KHR_float_controls: execution mode for floating point ops */
|
||||
uint16_t float_controls_execution_mode;
|
||||
|
@@ -121,7 +121,7 @@ resolve_image_views(struct iris_context *ice,
|
||||
bool *draw_aux_buffer_disabled,
|
||||
bool consider_framebuffer)
|
||||
{
|
||||
uint32_t views = info ? (shs->bound_image_views & info->images_used) : 0;
|
||||
uint32_t views = info ? (shs->bound_image_views & info->images_used[0]) : 0;
|
||||
|
||||
while (views) {
|
||||
const int i = u_bit_scan(&views);
|
||||
|
@@ -152,12 +152,14 @@ static void si_create_compute_state_async(void *job, void *gdata, int thread_ind
|
||||
/* Images in user SGPRs. */
|
||||
unsigned non_fmask_images = u_bit_consecutive(0, sel->info.base.num_images);
|
||||
|
||||
/* Remove images with FMASK from the bitmask. */
|
||||
/* Remove images with FMASK from the bitmask. We only care about the first
|
||||
* 3 anyway, so we can take msaa_images[0] and ignore the rest.
|
||||
*/
|
||||
if (sscreen->info.chip_class < GFX11)
|
||||
non_fmask_images &= ~sel->info.base.msaa_images;
|
||||
non_fmask_images &= ~sel->info.base.msaa_images[0];
|
||||
|
||||
for (unsigned i = 0; i < 3 && non_fmask_images & (1 << i); i++) {
|
||||
unsigned num_sgprs = sel->info.base.image_buffers & (1 << i) ? 4 : 8;
|
||||
unsigned num_sgprs = BITSET_TEST(sel->info.base.image_buffers, i) ? 4 : 8;
|
||||
|
||||
if (align(user_sgprs, num_sgprs) + num_sgprs > 16)
|
||||
break;
|
||||
|
@@ -2291,7 +2291,7 @@ void si_emit_compute_shader_pointers(struct si_context *sctx)
|
||||
unsigned num_sgprs = 8;
|
||||
|
||||
/* Image buffers are in desc[4..7]. */
|
||||
if (shader->info.base.image_buffers & (1 << i)) {
|
||||
if (BITSET_TEST(shader->info.base.image_buffers, i)) {
|
||||
desc_offset += 4;
|
||||
num_sgprs = 4;
|
||||
}
|
||||
|
@@ -758,7 +758,7 @@ void si_init_shader_args(struct si_shader_context *ctx, bool ngg_cull_shader)
|
||||
}
|
||||
/* Images in user SGPRs. */
|
||||
for (unsigned i = 0; i < shader->selector->cs_num_images_in_user_sgprs; i++) {
|
||||
unsigned num_sgprs = shader->selector->info.base.image_buffers & (1 << i) ? 4 : 8;
|
||||
unsigned num_sgprs = BITSET_TEST(shader->selector->info.base.image_buffers, i) ? 4 : 8;
|
||||
|
||||
while (ctx->args.num_sgprs_used % num_sgprs != 0)
|
||||
ac_add_arg(&ctx->args, AC_ARG_SGPR, 1, AC_ARG_INT, NULL);
|
||||
|
@@ -3065,7 +3065,7 @@ void si_get_active_slot_masks(struct si_screen *sscreen, const struct si_shader_
|
||||
num_constbufs = info->base.num_ubos;
|
||||
/* two 8-byte images share one 16-byte slot */
|
||||
num_images = align(info->base.num_images, 2);
|
||||
num_msaa_images = align(util_last_bit(info->base.msaa_images), 2);
|
||||
num_msaa_images = align(BITSET_LAST_BIT(info->base.msaa_images), 2);
|
||||
num_samplers = BITSET_LAST_BIT(info->base.textures_used);
|
||||
|
||||
/* The layout is: sb[last] ... sb[0], cb[0] ... cb[last] */
|
||||
|
@@ -3924,7 +3924,7 @@ nir_to_spirv(struct nir_shader *s, const struct zink_shader_info *sinfo, uint32_
|
||||
goto fail;
|
||||
|
||||
spirv_builder_emit_cap(&ctx.builder, SpvCapabilityShader);
|
||||
if (s->info.image_buffers != 0)
|
||||
if (BITSET_COUNT(s->info.image_buffers) != 0)
|
||||
spirv_builder_emit_cap(&ctx.builder, SpvCapabilityImageBuffer);
|
||||
spirv_builder_emit_cap(&ctx.builder, SpvCapabilitySampledBuffer);
|
||||
|
||||
|
@@ -2020,9 +2020,8 @@ scan_nir(struct zink_screen *screen, nir_shader *shader, struct zink_shader *zs)
|
||||
/* Structs have been lowered already, so get_aoa_size is sufficient. */
|
||||
const unsigned size =
|
||||
glsl_type_is_array(var->type) ? glsl_get_aoa_size(var->type) : 1;
|
||||
unsigned mask = ((1ull << MAX2(size, 1)) - 1) << var->data.binding;
|
||||
|
||||
shader->info.images_used |= mask;
|
||||
BITSET_SET_RANGE(shader->info.images_used, var->data.binding,
|
||||
var->data.binding + (MAX2(size, 1) - 1));
|
||||
}
|
||||
if (intr->intrinsic == nir_intrinsic_is_sparse_texels_resident ||
|
||||
intr->intrinsic == nir_intrinsic_image_deref_sparse_load)
|
||||
|
@@ -597,7 +597,7 @@ zink_program_get_descriptor_usage(struct zink_context *ctx, enum pipe_shader_typ
|
||||
case ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW:
|
||||
return BITSET_TEST_RANGE(zs->nir->info.textures_used, 0, PIPE_MAX_SAMPLERS - 1);
|
||||
case ZINK_DESCRIPTOR_TYPE_IMAGE:
|
||||
return zs->nir->info.images_used;
|
||||
return BITSET_TEST_RANGE(zs->nir->info.images_used, 0, PIPE_MAX_SAMPLERS - 1);
|
||||
default:
|
||||
unreachable("unknown descriptor type!");
|
||||
}
|
||||
|
@@ -589,7 +589,7 @@ set_image_access(struct lvp_pipeline *pipeline, nir_shader *nir,
|
||||
const unsigned size = glsl_type_is_array(var->type) ? glsl_get_aoa_size(var->type) : 1;
|
||||
unsigned mask = ((1ull << MAX2(size, 1)) - 1) << var->data.binding;
|
||||
|
||||
nir->info.images_used |= mask;
|
||||
nir->info.images_used[0] |= mask;
|
||||
if (reads)
|
||||
pipeline->access[nir->info.stage].images_read |= mask;
|
||||
if (writes)
|
||||
|
@@ -990,9 +990,9 @@ st_nir_lower_samplers(struct pipe_screen *screen, nir_shader *nir,
|
||||
if (prog) {
|
||||
BITSET_COPY(prog->info.textures_used, nir->info.textures_used);
|
||||
BITSET_COPY(prog->info.textures_used_by_txf, nir->info.textures_used_by_txf);
|
||||
prog->info.images_used = nir->info.images_used;
|
||||
prog->info.image_buffers = nir->info.image_buffers;
|
||||
prog->info.msaa_images = nir->info.msaa_images;
|
||||
BITSET_COPY(prog->info.images_used, nir->info.images_used);
|
||||
BITSET_COPY(prog->info.image_buffers, nir->info.image_buffers);
|
||||
BITSET_COPY(prog->info.msaa_images, nir->info.msaa_images);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4202,7 +4202,7 @@ bi_optimize_nir(nir_shader *nir, unsigned gpu_id, bool is_blend)
|
||||
nir->info.outputs_accessed_indirectly ||
|
||||
nir->info.patch_inputs_read_indirectly ||
|
||||
nir->info.patch_outputs_accessed_indirectly ||
|
||||
nir->info.images_used;
|
||||
nir->info.images_used[0];
|
||||
|
||||
if (any_indirects) {
|
||||
nir_convert_to_lcssa(nir, true, true);
|
||||
|
@@ -317,7 +317,7 @@ GENX(pan_shader_compile)(nir_shader *s,
|
||||
else
|
||||
info->ubo_count = s->info.num_ubos;
|
||||
|
||||
info->attribute_count += util_last_bit(s->info.images_used);
|
||||
info->attribute_count += BITSET_LAST_BIT(s->info.images_used);
|
||||
info->writes_global = s->info.writes_memory;
|
||||
|
||||
info->sampler_count = info->texture_count = BITSET_LAST_BIT(s->info.textures_used);
|
||||
|
Reference in New Issue
Block a user