mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Add a stub for the noise() intrinsic.
This function is used in tx_1_0 code, but is also supported in fx_2_0 and fx_4_0 expressions. Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
committed by
Henri Verbeet
parent
93e1a8c784
commit
f135f7fe07
Notes:
Henri Verbeet
2025-06-19 20:52:05 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1564
@@ -199,6 +199,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/multiple-rt.shader_test \
|
||||
tests/hlsl/nested-arrays.shader_test \
|
||||
tests/hlsl/nointerpolation.shader_test \
|
||||
tests/hlsl/noise.shader_test \
|
||||
tests/hlsl/non-const-indexing.shader_test \
|
||||
tests/hlsl/normalize.shader_test \
|
||||
tests/hlsl/null.shader_test \
|
||||
|
@@ -3652,6 +3652,7 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op)
|
||||
[HLSL_OP1_LOG2] = "log2",
|
||||
[HLSL_OP1_LOGIC_NOT] = "!",
|
||||
[HLSL_OP1_NEG] = "-",
|
||||
[HLSL_OP1_NOISE] = "noise",
|
||||
[HLSL_OP1_RCP] = "rcp",
|
||||
[HLSL_OP1_REINTERPRET] = "reinterpret",
|
||||
[HLSL_OP1_ROUND] = "round",
|
||||
|
@@ -734,6 +734,7 @@ enum hlsl_ir_expr_op
|
||||
HLSL_OP1_ISINF,
|
||||
HLSL_OP1_LOG2,
|
||||
HLSL_OP1_LOGIC_NOT,
|
||||
HLSL_OP1_NOISE,
|
||||
HLSL_OP1_NEG,
|
||||
HLSL_OP1_RCP,
|
||||
HLSL_OP1_REINTERPRET,
|
||||
|
@@ -4294,6 +4294,28 @@ static bool intrinsic_mul(struct hlsl_ctx *ctx,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool intrinsic_noise(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_type *type = params->args[0]->data_type, *ret_type;
|
||||
struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0};
|
||||
|
||||
type = params->args[0]->data_type;
|
||||
if (type->class == HLSL_CLASS_MATRIX)
|
||||
{
|
||||
struct vkd3d_string_buffer *string;
|
||||
if ((string = hlsl_type_to_string(ctx, type)))
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
"Wrong argument type for noise(): expected vector or scalar, but got '%s'.", string->buffer);
|
||||
hlsl_release_string_buffer(ctx, string);
|
||||
}
|
||||
|
||||
args[0] = intrinsic_float_convert_arg(ctx, params, params->args[0], loc);
|
||||
ret_type = hlsl_get_scalar_type(ctx, args[0]->data_type->e.numeric.type);
|
||||
|
||||
return !!add_expr(ctx, params->instrs, HLSL_OP1_NOISE, args, ret_type, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_normalize(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
@@ -5258,6 +5280,7 @@ intrinsic_functions[] =
|
||||
{"min", 2, true, intrinsic_min},
|
||||
{"modf", 2, true, intrinsic_modf},
|
||||
{"mul", 2, true, intrinsic_mul},
|
||||
{"noise", 1, true, intrinsic_noise},
|
||||
{"normalize", 1, true, intrinsic_normalize},
|
||||
{"pow", 2, true, intrinsic_pow},
|
||||
{"radians", 1, true, intrinsic_radians},
|
||||
|
33
tests/hlsl/noise.shader_test
Normal file
33
tests/hlsl/noise.shader_test
Normal file
@@ -0,0 +1,33 @@
|
||||
[pixel shader fail(sm>=6)]
|
||||
float v1;
|
||||
float1 v2;
|
||||
float4 v3;
|
||||
int2 v4;
|
||||
int3 v5;
|
||||
|
||||
float4 func()
|
||||
{
|
||||
return noise(v1) + noise(v2) + noise(v3) + noise(v4) + noise(v5);
|
||||
}
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return float4(1, 2, 3, 4);
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe (0, 0) f32(1.0, 2.0, 3.0, 4.0)
|
||||
|
||||
[pixel shader fail]
|
||||
float2x2 v1;
|
||||
|
||||
float4 func()
|
||||
{
|
||||
return noise(v1);
|
||||
}
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return float4(1, 2, 3, 4);
|
||||
}
|
Reference in New Issue
Block a user