tgsi_to_nir: translate TG4

Tested-by: David Heidelberg <david@ixit.cz>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28349>
This commit is contained in:
Marek Olšák 2024-03-22 18:31:12 -04:00
parent 96ee0d6711
commit 5c543f4a02

View file

@ -97,6 +97,7 @@ struct ttn_compile {
bool cap_samplers_as_deref;
bool cap_integers;
bool cap_compact_arrays;
bool cap_tg4_component_in_swizzle;
};
#define ttn_swizzle(b, src, x, y, z, w) \
@ -1229,6 +1230,13 @@ ttn_tex(struct ttn_compile *c, nir_def **src)
op = nir_texop_lod;
num_srcs = 1;
break;
case TGSI_OPCODE_TG4:
/* TODO: Shadow cube samplers unsupported. */
assert(tgsi_inst->Texture.Texture != TGSI_TEXTURE_SHADOWCUBE_ARRAY);
op = nir_texop_tg4;
num_srcs = 1;
samp = 2;
break;
default:
fprintf(stderr, "unknown TGSI tex op %d\n", tgsi_inst->Instruction.Opcode);
@ -1362,6 +1370,13 @@ ttn_tex(struct ttn_compile *c, nir_def **src)
src_number++;
}
if (tgsi_inst->Instruction.Opcode == TGSI_OPCODE_TG4) {
if (c->cap_tg4_component_in_swizzle)
instr->component = tgsi_inst->Src[samp].Register.SwizzleX;
else
instr->component = nir_scalar_as_uint(nir_scalar_resolved(src[1], 0));
}
if (instr->is_shadow) {
if (instr->coord_components == 4)
instr->src[src_number].src = nir_src_for_ssa(ttn_channel(b, src[1], X));
@ -2192,6 +2207,8 @@ ttn_read_pipe_caps(struct ttn_compile *c,
c->cap_point_is_sysval = screen->get_param(screen, PIPE_CAP_FS_POINT_IS_SYSVAL);
c->cap_integers = screen->get_shader_param(screen, c->scan->processor, PIPE_SHADER_CAP_INTEGERS);
c->cap_compact_arrays = screen->get_param(screen, PIPE_CAP_NIR_COMPACT_ARRAYS);
c->cap_tg4_component_in_swizzle =
screen->get_param(screen, PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE);
}
#define BITSET_SET32(bitset, u32_mask) do { \