652 |
652 |
653 static inline int vecsize_from_writemask(const int m) |
653 static inline int vecsize_from_writemask(const int m) |
654 { |
654 { |
655 return (m & 1) + ((m >> 1) & 1) + ((m >> 2) & 1) + ((m >> 3) & 1); |
655 return (m & 1) + ((m >> 1) & 1) + ((m >> 2) & 1) + ((m >> 3) & 1); |
656 } // vecsize_from_writemask |
656 } // vecsize_from_writemask |
|
657 |
|
658 |
|
659 static inline void set_dstarg_writemask(DestArgInfo *dst, const int mask) |
|
660 { |
|
661 dst->writemask = mask; |
|
662 dst->writemask0 = ((mask >> 0) & 1); |
|
663 dst->writemask1 = ((mask >> 1) & 1); |
|
664 dst->writemask2 = ((mask >> 2) & 1); |
|
665 dst->writemask3 = ((mask >> 3) & 1); |
|
666 } // set_dstarg_writemask |
|
667 |
657 |
668 |
658 static int allocate_scratch_register(Context *ctx) |
669 static int allocate_scratch_register(Context *ctx) |
659 { |
670 { |
660 const int retval = ctx->scratch_registers++; |
671 const int retval = ctx->scratch_registers++; |
661 if (retval >= ctx->max_scratch_registers) |
672 if (retval >= ctx->max_scratch_registers) |
3316 char src2[64]; |
3327 char src2[64]; |
3317 make_GLSL_srcarg_string(ctx, 0, (1 << i), src0, sizeof (src0)); |
3328 make_GLSL_srcarg_string(ctx, 0, (1 << i), src0, sizeof (src0)); |
3318 make_GLSL_srcarg_string(ctx, 1, mask, src1, sizeof (src1)); |
3329 make_GLSL_srcarg_string(ctx, 1, mask, src1, sizeof (src1)); |
3319 make_GLSL_srcarg_string(ctx, 2, mask, src2, sizeof (src2)); |
3330 make_GLSL_srcarg_string(ctx, 2, mask, src2, sizeof (src2)); |
3320 |
3331 |
3321 dst->writemask = mask; |
3332 set_dstarg_writemask(dst, mask); |
3322 dst->writemask0 = ((mask >> 0) & 1); |
|
3323 dst->writemask1 = ((mask >> 1) & 1); |
|
3324 dst->writemask2 = ((mask >> 2) & 1); |
|
3325 dst->writemask3 = ((mask >> 3) & 1); |
|
3326 |
3333 |
3327 char code[128]; |
3334 char code[128]; |
3328 make_GLSL_destarg_assign(ctx, code, sizeof (code), |
3335 make_GLSL_destarg_assign(ctx, code, sizeof (code), |
3329 "((%s %s) ? %s : %s)", |
3336 "((%s %s) ? %s : %s)", |
3330 src0, cmp, src1, src2); |
3337 src0, cmp, src1, src2); |
3331 dst->writemask = origmask; |
|
3332 dst->writemask0 = ((origmask >> 0) & 1); |
|
3333 dst->writemask1 = ((origmask >> 1) & 1); |
|
3334 dst->writemask2 = ((origmask >> 2) & 1); |
|
3335 dst->writemask3 = ((origmask >> 3) & 1); |
|
3336 output_line(ctx, "%s", code); |
3338 output_line(ctx, "%s", code); |
3337 } // for |
3339 } // for |
|
3340 |
|
3341 set_dstarg_writemask(dst, origmask); |
3338 } // emit_GLSL_comparison_operations |
3342 } // emit_GLSL_comparison_operations |
3339 |
3343 |
3340 static void emit_GLSL_CND(Context *ctx) |
3344 static void emit_GLSL_CND(Context *ctx) |
3341 { |
3345 { |
3342 emit_GLSL_comparison_operations(ctx, "> 0.5"); |
3346 emit_GLSL_comparison_operations(ctx, "> 0.5"); |
5399 if (isscalar(ctx, ctx->shader_type, info->regtype, info->regnum)) |
5403 if (isscalar(ctx, ctx->shader_type, info->regtype, info->regnum)) |
5400 writemask = 0x1; // just x. |
5404 writemask = 0x1; // just x. |
5401 else |
5405 else |
5402 writemask = info->orig_writemask; |
5406 writemask = info->orig_writemask; |
5403 |
5407 |
5404 info->writemask = writemask; |
5408 set_dstarg_writemask(info, writemask); // bits 16 through 19. |
5405 info->writemask0 = (int) ((writemask >> 0) & 0x1); // bit 16 |
|
5406 info->writemask1 = (int) ((writemask >> 1) & 0x1); // bit 17 |
|
5407 info->writemask2 = (int) ((writemask >> 2) & 0x1); // bit 18 |
|
5408 info->writemask3 = (int) ((writemask >> 3) & 0x1); // bit 19 |
|
5409 |
5409 |
5410 // all the REG_TYPE_CONSTx types are the same register type, it's just |
5410 // all the REG_TYPE_CONSTx types are the same register type, it's just |
5411 // split up so its regnum can be > 2047 in the bytecode. Clean it up. |
5411 // split up so its regnum can be > 2047 in the bytecode. Clean it up. |
5412 if (info->regtype == REG_TYPE_CONST2) |
5412 if (info->regtype == REG_TYPE_CONST2) |
5413 { |
5413 { |