mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Support frac() intrinsic.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=34242 Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
3db509383b
commit
3e6fccdbf9
Notes:
Alexandre Julliard
2023-01-25 22:43:33 +01:00
Approved-by: Zebediah Figura (@zfigura) Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/68
@ -60,6 +60,7 @@ vkd3d_shader_tests = \
|
|||||||
tests/compute.shader_test \
|
tests/compute.shader_test \
|
||||||
tests/conditional.shader_test \
|
tests/conditional.shader_test \
|
||||||
tests/floor.shader_test \
|
tests/floor.shader_test \
|
||||||
|
tests/frac.shader_test \
|
||||||
tests/hlsl-array-dimension.shader_test \
|
tests/hlsl-array-dimension.shader_test \
|
||||||
tests/hlsl-attributes.shader_test \
|
tests/hlsl-attributes.shader_test \
|
||||||
tests/hlsl-bool-cast.shader_test \
|
tests/hlsl-bool-cast.shader_test \
|
||||||
|
@ -2502,6 +2502,17 @@ static bool intrinsic_floor(struct hlsl_ctx *ctx,
|
|||||||
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_FLOOR, arg, loc);
|
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_FLOOR, arg, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool intrinsic_frac(struct hlsl_ctx *ctx,
|
||||||
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_node *arg;
|
||||||
|
|
||||||
|
if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_FRACT, arg, loc);
|
||||||
|
}
|
||||||
|
|
||||||
static bool intrinsic_ldexp(struct hlsl_ctx *ctx,
|
static bool intrinsic_ldexp(struct hlsl_ctx *ctx,
|
||||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
@ -2922,6 +2933,7 @@ intrinsic_functions[] =
|
|||||||
{"cross", 2, true, intrinsic_cross},
|
{"cross", 2, true, intrinsic_cross},
|
||||||
{"dot", 2, true, intrinsic_dot},
|
{"dot", 2, true, intrinsic_dot},
|
||||||
{"floor", 1, true, intrinsic_floor},
|
{"floor", 1, true, intrinsic_floor},
|
||||||
|
{"frac", 1, true, intrinsic_frac},
|
||||||
{"ldexp", 2, true, intrinsic_ldexp},
|
{"ldexp", 2, true, intrinsic_ldexp},
|
||||||
{"length", 1, true, intrinsic_length},
|
{"length", 1, true, intrinsic_length},
|
||||||
{"lerp", 3, true, intrinsic_lerp},
|
{"lerp", 3, true, intrinsic_lerp},
|
||||||
|
@ -658,6 +658,10 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
|
|||||||
write_sm1_binary_op(ctx, buffer, D3DSIO_MUL, &instr->reg, &arg1->reg, &arg2->reg);
|
write_sm1_binary_op(ctx, buffer, D3DSIO_MUL, &instr->reg, &arg1->reg, &arg2->reg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HLSL_OP1_FRACT:
|
||||||
|
write_sm1_unary_op(ctx, buffer, D3DSIO_FRC, &instr->reg, &arg1->reg, D3DSPSM_NONE);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
hlsl_fixme(ctx, &instr->loc, "SM1 \"%s\" expression.", debug_hlsl_expr_op(expr->op));
|
hlsl_fixme(ctx, &instr->loc, "SM1 \"%s\" expression.", debug_hlsl_expr_op(expr->op));
|
||||||
break;
|
break;
|
||||||
|
12
tests/frac.shader_test
Normal file
12
tests/frac.shader_test
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[pixel shader]
|
||||||
|
uniform float4 f;
|
||||||
|
|
||||||
|
float4 main() : sv_target
|
||||||
|
{
|
||||||
|
return frac(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 float4 -1.1 1.6 1.3 0.5
|
||||||
|
draw quad
|
||||||
|
probe all rgba (0.9, 0.6, 0.3, 0.5) 2
|
Loading…
x
Reference in New Issue
Block a user