Commit Graph

4153 Commits

Author SHA1 Message Date
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
Francisco Casas
4c40deaac1 vkd3d-shader/hlsl: Use hlsl_fixme() on missing SM1 matrix writemask lowering.
Instead of FIXME(). Otherwise we compile invalid d3dbc.
2024-03-14 22:49:29 +01:00
Francisco Casas
5c986b9cde vkd3d-shader/hlsl: Lower SLT instructions for pixel shaders.
Properly passing the inverse-trig.shader_test tests whose qualifiers
have been removed requires making spirv.c capable of handling ABS.
The same happens for the ps_3_0 equality test in
float-comparison.shader_test.
2024-03-14 22:49:29 +01:00
Francisco Casas
e9a4758648 vkd3d-shader/hlsl: Implement SM1 comparison operators. 2024-03-14 22:49:29 +01:00
Francisco Casas
7b883eef53 vkd3d-shader/d3dbc: Check profiles before writing SLT and CMP. 2024-03-14 22:48:56 +01:00
Giovanni Mascellani
d75dc76011 vkd3d-shader/ir: Dump the reconstructed structured program. 2024-03-14 22:48:53 +01:00
Giovanni Mascellani
2b3e21caeb vkd3d-shader/ir: Add jumps to the structured programs. 2024-03-14 22:48:52 +01:00
Giovanni Mascellani
c25e4c47c3 vkd3d-shader/ir: Reconstruct a structured program.
For simplicity jumps are not currently processed.
2024-03-14 22:48:50 +01:00
Conor McCarthy
f08976be33 vkd3d-shader/dxil: Implement DX instruction Barrier. 2024-03-14 22:48:46 +01:00
Conor McCarthy
b22632ff1a vkd3d-shader/spirv: Emit a trace message if TGSM alignment is ignored.
This would cause a lot of warning spam if it was a warning.
2024-03-14 22:48:45 +01:00
Conor McCarthy
5e63164d01 vkd3d-shader/dxil: Implement structured groupshared address space global variables. 2024-03-14 22:48:44 +01:00
Conor McCarthy
0965a3608a vkd3d-shader/dxil: Implement raw groupshared address space global variables. 2024-03-14 22:48:43 +01:00
Conor McCarthy
6dd54eeb09 vkd3d-shader/spirv: Support zero-initialisation for workgroup memory. 2024-03-14 22:48:41 +01:00
Henri Verbeet
374c5fcbdd vkd3d-shader/glsl: Store a pointer to the vsir program in struct vkd3d_glsl_generator. 2024-03-13 22:00:48 +01:00
Henri Verbeet
5f1f7ababb vkd3d-shader/ir: Pass a struct vsir_program to remap_output_signature(). 2024-03-13 22:00:42 +01:00
Henri Verbeet
0edf6d25f3 vkd3d-shader/ir: Pass a struct vsir_program to simple_structurizer_run(). 2024-03-13 22:00:41 +01:00
Henri Verbeet
c3f3cb5ef9 vkd3d-shader/ir: Pass a struct vsir_program to materialize_ssas_to_temps(). 2024-03-13 22:00:40 +01:00
Henri Verbeet
76791913d0 vkd3d-shader/ir: Pass a struct vsir_program to materialize_ssas_to_temps_process_reg(). 2024-03-13 22:00:39 +01:00
Henri Verbeet
343a365c97 vkd3d-shader/ir: Pass a struct vsir_program to instruction_array_lower_texkills(). 2024-03-13 22:00:37 +01:00
Conor McCarthy
0dc174ebd7 vkd3d-shader/spirv: Emit an error if a FIRSTBIT instruction has a 64-bit source. 2024-03-13 21:50:37 +01:00
Conor McCarthy
a64eb75c1d vkd3d-shader/spirv: Emit an error if COUNTBITS has a 64-bit source. 2024-03-13 21:50:36 +01:00
Henri Verbeet
9b0d304f8f vkd3d-shader/glsl: Introduce glsl_compile(). 2024-03-12 22:15:41 +01:00
Henri Verbeet
bdc096d437 vkd3d-shader/d3d-asm: Get rid of the (now) redundant "shader_desc" parameter to vkd3d_dxbc_binary_to_text().
And rename the function to d3d_asm_compile() while we're touching it.
2024-03-12 22:15:34 +01:00
Nikolay Sivov
948cd2154a vkd3d-shader/fx: Handle 'single' modifier for buffers.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-12 22:14:50 +01:00
Nikolay Sivov
e0ef45c0a3 vkd3d-shader: Parse a 'single' modifier.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-12 22:14:50 +01:00
Nikolay Sivov
cf7c05f431 vkd3d-shader: Remove a token for 'precise' modifier.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-12 22:14:50 +01:00
Giovanni Mascellani
f2b2040ff6 vkd3d-shader/ir: Sort loop intervals. 2024-03-12 22:14:47 +01:00
Giovanni Mascellani
070c4af8b3 vkd3d-shader/ir: Generate synthetic intervals for forward edges. 2024-03-12 22:14:46 +01:00
Giovanni Mascellani
1d60612340 vkd3d-shader/ir: Compute loop as intervals of the block order. 2024-03-12 22:14:45 +01:00
Nikolay Sivov
30cc6ceb44 vkd3d-shader/fx: Add support for writing shared object descriptions for fx_4_x.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-12 22:14:41 +01:00
Nikolay Sivov
13227f3852 vkd3d-shader: Add an option to enable child effects compilation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-12 22:14:41 +01:00
Nikolay Sivov
7f1fdd447c vkd3d-shader/fx: Add initial support for writing uninitialized vertex/pixel shader objects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-12 22:14:40 +01:00
Evan Tang
03a80cde2e vkd3d: Enable VK_EXT_fragment_shader_interlock if available. 2024-03-11 22:10:25 +01:00
Henri Verbeet
038764985a vkd3d-shader/glsl: Use location information from the current instruction. 2024-03-11 22:10:21 +01:00
Conor McCarthy
4f0e5b9069 vkd3d-shader/dxil: Support 16-bit types. 2024-03-11 22:10:06 +01:00
Conor McCarthy
066ea75945 vkd3d-shader/spirv: Introduce HALF and UINT16 types for minimum precision.
Minimum precision types must always be implemented as 32-bit to match how
reduced precision works in SPIR-V.
2024-03-11 22:10:05 +01:00
Conor McCarthy
58123c2e10 vkd3d-shader/spirv: Introduce a data_type_is_floating_point() helper function. 2024-03-11 22:10:03 +01:00
Nikolay Sivov
25d353db91 vkd3d-shader/d3dbc: Do not write semantic declarations for unused variables.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55829
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56402
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-11 22:09:55 +01:00
Zebediah Figura
ad495970e0 vkd3d-shader/spirv: Implement SLT and SGE. 2024-03-11 22:09:48 +01:00
Zebediah Figura
27196d8b0f vkd3d-shader/spirv: Implement CMP. 2024-03-11 22:09:44 +01:00
Francisco Casas
cfac67ccc2 vkd3d-shader/hlsl: Cast slt before multiplying on ternary operator.
Otherwise we may get a failing
    "hlsl_types_are_equal(arg1->data_type, arg2->data_type)"
assertion on hlsl_new_binary_expr() when creating the MUL.

This happens in the test introducing in the following patch:

    int a, b, c;

    void main(out float4 res : COLOR1, in float4 pos : position, out float4 out_pos : sv_position)
    {
        out_pos = pos;

        res = a ? b/1000.0 : c/1000.0;
    }
2024-03-11 22:09:42 +01:00
Giovanni Mascellani
1690b0b554 vkd3d-shader: Remove the bytecode fields from vkd3d_shader_desc. 2024-03-11 22:09:32 +01:00
Giovanni Mascellani
204c8afb9c vkd3d-shader/dxbc: Remove flag is_dxil.
The full shader profile is already available in vsir_program.
2024-03-11 22:09:31 +01:00
Giovanni Mascellani
470d83a9da vkd3d-shader: Move shader signatures to vsir_program. 2024-03-11 22:09:31 +01:00
Giovanni Mascellani
56dc0c9842 vkd3d-shader/dxbc: Decouple vkd3d_shader_desc from DXBC parsing. 2024-03-11 22:09:30 +01:00
Giovanni Mascellani
5204b92fa0 vkd3d-shader/tpf: Remove a useless parameter to shader_sm4_init(). 2024-03-11 22:09:28 +01:00
Conor McCarthy
7b4b0143bd vkd3d-shader/dxil: Implement DX intrinsic TextureGatherCmp. 2024-03-11 22:09:20 +01:00
Conor McCarthy
5a6fd010ac vkd3d-shader/dxil: Implement DX intrinsic TextureGather. 2024-03-11 22:09:18 +01:00
Giovanni Mascellani
75bc68962d vkd3d-shader/dxbc: Add flag to ignore the DXBC checksum. 2024-03-11 22:08:55 +01:00
Giovanni Mascellani
23259263cf vkd3d-shader/d3d-asm: Only emit signatures for SM4-6. 2024-03-08 23:36:44 +01:00
Henri Verbeet
1fc55d80cd vkd3d-shader: Enable GLSL target support when VKD3D_SHADER_UNSUPPORTED_GLSL is defined. 2024-03-08 23:36:40 +01:00
Evan Tang
4553b2a0dc vkd3d-shader/spirv: Implement support for rasteriser-ordered views.
Using SPV_EXT_fragment_shader_interlock.
2024-03-08 23:36:35 +01:00
Giovanni Mascellani
21f76257b0 vkd3d-shader/d3d-asm: Print labels in red.
They are substantially different from any other register type, so
it makes sense to have them stand out. Also, they help segmenting
visually the code into blocks, because labels are usually found
either at the beginning or at the end of a block.
2024-03-08 23:36:25 +01:00
Conor McCarthy
e65055b435 vkd3d-shader/spirv: Handle the ORD and UNO instructions. 2024-03-08 23:36:14 +01:00
Conor McCarthy
f212aad0ff vkd3d-shader/dxil: Support FCMP_ORD and FCMP_UNO for CMP2. 2024-03-08 23:36:13 +01:00
Conor McCarthy
4dafd6bedf vkd3d: Implement GetCopyableFootprints1(). 2024-03-08 23:36:08 +01:00
Conor McCarthy
197f16efa9 vkd3d: Implement CreatePlacedResource1(). 2024-03-08 23:36:08 +01:00
Conor McCarthy
e5ae6bd3c2 vkd3d: Implement CreateCommittedResource2(). 2024-03-08 23:36:08 +01:00
Conor McCarthy
6edba86a26 vkd3d: Implement GetResourceAllocationInfo2(). 2024-03-08 23:36:08 +01:00
Conor McCarthy
7d2c274b9b vkd3d: Add ID3D12Device8 interface stubs. 2024-03-08 23:36:02 +01:00
Giovanni Mascellani
172e7edf2d vkd3d-shader: Refactor common code for vkd3d_shader_compile(). 2024-03-08 23:35:54 +01:00
Giovanni Mascellani
0e5d6a97cc vkd3d-shader: Refactor common code for vkd3d_shader_scan(). 2024-03-08 23:35:54 +01:00
Giovanni Mascellani
bbd37a76fc vkd3d-shader: Treat the HLSL case specially in vkd3d_shader_compile(). 2024-03-08 23:35:54 +01:00
Giovanni Mascellani
3a1c32acd4 vkd3d-shader: Treat the HLSL case specially in vkd3d_shader_scan().
The other cases are similar and common code can be refactored.
Ideally the HLSL parser will eventually fit the same model, but that
will require more extensive work.
2024-03-08 23:35:53 +01:00
Giovanni Mascellani
b940d79aa8 vkd3d-shader/ir: Keep loops contiguous in the topological sort. 2024-03-08 23:35:48 +01:00
Giovanni Mascellani
cf9a023566 vkd3d-shader/ir: Dump the topological order of the control flow graph. 2024-03-08 23:35:47 +01:00
Giovanni Mascellani
ed40646c8a vkd3d-shader/ir: Topologically sort the control flow graph. 2024-03-08 23:35:46 +01:00
Giovanni Mascellani
880d781b57 vkd3d-shader/ir: Allow adding to a block list without checking for duplicates. 2024-03-08 23:35:45 +01:00
Nikolay Sivov
75c019074a vkd3d-shader/hlsl: Allow modifiers on buffer declarations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-08 23:35:40 +01:00
Nikolay Sivov
b13d60d805 vkd3d-shader/hlsl: Add determinant() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-08 23:35:23 +01:00
Giovanni Mascellani
8723b5d266 vkd3d-shader/ir: Sort each loop by block label. 2024-03-07 23:08:36 +01:00
Giovanni Mascellani
3d4092d9dc vkd3d-shader/ir: Dump the loops in the control flow graph. 2024-03-07 23:08:35 +01:00
Giovanni Mascellani
8241ca2b67 vkd3d-shader/ir: Keep track of loops by header block. 2024-03-07 23:08:34 +01:00
Giovanni Mascellani
088a6c49a2 vkd3d-shader/ir: Keep a reference to the message context inside struct vsir_cfg. 2024-03-07 23:08:33 +01:00
Giovanni Mascellani
9ac842b36b vkd3d-shader/ir: Compute the loops in the control flow graph. 2024-03-07 23:08:32 +01:00
Giovanni Mascellani
de15f55477 vkd3d-shader/ir: Introduce a helper to express block domination. 2024-03-07 23:08:31 +01:00
Giovanni Mascellani
c3657c4799 vkd3d-shader/ir: Add a debug buffer to struct vsir_cfg. 2024-03-07 23:08:30 +01:00
Giovanni Mascellani
c5893288d9 vkd3d-shader/ir: Properly handle function-local indexable temps when flattening control flow.
They have to be considered code rather than declarations, as required
for instance by the SPIR-V backend.
2024-03-07 23:08:28 +01:00
Giovanni Mascellani
9aa86901e3 vkd3d-shader/d3d-asm: Support emitting the shader signature. 2024-03-07 23:08:24 +01:00
Giovanni Mascellani
01a687a7fc vkd3d-shader/d3d-asm: Refactor dumping a write mask to a dedicated function. 2024-03-07 23:08:23 +01:00
Giovanni Mascellani
9d99389663 vkd3d-shader/d3d-asm: Describe the ASM dialect with a bunch of flags instead of a plain enum. 2024-03-07 23:08:22 +01:00
Giovanni Mascellani
94d641783b vkd3d-shader/d3d-asm: Do not make a copy of the buffer before returning it. 2024-03-07 23:08:20 +01:00
Nikolay Sivov
a0d52dc385 vkd3d-shader/hlsl: Improve VertexShader/PixelShader types handling.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:04:25 +01:00
Nikolay Sivov
437ef0896f vkd3d-shader/fx: Make sure to set error message for unimplemented cases.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:04:22 +01:00
Nikolay Sivov
8c5db57ea7 vkd3d-shader/fx: Reject fx_2_0 output without techniques.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:04:19 +01:00
Nikolay Sivov
dd5e42d347 vkd3d-shader/hlsl: Allow technique10 {} blocks for fx_2_0.
Such techniques are ignored later, but do not cause compilation errors.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:04:18 +01:00
Nikolay Sivov
5edbccd33b vkd3d-shader/hlsl: Add keyword tokens for fx_5_0 shader object types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:04:16 +01:00
Conor McCarthy
5082893e5d vkd3d-shader/spirv: Always use a 64-bit write mask for IMMCONST64 src params.
There is no way to tell in spirv_compiler_emit_load_reg() if the write
mask is 64-bit. All loads are 32-bit except for IMMCONST64 and SSA, and
the latter ignores the mask, so the only issue lies with IMMCONST64.
2024-03-06 23:04:12 +01:00
Francisco Casas
58c456ff2b vkd3d-shader/d3dbc: Implement bool to float cast as MOV.
In SM1, bools are always represented as either 0.0f or 1.0f at runtime.
2024-03-06 23:04:07 +01:00
Francisco Casas
747511131d vkd3d-shader/hlsl: Lower non-float operators for SM1. 2024-03-06 23:04:05 +01:00
Francisco Casas
a3319339e4 vkd3d-shader/hlsl: Lower casts to int using REINTERPRET instead.
I realized that it is better to lower casts to int to FLOOR+REINTERPET
instead of appending a FLOOR to all casts to int and assuming that this
is the case for all of them in d3dbc.c.

This in case we introduce new passes in the future that add casts that
we forget to lower, after the lower_casts_to_bool pass.
2024-03-06 23:04:04 +01:00
Nikolay Sivov
937d76507d vkd3d-shader/hlsl: Implement ternary operator for older vertex profiles.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56333
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:03:59 +01:00
Henri Verbeet
f866fb95ad Release 1.11. 2024-03-05 20:39:45 +01:00
Zebediah Figura
9177df883e vkd3d-shader/hlsl: Write the SFI0 section and "REQUIRES_ROVS" flag when ROVs are used. 2024-03-04 22:34:46 +01:00
Henri Verbeet
0914561f85 vkd3d: Store a D3D12_RESOURCE_DESC structure in struct vkd3d_image_resource_create_info.
Like we did before commit 6d4782ed7f. That
commit somehow managed to change the "desc" field from
D3D12_RESOURCE_DESC to D3D12_RESOURCE_DESC1, but that breaks the ABI.
2024-02-26 23:04:05 +01:00
Victor Chiletto
7e27ae73af vkd3d-shader/hlsl: Fix hlsl_ir_resource_store::resource cleanup. 2024-02-26 23:03:51 +01:00
Conor McCarthy
c083b1d0fc vkd3d-shader/dxil: Implement DX intrinsic GetDimensions. 2024-02-26 23:03:48 +01:00
Conor McCarthy
292bbdefbf vkd3d-shader/dxil: Move the resource kind helper functions up. 2024-02-26 23:03:46 +01:00
Henri Verbeet
d65f331efc configure: Build with -Wwrite-strings.
libs/vkd3d-shader/hlsl.c: In function ‘declare_predefined_types’:
libs/vkd3d-shader/hlsl.c:3408:10: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
         {"technique",    9},
          ^~~~~~~~~~~
...
programs/vkd3d-compiler/main.c: In function ‘parse_formatting’:
programs/vkd3d-compiler/main.c:303:10: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
         {"colour",  VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR},
          ^~~~~~~~
...

macOS tigetstr() takes a non-const char *, so account for that as well.
2024-02-22 22:46:29 +01:00
Henri Verbeet
7029d821be configure: Build with -Wtype-limits.
libs/vkd3d-shader/tpf.c: In function ‘write_sm4_unary_op_with_two_destinations’:
libs/vkd3d-shader/tpf.c:4489:24: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
     assert(1 - dst_idx >= 0);
                        ^~
libs/vkd3d-shader/tpf.c: In function ‘write_sm4_binary_op_with_two_destinations’:
libs/vkd3d-shader/tpf.c:4549:24: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
     assert(1 - dst_idx >= 0);
                        ^~
2024-02-22 22:46:22 +01:00
Henri Verbeet
773f02d82f vkd3d: Disable "robustBufferAccess2" as well when we disable "robustBufferAccess".
From the validation layers: "If robustBufferAccess2 is enabled then
robustBufferAccess must also be enabled
(https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000)"
2024-02-22 22:45:46 +01:00
Conor McCarthy
ba4bd651e5 vkd3d-shader/dxil: Implement DX intrinsics SampleCmp and SampleCmpLevelZero. 2024-02-22 22:45:36 +01:00
Conor McCarthy
2330ffdeda vkd3d-shader/dxil: Implement DX intrinsics SampleBias and SampleLevel. 2024-02-22 22:45:34 +01:00
Zebediah Figura
87b1de94da vkd3d-shader/hlsl: Check the resource format for UAVs also in hlsl_types_are_equal().
Spotted by Henri Verbeet.
2024-02-22 22:45:31 +01:00
Nikolay Sivov
5474d91804 vkd3d-shader/fx: Write DepthStencilView types. 2024-02-22 22:45:27 +01:00
Nikolay Sivov
371be3b60a vkd3d-shader/hlsl: Add DepthStencilView object type. 2024-02-22 22:45:26 +01:00
Nikolay Sivov
9632adaaec vkd3d-shader/fx: Handle fx_4+ UAV types. 2024-02-22 22:45:24 +01:00
Nikolay Sivov
e5f4f60214 vkd3d-shader/fx: Handle fx_4+ texture types. 2024-02-22 22:45:23 +01:00
Nikolay Sivov
a6057a1365 vkd3d-shader/fx: Add initial support for writing object variables.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-02-22 22:45:22 +01:00
Nikolay Sivov
c2b1714c5c vkd3d-shader/hlsl: Add RenderTargetView object type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-02-22 22:45:21 +01:00
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
Conor McCarthy
a0bb055ad2 vkd3d: Handle D3D12_FEATURE_D3D12_OPTIONS10 in CheckFeatureSupport(). 2024-02-13 22:51:28 +01:00
Henri Verbeet
5eba031fa1 vkd3d: Cast DWORD flags to uint32_t in debug traces. 2024-02-09 22:47:51 +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
Henri Verbeet
5c917552c9 vkd3d: Use PRIuPTR for SIZE_T variables in debug traces. 2024-02-07 22:59:45 +01:00
Henri Verbeet
8ddca1ebaf vkd3d: Get rid of vkd3d_atomic_decrement(). 2024-02-07 22:59:37 +01:00
Henri Verbeet
6e439045e8 vkd3d: Get rid of vkd3d_atomic_increment(). 2024-02-07 22:59:37 +01:00
Conor McCarthy
18f73c1c4d vkd3d: Handle D3D12_FEATURE_D3D12_OPTIONS9 in CheckFeatureSupport(). 2024-02-07 22:59:32 +01:00
Conor McCarthy
8ea67b0ac6 vkd3d: Handle D3D12_FEATURE_D3D12_OPTIONS8 in CheckFeatureSupport(). 2024-02-07 22:59:32 +01:00
Conor McCarthy
5fd3076c67 vkd3d: Handle D3D12_FEATURE_D3D12_OPTIONS7 in CheckFeatureSupport(). 2024-02-07 22:59:31 +01:00
Conor McCarthy
db4a98c0d2 vkd3d: Handle D3D12_FEATURE_D3D12_OPTIONS6 in CheckFeatureSupport(). 2024-02-07 22:59:31 +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
Henri Verbeet
2f9906ee90 vkd3d-utils: Use PRIuPTR for SIZE_T variables in debug traces. 2024-02-06 23:09:41 +01:00
Henri Verbeet
51cdddb961 vkd3d: Introduce a debug helper for GPU descriptor handles. 2024-02-06 23:07:43 +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
Henri Verbeet
06ddb10c40 vkd3d: Introduce a debug helper for CPU descriptor handles. 2024-02-01 22:25:36 +01:00
Henri Verbeet
feca006d6a vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_versioned_root_signature_deserializer_Release(). 2024-02-01 22:25:27 +01:00
Henri Verbeet
f42411fe4a vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_versioned_root_signature_deserializer_AddRef(). 2024-02-01 22:25:27 +01:00
Henri Verbeet
afd0e45cd6 vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_root_signature_deserializer_Release(). 2024-02-01 22:25:27 +01:00
Henri Verbeet
c2e82cf06a vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_root_signature_deserializer_AddRef(). 2024-02-01 22:25:27 +01:00
Henri Verbeet
9434687c5b vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_pipeline_state_Release(). 2024-02-01 22:25:27 +01:00
Henri Verbeet
c71fa87522 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_pipeline_state_AddRef(). 2024-02-01 22:25:27 +01:00
Henri Verbeet
9e135f6143 vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_root_signature_Release(). 2024-02-01 22:25:27 +01:00
Henri Verbeet
37e8826301 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_root_signature_AddRef(). 2024-02-01 22:25:27 +01:00
Jacek Caban
2ae9f18a3a vkd3d: Use uint64_t for the size in vkd3d_gpu_va_allocator_allocate.
Avoids value truncation in 32-bit builds.
2024-02-01 22:25:20 +01:00
Conor McCarthy
eae4b7b4a2 vkd3d: Implement GetResourceAllocationInfo1(). 2024-02-01 22:25:13 +01:00
Conor McCarthy
7e84421b9c vkd3d: Support multiple descriptions in GetResourceAllocationInfo(). 2024-02-01 22:25:11 +01:00
Conor McCarthy
92e19a7da3 vkd3d: Add ID3D12Device7 interface stubs. 2024-02-01 22:25:10 +01:00
Conor McCarthy
76fbbe980a vkd3d: Add ID3D12Device6 interface stub. 2024-02-01 22:25:10 +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
Henri Verbeet
6dea3d08b1 vkd3d: Use debugstr_hresult() in d3d12_device_mark_as_removed(). 2024-02-01 00:08:39 +01:00
Henri Verbeet
920f5293e9 vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_query_heap_Release(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
d66f61cd5f vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_query_heap_AddRef(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
334f60c281 vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_descriptor_heap_Release(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
db37be2a70 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_descriptor_heap_AddRef(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
886c1fdcc4 vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_resource_Release(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
84234a8875 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_resource_AddRef(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
201fab7d5d vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_resource_decref(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
a9582a7355 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_resource_incref(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
6f7aec58ea vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_heap_resource_destroyed(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
30a00160e2 vkd3d: Use vkd3d_atomic_increment_u32() in vkd3d_bind_heap_memory(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
06eb8e5f8c vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_heap_Release(). 2024-02-01 00:08:35 +01:00
Henri Verbeet
fd385ab994 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_heap_AddRef(). 2024-02-01 00:08:35 +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
Henri Verbeet
8c6f5b847b vkd3d-utils: Implement D3DDisassemble().
Very loosely based on Wine's d3dcompiler_43.
2024-01-29 22:33:44 +01:00
Henri Verbeet
4fd4ecc020 vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_device_Release(). 2024-01-29 22:33:40 +01:00
Henri Verbeet
7d7833f3c0 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_device_AddRef(). 2024-01-29 22:33:40 +01:00
Henri Verbeet
f61891954e vkd3d: Use vkd3d_atomic_decrement_u32() in vkd3d_instance_decref(). 2024-01-29 22:33:40 +01:00
Henri Verbeet
042e269791 vkd3d: Use vkd3d_atomic_increment_u32() in vkd3d_instance_incref(). 2024-01-29 22:33:40 +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
3295f0d16e vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_command_signature_Release(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
13ba36bb43 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_command_signature_AddRef(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
0ff20e6b8d vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_command_queue_Release(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
cdb559c39d vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_command_queue_AddRef(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
298dce541d vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_command_list_Release(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
87f3a606d7 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_command_list_AddRef(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
d891e5c2a0 vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_command_allocator_Release(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
315fce8ac5 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_command_allocator_AddRef(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
78bb7b6760 vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_fence_decref(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
c8122ff47e vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_fence_incref(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
1b4f1ac8a0 vkd3d: Use vkd3d_atomic_decrement_u32() in d3d12_fence_Release(). 2024-01-25 22:24:55 +01:00
Henri Verbeet
5a2b82fbd5 vkd3d: Use vkd3d_atomic_increment_u32() in d3d12_fence_AddRef(). 2024-01-25 22:24:55 +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
Henri Verbeet
766f5f039b vkd3d: Use debugstr_hresult() in vkd3d_serialize_versioned_root_signature(). 2024-01-24 22:38:42 +01:00
Henri Verbeet
30113c098d vkd3d: Use debugstr_hresult() in vkd3d_serialize_root_signature(). 2024-01-24 22:38:42 +01:00
Henri Verbeet
a86a21667c vkd3d: Use debugstr_hresult() in vkd3d_create_device(). 2024-01-24 22:38:42 +01:00
Henri Verbeet
ad08cbc390 vkd3d: Use debugstr_hresult() in vkd3d_uav_clear_state_init(). 2024-01-24 22:38:42 +01:00
Henri Verbeet
1599de9a0d vkd3d: Use debugstr_hresult() in d3d12_pipeline_state_init_compute(). 2024-01-24 22:38:42 +01:00
Henri Verbeet
c5b5621e28 vkd3d: Use debugstr_hresult() in d3d12_pipeline_state_find_and_init_uav_counters(). 2024-01-24 22:38:42 +01:00
Henri Verbeet
9c1e661ae3 vkd3d: Use debugstr_hresult() in vkd3d_create_compute_pipeline(). 2024-01-24 22:38:42 +01:00
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
6446b6ea21 vkd3d-shader: Introduce VKD3D_SHADER_COMPILE_OPTION_FEATURE_FLOAT64. 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
Zebediah Figura
579e262d98 vkd3d-utils: Implement input and output signature reflection. 2024-01-24 22:37:53 +01:00
Zebediah Figura
53bd1f5419 vkd3d-utils: Add D3DReflect(). 2024-01-24 22:37:53 +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
Henri Verbeet
e4cc4a336e vkd3d: Use debugstr_hresult() in vkd3d_init_null_resources(). 2024-01-23 20:27:28 +01:00
Henri Verbeet
d4b329e628 vkd3d: Use debugstr_hresult() in vkd3d_join_thread(). 2024-01-23 20:27:28 +01:00
Henri Verbeet
e965701776 vkd3d: Use debugstr_hresult() in d3d12_device_init(). 2024-01-23 20:27:28 +01:00
Henri Verbeet
8dc1239e14 vkd3d: Use debugstr_hresult() in vkd3d_create_vk_device(). 2024-01-23 20:27:28 +01:00
Henri Verbeet
af160ef0c4 vkd3d: Use debugstr_hresult() in vkd3d_instance_init(). 2024-01-23 20:27:28 +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