mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Support log() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
210caa931d
commit
a1bd4e080e
Notes:
Alexandre Julliard
2023-04-13 23:19:56 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/89
@ -2843,6 +2843,25 @@ static bool intrinsic_lit(struct hlsl_ctx *ctx,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool intrinsic_log(struct hlsl_ctx *ctx,
|
||||||
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_constant *coeff;
|
||||||
|
struct hlsl_ir_node *log, *arg;
|
||||||
|
|
||||||
|
if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(log = add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_LOG2, arg, loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* ln(2) */
|
||||||
|
if (!(coeff = hlsl_new_float_constant(ctx, 0.69314718055f, loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, log, &coeff->node, loc);
|
||||||
|
}
|
||||||
|
|
||||||
static bool intrinsic_log10(struct hlsl_ctx *ctx,
|
static bool intrinsic_log10(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)
|
||||||
{
|
{
|
||||||
@ -3330,6 +3349,7 @@ intrinsic_functions[] =
|
|||||||
{"length", 1, true, intrinsic_length},
|
{"length", 1, true, intrinsic_length},
|
||||||
{"lerp", 3, true, intrinsic_lerp},
|
{"lerp", 3, true, intrinsic_lerp},
|
||||||
{"lit", 3, true, intrinsic_lit},
|
{"lit", 3, true, intrinsic_lit},
|
||||||
|
{"log", 1, true, intrinsic_log},
|
||||||
{"log10", 1, true, intrinsic_log10},
|
{"log10", 1, true, intrinsic_log10},
|
||||||
{"log2", 1, true, intrinsic_log2},
|
{"log2", 1, true, intrinsic_log2},
|
||||||
{"max", 2, true, intrinsic_max},
|
{"max", 2, true, intrinsic_max},
|
||||||
|
@ -23,3 +23,16 @@ float4 main() : sv_target
|
|||||||
uniform 0 float4 10.0 100.0 1.0 0.1
|
uniform 0 float4 10.0 100.0 1.0 0.1
|
||||||
draw quad
|
draw quad
|
||||||
probe all rgba (1.0, 2.0, 0.0, -1.0) 1
|
probe all rgba (1.0, 2.0, 0.0, -1.0) 1
|
||||||
|
|
||||||
|
[pixel shader]
|
||||||
|
uniform float4 x;
|
||||||
|
|
||||||
|
float4 main() : sv_target
|
||||||
|
{
|
||||||
|
return log(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 float4 3.0 10.0 1.0 0.1
|
||||||
|
draw quad
|
||||||
|
probe all rgba (1.0986123, 2.302585, 0.0, -2.302585) 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user