agx: implement query_levels
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26963>
This commit is contained in:
@@ -35,7 +35,8 @@ lower_tex_crawl(nir_builder *b, nir_instr *instr, UNUSED void *data)
|
||||
nir_tex_instr *tex = nir_instr_as_tex(instr);
|
||||
b->cursor = nir_before_instr(instr);
|
||||
|
||||
if (tex->op != nir_texop_txs && tex->op != nir_texop_texture_samples)
|
||||
if (tex->op != nir_texop_txs && tex->op != nir_texop_texture_samples &&
|
||||
tex->op != nir_texop_query_levels)
|
||||
return false;
|
||||
|
||||
nir_def *ptr = texture_descriptor_ptr(b, tex);
|
||||
@@ -55,6 +56,8 @@ lower_tex_crawl(nir_builder *b, nir_instr *instr, UNUSED void *data)
|
||||
nir_imm_bool(b, tex->sampler_dim == GLSL_SAMPLER_DIM_2D),
|
||||
nir_imm_bool(b, tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE),
|
||||
nir_imm_bool(b, tex->is_array));
|
||||
} else if (tex->op == nir_texop_query_levels) {
|
||||
res = libagx_texture_levels(b, ptr);
|
||||
} else {
|
||||
res = libagx_texture_samples(b, ptr);
|
||||
}
|
||||
@@ -317,6 +320,7 @@ lower_sampler_bias(nir_builder *b, nir_instr *instr, UNUSED void *data)
|
||||
case nir_texop_tg4:
|
||||
case nir_texop_texture_samples:
|
||||
case nir_texop_samples_identical:
|
||||
case nir_texop_query_levels:
|
||||
/* These operations do not use a sampler */
|
||||
return false;
|
||||
|
||||
@@ -654,6 +658,7 @@ agx_nir_needs_texture_crawl(nir_instr *instr)
|
||||
/* Queries always become a crawl */
|
||||
case nir_texop_txs:
|
||||
case nir_texop_texture_samples:
|
||||
case nir_texop_query_levels:
|
||||
return true;
|
||||
|
||||
/* Buffer textures need their format read */
|
||||
|
@@ -68,6 +68,18 @@ libagx_texture_samples(constant struct agx_texture_packed *ptr)
|
||||
return (d.samples == AGX_SAMPLE_COUNT_2) ? 2 : 4;
|
||||
}
|
||||
|
||||
uint
|
||||
libagx_texture_levels(constant struct agx_texture_packed *ptr)
|
||||
{
|
||||
agx_unpack(NULL, ptr, TEXTURE, d);
|
||||
|
||||
/* As above */
|
||||
if (d.null)
|
||||
return 0;
|
||||
else
|
||||
return (d.last_level - d.first_level) + 1;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
calculate_twiddled_coordinates(ushort2 coord, uint16_t tile_w_px,
|
||||
uint16_t tile_h_px, uint32_t width_tl)
|
||||
|
Reference in New Issue
Block a user