From: Mike Blumenkrantz Date: Fri, 14 Jan 2022 14:51:47 +0000 (-0500) Subject: zink: only allocate ntv residency info if it will be used X-Git-Tag: upstream/22.3.5~13729 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d76694a18ff0667abf3787634e6755f170266e01;p=platform%2Fupstream%2Fmesa.git zink: only allocate ntv residency info if it will be used odds are it will never be used, so don't bother allocating Acked-by: Dave Airlie Part-of: --- diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index 82da393..8e84948 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -3901,10 +3901,15 @@ nir_to_spirv(struct nir_shader *s, const struct zink_shader_info *sinfo, uint32_ sizeof(SpvId), entry->ssa_alloc); if (!ctx.defs) goto fail; - ctx.resident_defs = ralloc_array_size(ctx.mem_ctx, - sizeof(SpvId), entry->ssa_alloc); - if (!ctx.resident_defs) - goto fail; + if (sinfo->have_sparse) { + /* this could be huge, so only alloc if needed since it's extremely unlikely to + * ever be used by anything except cts + */ + ctx.resident_defs = ralloc_array_size(ctx.mem_ctx, + sizeof(SpvId), entry->ssa_alloc); + if (!ctx.resident_defs) + goto fail; + } ctx.num_defs = entry->ssa_alloc; nir_index_local_regs(entry); diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index b9e27bc..f582c5c 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -1712,13 +1712,17 @@ lower_1d_shadow(nir_shader *shader) } static void -scan_nir(nir_shader *shader) +scan_nir(nir_shader *shader, struct zink_shader *zs) { nir_foreach_function(function, shader) { if (!function->impl) continue; nir_foreach_block_safe(block, function->impl) { nir_foreach_instr_safe(instr, block) { + if (instr->type == nir_instr_type_tex) { + nir_tex_instr *tex = nir_instr_as_tex(instr); + zs->sinfo.have_sparse |= tex->is_sparse; + } if (instr->type != nir_instr_type_intrinsic) continue; nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); @@ -1751,6 +1755,9 @@ scan_nir(nir_shader *shader) shader->info.images_used |= mask; } + if (intr->intrinsic == nir_intrinsic_is_sparse_texels_resident || + intr->intrinsic == nir_intrinsic_image_deref_sparse_load) + zs->sinfo.have_sparse = true; } } } @@ -1865,7 +1872,7 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir, if (has_bindless_io) NIR_PASS_V(nir, lower_bindless_io); - scan_nir(nir); + scan_nir(nir, ret); foreach_list_typed_reverse_safe(nir_variable, var, node, &nir->variables) { if (_nir_shader_variable_has_mode(var, nir_var_uniform | diff --git a/src/gallium/drivers/zink/zink_compiler.h b/src/gallium/drivers/zink/zink_compiler.h index 62a831e..1303646 100644 --- a/src/gallium/drivers/zink/zink_compiler.h +++ b/src/gallium/drivers/zink/zink_compiler.h @@ -56,6 +56,7 @@ struct zink_shader_info { unsigned so_info_slots[PIPE_MAX_SO_OUTPUTS]; bool last_vertex; bool have_xfb; + bool have_sparse; };