aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r300/compiler/radeon_program_alu.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-01-06 00:31:55 +0100
committerMarek Olšák <[email protected]>2013-01-06 14:44:12 +0100
commit25b3c0a52cb0834d683b99e141305424ea5695b6 (patch)
tree691245a38f2fffaa750a285deb6d503574984871 /src/gallium/drivers/r300/compiler/radeon_program_alu.c
parent2f358feda311570610729658cfc2897090c14327 (diff)
r300g/compiler: add shader emulation for the alpha_to_one state
Diffstat (limited to 'src/gallium/drivers/r300/compiler/radeon_program_alu.c')
-rw-r--r--src/gallium/drivers/r300/compiler/radeon_program_alu.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.c b/src/gallium/drivers/r300/compiler/radeon_program_alu.c
index f4ee86de5d0..4dc4250699e 100644
--- a/src/gallium/drivers/r300/compiler/radeon_program_alu.c
+++ b/src/gallium/drivers/r300/compiler/radeon_program_alu.c
@@ -1283,3 +1283,31 @@ void rc_transform_KILP(struct radeon_compiler * c, void *user)
}
}
}
+
+int rc_force_output_alpha_to_one(struct radeon_compiler *c,
+ struct rc_instruction *inst, void *data)
+{
+ struct r300_fragment_program_compiler *fragc = (struct r300_fragment_program_compiler*)c;
+ const struct rc_opcode_info *info = rc_get_opcode_info(inst->U.I.Opcode);
+ unsigned tmp;
+
+ if (!info->HasDstReg || inst->U.I.DstReg.File != RC_FILE_OUTPUT ||
+ inst->U.I.DstReg.Index == fragc->OutputDepth)
+ return 1;
+
+ tmp = rc_find_free_temporary(c);
+
+ /* Insert MOV after inst, set alpha to 1. */
+ emit1(c, inst, RC_OPCODE_MOV, 0, inst->U.I.DstReg,
+ srcregswz(RC_FILE_TEMPORARY, tmp, RC_SWIZZLE_XYZ1));
+
+ /* Re-route the destination of inst to the source of mov. */
+ inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst->U.I.DstReg.Index = tmp;
+
+ /* Move the saturate output modifier to the MOV instruction
+ * (for better copy propagation). */
+ inst->Next->U.I.SaturateMode = inst->U.I.SaturateMode;
+ inst->U.I.SaturateMode = RC_SATURATE_NONE;
+ return 1;
+}