summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorentin Noël <corentin.noel@collabora.com>2023-08-09 15:53:42 +0200
committerCorentin Noël <corentin.noel@collabora.com>2023-08-11 12:48:50 +0200
commit67441a153cb0e4e24ea4d61e8d372381f90a36ae (patch)
tree708396cfcf1374188cbc86c0d6848977382c120a
parent1b0c45bedbad63d1b41e28824c2ef4c0d99cfd25 (diff)
shader: Use a switch to iterate the immediates in get_source_info
Allows for better readability Signed-off-by: Corentin Noël <corentin.noel@collabora.com> Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/779>
-rw-r--r--src/vrend_shader.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index e37adb4..9b0068f 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -4952,29 +4952,36 @@ 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;
+ break;
+ 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;
else
imm_stypeprefix = UINT_BITS_TO_FLOAT;
+ break;
+ case TGSI_IMM_INT64:
+ case TGSI_IMM_UINT64:
+ case TGSI_IMM_FLOAT32:
+ break;
}
/* build up a vec4 of immediates */