mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-15 13:50:29 +01:00
nak/nir/lower_tex: Use nir_tex_instr_add_src()
This is slightly less efficient but way safer than trying to mangle the sources array that's already in the tex instruction. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34910>
This commit is contained in:
parent
8a39a1502f
commit
e2b7a736a4
1 changed files with 11 additions and 18 deletions
|
|
@ -70,7 +70,10 @@ lower_tex(nir_builder *b, nir_tex_instr *tex, const struct nak_compiler *nak)
|
|||
default:
|
||||
unreachable("Unsupported texture source");
|
||||
}
|
||||
/* Remove sources as we walk them. We'll add them back later */
|
||||
nir_instr_clear_src(&tex->instr, &tex->src[i].src);
|
||||
}
|
||||
tex->num_srcs = 0;
|
||||
|
||||
/* Combine sampler and texture into one if needed */
|
||||
if (samp_h != NULL && samp_h != tex_h) {
|
||||
|
|
@ -176,7 +179,6 @@ lower_tex(nir_builder *b, nir_tex_instr *tex, const struct nak_compiler *nak)
|
|||
a[a##_comps++] = val; \
|
||||
} while(0)
|
||||
|
||||
unsigned num_backend_srcs = 0;
|
||||
if (nak->sm >= 50) {
|
||||
nir_def *src0[4] = { NULL, };
|
||||
nir_def *src1[4] = { NULL, };
|
||||
|
|
@ -232,16 +234,14 @@ lower_tex(nir_builder *b, nir_tex_instr *tex, const struct nak_compiler *nak)
|
|||
PUSH(src1, z_cmpr);
|
||||
}
|
||||
|
||||
num_backend_srcs = 1;
|
||||
tex->src[0].src_type = nir_tex_src_backend1;
|
||||
nir_src_rewrite(&tex->src[0].src, nir_vec(b, src0, src0_comps));
|
||||
nir_tex_instr_add_src(tex, nir_tex_src_backend1,
|
||||
nir_vec(b, src0, src0_comps));
|
||||
|
||||
if (src1_comps > 0) {
|
||||
while (src1_comps < 4)
|
||||
PUSH(src1, nir_undef(b, 1, 32));
|
||||
num_backend_srcs = 2;
|
||||
tex->src[1].src_type = nir_tex_src_backend2;
|
||||
nir_src_rewrite(&tex->src[1].src, nir_vec(b, src1, src1_comps));
|
||||
nir_tex_instr_add_src(tex, nir_tex_src_backend2,
|
||||
nir_vec(b, src1, src1_comps));
|
||||
}
|
||||
} else if (nak->sm >= 30) {
|
||||
nir_def *src[8] = { NULL, };
|
||||
|
|
@ -292,23 +292,16 @@ lower_tex(nir_builder *b, nir_tex_instr *tex, const struct nak_compiler *nak)
|
|||
while (src_comps % 4)
|
||||
PUSH(src, nir_undef(b, 1, 32));
|
||||
|
||||
num_backend_srcs = 1;
|
||||
tex->src[0].src_type = nir_tex_src_backend1;
|
||||
nir_src_rewrite(&tex->src[0].src, nir_vec(b, src, 4));
|
||||
|
||||
nir_tex_instr_add_src(tex, nir_tex_src_backend1,
|
||||
nir_vec(b, src, 4));
|
||||
if (src_comps > 4) {
|
||||
num_backend_srcs = 2;
|
||||
tex->src[1].src_type = nir_tex_src_backend2;
|
||||
nir_src_rewrite(&tex->src[1].src, nir_vec(b, src + 4, 4));
|
||||
nir_tex_instr_add_src(tex, nir_tex_src_backend2,
|
||||
nir_vec(b, src + 4, 4));
|
||||
}
|
||||
} else {
|
||||
unreachable("Unsupported shader model");
|
||||
}
|
||||
|
||||
/* Remove any extras */
|
||||
while (tex->num_srcs > num_backend_srcs)
|
||||
nir_tex_instr_remove_src(tex, tex->num_srcs - 1);
|
||||
|
||||
tex->sampler_dim = remap_sampler_dim(tex->sampler_dim);
|
||||
|
||||
struct nak_nir_tex_flags flags = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue