summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c56
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h35
2 files changed, 69 insertions, 22 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 8cb574ea439..1ef16d144c3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -29,6 +29,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "tgsi/tgsi_ureg.h"
+#include "tgsi/tgsi_build.h"
#include "tgsi/tgsi_info.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_sanity.h"
@@ -46,7 +47,6 @@ union tgsi_any_token {
struct tgsi_immediate imm;
union tgsi_immediate_data imm_data;
struct tgsi_instruction insn;
- struct tgsi_instruction_ext_nv insn_ext_nv;
struct tgsi_instruction_ext_label insn_ext_label;
struct tgsi_instruction_ext_texture insn_ext_texture;
struct tgsi_instruction_ext_predicate insn_ext_predicate;
@@ -54,9 +54,7 @@ union tgsi_any_token {
struct tgsi_src_register_ext_mod src_ext_mod;
struct tgsi_dimension dim;
struct tgsi_dst_register dst;
- struct tgsi_dst_register_ext_concode dst_ext_code;
struct tgsi_dst_register_ext_modulate dst_ext_mod;
- struct tgsi_dst_register_ext_predicate dst_ext_pred;
unsigned value;
};
@@ -74,6 +72,7 @@ struct ureg_tokens {
#define UREG_MAX_IMMEDIATE 32
#define UREG_MAX_TEMP 256
#define UREG_MAX_ADDR 2
+#define UREG_MAX_PRED 1
#define DOMAIN_DECL 0
#define DOMAIN_INSN 1
@@ -117,6 +116,7 @@ struct ureg_program
unsigned nr_constant_ranges;
unsigned nr_addrs;
+ unsigned nr_preds;
unsigned nr_instructions;
struct ureg_tokens domain[2];
@@ -416,6 +416,19 @@ struct ureg_dst ureg_DECL_address( struct ureg_program *ureg )
return ureg_dst_register( TGSI_FILE_ADDRESS, 0 );
}
+/* Allocate a new predicate register.
+ */
+struct ureg_dst
+ureg_DECL_predicate(struct ureg_program *ureg)
+{
+ if (ureg->nr_preds < UREG_MAX_PRED) {
+ return ureg_dst_register(TGSI_FILE_PREDICATE, ureg->nr_preds++);
+ }
+
+ assert(0);
+ return ureg_dst_register(TGSI_FILE_PREDICATE, 0);
+}
+
/* Allocate a new sampler.
*/
struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg,
@@ -631,14 +644,16 @@ unsigned
ureg_emit_insn(struct ureg_program *ureg,
unsigned opcode,
boolean saturate,
+ boolean predicate,
unsigned num_dst,
unsigned num_src )
{
union tgsi_any_token *out;
+ uint count = predicate ? 2 : 1;
validate( opcode, num_dst, num_src );
- out = get_tokens( ureg, DOMAIN_INSN, 1 );
+ out = get_tokens( ureg, DOMAIN_INSN, count );
out[0].value = 0;
out[0].insn.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
out[0].insn.NrTokens = 0;
@@ -647,11 +662,17 @@ ureg_emit_insn(struct ureg_program *ureg,
out[0].insn.NumDstRegs = num_dst;
out[0].insn.NumSrcRegs = num_src;
out[0].insn.Padding = 0;
- out[0].insn.Extended = 0;
-
+
+ if (predicate) {
+ out[0].insn.Extended = 1;
+ out[1].insn_ext_predicate = tgsi_default_instruction_ext_predicate();
+ } else {
+ out[0].insn.Extended = 0;
+ }
+
ureg->nr_instructions++;
- return ureg->domain[DOMAIN_INSN].count - 1;
+ return ureg->domain[DOMAIN_INSN].count - count;
}
@@ -739,10 +760,12 @@ ureg_insn(struct ureg_program *ureg,
{
unsigned insn, i;
boolean saturate;
+ boolean predicate;
saturate = nr_dst ? dst[0].Saturate : FALSE;
+ predicate = nr_dst ? dst[0].Predicate : FALSE;
- insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src );
+ insn = ureg_emit_insn( ureg, opcode, saturate, predicate, nr_dst, nr_src );
for (i = 0; i < nr_dst; i++)
ureg_emit_dst( ureg, dst[i] );
@@ -764,12 +787,14 @@ ureg_tex_insn(struct ureg_program *ureg,
{
unsigned insn, i;
boolean saturate;
+ boolean predicate;
saturate = nr_dst ? dst[0].Saturate : FALSE;
+ predicate = nr_dst ? dst[0].Predicate : FALSE;
- insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src );
+ insn = ureg_emit_insn( ureg, opcode, saturate, predicate, nr_dst, nr_src );
- ureg_emit_texture( ureg, insn, target ); \
+ ureg_emit_texture( ureg, insn, target );
for (i = 0; i < nr_dst; i++)
ureg_emit_dst( ureg, dst[i] );
@@ -790,9 +815,9 @@ ureg_label_insn(struct ureg_program *ureg,
{
unsigned insn, i;
- insn = ureg_emit_insn( ureg, opcode, FALSE, 0, nr_src );
+ insn = ureg_emit_insn( ureg, opcode, FALSE, FALSE, 0, nr_src );
- ureg_emit_label( ureg, insn, label_token ); \
+ ureg_emit_label( ureg, insn, label_token );
for (i = 0; i < nr_src; i++)
ureg_emit_src( ureg, src[i] );
@@ -929,6 +954,13 @@ static void emit_decls( struct ureg_program *ureg )
0, ureg->nr_addrs );
}
+ if (ureg->nr_preds) {
+ emit_decl_range(ureg,
+ TGSI_FILE_PREDICATE,
+ 0,
+ ureg->nr_preds);
+ }
+
for (i = 0; i < ureg->nr_immediates; i++) {
emit_immediate( ureg,
ureg->immediate[i].v );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index f04f443b9e7..36c0bd2dcf4 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -67,6 +67,7 @@ struct ureg_dst
unsigned WriteMask : 4; /* TGSI_WRITEMASK_ */
unsigned Indirect : 1; /* BOOL */
unsigned Saturate : 1; /* BOOL */
+ unsigned Predicate : 1;
int Index : 16; /* SINT */
unsigned Pad1 : 5;
unsigned Pad2 : 1; /* BOOL */
@@ -153,6 +154,9 @@ ureg_release_temporary( struct ureg_program *ureg,
struct ureg_dst
ureg_DECL_address( struct ureg_program * );
+struct ureg_dst
+ureg_DECL_predicate(struct ureg_program *);
+
/* Supply an index to the sampler declaration as this is the hook to
* the external pipe_sampler state. Users of this function probably
* don't want just any sampler, but a specific one which they've set
@@ -270,6 +274,7 @@ unsigned
ureg_emit_insn(struct ureg_program *ureg,
unsigned opcode,
boolean saturate,
+ boolean predicate,
unsigned num_dst,
unsigned num_src );
@@ -300,7 +305,7 @@ ureg_fixup_insn_size(struct ureg_program *ureg,
static INLINE void ureg_##op( struct ureg_program *ureg ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 0 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, FALSE, 0, 0 );\
ureg_fixup_insn_size( ureg, insn ); \
}
@@ -309,7 +314,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 1 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, FALSE, 0, 1 );\
ureg_emit_src( ureg, src ); \
ureg_fixup_insn_size( ureg, insn ); \
}
@@ -319,7 +324,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
unsigned *label_token ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 0 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, FALSE, 0, 0 );\
ureg_emit_label( ureg, insn, label_token ); \
ureg_fixup_insn_size( ureg, insn ); \
}
@@ -330,7 +335,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
unsigned *label_token ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 1 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, FALSE, 0, 1 );\
ureg_emit_label( ureg, insn, label_token ); \
ureg_emit_src( ureg, src ); \
ureg_fixup_insn_size( ureg, insn ); \
@@ -341,7 +346,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_dst dst ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 0 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, dst.Predicate, 1, 0 );\
ureg_emit_dst( ureg, dst ); \
ureg_fixup_insn_size( ureg, insn ); \
}
@@ -353,7 +358,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 1 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, dst.Predicate, 1, 1 );\
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src ); \
ureg_fixup_insn_size( ureg, insn ); \
@@ -366,7 +371,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src1 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 2 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, dst.Predicate, 1, 2 );\
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
@@ -381,7 +386,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src1 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 2 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, dst.Predicate, 1, 2 );\
ureg_emit_texture( ureg, insn, target ); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
@@ -397,7 +402,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src2 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 3 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, dst.Predicate, 1, 3 );\
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
@@ -415,7 +420,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src3 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 4 ); \
+ unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, dst.Predicate, 1, 4 );\
ureg_emit_texture( ureg, insn, target ); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
@@ -497,6 +502,14 @@ ureg_saturate( struct ureg_dst reg )
return reg;
}
+static INLINE struct ureg_dst
+ureg_predicate(struct ureg_dst reg)
+{
+ assert(reg.File != TGSI_FILE_NULL);
+ reg.Predicate = 1;
+ return reg;
+}
+
static INLINE struct ureg_dst
ureg_dst_indirect( struct ureg_dst reg, struct ureg_src addr )
{
@@ -530,6 +543,7 @@ ureg_dst( struct ureg_src src )
dst.IndirectIndex = src.IndirectIndex;
dst.IndirectSwizzle = src.IndirectSwizzle;
dst.Saturate = 0;
+ dst.Predicate = 0;
dst.Index = src.Index;
dst.Pad1 = 0;
dst.Pad2 = 0;
@@ -571,6 +585,7 @@ ureg_dst_undef( void )
dst.IndirectIndex = 0;
dst.IndirectSwizzle = 0;
dst.Saturate = 0;
+ dst.Predicate = 0;
dst.Index = 0;
dst.Pad1 = 0;
dst.Pad2 = 0;