Commit Graph

3049 Commits

Author SHA1 Message Date
Conor McCarthy
b765f3c770 vkd3d-shader: Make the paramater allocator slab size at least MAX_REG_OUTPUT.
The allocator is used for DXIL input/output parameter arrays.
2023-09-25 22:07:01 +02:00
Zebediah Figura
257a351f37 vkd3d-shader/spirv: Flush NaN to zero in ftoi. 2023-09-25 22:06:45 +02:00
Zebediah Figura
a5b6162d25 vkd3d-shader/spirv: Clamp ftoi upper bound to INT_MAX. 2023-09-25 22:06:44 +02:00
Zebediah Figura
9dee15da5b vkd3d-shader/spirv: Clamp ftoi lower bound to INT_MIN. 2023-09-25 22:06:43 +02:00
Zebediah Figura
cc893a3368 vkd3d-shader/spirv: Clamp ftou upper bound to UINT_MAX. 2023-09-25 22:06:41 +02:00
Zebediah Figura
491146fa94 vkd3d-shader/spirv: Clamp ftou lower bound to zero. 2023-09-25 22:06:39 +02:00
Giovanni Mascellani
b9fa8cfaa6 vkd3d: Set the image aspect when clearing UAVs.
This fixes a number of tests on Mesa on Intel.
2023-09-22 11:06:55 +02:00
Nikolay Sivov
485cbe8cb7 vkd3d-shader/hlsl: Add constant folding for 'sat'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-22 11:06:35 +02:00
Nikolay Sivov
89c99cccce vkd3d-shader/hlsl: Add constant folding for 'exp2'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-22 11:06:34 +02:00
Nikolay Sivov
c16c5caad8 vkd3d-shader/hlsl: Add constant folding for 'fract'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-22 11:06:33 +02:00
Giovanni Mascellani
c69562128a vkd3d-shader/hlsl: Correctly fold casts from double. 2023-09-22 11:06:29 +02:00
Giovanni Mascellani
49bbd98a04 vkd3d-shader/hlsl: Correctly fold casts from float.
I.e., without invoking undefined behavior in the compiler. The rules
are desumed from the the MSDN documentation for ftoi and ftou.
2023-09-22 11:06:28 +02:00
Nikolay Sivov
d9c984c11a vkd3d-shader/hlsl: Add constant folding for the ternary operator.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-22 11:06:23 +02:00
Nikolay Sivov
6d1ba83856 vkd3d-shader/hlsl: Use conditional moves for arithmetic operators instead of branching.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-22 11:06:22 +02:00
Giovanni Mascellani
34b1c0fe5d vkd3d-shader/ir: Validate source parameters. 2023-09-22 11:06:18 +02:00
Giovanni Mascellani
603170106c vkd3d-shader/ir: Validate destination parameters. 2023-09-22 11:06:17 +02:00
Giovanni Mascellani
585e60ad3b vkd3d-shader/ir: Validate register types. 2023-09-22 11:06:16 +02:00
Giovanni Mascellani
b09cfbda90 vkd3d-shader/ir: Validate instruction handlers. 2023-09-22 11:06:15 +02:00
Giovanni Mascellani
c052cd8998 vkd3d-shader/ir: Introduce a boilerplate to validate the generated IR.
For the moment the validator is trivial, it never fails. Checks will
be added incrementally.
2023-09-22 11:06:13 +02:00
Giovanni Mascellani
cf871d2cb2 vkd3d-shader: Embed the parsing location in vkd3d_shader_instruction.
So that it can be used for printing meaningful error locations by
downstream processors.
2023-09-22 11:06:12 +02:00
Giovanni Mascellani
531c41306d vkd3d-shader/dxil: Destroy the SM6 parser on parsing errors. 2023-09-22 11:06:11 +02:00
Giovanni Mascellani
78220ed07e vkd3d-shader/tpf: Destroy the SM4 parser on parsing errors. 2023-09-22 11:06:10 +02:00
Giovanni Mascellani
a2fb9588c7 vkd3d-shader/d3dbc: Destroy the SM1 parser on parsing errors. 2023-09-22 11:06:09 +02:00
Giovanni Mascellani
d1cb6b41b1 vkd3d-shader/d3dbc: Skip DCL semantic tokens properly. 2023-09-22 11:06:08 +02:00
Giovanni Mascellani
9487cc6ab5 vkd3d-shader/ir: Simplify the control flow in shader_instruction_normalise_io_params(). 2023-09-22 11:06:06 +02:00
Giovanni Mascellani
5220125c9f vkd3d-shader/ir: Fully reinitialize an instruction when making it a NOP. 2023-09-22 11:06:05 +02:00
Giovanni Mascellani
05af25eecb vkd3d-shader: Rename shader_instruction_init(). 2023-09-22 11:06:05 +02:00
Andrey Gusev
78ff0f3df4 vkd3d: Add ID3D12Device2 interface. 2023-09-22 11:05:59 +02:00
Henri Verbeet
90d4529f27 Release 1.9. 2023-09-21 19:16:32 +02:00
Zebediah Figura
9417c7cfb7 vkd3d-shader/d3dbc: Translate sm1 fragment outputs to system values. 2023-09-21 19:16:31 +02:00
Zebediah Figura
1615e5a76b vkd3d-shader/dxbc: Map sm4 fragment outputs to system values based on their name. 2023-09-21 19:16:29 +02:00
Zebediah Figura
fd120d8f2d vkd3d-shader: Rename vkd3d_shader_next_stage_info to vkd3d_shader_varying_map_info.
It was originally intended that this structure could hold other information
about the next stage which compilation might depend on. For example, compilation
to GLSL needs to know the type of the next shader in some circumstances.

That was never actualized, and since the API is fixed at this point for 1.9, it
makes the most sense to rename the structure to match its actual scope.

The documentation was written and arranged to imply that the structure would
hold other information about the next shader than the varying map; this is
changed accordingly as well.
2023-09-21 19:16:27 +02:00
Henri Verbeet
f796d8668e vkd3d-shader: Export vkd3d_shader_build_varying_map. 2023-09-19 21:30:35 +02:00
Henri Verbeet
da89da2bf3 vkd3d-shader: Hide support for DXIL sources.
Unfortunately this is not sufficiently ready to release.
2023-09-18 21:04:19 +02:00
Giovanni Mascellani
ee28861837 vkd3d-shader/hlsl: Document some possibly obscure HLSL opcodes. 2023-09-14 20:28:55 +02:00
Giovanni Mascellani
f251da574c vkd3d-shader/hlsl: Remove HLSL_OP3_LERP.
It is unused, and it's not clear whether it would be of any help to
have it.
2023-09-14 20:28:54 +02:00
Nikolay Sivov
45541dd9b2 vkd3d-shader/asm: Tweak TEXCOORD declaration name.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-13 23:11:16 +02:00
Nikolay Sivov
ee6c66eb1b vkd3d-shader/d3dbc: Disallow 1D sampler types when writing sampler declaration.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-13 23:11:14 +02:00
Nikolay Sivov
177ea3bcbd vkd3d-shader/hlsl: Produce 2D resource declarations and loads for tex1D().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-13 23:11:11 +02:00
Francisco Casas
39563aa5b3 vkd3d-shader/hlsl: Lower matrix swizzles. 2023-09-13 23:10:38 +02:00
Nikolay Sivov
fc2aaee224 vkd3d-shader: Use ternary operator in fmod() implementation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-07 19:15:26 +02:00
Nikolay Sivov
1002a6b357 vkd3d-shader/tpf: Use 'movc' to implement ternary operator.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-07 19:15:25 +02:00
Nikolay Sivov
c5d680d141 vkd3d-shader/hlsl: Add tex1D() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-07 19:15:06 +02:00
Conor McCarthy
3badab2086 vkd3d-shader: Handle size in bytes in spirv_compiler_emit_cbv_declaration().
The caller passes a byte size now.
2023-09-04 20:25:33 +02:00
Conor McCarthy
bad4c74002 vkd3d-shader: Match only UAV descriptors in vkd3d_shader_scan_add_uav_flag().
Fixes compilation failures in Cyberpunk 2077 due to missing UAV counter
flag.
2023-09-04 20:25:31 +02:00
Zebediah Figura
a597dc8755 vkd3d-shader/hlsl: Define lit() in HLSL. 2023-08-30 22:49:03 +02:00
Zebediah Figura
9ab77658f2 vkd3d-shader/hlsl: Define smoothstep() in HLSL. 2023-08-30 22:49:01 +02:00
Zebediah Figura
d396c4ce27 vkd3d-shader/hlsl: Store the internal name counter in struct hlsl_ctx.
This is minutely more efficient than using a global variable and atomic instructions.
2023-08-30 22:48:59 +02:00
Zebediah Figura
f22e52f358 vkd3d-shader/hlsl: Separate an add_user_call() helper. 2023-08-30 22:48:57 +02:00
Zebediah Figura
63e056512d vkd3d-shader/hlsl: Introduce an hlsl_sprintf_alloc() helper. 2023-08-30 22:48:55 +02:00
Conor McCarthy
d27b8eb2c0 vkd3d-shader/dxil: Implement DX instruction StoreOutput. 2023-08-30 22:48:52 +02:00
Conor McCarthy
bf49a1a95b vkd3d-shader/dxil: Declare shader outputs. 2023-08-30 22:48:50 +02:00
Conor McCarthy
e54f770669 vkd3d-shader/dxil: Implement the DXIL CALL instruction. 2023-08-30 22:48:48 +02:00
Conor McCarthy
720a087c28 vkd3d-shader/dxil: Replace the result type enum with a bool.
Changes to failure handling make the enum unnecessary.
2023-08-30 22:48:47 +02:00
Conor McCarthy
58d6e44501 vkd3d-shader/dxil: Validate the function block count. 2023-08-30 22:48:45 +02:00
Conor McCarthy
61a550017f vkd3d-shader/spirv: Handle signature element mask left shift in spirv_compiler_emit_output().
Element masks can have a left shift in DXIL, but these must start at
bit 0 in the register info. The SPIR-V declaration will either be a
builtin or have SpvDecorationComponent.
2023-08-30 22:48:43 +02:00
Conor McCarthy
ebc461f795 vkd3d-shader/spirv: Handle signature element mask left shift in calculate_clip_or_cull_distance_mask().
In DXIL these masks can have a left shift.
2023-08-30 22:48:41 +02:00
Nikolay Sivov
c39c5b3907 vkd3d-shader/hlsl: Add texCUBE() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-29 22:07:56 +02:00
Zebediah Figura
9624e2f904 vkd3d-shader/spirv: Declare SRVs and UAVs from the descriptor info. 2023-08-28 20:40:02 +02:00
Zebediah Figura
e8b3561252 vkd3d-shader/spirv: Declare constant buffers from the descriptor info. 2023-08-28 20:40:01 +02:00
Zebediah Figura
547768bcdd vkd3d-shader/spirv: Declare samplers from the descriptor info. 2023-08-28 20:39:59 +02:00
Zebediah Figura
a1e10e5c90 vkd3d-shader/spirv: Split spirv_compiler_has_combined_sampler() into two functions.
These functions do not really share any code in common.
2023-08-28 20:39:57 +02:00
Nikolay Sivov
18c1477464 vkd3d-shader/hlsl: Ignore 'inline' modifier for functions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-28 20:39:53 +02:00
Conor McCarthy
61841e9423 vkd3d-shader/tpf: Handle the swizzle type bitfield in dst param tokens. 2023-08-28 20:39:49 +02:00
Conor McCarthy
eddae47062 vkd3d-shader/tpf: Handle the dimension bitfield in dst param tokens.
A zero mask is still emitted for some scalar registers. This has no
effect on current tests, but keeping the correction is probably a good
idea.
2023-08-28 20:39:48 +02:00
Conor McCarthy
92021b7a3c vkd3d-shader/tpf: Use the default vec4 swizzle if a src param contains a mask. 2023-08-28 20:39:46 +02:00
Conor McCarthy
7e5d9e3b6f vkd3d-shader/tpf: Handle the dimension bitfield in src param tokens. 2023-08-28 20:39:45 +02:00
Conor McCarthy
5c706152fa vkd3d-shader/tpf: Validate the src register of case conditions.
Case values are constants in TPF.
2023-08-28 20:39:43 +02:00
Conor McCarthy
5c09752194 vkd3d: Do not flush descriptor heaps stored in the command list when the array size is exceeded.
An earlier patch introduced a bug which overflows the descriptor heap
array. The array should not be emptied here in case the list is
resubmitted, so just flush the new heap.
2023-08-24 21:44:03 +02:00
Francisco Casas
ed9e236b01 vkd3d-shader/tpf: Avoid reading constant value components beyond type's width (Valgrind).
We are passing map writemasks that may have more components than the
constant's data type, so a (j < width) check is added to avoid reading
components from the constant that are not intended to be used.

Remaining values in the register are initialized to zero.
2023-08-24 21:43:55 +02:00
Nikolay Sivov
89eda51855 vkd3d-shader/hlsl: Change warning code for unknown loop attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-24 21:43:50 +02:00
Nikolay Sivov
1153f6bb34 vkd3d-shader/hlsl: Parse "if" statement attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-24 21:43:49 +02:00
Zebediah Figura
926575a6f3 vkd3d-shader/hlsl: Force sm1 inputs to be 4-component only for vertex shaders.
Pixel shaders still have an appropriate writemask.
2023-08-24 21:43:44 +02:00
Zebediah Figura
622311da8e vkd3d-shader: Add a flag marking raw buffers to struct vkd3d_shader_descriptor_info. 2023-08-23 22:45:04 +02:00
Zebediah Figura
c1ebba9515 vkd3d-shader: Add structure stride to struct vkd3d_shader_descriptor_info1. 2023-08-23 22:45:04 +02:00
Zebediah Figura
88f85ffb50 vkd3d-shader: Add constant buffer size to struct vkd3d_shader_descriptor_info1. 2023-08-23 22:45:04 +02:00
Zebediah Figura
8c465c81cf vkd3d-shader: Add sample count to struct vkd3d_shader_descriptor_info1. 2023-08-23 22:45:04 +02:00
Zebediah Figura
ccedb7f711 vkd3d-shader: Set descriptor flags in the caller to vkd3d_shader_scan_add_descriptor().
Return the vkd3d_shader_descriptor_info1 from that function.
2023-08-23 22:45:02 +02:00
Conor McCarthy
f3baf55d97 vkd3d: Implement ID3D12Device1 with stubs. 2023-08-23 22:44:58 +02:00
Giovanni Mascellani
8f8c89fb87 vkd3d: Update a warning so that it aligns with the check that triggers it. 2023-08-23 22:44:52 +02:00
Conor McCarthy
3ca2259807 vkd3d: Fix invalid atomic behaviour in the view cache linked list.
The list suffers from the ABA problem, where comparison with the head
succeeds but the head's `next` pointer has changed. Occurs in Cyberpunk
2077, on NVIDIA at least.
2023-08-23 22:44:45 +02:00
Nikolay Sivov
4f2e07a45d vkd3d-shader/hlsl: Allow 'const' modifier without initializer in the global scope.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-15 21:51:50 +02:00
Zebediah Figura
240b9424fb vkd3d-shader/hlsl: Pass an hlsl_block pointer to append_output_copy(). 2023-08-15 21:51:47 +02:00
Zebediah Figura
a04e3a51dd vkd3d-shader/hlsl: Pass an hlsl_block pointer to prepend_input_copy(). 2023-08-15 21:51:39 +02:00
Zebediah Figura
7a4ac1afb1 vkd3d-shader/hlsl: Pass an hlsl_block pointer to prepend_uniform_copy(). 2023-08-15 21:51:37 +02:00
Francisco Casas
96f66aa4f8 vkd3d-shader/d3dbc: Use the bind count instead of the allocation size in d3dbc.c.
This should have no effect, since in SM1 the allocation size is the
same as the bind count because there are no texture registers.
It is just done for consistency.
2023-08-15 21:51:33 +02:00
Francisco Casas
d4a49d788a vkd3d-shader/hlsl: Simplify computation of allocation size. 2023-08-15 21:51:32 +02:00
Francisco Casas
37cfbe47d7 vkd3d-shader/hlsl: Sort synthetic separated samplers first for SM4. 2023-08-15 21:51:31 +02:00
Francisco Casas
81afe43569 vkd3d-shader/tpf: Put the actual bind count in the RDEF table. 2023-08-15 21:51:29 +02:00
Francisco Casas
7eba063136 vkd3d-shader/hlsl: Rename hlsl_reg.bind_count to hlsl_reg.allocation_size.
We have to distinguish between the "bind count" and the "allocation size"
of variables.

The "allocation size" affects the starting register id for the resource to
be allocated next, while the "bind count" is determined by the last field
actually used. The former may be larger than the latter.

What we are currently calling hlsl_reg.bind_count is actually the
"allocation size", so a rename is in order.

The real "bind count", which will be introduced in following patches,
is important because it is what should be shown in the RDEF table and
some resource allocation rules depend on it.

For instance, for this shader:

    texture2D texs[3];
    texture2D tex;

    float4 main() : sv_target
    {
        return texs[0].Load(int3(0, 0, 0)) + tex.Load(int3(0, 0, 0));
    }

the variable "texs" has a "bind count" of 1, but an "allocation size" of
3:

    // Resource Bindings:
    //
    // Name                                 Type  Format         Dim      HLSL Bind  Count
    // ------------------------------ ---------- ------- ----------- -------------- ------
    // texs                              texture  float4          2d             t0      1
    // tex                               texture  float4          2d             t3      1
2023-08-15 21:51:27 +02:00
Nikolay Sivov
98f63c46f8 vkd3d-shader/hlsl: Use type width in fold_rcp().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:21 +02:00
Nikolay Sivov
932c5e36dc vkd3d-shader/hlsl: Add constant folding for 'log2'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:20 +02:00
Nikolay Sivov
58bc61e48d vkd3d-shader/hlsl: Add constant folding for 'sqrt'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:18 +02:00
Nikolay Sivov
7e99188dc7 vkd3d-shader: Add constant folding for 'dp2add' operation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:15 +02:00
Nikolay Sivov
25ff56769b vkd3d-shader: Add constant folding for the 'dot' operation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-14 18:38:15 +02:00
Zebediah Figura
983d01df8c vkd3d-shader: Get rid of the uav_ranges array.
This is now redundant; the register ID is encoded into the scan descriptors.
2023-08-14 18:38:11 +02:00
Zebediah Figura
7d02922541 vkd3d-shader: Add register ID to struct vkd3d_shader_descriptor_info1. 2023-08-14 18:38:11 +02:00
Zebediah Figura
4e9798f6f7 vkd3d-shader: Introduce struct vkd3d_shader_scan_descriptor_info1. 2023-08-14 18:38:11 +02:00
Zebediah Figura
fd4a820c4b vkd3d-shader: Centralize cleanup on error in scan_with_parser(). 2023-08-14 18:38:11 +02:00
Zebediah Figura
9c5cb2de18 vkd3d-shader: Factor more code into vkd3d_shader_scan_get_uav_descriptor_info(). 2023-08-14 18:38:11 +02:00