366 Commits

Author SHA1 Message Date
Henri Verbeet
a93d258a86 Release 1.16. 2025-05-20 11:35:48 +02:00
Henri Verbeet
379b297d2c build: Add the Objective-C API JSON to the distribution. 2025-05-15 14:13:07 +02:00
Henri Verbeet
07d8fe0462 build: Add the SPIR-V grammar JSON to the distribution. 2025-05-15 14:13:07 +02:00
Giovanni Mascellani
129b3a8c4b tests: Check that shader-visible descriptor heaps have a valid GPU descriptor handle start.
We currently check that non-shader-visible heaps have a NULL
handle, but that doesn't seem to be guaranteed: beside WARP, also
NVIDIA drivers still return a valid pointer. And that's a pretty
useless check anyway; rather, check that shader-visible heaps
have a valid pointer, which is more interesting.
2025-05-15 14:11:10 +02:00
Giovanni Mascellani
1aa33ebc80 tests: Allow creating GPU upload heaps.
They are write-combine heaps on L1 memory, and were introduced
recently in Direct3D 12.
2025-05-15 14:10:53 +02:00
Giovanni Mascellani
d5410e3115 tests: Expect success when creating resources in certain cases.
Currently the tests expect that creating buffers in COMMON or
COPY_SOURCE state on UPLOAD heaps or in COMMON state on READBACK
heaps leads to a failure. I tested WARP, AMD and NVIDIA, and in
all cases the operations is successful.

I think the D3D12 runtime used reject resources created in the
configurations detailed above, but it doesn't any more (both
using the latest Agility SDK and the runtime distributed with
an updated Windows 11 system). However the CI still uses an
earlier runtime, so the old behavior is still allowed as
broken.
2025-05-15 14:09:23 +02:00
Henri Verbeet
f5a26fd2b8 vkd3d-shader/dxil: Document the supported dxbc-dxil transformations. 2025-05-14 15:10:44 +02:00
Henri Verbeet
1efbcebed4 build: Sort the $(vkd3d_shader_tests) list. 2025-05-14 15:10:18 +02:00
Elizabeth Figura
c1adf54a44 vkd3d-shader/hlsl: Forbid referring to typedefs with "struct". 2025-05-14 15:09:48 +02:00
Elizabeth Figura
8ca50a2f7e tests/hlsl: Add more tests for struct syntax. 2025-05-14 15:09:42 +02:00
Elizabeth Figura
5ad2e7ee6d vkd3d-shader/hlsl: Fix an incorrect error message for referring to non-struct types with "struct".
We cannot be redefining struct types in this rule, only referring to already
defined types. Struct type definition is handled by named_struct_spec, which
complains if the type was defined at all, regardless of class.
2025-05-14 15:08:13 +02:00
Elizabeth Figura
bfa655a01f vkd3d-shader/ir: Use the .w component of the existing swizzle when lowering texldb. 2025-05-14 15:07:46 +02:00
Elizabeth Figura
e16176672a vkd3d-shader/hlsl: Validate "numthreads" attribute values. 2025-05-14 14:56:42 +02:00
Elizabeth Figura
cfb59828f3 tests/hlsl: Add more tests for the "numthreads" attribute. 2025-05-14 14:56:42 +02:00
Elizabeth Figura
a06b9f6646 vkd3d-shader/hlsl: Do not emit HLSL_OP1_ABS for unsigned types. 2025-05-14 14:55:59 +02:00
Elizabeth Figura
cdc74a9377 vkd3d-shader/hlsl: Emit an error when min16uint is used in d3dbc target profiles.
Fixes: 18ca7affad
2025-05-14 14:12:19 +02:00
Elizabeth Figura
8f6616993b vkd3d-shader/spirv: Do not declare inputs with an empty used_mask.
This is motivated by SampleId, whose presence or absence determines whether a
fragment shader runs at sample frequency or not.

In HLSL, if SV_SampleIndex is declared but not used, this results in a signature
entry, but no dcl instruction (and a zero used mask in the signature entry).
Whether the shader will actually run at sample frequency is inconsistent. NVidia
does, AMD does not, and WARP does for d3d12 but not for d3d11.

Previously vkd3d-shader relied on the dcl instruction, thereby aligning with
AMD. This was changed by 66cb2815f0. This commit
restores the previous behaviour.
2025-05-14 14:09:28 +02:00
Elizabeth Figura
65e1ef047f vkd3d-shader/spirv: Return void from spirv_compiler_emit_input(). 2025-05-14 14:09:28 +02:00
Elizabeth Figura
d40422592a vkd3d-shader/ir: Merge tess factor used masks together.
Encountered with the domain shader in
test_domain_shader_one_patch_constant_input().
2025-05-14 14:09:21 +02:00
Henri Verbeet
d4032f7d09 demos: Build with -fno-lto.
Some versions of Clang do not properly pass include paths to the
assembler when LTO is enabled. That's a problem for the DEMO_EMBED macro
used by the demos, since it relies on .incbin. To make matters even
better, compilation fails, but doesn't return an error code; the
resulting binary is simply broken. Fortunately we don't really care
about LTO for the demos, so we can simply disable it. See also
https://github.com/llvm/llvm-project/issues/112920

Thanks to Giovanni for tracking down some of the pieces of this issue.
2025-05-14 14:06:37 +02:00
Henri Verbeet
3c8fd8a2f2 ci: Build the demos on macOS. 2025-05-12 15:38:01 +02:00
Henri Verbeet
a2d5358ac6 demos: Avoid objc_msgSend_fpret() on ARM64 macOS.
It's unavailable, and unnecessary.
2025-05-12 15:38:01 +02:00
Giovanni Mascellani
dd34899e97 vkd3d-shader/dxil: Call register_get_float_value() directly in sm6_value_get_constant_float().
sm6_metadata_get_float_value() already calls sm6_value_is_constant()
itself, and some compilers (rightly) emit a warning that the conversion
of UINT_MAX to float changes the value.
2025-05-12 15:37:27 +02:00
Anna (navi) Figueiredo Gomes
820430001f vkd3d-shader/hlsl: Use the source data type in clone_interlocked(). 2025-05-12 15:31:09 +02:00
Elizabeth Figura
4a5411aa6e vkd3d-shader/hlsl: Return a uint1 from GetRenderTargetSampleCount(). 2025-05-12 15:29:23 +02:00
Elizabeth Figura
4cdea712d0 tests/hlsl: Show that GetRenderTargetSampleCount() returns a vector. 2025-05-12 15:28:49 +02:00
Giovanni Mascellani
42df4517c6 vkd3d-shader/dxil: Generate GROUPSHAREDMEM values in sm6_parser_declare_tgsm_structured(). 2025-05-12 15:24:23 +02:00
Giovanni Mascellani
fd918062d6 vkd3d-shader/dxil: Generate GROUPSHAREDMEM values in sm6_parser_declare_tgsm_raw(). 2025-05-12 15:24:23 +02:00
Giovanni Mascellani
cb5a548740 vkd3d-shader/dxil: Generate IDXTEMP values in sm6_parser_declare_indexable_temp(). 2025-05-12 15:24:23 +02:00
Giovanni Mascellani
8635a7ff6e vkd3d-shader/dxil: Generate ICB values in sm6_parser_declare_icb(). 2025-05-12 15:24:23 +02:00
Giovanni Mascellani
1d88638bd3 vkd3d-shader/dxil: Rename VALUE_TYPE_ICB to VALUE_TYPE_DATA.
And other related identifiers similarly.

Currently we use VALUE_TYPE_ICB to indicate a raw chunk of data
(which can be used as an immediate constant buffer, but also for
initializing an indexable temporary) and VALUE_TYPE_REG with
register type VKD3DSPR_IMMCONSTBUFFER to indicate an actual ICB
register.

Since we are now switching to represent the register type directly
in the SM6 value, it seems sensible to use VALUE_TYPE_ICB for an
ICB register. Indeed, since what we're currently describing with
VALUE_TYPE_ICB is not necessarily related to an ICB register, it
makes sense to use a more general name, which is therefore being
introduced with this commit.
2025-05-12 15:24:23 +02:00
Nikolay Sivov
960244bf1e vkd3d-shader/fx: Use appropriate BlendState description when tracing.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-06 19:01:09 +02:00
Nikolay Sivov
5d5d892830 vkd3d-shader/fx: Use the same BlendState states description for both fx_4_1 and fx_5_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-06 18:58:03 +02:00
Nikolay Sivov
d660a0d2ae tests: Add a fx_4_1 compilation test for the BlendState states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-05-06 18:58:03 +02:00
Giovanni Mascellani
fd1f74f44d vkd3d-shader/dxil: Generate INVALID values in sm6_parser_emit_unhandled(). 2025-05-06 18:55:19 +02:00
Giovanni Mascellani
44e0b17606 vkd3d-shader/dxil: Generate INVALID values in sm6_parser_constants_init(). 2025-05-06 18:55:18 +02:00
Giovanni Mascellani
7381598310 vkd3d-shader/dxil: Generate UNDEFINED values in sm6_parser_constants_init().
VALUE_TYPE_UNDEFINED means that a value is explicitly undefined,
equivalently to what was first represented with is_undefined.
VALUE_TYPE_INVALID will be introduced for values that arise from
invalid programs.
2025-05-06 18:55:18 +02:00
Giovanni Mascellani
e9e02884e5 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_phi(). 2025-05-06 18:55:18 +02:00
Giovanni Mascellani
7c344bdfd0 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_cmpxchg(). 2025-05-06 18:55:18 +02:00
Giovanni Mascellani
326f3624d9 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_dx_sincos(). 2025-05-06 18:55:18 +02:00
Giovanni Mascellani
527c1518f2 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_dx_atomic_binop(). 2025-05-06 18:55:18 +02:00
Henri Verbeet
b389fa89e4 demos: Make the demos work in the macOS build. 2025-05-06 18:42:09 +02:00
Francisco Casas
7b07d77396 ci: Update the DXC version used on the CI to 1.8.2502. 2025-05-06 18:39:02 +02:00
Henri Verbeet
cb4b5641ea vkd3d: Handle multiple fence NULL event waits in d3d12_device_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
3fabac3f70 vkd3d: Handle multiple fence ANY waits in d3d12_device_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
9222f5e5b1 vkd3d: Handle multiple fence ALL waits in d3d12_device_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
52b947a005 vkd3d: Handle single fence waits in d3d12_device_SetEventOnMultipleFenceCompletion().
By forwarding to ID3D12Fence_SetEventOnCompletion().
2025-05-06 18:29:06 +02:00
Henri Verbeet
3ea84156c7 vkd3d: Validate the fence count in d3d12_device_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
75ce9cef92 tests/d3d12: Test ID3D12Device1_SetEventOnMultipleFenceCompletion(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
e54070c2d7 vkd3d: Introduce d3d12_fence_add_waiting_event(). 2025-05-06 18:29:06 +02:00
Henri Verbeet
615dce0eaa vkd3d: Introduce struct vkd3d_null_event.
This effectively moves "null_event_cond" from struct d3d12_fence and
"latch" from struct vkd3d_waiting_event together into a separate
structure, as well as storing the signalling function in struct
vkd3d_waiting_event instead of getting it from struct d3d12_device. I
think that largely makes sense on its own, but storing the signalling
function in struct vkd3d_waiting_event also allows us to more easily
implement d3d12_device_SetEventOnMultipleFenceCompletion() in a
subsequent commit.
2025-05-06 18:29:06 +02:00
Giovanni Mascellani
4289ec60a1 vkd3d-shader/dxil: Do not encode the offset twice for structured TGSM loads.
Currently structured TGSM loads are encoded to something like this:

    ld_structured sr12 <s:float>, sr1 <s:uint>, l(0) <s:uint>, g0[sr1 <s:uint> + 0] <s:float>

Notice how the TGSM offset, expressed by sr1, is encoded twice in
the instruction. In TPF there is no expectation of two indices
in the resource source, so let's avoid producing it for DXIL as
well. The same instruction will therefore become:

    ld_structured sr12 <s:float>, sr1 <s:uint>, l(0) <s:uint>, g0 <s:float>
2025-05-05 15:14:26 +02:00
Giovanni Mascellani
9fdaee1529 vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_binop(). 2025-05-05 15:10:15 +02:00
Giovanni Mascellani
31f8ed1d1e vkd3d-shader/dxil: Generate SSA values in sm6_parser_emit_atomicrmw(). 2025-05-05 15:10:15 +02:00
Giovanni Mascellani
fae03b2ba5 vkd3d-shader/dxil: Generate SSA values in instruction_dst_param_init_ssa_scalar(). 2025-05-05 15:10:15 +02:00
Giovanni Mascellani
bd73de7198 vkd3d-shader/dxil: Generate SSA values in instruction_dst_param_init_ssa_vector(). 2025-05-05 15:10:14 +02:00
Giovanni Mascellani
b8c6092a16 vkd3d-shader/dxil: Generate SSA values in sm6_parser_get_value_idx_by_ref(). 2025-05-05 15:08:29 +02:00
Giovanni Mascellani
9e7ad75944 vkd3d-shader/dxil: Move the VSIR register in the SM6 value outside of the union.
It will eventually disappear, but while it's replaced with other
union members it shouldn't interfere with them.
2025-05-05 15:02:58 +02:00
Giovanni Mascellani
648a60d4c8 vkd3d-shader/dxil: Introduce a uniform interface to synthesize a register from a SM6 value. 2025-05-05 15:02:57 +02:00
Giovanni Mascellani
8b58ce9e85 vkd3d-shader/dxil: Have sm6_parser_emit_reg_composite_construct() accept an array of registers.
Rather than an array of pointers to registers. This makes it nicer
to use with registers that are synthesized on the fly, a situation
that already exists and is likely to become more common in future
commits.
2025-05-05 15:01:36 +02:00
Shaun Ren
5b06fe83df vkd3d-shader/hlsl: Generate vsir instructions for stream output operations. 2025-05-05 14:54:07 +02:00
Shaun Ren
c8c1e270e0 vkd3d-shader/hlsl: Validate maximum output size in geometry shaders. 2025-05-05 14:43:53 +02:00
Shaun Ren
729a3ac089 vkd3d-shader/hlsl: Append output copies for stream output Append() invocations. 2025-05-05 14:30:16 +02:00
Shaun Ren
34b4b34f2c vkd3d-shader/hlsl: Use a block in append_output_copy*(). 2025-05-05 14:30:16 +02:00
Francisco Casas
e6db0ab614 tests: Add tests for DeviceMemoryBarrierWithGroupSync(). 2025-05-05 14:27:35 +02:00
Francisco Casas
b89f0bc730 vkd3d-shader/hlsl: Generate vsir for HLSL_IR_SYNC operations.
The following table shows how each intrinsic maps to d3d assembly and the
flags that appear in the tpf bytecode, in binary.

    GroupMemoryBarrier()                   sync_g               0010
    GroupMemoryBarrierWithGroupSync()      sync_g_t             0011
    DeviceMemoryBarrier()                  sync_uglobal         1000
    DeviceMemoryBarrierWithGroupSync()     sync_uglobal_t       1001
    AllMemoryBarrier()                     sync_uglobal_g       1010
    AllMemoryBarrierWithGroupSync()        sync_uglobal_g_t     1011
2025-05-05 14:17:47 +02:00
Francisco Casas
a975c56695 vkd3d-shader/hlsl: Mark stores dirty on interlocked operation in vectorize_stores(). 2025-05-05 14:15:23 +02:00
Francisco Casas
758a4bef09 vkd3d-shader/hlsl: Parse barriers.
And introduce hlsl_ir_sync to represent them.
2025-05-05 14:15:14 +02:00
Giovanni Mascellani
541060215e vkd3d-shader/dxil: Create vsir registers from DXIL handles when needed.
The idea is that sm6_value and related structures should not commit
to a specific vsir register representation yet, because at the time
they are created some information might be still unavailable. For
instance, it might be not yet known whether the program is using
native 16-bit types or minimum precision types. vsir registers
should only be synthesized during instruction emission.

Field "reg" in struct sm6_value will be handled in a later commit.
2025-04-30 16:58:31 +02:00
Elizabeth Figura
315247bf02 vkd3d-shader: Normalize TEXKILL to use a source register. 2025-04-30 16:51:44 +02:00
Giovanni Mascellani
50ca4a2101 vkd3d-shader/msl: Use the standard helper to print bitcasts. 2025-04-30 16:23:35 +02:00
Giovanni Mascellani
bb78c06193 vkd3d-shader/msl: Introduce msl_print_bitcast(). 2025-04-30 16:22:48 +02:00
Giovanni Mascellani
a1f48d2575 vkd3d-shader/msl: Introduce msl_print_src(). 2025-04-30 16:17:50 +02:00
Andrey Gusev
8882d324a6 vkd3d-shader/ir: Store the actual return value in shader_signature_map_patch_constant_index_ranges(). 2025-04-28 12:49:27 +02:00
Andrey Gusev
c69d2ab0ae vkd3d-shader/dxil: Store the actual return value in sm6_parser_signatures_init(). 2025-04-28 12:47:57 +02:00
Henri Verbeet
dfe3ad5551 demos: Make the demos work in the Windows build.
Commit 02fe9f5bdf introduced linking the
Windows build of the demos with d3d12 and dxgi, while also still linking
to libvkd3d-utils.la. That happens to more or less work on Wine; we get
vkd3d-utils' D3D12CreateDevice(), and Wine's
IDXGIFactory2_CreateSwapChainForHwnd(), but because Wine's
implementation of d3d12 swapchains uses vkd3d, we're able to use the
resulting swapchain buffers even though the instance of vkd3d used by
Wine may not be the same instance of vkd3d used by the demos. Perhaps
unsurprisingly, things don't go nearly as well on Windows.

We could of course stop linking the demos to vkd3d-utils on Windows, but
that's not that interesting; we're trying to show what vkd3d can do
here, not what d3d12 can do.
2025-04-28 12:16:10 +02:00
Henri Verbeet
883ffc5fd6 demos: Split demo_win32.h.
Much like we did for demo_xcb.h, demo_win32.h now just has the bits for
creating windows and handling events, while demo_d3d12.h has the d3d12
and dxgi bits.
2025-04-28 12:14:36 +02:00
Henri Verbeet
ceb2787d46 ci: Install mingw-w64-tools in the Linux image.
For the build-mingw-32 and build-mingw-64 jobs. These currently end up
picking up Linux pkg-config instead of MinGW pkg-config, which in turn
causes configure to pick up Linux OpenGL and XCB. We happen to get away
with that at the moment because none of the code using HAVE_OPENGL or
HAVE_XCB ends up getting built for Windows, but that's about to change.
Specifically, we'd like to build the vkd3d versions of the demos for
Windows.
2025-04-23 18:13:07 +02:00
Henri Verbeet
aa8161a7ad build: Do not add libvkd3d-shader.la to DEMOS_LDADD twice.
Commit e3f78706ec added libvkd3d-shader.la
to LDADD, but didn't remove it from DEMOS_LDADD.
2025-04-23 18:12:54 +02:00
Henri Verbeet
88bbc106c7 vkd3d-shader/spirv: We can parse up to SPIR-V 1.6.
The main reason to care at this point is that we actually emit SPIR-V 1.3
ourselves in some cases.
2025-04-23 18:12:39 +02:00
Conor McCarthy
4c8c31fa2e tests/hlsl: Add a shader model 5.1 test to srv-byteaddressbuffer.shader_test.
Some code paths for TPF handling are not tested if no 5.1 shaders are
compiled.
2025-04-23 18:11:42 +02:00
Conor McCarthy
c75b318805 vkd3d-shader/tpf: Emit the resource data type only for typed resource declarations. 2025-04-23 18:10:51 +02:00
Shaun Ren
5d29554fed tests/hlsl: Add geometry shader stream output syntax tests. 2025-04-23 18:03:59 +02:00
Shaun Ren
2a89b23ede vkd3d-shader/hlsl: Validate and record stream output objects.
Validation should only be done for stream outputs that are used.
2025-04-23 18:01:06 +02:00
Shaun Ren
f2f44b054d vkd3d-shader/hlsl: Allocate registers for stream output objects.
All stream output objects need to have a stream index allocated,
whether they are used or not.

We allocate stream outputs here, before other objects are allocated,
because the stream index is needed to create the appropriate output
semantic variables during append_output_copy(), which will be called
in a lowering pass for the Append() method.
2025-04-23 17:54:54 +02:00
Shaun Ren
d620ad4942 vkd3d-shader/hlsl: Introduce HLSL_REGSET_STREAM_OUTPUTS regset. 2025-04-23 17:54:54 +02:00
Shaun Ren
8059608af9 vkd3d-shader/hlsl: Parse the RestartStrip() method for stream outputs. 2025-04-23 17:54:54 +02:00
Shaun Ren
9525eb2f0c vkd3d-shader/hlsl: Parse the Append() method for stream outputs. 2025-04-23 17:54:54 +02:00
Shaun Ren
9b65cc8895 vkd3d-shader/hlsl: Support HLSL_CLASS_STREAM_OUTPUT in hlsl type helpers. 2025-04-23 17:54:54 +02:00
Giovanni Mascellani
6ca9395368 tests/d3d12: Skip testing NULL VBVs on NVIDIA on Windows.
It seems that the NVIDIA drivers leaves VBVs bindings untouched
when they are NULL (or the GPU buffer address is NULL), instead of
setting them to a null binding.

Differently from other cases of inconsistent behaviour between AMD
and NVIDIA, here I'm explicitly marking the NVIDIA behaviour as
broken, because the expected behaviour is spelled out explicitly
(at least for the D3D12 specification standards).
2025-04-21 14:43:59 +02:00
Giovanni Mascellani
bc637f2633 tests/d3d12: Do not validate the semantic of uint-clearing R11G11B10_FLOAT resources.
Implementations have no consistent behaviour.
2025-04-21 14:43:27 +02:00
Giovanni Mascellani
c1d04b84c7 tests/d3d12: Do not test out-of-bound UAV uint clears.
The behaviour is not uniform: AMD truncates, NVIDIA saturates.
2025-04-21 14:40:44 +02:00
Giovanni Mascellani
f890db872a tests/d3d12: Do not allow texture creation to fail when testing UAV uint clears.
If the format is supported texture creation should always succeed.
2025-04-21 14:40:31 +02:00
Giovanni Mascellani
f932af7f18 tests/d3d12: Check that B5G6R5_UNORM and B5G5R5A1_UNORM are supported before testing them.
They are not always available on NVIDIA GPUs.
2025-04-21 14:36:39 +02:00
Giovanni Mascellani
4324817c68 tests/d3d12: Set the descriptor heap when clearing UAVs. 2025-04-21 14:32:58 +02:00
Giovanni Mascellani
c764f71cf5 vkd3d-shader/ir: Validate that DEPTHOUTLE registers aren't used as sources. 2025-04-16 16:46:38 +02:00
Giovanni Mascellani
ee7895465c vkd3d-shader/ir: Validate that DEPTHOUTGE registers aren't used as sources. 2025-04-16 16:46:28 +02:00
Giovanni Mascellani
834017c198 vkd3d-shader/ir: Validate that DEPTHOUT registers aren't used as sources. 2025-04-16 16:46:05 +02:00
Giovanni Mascellani
a189a4cfb7 tests/hlsl: Do not test the implicit passthrough control point phase for SM6. 2025-04-16 16:43:45 +02:00
Giovanni Mascellani
dbd1938ce4 tests/hlsl: Fix the precision for a 16-bit arithmetic test. 2025-04-16 16:42:20 +02:00
Giovanni Mascellani
3186d66596 tests/hlsl: Do not test dst() on integer arguments with SM6.
That seems to hit a DXC bug we're not interested into.
2025-04-16 16:36:58 +02:00
Giovanni Mascellani
9db9f3bdaf tests/hlsl: Do not test 16-bit out-of-bound varyings. 2025-04-16 16:35:23 +02:00
Giovanni Mascellani
26656808e6 tests/hlsl: Remove a test in which a function reads an "out" argument.
The code doesn't make sense in the first place, even if it's
accepted by the compiler, so it makes sense that the behaviour
is undefined. And indeed the behaviour is different on AMD (4 is
returned), NVIDIA (QNaN is returned) and WARP (device is removed).
2025-04-16 16:30:19 +02:00
Giovanni Mascellani
df1aecb7bd tests/hlsl: Do not test 16-bit out-of-bound UAV writes. 2025-04-16 16:28:42 +02:00
Giovanni Mascellani
0ac661f571 tests/hlsl: Do not test 16-bit out-of-bound SRV buffer reads.
They do not behave consistently between AMD, NVIDIA and WARP, so
there is little point enforcing a specific behaviour.
2025-04-16 16:25:26 +02:00
Giovanni Mascellani
64bd2af015 tests/shader_runner_d3d9: Request the adapter specified on the command line. 2025-04-16 16:24:39 +02:00
Francisco Casas
9378d51b18 vkd3d-shader/hlsl: Remove the unnecessary "instr" field from the parser %union. 2025-04-16 16:22:42 +02:00
Francisco Casas
77941b131e vkd3d-shader/hlsl: Add switch_case destructors to the parser. 2025-04-16 16:21:51 +02:00
Francisco Casas
ff5f9cbcb6 vkd3d-shader/hlsl: Add parse_variable_def destructors to the parser. 2025-04-16 16:21:45 +02:00
Francisco Casas
f3ba7a84f4 vkd3d-shader/hlsl: Avoid leaking blocks on YYABORT.
Currently program errors might result on instructions that use
ctx->error_instr as src. In case we hit YYABORT while parsing another
part of the HLSL source, we have to make sure that the block that
contains the instruction is properly cleaned up, or we might hit the

    vkd3d:590273:err:hlsl_free_instr Failed assertion: list_empty(&node->uses)

assertion when hlsl_ctx_cleanup() is called after the YYABORT.

Consider the following shader:

    float4 main() : sv_target
    {
        // Statement A
        int p = foo;      // initializer argument is ERROR.
        // Statement B
        undeclared_fun(); // triggers YYABORT.
    }

Statement A will src the ctx->error_instr because of the undeclared
identifier and Statement B will trigger an YYABORT because of the
undeclared function.
2025-04-16 16:01:35 +02:00
Francisco Casas
128688a573 vkd3d-shader/hlsl: Avoid leaking declaration_statement blocks. 2025-04-16 16:00:18 +02:00
Francisco Casas
58706474ec vkd3d-shader/hlsl: Make struct_declaration_without_vars return void. 2025-04-16 15:58:40 +02:00
Giovanni Mascellani
922cb47a4b vkd3d-shader/ir: Validate descriptor counts in vsir programs. 2025-04-16 15:56:59 +02:00
Giovanni Mascellani
be94a37e23 vkd3d-shader/ir: Validate descriptor resource data types in vsir programs. 2025-04-16 15:52:46 +02:00
Giovanni Mascellani
01f47e00f2 vkd3d-shader/ir: Validate descriptor resource types in vsir programs. 2025-04-16 15:49:32 +02:00
Giovanni Mascellani
0da80c1f25 vkd3d-shader/ir: Validate descriptor types in vsir programs. 2025-04-16 15:46:20 +02:00
Giovanni Mascellani
869e6ef583 vkd3d-shader: Describe the resource data types of samplers as NONE.
It used to be UINT before, but it doesn't make any sense.
2025-04-16 15:42:31 +02:00
Giovanni Mascellani
f02ea94c42 vkd3d-shader/d3d-asm: Trace register names for I/O declarations. 2025-04-14 21:57:27 +02:00
Giovanni Mascellani
0417f4f162 vkd3d-shader/d3d-asm: Include the program descriptors when tracing vsir code. 2025-04-14 21:57:15 +02:00
Giovanni Mascellani
bac6949365 vkd3d-shader/d3d-asm: Expose the raw value if unknown in shader_dump_data_type(). 2025-04-14 21:55:26 +02:00
Giovanni Mascellani
fd16bba29d vkd3d-shader/d3d-asm: Expose the raw value if unknown in shader_dump_resource_type(). 2025-04-14 21:55:26 +02:00
Henri Verbeet
f4e10ea9d5 vkd3d-shader/d3d-asm: Include the I/O signatures when tracing vsir code. 2025-04-14 21:55:26 +02:00
Giovanni Mascellani
24e61cf74e vkd3d-shader: Represent resource data types as vkd3d_data_type in struct vkd3d_shader_descriptor_info1. 2025-04-14 21:55:26 +02:00
Giovanni Mascellani
4412a83655 tests: Create structured buffers with the appropriate stride.
The stride didn't match the structure size used in the shader.

This didn't seem to be a problem on AMD and WARP, but it was
on NVIDIA on Windows. Specifically, it seems that the buffer
is read using the shader structure size (so most tests pass),
but bounds are checked using the buffer stride, so a test
returned zero simply because an out-of-bounds read was detected.
2025-04-14 15:56:01 +02:00
Giovanni Mascellani
85e848289b tests/shader_runner_d3d11: Do not create CPU-readable multisample resolution textures.
Unless the D3D11_FEATURE_DATA_D3D11_OPTIONS2.MapOnDefaultTextures
feature is supported, textures with default usage cannot be read by the
CPU; and there isn't a need to either, since we're going through a
staging texture anyway.

This worked on AMD and WARP, but failed on NVIDIA on Windows.
2025-04-14 15:54:27 +02:00
Henri Verbeet
4e783e2d66 tests/shader_runner: Get rid of enum texture_data_type. 2025-04-14 15:48:24 +02:00
Francisco Casas
7b21059ee5 vkd3d-shader/hlsl: Support the .Length property for Textures.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57686
2025-04-14 15:47:16 +02:00
Francisco Casas
2dce34d7e0 tests/hlsl: Test the object .Length property. 2025-04-14 15:41:47 +02:00
Elizabeth Figura
0c18736370 vkd3d-shader/ir: Validate SSA write masks. 2025-04-14 15:32:15 +02:00
Elizabeth Figura
d91d552a5e vkd3d-shader/ir: Introduce a vsir_dst_param_init_null() helper. 2025-04-14 15:32:12 +02:00
Elizabeth Figura
1a1f1f1369 vkd3d-shader/hlsl: Set the right interpolation mode in the vsir signature. 2025-04-14 15:29:19 +02:00
Elizabeth Figura
7331c70e9e vkd3d-shader/hlsl: Set the sysval for more sm1 semantics.
To match the sysval we set when reading them.
2025-04-14 15:29:19 +02:00
Feifan He
ba7a9a0b29 vkd3d-shader/msl: Implement VKD3DSIH_LD.
Co-authored-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2025-04-14 15:27:02 +02:00
Feifan He
015a751ea0 tests/shader_runner_metal: Add texture support.
Co-authored-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2025-04-14 14:50:51 +02:00
Giovanni Mascellani
3493688a4d vkd3d-shader/msl: Access descriptors with a type-erased array.
Currently a descriptor set is represented with a structure
whose fields are the various descriptors that the shader is
going to use, each of them qualified with its type. This model
doesn't match very well what happens with D3D12 and with Vulkan
and descriptor indexing and mutable descriptors, where many
descriptor of different types can overlap, and only at shader
runtime it is decided which of them must be used.

Therefore with this patch a descriptor is represented as a
structure whose fields carry no intrinsic typing information,
but are reinterpreted according to the shader behavior on
each access. For the moment there is just one field, but more
will be added to account for fancier descriptor types and
to workaround Metal limitations.

When completed, this design will be similar in spirit to what
the Metal shader converter does, with little technical
differences.

This choice has a couple of drawbacks:

 1. shader debugging with Xcode is less comfortable, because
    the shader doesn't carry static descriptor typing
    information and Xcode is therefore less able to provide
    useful context;

 2. it requires tier 2 argument buffer support and macOS
    version >= 13, which includes guarantees on the runtime
    layout for descriptors.

Supporting descriptor indexing and mutable descriptors is
considered to be worthy of those drawbacks, though, is
effectively required by many applications and appears to be
the first goal we should aim for. If needed, in the future
we might also add support for older hardware, at least for
shaders that do not make use of advanced features.
2025-04-14 14:45:14 +02:00
Giovanni Mascellani
ed677a8f32 tests/shader_runner_metal: Do not use shared buffers.
They are not supported on non-Apple discrete GPUs. Instead make
them managed (if they are short lived) or private.
2025-04-14 14:38:39 +02:00
Feifan He
e5bb3a5233 tests/shader_runner_metal: Introduce a helper to encode the argument buffer.
Co-authored-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2025-04-14 14:38:39 +02:00
Giovanni Mascellani
eb9e254b8c tests/shader_runner_metal: Handle multisampled 2D texture arrays properly.
They're not supported by the shader runner anyway, but there's no
reason to make the code subtly wrong.
2025-04-14 14:38:38 +02:00
Giovanni Mascellani
cbce3a8631 tests/shader_runner: Always set descriptor heaps. 2025-04-09 16:42:16 +02:00
Giovanni Mascellani
bb8f1304ba tests/d3d12: Always set descriptor heaps.
It seems AMD and WARP are not particularly sensitive to that, but
NVIDIA drivers crash if descriptor heaps are not set.
2025-04-09 16:41:33 +02:00
Conor McCarthy
fdd21470b9 tests/hlsl: Test casts from double to 16-bit integer types. 2025-04-09 16:39:07 +02:00
Conor McCarthy
bb8b4f3827 tests/hlsl: Test casts to 16-bit uint. 2025-04-09 16:22:19 +02:00
Conor McCarthy
3c950e5977 tests/hlsl: Test casts to 16-bit int. 2025-04-09 16:20:58 +02:00
Conor McCarthy
88a85024e2 tests/hlsl: Test casts to 16-bit float. 2025-04-09 16:20:53 +02:00
Giovanni Mascellani
7fb288819a vkd3d-shader/msl: Set the prefix to "unknown" for unhandled shader types in msl_generator_init().
Like we do for GLSL; there's no reason to abort compilation here. Note
that this also avoids leaking "gen->buffer" and "gen->string_buffers" on
the error path.
2025-04-09 16:08:15 +02:00
Shaun Ren
0c139ef7a0 vkd3d-shader/hlsl: Add special allocation rules for patch constant data. 2025-04-09 16:02:12 +02:00
Shaun Ren
7ba84b7787 tests: Add signature reflection tests for register allocation rules in tessellation shaders. 2025-04-09 16:02:12 +02:00
Shaun Ren
d3b32fefa3 vkd3d-shader/tpf: Support SV_RenderTargetArrayIndex/SV_ViewportArrayIndex sysvals in tessellation shaders. 2025-04-09 16:02:12 +02:00
Shaun Ren
05f8dd8273 vkd3d-shader/hlsl: Prioritize smaller writemasks for all allocators in allocate_semantic_registers(). 2025-04-09 16:02:12 +02:00
Shaun Ren
ec2f18ab17 vkd3d-shader/hlsl: Free all allocators in allocate_semantic_registers(). 2025-04-09 16:02:12 +02:00
Shaun Ren
d1df10ac86 vkd3d-shader/hlsl: Use dcl_output_siv for patch constant function sysval outputs. 2025-04-09 16:02:12 +02:00
Henri Verbeet
70655012ab demos: Move the vkd3d parts of demo_xcb.h into a separate header.
So that they can be used for e.g. Wayland or macOS support. Or Windows,
if we're so inclined.
2025-04-08 20:38:26 +02:00
Henri Verbeet
b12e3d8eec demos: Get rid of some unused includes.
These were used for demo_load_shader(), but that was removed some time
ago in commit aa5d48eec4.
2025-04-08 20:38:26 +02:00
Victor Chiletto
89d3e667e0 tests/hlsl: Add tests for SRV structured buffers. 2025-04-08 19:31:40 +02:00
Victor Chiletto
cc9f4ac587 tests/hlsl: Attempt to deduce the data type of unspecified type texture data.
Try parsing first as integer, and if the parse stops at a decimal separator, parse as float.
2025-04-08 19:18:57 +02:00
Victor Chiletto
7b21183f45 tests/shader_runner_d3d12: Pass the structure byte stride for SRVs. 2025-04-08 19:18:56 +02:00
Anna (navi) Figueiredo Gomes
3e8b56c509 vkd3d-shader/fx: Don't cast between int and uint in state blocks. 2025-04-08 19:14:15 +02:00
Anna (navi) Figueiredo Gomes
8866a43b2d tests/hlsl: Add some fx_4_0 state tests. 2025-04-08 19:14:15 +02:00
Elizabeth Figura
f576ecc992 vkd3d-shader/hlsl: Introduce a compiler pass to vectorize stores. 2025-04-03 20:29:20 +02:00
Elizabeth Figura
1a999f74fc vkd3d-shader/hlsl: Introduce a compiler pass to vectorize expressions. 2025-04-03 20:29:20 +02:00
Giovanni Mascellani
7b4a29da81 tests: Mark a todo as resolved on MoltenVK 1.2.12.
Technically it is not, the Vulkan commands we're generating are
still not correct. But let's get rid of the failure message.
2025-04-03 20:28:31 +02:00
Giovanni Mascellani
653e4f47ac ci: Disable testing with DXC on macOS.
With this we can finally disallow failure for the macOS CI script,
which is more valuable than checking DXC. Eventually DXC tests
will have to be fixed, though.
2025-04-03 20:28:27 +02:00
Giovanni Mascellani
aab8ba02d8 tests: Mark a number of test failures as buggy on macOS before Sequoia.
It's hard to pinpoint exactly what's going wrong with these
tests. They seem to be related to atomics and GPU timestamps,
both categories that are known to have problems on MoltenVK in a
way or another; those failures clearly depend on a few factors
like the MoltenVK version, the macOS version and whether we're in
a virtual machine or not, but the exact dependency on those factors
is hard to describe (for example, in general the paravirtualized
device offered inside virtual machines has a lot more problems than
real devices, but I've seen tests, fixed all other conditions,
working on the paravirtualized device and not on the real device).

The only thing all tests in this batch have in common is that I've
never seen them fail on a Sequoia system, thus I've settled for
using just that as the bug_if() condition. Ultimately, wasting a
lot of time to get to the bottom of each single test failure is
pointless, and being able to mark the CI job as not allowed to
fail gives better regression protection than investigating each
of those. Also, I routinely run the tests on a Sequoia system, so
if these tests get broken this is going to be noticed anyway.
2025-04-03 20:26:26 +02:00
Nikolay Sivov
2540081988 vkd3d-shader/fx: Accept int(0) as well as uint(0) constant value for object-type states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-04-02 19:34:25 +02:00
Nikolay Sivov
4ff14104b0 vkd3d-shader/fx: Set GeometryShader state type as an object type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-04-02 19:34:25 +02:00
Elizabeth Figura
ea21dddec9 vkd3d-shader/hlsl: Allow compiling directly to GLSL. 2025-04-02 19:33:41 +02:00
Elizabeth Figura
33cd10581e vkd3d-shader/glsl: Invert gl_FragCoord w. 2025-04-02 19:32:39 +02:00
Francisco Casas
4b9c23272a vkd3d-shader/ir: Reset instruction pointers after shader_instruction_array_insert_at().
Every call to shader_instruction_array_insert_at() means a possible
reallocation of all vsir instructions in the program. This means that all
previous pointers are potentially no longer valid.

We are currently using these potentially invalid pointers in some cases,
usually in the form of "ins->location". This commit fixes these.

I moved all pointer changes to right after the call to
shader_instruction_array_insert_at() to make this more evident.
2025-04-02 19:25:12 +02:00
Giovanni Mascellani
875c5df519 vkd3d-shader/ir: Validate register id and index for CONSTBUFFER registers. 2025-04-02 19:24:10 +02:00
Giovanni Mascellani
c181f147ce vkd3d-shader/ir: Validate register id and index for SAMPLER registers. 2025-04-02 19:08:50 +02:00
Giovanni Mascellani
9b7256c0c8 vkd3d-shader/ir: Validate register id and index for UAV registers. 2025-04-02 19:08:00 +02:00
Giovanni Mascellani
10d8760134 vkd3d-shader/ir: Validate register id and index for RESOURCE registers. 2025-04-02 19:06:43 +02:00
Shaun Ren
3e44bd4e5b tests/hlsl: Add a test for copy-propagation of uniform texture object writes. 2025-04-02 18:51:10 +02:00
Shaun Ren
7aebed0eea vkd3d-shader/hlsl: Ensure that uniform objects are never written to in copy_propagation_transform_object_load(). 2025-04-02 18:49:52 +02:00
Shaun Ren
b1d8915440 vkd3d-shader/hlsl: Divert written uniform derefs to temps before copy-propagation passes.
The following pixel shader currently triggers an infinite loop during
copy propagation, which is fixed by this commit:

    sampler s;
    Texture2D t1, t2;

    float4 main() : sv_target
    {
        Texture2D t = t1;
        t1 = t2;
        t2 = t;
        return t1.Sample(s, float2(0, 0)) + t2.Sample(s, float2(0, 0));
    }

The infinite loop occurs because copy_propagation_transform_object_load()
replaces t1 in the resource_load(t1, ...) instruction
with t2, t1, t2, ... repeatedly.
2025-04-02 18:49:52 +02:00
Francisco Casas
3ead8d532b vkd3d-shader/hlsl: Allow non-constant deref propagation on SM1.
Note that we still have to preempt the propagation to SM1 pixel shader
uniforms. Otherwise this will turn the many constant derefs that appear
from the <index-val> copy generated in lower_index_loads() into a single
non-constant deref, causing it to allocate all the registers instead of
up until the last one used.
2025-04-02 18:27:16 +02:00
Francisco Casas
f65e6265e0 vkd3d-shader/ir: Normalise MOVA and d3dbc indirect addressing. 2025-04-02 18:27:16 +02:00
Francisco Casas
fd02d69dda vkd3d-shader/hlsl: Implement indirect addressing for d3dbc target profiles. 2025-04-02 18:26:03 +02:00
Francisco Casas
0e0ed72652 vkd3d-shader/d3dbc: Respect "idx_count" when writing registers.
Some SM1 src registers have idx_count = 0, in which case we have to
respect that instead of always reading reg->reg.idx[0].offset even when
it is invalid.
2025-04-02 18:06:48 +02:00
Francisco Casas
2327f87e37 tests/hlsl: Test SM1 vertex shader uniform allocation on indirect addressing.
Here, a vertex shader version of the previous test by Shaun is
introduced. Note that in this case the uniform allocates all 4 registers
instead of 3 because it is indirectly addressed.
2025-04-02 18:06:48 +02:00
Francisco Casas
b6ce1479fe tests/hlsl: Test vertex shader uniform indirect addressing.
Note that, for indexes with a decimal part, the behavior is different
depending on whether it is a temp load or a direct uniform load (which
can only happen on vertex shaders). The former rounds to the
closest-to-zero, while the latter rounds to the nearest even.
2025-04-02 18:06:18 +02:00
Elizabeth Figura
20b76f87bf vkd3d-shader/hlsl: Initialize the temp count for sm1. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
7cb5a7bebc vkd3d-shader/hlsl: Leave the swizzle zero for VSIR_DIMENSION_NONE registers. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
950f78041a vkd3d-shader/hlsl: Initialize the vsir dimension for sm1. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
856f4b55f6 vkd3d-shader/hlsl: Set the correct index count for sm1 DEPTHOUT. 2025-04-02 17:58:26 +02:00
Elizabeth Figura
227e2cc0f5 vkd3d-shader/hlsl: Use vsir_*_from_hlsl_node() helpers in more places. 2025-04-02 17:58:18 +02:00
Henri Verbeet
110edf32d0 demos: Add basic DPI handling. 2025-03-19 14:10:24 +01:00
Nikolay Sivov
21e08955d3 vkd3d-shader/fx: Pad fx_2_0 object data blobs with zeroes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-18 15:56:32 +01:00
Giovanni Mascellani
803bf59654 tests: Mark an early depth stencil test as buggy on MoltenVK.
On MoltenVK it seems that all draws are always executed,
independently of the early depth stencil test. The problem doesn't
seem to belong to vkd3d or MoltenVK, because the generated Metal
commands look correct. I tried looking at a GPU capture with Xcode,
which was not very conclusive because it doesn't state clearly
whether early fragment tests were passed or not. Sometimes it
says that a fragment shader execution had no thread execution
data, which I interpret as the early fragment tests having
prevented the fragment shader from running, but it's not really
consistent, and it's never clear which results are based on
software simulation and which on the hardware run.

However taking everything into account I think the most likely
explanation is some incorrect optimization at the Metal level.
2025-03-18 15:55:29 +01:00
Giovanni Mascellani
05f7f03dab tests: Mark a queue synchronization test as buggy on MoltenVK.
The graphics pipeline triggers an internal error in the Metal
pipeline compiler, with a completely generic error message. I have
no idea what the actual problem is.
2025-03-18 15:53:59 +01:00
Shaun Ren
8f19d02501 tests: Add a signature reflection test for geometry shader inputs. 2025-03-18 15:46:07 +01:00
Shaun Ren
62c00be873 vkd3d-shader/tpf: Emit geometry shader property declarations. 2025-03-18 15:46:07 +01:00
Shaun Ren
bd055fac1c vkd3d-shader/hlsl: Store geometry shader properties in struct vsir_program. 2025-03-18 15:46:02 +01:00
Shaun Ren
b1ace5763a vkd3d-shader/hlsl: Implement input semantics for geometry shaders. 2025-03-18 15:40:11 +01:00
Shaun Ren
8af3173955 vkd3d-shader/hlsl: Support input primitive arrays in geometry shaders. 2025-03-18 15:40:11 +01:00
Giovanni Mascellani
2377db33db vkd3d-shader: Represent descriptor information in the vsir program. 2025-03-18 15:38:01 +01:00
Giovanni Mascellani
4308fa3f68 vkd3d-shader/spirv: Do not steal the instruction array from the vsir program.
There is no need, and it only complicates tracking ownership.
2025-03-18 15:37:57 +01:00
Giovanni Mascellani
fc520e7b4c vkd3d-shader/spirv: Do not store duplicate references to the signatures.
They are already available through the program.
2025-03-18 15:34:16 +01:00
Giovanni Mascellani
5ce03258b5 vkd3d-shader/spirv: Immediately store a reference to the program in the SPIR-V generator.
So it doesn't have to be passed around uselessly.
2025-03-18 15:34:04 +01:00
Giovanni Mascellani
549659dab6 vkd3d-shader/spirv: Run the vsir passes before creating the SPIR-V generator.
This makes it more similar to the MSL and GLSL generators. It also looks
like a cleaner design, the backend is supposed to get access to the vsir
program after it has gone through the pipeline.
2025-03-18 15:33:27 +01:00
Francisco Casas
ea99d2c2cd vkd3d-shader/hlsl: Lower integer modulus for d3dbc target profiles. 2025-03-18 15:27:04 +01:00
Francisco Casas
828afe188c vkd3d-shader/hlsl: Don't lower integer MOD and DIV on const passes for d3dbc target profiles.
These bitwise operations are not available in these profiles.
2025-03-18 15:27:03 +01:00
Francisco Casas
e3923876c0 tests/hlsl: Test integer division with big integers.
Similarly to the modulus operator, d3dbc results with constant folding
are different from results when constant folding cannot be applied, and
different from tpf results.
2025-03-18 15:25:41 +01:00
Francisco Casas
080672478d tests/hlsl: Test integer modulus with big integers.
Note that in d3dbc target profiles it gives different results when this
operation is constant folded compared to when it is not.

This suggests that whatever pass lowers the modulus operation to d3dbc
operations doesn't do it before constant folding.

Also note that when constant folded, d3dbc results differ from tpf
results for negative operands, because of the loss of precision that
happens when NEG is constant folded.

So the same integer modulus expression can have 3 different results
depending on the context.
2025-03-18 15:21:43 +01:00
Francisco Casas
a3f80061b1 tests/hlsl: Test for loss of precision on integer negation in d3dbc target profiles. 2025-03-18 14:25:26 +01:00
Elizabeth Figura
bc382c6835 vkd3d-shader/hlsl: Reuse shader model 1-3 constants. 2025-03-18 14:21:02 +01:00
Giovanni Mascellani
e418bbcfac tests: Mark a test about resource aliasing as todo on MoltenVK.
As far as I know there is no way to implement this properly on
Vulkan, and all the other Vulkan implementations essentially work
by luck. In Vulkan the initial layout of a resource must always be
UNDEFINED or PREINITIALIZED and it must be transitioned away from
before any meaningful use of that image is done. Therefore it's
possible to alias two images and let the second one inherit the
content in the first one only if both already exist (and are in
the same layout) before the first writing is done. If, as in this
example, the second image is created after the first one has
already been written to, the obligatory transition away from
UNDEFINED or PREINITIALIZED will potentially wipe out the content.

Therefore I am marking this as todo, not as a bug. I might also be
that there is a bug in MoltenVK, and ultimately that's the reason
why we're reading invalid data, but technically the Vulkan
commands we generate are incorrect anyway.
2025-03-17 15:14:23 +01:00
Giovanni Mascellani
44072062ff tests: Transition texture state to inherit aliased data.
When textures[1] is read for the second time it is aliased to
textures[0]. But textures[0] was left in COPY_DEST state (since
its creation), and textures[1] is currently recreated in COPY_SOURCE
state, which AFAIU is invalid. So recreate textures[1] in COPY_DEST
state and then transition it before reading it.
2025-03-17 15:14:23 +01:00
Giovanni Mascellani
c3f01d7db9 tests: Mark two other tessellation tests as buggy on MoltenVK.
I haven't investigated the actual problem here, but the generated
Vulkan commands look correct (and work with basically all other
Vulkan implementations) and MoltenVK is known to have incomplete
tessellation support, so it's likely that the problem is there.
2025-03-17 15:14:23 +01:00
Giovanni Mascellani
8cf61c859d tests: Mark a few other timestamp query tests as buggy on MoltenVK.
Similarly to 5d4edba925, it seems
that sometimes MoltenVK returns 0 to timestamp queries. It
doesn't happen deterministically and it might depend on the
hardware (I have seen differences between the M2 I used some
time ago and the M3 Max I have now).
2025-03-17 15:14:23 +01:00
Giovanni Mascellani
101f070f12 ci: Define VKD3D_TEST_DEBUG when running the CI scripts.
Essentially to make d3d12.log more readable.
2025-03-17 15:14:23 +01:00
Henri Verbeet
0dff53ada7 build: Add @DL_LIBS@ to tests_vkd3d_shader_api_LDADD.
It uses dxcompiler_create(), which (potentially) uses dlopen().
2025-03-17 15:13:42 +01:00
Giovanni Mascellani
674614cc7a vkd3d-shader/ir: Disallow IMMCONSTBUFFER registers in destination parameters. 2025-03-17 15:12:13 +01:00
Giovanni Mascellani
0761d73e9c vkd3d-shader/ir: Disallow CONSTBUFFER registers in destination parameters. 2025-03-17 15:12:13 +01:00
Giovanni Mascellani
0c9c29fb34 vkd3d-shader/ir: Validate CONSTBUFFER registers. 2025-03-17 15:11:52 +01:00
Henri Verbeet
808931b108 vkd3d-shader/glsl: Implement VKD3DSIH_XOR. 2025-03-17 15:07:51 +01:00
Nikolay Sivov
ba79890398 vkd3d-shader/fx: Support dumping parameter and array selector assignments for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 15:05:14 +01:00
Nikolay Sivov
ff7591171b vkd3d-shader/fx: Dump complex state value blobs for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:54:26 +01:00
Nikolay Sivov
fb16ae2325 vkd3d-shader/fx: Add support for dumping fx_2_0 shader blobs.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:48:12 +01:00
Nikolay Sivov
36e1a0ceae vkd3d-shader/fx: Add support for parsing fx_2_0 sampler states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:46:36 +01:00
Nikolay Sivov
3e86484091 vkd3d-shader/fx: Read fx_2_0 assignment data outside of its dumping helper.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:46:36 +01:00
Nikolay Sivov
fb5d53bf57 vkd3d-shader/fx: Add a helper to escape printed strings.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-17 14:46:18 +01:00
Giovanni Mascellani
fc4316f664 tests/shader_runner: Avoid creating devices for backends that won't execute.
My main motivation to this is avoiding generating a lot of useless
log lines from other executors when I'm interested in just one of
them, but I can imagine this also somewhat improving efficiency.
2025-03-17 14:01:22 +01:00
Giovanni Mascellani
0b273ea88c tests: Store the compiler string in the shader runner capabilities.
Just like the executor.
2025-03-17 13:50:19 +01:00
Shaun Ren
a4f58be00c vkd3d-shader/hlsl: Remove the unused hlsl_array_type_to_string() declaration.
Accidentally introduced in 870c68dd27.
2025-03-13 14:02:26 +01:00
Elizabeth Figura
c9a5f586b7 vkd3d-shader/hlsl: Zero-initialize "nonconst_i" and "ret_swizzle" in copy_propagation_replace_with_deref().
GCC without LTO is unable to determine that these are never used
uninitialized.
2025-03-13 13:59:05 +01:00
Francisco Casas
09b9f8ff9f vkd3d-shader/hlsl: Fix invalidation of the wrong components in copy-propagation.
Fixes: 1bba18aa75.
2025-03-12 22:14:25 +01:00
Francisco Casas
bff9068a7f tests: Add a hard test for copy-propagation invalidation.
This test is currently miscompiling on SM4 because
copy_propagation_invalidate_variable_from_deref_recurse() is not always
invalidating the right components.
2025-03-12 22:14:15 +01:00
Elizabeth Figura
a87b1efbd2 vkd3d-shader/hlsl: Don't invalidate OOB constant derefs. 2025-03-12 22:09:57 +01:00
Elizabeth Figura
193e40c271 vkd3d-shader/hlsl: Stop checking for failure from intrinsic_float_convert_arg(). 2025-03-12 22:02:39 +01:00
Elizabeth Figura
7b5b5dbb8d vkd3d-shader/hlsl: Do not abort when performing an invalid implicit cast. 2025-03-12 22:02:39 +01:00
Elizabeth Figura
2ee19c4d34 vkd3d-shader/hlsl: Do not abort when performing an invalid explicit cast. 2025-03-12 22:02:39 +01:00
Elizabeth Figura
25f476c7ad vkd3d-shader/hlsl: Return an error expression from add_cast() on allocation failure. 2025-03-12 22:02:39 +01:00
Elizabeth Figura
0642531c2a vkd3d-shader/hlsl: Introduce hlsl_block_add_swizzle(). 2025-03-12 22:02:31 +01:00
Elizabeth Figura
f8c53fae37 vkd3d-shader/hlsl: Introduce hlsl_block_add_resource_load(). 2025-03-12 22:02:21 +01:00
Henri Verbeet
b9ebf87114 vkd3d-shader/hlsl: Do not collect expressions across different operations in hlsl_normalize_binary_exprs(). 2025-03-12 21:34:17 +01:00
Henri Verbeet
b4296e1a2d tests/hlsl: Add another constant folding test. 2025-03-12 21:34:02 +01:00
Shaun Ren
dd1072a99b tests/hlsl: Add geometry shader syntax tests. 2025-03-12 21:21:35 +01:00
Shaun Ren
ae5261b98b vkd3d-shader/hlsl: Forbid output parameters in geometry shaders.
Outputs in geometry shaders must be written to streams.
2025-03-12 21:15:15 +01:00
Shaun Ren
4137ea5ab7 vkd3d-shader/hlsl: Validate stream output parameters in geometry shaders. 2025-03-12 21:13:59 +01:00
Shaun Ren
b650e7a503 vkd3d-shader/hlsl: Validate stream output object declarations.
Valid stream output objects must be single-element containing a
PointStream/LineStream/TriangleStream object.

Moreover, stream output objects cannot be declared globally.
2025-03-12 21:12:56 +01:00
Shaun Ren
870c68dd27 vkd3d-shader/hlsl: Validate and record input primitive types in geometry shaders. 2025-03-12 21:11:46 +01:00
Shaun Ren
57bb28e841 vkd3d-shader/hlsl: Parse primitive type modifiers in geometry shaders. 2025-03-12 20:42:59 +01:00
Shaun Ren
e880b11626 vkd3d-shader/hlsl: Parse the maxvertexcount attribute. 2025-03-12 20:42:15 +01:00
Francisco Casas
7be7e589a9 vkd3d-shader/hlsl: Lower TRUNC expressions for SM1.
Basically, separate lower_casts_to_int() into the lowering of the CAST
and the lowering of the TRUNC, so that TRUNCs that are not part of a
cast are lowered as well.
2025-03-12 18:26:23 +01:00
Shaun Ren
1b03676a36 tests/hlsl: Add dynamic addressing copy-propagation tests. 2025-03-12 18:22:01 +01:00
Shaun Ren
7ab7b2ab8b vkd3d-shader/hlsl: Implement copy-propagation of derefs with a non-constant index.
We implement a transformation that propagates loads with a single
non-constant index in its deref path. Consider a load of the form
var[[a0][a1]...[i]...[an]], where ak are integral constants, and i is
an arbitrary non-constant node. If, for all j, the following holds:

  var[[a0][a1]...[j]...[an]] = x[[c0*j + d0][c1*j + d1]...[cm*j + dm]],

where ck, dk are constants, then we can replace the load with
x[[c0*i + d0]...[cm*i + dm]]. This pass is implemented by
copy_propagation_replace_with_deref().
2025-03-12 18:16:59 +01:00
Shaun Ren
f484527cfb vkd3d-shader/hlsl: Rename init_deref() to hlsl_init_deref(). 2025-03-12 17:22:44 +01:00
Shaun Ren
2bc7fa568f vkd3d-shader/hlsl: Introduce component_index_from_deref_path_node(). 2025-03-12 17:19:56 +01:00
Shaun Ren
2368ff6637 vkd3d-shader/hlsl: Introduce simplify_exprs().
Also invoke simplify_exprs() after replace_deref_path_with_offset().
2025-03-12 17:18:52 +01:00
Shaun Ren
c6f18c9394 vkd3d-shader/hlsl: Support indirect addressing of uniforms in sm4_generate_vsir_reg_from_deref(). 2025-03-12 17:14:52 +01:00
Shaun Ren
f6c35144e4 vkd3d-shader/hlsl: Support patch arrays in hlsl_reg_from_deref(). 2025-03-12 17:10:32 +01:00
Shaun Ren
261b5120f6 vkd3d-shader/hlsl: Allow non-constant indices in register_deref_usage(). 2025-03-12 17:10:32 +01:00
Shaun Ren
1c2434f4d3 vkd3d-shader/hlsl: Allow uint1-typed deref path nodes.
When derefs with non-constant indices are copy-propagated, it is
possible to end up with uint1-typed path nodes.

Also, introduce hlsl_is_vec1().
2025-03-12 17:09:35 +01:00
Shaun Ren
766492d1cc vkd3d-shader/glsl: Implement support for indirect constant buffer addressing. 2025-03-12 17:06:47 +01:00
Shaun Ren
16b0afc192 vkd3d-shader/tpf: Write non-zero static offsets in relative addressing mode in sm4_write_register_index(). 2025-03-12 17:04:52 +01:00
Henri Verbeet
81dc67b1ef demos: Add copyright headers to the HLSL shaders. 2025-03-10 15:18:07 +01:00
Elizabeth Figura
8f28956108 vkd3d-shader/hlsl: Fix writing the sincos extra constants.
Fixes: 4ed16108f0
2025-03-10 15:17:19 +01:00
Elizabeth Figura
d075c3c274 vkd3d-shader/hlsl: Fix temp allocation for ps 1.x.
Iterate over the extern vars, not the parameters. The synthesized inputs and
output don't go in the function parameters.

Fixes: 8b57a612d7
2025-03-10 15:17:19 +01:00
Nikolay Sivov
553e37314a vkd3d-shader/fx: Print string object entries for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-10 15:14:32 +01:00
Nikolay Sivov
3749171656 vkd3d-shader/fx: Output object initialiser IDs for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-10 15:14:24 +01:00
Giovanni Mascellani
d34f5fbae2 tests/shader_runner: Allow selecting the compiler. 2025-03-10 15:12:45 +01:00
Giovanni Mascellani
5a898254b0 tests/shader_runner: Allow selecting the executor. 2025-03-10 15:12:33 +01:00
Petrichor Park
f05386e006 tests/shader_runner: Allow controlling which shader models to run via command line.
Adds new flags --sm-min and --sm-max. They each take a shader model
identifier, with the same syntax as in the test harness. If either is
present, then it will only run tests within the (inclusive) range.
Omitting one allows anything as the min/max.
2025-03-10 15:12:25 +01:00
Henri Verbeet
2f260a344e build: Get rid of some redundant instances of "checking" in AC_MSG_CHECKING messages.
AC_MSG_CHECKING already prints "checking" itself.
2025-03-10 15:03:23 +01:00
Elizabeth Figura
f4042ba752 vkd3d-shader/hlsl: Add a hlsl_block_add_resource_store() helper. 2025-03-10 14:56:11 +01:00
Elizabeth Figura
e7ff5da5b1 vkd3d-shader/hlsl: Add a hlsl_block_add_index() helper. 2025-03-10 14:56:11 +01:00
Elizabeth Figura
e5cabeafe5 vkd3d-shader/hlsl: Add a hlsl_block_add_loop() helper. 2025-03-10 14:56:11 +01:00
Elizabeth Figura
62196b2bf1 vkd3d-shader/hlsl: Add a hlsl_block_add_if() helper. 2025-03-10 14:56:11 +01:00
Elizabeth Figura
20aa37237d vkd3d-shader/hlsl: Add a hlsl_block_add_jump() helper. 2025-03-10 14:56:11 +01:00
Henri Verbeet
5d55a5894c vkd3d-shader/spirv: Handle "BitEnum" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
00039ba629 vkd3d-shader/spirv: Handle "ValueEnum" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
321154d25a vkd3d-shader/spirv: Handle "LiteralString" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
0e092aef70 vkd3d-shader/spirv: Handle "LiteralInteger" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
8afeb13035 vkd3d-shader/spirv: Handle "IdResultType" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
b9e78f2e2e vkd3d-shader/spirv: Handle "IdResult" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
e83f4f40f9 vkd3d-shader/spirv: Handle "IdRef" operands. 2025-03-10 14:47:03 +01:00
Henri Verbeet
bebc550f02 vkd3d-shader/spirv: Implement outputting opcode names. 2025-03-10 14:47:00 +01:00
Henri Verbeet
997f3f8266 vkd3d-shader/spirv: Implement outputting instruction offsets. 2025-03-10 14:45:06 +01:00
Giovanni Mascellani
8c785f1dc9 vkd3d-shader/spirv: Emit immediate words for unhandled instructions.
The assembler can parse these to reconstruct the original bytecode.
2025-03-10 14:45:06 +01:00
Nikolay Sivov
1417af2eab vkd3d-shader/fx: Add support for parsing numeric states in fx_2_0 passes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-06 17:21:10 +01:00
Nikolay Sivov
fb76e5daa2 vkd3d-shader/fx: Add support for parsing fx_2_0 parameters.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-06 17:21:10 +01:00
Henri Verbeet
36b8186021 vkd3d-shader/fx: Handle parser failures in fx_parse(). 2025-03-06 17:19:28 +01:00
Henri Verbeet
a6fda3e65d vkd3d-shader/fx: Output error messages for invalid sizes. 2025-03-06 17:19:28 +01:00
Elizabeth Figura
18ca7affad vkd3d-shader/hlsl: Make min16uint into a first-class type.
And properly implement translation into some binary enumerations.
2025-03-06 17:15:15 +01:00
Elizabeth Figura
16be9181a0 vkd3d-shader/hlsl: Pass the correct type to base_type_get_semantic_equivalent(). 2025-03-06 17:15:15 +01:00
Elizabeth Figura
3cf4a4e95e vkd3d-shader/hlsl: Use common hlsl_type_is_integer() and hlsl_base_type_is_integer() helpers. 2025-03-06 17:15:15 +01:00
Elizabeth Figura
bd34ec1fb3 vkd3d-shader/hlsl: Emit the minimum-precision SFI0 flag. 2025-03-06 17:15:15 +01:00
Elizabeth Figura
6cdfe38319 vkd3d-shader/hlsl: Emit minimum-precision signatures. 2025-03-06 17:15:15 +01:00
Elizabeth Figura
c2ca6b6bdf vkd3d-shader/hlsl: Emit the minimum-precision global flag when minimum-precision semantics are used.
There are other things we need to check, but this is a start.
2025-03-06 17:15:15 +01:00
Elizabeth Figura
055625448b vkd3d-shader/hlsl: Add a hlsl_block_add_simple_load() helper. 2025-03-05 14:12:12 +01:00
Elizabeth Figura
d52df527ba vkd3d-shader/hlsl: Add a hlsl_block_add_load_index() helper. 2025-03-05 14:12:12 +01:00
Elizabeth Figura
7b486fe239 vkd3d-shader/hlsl: Return an error expr from hlsl_add_load_component() on allocation failure. 2025-03-05 14:12:12 +01:00
Elizabeth Figura
009f5765df vkd3d-shader/hlsl: Return void from hlsl_block_add_store_component(). 2025-03-05 14:12:12 +01:00
Elizabeth Figura
9e3ac35669 vkd3d-shader/hlsl: Pass the target block to hlsl_new_store_component(). 2025-03-05 14:12:12 +01:00
Henri Verbeet
5ab5a721a1 vkd3d-shader/spirv: Do not sign-extend *ptr in vkd3d_spirv_build_string().
"char" is (potentially) signed, so casting it to uint32_t will
sign-extend it. Because we use |= to assign it to "word", and don't
otherwise mask out the higher bits either, we effectively set subsequent
bytes in the same word to 0xff for input bytes > 0x7f. That potentially
includes the \0 terminator. For example, "é" (U+00e9) is "\xc3\xa9"
when encoded as UTF-8, and would get us 0xffffffc3 instead of
0x0000a9c3.
2025-03-05 14:10:58 +01:00
Nikolay Sivov
871c9c61a5 vkd3d-shader/fx: Fix const strings array types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-05 14:09:58 +01:00
Nikolay Sivov
1c43b7b55c vkd3d-shader/fx: Add support for parsing fx_2_0 annotations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-05 14:02:09 +01:00
Nikolay Sivov
db7c22d9d6 vkd3d-shader/fx: Parse technique and pass blocks for fx_2_0.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-05 14:01:53 +01:00
Anna (navi) Figueiredo Gomes
50254c284b vkd3d-shader: Parse angle bracket initializer in state blocks.
While fxc allows full expressions inside the angle brackets, we don't parse that
yet as it'd be quite a mess to properly do so with yacc, and I'm not aware of any
game doing so in their shaders.
2025-03-03 18:00:23 +01:00
Anna (navi) Figueiredo Gomes
9809bda0e5 tests/hlsl: Add angle bracket state block syntax test. 2025-03-03 18:00:23 +01:00
Nikolay Sivov
9f09ac6893 vkd3d-shader/fx: Fix condition when printing literal constant arguments.
To reproduce:

float4 v;

SamplerState s
{
    BorderColor = 0.1 + v*0.2;
};

Expression should use more than one literal constant,
as a scalar in operation that involves a vector.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-03-03 17:54:17 +01:00
Giovanni Mascellani
aa032f31bb vkd3d: Split Vulkan debug messages.
So that they do not get truncated if they're too long.
2025-03-03 17:53:17 +01:00
Elizabeth Figura
e76c596d56 vkd3d-shader/hlsl: Add a hlsl_block_add_simple_store() helper. 2025-03-03 17:48:03 +01:00
Elizabeth Figura
fc4f440245 vkd3d-shader/hlsl: Add a hlsl_block_add_store_index() helper. 2025-03-03 17:48:03 +01:00
Elizabeth Figura
eafc97bcb3 vkd3d-shader/hlsl: Pass the target block to hlsl_new_load_component(). 2025-03-03 17:48:03 +01:00
Elizabeth Figura
d053f3665d vkd3d-shader/hlsl: Pass a block to hlsl_new_void_expr(). 2025-03-03 17:48:03 +01:00
Elizabeth Figura
662d60ad6b vkd3d-shader/hlsl: Add a hlsl_block_add_expr() helper. 2025-03-03 17:48:03 +01:00
Francisco Casas
f24cc55c14 vkd3d-shader/hlsl: Remove lower_nonfloat_exprs().
The only purpose it has at this point is wrapping integer DIV in casts,
which can be moved to lower_division().
2025-03-03 17:47:42 +01:00
Francisco Casas
7cb1970952 vkd3d-shader/hlsl: Don't cast all expressions to float.
Instead, allow half, bool, int, and uint, expressions that map to the
same float op to reach sm1_generate_vsir_instr_expr().
2025-03-03 17:26:15 +01:00
Anna (navi) Figueiredo Gomes
0ce2b1359f tests/hlsl: Add lower sm1 saturate test. 2025-03-03 17:25:20 +01:00
Henri Verbeet
57518d5312 ci: Install libjson-perl. 2025-03-02 17:08:51 +01:00
Giovanni Mascellani
8297ea9aa6 vkd3d/device: Require VK_KHR_zero_initialize_workgroup_memory when appropriate.
That extension (and the corresponding feature) must be enabled when
the Initializer operand is used for workgroup variables.
2025-02-26 16:11:50 +01:00
Nikolay Sivov
e746a4c12f vkd3d-shader/fx: Improve state object nesting for the fx -> text output.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-02-24 16:19:07 +01:00
Nikolay Sivov
09226543fe vkd3d-shader/fx: Implement parsing complex value and index expressions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-02-24 16:19:07 +01:00
Henri Verbeet
58aed8fd0d vkd3d-shader/fx: Use vkd3d_string_buffer_print_f32() in parse_fx_4_numeric_value().
Instead of "%f". vkd3d_string_buffer_print_f32() will use sufficient
precision to represent the stored value exactly, and will use '.' as
decimal separator regardless of the current locale.
2025-02-24 16:19:07 +01:00
Elizabeth Figura
2989373212 vkd3d-shader/hlsl: Add a hlsl_block_add_binary_expr() helper. 2025-02-24 16:19:07 +01:00
Elizabeth Figura
858b6a3e0b vkd3d-shader/hlsl: Add a hlsl_block_add_cast() helper. 2025-02-24 16:19:07 +01:00
Elizabeth Figura
2e09257d94 vkd3d-shader/hlsl: Add a hlsl_block_add_unary_expr() helper. 2025-02-24 16:19:07 +01:00
Elizabeth Figura
b7ea23303e vkd3d-shader/hlsl: Add a hlsl_block_add_float_constant() helper. 2025-02-24 16:19:07 +01:00
Elizabeth Figura
e830cdee71 vkd3d-shader/hlsl: Inline add_pow_expr().
The helper is used in one place.
2025-02-24 16:19:07 +01:00
Conor McCarthy
439652f023 tests: Replace test_vs_ps_relative_addressing() with a shader runner test.
Besides simply being more compact, this allows the test to cover more
shader types, perhaps most notably DXIL.
2025-02-24 16:19:01 +01:00
Henri Verbeet
1fd89abcc3 vkd3d-shader: Enable DXIL support in the default configuration. 2025-02-24 15:10:08 +01:00
Henri Verbeet
73c0356861 tests: Add a shader model 6 signature reflection test for different types. 2025-02-24 15:10:08 +01:00
Henri Verbeet
fe4143ad19 vkd3d-shader/dxil: Generate I/O signatures with 16-bit component types for native 16-bit shaders.
Which incidentally matches the I/O signatures from the DXBC container.
2025-02-24 15:10:08 +01:00
Henri Verbeet
f5d702b09a vkd3d-shader/dxbc: Validate component types in shader_parse_signature(). 2025-02-24 15:10:08 +01:00
Henri Verbeet
b8d740ebfc vkd3d-shader/dxbc: Output messages for invalid semantic name references in shader_parse_signature(). 2025-02-24 15:10:08 +01:00
Henri Verbeet
3bcdb85ddc vkd3d-shader/dxbc: Set the "elements_capacity" field as well in shader_parse_signature().
Leaving it as 0 mostly ends up doing the right thing in practice, but isn't
quite right.
2025-02-24 15:10:08 +01:00
Giovanni Mascellani
2feb3a3bba vkd3d: Take the root signature from shaders when creating graphics pipelines.
If the root signature wasn't explicitly specified.

This fixes a failure in The Touryst.
2025-02-20 16:00:55 +01:00
Giovanni Mascellani
42b65e80cf tests: Test embedding the root signature in shaders for graphics pipelines. 2025-02-20 15:59:22 +01:00
Henri Verbeet
0796af7b4b vkd3d: Avoid vkd3d_shader_parse_input_signature(). 2025-02-20 15:57:26 +01:00
Henri Verbeet
2e62e9ea7e vkd3d-shader: Handle arrayed elements in vkd3d_shader_signature_from_shader_signature(). 2025-02-20 15:57:26 +01:00
Henri Verbeet
ce5164e26e tests: Add a signature reflection test for arrayed inputs and outputs. 2025-02-20 15:57:26 +01:00
Henri Verbeet
4e28d1c658 vkd3d-shader/dxbc: Do not extract I/O signatures for DXIL shaders.
The DXIL parser doesn't need them.
2025-02-20 15:57:26 +01:00
Henri Verbeet
f4a3d17269 vkd3d-shader/dxil: Avoid using the I/O signatures from the DXBC container.
We currently generate our own I/O signatures inside the DXIL parser, but
use the element counts from the DXBC container signatures to allocate
the input_params/output_params/patch_constant_params arrays. That
happens to work for well-behaved inputs, but it's asking for trouble.
2025-02-20 15:57:26 +01:00
Henri Verbeet
970a1a2b35 vkd3d-shader/dxbc: Update the vkd3d_shader_parse_input_signature() documentation for dxbc-dxil shaders. 2025-02-20 15:57:26 +01:00
Elizabeth Figura
d5a2ff5c12 vkd3d-shader/hlsl: Add a hlsl_block_add_int_constant() helper. 2025-02-20 15:56:31 +01:00
Elizabeth Figura
992d20def3 vkd3d-shader/hlsl: Add a hlsl_block_add_uint_constant() helper. 2025-02-20 15:50:13 +01:00
Elizabeth Figura
79ad8c9354 vkd3d-shader/hlsl: Handle error instructions in hlsl_new_swizzle().
We already check for error instructions when parsing swizzles, but if allocation
fails at codegen time we would like to avoid asserting when subsequently
constructing a swizzle.
2025-02-20 15:49:40 +01:00
Elizabeth Figura
4072aa4a4b vkd3d-shader/hlsl: Remove the type equality assertions in hlsl_new_ternary_expr().
Similar to d1c2ae3f0e, this is a bit too strict
and may prevent e.g. simultaneous use of float and float1 at codegen time.

However, in this case the inciting factor is that in the case of allocation
failure at codegen time, we would like to allow one or more arguments to have
error type.
2025-02-20 15:48:25 +01:00
Elizabeth Figura
ba868ed4a6 vkd3d-shader/hlsl: Skip transformation passes on error.
The primary motivation here is to avoid needing to worry about instructions
potentially pointing to the preallocated error instruction in the case of
allocation failure.

This doesn't cover all passes, but none of the other passes make assumptions
about instruction sources.
2025-02-20 15:48:24 +01:00
Francisco Casas
153b7c8460 vkd3d-shader/hlsl: Run folding passes again after lower_nonconstant_array_loads.
This is because lower_nonconstant_array_loads() can potentially turn
nonconstant loads into constant loads, allowing copy-prop to turn these
loads into previous instructions, which might help other passes as well.

This patch lowers the number of required temps for the following ps_2_0
shader from 19 to 16:

    int i;
    float3x3 mats[4];

    float4 main() : sv_target
    {
        return mul(mats[i], float3(1, 2, 3)).xyzz;
    }
2025-02-20 15:44:09 +01:00
Francisco Casas
e60c89c532 tests: Test unused invalid samples with a static sampler. 2025-02-20 15:44:09 +01:00
Francisco Casas
321fda9c26 vkd3d-shader/hlsl: Only use the temp copy for variables that are written.
This can save a significant amount of temp registers because it allows to
avoid referencing the temp (and having to store it) when not needed.

For instance, this patch lowers the number of required temps for the
following ps_2_0 shader from 24 to 19:

    int i;
    float3x3 mats[4];

    float4 main() : sv_target
    {
        return mul(mats[i], float3(1, 2, 3)).xyzz;
    }

Also, it is needed for SM1 vertex shader relative addressing since
non-constant loads are required to be directly on the uniform ('c'
registers) instead of the temp, and non-constant loads cannot be
transformed by copy propagation.
2025-02-20 15:44:09 +01:00
Elizabeth Figura
8e6ddb0c1a vkd3d-shader/hlsl: Don't mark extern variables with an explicit first_write or last_read.
Fix the last few places that care.
2025-02-20 15:44:09 +01:00
Francisco Casas
1d74ff075e vkd3d-make/hlsl: Trace the number of registers allocated in allocate_temp_registers(). 2025-02-20 15:44:04 +01:00
Nikolay Sivov
f830ac1206 vkd3d-shader/preproc: Do not attempt to load empty included files.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-02-20 15:40:34 +01:00
Giovanni Mascellani
07b7975d09 vkd3d: Put all root descriptors in a single Vulkan descriptor set when using Vulkan heaps.
Since 4a94bfc2f6 we segregate
different D3D12 descriptor types in different Vulkan descriptor sets.
This change was introduced to reduce descriptor wasting when
allocating a new descriptor pool; that can be very useful when
using virtual heaps, which have to often cycle through many
descriptors, but it is expected to have limited impact for Vulkan
heaps, given that in that case most descriptors are allocated through
the descriptor heap rather than through the command allocator.

Instead, it has a rather detrimental effect with Vulkan heaps,
because it tends to use many more Vulkan descriptor sets than
necessary, often with just a handful of descriptors each. This
causes a regression on some Vulkan implementations that support
too few descriptor sets.

With this change we revert to a situation similar to before,
stuffing all the descriptors that do not live in a root
descriptor table in as few descriptor sets as possible (at most
one or two, depending on whether push descriptors are used).
2025-02-19 17:58:23 +01:00
Giovanni Mascellani
6415c6b0e0 vkd3d: Rename push_descriptor_set to root_descriptor_set.
Soon it won't be used necessarily for push descriptors anymore, but
it will still contain root descriptors.
2025-02-19 17:57:15 +01:00
Conor McCarthy
67d8cf744c tests/hlsl: Add a conditional 16-bit test. 2025-02-19 17:53:57 +01:00
Conor McCarthy
36f9510bb3 tests/hlsl: Add interstage interface 16-bit tests. 2025-02-19 17:52:05 +01:00
Conor McCarthy
6ee650f316 tests/hlsl: Add a typed SRV load 16-bit test. 2025-02-19 17:48:38 +01:00
Conor McCarthy
2b325d3b59 tests/hlsl: Add a TGSM 16-bit test. 2025-02-19 17:47:29 +01:00
Conor McCarthy
94b8747da4 tests/hlsl: Add a sampler 16-bit test. 2025-02-19 17:46:05 +01:00
Conor McCarthy
e355cdbae0 tests/hlsl: Add typed buffer SRV 16-bit tests. 2025-02-19 17:44:59 +01:00
Giovanni Mascellani
a7337bc999 vkd3d: Require extension VK_KHR_maintenance2.
We're already implicitly using it for image layouts in which
either depth or stencil is writeable and the other is not.
Correspondingly, add the _KHR suffix in those cases, so the
extension usage is more evident.

According to the Vulkan Hardware Database, only four reports
without this extension were filed since 2023, and all of them
for configurations we likely don't target.
2025-02-19 17:41:30 +01:00
Francisco Casas
604fe3ccee tests/test-driver: Merge the same consecutive tags togeter. 2025-02-19 17:36:19 +01:00
Francisco Casas
681b839419 tests/test-driver: Group together tags in the same line and shader model. 2025-02-19 17:36:19 +01:00
Francisco Casas
72b603780c tests/test-driver: Print the shader model for the detailed output of the hlsl backend. 2025-02-19 17:36:19 +01:00
Francisco Casas
3aecbc5ac1 vkd3d-shader/hlsl: Also dump preprocessed shaders.
This could be useful since there are many shaders that contain `#include`
directives or use parameter-defined macros and we can't reproduce bugs
from the source alone.
2025-02-19 17:34:24 +01:00
Giovanni Mascellani
665c29f0be vkd3d-shader/tpf: Allow I/O index ranges to not intersect a signature element for a given register.
The current TPF validator enforces that for each register involved
in a DCL_INDEX_RANGE instruction there must be a signature element
for that register and the DCL_INDEX_RANGE write mask. This is an
excessively strong request, and causes some shaders from The Falconeer
to be invalidly rejected.

The excessively strong check was needed to avoid triggering a bug
in the I/O normaliser. Since that bug is now solved, the check
can be relaxed.
2025-02-19 17:30:25 +01:00
Giovanni Mascellani
4b84fb486b vkd3d-shader/ir: Handle index ranges that do not touch a signature element for each register.
A good part of the I/O normaliser job is to merge together signature
elements that are spanned by DCL_INDEX_RANGE instructions. The
current algorithm assumes that each index range touches exactly
one signature element for each index spanned by the range. The
assumption is used in shader_signature_merge() in the form of
expecting that, if the index range is N registers long, then,
once you find the first signature element of an index range, the
other elements that will have to be merged with it are exactly the
following N-1 according to the order given by
signature_element_register_compare() or
signature_element_mask_compare(), depending on the signature type.

This doesn't necessarily happen. For example, The Falconeer has a
few hull shaders in which this happens:

    hs_fork_phase
    dcl_hs_fork_phase_instance_count 13
    dcl_input vForkInstanceId
    dcl_output o4.z
    dcl_output o5.z
    dcl_output o6.z
    dcl_output o7.z
    dcl_output o12.z
    dcl_output o13.z
    dcl_output o14.z
    dcl_output o15.z
    dcl_output o16.z
    dcl_output o17.z
    dcl_output o18.z
    dcl_output o19.z
    dcl_output o20.z
    dcl_temps 1
    dcl_index_range o4.z 17
    iadd r0.x, vForkInstanceId.x, l(4)
    ult r0.y, vForkInstanceId.x, l(4)
    movc r0.x, r0.y, vForkInstanceId.x, r0.x
    mov o[r0.x + 4].z, l(0)
    ret

Here the index range "skips" o8.z through o11.z, because those
registers only use mask .xy. The current algorithm fails on such
a shader.

Even depending on the signature element order doesn't look ideal.
I don't have a full counterexample for that, but it looks fragile,
especially given that the register allocation algorithm in FXC is
notoriously full of unexpected corner cases.

We solve both problems by slightly changing the architecture of
the normaliser: first we move computing the masks for the merge
signature element from signature_element_range_expand_mask(),
which is executed while merging signature, to
io_normaliser_add_index_range(), which is executed before merging
signatures. Then, while we are merging signatures, we can decide
for each single signature element whether it has to be retained
or not, and how it should be patched. The algorithm becomes
independent of the order, because each signature element can be
processed individually.
2025-02-19 17:30:00 +01:00
Giovanni Mascellani
b5350f9387 vkd3d-shader/ir: Use a structure to record range data in the I/O normaliser.
In order to make it able to have other fields.
2025-02-19 17:01:54 +01:00
Giovanni Mascellani
ec7bac7ba7 vkd3d-shader/ir: Report errors in the I/O normaliser instead of asserting.
The assumptions the I/O normaliser makes on its input program are
rather intricated. In theory the VSIR validator checks should be
strong enough, but the validator isn't run by default anyway.
Whether the TPF parser validation is strong enough is not
completely clear to me, and considering that the I/O normaliser
could end up being used on different programs as well it's
probably better to revalidate locally just in case.
2025-02-19 17:01:54 +01:00
Giovanni Mascellani
8887501042 tests: Test I/O index ranges not intersecting a signature element for a given register.
Since this test depend on the specific code generated by the
native d3dcompiler we add the possibility to specify a "raw"
shader using a hex format. When the shader assembler is finally
available they should be replaced with assembly code.
2025-02-19 17:01:17 +01:00
Giovanni Mascellani
84a59fe4c0 tests: Enable tessellation shaders in the Vulkan shader runner. 2025-02-19 16:22:04 +01:00
129 changed files with 32148 additions and 5252 deletions

925
ANNOUNCE

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,102 @@
# What's new in vkd3d 1.16 (20 May 2025)
### libvkd3d
- DXIL shaders are supported in the default configuration. Previously this
required building vkd3d with the -DVKD3D_SHADER_UNSUPPORTED_DXIL
preprocessor option. The also raises the maximum supported shader model to
version 6.0.
- Graphics pipeline state objects can be created from shaders with embedded
root signatures. This was already possible for compute pipeline state
objects.
- The SetEventOnMultipleFenceCompletion() method of the ID3D12Device1
interface is implemented.
- When the VK_KHR_zero_initialize_workgroup_memory extension is supported,
libvkd3d supports zero-initialising compute shader thread group shared
memory.
- The VK_KHR_maintenance2 extension is now explicitly required. libvkd3d
already unconditionally used features provided by this extension, but
unfortunately didn't explicitly require it. Support for this extension is
widespread, and the extension is part of Vulkan 1.1.
### libvkd3d-shader
- The previously experimental support for compiling DXIL shaders is now a
supported feature and enabled by default. Please note that this feature is
nevertheless still far from perfect.
- New features for the HLSL source type:
- Initial support for geometry shaders.
- Indirect addressing in shader model 1-3 target profiles.
- Modulus and truncation operations in shader model 1-3 target profiles.
- Vectorised output code.
- Further improved constant folding and propagation.
- The following intrinsic functions are supported:
- AllMemoryBarrier()
- AllMemoryBarrierWithGroupSync()
- DeviceMemoryBarrier()
- DeviceMemoryBarrierWithGroupSync()
- GroupMemoryBarrier()
- GroupMemoryBarrierWithGroupSync()
- The .Length Texture object property.
- The SV_RenderTargetArrayIndex and SV_ViewportArrayIndex semantics in
tessellation shaders.
- Disassembler support for binary fx_2_0 effects.
- Experimental built-in support for disassembling SPIR-V shaders, enabled by
building vkd3d with the -DVKD3D_SHADER_UNSUPPORTED_SPIRV_PARSER
preprocessor option. When enabled, the built-in SPIR-V disassembler is
used instead of SPIRV-Tools for the spirv-text target type, as well as
for the debug output enabled by the VKD3D_SHADER_DEBUG environment
variable.
- The experimental OpenGL Shading Language (GLSL) target supports indirect
addressing of constant buffers.
- The experimental Metal Shading Language (MSL) target supports texture
loads.
- New interfaces:
- The VKD3D_SHADER_COMPILE_OPTION_FEATURE_ZERO_INITIALIZE_WORKGROUP_MEMORY
flag indicates support for zero-initialising workgroup memory in the
SPIR-V target environment.
- The VKD3D_SHADER_COMPONENT_INT64 enumeration value indicates a 64-bit
signed integer value.
- The VKD3D_SHADER_COMPONENT_FLOAT16 enumeration value indicates a 16-bit
IEEE floating-point value.
- The VKD3D_SHADER_COMPONENT_UINT16 enumeration value indicates a 16-bit
unsigned integer value.
- The VKD3D_SHADER_COMPONENT_INT16 enumeration value indicates a 16-bit
signed integer value.
- When targeting VKD3D_SHADER_API_1_16, the
VKD3D_SHADER_RESOURCE_DATA_NONE enumeration value is returned for the
resource_data_type field in the vkd3d_shader_descriptor_info structure
for sampler descriptors. VKD3D_SHADER_API_1_15 and before use the
VKD3D_SHADER_RESOURCE_DATA_UINT enumeration value for this.
### demos
- The vkd3d demos now work on both the Microsoft Windows and Apple macOS
builds. The macOS versions of the vkd3d demos are completely new in vkd3d
1.16, while the Windows demos could previously be built, but only worked
on Wine. Note that the vkd3d demos produced by a Windows build of vkd3d
are distinct from those produced by the make crosstest target: the
former are Vulkan applications using vkd3d, while the latter are Direct3D
12 applications.
- The vkd3d demos have basic support for DPI scaling.
### build
- Perl and the JSON Perl module have been added as build dependencies.
These are used for the experimental built-in SPIR-V disassembler, as well
as for the macOS versions of the vkd3d demos.
# What's new in vkd3d 1.15 (19 February 2025)
### libvkd3d

View File

@@ -2,6 +2,12 @@ ACLOCAL_AMFLAGS = -I m4
AM_CFLAGS = @VKD3D_CFLAGS@
AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include/private
AM_LDFLAGS = -no-undefined
VKD3D_PERL = $(PERL) -w
objc_headers = \
include/private/appkit.h \
include/private/foundation.h \
include/private/quartzcore.h
widl_headers = \
include/vkd3d_d3d12.h \
@@ -63,6 +69,7 @@ vkd3d_shader_tests = \
tests/hlsl/asint.shader_test \
tests/hlsl/asuint.shader_test \
tests/hlsl/attributes.shader_test \
tests/hlsl/barriers.shader_test \
tests/hlsl/bitwise-assignment.shader_test \
tests/hlsl/bitwise.shader_test \
tests/hlsl/bool-cast.shader_test \
@@ -108,6 +115,7 @@ vkd3d_shader_tests = \
tests/hlsl/effect-compile.shader_test \
tests/hlsl/effect-initial-values-fx_2.shader_test \
tests/hlsl/effect-initial-values-fx_4.shader_test \
tests/hlsl/effect-pass-states-fx_4.shader_test \
tests/hlsl/effect-pass-states-fx_5.shader_test \
tests/hlsl/effect-shader-objects-fx_2.shader_test \
tests/hlsl/effect-shader-objects-fx_5.shader_test \
@@ -116,6 +124,7 @@ vkd3d_shader_tests = \
tests/hlsl/effect-technique-fx_5.shader_test \
tests/hlsl/effect-variables-fx_2.shader_test \
tests/hlsl/effect-variables-fx_4.shader_test \
tests/hlsl/effect-variables-fx_4_1.shader_test \
tests/hlsl/effect-variables-fx_5.shader_test \
tests/hlsl/entry-point-semantics.shader_test \
tests/hlsl/eval-attrib.shader_test \
@@ -124,11 +133,11 @@ vkd3d_shader_tests = \
tests/hlsl/f16tof32.shader_test \
tests/hlsl/f32tof16.shader_test \
tests/hlsl/faceforward.shader_test \
tests/hlsl/fog.shader_test \
tests/hlsl/ffp-point-size.shader_test \
tests/hlsl/float-comparison.shader_test \
tests/hlsl/floor.shader_test \
tests/hlsl/fmod.shader_test \
tests/hlsl/fog.shader_test \
tests/hlsl/for.shader_test \
tests/hlsl/frac.shader_test \
tests/hlsl/function-cast.shader_test \
@@ -140,6 +149,7 @@ vkd3d_shader_tests = \
tests/hlsl/gather-cmp.shader_test \
tests/hlsl/gather-offset.shader_test \
tests/hlsl/gather.shader_test \
tests/hlsl/geometry-shader-syntax.shader_test \
tests/hlsl/geometry.shader_test \
tests/hlsl/get-sample-pos.shader_test \
tests/hlsl/getdimensions.shader_test \
@@ -166,6 +176,7 @@ vkd3d_shader_tests = \
tests/hlsl/is-front-face.shader_test \
tests/hlsl/isinf.shader_test \
tests/hlsl/ldexp.shader_test \
tests/hlsl/length-property.shader_test \
tests/hlsl/length.shader_test \
tests/hlsl/lerp.shader_test \
tests/hlsl/lhs-cast.shader_test \
@@ -198,6 +209,7 @@ vkd3d_shader_tests = \
tests/hlsl/object-parameters.shader_test \
tests/hlsl/object-references.shader_test \
tests/hlsl/patch-syntax.shader_test \
tests/hlsl/pixel-position.shader_test \
tests/hlsl/point-sprite.shader_test \
tests/hlsl/pointer-cast.shader_test \
tests/hlsl/pow.shader_test \
@@ -241,6 +253,7 @@ vkd3d_shader_tests = \
tests/hlsl/sqrt.shader_test \
tests/hlsl/srv-buffers.shader_test \
tests/hlsl/srv-byteaddressbuffer.shader_test \
tests/hlsl/srv-structuredbuffer.shader_test \
tests/hlsl/state-block-function-syntax.shader_test \
tests/hlsl/state-block-syntax.shader_test \
tests/hlsl/static-initializer.shader_test \
@@ -251,6 +264,7 @@ vkd3d_shader_tests = \
tests/hlsl/struct-assignment.shader_test \
tests/hlsl/struct-inheritance.shader_test \
tests/hlsl/struct-semantics.shader_test \
tests/hlsl/struct-syntax.shader_test \
tests/hlsl/switch.shader_test \
tests/hlsl/swizzle-constant-prop.shader_test \
tests/hlsl/swizzle-matrix.shader_test \
@@ -315,10 +329,14 @@ vkd3d_demos = \
vkd3d_demos_headers = \
demos/demo.h \
demos/demo_d3d12.h \
demos/demo_macos.h \
demos/demo_vkd3d.h \
demos/demo_win32.h \
demos/demo_xcb.h
BUILT_SOURCES = $(widl_headers) \
BUILT_SOURCES = $(objc_headers) $(widl_headers) \
include/private/spirv_grammar.h \
include/private/vkd3d_version.h
noinst_LTLIBRARIES = libvkd3d-common.la
@@ -377,6 +395,7 @@ nodist_libvkd3d_shader_la_SOURCES = $(vkd3d_shader_yyfiles)
libvkd3d_shader_la_SOURCES = \
include/private/list.h \
include/private/rbtree.h \
include/private/spirv_grammar.h \
include/private/vkd3d_common.h \
include/private/vkd3d_memory.h \
include/vkd3d_shader.h \
@@ -400,7 +419,7 @@ libvkd3d_shader_la_SOURCES = \
libs/vkd3d-shader/vkd3d_shader_main.c \
libs/vkd3d-shader/vkd3d_shader_private.h
libvkd3d_shader_la_CFLAGS = $(AM_CFLAGS) -DLIBVKD3D_SHADER_SOURCE -I$(srcdir)/libs/vkd3d-shader @SPIRV_TOOLS_CFLAGS@
libvkd3d_shader_la_LDFLAGS = $(AM_LDFLAGS) -version-info 14:0:13
libvkd3d_shader_la_LDFLAGS = $(AM_LDFLAGS) -version-info 15:0:14
libvkd3d_shader_la_LIBADD = libvkd3d-common.la @SPIRV_TOOLS_LIBS@ -lm
if HAVE_LD_VERSION_SCRIPT
libvkd3d_shader_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d-shader/vkd3d_shader.map
@@ -435,7 +454,7 @@ libvkd3d_la_SOURCES = \
libs/vkd3d/vkd3d_shaders.h \
libs/vkd3d/vulkan_procs.h
libvkd3d_la_CFLAGS = $(AM_CFLAGS) -DLIBVKD3D_SOURCE
libvkd3d_la_LDFLAGS = $(AM_LDFLAGS) -version-info 16:0:15
libvkd3d_la_LDFLAGS = $(AM_LDFLAGS) -version-info 17:0:16
libvkd3d_la_LIBADD = libvkd3d-common.la libvkd3d-shader.la @DL_LIBS@ @PTHREAD_LIBS@
if HAVE_LD_VERSION_SCRIPT
libvkd3d_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d/vkd3d.map
@@ -448,7 +467,7 @@ libvkd3d_utils_la_SOURCES = \
libs/vkd3d-utils/vkd3d_utils_main.c \
libs/vkd3d-utils/vkd3d_utils_private.h
libvkd3d_utils_la_CFLAGS = $(AM_CFLAGS) -DLIBVKD3D_UTILS_SOURCE
libvkd3d_utils_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:1:6
libvkd3d_utils_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:2:6
libvkd3d_utils_la_LIBADD = libvkd3d-common.la libvkd3d-shader.la libvkd3d.la @PTHREAD_LIBS@
if HAVE_LD_VERSION_SCRIPT
libvkd3d_utils_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d-utils/vkd3d_utils.map
@@ -513,7 +532,7 @@ tests_vkd3d_api_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
tests_vkd3d_api_LDADD = libvkd3d.la @DL_LIBS@
tests_vkd3d_shader_api_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
tests_vkd3d_shader_api_CFLAGS = $(AM_CFLAGS) @OPENGL_CFLAGS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la @OPENGL_LIBS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la @OPENGL_LIBS@ @DL_LIBS@
SHADER_TEST_LOG_COMPILER = tests/shader_runner
SHADER_TEST_LOG_DRIVER = $(srcdir)/tests/test-driver.sh
endif
@@ -521,8 +540,8 @@ endif
EXTRA_DIST += $(vkd3d_shader_tests)
if BUILD_DEMOS
DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @DL_LIBS@ @DEMO_LIBS@
DEMOS_CFLAGS = $(AM_CFLAGS) @DEMO_CFLAGS@ -Wa,-I$(srcdir)/demos
DEMOS_LDADD = $(LDADD) @DL_LIBS@ @DEMO_LIBS@
DEMOS_CFLAGS = $(AM_CFLAGS) @DEMO_CFLAGS@ -I$(srcdir)/demos -Wa,-I$(srcdir)/demos
bin_PROGRAMS += $(vkd3d_demos)
demos_vkd3d_gears_SOURCES = demos/gears.c demos/gears.hlsl
@@ -537,6 +556,17 @@ demos/vkd3d_triangle-triangle.$(OBJEXT): demos/triangle.hlsl
endif
noinst_HEADERS = $(vkd3d_test_headers) $(vkd3d_demos_headers)
dist_noinst_SCRIPTS = libs/vkd3d-shader/make_spirv demos/make_objc
VKD3D_V_PERL = $(vkd3d_v_perl_@AM_V@)
vkd3d_v_perl_ = $(vkd3d_v_perl_@AM_DEFAULT_V@)
vkd3d_v_perl_0 = @echo " PERL " $@;
vkd3d_v_perl_1 =
CLEANFILES += $(objc_headers)
${objc_headers}: %.h: demos/make_objc %.json
@$(MKDIR_P) $(@D)
$(VKD3D_V_PERL)$(VKD3D_PERL) $^ > $@.tmp && mv $@.tmp $@
VKD3D_V_WIDL = $(vkd3d_v_widl_@AM_V@)
vkd3d_v_widl_ = $(vkd3d_v_widl_@AM_DEFAULT_V@)
@@ -546,7 +576,11 @@ vkd3d_v_widl_1 =
if HAVE_WIDL
CLEANFILES += $(widl_headers)
endif
EXTRA_DIST += $(widl_headers) $(widl_headers:.h=.idl)
EXTRA_DIST += \
$(widl_headers) \
$(widl_headers:.h=.idl) \
$(objc_headers:.h=.json) \
include/private/spirv.core.grammar.json
$(widl_headers): %.h: %.idl
if HAVE_WIDL
$(VKD3D_V_WIDL)$(WIDL) -I$(srcdir)/include -h -o $@ $<
@@ -578,6 +612,10 @@ libvkd3d.pc: $(srcdir)/libs/vkd3d/libvkd3d.pc.in Makefile
-e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \
$< > $@
include/private/spirv_grammar.h: libs/vkd3d-shader/make_spirv include/private/spirv.core.grammar.json
@$(MKDIR_P) $(@D)
$(VKD3D_V_PERL)$(VKD3D_PERL) $^ > $@.tmp && mv $@.tmp $@
include/private/vkd3d_version.h: dummy-vkd3d-version
@$(MKDIR_P) include/private
version=`(GIT_DIR=$(top_srcdir)/.git git rev-parse --short HEAD 2>/dev/null || echo '') \
@@ -586,7 +624,7 @@ include/private/vkd3d_version.h: dummy-vkd3d-version
&& (echo $$version | cmp -s - $@) \
|| echo $$version >$@ || ($(RM) $@ && exit 1)
.SILENT: include/private/vkd3d_version.h
CLEANFILES += include/private/vkd3d_version.h
CLEANFILES += include/private/spirv_grammar.h include/private/vkd3d_version.h
.PHONY: dummy-vkd3d-version
dummy-vkd3d-version:

9
README
View File

@@ -9,7 +9,8 @@ similar, but not identical, to Direct3D 12.
Building vkd3d
==============
Vkd3d depends on SPIRV-Headers and Vulkan-Headers (>= 1.3.228).
Vkd3d depends on SPIRV-Headers and Vulkan-Headers (>= 1.3.228), as well as Perl
and libjson-perl.
Vkd3d generates some of its headers from IDL files. If you are using the
release tarballs, then these headers are pre-generated and are included. If
@@ -149,12 +150,6 @@ in future versions of vkd3d.
emitted; this can be useful for developers to make error conditions as
conspicuous as possible.
* VKD3D_SHADER_UNSUPPORTED_DXIL - enable DXIL (DirectX Intermediate Language)
support in vkd3d-shader, which is disabled by default because it is not
considered ready for release yet. Please note that this feature is not
currently supported, and it might change in a non-compatible way before it is
released.
* VKD3D_SHADER_UNSUPPORTED_GLSL - enable GLSL (GL Shading Language) support in
vkd3d-shader, which is disabled by default because it is not considered ready
for release yet. Please note that this feature is not currently supported,

View File

@@ -1,10 +1,11 @@
AC_PREREQ([2.69])
AC_INIT([vkd3d],[1.15])
AC_INIT([vkd3d],[1.16])
AC_CONFIG_AUX_DIR([bin])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS(include/config.h)
AC_ARG_VAR([PERL], [The Perl 5 language interpreter])
AC_ARG_VAR([WIDL], [widl IDL compiler])
AC_ARG_VAR([CROSSCC32], [32-bit Windows cross compiler])
AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler])
@@ -32,6 +33,11 @@ AC_PROG_MKDIR_P
VKD3D_PROG_WIDL(3, 21)
AS_IF([test "x$WIDL" = "xno"], [AC_MSG_WARN([widl is required to build header files.])])
AC_CHECK_PROGS([PERL], [perl], [none])
AS_IF([test "$PERL" = "none"], [AC_MSG_ERROR([no suitable perl found. Please install the 'perl-base' package.])])
VKD3D_CHECK_PERL_MODULE([JSON],
[AC_MSG_ERROR([perl module 'JSON' not found. Please install the 'libjson-perl' package.])])
AC_CHECK_PROGS([FLEX], [flex], [none])
AS_IF([test "$FLEX" = "none"], [AC_MSG_ERROR([no suitable flex found. Please install the 'flex' package.])])
AC_ARG_VAR([LFLAGS], [extra flags for flex])
@@ -178,15 +184,20 @@ AC_CHECK_FUNCS([pthread_threadid_np])
dnl Makefiles
case $host_os in
mingw32*)
AC_SUBST([DEMO_LIBS],["-ld3d12 -ldxgi -lgdi32"])
AC_SUBST([DEMO_LIBS],["-lgdi32"])
AC_SUBST([DEMO_CFLAGS],["-municode"])
;;
darwin*)
AC_SUBST([DEMO_LIBS],["-framework Foundation -framework AppKit -framework QuartzCore"])
AC_SUBST([DEMO_CFLAGS],[""])
;;
*) AS_IF([test "x$enable_demos" = "xyes" -a "x$HAVE_XCB" != "xyes"],
[AC_MSG_ERROR([libxcb is required for demos.])])
AC_SUBST([DEMO_LIBS],[$XCB_LIBS])
AC_SUBST([DEMO_CFLAGS],[$XCB_CFLAGS])
;;
esac
VKD3D_CHECK_CFLAGS([-fno-lto], [DEMO_CFLAGS="$DEMO_CFLAGS -fno-lto"])
AM_CONDITIONAL([BUILD_DEMOS], [test "x$enable_demos" = "xyes"])
AM_CONDITIONAL([BUILD_DOC], [test $DX_FLAG_doc = 1])
AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" != "xno"])

View File

@@ -43,13 +43,17 @@
#define DEMO_ASM_PUSHSECTION ".section rdata\n\t"
#define DEMO_ASM_POPSECTION ".text\n\t"
#define DEMO_ASM_OBJECT_TYPE(name)
#elif defined(__APPLE__)
#define DEMO_ASM_PUSHSECTION ".pushsection __TEXT,__const\n\t"
#define DEMO_ASM_POPSECTION ".popsection\n\t"
#define DEMO_ASM_OBJECT_TYPE(name)
#else
#define DEMO_ASM_PUSHSECTION ".pushsection .rodata\n\t"
#define DEMO_ASM_POPSECTION ".popsection\n\t"
#define DEMO_ASM_OBJECT_TYPE(name) ".type "name", @object\n\t"
#endif
#if defined(__WIN32__) && defined(__i386__)
#if (defined(__WIN32__) && defined(__i386__)) || defined(__APPLE__)
#define DEMO_ASM_NAME(name) "_"#name
#else
#define DEMO_ASM_NAME(name) #name
@@ -174,9 +178,11 @@ static inline HRESULT demo_create_root_signature(ID3D12Device *device,
return hr;
}
#ifdef _WIN32
#include "demo_win32.h"
#ifdef VKD3D_CROSSTEST
#include "demo_d3d12.h"
#else
#define INFINITE VKD3D_INFINITE
#include "demo_xcb.h"
# ifndef _WIN32
# define INFINITE VKD3D_INFINITE
# endif
#include "demo_vkd3d.h"
#endif

217
demos/demo_d3d12.h Normal file
View File

@@ -0,0 +1,217 @@
/*
* Copyright 2016 Józef Kucia for CodeWeavers
* Copyright 2016 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <vkd3d_dxgi1_4.h>
#include <vkd3d_d3dcompiler.h>
#include <stdbool.h>
#include <stdio.h>
struct demo_win32
{
UINT (*GetDpiForSystem)(void);
};
struct demo
{
union
{
struct demo_win32 win32;
} u;
size_t window_count;
void *user_data;
void (*idle_func)(struct demo *demo, void *user_data);
};
struct demo_window
{
struct demo *demo;
void *user_data;
void (*expose_func)(struct demo_window *window, void *user_data);
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data);
};
static inline bool demo_window_init(struct demo_window *window, struct demo *demo, void *user_data)
{
window->demo = demo;
window->user_data = user_data;
window->expose_func = NULL;
window->key_press_func = NULL;
++demo->window_count;
return true;
}
static inline void demo_window_cleanup(struct demo_window *window)
{
--window->demo->window_count;
}
#include "demo_win32.h"
struct demo_swapchain
{
IDXGISwapChain3 *swapchain;
};
static inline void demo_cleanup(struct demo *demo)
{
demo_win32_cleanup(demo);
}
static inline bool demo_init(struct demo *demo, void *user_data)
{
if (!demo_win32_init(&demo->u.win32))
{
fprintf(stderr, "Failed to initialise demo.\n");
return false;
}
demo->window_count = 0;
demo->user_data = user_data;
demo->idle_func = NULL;
return true;
}
static inline void demo_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
{
demo_win32_get_dpi(demo, dpi_x, dpi_y);
}
static inline void demo_process_events(struct demo *demo)
{
demo_win32_process_events(demo);
}
static inline void demo_set_idle_func(struct demo *demo,
void (*idle_func)(struct demo *demo, void *user_data))
{
demo->idle_func = idle_func;
}
static inline void demo_window_destroy(struct demo_window *window)
{
demo_window_win32_destroy(window);
}
static inline struct demo_window *demo_window_create(struct demo *demo, const char *title,
unsigned int width, unsigned int height, void *user_data)
{
return demo_window_win32_create(demo, title, width, height, user_data);
}
static inline void demo_window_set_expose_func(struct demo_window *window,
void (*expose_func)(struct demo_window *window, void *user_data))
{
window->expose_func = expose_func;
}
static inline void demo_window_set_key_press_func(struct demo_window *window,
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data))
{
window->key_press_func = key_press_func;
}
static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *command_queue,
struct demo_window *window, const struct demo_swapchain_desc *desc)
{
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
struct demo_swapchain *swapchain;
IDXGISwapChain1 *swapchain1;
IDXGIFactory2 *factory;
HRESULT hr;
if (!(swapchain = malloc(sizeof(*swapchain))))
return NULL;
if (FAILED(CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&factory)))
goto fail;
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
swapchain_desc.BufferCount = desc->buffer_count;
swapchain_desc.Width = desc->width;
swapchain_desc.Height = desc->height;
swapchain_desc.Format = desc->format;
swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
swapchain_desc.SampleDesc.Count = 1;
hr = IDXGIFactory2_CreateSwapChainForHwnd(factory, (IUnknown *)command_queue,
window_win32->window, &swapchain_desc, NULL, NULL, &swapchain1);
IDXGIFactory2_Release(factory);
if (FAILED(hr))
goto fail;
hr = IDXGISwapChain1_QueryInterface(swapchain1, &IID_IDXGISwapChain3, (void **)&swapchain->swapchain);
IDXGISwapChain1_Release(swapchain1);
if (FAILED(hr))
goto fail;
return swapchain;
fail:
free(swapchain);
return NULL;
}
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
{
return IDXGISwapChain3_GetCurrentBackBufferIndex(swapchain->swapchain);
}
static inline ID3D12Resource *demo_swapchain_get_back_buffer(struct demo_swapchain *swapchain, unsigned int index)
{
ID3D12Resource *buffer;
if (FAILED(IDXGISwapChain3_GetBuffer(swapchain->swapchain, index,
&IID_ID3D12Resource, (void **)&buffer)))
return NULL;
return buffer;
}
static inline void demo_swapchain_present(struct demo_swapchain *swapchain)
{
IDXGISwapChain3_Present(swapchain->swapchain, 1, 0);
}
static inline void demo_swapchain_destroy(struct demo_swapchain *swapchain)
{
IDXGISwapChain3_Release(swapchain->swapchain);
free(swapchain);
}
static inline HANDLE demo_create_event(void)
{
return CreateEventA(NULL, FALSE, FALSE, NULL);
}
static inline unsigned int demo_wait_event(HANDLE event, unsigned int ms)
{
return WaitForSingleObject(event, ms);
}
static inline void demo_destroy_event(HANDLE event)
{
CloseHandle(event);
}

310
demos/demo_macos.h Normal file
View File

@@ -0,0 +1,310 @@
/*
* Copyright 2025 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
typedef long NSInteger;
typedef unsigned long NSUInteger;
typedef struct NSPoint
{
double x, y;
} NSPoint;
typedef struct NSRect
{
double x, y;
double w, h;
} NSRect;
#define BOOL OBJC_BOOL
#include "private/appkit.h"
#include "private/foundation.h"
#include "private/quartzcore.h"
#undef BOOL
extern const id NSDefaultRunLoopMode;
enum NSBackingStoreType
{
NSBackingStoreBuffered = 2,
};
enum NSEventType
{
NSEventTypeKeyDown = 0xa,
NSEventTypeApplicationDefined = 0xf,
};
enum NSWindowStyleMask
{
NSWindowStyleMaskBorderless = 0x0000,
NSWindowStyleMaskTitled = 0x0001,
NSWindowStyleMaskClosable = 0x0002,
NSWindowStyleMaskMiniaturizable = 0x0004,
NSWindowStyleMaskResizable = 0x0008,
NSWindowStyleMaskUtilityWindow = 0x0010,
NSWindowStyleMaskDocModalWindow = 0x0040,
NSWindowStyleMaskNonactivatingPanel = 0x0080,
NSWindowStyleMaskUnifiedTitleAndToolbar = 0x1000,
NSWindowStyleMaskHUDWindow = 0x2000,
NSWindowStyleMaskFullScreen = 0x4000,
NSWindowStyleMaskFullSizeContentView = 0x8000,
};
enum
{
DemoWindowDestroyed,
};
struct demo_window_macos
{
struct demo_window w;
id window;
id layer;
};
static struct demo_window_macos *demo_macos_find_macos_window(struct demo *demo, id window)
{
size_t i;
for (i = 0; i < demo->window_count; ++i)
{
struct demo_window_macos *window_macos = CONTAINING_RECORD(demo->windows[i], struct demo_window_macos, w);
if (window_macos->window == window)
return window_macos;
}
return NULL;
}
static VkSurfaceKHR demo_window_macos_create_vk_surface(struct demo_window *window, VkInstance vk_instance)
{
struct demo_window_macos *window_macos = CONTAINING_RECORD(window, struct demo_window_macos, w);
struct VkMetalSurfaceCreateInfoEXT surface_desc;
VkSurfaceKHR vk_surface;
id l, v;
l = window_macos->layer = CAMetalLayer_layer();
CAMetalLayer_setContentsScale(l, NSScreen_backingScaleFactor(NSScreen_mainScreen()));
v = NSWindow_contentView(window_macos->window);
NSView_setLayer(v, l);
NSView_setWantsLayer(v, true);
surface_desc.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
surface_desc.pNext = NULL;
surface_desc.flags = 0;
surface_desc.pLayer = l;
if (vkCreateMetalSurfaceEXT(vk_instance, &surface_desc, NULL, &vk_surface) < 0)
return VK_NULL_HANDLE;
return vk_surface;
}
static void demo_window_macos_destroy(struct demo_window *window)
{
struct demo_window_macos *window_macos = CONTAINING_RECORD(window, struct demo_window_macos, w);
NSWindow_close(window_macos->window);
}
static void demo_window_macos_destroyed(struct demo_window_macos *window_macos)
{
CAMetalLayer_release(window_macos->layer);
NSWindow_release(window_macos->window);
demo_window_cleanup(&window_macos->w);
free(window_macos);
}
static struct demo_window *demo_window_macos_create(struct demo *demo,
const char *title, unsigned int width, unsigned int height, void *user_data)
{
unsigned long style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable;
struct demo_window_macos *window_macos;
NSRect r = {0, 0, width, height};
double scale;
id w, s;
if (!(window_macos = malloc(sizeof(*window_macos))))
return NULL;
if (!demo_window_init(&window_macos->w, demo, user_data,
demo_window_macos_create_vk_surface, demo_window_macos_destroy))
{
free(window_macos);
return NULL;
}
s = NSScreen_mainScreen();
scale = NSScreen_backingScaleFactor(s);
r.w /= scale;
r.h /= scale;
w = window_macos->window = class_createInstance(objc_getClass("DemoWindow"), 0);
NSWindow_initWithContentRect(w, r, style, NSBackingStoreBuffered, true, s);
NSWindow_setReleasedWhenClosed(w, false);
NSWindow_setDelegate(w, w);
NSWindow_center(w);
NSWindow_setTitle(w, NSString_stringWithUTF8String(title));
NSWindow_makeKeyAndOrderFront(w, nil);
window_macos->layer = nil;
return &window_macos->w;
}
static void demo_macos_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
{
*dpi_x = *dpi_y = 96.0 * NSScreen_backingScaleFactor(NSScreen_mainScreen());
}
static demo_key demo_key_from_nsevent(id event)
{
enum vkey
{
kVK_ANSI_A = 0x00,
kVK_Escape = 0x35,
kVK_LeftArrow = 0x7b,
kVK_RightArrow = 0x7c,
kVK_DownArrow = 0x7d,
kVK_UpArrow = 0x7e,
} vkey;
size_t i;
static const struct
{
enum vkey vkey;
demo_key demo_key;
}
lookup[] =
{
{kVK_ANSI_A, 'a'},
{kVK_Escape, DEMO_KEY_ESCAPE},
{kVK_LeftArrow, DEMO_KEY_LEFT},
{kVK_RightArrow, DEMO_KEY_RIGHT},
{kVK_UpArrow, DEMO_KEY_UP},
{kVK_DownArrow, DEMO_KEY_DOWN},
};
vkey = NSEvent_keyCode(event);
for (i = 0; i < ARRAY_SIZE(lookup); ++i)
{
if (lookup[i].vkey == vkey)
return lookup[i].demo_key;
}
return DEMO_KEY_UNKNOWN;
}
static void demo_macos_process_events(struct demo *demo)
{
struct demo_window_macos *window_macos;
struct demo_window *window;
id a, event;
size_t i;
for (i = 0; i < demo->window_count; ++i)
{
if ((window = demo->windows[i])->expose_func)
window->expose_func(window, window->user_data);
}
a = NSApplication_sharedApplication();
while (demo->window_count)
{
if (!demo->idle_func)
{
if (!(event = NSApplication_nextEventMatchingMask(a, ~(uint64_t)0,
NSDate_distantFuture(), NSDefaultRunLoopMode, true)))
break;
}
else if (!(event = NSApplication_nextEventMatchingMask(a, ~(uint64_t)0, nil, NSDefaultRunLoopMode, true)))
{
demo->idle_func(demo, demo->user_data);
continue;
}
switch (NSEvent_type(event))
{
case NSEventTypeKeyDown:
if (NSMenu_performKeyEquivalent(NSApplication_mainMenu(a), event))
continue;
if (!(window_macos = demo_macos_find_macos_window(demo, NSEvent_window(event)))
|| !window_macos->w.key_press_func)
break;
window_macos->w.key_press_func(&window_macos->w,
demo_key_from_nsevent(event), window_macos->w.user_data);
continue;
case NSEventTypeApplicationDefined:
if (NSEvent_subtype(event) != DemoWindowDestroyed
|| !(window_macos = demo_macos_find_macos_window(demo, NSEvent_window(event))))
break;
demo_window_macos_destroyed(window_macos);
continue;
}
NSApplication_sendEvent(a, event);
}
}
static void DemoWindow_windowWillClose(id window, SEL sel, id notification)
{
id event;
event = NSEvent_otherEventWithType(NSEventTypeApplicationDefined, (NSPoint){0.0, 0.0},
0, 0.0, NSWindow_windowNumber(window), nil, DemoWindowDestroyed, 0, 0);
NSApplication_postEvent(NSApplication_sharedApplication(), event, true);
}
static void demo_macos_cleanup(struct demo *demo)
{
}
static bool demo_macos_init(struct demo_macos *macos)
{
id application, item, menu, submenu;
Class c;
if ((c = objc_allocateClassPair(objc_getClass("NSWindow"), "DemoWindow", 0)))
{
class_addMethod(c, sel_registerName("windowWillClose:"), (IMP)DemoWindow_windowWillClose, "v@:@");
objc_registerClassPair(c);
}
application = NSApplication_sharedApplication();
NSApplication_setActivationPolicy(application, 0);
menu = NSMenu_new();
submenu = NSMenu_new();
NSMenu_addItemWithTitle(submenu, NSString_stringWithUTF8String("Quit"),
sel_registerName("terminate:"), NSString_stringWithUTF8String("q"));
item = NSMenuItem_new();
NSMenuItem_setSubmenu(item, submenu);
NSMenu_release(submenu);
NSMenu_addItem(menu, item);
NSMenuItem_release(item);
NSApplication_setMainMenu(application, menu);
NSMenu_release(menu);
NSApplication_finishLaunching(application);
return true;
}

617
demos/demo_vkd3d.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -17,85 +17,108 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <vkd3d_dxgi1_4.h>
#include <vkd3d_d3dcompiler.h>
#include <stdbool.h>
#include <stdio.h>
#define DEMO_WIN32_WINDOW_CLASS_NAME L"demo_wc"
#define DEMO_WINDOW_CLASS_NAME L"demo_wc"
struct demo
struct demo_window_win32
{
size_t window_count;
bool quit;
struct demo_window w;
void *user_data;
void (*idle_func)(struct demo *demo, void *user_data);
};
struct demo_window
{
HINSTANCE instance;
HWND hwnd;
struct demo *demo;
void *user_data;
void (*expose_func)(struct demo_window *window, void *user_data);
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data);
HWND window;
};
struct demo_swapchain
#ifndef VKD3D_CROSSTEST
static VkSurfaceKHR demo_window_win32_create_vk_surface(struct demo_window *window, VkInstance vk_instance)
{
IDXGISwapChain3 *swapchain;
};
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
struct VkWin32SurfaceCreateInfoKHR surface_desc;
VkSurfaceKHR vk_surface;
static inline struct demo_window *demo_window_create(struct demo *demo, const char *title,
surface_desc.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
surface_desc.pNext = NULL;
surface_desc.flags = 0;
surface_desc.hinstance = window_win32->instance;
surface_desc.hwnd = window_win32->window;
if (vkCreateWin32SurfaceKHR(vk_instance, &surface_desc, NULL, &vk_surface) < 0)
return VK_NULL_HANDLE;
return vk_surface;
}
#endif
static void demo_window_win32_destroy(struct demo_window *window)
{
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
DestroyWindow(window_win32->window);
}
static void demo_window_win32_destroyed(struct demo_window *window)
{
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
demo_window_cleanup(&window_win32->w);
free(window_win32);
}
static struct demo_window *demo_window_win32_create(struct demo *demo, const char *title,
unsigned int width, unsigned int height, void *user_data)
{
struct demo_window_win32 *window_win32;
RECT rect = {0, 0, width, height};
struct demo_window *window;
int title_size;
WCHAR *title_w;
DWORD style;
if (!(window = malloc(sizeof(*window))))
if (!(window_win32 = malloc(sizeof(*window_win32))))
return NULL;
#ifdef VKD3D_CROSSTEST
if (!demo_window_init(&window_win32->w, demo, user_data))
#else
if (!demo_window_init(&window_win32->w, demo, user_data,
demo_window_win32_create_vk_surface, demo_window_win32_destroy))
#endif
{
free(window_win32);
return NULL;
}
title_size = MultiByteToWideChar(CP_UTF8, 0, title, -1, NULL, 0);
if (!(title_w = calloc(title_size, sizeof(*title_w))))
{
free(window);
demo_window_cleanup(&window_win32->w);
free(window_win32);
return NULL;
}
MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w, title_size);
window->instance = GetModuleHandle(NULL);
window->user_data = user_data;
window->expose_func = NULL;
window->key_press_func = NULL;
window_win32->instance = GetModuleHandle(NULL);
style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE;
AdjustWindowRect(&rect, style, FALSE);
window->hwnd = CreateWindowExW(0, DEMO_WINDOW_CLASS_NAME, title_w, style, CW_USEDEFAULT, CW_USEDEFAULT,
rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, window->instance, NULL);
window_win32->window = CreateWindowExW(0, DEMO_WIN32_WINDOW_CLASS_NAME, title_w, style, CW_USEDEFAULT,
CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, window_win32->instance, NULL);
free(title_w);
if (!window->hwnd)
if (!window_win32->window)
{
free(window);
demo_window_cleanup(&window_win32->w);
free(window_win32);
return NULL;
}
SetWindowLongPtrW(window->hwnd, GWLP_USERDATA, (LONG_PTR)window);
window->demo = demo;
++demo->window_count;
SetWindowLongPtrW(window_win32->window, GWLP_USERDATA, (LONG_PTR)window_win32);
return window;
return &window_win32->w;
}
static inline void demo_window_destroy(struct demo_window *window)
static void demo_win32_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
{
DestroyWindow(window->hwnd);
struct demo_win32 *win32 = &demo->u.win32;
*dpi_x = *dpi_y = win32->GetDpiForSystem();
}
static inline demo_key demo_key_from_vkey(DWORD vkey)
static demo_key demo_key_from_win32_vkey(DWORD vkey)
{
static const struct
{
@@ -126,46 +149,33 @@ static inline demo_key demo_key_from_vkey(DWORD vkey)
return DEMO_KEY_UNKNOWN;
}
static inline LRESULT CALLBACK demo_window_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
static LRESULT CALLBACK demo_win32_window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
struct demo_window *window = (void *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
struct demo_window_win32 *window_win32 = (void *)GetWindowLongPtrW(window, GWLP_USERDATA);
switch (message)
{
case WM_PAINT:
if (window && window->expose_func)
window->expose_func(window, window->user_data);
if (window_win32 && window_win32->w.expose_func)
window_win32->w.expose_func(&window_win32->w, window_win32->w.user_data);
return 0;
case WM_KEYDOWN:
if (!window->key_press_func)
if (!window_win32->w.key_press_func)
break;
window->key_press_func(window, demo_key_from_vkey(wparam), window->user_data);
window_win32->w.key_press_func(&window_win32->w,
demo_key_from_win32_vkey(wparam), window_win32->w.user_data);
return 0;
case WM_DESTROY:
if (!--window->demo->window_count)
window->demo->quit = true;
free(window);
demo_window_win32_destroyed(&window_win32->w);
return 0;
}
return DefWindowProcW(hwnd, message, wparam, lparam);
return DefWindowProcW(window, message, wparam, lparam);
}
static inline void demo_window_set_key_press_func(struct demo_window *window,
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data))
{
window->key_press_func = key_press_func;
}
static inline void demo_window_set_expose_func(struct demo_window *window,
void (*expose_func)(struct demo_window *window, void *user_data))
{
window->expose_func = expose_func;
}
static inline void demo_process_events(struct demo *demo)
static void demo_win32_process_events(struct demo *demo)
{
MSG msg = {0};
@@ -186,18 +196,28 @@ static inline void demo_process_events(struct demo *demo)
break;
TranslateMessage(&msg);
DispatchMessageW(&msg);
if (demo->quit)
if (!demo->window_count)
PostQuitMessage(0);
}
}
static inline bool demo_init(struct demo *demo, void *user_data)
static void demo_win32_cleanup(struct demo *demo)
{
UnregisterClassW(DEMO_WIN32_WINDOW_CLASS_NAME, GetModuleHandle(NULL));
}
static inline UINT demo_win32_GetDpiForSystem(void)
{
return 96;
}
static bool demo_win32_init(struct demo_win32 *win32)
{
WNDCLASSEXW wc;
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = demo_window_proc;
wc.lpfnWndProc = demo_win32_window_proc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL);
@@ -205,110 +225,15 @@ static inline bool demo_init(struct demo *demo, void *user_data)
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = DEMO_WINDOW_CLASS_NAME;
wc.lpszClassName = DEMO_WIN32_WINDOW_CLASS_NAME;
wc.hIconSm = LoadIconW(NULL, IDI_WINLOGO);
if (!RegisterClassExW(&wc))
return false;
demo->window_count = 0;
demo->quit = false;
demo->user_data = user_data;
demo->idle_func = NULL;
if ((win32->GetDpiForSystem = (void *)GetProcAddress(GetModuleHandleA("user32"), "GetDpiForSystem")))
SetProcessDPIAware();
else
win32->GetDpiForSystem = demo_win32_GetDpiForSystem;
return true;
}
static inline void demo_cleanup(struct demo *demo)
{
UnregisterClassW(DEMO_WINDOW_CLASS_NAME, GetModuleHandle(NULL));
}
static inline void demo_set_idle_func(struct demo *demo,
void (*idle_func)(struct demo *demo, void *user_data))
{
demo->idle_func = idle_func;
}
static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *command_queue,
struct demo_window *window, const struct demo_swapchain_desc *desc)
{
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
struct demo_swapchain *swapchain;
IDXGISwapChain1 *swapchain1;
IDXGIFactory2 *factory;
HRESULT hr;
if (!(swapchain = malloc(sizeof(*swapchain))))
return NULL;
if (FAILED(CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&factory)))
goto fail;
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
swapchain_desc.BufferCount = desc->buffer_count;
swapchain_desc.Width = desc->width;
swapchain_desc.Height = desc->height;
swapchain_desc.Format = desc->format;
swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
swapchain_desc.SampleDesc.Count = 1;
hr = IDXGIFactory2_CreateSwapChainForHwnd(factory, (IUnknown *)command_queue,
window->hwnd, &swapchain_desc, NULL, NULL, &swapchain1);
IDXGIFactory2_Release(factory);
if (FAILED(hr))
goto fail;
hr = IDXGISwapChain1_QueryInterface(swapchain1, &IID_IDXGISwapChain3, (void **)&swapchain->swapchain);
IDXGISwapChain1_Release(swapchain1);
if (FAILED(hr))
goto fail;
return swapchain;
fail:
free(swapchain);
return NULL;
}
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
{
return IDXGISwapChain3_GetCurrentBackBufferIndex(swapchain->swapchain);
}
static inline ID3D12Resource *demo_swapchain_get_back_buffer(struct demo_swapchain *swapchain, unsigned int index)
{
ID3D12Resource *buffer;
if (FAILED(IDXGISwapChain3_GetBuffer(swapchain->swapchain, index,
&IID_ID3D12Resource, (void **)&buffer)))
return NULL;
return buffer;
}
static inline void demo_swapchain_present(struct demo_swapchain *swapchain)
{
IDXGISwapChain3_Present(swapchain->swapchain, 1, 0);
}
static inline void demo_swapchain_destroy(struct demo_swapchain *swapchain)
{
IDXGISwapChain3_Release(swapchain->swapchain);
free(swapchain);
}
static inline HANDLE demo_create_event(void)
{
return CreateEventA(NULL, FALSE, FALSE, NULL);
}
static inline unsigned int demo_wait_event(HANDLE event, unsigned int ms)
{
return WaitForSingleObject(event, ms);
}
static inline void demo_destroy_event(HANDLE event)
{
CloseHandle(event);
}

File diff suppressed because it is too large Load Diff

View File

@@ -849,12 +849,16 @@ static int cxg_main(void)
{
unsigned int width = 300, height = 300;
struct cx_gears cxg;
double dpi_x, dpi_y;
memset(&cxg, 0, sizeof(cxg));
if (!demo_init(&cxg.demo, &cxg))
return EXIT_FAILURE;
demo_set_idle_func(&cxg.demo, cxg_idle);
demo_get_dpi(&cxg.demo, &dpi_x, &dpi_y);
width *= dpi_x / 96.0;
height *= dpi_y / 96.0;
cxg.window = demo_window_create(&cxg.demo, "Vkd3d Gears", width, height, &cxg);
demo_window_set_key_press_func(cxg.window, cxg_key_press);
demo_window_set_expose_func(cxg.window, cxg_expose);

View File

@@ -1,3 +1,21 @@
/*
* Copyright 2016 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
cbuffer gear_block : register(b0)
{
float4x4 mvp_matrix;

151
demos/make_objc Executable file
View File

@@ -0,0 +1,151 @@
#!/usr/bin/perl -w
#
# Copyright 2025 Henri Verbeet
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use strict;
use warnings;
use JSON;
use open ':utf8';
binmode STDOUT, ':utf8';
sub method_name($)
{
shift->{selector} =~ s/(:.*)//r;
}
sub method_parameters($$)
{
my ($method, $method_type) = @_;
my $parameters = join ", ", $method_type eq "class" ? () : "id self",
map {"$_->{type} $_->{name}"} @{$method->{parameters}};
length $parameters ? $parameters : "void";
}
sub send_function($)
{
shift->{'return-float'} ? "vkd3d_objc_msgSend_fpret" : "objc_msgSend";
}
sub invocation_type($$)
{
my ($method, $method_type) = @_;
"$method->{'return-type'} (*)(" . join(", ", $method_type eq "class" ? "Class" : "id", "SEL",
map {$_->{type}} @{$method->{parameters}}) . ")";
}
sub invocation_parameters($$$)
{
my ($method, $interface_name, $method_type) = @_;
join ", ", $method_type eq "class" ? "objc_getClass(\"$interface_name\")" : "self",
"sel_registerName(\"$method->{selector}\")", map {$_->{name}} @{$method->{parameters}};
}
sub invocation($$$)
{
my ($method, $interface_name, $method_type) = @_;
($method->{'return-type'} eq "void" ? "" : "return ")
. "((${\invocation_type $method, $method_type})f)"
. "(${\invocation_parameters $method, $interface_name, $method_type});";
}
sub print_method($$$)
{
my ($method, $interface_name, $method_type) = @_;
print "static inline $method->{'return-type'} "
. "${interface_name}_${\method_name $method}(${\method_parameters $method, $method_type})\n";
print "{\n";
print " void *f = ${\send_function $method};\n";
print " ${\invocation $method, $interface_name, $method_type}\n";
print "}\n\n";
}
sub print_property($$)
{
my ($property, $interface_name) = @_;
my $method =
{
'return-type' => $property->{type},
'return-float' => $property->{float},
selector => $property->{getter} // $property->{name},
};
my $method_type = $property->{class} ? "class" : "instance";
print_method $method, $interface_name, $method_type;
if (!$property->{readonly})
{
$method->{'return-type'} = "void";
$method->{'return-float'} = 0;
$method->{selector} = "set${\ucfirst $property->{name}}:";
$method->{parameters} = [$property];
print_method $method, $interface_name, $method_type;
}
}
sub print_interface(_)
{
my ($interface) = @_;
print_method $_, $interface->{name}, "class" foreach (@{$interface->{'class-methods'}});
print_method $_, $interface->{name}, "instance" foreach (@{$interface->{'instance-methods'}});
print_property $_, $interface->{name} foreach (@{$interface->{properties}});
}
sub print_header($)
{
my ($grammar) = @_;
my $guard = "__VKD3D_${\uc $grammar->{name}}_H__";
print "/*\n";
print " * This file is automatically generated.\n";
print " * The original source is covered by the following license:\n";
print " *\n";
print map {" * $_" =~ s/ +$//r . "\n"} @{$grammar->{copyright}};
print " */\n\n";
print "#ifndef $guard\n";
print "#define $guard\n\n";
print "#include <objc/objc-runtime.h>\n\n";
print "#ifdef __arm64__\n";
print "# define vkd3d_objc_msgSend_fpret objc_msgSend\n";
print "#else\n";
print "# define vkd3d_objc_msgSend_fpret objc_msgSend_fpret\n";
print "#endif /* __arm64__ */\n\n";
print_interface foreach (@{$grammar->{interfaces}});
print "#undef vkd3d_objc_msgSend_fpret\n\n";
print "#endif /* $guard */\n";
}
die "No input file specified.\n" unless @ARGV;
print_header do
{
local $/;
open my $fh, '<', $ARGV[0] or die $!;
decode_json <$fh>;
};

View File

@@ -368,12 +368,16 @@ static int cxt_main(void)
{
unsigned int width = 640, height = 480;
struct cx_triangle cxt;
double dpi_x, dpi_y;
memset(&cxt, 0, sizeof(cxt));
if (!demo_init(&cxt.demo, NULL))
return EXIT_FAILURE;
demo_get_dpi(&cxt.demo, &dpi_x, &dpi_y);
width *= dpi_x / 96.0;
height *= dpi_y / 96.0;
cxt.window = demo_window_create(&cxt.demo, "Vkd3d Triangle", width, height, &cxt);
demo_window_set_expose_func(cxt.window, cxt_render_frame);
demo_window_set_key_press_func(cxt.window, cxt_key_press);

View File

@@ -1,3 +1,46 @@
/*
* Copyright 2016 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* This application contains code derived from Microsoft's "HelloTriangle"
* demo, the license for which follows:
*
* Copyright (c) 2015 Microsoft
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
struct ps_in
{
float4 position : SV_POSITION;

View File

@@ -12,7 +12,7 @@ mkdir build
cd build
export LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH-}"
if ../configure --enable-demos --with-spirv-tools DXCOMPILER_LIBS="-L/usr/local/lib" CFLAGS="-g -O2 -Werror" \
CPPFLAGS="-DVKD3D_SHADER_UNSUPPORTED_DXIL -DVKD3D_SHADER_UNSUPPORTED_GLSL -DVKD3D_ABORT_ON_ERR" && \
CPPFLAGS="-DVKD3D_SHADER_UNSUPPORTED_GLSL -DVKD3D_ABORT_ON_ERR" && \
make -j$(nproc) ; then
make -j$(nproc) AM_COLOR_TESTS=always check || \
touch ../tests_failed

View File

@@ -10,10 +10,12 @@ set -Eeuxo pipefail
rm -fr build
mkdir build
cd build
if ../configure CFLAGS="-I/opt/homebrew/opt/vulkan-headers/include -I/opt/homebrew/opt/spirv-headers/include -g -O2 -Wno-implicit-fallthrough -Wno-ignored-attributes -Wno-unknown-attributes -Wno-unused-but-set-variable -Werror" \
if ../configure CFLAGS="-I/opt/homebrew/opt/vulkan-headers/include -I/opt/homebrew/opt/spirv-headers/include -g -O2 -Wno-implicit-fallthrough -Wno-ignored-attributes -Wno-unknown-attributes -Wno-unused-but-set-variable -Wno-unused-command-line-argument -Werror" \
OBJCFLAGS="-g -O2 -Wno-unknown-attributes -Wno-ignored-attributes -Werror" \
CPPFLAGS="-DVKD3D_ABORT_ON_ERR -DVKD3D_SHADER_UNSUPPORTED_DXIL -DVKD3D_SHADER_UNSUPPORTED_MSL" \
VULKAN_LIBS=-L/opt/homebrew/opt/vulkan-loader/lib --with-spirv-tools && \
CPPFLAGS="-DVKD3D_ABORT_ON_ERR -DVKD3D_SHADER_UNSUPPORTED_MSL" \
VULKAN_LIBS=-L/opt/homebrew/opt/vulkan-loader/lib \
--with-spirv-tools \
--enable-demos && \
make -j$(sysctl -n hw.ncpu) ; then
make -j$(sysctl -n hw.ncpu) AM_COLOR_TESTS=always check || \
touch ../tests_failed

View File

@@ -32,6 +32,7 @@ build-radv-64:
variables:
VK_LOADER_DRIVERS_SELECT: 'radeon_*'
VKD3D_SHADER_CONFIG: 'force_validation'
VKD3D_TEST_DEBUG: '1'
build-llvmpipe-64:
extends: .build-linux
@@ -41,6 +42,7 @@ build-llvmpipe-64:
variables:
VK_LOADER_DRIVERS_SELECT: 'lvp_*'
VKD3D_SHADER_CONFIG: 'force_validation'
VKD3D_TEST_DEBUG: '1'
build-radv-32:
extends: .build-linux
@@ -50,6 +52,7 @@ build-radv-32:
VK_LOADER_DRIVERS_SELECT: 'radeon_*'
CC: 'i686-linux-gnu-gcc'
VKD3D_SHADER_CONFIG: 'force_validation'
VKD3D_TEST_DEBUG: '1'
build-llvmpipe-32:
extends: .build-linux
@@ -60,6 +63,7 @@ build-llvmpipe-32:
VK_LOADER_DRIVERS_SELECT: 'lvp_*'
CC: 'i686-linux-gnu-gcc'
VKD3D_SHADER_CONFIG: 'force_validation'
VKD3D_TEST_DEBUG: '1'
build-llvmpipe-64-mesa24:
extends: .build-linux
@@ -68,6 +72,7 @@ build-llvmpipe-64-mesa24:
LD_LIBRARY_PATH: '/opt/mesa24/lib/x86_64-linux-gnu'
__EGL_VENDOR_LIBRARY_FILENAMES: '/opt/mesa24/share/glvnd/egl_vendor.d/50_mesa.json'
VKD3D_SHADER_CONFIG: 'force_validation'
VKD3D_TEST_DEBUG: '1'
build-crosstest:
stage: build
@@ -135,7 +140,6 @@ build-mac:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
image: winehq-sonoma-pristine
allow_failure: true
interruptible: true
needs:
- job: image-mac
@@ -154,7 +158,8 @@ build-mac:
- mkdir artifacts
- export PATH="/opt/homebrew/opt/bison/bin:/opt/homebrew/opt/flex/bin:$PATH"
- export VK_DRIVER_FILES="$PWD/image/moltenvk/MoltenVK_icd.json"
- export SONAME_LIBDXCOMPILER="$PWD/image/dxc/libdxcompiler.dylib"
# Currently disabled because it has too many failures
#- export SONAME_LIBDXCOMPILER="$PWD/image/dxc/libdxcompiler.dylib"
- system_profiler SPSoftwareDataType SPHardwareDataType > artifacts/systeminfo.txt
- vulkaninfo > artifacts/vulkaninfo.txt
- git rebase $CI_MERGE_REQUEST_DIFF_BASE_SHA --exec ./gitlab/build-mac
@@ -163,6 +168,7 @@ build-mac:
variables:
VKD3D_DISABLE_EXTENSIONS: "VK_EXT_descriptor_indexing"
VKD3D_SHADER_CONFIG: 'force_validation'
VKD3D_TEST_DEBUG: '1'
MVK_CONFIG_LOG_LEVEL: 2
SONAME_LIBVULKAN: "/opt/homebrew/opt/vulkan-loader/lib/libvulkan.1.dylib"
WIDL: "x86_64-w64-mingw32-widl"

View File

@@ -27,14 +27,14 @@ RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y build-essential pkg-config gcc-mingw-w64 crossbuild-essential-i386 \
autoconf automake libtool flex bison curl \
mingw-w64-tools autoconf automake libtool flex bison curl \
git ca-certificates rsync \
llvm-15-dev meson ninja-build python3-mako \
zlib1g-dev libexpat-dev libdrm-dev libglvnd-dev \
doxygen doxygen-latex graphviz \
mesa-vulkan-drivers mesa-vulkan-drivers:i386 \
vulkan-tools spirv-headers \
libegl-dev libegl-dev:i386 \
libegl-dev libegl-dev:i386 libjson-perl libjson-xs-perl \
libvulkan-dev libvulkan-dev:i386 \
libncurses-dev libncurses-dev:i386 \
libopengl-dev libopengl-dev:i386 \
@@ -89,7 +89,7 @@ RUN export DEBIAN_FRONTEND=noninteractive; \
rm -fr mesa && \
apt-get clean && \
curl -L -s https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.8.2407/linux_dxc_2024_07_31.x86_64.tar.gz | tar zx -C /usr/local ./lib/libdxcompiler.so ./lib/libdxil.so && \
curl -L -s https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.8.2502/linux_dxc_2025_02_20.x86_64.tar.gz | tar zx -C /usr/local ./lib/libdxcompiler.so ./lib/libdxil.so && \
groupadd host-render -g 800 && \
useradd -m gitlab -G host-render

Some files were not shown because too many files have changed in this diff Show More