diff options
author | Brian <[email protected]> | 2006-12-22 10:18:50 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2006-12-22 10:18:50 -0700 |
commit | aa710c3e6b17a4af54f2243de8888da4844d5c75 (patch) | |
tree | b757f48473322fc330e9248b0e10673f8e82b73d /src | |
parent | 9b694589e9c47a777ce9f7fab6e4ef90d3c94c80 (diff) |
implement unary +, -
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 13 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 27 |
2 files changed, 19 insertions, 21 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 0f7a5a4cb69..3fca45ce121 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -84,7 +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 }, + { "vec4_negate", IR_NEG, 1, 1 }, /* float binary op */ { "float_add", IR_ADD, 1, 2 }, { "float_subtract", IR_SUB, 1, 2 }, @@ -1426,7 +1426,16 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper) n = _slang_gen_function_call_name(A, "/", oper, NULL); return n; } - + case slang_oper_minus: + { + slang_ir_node *n; + assert(oper->num_children == 1); + n = _slang_gen_function_call_name(A, "-", oper, NULL); + return n; + } + case slang_oper_plus: + /* +expr --> do nothing */ + return _slang_gen_operation(A, &oper->children[0]); case slang_oper_variable_decl: return _slang_gen_declaration(A, oper); case slang_oper_assign: diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 2b631a3b722..8b0999dfcc2 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -78,7 +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_NEG, "IR_NEG", 0/*spec case*/, 4, 1 }, { IR_SIN, "IR_SIN", OPCODE_SIN, 1, 1 }, { IR_COS, "IR_COS", OPCODE_COS, 1, 1 }, /* other */ @@ -921,7 +921,6 @@ emit_unop(slang_gen_context *gc, slang_ir_node *n, struct gl_program *prog) 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); @@ -940,34 +939,24 @@ 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 + /* Implement as MOV dst, -src; */ + /* XXX we could look at the previous instruction and in some circumstances + * modify it to accomplish the negation. + */ 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); + slang_alloc_temp_storage(gc, n, n->Children[0]->Store->Size); + inst = new_instruction(prog, OPCODE_MOV); 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->SrcReg[0].NegateBase = NEGATE_XYZW; inst->Comment = n->Comment; - return inst; -#else - /* XXX this is something we can optimize for, with a bit of work.*/ - abort(); - return NULL; -#endif } |