mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Support all() intrinsic.
This commit is contained in:
parent
2142d31f13
commit
e5b40092c2
Notes:
Alexandre Julliard
2023-02-20 22:45:13 +01: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/97
@ -43,6 +43,7 @@ vkd3d_cross_tests = \
|
||||
|
||||
vkd3d_shader_tests = \
|
||||
tests/abs.shader_test \
|
||||
tests/all.shader_test \
|
||||
tests/arithmetic-float.shader_test \
|
||||
tests/arithmetic-float-uniform.shader_test \
|
||||
tests/arithmetic-int.shader_test \
|
||||
|
@ -2370,6 +2370,37 @@ static bool intrinsic_abs(struct hlsl_ctx *ctx,
|
||||
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ABS, params->args[0], loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_all(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_ir_node *arg = params->args[0], *mul;
|
||||
struct hlsl_ir_constant *one, *zero;
|
||||
struct hlsl_ir_load *load;
|
||||
unsigned int i, count;
|
||||
|
||||
if (!(one = hlsl_new_float_constant(ctx, 1.0f, loc)))
|
||||
return false;
|
||||
list_add_tail(params->instrs, &one->node.entry);
|
||||
|
||||
if (!(zero = hlsl_new_float_constant(ctx, 0.0f, loc)))
|
||||
return false;
|
||||
list_add_tail(params->instrs, &zero->node.entry);
|
||||
|
||||
mul = &one->node;
|
||||
|
||||
count = hlsl_type_component_count(arg->data_type);
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
if (!(load = add_load_component(ctx, params->instrs, arg, i, loc)))
|
||||
return false;
|
||||
|
||||
if (!(mul = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, &load->node, mul, loc)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!add_binary_comparison_expr(ctx, params->instrs, HLSL_OP2_NEQUAL, mul, &zero->node, loc);
|
||||
}
|
||||
|
||||
/* Find the type corresponding to the given source type, with the same
|
||||
* dimensions but a different base type. */
|
||||
static struct hlsl_type *convert_numeric_type(const struct hlsl_ctx *ctx,
|
||||
@ -2986,6 +3017,7 @@ intrinsic_functions[] =
|
||||
{
|
||||
/* Note: these entries should be kept in alphabetical order. */
|
||||
{"abs", 1, true, intrinsic_abs},
|
||||
{"all", 1, true, intrinsic_all},
|
||||
{"asuint", -1, true, intrinsic_asuint},
|
||||
{"clamp", 3, true, intrinsic_clamp},
|
||||
{"cos", 1, true, intrinsic_cos},
|
||||
|
63
tests/all.shader_test
Normal file
63
tests/all.shader_test
Normal file
@ -0,0 +1,63 @@
|
||||
[require]
|
||||
shader model >= 4.0
|
||||
|
||||
[pixel shader]
|
||||
uniform float4 f;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return all(f);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float4 -1.1 1.6 1.3 0.5
|
||||
draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
[test]
|
||||
uniform 0 float4 0.0 1.6 1.3 0.5
|
||||
draw quad
|
||||
probe all rgba (0.0, 0.0, 0.0, 0.0)
|
||||
|
||||
[test]
|
||||
uniform 0 float4 1.0 0.0 1.3 0.5
|
||||
draw quad
|
||||
probe all rgba (0.0, 0.0, 0.0, 0.0)
|
||||
|
||||
[pixel shader]
|
||||
uniform float f;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return all(f);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float4 1.0 0.0 0.0 0.0
|
||||
draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
[test]
|
||||
uniform 0 float4 0.0 0.0 0.0 0.0
|
||||
draw quad
|
||||
probe all rgba (0.0, 0.0, 0.0, 0.0)
|
||||
|
||||
[pixel shader]
|
||||
uniform float2x2 f;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return all(f);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float4 1.0 2.0 0.0 0.0
|
||||
uniform 4 float4 3.0 4.0 0.0 0.0
|
||||
draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
[test]
|
||||
uniform 0 float4 1.0 2.0 0.0 0.0
|
||||
uniform 4 float4 0.0 4.0 0.0 0.0
|
||||
draw quad
|
||||
probe all rgba (0.0, 0.0, 0.0, 0.0)
|
Loading…
x
Reference in New Issue
Block a user