Commit Graph

2470 Commits

Author SHA1 Message Date
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
Giovanni Mascellani
5905489b7f vkd3d-shader/hlsl: Free the selector in postfix_expr (Valgrind). 2024-02-09 22:47:46 +01:00
Giovanni Mascellani
a10de1b239 vkd3d-shader/hlsl: Free the individual attributes in func_prototype (Valgrind). 2024-02-09 22:47:45 +01:00
Giovanni Mascellani
049327a270 vkd3d-shader/hlsl: Free the parse initializer in attribute (Valgrind). 2024-02-09 22:47:44 +01:00
Giovanni Mascellani
521082afbe vkd3d-shader/hlsl: Free variable identifiers in primary_expr (Valgrind). 2024-02-09 22:47:42 +01:00
Conor McCarthy
625e289574 vkd3d-shader/dxil: Handle hyperbolic trigonometric functions in sm6_parser_emit_dx_unary(). 2024-02-07 22:59:23 +01:00
Conor McCarthy
c35ec4f820 vkd3d-shader/dxil: Implement DX intrinsic TextureStore. 2024-02-07 22:59:18 +01:00
Conor McCarthy
efddcc9a99 vkd3d-shader/dxil: Support forward-referenced value ids. 2024-02-07 22:59:10 +01:00
Conor McCarthy
7f87a3e5fc vkd3d-shader/spirv: Handle the ACOS, ASIN and ATAN instructions in spirv_compiler_emit_ext_glsl_instruction(). 2024-02-06 23:09:55 +01:00
Conor McCarthy
19d23fa696 vkd3d-shader/dxil: Handle inverse trigonometric functions in sm6_parser_emit_dx_unary(). 2024-02-06 23:09:53 +01:00
Giovanni Mascellani
51f13391e6 vkd3d-shader/ir: Introduce a simple control flow graph structurizer.
The structurizer is implemented along the lines of what is usually called
the "structured program theorem": the control flow is completely
virtualized by mean of an additional TEMP register which stores the
block index which is currently running. The whole program is then
converted to a huge switch construction enclosed in a loop, executing
at each iteration the appropriate block and updating the register
depending on block jump instruction.

The algorithm's generality is also its major weakness: it accepts any
input program, even if its CFG is not reducible, but the output
program lacks any useful convergence information. It satisfies the
letter of the SPIR-V requirements, but it is expected that it will
be very inefficient to run on a GPU (unless a downstream compiler is
able to devirtualize the control flow and do a proper convergence
analysis pass). The algorithm is however very simple, and good enough
to at least pass tests, enabling further development. A better
alternative is expected to be upstreamed incrementally.

Side note: the structured program theorem is often called the
Böhm-Jacopini theorem; Böhm and Jacopini did indeed prove a variation
of it, but their algorithm is different from what is commontly attributed
to them and implemented here, so I opted for not using their name.
2024-02-06 23:07:07 +01:00
Giovanni Mascellani
19aef21369 vkd3d-shader/ir: Handle PHI nodes when materializing SSA registers.
PHI nodes cannot be used with TEMP registers, so they have to be
converted to MOV/MOVC nodes and moved before the BRANCH node.
2024-02-06 23:07:03 +01:00
Giovanni Mascellani
e0d3e9c376 vkd3d-shader/ir: Materialize SSA registers to temporaries.
For simplicity PHI nodes are not currently handled.

The goal for this pass is to make the CFG structurizer simpler, because
it doesn't have to care about the more rigid rules SSA registers have
to satisfy than TEMP registers.

It is likely that the generated code will be harder for downstream
compilers to optimize and execute efficiently, so once a complete
structurizer is in place this pass should be removed, or at least
greatly reduced in scope.
2024-02-06 23:07:00 +01:00
Giovanni Mascellani
eb723a8d2b vkd3d-shader/spirv: Support bool TEMP registers. 2024-02-06 23:06:58 +01:00
Giovanni Mascellani
49f0fd42b8 vkd3d-shader/spirv: Move bool casting helpers above register loading helpers. 2024-02-06 23:06:55 +01:00
Giovanni Mascellani
ee994e95dd vkd3d-shader/spirv: Convert the swizzle according to the source bit width.
Fixes: 1f536238a8
2024-02-06 23:06:53 +01:00
Giovanni Mascellani
674f86042d vkd3d-shader/dxil: Set the register before calling src_param_init_scalar().
Which uses the register to compute the appropriate swizzle.

Fixes: 1f536238a8
2024-02-06 23:06:49 +01:00
Conor McCarthy
95e4222cc6 vkd3d-shader/spirv: Emit a vector bitcast if necessary in spirv_compiler_emit_load_ssa_reg(). 2024-02-01 22:25:04 +01:00
Conor McCarthy
ebec0aa434 vkd3d-shader/dxil: Implement DX intrinsic TextureLoad. 2024-02-01 22:25:02 +01:00
Conor McCarthy
e6d52861e9 vkd3d-shader/dxil: Implement DX intrinsic SplitDouble. 2024-02-01 22:24:58 +01:00
Giovanni Mascellani
cc72a8d311 vkd3d-shader/spirv: Free binary SPIR-V code (Valgrind). 2024-02-01 00:08:28 +01:00
Henri Verbeet
d38221bd68 vkd3d-shader/ir: Pass a struct vsir_program to shader_parser_get_src_params(). 2024-02-01 00:08:23 +01:00
Henri Verbeet
47ec24ebad vkd3d-shader/ir: Pass a struct vsir_program to shader_parser_get_dst_params(). 2024-02-01 00:08:22 +01:00
Henri Verbeet
ced8543952 vkd3d-shader: Use vkd3d_atomic_increment_u32() in vkd3d_shader_dump_blob(). 2024-02-01 00:08:18 +01:00
Henri Verbeet
fef30dac2c vkd3d-shader/d3dbc: Do not fail parsing the shader when undeclared inputs are encountered.
These can be disassembled by D3DDisassemble() just fine, and perhaps
more importantly, shader model 1 vertex shaders do not require dcl_
instructions in Direct3D 8.
2024-01-29 22:33:46 +01:00
Giovanni Mascellani
edc406d297 vkd3d-shader/ir: Check that SSA registers are used with compatible data types.
Specifically, accesses are always 32 bit or always 64 bit.
2024-01-29 22:33:34 +01:00
Giovanni Mascellani
1f536238a8 vkd3d-shader: Use 64 bit swizzles for 64 bit data types in VSIR.
The handling of write masks and swizzles for 64 bit data types is
currently irregular: write masks are always 64 bit, while swizzles
are usually 32 bit, except for SSA registers with are 64 bit.
With this change we always use 64 bit swizzles, in order to make
the situation less surprising and make it easier to convert
registers between SSA and TEMP.

64 bit swizzles are always required to have X in their last two
components.
2024-01-29 22:33:33 +01:00
Giovanni Mascellani
2b93aae069 vkd3d-shader: Convert write masks between 32 and 64 bit by cases.
There are only three cases, and while the code is longer it is also
hopefully easier to read. Moreover, an error message is casted if
we're doing something unexpected.
2024-01-29 22:33:30 +01:00
Francisco Casas
13f713f74b vkd3d-shader/hlsl: Turn register(cX) reservations into buffer offset for SM4. 2024-01-29 22:33:27 +01:00
Francisco Casas
c7f7636534 vkd3d-shader/hlsl: Make register(cX) reservations work for SM1. 2024-01-29 22:33:25 +01:00
Conor McCarthy
92f0b37133 vkd3d-shader/spirv: Support 64-bit source value for bitfield instructions. 2024-01-29 22:33:22 +01:00
Conor McCarthy
3bbe374ca8 vkd3d-shader/dxil: Implement DX intrinsic Tertiary.
IBFE and UBFE are not emitted for HLSL sources which perform bitfield
extractions, e.g. loading a value from a struct containing bitfields, or
the equivalent done with bit shifts. These instructions are probably
only emitted by the TPF -> DXIL converter, which makes them hard to test.
2024-01-29 22:33:20 +01:00
Giovanni Mascellani
026c502f31 vkd3d-shader/ir: Fixup PHI nodes when lowering switches to selection ladders.
A map between the blocks before and after the pass is built and then
used to fix the PHI nodes.
2024-01-29 22:33:17 +01:00
Giovanni Mascellani
378109051c vkd3d-shader/ir: Lower monolithic switches to selection ladders.
PHI nodes must be fixed up after this pass, because the block references
might have become broken. For simplicitly this is not handled yet.

The goal for this pass is to make the CFG structurizer simpler, because
only conditional and unconditional branches must be supported.
Eventually this limitation might be lifted if there is advantage in
doing so.
2024-01-29 22:33:15 +01:00
Giovanni Mascellani
b97edee03d vkd3d-shader/spirv: Emit an error if merge information is missing.
Instead of crashing.
2024-01-29 22:33:14 +01:00
Conor McCarthy
e08c0cfc4f vkd3d-shader/dxil: Implement DX intrinsic RawBufferLoad. 2024-01-29 22:33:10 +01:00
Conor McCarthy
1bab93843d vkd3d-shader/dxil: Load raw/structured buffer SRV/UAV descriptors. 2024-01-29 22:33:09 +01:00
Henri Verbeet
fee3b94563 vkd3d-shader: Start an if-block on VKD3DSIH_IFC in vkd3d_shader_scan_instruction(). 2024-01-25 22:24:50 +01:00
Conor McCarthy
f954724870 vkd3d-shader/spirv: Handle the TAN instruction in spirv_compiler_emit_ext_glsl_instruction(). 2024-01-25 22:24:44 +01:00
Conor McCarthy
93d7c30395 vkd3d-shader/dxil: Handle DX intrinsic Tan in sm6_parser_emit_dx_unary(). 2024-01-25 22:24:43 +01:00
Conor McCarthy
2a260b8d56 vkd3d-shader/dxil: Implement DX intrinsics Cos and Sin. 2024-01-25 22:24:41 +01:00
Francisco Casas
cec45da45b vkd3d-shader/ir: Update flatten_control_flow_constructs() comment. 2024-01-25 22:24:27 +01:00
Conor McCarthy
8ae69c745b vkd3d-shader/spirv: Handle thread group UAV barriers. 2024-01-25 22:24:23 +01:00
Conor McCarthy
18e9148f58 vkd3d-shader/spirv: Include Uniform in the memory semantics for UAV barriers.
The UniformMemory semantic applies the constraints to Uniform storage
class memory, which matches how UAV variables are declared.
2024-01-25 22:24:22 +01:00
Conor McCarthy
adfbecef3c vkd3d-shader/spirv: Handle globally coherent UAVs. 2024-01-25 22:24:20 +01:00