summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/r600/r600_shader.c
diff options
context:
space:
mode:
authorTilman Sauerbeck <tilman@code-monkey.de>2011-01-06 21:35:19 +0100
committerTilman Sauerbeck <tilman@code-monkey.de>2011-01-11 22:37:01 +0100
commit242205404d24f04f9abe1cfa01b9cf0f9e4f9d07 (patch)
treeaaf3af5aa2c34b43a28e069bccd72fd1b4704db3 /src/gallium/drivers/r600/r600_shader.c
parentca8960234e0a727f46fcf8af1a9b7fa2ff0451dd (diff)
r600g: Fixed SIN/COS/SCS for the case where the operand is a literal.
Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de> Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
Diffstat (limited to 'src/gallium/drivers/r600/r600_shader.c')
-rw-r--r--src/gallium/drivers/r600/r600_shader.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 51ff7db361..a2fec20505 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -952,7 +952,7 @@ static int tgsi_setup_trig(struct r600_shader_ctx *ctx,
struct r600_bc_alu_src r600_src[3])
{
struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
- int r;
+ int r, src0_chan;
uint32_t lit_vals[4];
struct r600_bc_alu alu;
@@ -964,6 +964,19 @@ static int tgsi_setup_trig(struct r600_shader_ctx *ctx,
if (r)
return r;
+ src0_chan = tgsi_chan(&inst->Src[0], 0);
+
+ /* We are going to feed two literals to the MAD below,
+ * which means that if the first operand is a literal as well,
+ * we need to copy its value manually.
+ */
+ if (r600_src[0].sel == V_SQ_ALU_SRC_LITERAL) {
+ unsigned index = inst->Src[0].Register.Index;
+
+ lit_vals[2] = ctx->literals[index * 4 + src0_chan];
+ src0_chan = 2;
+ }
+
lit_vals[0] = fui(1.0 /(3.1415926535 * 2));
lit_vals[1] = fui(0.5f);
@@ -976,7 +989,7 @@ static int tgsi_setup_trig(struct r600_shader_ctx *ctx,
alu.dst.write = 1;
alu.src[0] = r600_src[0];
- alu.src[0].chan = tgsi_chan(&inst->Src[0], 0);
+ alu.src[0].chan = src0_chan;
alu.src[1].sel = V_SQ_ALU_SRC_LITERAL;
alu.src[1].chan = 0;