mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Parse the pow() intrinsic.
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
96fd5f74f9
commit
2461ad601b
@ -82,6 +82,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl-vector-indexing-uniform.shader_test \
|
||||
tests/math.shader_test \
|
||||
tests/max.shader_test \
|
||||
tests/pow.shader_test \
|
||||
tests/preproc-if.shader_test \
|
||||
tests/preproc-ifdef.shader_test \
|
||||
tests/preproc-if-expr.shader_test \
|
||||
@ -297,6 +298,7 @@ XFAIL_TESTS = \
|
||||
tests/hlsl-vector-indexing-uniform.shader_test \
|
||||
tests/math.shader_test \
|
||||
tests/max.shader_test \
|
||||
tests/pow.shader_test \
|
||||
tests/trigonometry.shader_test \
|
||||
tests/writemask-assignop-1.shader_test
|
||||
endif
|
||||
|
@ -1093,7 +1093,6 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op)
|
||||
[HLSL_OP2_MOD] = "%",
|
||||
[HLSL_OP2_MUL] = "*",
|
||||
[HLSL_OP2_NEQUAL] = "!=",
|
||||
[HLSL_OP2_POW] = "pow",
|
||||
[HLSL_OP2_RSHIFT] = ">>",
|
||||
|
||||
[HLSL_OP3_LERP] = "lerp",
|
||||
|
@ -318,7 +318,6 @@ enum hlsl_ir_expr_op
|
||||
HLSL_OP2_MOD,
|
||||
HLSL_OP2_MUL,
|
||||
HLSL_OP2_NEQUAL,
|
||||
HLSL_OP2_POW,
|
||||
HLSL_OP2_RSHIFT,
|
||||
|
||||
HLSL_OP3_LERP,
|
||||
|
@ -1585,6 +1585,28 @@ static bool intrinsic_max(struct hlsl_ctx *ctx,
|
||||
return !!add_expr(ctx, params->instrs, HLSL_OP2_MAX, args, &loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_pow(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, struct vkd3d_shader_location loc)
|
||||
{
|
||||
struct hlsl_ir_node *args[3] = {0};
|
||||
struct hlsl_ir_node *log, *exp;
|
||||
struct hlsl_ir_expr *mul;
|
||||
|
||||
if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], loc)))
|
||||
return false;
|
||||
list_add_tail(params->instrs, &log->entry);
|
||||
|
||||
args[0] = params->args[1];
|
||||
args[1] = log;
|
||||
if (!(mul = add_expr(ctx, params->instrs, HLSL_OP2_MUL, args, &loc)))
|
||||
return false;
|
||||
|
||||
if (!(exp = hlsl_new_unary_expr(ctx, HLSL_OP1_EXP2, &mul->node, loc)))
|
||||
return false;
|
||||
list_add_tail(params->instrs, &exp->entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool intrinsic_saturate(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, struct vkd3d_shader_location loc)
|
||||
{
|
||||
@ -1605,6 +1627,7 @@ intrinsic_functions[] =
|
||||
{"abs", 1, true, intrinsic_abs},
|
||||
{"clamp", 3, true, intrinsic_clamp},
|
||||
{"max", 2, true, intrinsic_max},
|
||||
{"pow", 2, true, intrinsic_pow},
|
||||
{"saturate", 1, true, intrinsic_saturate},
|
||||
};
|
||||
|
||||
|
10
tests/pow.shader_test
Normal file
10
tests/pow.shader_test
Normal file
@ -0,0 +1,10 @@
|
||||
[pixel shader]
|
||||
float4 main(uniform float2 u, uniform float2 v) : sv_target
|
||||
{
|
||||
return float4(pow(u.y, 3), pow(u, v), pow(0.5, v.y));
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float4 0.4 0.8 2.5 2.0
|
||||
draw quad
|
||||
probe all rgba (0.512, 0.101192884, 0.64, 0.25) 4
|
Loading…
Reference in New Issue
Block a user