[Freedreno] [PATCH] freedreno/ir3: add TXB2 support
Ilia Mirkin
imirkin at alum.mit.edu
Tue Sep 16 16:56:31 PDT 2014
Handles texture(samplerCubeShadow, bias), part of GLES3 and GL3
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
Perhaps some of that info should go into the tex info structure, but I'll hold
off for now. The generated code seemed reasonable:
0000[30245000x_00000000x] (sy)(ss)mov.f32f32 r0.x, c0.x
0001[20244001x_00000001x] mov.f32f32 r0.y, c0.y
0002[20244002x_00000002x] mov.f32f32 r0.z, c0.z
0003[20244003x_00000003x] mov.f32f32 r0.w, c0.w
0006[20244004x_00000004x] mov.f32f32 r1.x, c1.x
0008[a1051300x_00000801x] samb.3d.s (f32)(xy)r0.x, r0.x, r1.x, s#0, t#0
The tex-miplevel-selection 'texture(bias)' piglit should hit this case.
src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
index 35550e6..a0657aa 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
@@ -1130,6 +1130,7 @@ fill_tex_info(struct ir3_compile_context *ctx,
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_TXB:
+ case TGSI_OPCODE_TXB2:
case TGSI_OPCODE_TXL:
info->args = 2;
break;
@@ -1254,14 +1255,20 @@ trans_samp(const struct instr_translater *t,
{
struct ir3_instruction *instr;
struct tgsi_dst_register *dst = &inst->Dst[0].Register;
- struct tgsi_src_register *orig = &inst->Src[0].Register;
- struct tgsi_src_register *coord;
- struct tgsi_src_register *samp = &inst->Src[1].Register;
+ struct tgsi_src_register *orig, *coord, *samp;
struct tex_info tinf;
memset(&tinf, 0, sizeof(tinf));
fill_tex_info(ctx, inst, &tinf);
coord = get_tex_coord(ctx, inst, &tinf);
+
+ if (inst->Instruction.Opcode == TGSI_OPCODE_TXB2) {
+ orig = &inst->Src[1].Register;
+ samp = &inst->Src[2].Register;
+ } else {
+ orig = &inst->Src[0].Register;
+ samp = &inst->Src[1].Register;
+ }
if (tinf.args > 1 && is_rel_or_const(orig))
orig = get_unconst(ctx, orig);
@@ -1274,7 +1281,9 @@ trans_samp(const struct instr_translater *t,
add_dst_reg_wrmask(ctx, instr, dst, 0, dst->WriteMask);
add_src_reg_wrmask(ctx, instr, coord, coord->SwizzleX, tinf.src_wrmask);
- if (tinf.args > 1)
+ if (inst->Instruction.Opcode == TGSI_OPCODE_TXB2)
+ add_src_reg_wrmask(ctx, instr, orig, orig->SwizzleX, 0x1);
+ else if (tinf.args > 1)
add_src_reg_wrmask(ctx, instr, orig, orig->SwizzleW, 0x1);
}
@@ -2338,6 +2347,7 @@ static const struct instr_translater translaters[TGSI_OPCODE_LAST] = {
INSTR(TEX, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TEX),
INSTR(TXP, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TXP),
INSTR(TXB, trans_samp, .opc = OPC_SAMB, .arg = TGSI_OPCODE_TXB),
+ INSTR(TXB2, trans_samp, .opc = OPC_SAMB, .arg = TGSI_OPCODE_TXB2),
INSTR(TXL, trans_samp, .opc = OPC_SAML, .arg = TGSI_OPCODE_TXL),
INSTR(TXQ, trans_txq),
INSTR(DDX, trans_deriv, .opc = OPC_DSX),
--
1.8.5.5
More information about the Freedreno
mailing list