summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2014-09-19 13:19:21 -0600
committerBrian Paul <brianp@vmware.com>2014-09-22 16:56:24 -0600
commit6581aa441eef8fafc49a8770a0d82cf9d99b39b5 (patch)
tree8f773e26d445245d256e49e85123fa59049588ca
parentd77c0a2b52a4b9572bf09ee31a5f138b054dd5b1 (diff)
draw: use tgsi transform prolog/epilog callbacks in AA line code
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c182
1 files changed, 92 insertions, 90 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 8955762ce2..c8344dd427 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -140,7 +140,6 @@ struct aa_transform_context {
int freeSampler; /** an available sampler for the pstipple */
int maxInput, maxGeneric; /**< max input index found */
int colorTemp, texTemp; /**< temp registers */
- boolean firstInstruction;
};
@@ -197,80 +196,80 @@ free_bit(uint bitfield)
/**
- * TGSI instruction transform callback.
- * Replace writes to result.color w/ a temp reg.
- * Upon END instruction, insert texture sampling code for antialiasing.
+ * TGSI transform prolog callback.
*/
static void
-aa_transform_inst(struct tgsi_transform_context *ctx,
- struct tgsi_full_instruction *inst)
+aa_transform_prolog(struct tgsi_transform_context *ctx)
{
struct aa_transform_context *aactx = (struct aa_transform_context *) ctx;
+ struct tgsi_full_declaration decl;
+ uint i;
- if (aactx->firstInstruction) {
- /* emit our new declarations before the first instruction */
-
- struct tgsi_full_declaration decl;
- uint i;
-
- /* find free sampler */
- aactx->freeSampler = free_bit(aactx->samplersUsed);
- if (aactx->freeSampler >= PIPE_MAX_SAMPLERS)
- aactx->freeSampler = PIPE_MAX_SAMPLERS - 1;
-
- /* find two free temp regs */
- for (i = 0; i < 32; i++) {
- if ((aactx->tempsUsed & (1 << i)) == 0) {
- /* found a free temp */
- if (aactx->colorTemp < 0)
- aactx->colorTemp = i;
- else if (aactx->texTemp < 0)
- aactx->texTemp = i;
- else
- break;
- }
+ /* find free sampler */
+ aactx->freeSampler = free_bit(aactx->samplersUsed);
+ if (aactx->freeSampler >= PIPE_MAX_SAMPLERS)
+ aactx->freeSampler = PIPE_MAX_SAMPLERS - 1;
+
+ /* find two free temp regs */
+ for (i = 0; i < 32; i++) {
+ if ((aactx->tempsUsed & (1 << i)) == 0) {
+ /* found a free temp */
+ if (aactx->colorTemp < 0)
+ aactx->colorTemp = i;
+ else if (aactx->texTemp < 0)
+ aactx->texTemp = i;
+ else
+ break;
}
- assert(aactx->colorTemp >= 0);
- assert(aactx->texTemp >= 0);
-
- /* declare new generic input/texcoord */
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_INPUT;
- /* XXX this could be linear... */
- decl.Declaration.Interpolate = 1;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = TGSI_SEMANTIC_GENERIC;
- decl.Semantic.Index = aactx->maxGeneric + 1;
- decl.Range.First =
- decl.Range.Last = aactx->maxInput + 1;
- decl.Interp.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE;
- ctx->emit_declaration(ctx, &decl);
-
- /* declare new sampler */
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_SAMPLER;
- decl.Range.First =
- decl.Range.Last = aactx->freeSampler;
- ctx->emit_declaration(ctx, &decl);
-
- /* declare new temp regs */
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.Range.First =
- decl.Range.Last = aactx->texTemp;
- ctx->emit_declaration(ctx, &decl);
-
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.Range.First =
- decl.Range.Last = aactx->colorTemp;
- ctx->emit_declaration(ctx, &decl);
-
- aactx->firstInstruction = FALSE;
}
+ assert(aactx->colorTemp >= 0);
+ assert(aactx->texTemp >= 0);
+
+ /* declare new generic input/texcoord */
+ decl = tgsi_default_full_declaration();
+ decl.Declaration.File = TGSI_FILE_INPUT;
+ /* XXX this could be linear... */
+ decl.Declaration.Interpolate = 1;
+ decl.Declaration.Semantic = 1;
+ decl.Semantic.Name = TGSI_SEMANTIC_GENERIC;
+ decl.Semantic.Index = aactx->maxGeneric + 1;
+ decl.Range.First =
+ decl.Range.Last = aactx->maxInput + 1;
+ decl.Interp.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE;
+ ctx->emit_declaration(ctx, &decl);
+
+ /* declare new sampler */
+ decl = tgsi_default_full_declaration();
+ decl.Declaration.File = TGSI_FILE_SAMPLER;
+ decl.Range.First =
+ decl.Range.Last = aactx->freeSampler;
+ ctx->emit_declaration(ctx, &decl);
+
+ /* declare new temp regs */
+ decl = tgsi_default_full_declaration();
+ decl.Declaration.File = TGSI_FILE_TEMPORARY;
+ decl.Range.First =
+ decl.Range.Last = aactx->texTemp;
+ ctx->emit_declaration(ctx, &decl);
+
+ decl = tgsi_default_full_declaration();
+ decl.Declaration.File = TGSI_FILE_TEMPORARY;
+ decl.Range.First =
+ decl.Range.Last = aactx->colorTemp;
+ ctx->emit_declaration(ctx, &decl);
+}
+
- if (inst->Instruction.Opcode == TGSI_OPCODE_END &&
- aactx->colorOutput != -1) {
+/**
+ * TGSI transform epilog callback.
+ */
+static void
+aa_transform_epilog(struct tgsi_transform_context *ctx)
+{
+ struct aa_transform_context *aactx = (struct aa_transform_context *) ctx;
+
+ if (aactx->colorOutput != -1) {
+ /* insert texture sampling code for antialiasing. */
struct tgsi_full_instruction newInst;
/* TEX */
@@ -286,7 +285,6 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst.Src[0].Register.Index = aactx->maxInput + 1;
newInst.Src[1].Register.File = TGSI_FILE_SAMPLER;
newInst.Src[1].Register.Index = aactx->freeSampler;
-
ctx->emit_instruction(ctx, &newInst);
/* MOV rgb */
@@ -314,31 +312,34 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
newInst.Src[1].Register.Index = aactx->texTemp;
ctx->emit_instruction(ctx, &newInst);
-
- /* END */
- newInst = tgsi_default_full_instruction();
- newInst.Instruction.Opcode = TGSI_OPCODE_END;
- newInst.Instruction.NumDstRegs = 0;
- newInst.Instruction.NumSrcRegs = 0;
- ctx->emit_instruction(ctx, &newInst);
}
- else {
- /* Not an END instruction.
- * Look for writes to result.color and replace with colorTemp reg.
- */
- uint i;
+}
- for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
- struct tgsi_full_dst_register *dst = &inst->Dst[i];
- if (dst->Register.File == TGSI_FILE_OUTPUT &&
- dst->Register.Index == aactx->colorOutput) {
- dst->Register.File = TGSI_FILE_TEMPORARY;
- dst->Register.Index = aactx->colorTemp;
- }
- }
- ctx->emit_instruction(ctx, inst);
+/**
+ * TGSI instruction transform callback.
+ * Replace writes to result.color w/ a temp reg.
+ */
+static void
+aa_transform_inst(struct tgsi_transform_context *ctx,
+ struct tgsi_full_instruction *inst)
+{
+ struct aa_transform_context *aactx = (struct aa_transform_context *) ctx;
+ uint i;
+
+ /*
+ * Look for writes to result.color and replace with colorTemp reg.
+ */
+ for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
+ struct tgsi_full_dst_register *dst = &inst->Dst[i];
+ if (dst->Register.File == TGSI_FILE_OUTPUT &&
+ dst->Register.Index == aactx->colorOutput) {
+ dst->Register.File = TGSI_FILE_TEMPORARY;
+ dst->Register.Index = aactx->colorTemp;
+ }
}
+
+ ctx->emit_instruction(ctx, inst);
}
@@ -366,7 +367,8 @@ generate_aaline_fs(struct aaline_stage *aaline)
transform.maxGeneric = -1;
transform.colorTemp = -1;
transform.texTemp = -1;
- transform.firstInstruction = TRUE;
+ transform.base.prolog = aa_transform_prolog;
+ transform.base.epilog = aa_transform_epilog;
transform.base.transform_instruction = aa_transform_inst;
transform.base.transform_declaration = aa_transform_decl;