mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Implement round() intrinsic function in SM4.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com> Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c632ac7605
commit
3dad54845e
@ -91,6 +91,7 @@ vkd3d_shader_tests = \
|
||||
tests/preproc-invalid.shader_test \
|
||||
tests/preproc-macro.shader_test \
|
||||
tests/preproc-misc.shader_test \
|
||||
tests/round.shader_test \
|
||||
tests/sampler.shader_test \
|
||||
tests/saturate.shader_test \
|
||||
tests/swizzle-0.shader_test \
|
||||
|
@ -1156,6 +1156,7 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op)
|
||||
[HLSL_OP1_NEG] = "-",
|
||||
[HLSL_OP1_NRM] = "nrm",
|
||||
[HLSL_OP1_RCP] = "rcp",
|
||||
[HLSL_OP1_ROUND] = "round",
|
||||
[HLSL_OP1_RSQ] = "rsq",
|
||||
[HLSL_OP1_SAT] = "sat",
|
||||
[HLSL_OP1_SIGN] = "sign",
|
||||
|
@ -299,6 +299,7 @@ enum hlsl_ir_expr_op
|
||||
HLSL_OP1_NEG,
|
||||
HLSL_OP1_NRM,
|
||||
HLSL_OP1_RCP,
|
||||
HLSL_OP1_ROUND,
|
||||
HLSL_OP1_RSQ,
|
||||
HLSL_OP1_SAT,
|
||||
HLSL_OP1_SIGN,
|
||||
|
@ -1611,6 +1611,12 @@ static bool intrinsic_pow(struct hlsl_ctx *ctx,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool intrinsic_round(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, struct vkd3d_shader_location loc)
|
||||
{
|
||||
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ROUND, params->args[0], &loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_saturate(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, struct vkd3d_shader_location loc)
|
||||
{
|
||||
@ -1626,10 +1632,12 @@ static const struct intrinsic_function
|
||||
}
|
||||
intrinsic_functions[] =
|
||||
{
|
||||
/* Note: these entries should be kept in alphabetical order. */
|
||||
{"abs", 1, true, intrinsic_abs},
|
||||
{"clamp", 3, true, intrinsic_clamp},
|
||||
{"max", 2, true, intrinsic_max},
|
||||
{"pow", 2, true, intrinsic_pow},
|
||||
{"round", 1, true, intrinsic_round},
|
||||
{"saturate", 1, true, intrinsic_saturate},
|
||||
};
|
||||
|
||||
|
@ -1305,6 +1305,10 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
|
||||
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_NEGATE);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_ROUND:
|
||||
write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NE, &expr->node, arg1, 0);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_SAT:
|
||||
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV
|
||||
| (VKD3D_SM4_INSTRUCTION_FLAG_SATURATE << VKD3D_SM4_INSTRUCTION_FLAGS_SHIFT),
|
||||
|
26
tests/round.shader_test
Normal file
26
tests/round.shader_test
Normal file
@ -0,0 +1,26 @@
|
||||
[pixel shader]
|
||||
float4 main(uniform float4 u) : sv_target
|
||||
{
|
||||
return round(u);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float4 -0.5 6.5 7.5 3.4
|
||||
draw quad
|
||||
probe all rgba (0.0, 6.0, 8.0, 3.0) 4
|
||||
|
||||
|
||||
|
||||
[pixel shader]
|
||||
float4 main(uniform float4 u) : sv_target
|
||||
{
|
||||
float a = round(u.r);
|
||||
int2 b = round(u.gb);
|
||||
float4 res = float4(b, a, u.a);
|
||||
return round(res);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float4 -0.5 6.5 7.5 3.4
|
||||
draw quad
|
||||
probe all rgba (6.0, 8.0, 0.0, 3.0) 4
|
Loading…
Reference in New Issue
Block a user