shader: better type promotion for comparison op

This is an improvement from ee7852525: the right source type is
used.

Fixes piglit spec/glsl-1.50/execution/built-in-functions/gs-equal-ivec2-ivec2
macos/master
Marc-André Lureau 10 years ago committed by Dave Airlie
parent 444f661736
commit 043320c4f1
  1. 8
      src/vrend_shader.c

@ -840,9 +840,9 @@ static int emit_clip_dist_movs(struct dump_ctx *ctx)
#define emit_arit_op2(op) snprintf(buf, 255, "%s = %s(%s((%s %s %s))%s);\n", dsts[0], dstconv, dtypeprefix, srcs[0], op, srcs[1], writemask) #define emit_arit_op2(op) snprintf(buf, 255, "%s = %s(%s((%s %s %s))%s);\n", dsts[0], dstconv, dtypeprefix, srcs[0], op, srcs[1], writemask)
#define emit_op1(op) snprintf(buf, 255, "%s = %s(%s(%s(%s))%s);\n", dsts[0], dstconv, dtypeprefix, op, srcs[0], writemask) #define emit_op1(op) snprintf(buf, 255, "%s = %s(%s(%s(%s))%s);\n", dsts[0], dstconv, dtypeprefix, op, srcs[0], writemask)
#define emit_compare(op) snprintf(buf, 255, "%s = %s(%s((%s(%s, %s)))%s);\n", dsts[0], dstconv, dtypeprefix, op, srcs[0], srcs[1], writemask) #define emit_compare(op) snprintf(buf, 255, "%s = %s(%s((%s(%s(%s), %s(%s))))%s);\n", dsts[0], dstconv, dtypeprefix, op, svec4, srcs[0], svec4, srcs[1], writemask)
#define emit_ucompare(op) snprintf(buf, 255, "%s = %s(uintBitsToFloat(%s(%s(vec4(%s), vec4(%s))%s) * %s(0xffffffff)));\n", dsts[0], dstconv, udstconv, op, srcs[0], srcs[1], writemask, udstconv) #define emit_ucompare(op) snprintf(buf, 255, "%s = %s(uintBitsToFloat(%s(%s(%s(%s), %s(%s))%s) * %s(0xffffffff)));\n", dsts[0], dstconv, udstconv, op, svec4, srcs[0], svec4, srcs[1], writemask, udstconv)
static int emit_buf(struct dump_ctx *ctx, char *buf) static int emit_buf(struct dump_ctx *ctx, char *buf)
{ {
@ -1143,7 +1143,7 @@ iter_instruction(struct tgsi_iterate_context *iter,
char writemask[6] = {0}; char writemask[6] = {0};
enum tgsi_opcode_type dtype = tgsi_opcode_infer_dst_type(inst->Instruction.Opcode); enum tgsi_opcode_type dtype = tgsi_opcode_infer_dst_type(inst->Instruction.Opcode);
enum tgsi_opcode_type stype = tgsi_opcode_infer_src_type(inst->Instruction.Opcode); enum tgsi_opcode_type stype = tgsi_opcode_infer_src_type(inst->Instruction.Opcode);
char *dtypeprefix="", *stypeprefix = ""; char *dtypeprefix="", *stypeprefix = "", *svec4 = "vec4";
bool stprefix = false; bool stprefix = false;
bool override_no_wm[4]; bool override_no_wm[4];
char *sret; char *sret;
@ -1173,10 +1173,12 @@ iter_instruction(struct tgsi_iterate_context *iter,
switch (stype) { switch (stype) {
case TGSI_TYPE_UNSIGNED: case TGSI_TYPE_UNSIGNED:
stypeprefix = "floatBitsToUint"; stypeprefix = "floatBitsToUint";
svec4 = "uvec4";
stprefix = true; stprefix = true;
break; break;
case TGSI_TYPE_SIGNED: case TGSI_TYPE_SIGNED:
stypeprefix = "floatBitsToInt"; stypeprefix = "floatBitsToInt";
svec4 = "ivec4";
stprefix = true; stprefix = true;
break; break;
default: default:

Loading…
Cancel
Save