vkd3d-shader/hlsl: Consider scalars to be equivalent to 1-component vectors in hlsl_add_conditional().

This commit is contained in:
Henri Verbeet
2025-11-11 17:24:38 +01:00
parent 5d385fbce0
commit 4039168bca
Notes: Henri Verbeet 2025-11-12 15:31:32 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1824
2 changed files with 36 additions and 2 deletions

View File

@@ -5490,10 +5490,14 @@ static struct hlsl_ir_node *lower_casts_to_bool(struct hlsl_ctx *ctx,
struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_block *instrs,
struct hlsl_ir_node *condition, struct hlsl_ir_node *if_true, struct hlsl_ir_node *if_false)
{
struct hlsl_type *false_type = if_false->data_type;
struct hlsl_type *cond_type = condition->data_type;
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS];
struct hlsl_type *true_type = if_true->data_type;
VKD3D_ASSERT(hlsl_types_are_equal(if_true->data_type, if_false->data_type));
VKD3D_ASSERT(hlsl_types_are_equal(true_type, false_type)
|| (hlsl_is_vec1(true_type) && hlsl_is_vec1(false_type)
&& true_type->e.numeric.type == false_type->e.numeric.type));
if (cond_type->e.numeric.type != HLSL_TYPE_BOOL)
{
@@ -5505,7 +5509,7 @@ struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_bloc
operands[0] = condition;
operands[1] = if_true;
operands[2] = if_false;
return hlsl_block_add_expr(ctx, instrs, HLSL_OP3_TERNARY, operands, if_true->data_type, &condition->loc);
return hlsl_block_add_expr(ctx, instrs, HLSL_OP3_TERNARY, operands, true_type, &condition->loc);
}
static struct hlsl_ir_node *lower_int_division_sm4(struct hlsl_ctx *ctx,

View File

@@ -70,10 +70,40 @@ float main() : sv_target
return float4(0.9, 0.8, 0.7, 0.6);
}
[vertex shader]
void main(float4 p : position, out float t[4] : texcoord, out float4 position : sv_position)
{
t[0] = (p.x + 1.0) / 2.0;
t[2] = 0.0;
t[1] = (p.y + 1.0) / 2.0;
t[3] = 1.0;
position = p;
}
[pixel shader]
float4 main(float t[4] : texcoord) : sv_target
{
if (t[0] > 0.5)
return floor(float4(t) * 128.0 + 0.5) / 128.0;
return float4(0.0, 1.0, 0.0, 1.0);
}
[test]
todo(msl & sm>=6) draw quad
probe (160, 120) f32(0.00, 1.00, 0.0, 1.0)
probe (480, 120) f32(0.75, 0.75, 0.0, 1.0)
probe (160, 360) f32(0.00, 1.00, 0.0, 1.0)
probe (480, 360) f32(0.75, 0.25, 0.0, 1.0)
% Using older profiles fails to compile with forced control flow instruction
[require]
shader model >= 3.0
[vertex shader]
float4 main(float4 p : position) : sv_position
{
return p;
}
[pixel shader]
uniform float a;