Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl_codegen.c:
- struct hlsl_ir_switch_case *c;
- bool terminal_break = false;
- struct hlsl_ir_node *node;
- struct hlsl_ir_jump *jump;
- struct hlsl_ir_switch *s;
- if (instr->type != HLSL_IR_SWITCH)
return false;
- s = hlsl_ir_switch(instr);
- LIST_FOR_EACH_ENTRY(c, &s->cases, struct hlsl_ir_switch_case, entry)
- {
if (list_empty(&c->body.instrs))
continue;
terminal_break = false;
This doesn't validate that the last case actually has some code. See for example these two tests (which should probably be added to the first commit): ```hlsl [pixel shader fail] uint4 v;
float4 main() : sv_target { switch (v.x) { case 0: return 3.0; case 1: return 4.0; case 2: } return 0.0; }
[pixel shader fail] uint4 v;
float4 main() : sv_target { switch (v.x) { case 0: return 3.0; case 1: return 4.0; default: } return 0.0; } ```
It seems that you can easily fix your code by swapping `if (list_empty(...)) continue;` and `terminal_break = false;`, so that if the last case has not instructions `terminal_break` is left to `false`. However you would then need to tweak the error message a little.