hk: pack has_border with clamp_0_sampler_index

this is cheaper to decode (shorter preambles!).

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33386>
This commit is contained in:
Alyssa Rosenzweig 2025-01-31 14:37:31 -05:00 committed by Marge Bot
parent 6e29a2c8d5
commit 7ed6aa68ad
3 changed files with 16 additions and 10 deletions

View file

@ -107,12 +107,16 @@ write_sampled_image_view_desc(struct hk_descriptor_set *set,
desc[plane].sampler_index =
sampler->planes[sampler_plane].hw->index + 28;
desc[plane].lod_bias_fp16 = sampler->lod_bias_fp16;
desc[plane].has_border = sampler->has_border;
desc[plane].clamp_0_sampler_index_or_negative = -1;
}
if (sampler->has_border) {
assert(sampler->plane_count == 2);
desc[0].clamp_0_sampler_index = sampler->planes[1].hw->index + 28;
desc[0].clamp_0_sampler_index_or_negative =
sampler->planes[1].hw->index + 28;
assert(desc[0].clamp_0_sampler_index_or_negative >= 0 &&
"we have a border colour");
static_assert(sizeof(desc[0].border) == sizeof(sampler->custom_border),
"fixed format");

View file

@ -27,10 +27,11 @@ struct hk_sampled_image_descriptor {
uint16_t lod_bias_fp16;
/* TODO: This should probably be a heap! */
uint32_t border[4];
/* XXX: Single bit! Tuck it in somewhere else */
uint32_t has_border;
uint16_t clamp_0_sampler_index;
uint16_t pad_0;
/* Negative if there is no border colour, else the clamp=0 sampler index used
* for custom border colour emulation.
*/
int16_t clamp_0_sampler_index_or_negative;
uint32_t pad;
};
static_assert(sizeof(struct hk_sampled_image_descriptor) == 32,
"hk_sampled_image_descriptor has no holes");

View file

@ -610,13 +610,14 @@ lower_tex(nir_builder *b, nir_tex_instr *tex,
}
if (tex->op == nir_texop_has_custom_border_color_agx) {
unsigned offs = offsetof(struct hk_sampled_image_descriptor, has_border);
unsigned offs = offsetof(struct hk_sampled_image_descriptor,
clamp_0_sampler_index_or_negative);
nir_def *res = load_resource_deref_desc(
b, 1, 16, nir_src_as_deref(nir_src_for_ssa(sampler)),
plane_offset_B + offs, ctx);
nir_def_replace(&tex->def, nir_ine_imm(b, res, 0));
nir_def_replace(&tex->def, nir_ige_imm(b, res, 0));
return true;
}
@ -651,8 +652,8 @@ lower_tex(nir_builder *b, nir_tex_instr *tex,
offsetof(struct hk_sampled_image_descriptor, sampler_index);
if (tex->backend_flags & AGX_TEXTURE_FLAG_CLAMP_TO_0) {
offs =
offsetof(struct hk_sampled_image_descriptor, clamp_0_sampler_index);
offs = offsetof(struct hk_sampled_image_descriptor,
clamp_0_sampler_index_or_negative);
}
nir_def *index = load_resource_deref_desc(