mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Write SM4 casts from bool.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
98ebe9b69c
commit
3e88a46d4c
@ -1459,9 +1459,36 @@ static bool type_is_float(const struct hlsl_type *type)
|
|||||||
return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF;
|
return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void write_sm4_cast_from_bool(struct hlsl_ctx *ctx,
|
||||||
|
struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr,
|
||||||
|
const struct hlsl_ir_node *arg, uint32_t mask)
|
||||||
|
{
|
||||||
|
struct sm4_instruction instr;
|
||||||
|
|
||||||
|
memset(&instr, 0, sizeof(instr));
|
||||||
|
instr.opcode = VKD3D_SM4_OP_AND;
|
||||||
|
|
||||||
|
sm4_dst_from_node(&instr.dsts[0], &expr->node);
|
||||||
|
instr.dst_count = 1;
|
||||||
|
|
||||||
|
sm4_src_from_node(&instr.srcs[0], arg, instr.dsts[0].writemask);
|
||||||
|
instr.srcs[1].swizzle_type = VKD3D_SM4_SWIZZLE_NONE;
|
||||||
|
instr.srcs[1].reg.type = VKD3D_SM4_RT_IMMCONST;
|
||||||
|
instr.srcs[1].reg.dim = VKD3D_SM4_DIMENSION_SCALAR;
|
||||||
|
instr.srcs[1].reg.immconst_uint[0] = mask;
|
||||||
|
instr.src_count = 2;
|
||||||
|
|
||||||
|
write_sm4_instruction(buffer, &instr);
|
||||||
|
}
|
||||||
|
|
||||||
static void write_sm4_cast(struct hlsl_ctx *ctx,
|
static void write_sm4_cast(struct hlsl_ctx *ctx,
|
||||||
struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr)
|
struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr)
|
||||||
{
|
{
|
||||||
|
static const union
|
||||||
|
{
|
||||||
|
uint32_t u;
|
||||||
|
float f;
|
||||||
|
} one = { .f = 1.0 };
|
||||||
const struct hlsl_ir_node *arg1 = expr->operands[0].node;
|
const struct hlsl_ir_node *arg1 = expr->operands[0].node;
|
||||||
const struct hlsl_type *dst_type = expr->node.data_type;
|
const struct hlsl_type *dst_type = expr->node.data_type;
|
||||||
const struct hlsl_type *src_type = arg1->data_type;
|
const struct hlsl_type *src_type = arg1->data_type;
|
||||||
@ -1488,7 +1515,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_TYPE_BOOL:
|
case HLSL_TYPE_BOOL:
|
||||||
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to float.");
|
write_sm4_cast_from_bool(ctx, buffer, expr, arg1, one.u);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_TYPE_DOUBLE:
|
case HLSL_TYPE_DOUBLE:
|
||||||
@ -1514,7 +1541,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_TYPE_BOOL:
|
case HLSL_TYPE_BOOL:
|
||||||
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int.");
|
write_sm4_cast_from_bool(ctx, buffer, expr, arg1, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_TYPE_DOUBLE:
|
case HLSL_TYPE_DOUBLE:
|
||||||
@ -1540,7 +1567,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_TYPE_BOOL:
|
case HLSL_TYPE_BOOL:
|
||||||
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.");
|
write_sm4_cast_from_bool(ctx, buffer, expr, arg1, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_TYPE_DOUBLE:
|
case HLSL_TYPE_DOUBLE:
|
||||||
|
@ -12,7 +12,7 @@ uniform 0 int -1
|
|||||||
uniform 1 uint 3
|
uniform 1 uint 3
|
||||||
uniform 2 int -2
|
uniform 2 int -2
|
||||||
uniform 3 float 0.5
|
uniform 3 float 0.5
|
||||||
todo draw quad
|
draw quad
|
||||||
probe all rgba (0.5, 0.5, 0.5, 0.5)
|
probe all rgba (0.5, 0.5, 0.5, 0.5)
|
||||||
|
|
||||||
[pixel shader]
|
[pixel shader]
|
||||||
|
@ -19,8 +19,8 @@ uniform 0 float 2.6
|
|||||||
uniform 1 int -2
|
uniform 1 int -2
|
||||||
uniform 2 int -2
|
uniform 2 int -2
|
||||||
uniform 3 float -3.6
|
uniform 3 float -3.6
|
||||||
todo draw quad
|
draw quad
|
||||||
probe all rgba (0.5, 0.5, 0.5, 0.5)
|
todo probe all rgba (0.5, 0.5, 0.5, 0.5)
|
||||||
|
|
||||||
[pixel shader]
|
[pixel shader]
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ uniform 0 float 2.6
|
|||||||
uniform 1 int 2
|
uniform 1 int 2
|
||||||
uniform 2 int -2
|
uniform 2 int -2
|
||||||
uniform 3 float -3.6
|
uniform 3 float -3.6
|
||||||
todo draw quad
|
draw quad
|
||||||
probe all rgba (0.5, 0.5, 0.5, 0.5)
|
todo probe all rgba (0.5, 0.5, 0.5, 0.5)
|
||||||
|
|
||||||
[pixel shader]
|
[pixel shader]
|
||||||
|
|
||||||
|
@ -12,3 +12,21 @@ float4 main() : SV_TARGET
|
|||||||
[test]
|
[test]
|
||||||
draw quad
|
draw quad
|
||||||
probe all rgba (0.0, 0.0, 1.0, 1.0)
|
probe all rgba (0.0, 0.0, 1.0, 1.0)
|
||||||
|
|
||||||
|
[require]
|
||||||
|
shader model >= 4.0
|
||||||
|
|
||||||
|
[pixel shader]
|
||||||
|
uniform float4 x;
|
||||||
|
uniform int4 y;
|
||||||
|
|
||||||
|
float4 main() : SV_TARGET
|
||||||
|
{
|
||||||
|
return (float4)(bool4)x + 10.0 * (float4)(int4)(bool4)y;
|
||||||
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 float4 0.0 0.0 2.0 4.0
|
||||||
|
uniform 4 int4 0 1 0 10
|
||||||
|
draw quad
|
||||||
|
probe all rgba (0.0, 10.0, 1.0, 11.0)
|
||||||
|
@ -8,7 +8,7 @@ float4 main() : SV_TARGET
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo draw quad
|
draw quad
|
||||||
probe all rgba (0.0, 1.0, 1.0, 1.0)
|
probe all rgba (0.0, 1.0, 1.0, 1.0)
|
||||||
|
|
||||||
[pixel shader]
|
[pixel shader]
|
||||||
@ -61,7 +61,7 @@ float4 main() : SV_TARGET
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo draw quad
|
draw quad
|
||||||
probe all rgba (0.0, 1.0, 1.0, 1.0)
|
probe all rgba (0.0, 1.0, 1.0, 1.0)
|
||||||
|
|
||||||
[pixel shader]
|
[pixel shader]
|
||||||
@ -114,7 +114,7 @@ float4 main() : SV_TARGET
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo draw quad
|
draw quad
|
||||||
probe all rgba (0.0, 1.0, 1.0, 1.0)
|
probe all rgba (0.0, 1.0, 1.0, 1.0)
|
||||||
|
|
||||||
[pixel shader]
|
[pixel shader]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user