6997 Commits

Author SHA1 Message Date
Shaun Ren
31c3d46925 tests/shader_runner_vulkan: Check if create_shader_stage() fails in create_compute_pipeline(). 2025-01-20 14:59:12 +01:00
Conor McCarthy
10edcec030 vkd3d: Do not require the ALLOW_DEPTH_STENCIL flag for depth/stencil formats in GetCopyableFootprints(). 2025-01-20 14:37:13 +01:00
Conor McCarthy
e99906f05d vkd3d: Return correctly aligned depth/stencil sizes from GetCopyableFootprints(). 2025-01-20 13:59:46 +01:00
Conor McCarthy
1a4dedbc8d vkd3d: Return the correct depth/stencil plane format from GetCopyableFootprints(). 2025-01-20 13:45:16 +01:00
Giovanni Mascellani
17adde7f73 vkd3d: Describe DXGI_UNKNOWN as having one plane.
We're explicitly replacing zero with one in the only place where the
plane count being zero or one makes a difference. It also make sense:
UNKNOWN is used for buffers, which for all intents and purposes have one
plane.
2025-01-20 13:43:36 +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
Henri Verbeet
ce4f2728ba vkd3d-shader/msl: Get rid of a stray vkd3d_string_buffer_printf() in the VEC4 UINT immediate constant handling.
Uncovered by the ininf() test in the next commit. This is why we insist
on test coverage; unfortunately this one slipped through in
fd1beedc07becc7e5e49b64273f7bde7f9a8b2a0.
2025-01-16 19:18:08 +01:00
Francisco Casas
cf19b4da49 vkd3d-shader/hlsl: Specialize lowering SM1 casts to int for vertex shaders.
Vertex shaders do not have CMP, so we use SLT and MAD.

For example, this vertex shader:

    uniform float4 f;

    void main(inout float4 pos : position, out float4 t1 : TEXCOORD1)
    {
        t1 = (int4)f;
    }

results in:

    vs_2_0
    dcl_position v0
    slt r0, c0, -c0
    frc r1, c0
    add r2, -r1, c0
    slt r1, -r1, r1
    mad oT1, r0, r1, r2
    mov oPos, v0

while we have the lower_cmp() pass, each time it is applied many
instructions are generated, so this patch introduces a specialized
version of the cast-to-int lowering for efficiency.
2025-01-16 18:48:35 +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
efd7f2e014 vkd3d-shader/hlsl: Don't lower separate samples with texel offsets. 2025-01-14 17:59:50 +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
Giovanni Mascellani
c7e173a1ff vkd3d: Log the requested feature levels for D3D12_FEATURE_FEATURE_LEVELS. 2025-01-13 16:41:53 +01:00
Henri Verbeet
fb4b150f27 demos: Use the assembler to embed HLSL sources. 2025-01-13 16:39:35 +01:00
Henri Verbeet
4227858cfe vkd3d-shader/hlsl: Move RDEF generation to hlsl_codegen.c. 2025-01-10 20:03:14 +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
Francisco Casas
8056058aa1 vkd3d-shader: Avoid passing NULL to memset(). (ubsan)
Otherwise ubsan reports errors such as:

    libs/vkd3d-shader/spirv.c:7266:5: runtime error: null pointer passed as argument 1, which is declared to never be null
2025-01-10 19:51:55 +01:00
Francisco Casas
7b23cd4d3c vkd3d-shader: Avoid passing NULL to qsort(). (ubsan)
Otherwise ubsan reports runtime errors such as:

    libs/vkd3d-shader/ir.c:4731:5: runtime error: null pointer passed as argument 1, which is declared to never be null
2025-01-10 19:51:55 +01:00
Francisco Casas
eaf4d0bfbf vkd3d-shader: Avoid passing NULL to memcpy(). (ubsan)
Otherwise when passing "-fsanitize=undefined" to the compiler, ubsan
reports such as:

   libs/vkd3d-shader/ir.c:3794:5: runtime error: null pointer passed as argument 1, which is declared to never be null
2025-01-10 19:51:43 +01:00
Elizabeth Figura
29bac62ba2 vkd3d-shader/hlsl: Move the "dimx" and "dimy" fields to the type-specific union. 2025-01-10 19:38:13 +01:00
Elizabeth Figura
392398794f vkd3d-shader/d3dbc: Do not access the type dimensions for non-numeric types. 2025-01-10 19:24:21 +01:00
Elizabeth Figura
1ff1a51e4b vkd3d-shader/hlsl: Avoid some uses of the default case when switching over hlsl_base_type.
Since we have -Wswitch, this forces the developer to update all relevant
switches when an enum case is added.

Places where the default is just a FIXME are left alone.
2025-01-10 19:24:10 +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
Henri Verbeet
b60995b106 tests/shader_runner: Do not use skip() for shader model requirements.
Like we did before commit 067e6deee4aba447c6627ce02b58c6bdcd90470e.
These skips aren't all that interesting; it's entirely intentional that
e.g. a 2.0-3.0 run wouldn't run 4.0 shaders.
2024-12-19 21:17:05 +01:00
Henri Verbeet
45d9a097e6 vkd3d-shader/hlsl: Move sm4_free_extern_resources() to hlsl_codegen.c. 2024-12-19 21:09:32 +01:00
Henri Verbeet
b143754360 vkd3d-shader/hlsl: Move sm4_get_extern_resources() to hlsl_codegen.c. 2024-12-19 21:09:32 +01:00
Henri Verbeet
0236c480e3 vkd3d-shader/hlsl: Make sm4_get_interpolation_mode() static. 2024-12-19 21:09:32 +01:00
Giovanni Mascellani
4f7eb890ef vkd3d-shader/ir: Validate OUTCONTROLPOINT source parameters. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
495e10e93b vkd3d-shader/ir: Validate INCONTROLPOINT source parameters. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
513609ef0e vkd3d-shader/ir: Validate INPUT source parameters. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
23d4bd1dae vkd3d-shader/ir: Validate PATCHCONST source parameters using a uniform helper. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
67420aa8b6 vkd3d-shader/ir: Validate OUTPUT source parameters using a uniform helper. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
7de7025750 vkd3d-shader/ir: Disallow array signature elements for normalisation levels < SM6. 2024-12-19 21:06:13 +01:00
Giovanni Mascellani
922af42aca tests/hlsl: Add some clip/cull distance tests. 2024-12-19 20:54:56 +01:00
Anna (navi) Figueiredo Gomes
d5ed4df254 tests/shader_runner: Add a "mesa<23.3" tag. 2024-12-19 20:34:55 +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
Elizabeth Figura
d164752efc vkd3d-shader/d3dbc: Introduce d3dbc_parse_register(). 2024-12-18 17:30:16 +01:00
Elizabeth Figura
3c53293028 vkd3d-shader/ir: Separate VKD3DSPR_OUTPUT and VKD3DSPR_TEXCRDOUT.
This simplifies the IR.
2024-12-18 17:30:16 +01:00
Elizabeth Figura
8132239ed2 vkd3d-shader/ir: Separate VKD3DSPR_ADDR and VKD3DSPR_TEXTURE.
This simplifies the IR.
2024-12-18 17:30:16 +01:00
Elizabeth Figura
0df5dea653 vkd3d-shader/d3d-asm: Define register names in a table. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
65f3f56f63 vkd3d-shader/d3dbc: Normalize to a single VKD3DSPR_CONST register set when reading.
We don't need VKD3DSPR_CONST2 et al in the IR, even for disassembly.
2024-12-18 17:30:16 +01:00
Elizabeth Figura
118617916a vkd3d-shader: Explicitly translate between d3dbc and vsir register types. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
dd450c526f tests/d3d12: Make the dtof test a bit more interesting. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
efe686105d vkd3d-shader/spirv: Correctly implement DTOU. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
4130ce5bb9 vkd3d-shader/spirv: Correctly implement DTOI. 2024-12-18 17:30:16 +01:00
Elizabeth Figura
f416713608 vkd3d-shader/spirv: Correctly implement DTOF. 2024-12-18 17:30:16 +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