#endif
}
-unsigned
+struct ureg_emit_insn_result
ureg_emit_insn(struct ureg_program *ureg,
unsigned opcode,
boolean saturate,
{
union tgsi_any_token *out;
uint count = predicate ? 2 : 1;
+ struct ureg_emit_insn_result result;
validate( opcode, num_dst, num_src );
out[0].insn.NumSrcRegs = num_src;
out[0].insn.Padding = 0;
+ result.insn_token = ureg->domain[DOMAIN_INSN].count - count;
+
if (predicate) {
out[0].insn.Extended = 1;
out[1].insn_ext_predicate = tgsi_default_instruction_ext_predicate();
out[1].insn_ext_predicate.SwizzleY = pred_swizzle_y;
out[1].insn_ext_predicate.SwizzleZ = pred_swizzle_z;
out[1].insn_ext_predicate.SwizzleW = pred_swizzle_w;
+
+ result.extended_token = result.insn_token + 1;
} else {
out[0].insn.Extended = 0;
+
+ result.extended_token = result.insn_token;
}
ureg->nr_instructions++;
- return ureg->domain[DOMAIN_INSN].count - count;
+ return result;
}
void
ureg_emit_label(struct ureg_program *ureg,
- unsigned insn_token,
+ unsigned extended_token,
unsigned *label_token )
{
union tgsi_any_token *out, *insn;
return;
out = get_tokens( ureg, DOMAIN_INSN, 1 );
- insn = retrieve_token( ureg, DOMAIN_INSN, insn_token );
+ insn = retrieve_token( ureg, DOMAIN_INSN, extended_token );
- insn->insn.Extended = 1;
+ insn->token.Extended = 1;
out[0].value = 0;
out[0].insn_ext_label.Type = TGSI_INSTRUCTION_EXT_TYPE_LABEL;
void
ureg_emit_texture(struct ureg_program *ureg,
- unsigned insn_token,
+ unsigned extended_token,
unsigned target )
{
union tgsi_any_token *out, *insn;
out = get_tokens( ureg, DOMAIN_INSN, 1 );
- insn = retrieve_token( ureg, DOMAIN_INSN, insn_token );
+ insn = retrieve_token( ureg, DOMAIN_INSN, extended_token );
- insn->insn.Extended = 1;
+ insn->token.Extended = 1;
out[0].value = 0;
out[0].insn_ext_texture.Type = TGSI_INSTRUCTION_EXT_TYPE_TEXTURE;
const struct ureg_src *src,
unsigned nr_src )
{
- unsigned insn, i;
+ struct ureg_emit_insn_result insn;
+ unsigned i;
boolean saturate;
boolean predicate;
boolean negate;
for (i = 0; i < nr_src; i++)
ureg_emit_src( ureg, src[i] );
- ureg_fixup_insn_size( ureg, insn );
+ ureg_fixup_insn_size( ureg, insn.insn_token );
}
void
const struct ureg_src *src,
unsigned nr_src )
{
- unsigned insn, i;
+ struct ureg_emit_insn_result insn;
+ unsigned i;
boolean saturate;
boolean predicate;
boolean negate;
nr_dst,
nr_src);
- ureg_emit_texture( ureg, insn, target );
+ ureg_emit_texture( ureg, insn.extended_token, target );
for (i = 0; i < nr_dst; i++)
ureg_emit_dst( ureg, dst[i] );
for (i = 0; i < nr_src; i++)
ureg_emit_src( ureg, src[i] );
- ureg_fixup_insn_size( ureg, insn );
+ ureg_fixup_insn_size( ureg, insn.insn_token );
}
unsigned nr_src,
unsigned *label_token )
{
- unsigned insn, i;
+ struct ureg_emit_insn_result insn;
+ unsigned i;
insn = ureg_emit_insn(ureg,
opcode,
0,
nr_src);
- ureg_emit_label( ureg, insn, label_token );
+ ureg_emit_label( ureg, insn.extended_token, label_token );
for (i = 0; i < nr_src; i++)
ureg_emit_src( ureg, src[i] );
- ureg_fixup_insn_size( ureg, insn );
+ ureg_fixup_insn_size( ureg, insn.insn_token );
}
* Internal instruction helpers, don't call these directly:
*/
-unsigned
+struct ureg_emit_insn_result {
+ unsigned insn_token; /*< Used to fixup insn size. */
+ unsigned extended_token; /*< Used to set the Extended bit, usually the same as insn_token. */
+};
+
+struct ureg_emit_insn_result
ureg_emit_insn(struct ureg_program *ureg,
unsigned opcode,
boolean saturate,
TGSI_SWIZZLE_Z, \
TGSI_SWIZZLE_W, \
0, \
- 0); \
+ 0).insn_token; \
ureg_fixup_insn_size( ureg, insn ); \
}
TGSI_SWIZZLE_Z, \
TGSI_SWIZZLE_W, \
0, \
- 1); \
+ 1).insn_token; \
ureg_emit_src( ureg, src ); \
ureg_fixup_insn_size( ureg, insn ); \
}
unsigned *label_token ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn(ureg, \
- opcode, \
- FALSE, \
- FALSE, \
- FALSE, \
- TGSI_SWIZZLE_X, \
- TGSI_SWIZZLE_Y, \
- TGSI_SWIZZLE_Z, \
- TGSI_SWIZZLE_W, \
- 0, \
- 0); \
- ureg_emit_label( ureg, insn, label_token ); \
- ureg_fixup_insn_size( ureg, insn ); \
+ struct ureg_emit_insn_result insn; \
+ insn = ureg_emit_insn(ureg, \
+ opcode, \
+ FALSE, \
+ FALSE, \
+ FALSE, \
+ TGSI_SWIZZLE_X, \
+ TGSI_SWIZZLE_Y, \
+ TGSI_SWIZZLE_Z, \
+ TGSI_SWIZZLE_W, \
+ 0, \
+ 0); \
+ ureg_emit_label( ureg, insn.extended_token, label_token ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
}
#define OP01_LBL( op ) \
unsigned *label_token ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn(ureg, \
- opcode, \
- FALSE, \
- FALSE, \
- FALSE, \
- TGSI_SWIZZLE_X, \
- TGSI_SWIZZLE_Y, \
- TGSI_SWIZZLE_Z, \
- TGSI_SWIZZLE_W, \
- 0, \
- 1); \
- ureg_emit_label( ureg, insn, label_token ); \
+ struct ureg_emit_insn_result insn; \
+ insn = ureg_emit_insn(ureg, \
+ opcode, \
+ FALSE, \
+ FALSE, \
+ FALSE, \
+ TGSI_SWIZZLE_X, \
+ TGSI_SWIZZLE_Y, \
+ TGSI_SWIZZLE_Z, \
+ TGSI_SWIZZLE_W, \
+ 0, \
+ 1); \
+ ureg_emit_label( ureg, insn.extended_token, label_token ); \
ureg_emit_src( ureg, src ); \
- ureg_fixup_insn_size( ureg, insn ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
}
#define OP10( op ) \
dst.PredSwizzleZ, \
dst.PredSwizzleW, \
1, \
- 0); \
+ 0).insn_token; \
ureg_emit_dst( ureg, dst ); \
ureg_fixup_insn_size( ureg, insn ); \
}
dst.PredSwizzleZ, \
dst.PredSwizzleW, \
1, \
- 1); \
+ 1).insn_token; \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src ); \
ureg_fixup_insn_size( ureg, insn ); \
dst.PredSwizzleZ, \
dst.PredSwizzleW, \
1, \
- 2); \
+ 2).insn_token; \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
struct ureg_src src1 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned 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, target ); \
+ 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 ); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
- ureg_fixup_insn_size( ureg, insn ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
}
#define OP13( op ) \
dst.PredSwizzleZ, \
dst.PredSwizzleW, \
1, \
- 3); \
+ 3).insn_token; \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
struct ureg_src src3 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned 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, target ); \
+ 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 ); \
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 ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
}