Commit Graph

2470 Commits

Author SHA1 Message Date
Henri Verbeet
eabcaf15fb vkd3d-shader/ir: Use vsir_instruction_is_dcl() in vsir_validate_instruction(). 2024-01-24 22:38:36 +01:00
Henri Verbeet
365ad56888 vkd3d-shader/ir: Get rid of shader_instruction_is_dcl(). 2024-01-24 22:38:34 +01:00
Conor McCarthy
54f6e6dd67 vkd3d-shader/spirv: Check for FEATURE_FLOAT64 when double precision use is flagged. 2024-01-24 22:38:09 +01:00
Conor McCarthy
e973271a40 vkd3d-shader/spirv: Handle the ISINF and ISNAN instructions in spirv_compiler_emit_alu_instruction(). 2024-01-24 22:38:04 +01:00
Conor McCarthy
cd674d593e vkd3d-shader/spirv: Implement the ISFINITE instruction. 2024-01-24 22:38:03 +01:00
Conor McCarthy
41cce4cbf1 vkd3d-shader/dxil: Handle floating point special value comparisons in sm6_parser_emit_dx_unary(). 2024-01-24 22:37:59 +01:00
Francisco Casas
b92f6c448a vkd3d-shader/ir: Lower texkill instructions to discard_nz. 2024-01-24 22:37:41 +01:00
Francisco Casas
7e75ac63a1 vkd3d-shader/d3dbc: Emit fixme for HLSL_RESOURCE_SAMPLE_LOD.
Currently, HLSL_RESOURCE_SAMPLE_LOD is not implemented for d3dbc,
but we are incorrectly writting a texld instruction to handle it.
This causes SM1 tests with the vulkan backend (in following patches)
to fail if VKD3D_SHADER_CONFIG="force_validation" is enabled.

For now a fixme is emited in these cases.
2024-01-24 22:37:38 +01:00
Henri Verbeet
bf628f0c74 vkd3d-shader/ir: Store block names in struct vsir_program. 2024-01-23 20:27:35 +01:00
Henri Verbeet
f3c7d2d05c vkd3d-shader/ir: Store the block count in struct vsir_program. 2024-01-23 20:27:34 +01:00
Henri Verbeet
98c6e85b33 vkd3d-shader/ir: Store control point counts in struct vsir_program. 2024-01-23 20:27:32 +01:00
Conor McCarthy
e4660fe0e6 vkd3d-shader/spirv: Emit DISCARD as a function call. 2024-01-23 20:26:59 +01:00
Conor McCarthy
367a06d748 vkd3d-shader/dxil: Use strcmp() to find the handle type.
We use strcmp() on the same type name elsewhere, and case-insensitive
matching does not seem necessary.
2024-01-23 20:26:53 +01:00
Conor McCarthy
1cca18a228 vkd3d-shader/dxil: Use strcmp() to find function names.
Function names are case-sensitive.
2024-01-23 20:26:52 +01:00
Conor McCarthy
4dec25cbde vkd3d-shader/dxil: Use strcmp() to check the entry point name.
Function names are case-sensitive.
2024-01-23 20:26:50 +01:00
Zebediah Figura
a8b0c03912 vkd3d-shader/hlsl: Always cast to bool in if() statements.
We emit sm4 if_nz for these, but that does a bitwise comparison to zero, which is wrong for floats.
2024-01-23 20:26:46 +01:00
Zebediah Figura
183172eff4 vkd3d-shader/hlsl: Validate that condition expressions are numeric. 2024-01-23 20:26:45 +01:00
Zebediah Figura
09220edd21 vkd3d-shader/hlsl: Validate the condition data type for loops as well. 2024-01-23 20:26:44 +01:00
Zebediah Figura
c18a349a3f vkd3d-shader/hlsl: Copy some missing fields in hlsl_type_clone(). 2024-01-23 20:26:42 +01:00
Giovanni Mascellani
de9725b6ba vkd3d-shader/ir: Remove DCL_TEMPS instructions.
We have to do work to keep it updated across passes and we never read it.
2024-01-23 20:26:38 +01:00
Giovanni Mascellani
4b869f73bb vkd3d-shader/ir: Run tracing and validation for DXIL code too. 2024-01-23 20:26:36 +01:00
Conor McCarthy
6df725718a vkd3d-shader/ir: Refactor return code checking in vkd3d_shader_normalise().
We started with only one or two of these but it has become excessive.

Patch originally written by Conor McCarthy and updated by Giovanni Mascellani.
2024-01-23 20:26:34 +01:00
Conor McCarthy
b3903636f7 vkd3d-shader/dxil: Implement DX intrinsic Binary. 2024-01-23 20:26:29 +01:00
Conor McCarthy
6c71cd5a72 vkd3d-shader/dxil: Add an operand type code for the return type. 2024-01-23 20:26:28 +01:00
Nikolay Sivov
0117e4fb7e vkd3d-shader/fx: Add initial support for writing passes for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-23 20:26:22 +01:00
Nikolay Sivov
b478f0a300 vkd3d-shader/fx: Add initial support for writing fx_2_0 binaries.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-23 20:26:21 +01:00
Nikolay Sivov
56100d36b1 vkd3d-shader/fx: Check technique type in global scope as well.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-23 20:26:20 +01:00
Nikolay Sivov
2c1905b780 vkd3d-shader/hlsl: Allow annotations on techniques.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-23 20:26:19 +01:00
Nikolay Sivov
76a689d43f vkd3d-shader/hlsl: Allow annotations on passes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-23 20:26:18 +01:00
Nikolay Sivov
e72f8f9a30 vkd3d-shader/hlsl: Add passes variables to the techniques.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-23 20:26:16 +01:00
Nikolay Sivov
fe8881747b vkd3d-shader/hlsl: Add initial support for parsing annotations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-23 20:26:15 +01:00
Giovanni Mascellani
232b2ad360 vkd3d-shader/ir: Validate PHI instructions. 2024-01-23 20:26:08 +01:00
Giovanni Mascellani
56f9057985 vkd3d-shader/ir: Do not allow IMMCONST and IMMCONST64 as destination registers. 2024-01-23 20:26:06 +01:00
Giovanni Mascellani
21633fcc52 vkd3d-shader/ir: Refactor register-type-specific code in parameter validation.
To better accommodate code for other register types.
2024-01-23 20:26:05 +01:00
Giovanni Mascellani
fb6409bda1 vkd3d-shader/ir: Check that all instructions appear in a block. 2024-01-23 20:26:03 +01:00
Giovanni Mascellani
dc56320b31 vkd3d-shader/tpf: Support SV_ViewportArrayIndex in pixel and vertex shaders. 2024-01-22 22:19:14 +01:00
Giovanni Mascellani
3a90f3e29d vkd3d-shader/tpf: Support SV_InstanceID in vertex shaders. 2024-01-22 22:19:13 +01:00
Giovanni Mascellani
b500381b5c vkd3d-shader/tpf: Support SV_RenderTargetArrayIndex in pixel and vertex shaders. 2024-01-22 22:19:12 +01:00
Giovanni Mascellani
45495f54f2 vkd3d-shader/spirv: Use capability ShaderViewportIndexLayerEXT for decoration ViewportIndex. 2024-01-22 22:19:11 +01:00
Giovanni Mascellani
6ac525d6c3 vkd3d-shader/spirv: Use capability ShaderViewportIndexLayerEXT for decoration Layer.
Capability Geometry allows to use the Layer builtin in geometry and pixel
shaders. For vertex and domain shaders ShaderLayer should be used, but it's only
available starting from SPIR-V 1.5. ShaderViewportIndexLayerEXT can be used
instead with extension SPV_EXT_shader_viewport_index_layer.
2024-01-22 22:19:09 +01:00
Henri Verbeet
adc02eada8 vkd3d-shader/ir: Store the temporary register count in struct vsir_program. 2024-01-22 22:18:53 +01:00
Henri Verbeet
94ca46916a vkd3d-shader/ir: Store the SSA register count in struct vsir_program. 2024-01-22 22:18:52 +01:00
Henri Verbeet
7b85cd6a31 vkd3d-shader/ir: Store the "use_vocp" field in struct vsir_program. 2024-01-22 22:18:51 +01:00
Henri Verbeet
23dcd4f22b vkd3d-shader/ir: Store the shader version in struct vsir_program. 2024-01-22 22:18:50 +01:00
Henri Verbeet
fc9043be3c vkd3d-shader/ir: Introduce struct vsir_program. 2024-01-22 22:18:48 +01:00
Conor McCarthy
55c7cd5c22 vkd3d-shader/dxil: Handle semantic kind ISFRONTFACE. 2024-01-22 22:18:33 +01:00
Conor McCarthy
9f409b67d7 vkd3d-shader/dxil: Handle semantic kind VERTEXID. 2024-01-22 22:18:32 +01:00
Conor McCarthy
ca7487a56d vkd3d-shader/spirv: Handle UINT32_MAX result from FIRSTBIT_HI and FIRSTBIT_SHI instructions. 2024-01-22 22:18:27 +01:00
Conor McCarthy
bfdc8b31a3 vkd3d-shader/dxil: Implement DX intrinsic BufferLoad for typed buffers. 2024-01-22 22:18:21 +01:00
Conor McCarthy
85052ba93e vkd3d-shader/dxil: Load typed UAV descriptors. 2024-01-22 22:18:19 +01:00
Conor McCarthy
89d1ef83f4 vkd3d-shader/dxil: Load typed SRV descriptors. 2024-01-22 22:18:18 +01:00
Conor McCarthy
5ebe0cc717 vkd3d-shader/spirv: Do not assert VKD3D_DATA_UINT in spirv_compiler_emit_ld_raw_structured_srv_uav(). 2024-01-22 22:18:17 +01:00
Conor McCarthy
80d7ea2924 vkd3d-shader/dxil: Pass the code block and instruction in a struct to intrinsic handlers.
Simplifies handling of intrinsics which need to emit more than one
instruction.
2024-01-22 22:18:16 +01:00
Henri Verbeet
f69c8b1cc4 vkd3d-shader/d3dbc: Store the "offset" field as an unsigned int in hlsl_sm1_register_from_semantic(). 2024-01-18 23:16:06 +01:00
Giovanni Mascellani
67902d4304 vkd3d-shader/ir: Validate RET instructions. 2024-01-18 23:15:58 +01:00
Giovanni Mascellani
af96730276 vkd3d-shader/ir: Validate SWITCH_MONOLITHIC instructions. 2024-01-18 23:15:57 +01:00
Giovanni Mascellani
46ebb404d7 vkd3d-shader/ir: Validate BRANCH instructions. 2024-01-18 23:15:56 +01:00
Giovanni Mascellani
bc9db34cdc vkd3d-shader/ir: Validate LABEL instructions. 2024-01-18 23:15:55 +01:00
Giovanni Mascellani
dd1b2feec0 vkd3d-shader/ir: Validate LABEL registers. 2024-01-18 23:15:54 +01:00
Giovanni Mascellani
17f4afc2b5 vkd3d-shader/ir: Validate that structured CF does not appear in block-based shaders. 2024-01-18 23:15:53 +01:00
Giovanni Mascellani
1d45b7a422 vkd3d-shader/spirv: Normalise the shader before allocating registers.
So registers are allocated after normalisation (which could require
additional registers).
2024-01-18 23:15:48 +01:00
Zebediah Figura
9ad48f16ea vkd3d-shader/hlsl: Forbid mismatched argument types in ternaries. 2024-01-18 23:15:44 +01:00
Zebediah Figura
275901557c vkd3d-shader/hlsl: Handle scalar values in ternaries. 2024-01-18 23:15:43 +01:00
Zebediah Figura
11112798c8 vkd3d-shader/hlsl: Handle scalar conditions in ternaries. 2024-01-18 23:15:42 +01:00
Zebediah Figura
2c8751478f vkd3d-shader/hlsl: Forbid objects in ternary conditions. 2024-01-18 23:15:41 +01:00
Giovanni Mascellani
38fdf24002 vkd3d-shader: Make relative address sources mutable too.
They were forgotten in 78d95889bd.

Fixes: 78d95889bd
2024-01-18 23:15:35 +01:00
Conor McCarthy
83851133c5 vkd3d-shader/ir: Set merged signature element interpolation mode only from used elements. 2024-01-18 23:15:27 +01:00
Conor McCarthy
b8280e4210 vkd3d-shader/ir: Revert "Do not merge signature elements which have different interpolation modes.".
This reverts commit b5c067b41a.

The commit causes regressions in other shaders because unused elements
do not have an interpolation mode.
2024-01-18 23:15:25 +01:00
Conor McCarthy
efe800f7f0 vkd3d-shader/dxil: Handle the DXIL SWITCH instruction. 2024-01-18 23:15:14 +01:00
Conor McCarthy
ba1ee27b4b vkd3d-shader/dxil: Handle the DXIL PHI instruction. 2024-01-18 23:15:12 +01:00
Conor McCarthy
8a5804eb43 vkd3d-shader/dxil: Handle the DXIL BR instruction conditional variant. 2024-01-18 23:15:10 +01:00
Conor McCarthy
c9493884ef vkd3d-shader/dxil: Handle the DXIL BR instruction unconditional variant. 2024-01-18 23:15:03 +01:00
Conor McCarthy
9e964fa0c7 vkd3d-shader/dxil: Introduce a code block terminator struct. 2024-01-18 23:15:01 +01:00
Conor McCarthy
c40093474e vkd3d-shader/tpf: Validate sysvals in index range declarations. 2024-01-17 22:29:01 +01:00
Conor McCarthy
4c30b23821 vkd3d-shader: Make the control point count the outer dimension of I/O arrays.
The relative-addressed case in shader_register_normalise_arrayed_addressing()
leaves the control point id in idx[0], while for constant register
indices it is placed in idx[1]. The latter case could be fixed instead,
but placing the control point count in the outer dimension is more
logical.
2024-01-17 22:28:59 +01:00
Conor McCarthy
418e8d8100 vkd3d-shader/ir: Expand index range write masks to cover all element masks.
For example, this occurred in a shader:

reg_idx write_mask
   0      xyz
   1      xyzw
   2      xyzw
   3      xyz

The dcl_indexrange instruction covered only xyz, so once merged, searching for
xyzw failed.

It is impossible to declare an input array where elements have different
component counts, but the optimiser can create this case. One way for
this to occur is to dynamically index input values via a local array
containing copies of the input values. The optimiser converts this to
dynamically indexed inputs.
2024-01-17 22:28:56 +01:00
Zebediah Figura
16962ac6f1 vkd3d-shader/hlsl: Allow non-numeric types in the ternary operator. 2024-01-17 22:28:51 +01:00
Zebediah Figura
46bd099341 vkd3d-shader/hlsl: Separate an add_ternary() helper. 2024-01-17 22:28:50 +01:00
Zebediah Figura
a5549bae38 vkd3d-shader/hlsl: Do not try to lower ternaries of types other than scalar or vector. 2024-01-17 22:28:49 +01:00
Zebediah Figura
e0b1f2e273 vkd3d-shader/hlsl: Remove a redundant definition of the "float" type. 2024-01-17 22:28:47 +01:00
Conor McCarthy
559d9d4ee0 vkd3d-shader/ir: Include an initial label instruction in the first control flow block. 2024-01-17 22:28:41 +01:00
Conor McCarthy
d402804851 vkd3d-shader/spirv: Do not emit function code before the main prolog. 2024-01-17 22:28:40 +01:00
Conor McCarthy
b4b2b0d3ac vkd3d-shader/spirv: Declare indexable temps as Private unless function scope is specified. 2024-01-17 22:28:39 +01:00
Conor McCarthy
37d9dba512 vkd3d-shader/ir: Store code block names in struct vkd3d_shader_desc. 2024-01-17 22:28:38 +01:00
Conor McCarthy
ffc65215ba vkd3d-shader/ir: Flatten SWITCH/CASE/DEFAULT/ENDSWITCH control flow instructions. 2024-01-17 22:28:36 +01:00
Conor McCarthy
dcb8527327 vkd3d-shader/ir: Flatten LOOP/BREAK/CONTINUE/ENDLOOP control flow instructions. 2024-01-17 22:28:35 +01:00
Conor McCarthy
e1dddc01b7 vkd3d-shader/ir: Flatten IF/ELSE/ENDIF control flow instructions. 2024-01-17 22:28:34 +01:00
Conor McCarthy
f3d464de0e vkd3d-shader/spirv: Handle RETP in spirv_compiler_handle_instruction(). 2024-01-17 22:28:33 +01:00
Conor McCarthy
bc1b5e7132 vkd3d-shader/spirv: Handle DISCARD and TEXKILL in spirv_compiler_handle_instruction(). 2024-01-17 22:28:31 +01:00
Conor McCarthy
db0d51675c vkd3d-shader/spirv: Emit descriptor offset loads in the function entry block.
Ensures they are loaded only once per function independent of the
control flow graph.
2024-01-17 22:28:29 +01:00
Henri Verbeet
68b898fcb6 vkd3d-shader/tpf: Store the "precise" mask as a uint32_t in shader_sm4_read_instruction(). 2024-01-15 19:58:22 +01:00
Henri Verbeet
ad2af68d2a vkd3d-shader/tpf: Store the "recognized_bits" mask as a uint32_t in shader_sm4_read_instruction_modifier(). 2024-01-15 19:58:21 +01:00
Henri Verbeet
b8903f5526 vkd3d-shader/tpf: Store the current token as a uint32_t in shader_sm4_read_dst_param(). 2024-01-15 19:58:20 +01:00
Henri Verbeet
fd854bc0c0 vkd3d-shader/tpf: Store the current token as a uint32_t in shader_sm4_read_src_param(). 2024-01-15 19:58:19 +01:00
Henri Verbeet
c5facd4e03 vkd3d-shader/tpf: Store the "addressing" token as a uint32_t in shader_sm4_read_param(). 2024-01-15 19:58:18 +01:00
Henri Verbeet
b1c538e0fe vkd3d-shader/tpf: Store the "components" token as a uint32_t in shader_sm4_read_dcl_resource(). 2024-01-15 19:58:17 +01:00
Henri Verbeet
9896394220 vkd3d-shader/tpf: Pass a uint32_t modifier token to shader_sm4_read_instruction_modifier(). 2024-01-15 19:58:15 +01:00
Nikolay Sivov
1a036ddff6 vkd3d-shader/fx: Do not write the same string twice. 2024-01-15 19:57:43 +01:00
Nikolay Sivov
e7d65d39ba vkd3d-shader/fx: Initial support for fx_5_0 output. 2024-01-15 19:57:42 +01:00
Nikolay Sivov
8014c11e88 vkd3d-shader/fx: Write empty passes blocks.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-15 19:57:41 +01:00