shader: move dtypeprefix for txq into function.

This is always the same value.

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Dave Airlie 7 years ago
parent 98eb584dd2
commit e6307939eb
  1. 38
      src/vrend_shader.c

@ -1300,13 +1300,13 @@ static int emit_txq(struct dump_ctx *ctx,
struct tgsi_full_instruction *inst, struct tgsi_full_instruction *inst,
char srcs[4][255], char srcs[4][255],
char dsts[3][255], char dsts[3][255],
const char *dtypeprefix,
const char *writemask) const char *writemask)
{ {
const char *twm = ""; const char *twm = "";
char bias[128] = {0}; char bias[128] = {0};
char buf[512]; char buf[512];
const int sampler_index = 1; const int sampler_index = 1;
enum vrend_type_qualifier dtypeprefix = INT_BITS_TO_FLOAT;
/* no lod parameter for txq for these */ /* no lod parameter for txq for these */
if (inst->Texture.Texture != TGSI_TEXTURE_RECT && if (inst->Texture.Texture != TGSI_TEXTURE_RECT &&
inst->Texture.Texture != TGSI_TEXTURE_SHADOWRECT && inst->Texture.Texture != TGSI_TEXTURE_SHADOWRECT &&
@ -1325,7 +1325,7 @@ static int emit_txq(struct dump_ctx *ctx,
ctx->shader_req_bits |= SHADER_REQ_TXQ_LEVELS; ctx->shader_req_bits |= SHADER_REQ_TXQ_LEVELS;
if (inst->Dst[0].Register.WriteMask & 0x7) if (inst->Dst[0].Register.WriteMask & 0x7)
twm = ".w"; twm = ".w";
snprintf(buf, 255, "%s%s = %s(textureQueryLevels(%s));\n", dsts[0], twm, dtypeprefix, srcs[sampler_index]); snprintf(buf, 255, "%s%s = %s(textureQueryLevels(%s));\n", dsts[0], twm, get_string(dtypeprefix), srcs[sampler_index]);
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
} }
@ -1360,7 +1360,7 @@ static int emit_txq(struct dump_ctx *ctx,
} }
if (inst->Dst[0].Register.WriteMask & 0x7) { if (inst->Dst[0].Register.WriteMask & 0x7) {
snprintf(buf, 255, "%s%s = %s(textureSize(%s%s))%s;\n", dsts[0], twm, dtypeprefix, srcs[sampler_index], bias, util_bitcount(inst->Dst[0].Register.WriteMask) > 1 ? writemask : ""); snprintf(buf, 255, "%s%s = %s(textureSize(%s%s))%s;\n", dsts[0], twm, get_string(dtypeprefix), srcs[sampler_index], bias, util_bitcount(inst->Dst[0].Register.WriteMask) > 1 ? writemask : "");
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
} }
return 0; return 0;
@ -1392,23 +1392,19 @@ static int translate_tex(struct dump_ctx *ctx,
ctx->samplers[sreg_index].tgsi_sampler_type = inst->Texture.Texture; ctx->samplers[sreg_index].tgsi_sampler_type = inst->Texture.Texture;
if (inst->Instruction.Opcode == TGSI_OPCODE_TXQ) { switch (ctx->samplers[sreg_index].tgsi_sampler_return) {
dtypeprefix = "intBitsToFloat"; case TGSI_RETURN_TYPE_SINT:
} else { /* if dstconv isn't an int */
switch (ctx->samplers[sreg_index].tgsi_sampler_return) { if (strcmp(dstconv, "int"))
case TGSI_RETURN_TYPE_SINT: dtypeprefix = "intBitsToFloat";
/* if dstconv isn't an int */ break;
if (strcmp(dstconv, "int")) case TGSI_RETURN_TYPE_UINT:
dtypeprefix = "intBitsToFloat"; /* if dstconv isn't an int */
break; if (strcmp(dstconv, "int"))
case TGSI_RETURN_TYPE_UINT: dtypeprefix = "uintBitsToFloat";
/* if dstconv isn't an int */ break;
if (strcmp(dstconv, "int")) default:
dtypeprefix = "uintBitsToFloat"; break;
break;
default:
break;
}
} }
switch (inst->Texture.Texture) { switch (inst->Texture.Texture) {
@ -1458,7 +1454,7 @@ static int translate_tex(struct dump_ctx *ctx,
ctx->shader_req_bits |= SHADER_REQ_LODQ; ctx->shader_req_bits |= SHADER_REQ_LODQ;
if (inst->Instruction.Opcode == TGSI_OPCODE_TXQ) { if (inst->Instruction.Opcode == TGSI_OPCODE_TXQ) {
return emit_txq(ctx, inst, srcs, dsts, dtypeprefix, writemask); return emit_txq(ctx, inst, srcs, dsts, writemask);
} }
switch (inst->Texture.Texture) { switch (inst->Texture.Texture) {

Loading…
Cancel
Save