Commit Graph

706 Commits

Author SHA1 Message Date
802d7317cb vkd3d-shader/hlsl: Implement the InterlockedXor() intrinsic. 2025-01-20 15:42:45 +01:00
5b9634a7b7 vkd3d-shader/hlsl: Implement the InterlockedMin() intrinsic. 2025-01-20 15:42:43 +01:00
b447fdce51 vkd3d-shader/hlsl: Implement the InterlockedExchange() intrinsic. 2025-01-20 15:41:07 +01:00
5f943e9110 tests/hlsl: Add tests for valid destination types of atomic operations. 2025-01-20 15:30:54 +01:00
b3c13b443f tests/hlsl: Add tests to check the void return type of atomic ops. 2025-01-20 15:26:10 +01:00
728cf1dcfe tests/hlsl: Add tests to check the types of the value arguments of atomic ops. 2025-01-20 15:26:10 +01:00
c8b87f9bd9 tests/hlsl: Add a test for UAV InterlockedCompareExchange(). 2025-01-20 15:26:10 +01:00
a082daeb56 vkd3d-shader/hlsl: Implement the isinf() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-01-16 19:25:02 +01:00
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
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
0a5955372a vkd3d-shader/hlsl: Lower separate SampleGrad() for SM1. 2025-01-14 17:59:50 +01:00
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
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
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
922af42aca tests/hlsl: Add some clip/cull distance tests. 2024-12-19 20:54:56 +01:00
31ea11fb0e tests/shader_runner: Ignore the "backcompat" option for shader model 5.1+. 2024-12-19 12:24:02 +01:00
825784322d vkd3d-shader/ir: Properly lower texldp. 2024-12-18 17:30:15 +01:00
02fc26507b tests/hlsl: Test tex2Dproj(). 2024-12-18 17:29:10 +01:00
7cc802afd7 vkd3d-shader/ir: Properly lower texldb. 2024-12-18 17:27:43 +01:00
f09ac4959e vkd3d-shader/hlsl: Implement the GatherCmp() methods. 2024-12-18 17:27:43 +01:00
fd8bcc188f tests/hlsl: Add GatherCmp() tests. 2024-12-18 17:27:43 +01:00
8d479d2ea6 vkd3d-shader/dxil: Implement DX intrinsic EvalCentroid. 2024-12-18 17:27:43 +01:00
1bb3b13c0a vkd3d-shader/dxil: Implement DX intrinsic EvalSampleIndex. 2024-12-18 17:27:43 +01:00
ed552e4519 tests/hlsl: Add tests for the EvaluateAttribute*() intrinsics.
Based on earlier tests by Conor McCarthy.
2024-12-18 17:27:31 +01:00
27c7776947 tests: Use fail(sm<5) instead of [require] for uav-atomics. 2024-12-17 16:37:41 +01:00