mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
nir: Add flag to tex instruction to indicate lowering cube to array
E.g. r600 a cube texture lookup uses a specific cube instruction
to evaluate the sample coordinates and the face ID, so that the cube
texture lookup can be lowered to a array texture lookup, thereby sharing
the code with the 2D array texture lopkup.
However, for TXD the given gradients still need to be three-component
vectors, so add a flag that the NIR validation knows that we deal with
cube texture that was lowered to an array and can validate accordingly.
v2: Handle new flag in serialization (Marek)
v3: Rebase so that the change does not require the patch to deduct the
number of offset and grad components from sampler type
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v2)
Acked-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9200>
This commit is contained in:
parent
b44c48fd21
commit
4f4e1e5ed9
3 changed files with 10 additions and 2 deletions
|
|
@ -2049,6 +2049,9 @@ typedef struct {
|
|||
/* gather component selector */
|
||||
unsigned component : 2;
|
||||
|
||||
/* Validation needs to know this for gradient component count */
|
||||
unsigned array_is_lowered_cube : 1;
|
||||
|
||||
/* gather offsets */
|
||||
int8_t tg4_offsets[4][2];
|
||||
|
||||
|
|
@ -2268,7 +2271,8 @@ nir_tex_instr_src_size(const nir_tex_instr *instr, unsigned src)
|
|||
|
||||
if (instr->src[src].src_type == nir_tex_src_ddx ||
|
||||
instr->src[src].src_type == nir_tex_src_ddy) {
|
||||
if (instr->is_array)
|
||||
|
||||
if (instr->is_array && !instr->array_is_lowered_cube)
|
||||
return instr->coord_components - 1;
|
||||
else
|
||||
return instr->coord_components;
|
||||
|
|
|
|||
|
|
@ -411,6 +411,7 @@ clone_tex(clone_state *state, const nir_tex_instr *tex)
|
|||
}
|
||||
ntex->coord_components = tex->coord_components;
|
||||
ntex->is_array = tex->is_array;
|
||||
ntex->array_is_lowered_cube = tex->array_is_lowered_cube;
|
||||
ntex->is_shadow = tex->is_shadow;
|
||||
ntex->is_new_style_shadow = tex->is_new_style_shadow;
|
||||
ntex->is_sparse = tex->is_sparse;
|
||||
|
|
|
|||
|
|
@ -1460,7 +1460,8 @@ union packed_tex_data {
|
|||
unsigned component:2;
|
||||
unsigned texture_non_uniform:1;
|
||||
unsigned sampler_non_uniform:1;
|
||||
unsigned unused:7; /* Mark unused for valgrind. */
|
||||
unsigned array_is_lowered_cube:1;
|
||||
unsigned unused:6; /* Mark unused for valgrind. */
|
||||
} u;
|
||||
};
|
||||
|
||||
|
|
@ -1496,6 +1497,7 @@ write_tex(write_ctx *ctx, const nir_tex_instr *tex)
|
|||
.u.component = tex->component,
|
||||
.u.texture_non_uniform = tex->texture_non_uniform,
|
||||
.u.sampler_non_uniform = tex->sampler_non_uniform,
|
||||
.u.array_is_lowered_cube = tex->array_is_lowered_cube,
|
||||
};
|
||||
blob_write_uint32(ctx->blob, packed.u32);
|
||||
|
||||
|
|
@ -1532,6 +1534,7 @@ read_tex(read_ctx *ctx, union packed_instr header)
|
|||
tex->component = packed.u.component;
|
||||
tex->texture_non_uniform = packed.u.texture_non_uniform;
|
||||
tex->sampler_non_uniform = packed.u.sampler_non_uniform;
|
||||
tex->array_is_lowered_cube = packed.u.array_is_lowered_cube;
|
||||
|
||||
for (unsigned i = 0; i < tex->num_srcs; i++) {
|
||||
union packed_src src = read_src(ctx, &tex->src[i].src, &tex->instr);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue