mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Support log10() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
49b63fbeba
commit
210caa931d
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;
|
||||
}
|
||||
|
||||
static bool intrinsic_log10(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;
|
||||
|
||||
/* 1 / log2(10) */
|
||||
if (!(coeff = hlsl_new_float_constant(ctx, 0.301029996f, loc)))
|
||||
return false;
|
||||
|
||||
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, log, &coeff->node, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_log2(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
@ -3311,6 +3330,7 @@ intrinsic_functions[] =
|
||||
{"length", 1, true, intrinsic_length},
|
||||
{"lerp", 3, true, intrinsic_lerp},
|
||||
{"lit", 3, true, intrinsic_lit},
|
||||
{"log10", 1, true, intrinsic_log10},
|
||||
{"log2", 1, true, intrinsic_log2},
|
||||
{"max", 2, true, intrinsic_max},
|
||||
{"min", 2, true, intrinsic_min},
|
||||
|
@ -10,3 +10,16 @@ float4 main() : sv_target
|
||||
uniform 0 float4 2.0 4.0 5.0 0.4
|
||||
draw quad
|
||||
probe all rgba (1.0, 2.0, 2.32192802, -1.32192802) 1
|
||||
|
||||
[pixel shader]
|
||||
uniform float4 x;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return log10(x);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float4 10.0 100.0 1.0 0.1
|
||||
draw quad
|
||||
probe all rgba (1.0, 2.0, 0.0, -1.0) 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user