Commit Graph

3681 Commits

Author SHA1 Message Date
Giovanni Mascellani
9c678532a7 vkd3d-shader/ir: Dump the domination relationship. 2024-02-22 22:45:16 +01:00
Giovanni Mascellani
04c2852c1a vkd3d-shader/ir: Compute the domination relationship. 2024-02-22 22:45:15 +01:00
Giovanni Mascellani
2573d86ccf vkd3d-shader/ir: Dump the control flow graph in the GraphViz format. 2024-02-22 22:45:14 +01:00
Giovanni Mascellani
da037b61ba vkd3d-shader/ir: Build a representation of the control flow graph. 2024-02-22 22:45:13 +01:00
Conor McCarthy
1dffc281c9 vkd3d-shader/dxil: Implement DX intrinsic RawBufferStore. 2024-02-22 22:45:08 +01:00
Conor McCarthy
cab8b781ab vkd3d-shader/dxil: Handle raw and structured buffers in sm6_parser_emit_dx_buffer_store(). 2024-02-22 22:45:07 +01:00
Conor McCarthy
ce1875c435 vkd3d-shader/dxil: Implement DX intrinsic BufferStore. 2024-02-22 22:45:06 +01:00
Petrichor Park
02a3667822 vkd3d-shader/hlsl: Implement atan and atan2.
Also narrows some more todos on the tests.
2024-02-21 23:23:13 +01:00
Petrichor Park
69294c290b vkd3d-shader/hlsl: Implement acos and asin trig intrinsics.
Tests have already been implemented in 92044d5e; this commit also reduces
the scope of some of the todos (because now they're implemented!).

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55154
2024-02-21 23:23:11 +01:00
Henri Verbeet
d4223a03c8 vkd3d-shader/hlsl: Replace HLSL_MODIFIER_RASTERIZER_ORDERED with a hlsl_type.e.resource flag. 2024-02-21 23:23:08 +01:00
Henri Verbeet
49d14613a5 vkd3d-shader/hlsl: Introduce hlsl_type.e.resource. 2024-02-21 23:23:06 +01:00
Conor McCarthy
d9c68ee481 vkd3d-shader/dxil: Handle resource descriptor additional tag/value pairs.
These are tag/value pairs, and the current code only works if an element
type or element stride pair is present at index zero.
2024-02-20 22:50:19 +01:00
Conor McCarthy
96a0685ba6 vkd3d-shader/dxil: Implement DX intrinsic AtomicCompareExchange. 2024-02-20 22:50:16 +01:00
Conor McCarthy
560c9413c3 vkd3d-shader/dxil: Implement DX intrinsic AtomicBinOp. 2024-02-20 22:50:15 +01:00
Evan Tang
7b41abaa1b vkd3d-shader/hlsl: Support SV_PrimitiveID in pixel shaders. 2024-02-19 21:12:23 +01:00
Francisco Casas
8df34fce62 vkd3d-shader/hlsl: Emit fixme on non-direct resource stores.
Co-authored-by: Giovanni Mascellani <gmascellani@codeweavers.com>

These may happen when storing to structured buffers, and we are not
handling them properly yet. The included test reaches unreacheable code
before this patch.

Storing to buffers is complicated since we need to split the index
chain in two paths:
- The path within the variable where the resource is.
- The subpath to the part of the resource element that is being stored
  to.

For now, we will emit a fixme when the index chain in the lhs is not a
direct resource access.
2024-02-19 21:12:14 +01:00
Nikolay Sivov
315b7c5a42 vkd3d-shader/fx: Do not align structured data section.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-02-19 21:12:09 +01:00
Nikolay Sivov
c107ec03b8 vkd3d-shader/fx: Add initial support for writing buffers descriptions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-02-19 21:12:08 +01:00
Nikolay Sivov
656c068b32 vkd3d-shader/fx: Do not align strings for fx_4/fx_5 profiles.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-02-19 21:12:07 +01:00
Nikolay Sivov
d5f562d994 vkd3d-shader/fx: Use variable pointer in write_group().
The helper will need to access group annotations later, and these are
available for variables.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-02-19 21:12:05 +01:00
Francisco Casas
c249461e97 vkd3d-shader/hlsl: Parse Buffer types. 2024-02-19 21:11:55 +01:00
Francisco Casas
e1c759e1c9 vkd3d-shader/hlsl: Record valid methods in object_methods[].
Also, call hlsl_sampler_dim_count() and hlsl_offset_dim_count() after
type checking, to avoid reaching unreacheable cases.
2024-02-19 21:11:46 +01:00
Evan Tang
ee867bd470 vkd3d-shader/hlsl: Parse rasteriser-ordered view types. 2024-02-15 23:29:46 +01:00
Francisco Casas
e3ed5ac77e vkd3d-shader/hlsl: Lower casts to int for SM1. 2024-02-15 23:29:39 +01:00
Francisco Casas
4b5c7e3721 vkd3d-shader/d3dbc: Implement casts from ints to floats as a MOV.
For temporary registers, SM1-SM3 integer types are internally
represented as floating point, so, in order to perform a cast
from ints to floats we need a mere MOV.

For constant integer registers "iN" there is no operation for casting
from a floating point register to them. For address registers "aN", and
the loop counting register "aL", vertex shaders have the "mova" operation
but we haven't used these registers in any way yet.

We probably would want to introduce these as synthetic variables
allocated in a special register set. In that case we have to remember to
use MOVA instead of MOV in the store operations, but they shouldn't be src
or dst of CAST operations.

Regarding constant integer registers, in some shaders, constants are
expected to be received formatted as an integer, such as:

    int m;
    float4 main() : sv_target
    {
        float4 res = {0, 0, 0, 0};

        for (int k = 0; k < m; ++k)
            res += k;
        return res;
    }

which compiles as:

    // Registers:
    //
    //   Name         Reg   Size
    //   ------------ ----- ----
    //   m            i0       1
    //

    ps_3_0
    def c0, 0, 1, 0, 0
    mov r0, c0.x
    mov r1.x, c0.x
    rep i0
      add r0, r0, r1.x
      add r1.x, r1.x, c0.y
    endrep
    mov oC0, r0

but this only happens if the integer constant is used directly in an
instruction that needs it, and as I said there is no instruction that
allows converting them to a float representation.

Notice how a more complex shader, that performs operations with this
integer variable "m":

    int m;
    float4 main() : sv_target
    {
        float4 res = {0, 0, 0, 0};

        for (int k = 0; k < m * m; ++k)
            res += k;
        return res;
    }

gives the following output:

    // Registers:
    //
    //   Name         Reg   Size
    //   ------------ ----- ----
    //   m            c0       1
    //

    ps_3_0
    def c1, 0, 0, 1, 0
    defi i0, 255, 0, 0, 0
    mul r0.x, c0.x, c0.x
    mov r1, c1.y
    mov r0.y, c1.y
    rep i0
      mov r0.z, r0.x
      break_ge r0.y, r0.z
      add r1, r0.y, r1
      add r0.y, r0.y, c1.z
    endrep
    mov oC0, r1

Meaning that the uniform "m" is just stored as a floating point in
"c0", the constant integer register "i0" is just set to 255 (hoping
it is a high enough value) using "defi", and the "break_ge"
involving c0 is used to break from the loop.

We could potentially use this approach to implement loops from SM3
without expecting the variables being received as constant integer
registers.

According to the D3D documentation, for SM1-SM3 constant integer
registers are only used by the 'loop' and 'rep' instructions.
2024-02-15 23:29:37 +01:00
Conor McCarthy
6d4782ed7f vkd3d: Implement ID3D12Resource2. 2024-02-15 23:29:33 +01:00
Conor McCarthy
4668271872 vkd3d: Return DXGI_ERROR_NOT_FOUND from GetProtectedResourceSession(). 2024-02-15 23:29:32 +01:00
Conor McCarthy
6e634ad690 vkd3d-shader: Raise the instruction parameter allocation size if necessary.
Monolithic switch instructions have no definite case count limit.
2024-02-14 21:48:38 +01:00
Conor McCarthy
55c28e94f8 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_vselect(). 2024-02-14 21:48:32 +01:00
Conor McCarthy
c89627ec73 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_store(). 2024-02-14 21:48:31 +01:00
Conor McCarthy
4c7d956bdb vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_load(). 2024-02-14 21:48:30 +01:00
Conor McCarthy
04a9340164 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_extractval(). 2024-02-14 21:48:28 +01:00
Conor McCarthy
3c1ad054f0 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_cmp2(). 2024-02-14 21:48:26 +01:00
Conor McCarthy
cddb696499 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_cast(). 2024-02-14 21:48:25 +01:00
Conor McCarthy
76455580e2 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_dx_texture_load(). 2024-02-14 21:48:24 +01:00
Conor McCarthy
d04a8ea893 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_dx_split_double(). 2024-02-14 21:48:23 +01:00
Conor McCarthy
8c3512bd10 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_dx_sincos(). 2024-02-14 21:48:22 +01:00
Conor McCarthy
cc5293bb4f vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_dx_buffer_load(). 2024-02-14 21:48:21 +01:00
Conor McCarthy
6e3e200e96 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_dx_load_input(). 2024-02-14 21:48:20 +01:00
Conor McCarthy
eb1bfaa821 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_dx_tertiary(). 2024-02-14 21:48:19 +01:00
Conor McCarthy
1a2de25273 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_dx_cbuffer_load(). 2024-02-14 21:48:18 +01:00
Conor McCarthy
0a23c81196 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_dx_binary(). 2024-02-14 21:48:17 +01:00
Conor McCarthy
83e6ee4b3d vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_dx_unary(). 2024-02-14 21:48:14 +01:00
Conor McCarthy
217eb06f37 vkd3d-shader/dxil: Check for src param allocation failure in sm6_parser_emit_binop(). 2024-02-14 21:48:13 +01:00
Conor McCarthy
5a76cedf87 vkd3d-shader/dxil: Implement DX intrinsic SampleGrad. 2024-02-14 21:48:08 +01:00
Conor McCarthy
5178fb7364 vkd3d-shader/dxil: Implement DX intrinsic Sample. 2024-02-14 21:48:06 +01:00
Conor McCarthy
0a3eb61170 vkd3d-shader/dxil: Load sampler descriptors. 2024-02-14 21:48:03 +01:00
Conor McCarthy
aac3916fcf vkd3d: Handle D3D12_FEATURE_D3D12_OPTIONS13 in CheckFeatureSupport(). 2024-02-13 22:51:28 +01:00
Conor McCarthy
7b4e731aa5 vkd3d: Handle D3D12_FEATURE_D3D12_OPTIONS12 in CheckFeatureSupport(). 2024-02-13 22:51:28 +01:00
Conor McCarthy
68663b4fef vkd3d: Handle D3D12_FEATURE_D3D12_OPTIONS11 in CheckFeatureSupport(). 2024-02-13 22:51:28 +01:00