hk: only pass sampler heap if needed

I'm guessing the hardware needs to prefetch the whole sampler heap, so if we're
not gonna use it, let's omit it. I don't know if this helps, but it can't hurt.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36127>
This commit is contained in:
Alyssa Rosenzweig
2025-07-14 19:35:36 -04:00
committed by Marge Bot
parent 74c32c2357
commit a5e9669a78
5 changed files with 23 additions and 5 deletions
+1
View File
@@ -2270,6 +2270,7 @@ agx_emit_tex(agx_builder *b, nir_tex_instr *instr)
texture = index;
break;
case nir_tex_src_sampler_handle:
b->shader->out->uses_sampler_heap = true;
sampler = index;
break;
+3
View File
@@ -140,6 +140,9 @@ struct agx_shader_info {
/* Uses txf and hence needs a txf sampler mapped */
bool uses_txf;
/* Potentially uses the sampler heap (conservative) */
bool uses_sampler_heap;
/* Number of texture/sampler state registers pushed by the preamble. */
uint8_t texture_state_count, sampler_state_count;
+3
View File
@@ -630,6 +630,9 @@ hk_reserve_scratch(struct hk_cmd_buffer *cmd, struct hk_cs *cs,
uint32_t max_scratch_size =
MAX2(s->b.info.scratch_size, s->b.info.preamble_scratch_size);
/* Not scratch but this is the most convenient place for this... */
cs->uses_sampler_heap |= s->b.info.uses_sampler_heap;
if (max_scratch_size == 0)
return;
+7
View File
@@ -360,6 +360,12 @@ struct hk_cs {
/* Whether there is more than just the root chunk */
bool stream_linked;
/* Whether the sampler heap is required. Although we always must maintain the
* heap for correctness, it's often not necessary since we can push lots of
* samplers (especially for GL/DX11-era engines).
*/
bool uses_sampler_heap;
/* Scratch requirements */
struct {
union {
@@ -428,6 +434,7 @@ hk_cs_merge_cdm(struct hk_cs *a, const struct hk_cs *b)
a->current = b->current;
a->stream_linked = true;
a->uses_sampler_heap |= b->uses_sampler_heap;
a->scratch.cs.main |= b->scratch.cs.main;
a->scratch.cs.preamble |= b->scratch.cs.preamble;
+9 -5
View File
@@ -86,13 +86,15 @@ asahi_fill_cdm_command(struct hk_device *dev, struct hk_cs *cs,
.cdm_ctrl_stream_base = cs->addr,
.cdm_ctrl_stream_end = cs->addr + len,
.sampler_heap = dev->samplers.table.bo->va->addr,
.sampler_count = dev->samplers.table.alloc,
.ts.end.handle = cs->timestamp.end.handle,
.ts.end.offset = cs->timestamp.end.offset_B,
};
if (cs->uses_sampler_heap) {
cmd->sampler_heap = dev->samplers.table.bo->va->addr;
cmd->sampler_count = dev->samplers.table.alloc;
}
if (cs->scratch.cs.main || cs->scratch.cs.preamble) {
cmd->helper.data = dev->scratch.cs.buf->va->addr;
cmd->helper.cfg = cs->scratch.cs.preamble ? (1 << 16) : 0;
@@ -199,8 +201,10 @@ asahi_fill_vdm_command(struct hk_device *dev, struct hk_cs *cs,
c->isp_scissor_base = cs->uploaded_scissor;
c->isp_dbias_base = cs->uploaded_zbias;
c->sampler_heap = dev->samplers.table.bo->va->addr;
c->sampler_count = dev->samplers.table.alloc;
if (cs->uses_sampler_heap) {
c->sampler_heap = dev->samplers.table.bo->va->addr;
c->sampler_count = dev->samplers.table.alloc;
}
c->isp_oclqry_base = dev->occlusion_queries.bo->va->addr;