summaryrefslogtreecommitdiff
path: root/src/mesa/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c1
-rw-r--r--src/mesa/shader/slang/slang_emit.c37
-rw-r--r--src/mesa/shader/slang/slang_ir.h3
3 files changed, 40 insertions, 1 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index a2be043542..0f7a5a4cb6 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -84,6 +84,7 @@ static slang_asm_info AsmInfo[] = {
{ "vec4_floor", IR_FLOOR, 1, 1 },
{ "vec4_frac", IR_FRAC, 1, 1 },
{ "vec4_abs", IR_ABS, 1, 1 },
+ { "vec4_neg", IR_NEG, 1, 1 },
/* float binary op */
{ "float_add", IR_ADD, 1, 2 },
{ "float_subtract", IR_SUB, 1, 2 },
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 39f470046b..cc522131ce 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -78,6 +78,7 @@ static slang_ir_info IrInfo[] = {
{ IR_FLOOR, "IR_FLOOR", OPCODE_FLR, 4, 1 },
{ IR_FRAC, "IR_FRAC", OPCODE_FRC, 4, 1 },
{ IR_ABS, "IR_ABS", OPCODE_ABS, 4, 1 },
+ { IR_NEG, "IR_NEG", OPCODE_NOP, 4, 1 }, /* XXX fix!!!! */
{ IR_SIN, "IR_SIN", OPCODE_SIN, 1, 1 },
{ IR_COS, "IR_COS", OPCODE_COS, 1, 1 },
/* other */
@@ -937,6 +938,40 @@ emit_unop(slang_gen_context *gc, slang_ir_node *n, struct gl_program *prog)
static struct prog_instruction *
+emit_negation(slang_gen_context *gc, slang_ir_node *n, struct gl_program *prog)
+{
+#if 0
+ struct prog_instruction *inst;
+ const slang_ir_info *info = slang_find_ir_info(n->Opcode);
+ assert(info);
+
+ assert(info->NumParams == 1);
+
+ emit(gc, n->Children[0], prog);
+
+ inst = new_instruction(prog, info->InstOpcode);
+ /*slang_resolve_storage(gc, n, prog);*/
+
+ if (!n->Store)
+ slang_alloc_temp_storage(gc, n, info->ResultSize);
+
+ storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
+
+ storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store,
+ n->Children[0]->Swizzle);
+
+ inst->Comment = n->Comment;
+
+ return inst;
+#endif
+ /* XXX this is something we can optimize for, with a bit of work.*/
+ abort();
+ return NULL;
+#endif
+}
+
+
+static struct prog_instruction *
emit_label(const char *target, struct gl_program *prog)
{
struct prog_instruction *inst;
@@ -1084,6 +1119,8 @@ emit(slang_gen_context *gc, slang_ir_node *n, struct gl_program *prog)
case IR_SIN:
case IR_COS:
return emit_unop(gc, n, prog);
+ case IR_NEG:
+ return emit_negation(gc, n, prog):
case IR_LABEL:
return emit_label(n->Target, prog);
case IR_FLOAT:
diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h
index 188d7d96d3..7c5e044861 100644
--- a/src/mesa/shader/slang/slang_ir.h
+++ b/src/mesa/shader/slang/slang_ir.h
@@ -72,7 +72,8 @@ typedef enum
IR_RCP, /* recipricol */
IR_FLOOR,
IR_FRAC,
- IR_ABS,
+ IR_ABS, /* absolute value */
+ IR_NEG, /* negate */
IR_SIN, /* sine */
IR_COS, /* cosine */
IR_NOT, /* logical not */