Commit Graph

7243 Commits

Author SHA1 Message Date
Elizabeth Figura
ea21dddec9 vkd3d-shader/hlsl: Allow compiling directly to GLSL. 2025-04-02 19:33:41 +02:00
Elizabeth Figura
33cd10581e vkd3d-shader/glsl: Invert gl_FragCoord w. 2025-04-02 19:32:39 +02:00
Francisco Casas
4b9c23272a vkd3d-shader/ir: Reset instruction pointers after shader_instruction_array_insert_at().
Every call to shader_instruction_array_insert_at() means a possible
reallocation of all vsir instructions in the program. This means that all
previous pointers are potentially no longer valid.

We are currently using these potentially invalid pointers in some cases,
usually in the form of "ins->location". This commit fixes these.

I moved all pointer changes to right after the call to
shader_instruction_array_insert_at() to make this more evident.
2025-04-02 19:25:12 +02:00
Giovanni Mascellani
875c5df519 vkd3d-shader/ir: Validate register id and index for CONSTBUFFER registers. 2025-04-02 19:24:10 +02:00
Giovanni Mascellani
c181f147ce vkd3d-shader/ir: Validate register id and index for SAMPLER registers. 2025-04-02 19:08:50 +02:00
Giovanni Mascellani
9b7256c0c8 vkd3d-shader/ir: Validate register id and index for UAV registers. 2025-04-02 19:08:00 +02:00
Giovanni Mascellani
10d8760134 vkd3d-shader/ir: Validate register id and index for RESOURCE registers. 2025-04-02 19:06:43 +02:00
Shaun Ren
3e44bd4e5b tests/hlsl: Add a test for copy-propagation of uniform texture object writes. 2025-04-02 18:51:10 +02:00
Shaun Ren
7aebed0eea vkd3d-shader/hlsl: Ensure that uniform objects are never written to in copy_propagation_transform_object_load(). 2025-04-02 18:49:52 +02:00
Shaun Ren
b1d8915440 vkd3d-shader/hlsl: Divert written uniform derefs to temps before copy-propagation passes.
The following pixel shader currently triggers an infinite loop during
copy propagation, which is fixed by this commit:

    sampler s;
    Texture2D t1, t2;

    float4 main() : sv_target
    {
        Texture2D t = t1;
        t1 = t2;
        t2 = t;
        return t1.Sample(s, float2(0, 0)) + t2.Sample(s, float2(0, 0));
    }

The infinite loop occurs because copy_propagation_transform_object_load()
replaces t1 in the resource_load(t1, ...) instruction
with t2, t1, t2, ... repeatedly.
2025-04-02 18:49:52 +02:00
Francisco Casas
3ead8d532b vkd3d-shader/hlsl: Allow non-constant deref propagation on SM1.
Note that we still have to preempt the propagation to SM1 pixel shader
uniforms. Otherwise this will turn the many constant derefs that appear
from the <index-val> copy generated in lower_index_loads() into a single
non-constant deref, causing it to allocate all the registers instead of
up until the last one used.
2025-04-02 18:27:16 +02:00
Francisco Casas
f65e6265e0 vkd3d-shader/ir: Normalise MOVA and d3dbc indirect addressing. 2025-04-02 18:27:16 +02:00
Francisco Casas
fd02d69dda vkd3d-shader/hlsl: Implement indirect addressing for d3dbc target profiles. 2025-04-02 18:26:03 +02:00
Francisco Casas
0e0ed72652 vkd3d-shader/d3dbc: Respect "idx_count" when writing registers.
Some SM1 src registers have idx_count = 0, in which case we have to
respect that instead of always reading reg->reg.idx[0].offset even when
it is invalid.
2025-04-02 18:06:48 +02:00
Francisco Casas
2327f87e37 tests/hlsl: Test SM1 vertex shader uniform allocation on indirect addressing.
Here, a vertex shader version of the previous test by Shaun is
introduced. Note that in this case the uniform allocates all 4 registers
instead of 3 because it is indirectly addressed.
2025-04-02 18:06:48 +02:00
Francisco Casas
b6ce1479fe tests/hlsl: Test vertex shader uniform indirect addressing.
Note that, for indexes with a decimal part, the behavior is different
depending on whether it is a temp load or a direct uniform load (which
can only happen on vertex shaders). The former rounds to the
closest-to-zero, while the latter rounds to the nearest even.
2025-04-02 18:06:18 +02:00
Elizabeth Figura
20b76f87bf vkd3d-shader/hlsl: Initialize the temp count for sm1. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
7cb5a7bebc vkd3d-shader/hlsl: Leave the swizzle zero for VSIR_DIMENSION_NONE registers. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
950f78041a vkd3d-shader/hlsl: Initialize the vsir dimension for sm1. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
856f4b55f6 vkd3d-shader/hlsl: Set the correct index count for sm1 DEPTHOUT. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
227e2cc0f5 vkd3d-shader/hlsl: Use vsir_*_from_hlsl_node() helpers in more places. 2025-04-02 17:58:18 +02:00
Henri Verbeet
110edf32d0 demos: Add basic DPI handling. 2025-03-19 14:10:24 +01:00
Nikolay Sivov
21e08955d3 vkd3d-shader/fx: Pad fx_2_0 object data blobs with zeroes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-18 15:56:32 +01:00
Giovanni Mascellani
803bf59654 tests: Mark an early depth stencil test as buggy on MoltenVK.
On MoltenVK it seems that all draws are always executed,
independently of the early depth stencil test. The problem doesn't
seem to belong to vkd3d or MoltenVK, because the generated Metal
commands look correct. I tried looking at a GPU capture with Xcode,
which was not very conclusive because it doesn't state clearly
whether early fragment tests were passed or not. Sometimes it
says that a fragment shader execution had no thread execution
data, which I interpret as the early fragment tests having
prevented the fragment shader from running, but it's not really
consistent, and it's never clear which results are based on
software simulation and which on the hardware run.

However taking everything into account I think the most likely
explanation is some incorrect optimization at the Metal level.
2025-03-18 15:55:29 +01:00
Giovanni Mascellani
05f7f03dab tests: Mark a queue synchronization test as buggy on MoltenVK.
The graphics pipeline triggers an internal error in the Metal
pipeline compiler, with a completely generic error message. I have
no idea what the actual problem is.
2025-03-18 15:53:59 +01:00