diff options
author | Roland Scheidegger <[email protected]> | 2013-02-15 03:15:43 +0100 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2013-02-16 02:40:59 +0100 |
commit | f1ab67c13ab97f19c08d99c6ba101edc7d7b80e6 (patch) | |
tree | f6f4833be3ab74527a90daa15893b6fff716b582 /src/gallium/auxiliary/tgsi | |
parent | cb2e6782945d5ea6cc26f3f47d6ee04f48caf529 (diff) |
gallivm/tgsi: fix issues with sample opcodes
We need to encode them as Texture instructions since the NumOffsets field
is encoded there. However, we don't encode the actual target in there, this
is derived from the sampler view src later.
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_info.c | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h | 38 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_text.c | 11 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_ureg.h | 119 |
4 files changed, 160 insertions, 10 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index 9c6fdfcd278..8ae5523527c 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -185,7 +185,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 1, 3, 0, 0, 0, 0, OTHR, "SAMPLE", TGSI_OPCODE_SAMPLE }, { 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_I", TGSI_OPCODE_SAMPLE_I }, - { 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_I_MS", TGSI_OPCODE_SAMPLE_I_MS }, + { 1, 3, 0, 0, 0, 0, OTHR, "SAMPLE_I_MS", TGSI_OPCODE_SAMPLE_I_MS }, { 1, 4, 0, 0, 0, 0, OTHR, "SAMPLE_B", TGSI_OPCODE_SAMPLE_B }, { 1, 4, 0, 0, 0, 0, OTHR, "SAMPLE_C", TGSI_OPCODE_SAMPLE_C }, { 1, 4, 0, 0, 0, 0, OTHR, "SAMPLE_C_LZ", TGSI_OPCODE_SAMPLE_C_LZ }, diff --git a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h index 4a1b811b30b..fa30352fad8 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h +++ b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h @@ -32,6 +32,22 @@ #define OP14_TEX(a) OP14(a) #endif +#ifndef OP12_SAMPLE +#define OP12_SAMPLE(a) OP12(a) +#endif + +#ifndef OP13_SAMPLE +#define OP13_SAMPLE(a) OP13(a) +#endif + +#ifndef OP14_SAMPLE +#define OP14_SAMPLE(a) OP14(a) +#endif + +#ifndef OP15_SAMPLE +#define OP15_SAMPLE(a) OP15(a) +#endif + #ifndef OP00_LBL #define OP00_LBL(a) OP00(a) #endif @@ -169,15 +185,15 @@ OP01(CASE) OP00(DEFAULT) OP00(ENDSWITCH) -OP13(SAMPLE) -OP12(SAMPLE_I) -OP12(SAMPLE_I_MS) -OP14(SAMPLE_B) -OP14(SAMPLE_C) -OP14(SAMPLE_C_LZ) -OP15(SAMPLE_D) -OP14(SAMPLE_L) -OP13(GATHER4) +OP13_SAMPLE(SAMPLE) +OP12_SAMPLE(SAMPLE_I) +OP13_SAMPLE(SAMPLE_I_MS) +OP14_SAMPLE(SAMPLE_B) +OP14_SAMPLE(SAMPLE_C) +OP14_SAMPLE(SAMPLE_C_LZ) +OP15_SAMPLE(SAMPLE_D) +OP14_SAMPLE(SAMPLE_L) +OP13_SAMPLE(GATHER4) OP12(SVIEWINFO) OP13(SAMPLE_POS) OP12(SAMPLE_INFO) @@ -204,3 +220,7 @@ OP12(SAMPLE_INFO) #undef OP12_TEX #undef OP14_TEX +#undef OP12_SAMPLE +#undef OP13_SAMPLE +#undef OP14_SAMPLE +#undef OP15_SAMPLE diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 1267e79edb7..5abcb456387 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -941,6 +941,17 @@ parse_instruction( inst.Instruction.NumDstRegs = info->num_dst; inst.Instruction.NumSrcRegs = info->num_src; + if (i >= TGSI_OPCODE_SAMPLE && i <= TGSI_OPCODE_GATHER4) { + /* + * These are not considered tex opcodes here (no additional + * target argument) however we're required to set the Texture + * bit so we can set the number of tex offsets (offsets aren't + * actually handled here yet in any case). + */ + inst.Instruction.Texture = 1; + inst.Texture.Texture = TGSI_TEXTURE_UNKNOWN; + } + /* Parse instruction operands. */ for (i = 0; i < info->num_dst + info->num_src + info->is_tex; i++) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index e6131f25aae..fb663e9c07e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -719,6 +719,33 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ ureg_fixup_insn_size( ureg, insn.insn_token ); \ } +#define OP12_SAMPLE( op ) \ +static INLINE void ureg_##op( struct ureg_program *ureg, \ + struct ureg_dst dst, \ + struct ureg_src src0, \ + struct ureg_src src1 ) \ +{ \ + unsigned opcode = TGSI_OPCODE_##op; \ + unsigned target = TGSI_TEXTURE_UNKNOWN; \ + struct ureg_emit_insn_result insn; \ + insn = ureg_emit_insn(ureg, \ + opcode, \ + dst.Saturate, \ + dst.Predicate, \ + dst.PredNegate, \ + dst.PredSwizzleX, \ + dst.PredSwizzleY, \ + dst.PredSwizzleZ, \ + dst.PredSwizzleW, \ + 1, \ + 2); \ + ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ + ureg_emit_dst( ureg, dst ); \ + ureg_emit_src( ureg, src0 ); \ + ureg_emit_src( ureg, src1 ); \ + ureg_fixup_insn_size( ureg, insn.insn_token ); \ +} + #define OP13( op ) \ static INLINE void ureg_##op( struct ureg_program *ureg, \ struct ureg_dst dst, \ @@ -745,6 +772,35 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ ureg_fixup_insn_size( ureg, insn ); \ } +#define OP13_SAMPLE( op ) \ +static INLINE void ureg_##op( struct ureg_program *ureg, \ + struct ureg_dst dst, \ + struct ureg_src src0, \ + struct ureg_src src1, \ + struct ureg_src src2 ) \ +{ \ + unsigned opcode = TGSI_OPCODE_##op; \ + unsigned target = TGSI_TEXTURE_UNKNOWN; \ + struct ureg_emit_insn_result insn; \ + insn = ureg_emit_insn(ureg, \ + opcode, \ + dst.Saturate, \ + dst.Predicate, \ + dst.PredNegate, \ + dst.PredSwizzleX, \ + dst.PredSwizzleY, \ + dst.PredSwizzleZ, \ + dst.PredSwizzleW, \ + 1, \ + 3); \ + ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ + ureg_emit_dst( ureg, dst ); \ + ureg_emit_src( ureg, src0 ); \ + ureg_emit_src( ureg, src1 ); \ + ureg_emit_src( ureg, src2 ); \ + ureg_fixup_insn_size( ureg, insn.insn_token ); \ +} + #define OP14_TEX( op ) \ static INLINE void ureg_##op( struct ureg_program *ureg, \ struct ureg_dst dst, \ @@ -776,6 +832,37 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ ureg_fixup_insn_size( ureg, insn.insn_token ); \ } +#define OP14_SAMPLE( op ) \ +static INLINE void ureg_##op( struct ureg_program *ureg, \ + struct ureg_dst dst, \ + struct ureg_src src0, \ + struct ureg_src src1, \ + struct ureg_src src2, \ + struct ureg_src src3 ) \ +{ \ + unsigned opcode = TGSI_OPCODE_##op; \ + unsigned target = TGSI_TEXTURE_UNKNOWN; \ + struct ureg_emit_insn_result insn; \ + insn = ureg_emit_insn(ureg, \ + opcode, \ + dst.Saturate, \ + dst.Predicate, \ + dst.PredNegate, \ + dst.PredSwizzleX, \ + dst.PredSwizzleY, \ + dst.PredSwizzleZ, \ + dst.PredSwizzleW, \ + 1, \ + 4); \ + ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ + ureg_emit_dst( ureg, dst ); \ + ureg_emit_src( ureg, src0 ); \ + ureg_emit_src( ureg, src1 ); \ + ureg_emit_src( ureg, src2 ); \ + ureg_emit_src( ureg, src3 ); \ + ureg_fixup_insn_size( ureg, insn.insn_token ); \ +} + #define OP14( op ) \ static INLINE void ureg_##op( struct ureg_program *ureg, \ @@ -836,6 +923,38 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ ureg_fixup_insn_size( ureg, insn ); \ } +#define OP15_SAMPLE( op ) \ +static INLINE void ureg_##op( struct ureg_program *ureg, \ + struct ureg_dst dst, \ + struct ureg_src src0, \ + struct ureg_src src1, \ + struct ureg_src src2, \ + struct ureg_src src3, \ + struct ureg_src src4 ) \ +{ \ + unsigned opcode = TGSI_OPCODE_##op; \ + unsigned target = TGSI_TEXTURE_UNKNOWN; \ + struct ureg_emit_insn_result insn; \ + insn = ureg_emit_insn(ureg, \ + opcode, \ + dst.Saturate, \ + dst.Predicate, \ + dst.PredNegate, \ + dst.PredSwizzleX, \ + dst.PredSwizzleY, \ + dst.PredSwizzleZ, \ + dst.PredSwizzleW, \ + 1, \ + 5); \ + ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ + ureg_emit_dst( ureg, dst ); \ + ureg_emit_src( ureg, src0 ); \ + ureg_emit_src( ureg, src1 ); \ + ureg_emit_src( ureg, src2 ); \ + ureg_emit_src( ureg, src3 ); \ + ureg_emit_src( ureg, src4 ); \ + ureg_fixup_insn_size( ureg, insn.insn_token ); \ +} /* Use a template include to generate a correctly-typed ureg_OP() * function for each TGSI opcode: |