From 7685c84a66cc0397908812fac9c71ff14de94ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Fri, 8 Apr 2022 10:16:19 +0200 Subject: [PATCH 1/2] shader: Use a switch to select the immediate type Report any unhandled immediate type. --- src/vrend_shader.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index b00cfe8fd..fa59d5f73 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -1916,15 +1916,21 @@ iter_immediate(struct tgsi_iterate_context *iter, ctx->imm[first].type = imm->Immediate.DataType; for (i = 0; i < 4; i++) { - if (imm->Immediate.DataType == TGSI_IMM_FLOAT32) { + switch (imm->Immediate.DataType) { + case TGSI_IMM_FLOAT32: ctx->imm[first].val[i].f = imm->u[i].Float; - } else if (imm->Immediate.DataType == TGSI_IMM_UINT32 || - imm->Immediate.DataType == TGSI_IMM_FLOAT64) { + break; + case TGSI_IMM_UINT32: + case TGSI_IMM_FLOAT64: ctx->shader_req_bits |= SHADER_REQ_INTS; ctx->imm[first].val[i].ui = imm->u[i].Uint; - } else if (imm->Immediate.DataType == TGSI_IMM_INT32) { - ctx->shader_req_bits |= SHADER_REQ_INTS; + break; + case TGSI_IMM_INT32: ctx->imm[first].val[i].i = imm->u[i].Int; + break; + default: + vrend_printf( "Unhandled immediate type, ignoring: %x\n", imm->Immediate.DataType); + break; } } ctx->num_imm++; -- GitLab From 16f8be0fac34c36efb48940b113447fb568afd49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Fri, 8 Apr 2022 10:31:55 +0200 Subject: [PATCH 2/2] shader: Use a switch to iterate the immediates in get_source_info Allows for better readability --- src/vrend_shader.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index fa59d5f73..cd8d51463 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -4569,24 +4569,25 @@ get_source_info(struct dump_ctx *ctx, (inst->Instruction.Opcode == TGSI_OPCODE_INTERP_SAMPLE && i == 1)) stype = TGSI_TYPE_SIGNED; - if (imd->type == TGSI_IMM_UINT32 || imd->type == TGSI_IMM_INT32) { - if (imd->type == TGSI_IMM_UINT32) - vtype = UVEC4; - else - vtype = IVEC4; - - if (stype == TGSI_TYPE_UNSIGNED && imd->type == TGSI_IMM_INT32) + switch (imd->type) { + case TGSI_IMM_INT32: + vtype = IVEC4; + if (stype == TGSI_TYPE_SIGNED) + imm_stypeprefix = TYPE_CONVERSION_NONE; + else if (stype == TGSI_TYPE_UNSIGNED) imm_stypeprefix = UVEC4; - else if (stype == TGSI_TYPE_SIGNED && imd->type == TGSI_IMM_UINT32) - imm_stypeprefix = IVEC4; - else if (stype == TGSI_TYPE_FLOAT || stype == TGSI_TYPE_UNTYPED) { - if (imd->type == TGSI_IMM_INT32) - imm_stypeprefix = INT_BITS_TO_FLOAT; - else - imm_stypeprefix = UINT_BITS_TO_FLOAT; - } else if (stype == TGSI_TYPE_UNSIGNED || stype == TGSI_TYPE_SIGNED) + else if (stype == TGSI_TYPE_FLOAT || stype == TGSI_TYPE_UNTYPED) + imm_stypeprefix = INT_BITS_TO_FLOAT; + case TGSI_IMM_UINT32: + vtype = UVEC4; + if (stype == TGSI_TYPE_UNSIGNED) imm_stypeprefix = TYPE_CONVERSION_NONE; - } else if (imd->type == TGSI_IMM_FLOAT64) { + else if (stype == TGSI_TYPE_SIGNED) + imm_stypeprefix = IVEC4; + else if (stype == TGSI_TYPE_FLOAT || stype == TGSI_TYPE_UNTYPED) + imm_stypeprefix = UINT_BITS_TO_FLOAT; + break; + case TGSI_IMM_FLOAT64: vtype = UVEC4; if (stype == TGSI_TYPE_DOUBLE) imm_stypeprefix = TYPE_CONVERSION_NONE; -- GitLab