Conor McCarthy
e72c3bab71
vkd3d-shader/spirv: Ensure the data register is UINT in spirv_compiler_emit_store_tgsm().
2024-04-09 12:27:30 -05:00
Conor McCarthy
dc99159dd8
vkd3d-shader/spirv: Bitcast if necessary in spirv_compiler_emit_store_dst_components().
2024-04-09 12:27:29 -05:00
Conor McCarthy
85c8c6be4d
vkd3d-shader/dxil: Support constexpr GEP.
2024-04-09 12:27:26 -05:00
Conor McCarthy
7d5e3713f9
vkd3d-shader/ir: Materialise SSAs to temps before lowering switch instructions.
2024-04-09 12:27:20 -05:00
Conor McCarthy
cfcd57209b
vkd3d-shader/ir: Convert SSAs to temps only if the block of origin does not dominate all uses.
2024-04-09 12:27:19 -05:00
Conor McCarthy
1c61776c18
vkd3d-shader/spirv: Handle uint2 to double bitcast in spirv_compiler_emit_mov().
...
Necessary for MakeDouble if the dst is SSA.
2024-04-09 12:27:18 -05:00
Conor McCarthy
c8eb7e1c81
vkd3d-shader/spirv: Emit a uint result for RESINFO_UINT if the dst register is SSA.
2024-04-09 12:27:16 -05:00
Conor McCarthy
7bfc7410f2
vkd3d-shader/ir: Materialise phis to temps in the incoming blocks.
...
RADV converts temps to phi instructions, so converting phis to MOVC in
VSIR just translates back to phis feeding into a MOVC. This commit
eliminates the MOVC.
2024-04-09 12:27:15 -05:00
Francisco Casas
62bb12f322
vkd3d-shader/hlsl: Use LOGIC_AND instead of MUL in all().
2024-04-09 12:27:09 -05:00
Francisco Casas
53e4d6eedb
vkd3d-shader/hlsl: Use LOGIC_OR instead of BIT_OR in any().
...
Note that BIT_OR is not available for SM1 bools, so we must prefer
LOGIC_OR when possible.
2024-04-09 12:27:07 -05:00
Francisco Casas
2621fc9572
vkd3d-shader/ir: Add missing src swizzle in vsir_program_lower_texkills().
2024-04-09 12:27:06 -05:00
Francisco Casas
8fca801591
vkd3d-shader/tpf: Use the extra_bits field for _nz on discard.
2024-04-09 12:27:03 -05:00
Francisco Casas
3a0a4b625f
vkd3d-shader/hlsl: Merge HLSL_OP3_MOVC into HLSL_OP3_TERNARY.
2024-04-09 12:27:02 -05:00
Francisco Casas
8f6f875a59
vkd3d-shader/hlsl: Move lower of non-float expressions with the other SM1 passes.
2024-04-09 12:27:01 -05:00
Francisco Casas
19fd43214b
vkd3d-shader/hlsl: Ensure that TERNARY condition is always bool.
...
Also, properly casting it to float in lower_ternary() for SM1
avoids creating ABS and NEG on bool types.
2024-04-09 12:26:59 -05:00
Stefan Dösinger
7c93b5070f
vkd3d: Validate and store shader cache session descriptors.
2024-04-04 22:19:46 +02:00
Stefan Dösinger
fb87a72497
vkd3d: Add an ID3D12ShaderCacheSession stub.
2024-04-04 22:19:46 +02:00
Stefan Dösinger
d5c89051dd
vkd3d: Add ID3D12Device9 interface stubs.
2024-04-04 22:19:46 +02:00
Giovanni Mascellani
a278f32d3f
vkd3d-shader/ir: Synthesize selection constructs from conditional jumps.
2024-04-04 22:19:19 +02:00
Giovanni Mascellani
0d13b6afe9
vkd3d-shader/ir: Remove trailing `continue's.
2024-04-04 22:19:18 +02:00
Giovanni Mascellani
d8414302e8
vkd3d-shader/ir: Move `continue's to the false branch when possible.
2024-04-04 22:19:16 +02:00
Nikolay Sivov
4b0a328a2b
vkd3d-shader/hlsl: Allow 'export' modifier on functions.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-04-03 22:24:15 +02:00
Giovanni Mascellani
e6c20361ea
vkd3d-shader/ir: Drop a useless helper.
2024-04-03 22:23:08 +02:00
Giovanni Mascellani
9aff65c6d2
vkd3d-shader/ir: Open a loop when visiting the loop header.
...
Not when making the loop header available, which is too early and
might lead to open too many loops at once.
2024-04-03 22:23:06 +02:00
Nikolay Sivov
e1e6367210
vkd3d-shader/fx: Add an option to include empty buffers in the effect binary.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-04-02 23:10:42 +02:00
Nikolay Sivov
c509c85f63
vkd3d-shader/hlsl: Allow annotations on constant buffers.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-04-02 23:10:40 +02:00
Giovanni Mascellani
d10031911d
vkd3d-shader/ir: Move vsir_program_normalise() to the end of the file.
...
vsir_program_normalise() has function calls to basically everything in
ir.c, so it's useful to have it in an easily reachable place to
quickly jump to wherever you need using your favorite code editor's
features.
2024-04-02 23:10:07 +02:00
Zebediah Figura
106cbc02de
vkd3d-shader/hlsl: Use hlsl_is_numeric_type() in type_has_object_components().
2024-04-02 23:09:38 +02:00
Zebediah Figura
54f2dfe403
vkd3d-shader/hlsl: Simplify type_has_object_components().
...
The extra argument is not very easy to intuit. Since all we're trying to do here is check whether the type is a struct with object components in it, write that out explicitly.
2024-04-02 23:09:36 +02:00
Zebediah Figura
1e7d82798c
vkd3d-shader/hlsl: Move a hlsl_fixme() to a more relevant place.
2024-04-02 23:09:35 +02:00
Zebediah Figura
675d7b8cb6
vkd3d-shader/hlsl: Remove a redundant type check.
...
We already perform an implicit cast per component in initialize_var_components().
2024-04-02 23:09:33 +02:00
Conor McCarthy
d72d5c35d1
vkd3d-shader/dxil: Implement DX intrinsics Dot2, Dot3 and Dot4.
2024-04-02 23:09:28 +02:00
Conor McCarthy
2909a5aacc
vkd3d-shader/dxil: Implement DX intrinsic MakeDouble.
2024-04-02 23:09:23 +02:00
Conor McCarthy
11ee92ed7e
vkd3d-shader/dxil: Implement DX intrinsic Discard.
2024-03-27 22:37:42 +01:00
Conor McCarthy
8d947ce868
vkd3d-shader/spirv: Support bool source in spirv_compiler_emit_discard().
2024-03-27 22:37:40 +01:00
Zebediah Figura
6b6e4bc212
vkd3d-shader: Add a compile option to control whether implicit truncation warnings are printed.
...
d3dcompiler and d3dx9 versions before 42 don't emit this error; this will be
necessary to emulate that behaviour.
Other warnings exist that are introduced in different d3dcompiler versions,
although there are not very many distinct HLSL warnings to begin with.
We could of course group all these together under a single compiler option, but
I find that using separate top-level options is unilaterally friendlier to an
API consumer, and simpler to implement as well. It also in some sense maps
conceptually to e.g. "-Wno-implicit-conversion".
2024-03-27 22:37:34 +01:00
Nikolay Sivov
b382d1843d
vkd3d-shader/fx: Accept texture types when writing fx_2_0 effects.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:29 +01:00
Nikolay Sivov
b09f919673
vkd3d-shader/hlsl: Treat "texture" type name as case-insensitive.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:28 +01:00
Nikolay Sivov
17dc23269e
vkd3d-shader/fx: Handle "uint" type for fx_2_0 parameters.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:27 +01:00
Nikolay Sivov
9117629e35
vkd3d-shader/fx: Handle "half" type for fx_2_0 parameters.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:25 +01:00
Nikolay Sivov
88d9cff407
vkd3d-shader/fx: Set initial object count to 1 for fx_2_0.
...
This is used for the object table at runtime. Object variable index is 1-based.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:24 +01:00
Nikolay Sivov
501aed43f3
vkd3d-shader/fx: Zero-pad strings when aligning them for fx_2_0.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:23 +01:00
Nikolay Sivov
228d54efff
vkd3d-shader/fx: Mark shared variables as such for fx_2_0 effects.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:21 +01:00
Francisco Casas
11e7265815
vkd3d-shader/spirv: Throw compiler error on unrecognized register.
...
This codepath path is currently triggered when transpiling d3dbc shaders
that use vPos (or other of these special registers).
While vPos gets added to the input signature and gets assigned an INPUT
register, the registers in the shader instructions are still of
VKD3DSPR_MISCTYPE type and are not propperly mapped yet. This gives
invalid results.
Some SM1 tests must be set back to "todo" but they only work because, by
coincidence, we are assigning vPos the input register with index 0.
Propper mapping of these registers is still required.
2024-03-27 22:37:15 +01:00
Zebediah Figura
172cb75872
vkd3d-shader/spirv: Implement VKD3DSIH_ABS.
2024-03-27 22:37:10 +01:00
Francisco Casas
9a222d2be1
vkd3d-shader/d3dbc: Implement HLSL_OP2_LOGIC_AND for SM1.
2024-03-27 22:37:09 +01:00
Francisco Casas
777bf772bf
vkd3d-shader/d3dbc: Implement HLSL_OP2_LOGIC_OR for SM1.
2024-03-27 22:37:08 +01:00
Francisco Casas
a838f97e3f
vkd3d-shader/hlsl: Cast to bool before applying LOGIC_NOT.
...
Before this commit, it is possible for one of the tests of
cf-cond-types.shader_test to pass a non-bool to LOGIC_NOT, which should
not be allowed.
2024-03-27 22:37:07 +01:00
Francisco Casas
ee5fc7e968
vkd3d-shader/hlsl: Support LOGIC_NOT for SM1.
2024-03-27 22:37:06 +01:00
Conor McCarthy
68b31b7396
vkd3d-shader/spirv: Handle the sequentially consistent ordering flag for atomic instructions.
2024-03-27 22:37:01 +01:00
Conor McCarthy
a8dd788f41
vkd3d-shader/spirv: Emit a warning if the atomic instruction volatile flag is unhandled.
2024-03-27 22:37:00 +01:00
Conor McCarthy
9e0b9c3a7a
vkd3d-shader/dxil: Implement the DXIL ATOMICRMW instruction.
2024-03-27 22:36:59 +01:00
Conor McCarthy
b708a9b3b5
vkd3d-shader/dxil: Implement DX instructions ThreadId, GroupId, ThreadIdInGroup and FlattenedThreadIdInGroup.
2024-03-27 22:36:58 +01:00
Conor McCarthy
0f332eb939
vkd3d-shader/dxil: Emit an error if a constant code is unhandled.
2024-03-27 22:36:56 +01:00
Conor McCarthy
47e56cdfed
vkd3d-shader/spirv: Support 64-bit register info component type in spirv_compiler_emit_load_reg().
...
For 64-bit indexable temps (and any other 64-bit declarations) the write
mask must not be converted.
2024-03-27 22:36:55 +01:00
Conor McCarthy
83a67366da
vkd3d-shader/spirv: Do not assert if a TGSM store data register is not UINT.
2024-03-27 22:36:54 +01:00
Conor McCarthy
9da375414e
vkd3d-shader/spirv: Do not assert if a TGSM load dst register is not UINT.
2024-03-27 22:36:52 +01:00
Zebediah Figura
2247288003
vkd3d-shader/tpf: Set the user-packed flag for sm5.0 resources as well.
2024-03-27 22:36:39 +01:00
Zebediah Figura
7b87895289
vkd3d-shader/tpf: Write the component count as the column count for structs.
2024-03-27 22:36:37 +01:00
Zebediah Figura
5bf23cb2f5
vkd3d-shader/tpf: Explicitly write the class and base type for non-numeric types.
...
Avoid relying on that information being stored in the hlsl_type.
2024-03-27 22:36:36 +01:00
Zebediah Figura
34e9c101e8
vkd3d-shader/tpf: Do not write structs with no numeric fields into the RDEF.
2024-03-27 22:36:35 +01:00
Zebediah Figura
0b1f11dd33
vkd3d-shader/hlsl: Allocate register reservations for structs as well.
2024-03-27 22:36:34 +01:00
Zebediah Figura
622fcda9ee
vkd3d-shader/tpf: Do not write non-numeric struct fields into the RDEF.
2024-03-27 22:36:33 +01:00
Zebediah Figura
8ef5ee54c9
vkd3d-utils: Implement ID3D12ShaderReflectionType::GetMemberTypeByIndex().
2024-03-27 22:36:33 +01:00
Zebediah Figura
dfed19ccf6
vkd3d-utils: Implement ID3D12ShaderReflectionVariable::GetType().
2024-03-27 22:36:33 +01:00
Zebediah Figura
24b047f1fe
vkd3d-utils: Implement ID3D12ShaderReflectionConstantBuffer::GetVariableByIndex().
2024-03-27 22:36:33 +01:00
Zebediah Figura
2fceebd050
vkd3d-utils: Parse the RD11 section.
2024-03-27 22:36:33 +01:00
Zebediah Figura
90cd57404b
vkd3d-utils: Implement ID3D12ShaderReflection::GetConstantBufferByIndex().
2024-03-27 22:36:31 +01:00
Henri Verbeet
166dc24b2f
vkd3d: Move the vkd3d_mutex implementation to vkd3d-common.
2024-03-19 22:58:53 +01:00
Henri Verbeet
2431357fd6
vkd3d-common: Merge vkd3d_debug.h into vkd3d_common.h.
...
There doesn't seem much point in separating these. Pretty much all of
vkd3d (eventually) includes vkd3d_debug.h, and vkd3d_debug.h includes
vkd3d_common.h because it uses VKD3D_PRINTF_FUNC. The separation also
makes it inconvenient to use the debug macros in vkd3d_common.h.
2024-03-19 22:58:51 +01:00
Henri Verbeet
5de5f241a6
vkd3d-shader/ir: Pass a struct vsir_program to vkd3d_shader_normalise().
2024-03-19 22:57:56 +01:00
Henri Verbeet
164608a007
vkd3d-shader/d3d-asm: Pass a prefix and suffix to shader_dump_dst_param().
2024-03-18 23:08:03 +01:00
Henri Verbeet
e2d1a878a7
vkd3d-shader/d3d-asm: Pass a prefix and suffix to shader_dump_src_param().
2024-03-18 23:08:02 +01:00
Henri Verbeet
939a7fbe88
vkd3d-shader/d3d-asm: Pass a prefix and suffix to shader_dump_tessellator_partitioning().
2024-03-18 23:08:01 +01:00
Henri Verbeet
5f5145b8f8
vkd3d-shader/d3d-asm: Pass a prefix and suffix to shader_dump_tessellator_output_primitive().
2024-03-18 23:08:00 +01:00
Henri Verbeet
f61a92b908
vkd3d-shader/d3d-asm: Pass a prefix and suffix to shader_dump_tessellator_domain().
2024-03-18 23:07:58 +01:00
Henri Verbeet
b98171878f
vkd3d-shader/glsl: Keep track of the current indentation level.
2024-03-18 23:07:52 +01:00
Giovanni Mascellani
e5f486edd3
vkd3d-shader/ir: Use type "unused" for labels.
...
The label itself is certainly an unsigned integer, but the register
has no meaningful data type. It cannot be evaluated to anything.
The goal of this is to reduce cluttering in the internal ASM dumps.
2024-03-18 23:07:45 +01:00
Giovanni Mascellani
d418f49888
vkd3d-shader/d3d-asm: Do not dump a register's type if it's unused.
2024-03-18 23:07:44 +01:00
Giovanni Mascellani
22d19aed58
vkd3d-shader/d3d-asm: Indent instructions inside a block.
2024-03-18 23:07:43 +01:00
Conor McCarthy
0c01a55c7d
vkd3d-shader/dxil: Implement DX intrinsic Saturate.
2024-03-18 23:07:40 +01:00
Conor McCarthy
4599d3c1cf
vkd3d-shader/dxil: Implement DX intrinsic FAbs.
2024-03-18 23:07:39 +01:00
Conor McCarthy
33694f08fc
vkd3d-shader/dxil: Implement DX intrinsics FMa, FMad, IMad and UMad.
2024-03-18 23:07:38 +01:00
Conor McCarthy
421d311a49
vkd3d-shader/spirv: Use dst register data type in spirv_compiler_emit_imad().
2024-03-18 23:07:36 +01:00
Nikolay Sivov
f55b152811
vkd3d-shader/fx: Fail effect writing on unsupported annotations.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-18 23:07:32 +01:00
Nikolay Sivov
206eeb0752
vkd3d-shader/fx: Remove newlines from fixme messages.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-18 23:07:31 +01:00
Nikolay Sivov
4fc15d4b4a
vkd3d-shader/fx: Add initial support for writing fx_2_0 parameters.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-18 23:07:30 +01:00
Nikolay Sivov
ed06e0bbef
vkd3d-shader/fx: Populate global variables list during context initialization.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-18 23:07:29 +01:00
Nikolay Sivov
ea686e8f5a
vkd3d-shader/fx: Fix an instruction block leak.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-18 23:07:28 +01:00
Nikolay Sivov
9c7fe62da6
vkd3d-shader/fx: Use type writing helper only for fx_4+.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-18 23:07:27 +01:00
Conor McCarthy
3f99719ff2
vkd3d-shader/dxil: Implement DX intrinsic BufferUpdateCounter.
2024-03-18 23:07:23 +01:00
Giovanni Mascellani
8c15377ffc
vkd3d-shader/ir: Emit multilevel jumps in the structured program.
...
The new structurizer therefore reaches feature parity with the
older simple one, except for a couple of points:
* the old structurizer accepts any CFG, without requiring reducibility;
however, the DXIL specification requires the CFG to be reducible
anyway, so we're not really losing anything;
* the new structurizer additionally requires that no block has two
incoming back arrows; AFAIK this is condition that can happen,
but in practice it seems to be rare; also, it's not hard to add
support for it, as soon as it is decided it is useful.
On the other hand, the new structurizer makes use of the merging
information that are reconstructed from the CFG, which is important
for downstream optimization and fundamental for correctly emitting
tangled instructions.
Taking these considerations into account, the old structurizer is
considered superseded and is therefore removed.
2024-03-18 23:07:17 +01:00
Giovanni Mascellani
c2aa01de6e
vkd3d-shader/ir: Emit the reconstructed structured program.
...
Multilevel jumps are not supported yet, and trigger a fallback to the
simple structurizer.
2024-03-18 23:07:15 +01:00
Henri Verbeet
abf76372e0
vkd3d-shader/ir: Pass a struct vsir_program to vsir_validate().
2024-03-14 23:24:29 +01:00
Henri Verbeet
7af3e9300f
vkd3d-shader/ir: Pass a struct vsir_program to flatten_control_flow_constructs().
2024-03-14 23:24:28 +01:00
Henri Verbeet
268989f5b9
vkd3d-shader/ir: Pass a struct vsir_program to normalise_combined_samplers().
2024-03-14 23:24:27 +01:00
Henri Verbeet
674bebe9c9
vkd3d-shader/ir: Pass a struct vsir_program to shader_normalise_io_registers().
2024-03-14 23:24:24 +01:00
Henri Verbeet
8a60814476
vkd3d-shader/glsl: Generate comments for unhandled instructions.
...
Mostly for debugging purposes; we'll fail compilation, but will still trace
the shader that would have been generated.
2024-03-14 23:24:19 +01:00
Henri Verbeet
9869fbb0ea
vkd3d-shader/glsl: Trace the generated shader.
...
Even if compilation ultimately failed.
2024-03-14 23:24:16 +01:00
Francisco Casas
619edb4c38
vkd3d-shader/hlsl: Lower CMP instructions for vertex shaders.
2024-03-14 22:49:29 +01:00