diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 6 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 65 |
2 files changed, 29 insertions, 42 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index fa57ef86664..4a67d4535aa 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -458,10 +458,10 @@ new_label(slang_label *label) } static slang_ir_node * -new_float_literal(const float v[4]) +new_float_literal(const float v[4], GLuint size) { - const GLuint size = (v[0] == v[1] && v[0] == v[2] && v[0] == v[3]) ? 1 : 4; slang_ir_node *n = new_node0(IR_FLOAT); + assert(size <= 4); COPY_4V(n->Value, v); /* allocate a storage object, but compute actual location (Index) later */ n->Store = _slang_new_ir_storage(PROGRAM_CONSTANT, -1, size); @@ -2513,7 +2513,7 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper) case SLANG_OPER_LITERAL_INT: /* fall-through */ case SLANG_OPER_LITERAL_BOOL: - return new_float_literal(oper->literal); + return new_float_literal(oper->literal, oper->literal_size); case SLANG_OPER_POSTINCREMENT: /* var++ */ { diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 4bbc7c918ce..b318402e31a 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -125,7 +125,9 @@ alloc_temp_storage(slang_emit_info *emitInfo, slang_ir_node *n, GLint size) static void free_temp_storage(slang_var_table *vt, slang_ir_node *n) { - if (n->Store->File == PROGRAM_TEMPORARY && n->Store->Index >= 0) { + if (n->Store->File == PROGRAM_TEMPORARY && + n->Store->Index >= 0 && + n->Opcode != IR_SWIZZLE) { if (_slang_is_temp(vt, n->Store)) { _slang_free_temp(vt, n->Store); n->Store->Index = -1; @@ -142,12 +144,6 @@ static void storage_to_dst_reg(struct prog_dst_register *dst, const slang_ir_storage *st, GLuint writemask) { - static const GLuint defaultWritemask[4] = { - WRITEMASK_X, - WRITEMASK_X | WRITEMASK_Y, - WRITEMASK_X | WRITEMASK_Y | WRITEMASK_Z, - WRITEMASK_X | WRITEMASK_Y | WRITEMASK_Z | WRITEMASK_W - }; assert(st->Index >= 0); dst->File = st->File; dst->Index = st->Index; @@ -157,17 +153,10 @@ storage_to_dst_reg(struct prog_dst_register *dst, const slang_ir_storage *st, if (st->Size == 1) { GLuint comp = GET_SWZ(st->Swizzle, 0); assert(comp < 4); - assert(writemask & WRITEMASK_X); - /* - assert((writemask == WRITEMASK_X) || - (writemask == WRITEMASK_Y) || - (writemask == WRITEMASK_Z) || - (writemask == WRITEMASK_W)); - */ dst->WriteMask = WRITEMASK_X << comp; } else { - dst->WriteMask = defaultWritemask[st->Size - 1] & writemask; + dst->WriteMask = writemask; } } @@ -195,10 +184,10 @@ storage_to_src_reg(struct prog_src_register *src, const slang_ir_storage *st) else src->Swizzle = defaultSwizzle[st->Size - 1]; /*XXX really need this?*/ - assert(GET_SWZ(src->Swizzle, 0) != SWIZZLE_NIL); - assert(GET_SWZ(src->Swizzle, 1) != SWIZZLE_NIL); - assert(GET_SWZ(src->Swizzle, 2) != SWIZZLE_NIL); - assert(GET_SWZ(src->Swizzle, 3) != SWIZZLE_NIL); + assert(GET_SWZ(src->Swizzle, 0) <= 3); + assert(GET_SWZ(src->Swizzle, 1) <= 3); + assert(GET_SWZ(src->Swizzle, 2) <= 3); + assert(GET_SWZ(src->Swizzle, 3) <= 3); } @@ -501,13 +490,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n) emit(emitInfo, n->Children[0]); emit(emitInfo, n->Children[1]); -#if 0 assert(n->Children[0]->Store->Size == n->Children[1]->Store->Size); size = n->Children[0]->Store->Size; -#else - /* XXX kind of a hack for now... */ - size = MIN2(n->Children[0]->Store->Size, n->Children[1]->Store->Size); -#endif + if (size == 1) { gl_inst_opcode opcode; @@ -1220,7 +1205,10 @@ fix_swizzle(GLuint swizzle) } -#if 0 +/** + * Return the number of components actually named by the swizzle. + * Recall that swizzles may have undefined/don't-care values. + */ static GLuint swizzle_size(GLuint swizzle) { @@ -1231,7 +1219,6 @@ swizzle_size(GLuint swizzle) } return size; } -#endif static struct prog_instruction * @@ -1239,17 +1226,8 @@ emit_swizzle(slang_emit_info *emitInfo, slang_ir_node *n) { GLuint swizzle; - /* swizzled storage access */ (void) emit(emitInfo, n->Children[0]); - /* "pull-up" the child's storage info, applying our swizzle info */ - n->Store->File = n->Children[0]->Store->File; - n->Store->Index = n->Children[0]->Store->Index; - n->Store->Size = n->Children[0]->Store->Size; - /*n->Var = n->Children[0]->Var; XXX for debug */ - assert(n->Store->Index >= 0); - - swizzle = fix_swizzle(n->Store->Swizzle); #ifdef DEBUG { GLuint s = n->Children[0]->Store->Swizzle; @@ -1259,16 +1237,24 @@ emit_swizzle(slang_emit_info *emitInfo, slang_ir_node *n) assert(GET_SWZ(s, 3) != SWIZZLE_NIL); } #endif + /* For debug: n->Var = n->Children[0]->Var; */ -#if 0 + /* "pull-up" the child's storage info, applying our swizzle info */ + n->Store->File = n->Children[0]->Store->File; + n->Store->Index = n->Children[0]->Store->Index; n->Store->Size = swizzle_size(n->Store->Swizzle); - printf("Emit Swizzle reg %d chSize %d size %d\n", +#if 0 + printf("Emit Swizzle reg %d chSize %d size %d swz %s\n", n->Store->Index, n->Children[0]->Store->Size, - n->Store->Size); + n->Store->Size, + _mesa_swizzle_string(n->Store->Swizzle, 0, 0)); #endif + /* apply this swizzle to child's swizzle to get composed swizzle */ + swizzle = fix_swizzle(n->Store->Swizzle); /* remove the don't care terms */ n->Store->Swizzle = swizzle_swizzle(n->Children[0]->Store->Swizzle, swizzle); + return NULL; } @@ -1492,7 +1478,8 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n) return emit_negation(emitInfo, n); case IR_FLOAT: /* find storage location for this float constant */ - n->Store->Index = _mesa_add_unnamed_constant(emitInfo->prog->Parameters, n->Value, + n->Store->Index = _mesa_add_unnamed_constant(emitInfo->prog->Parameters, + n->Value, n->Store->Size, &n->Store->Swizzle); if (n->Store->Index < 0) { |