711 Commits

Author SHA1 Message Date
Elizabeth Figura
e40b191943 tests: Adjust arithmetic-int.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
fb75c0530a tests: Adjust arithmetic-float-uniform.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
8b4f0f348a tests: Adjust arithmetic-float.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
5f55f5adc7 tests: Adjust angle-unit.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Shaun Ren
f0070cd595 tests: Test invalid out const parameters. 2025-01-21 14:03:44 +01:00
Shaun Ren
802d7317cb vkd3d-shader/hlsl: Implement the InterlockedXor() intrinsic. 2025-01-20 15:42:45 +01:00
Shaun Ren
5b9634a7b7 vkd3d-shader/hlsl: Implement the InterlockedMin() intrinsic. 2025-01-20 15:42:43 +01:00
Shaun Ren
b447fdce51 vkd3d-shader/hlsl: Implement the InterlockedExchange() intrinsic. 2025-01-20 15:41:07 +01:00
Shaun Ren
5f943e9110 tests/hlsl: Add tests for valid destination types of atomic operations. 2025-01-20 15:30:54 +01:00
Shaun Ren
b3c13b443f tests/hlsl: Add tests to check the void return type of atomic ops. 2025-01-20 15:26:10 +01:00
Shaun Ren
728cf1dcfe tests/hlsl: Add tests to check the types of the value arguments of atomic ops. 2025-01-20 15:26:10 +01:00
Shaun Ren
c8b87f9bd9 tests/hlsl: Add a test for UAV InterlockedCompareExchange(). 2025-01-20 15:26:10 +01:00
Nikolay Sivov
a082daeb56 vkd3d-shader/hlsl: Implement the isinf() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-01-16 19:25:02 +01:00
Francisco Casas
2d91bd9200 vkd3d-shader/hlsl: Properly lower casts to int for negative numbers.
While it looks complicated, it is what fxc/d3dcompiler does.

A shader as simple as:

    float4 f;

    float4 main() : sv_target
    {
        return (int4)f;
    }

results in the following instructions:

    ps_2_0
    def c1, 0, 1, 0, 0
    frc r0, c0
    cmp r1, -r0, c1.x, c1.y
    add r0, -r0, c0
    mov r2, c0
    cmp r1, r2, c1.x, r1
    add r0, r0, r1
    mov oC0, r0
2025-01-16 18:46:49 +01:00
Francisco Casas
4f7c117296 tests: Test casting negative floats to int.
Turns out we are not doing this correctly in SM1, because the rounding
should be to the number that is closer to zero and lower_casts_to_int()
doesn't do that.

A vertex shader test is added since in SM1 they must rely on the SLT
operation instead of the CMP operation.
2025-01-16 18:43:12 +01:00
Francisco Casas
0a5955372a vkd3d-shader/hlsl: Lower separate SampleGrad() for SM1. 2025-01-14 17:59:50 +01:00
Francisco Casas
00b79cd781 tests: Test SampleGrad() on ps_3_0.
fxc compiles this method even without the backcompat option.

Furthermore, it even does it on ps_2_0 despite the fact that it maps to
a texldd instruction, which is not available on plain ps_2_0, nor ps_2_b,
only on ps_2_a and ps_3_0 according to documentation.

It is worth mentioning that the additional offset parameter is not
supported when lowering.
2025-01-14 17:59:50 +01:00
Francisco Casas
9b3b47b1b8 vkd3d-shader: Avoid left shifting signed integers. (ubsan)
Otherwise ubsan reports these errors on the bitwise.shader_test:

    libs/vkd3d-shader/hlsl_constant_ops.c:970:50: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
    libs/vkd3d-shader/hlsl_constant_ops.c:970:50: runtime error: left shift of negative value -12
2025-01-10 19:51:55 +01:00
Shaun Ren
646087d54c vkd3d-shader/hlsl: Collect together terms with constant coefficients.
We apply distributivity to applicable expressions, specifically with
the following rewrite rules:

  (x OPL a) OPR (x OPL b) -> x OPL (a OPR b)
  (y OPR (x OPL a)) OPR (x OPL b) -> y OPR (x OPL (a OPR b))
  ((x OPL a) OPR y) OPR (x OPL b) -> (x OPL (a OPR b)) OPR y
  (x OPL a) OPR ((x OPL b) OPR y) -> (x OPL (a OPR b)) OPR y
  (x OPL a) OPR (y OPR (x OPL b)) -> (x OPL (a OPR b)) OPR y

where a, b are constants.
2025-01-10 19:17:43 +01:00
Giovanni Mascellani
922af42aca tests/hlsl: Add some clip/cull distance tests. 2024-12-19 20:54:56 +01:00
Henri Verbeet
31ea11fb0e tests/shader_runner: Ignore the "backcompat" option for shader model 5.1+. 2024-12-19 12:24:02 +01:00
Francisco Casas
825784322d vkd3d-shader/ir: Properly lower texldp. 2024-12-18 17:30:15 +01:00
Francisco Casas
02fc26507b tests/hlsl: Test tex2Dproj(). 2024-12-18 17:29:10 +01:00
Francisco Casas
7cc802afd7 vkd3d-shader/ir: Properly lower texldb. 2024-12-18 17:27:43 +01:00
Anna (navi) Figueiredo Gomes
f09ac4959e vkd3d-shader/hlsl: Implement the GatherCmp() methods. 2024-12-18 17:27:43 +01:00
Anna (navi) Figueiredo Gomes
fd8bcc188f tests/hlsl: Add GatherCmp() tests. 2024-12-18 17:27:43 +01:00
Conor McCarthy
8d479d2ea6 vkd3d-shader/dxil: Implement DX intrinsic EvalCentroid. 2024-12-18 17:27:43 +01:00
Conor McCarthy
1bb3b13c0a vkd3d-shader/dxil: Implement DX intrinsic EvalSampleIndex. 2024-12-18 17:27:43 +01:00
Giovanni Mascellani
ed552e4519 tests/hlsl: Add tests for the EvaluateAttribute*() intrinsics.
Based on earlier tests by Conor McCarthy.
2024-12-18 17:27:31 +01:00
Elizabeth Figura
27c7776947 tests: Use fail(sm<5) instead of [require] for uav-atomics. 2024-12-17 16:37:41 +01:00
Elizabeth Figura
8fcbbfb8b1 tests/shader_runner: Test versions where the compilation result changes.
Adjust the algorithm for deciding for which profiles to test compilation.

We first ensure that if the compilation result changes (most often as the result
of a feature introduced in a specific version), we test the versions immediately
on either side of the change, to validate that vkd3d-shader is emulating the
same version behaviour.

We then ensure that we are testing at least one version from each set of sm1,
sm4, and sm6.
2024-12-17 16:35:09 +01:00
Henri Verbeet
c4f69f4d3d vkd3d-shader/hlsl: Prefer overload candidates without component count widening. 2024-12-16 17:09:40 +01:00
Henri Verbeet
64bb4150f0 vkd3d-shader/hlsl: Prefer overload candidates without component type narrowing. 2024-12-16 17:09:40 +01:00
Henri Verbeet
32d432ab5e vkd3d-shader/hlsl: Prefer overload candidates with matching component types. 2024-12-16 17:09:40 +01:00
Henri Verbeet
6b8878377f vkd3d-shader/hlsl: Prefer overload candidates with matching component type classes. 2024-12-16 17:09:40 +01:00
Henri Verbeet
63fce3062e vkd3d-shader/hlsl: Prefer overload candidates without component count narrowing. 2024-12-16 17:09:40 +01:00
Henri Verbeet
cdf6100fe5 tests: Add yet more overload resolution tests. 2024-12-16 17:09:40 +01:00
Victor Chiletto
a1d995e740 vkd3d-shader/hlsl: Unroll loops with conditional jumps. 2024-12-12 16:54:04 +01:00
Shaun Ren
2c9cf7c78b vkd3d-shader/hlsl: Implement normalization of binary expressions.
We normalize binary expressions by attempting to group constants
together, in order to facilitate further simplification of the
expressions.

For any binary operator OP, non-constants x, y, and constants a, b, we
apply the following rewrite rules:

  a OP x -> x OP a, if OP is commutative.

  (x OP a) OP b -> x OP (a OP b), if OP is associative.

  (x OP a) OP y -> (x OP y) OP a, if OP is associative and commutative.

  x OP (y OP a) -> (x OP y) OP a, if OP is associative.

Note that we consider floating point operations to be
non-associative.
2024-12-11 15:32:22 +01:00
Francisco Casas
aa3a716249 vkd3d-shader/hlsl: Allow lowering separate sampler arrays on deref offset 0. 2024-12-10 15:52:52 +01:00
Francisco Casas
2c9269ac3a vkd3d-shader/hlsl: Allocate samplers by decreasing bind count in SM1. 2024-12-10 15:52:50 +01:00
Francisco Casas
3a6bf3be24 vkd3d-shader/hlsl: Lower separated samplers for SM1.
The combined sampler is created as a SAMPLER instead of a TEXTURE
because that fits all our current infrastructure. The only problem is
that in the CTAB it must appear as a Texture, so the new field
hlsl_type.is_combined_sampler is added.

Co-authored-by: Elizabeth Figura <zfigura@codeweavers.com>
2024-12-10 15:51:43 +01:00
Francisco Casas
58d318719c tests: Test sampler array allocation. 2024-12-10 15:51:34 +01:00
Francisco Casas
a0a555878f tests: Add additional sampler allocation tests for SM1. 2024-12-10 14:02:00 +01:00
Conor McCarthy
f3fac95bb6 tests/hlsl: Add int64 wave op tests. 2024-12-09 14:21:49 +01:00
Conor McCarthy
50306a8b08 tests/hlsl: Add uint64 wave op tests. 2024-12-09 14:20:28 +01:00
Conor McCarthy
f0f8bb3f36 tests/hlsl: Add float64 wave op tests. 2024-12-09 14:17:05 +01:00
Feifan He
9d4bcc951d vkd3d-shader/msl: Implement VKD3DSIH_USHR. 2024-12-05 21:26:03 +01:00
Feifan He
138e7caa03 vkd3d-shader/msl: Implement VKD3DSIH_ISHR. 2024-12-05 21:26:03 +01:00
Feifan He
5d6ed0fa30 vkd3d-shader/msl: Implement VKD3DSIH_ISHL. 2024-12-05 21:26:03 +01:00