mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Avoid some uses of the default case when switching over hlsl_base_type.
Since we have -Wswitch, this forces the developer to update all relevant switches when an enum case is added. Places where the default is just a FIXME are left alone.
This commit is contained in:
parent
646087d54c
commit
1ff1a51e4b
Notes:
Henri Verbeet
2025-01-10 20:14:49 +01:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1326
@ -3204,9 +3204,6 @@ static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hl
|
||||
case HLSL_TYPE_UINT:
|
||||
vkd3d_string_buffer_printf(buffer, "%u ", value->u);
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
}
|
||||
if (type->dimx != 1)
|
||||
|
@ -5233,7 +5233,7 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx,
|
||||
for (x = 0, i = 0; x < 4; ++x)
|
||||
{
|
||||
const union hlsl_constant_value_component *value;
|
||||
float f;
|
||||
float f = 0;
|
||||
|
||||
if (!(constant->reg.writemask & (1u << x)))
|
||||
continue;
|
||||
@ -5261,9 +5261,6 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx,
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
FIXME("Double constant.\n");
|
||||
return;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
record_constant(ctx, constant->reg.id * 4 + x, f, &constant->node.loc);
|
||||
@ -6668,8 +6665,8 @@ void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
|
||||
static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_program *program,
|
||||
struct shader_signature *signature, bool output, bool is_patch_constant_func, struct hlsl_ir_var *var)
|
||||
{
|
||||
enum vkd3d_shader_component_type component_type = VKD3D_SHADER_COMPONENT_VOID;
|
||||
enum vkd3d_shader_sysval_semantic sysval = VKD3D_SHADER_SV_NONE;
|
||||
enum vkd3d_shader_component_type component_type;
|
||||
unsigned int register_index, mask, use_mask;
|
||||
const char *name = var->semantic.name;
|
||||
enum vkd3d_shader_register_type type;
|
||||
@ -6716,12 +6713,11 @@ static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_prog
|
||||
component_type = VKD3D_SHADER_COMPONENT_UINT;
|
||||
break;
|
||||
|
||||
default:
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
if ((string = hlsl_type_to_string(ctx, var->data_type)))
|
||||
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
"Invalid data type %s for semantic variable %s.", string->buffer, var->name);
|
||||
hlsl_release_string_buffer(ctx, string);
|
||||
component_type = VKD3D_SHADER_COMPONENT_VOID;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -7513,9 +7509,6 @@ static bool sm1_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
"The 'double' type is not supported for the %s profile.", ctx->profile->name);
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -7539,9 +7532,6 @@ static bool sm1_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
hlsl_fixme(ctx, &instr->loc, "SM1 cast from double to integer.");
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -7566,7 +7556,6 @@ static bool sm1_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
|
||||
case HLSL_TYPE_BOOL:
|
||||
/* Casts to bool should have already been lowered. */
|
||||
default:
|
||||
hlsl_fixme(ctx, &expr->node.loc, "SM1 cast from %s to %s.",
|
||||
debug_hlsl_type(ctx, src_type), debug_hlsl_type(ctx, dst_type));
|
||||
break;
|
||||
@ -8196,9 +8185,8 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type, bool is_comb
|
||||
case HLSL_TYPE_INT:
|
||||
case HLSL_TYPE_UINT:
|
||||
return D3DXPT_INT;
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
break;
|
||||
|
||||
case HLSL_CLASS_SAMPLER:
|
||||
switch (type->sampler_dim)
|
||||
@ -8457,7 +8445,7 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe
|
||||
{
|
||||
uint32_t u;
|
||||
float f;
|
||||
} uni;
|
||||
} uni = {0};
|
||||
|
||||
switch (comp_type->e.numeric.type)
|
||||
{
|
||||
@ -8481,9 +8469,6 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe
|
||||
case HLSL_TYPE_FLOAT:
|
||||
uni.u = var->default_values[k].number.u;
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
set_u32(buffer, default_value_offset + comp_offset * sizeof(uint32_t), uni.u);
|
||||
@ -8734,9 +8719,6 @@ static bool sm4_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to float.");
|
||||
return false;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -8760,9 +8742,6 @@ static bool sm4_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int.");
|
||||
return false;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -8786,9 +8765,6 @@ static bool sm4_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.");
|
||||
return false;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -8798,9 +8774,10 @@ static bool sm4_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
|
||||
case HLSL_TYPE_BOOL:
|
||||
/* Casts to bool should have already been lowered. */
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
break;
|
||||
}
|
||||
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
static void sm4_generate_vsir_expr_with_two_destinations(struct hlsl_ctx *ctx, struct vsir_program *program,
|
||||
@ -10454,15 +10431,13 @@ static enum vkd3d_data_type sm4_generate_vsir_get_format_type(const struct hlsl_
|
||||
|
||||
case HLSL_TYPE_INT:
|
||||
return VKD3D_DATA_INT;
|
||||
break;
|
||||
|
||||
case HLSL_TYPE_BOOL:
|
||||
case HLSL_TYPE_UINT:
|
||||
return VKD3D_DATA_UINT;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
static void sm4_generate_vsir_add_dcl_texture(struct hlsl_ctx *ctx,
|
||||
|
@ -143,10 +143,10 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
|
||||
const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
|
||||
{
|
||||
unsigned int k;
|
||||
uint32_t u;
|
||||
int32_t i;
|
||||
double d;
|
||||
float f;
|
||||
uint32_t u = 0;
|
||||
double d = 0.0;
|
||||
float f = 0.0f;
|
||||
int32_t i = 0;
|
||||
|
||||
if (dst_type->dimx != src->node.data_type->dimx
|
||||
|| dst_type->dimy != src->node.data_type->dimy)
|
||||
@ -195,9 +195,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
|
||||
f = !!src->value.u[k].u;
|
||||
d = !!src->value.u[k].u;
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
switch (dst_type->e.numeric.type)
|
||||
@ -222,9 +219,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
|
||||
case HLSL_TYPE_BOOL:
|
||||
dst->u[k].u = u ? ~0u : 0u;
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -864,9 +858,6 @@ static bool fold_equal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, co
|
||||
case HLSL_TYPE_BOOL:
|
||||
dst->u[k].u = src1->value.u[k].u == src2->value.u[k].u;
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
dst->u[k].u *= ~0u;
|
||||
@ -903,9 +894,6 @@ static bool fold_gequal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
|
||||
case HLSL_TYPE_BOOL:
|
||||
dst->u[k].u = src1->value.u[k].u >= src2->value.u[k].u;
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
dst->u[k].u *= ~0u;
|
||||
@ -942,9 +930,6 @@ static bool fold_less(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, con
|
||||
case HLSL_TYPE_BOOL:
|
||||
dst->u[k].u = src1->value.u[k].u < src2->value.u[k].u;
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
dst->u[k].u *= ~0u;
|
||||
@ -1162,9 +1147,6 @@ static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
|
||||
case HLSL_TYPE_BOOL:
|
||||
dst->u[k].u = src1->value.u[k].u != src2->value.u[k].u;
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
dst->u[k].u *= ~0u;
|
||||
@ -1424,9 +1406,6 @@ static bool constant_is_zero(struct hlsl_ir_constant *const_arg)
|
||||
if (const_arg->value.u[k].u != 0)
|
||||
return false;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -1462,9 +1441,6 @@ static bool constant_is_one(struct hlsl_ir_constant *const_arg)
|
||||
if (const_arg->value.u[k].u != ~0)
|
||||
return false;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -3328,9 +3328,8 @@ static D3D_SHADER_VARIABLE_TYPE sm4_base_type(const struct hlsl_type *type)
|
||||
return D3D_SVT_INT;
|
||||
case HLSL_TYPE_UINT:
|
||||
return D3D_SVT_UINT;
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
static void write_sm4_type(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, struct hlsl_type *type)
|
||||
@ -3446,10 +3445,9 @@ static enum vkd3d_sm4_data_type sm4_data_type(const struct hlsl_type *type)
|
||||
case HLSL_TYPE_BOOL:
|
||||
case HLSL_TYPE_UINT:
|
||||
return VKD3D_SM4_DATA_UINT;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
static D3D_SRV_DIMENSION sm4_rdef_resource_dimension(const struct hlsl_type *type)
|
||||
|
Loading…
x
Reference in New Issue
Block a user