Compare commits

...

2171 Commits

Author SHA1 Message Date
Joshua Ashton d00d035321 ci: Use arch-mingw-github-action v8
Fixes safe directory stuff giving invalid version info.
2022-07-26 18:37:26 +00:00
Joshua Ashton 253dc9027a Revert "ci: Workaround safe directory errors in vkd3d_build generation."
This reverts commit 0c4df9b32c.
2022-07-26 18:37:26 +00:00
Derek Lesho 146f5b8a74 vkd3d: Fall back to regular fences when shared timeline semaphores aren't supported.
Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-25 23:55:40 +02:00
Hans-Kristian Arntzen db4a8544a1 tests: Avoid potential UB in fence_wait robustness test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-25 23:11:37 +02:00
Hans-Kristian Arntzen 1d25b29413 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-25 21:55:45 +02:00
Hans-Kristian Arntzen 34a04a1a7f dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-25 18:39:06 +02:00
Hans-Kristian Arntzen b839fe14bb tests: Add test for freeing underlying memory of a reserved resource.
As long as the reserved regions are not used, this is okay.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-25 18:10:08 +02:00
Hans-Kristian Arntzen d3a76eee90 idl: Fix const correctness of UpdateTileMappings.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-25 18:10:08 +02:00
Hans-Kristian Arntzen 481680ecd8 vkd3d: Use IndexFormat as a sentinel for indexed RTAS build.
UE5 seems to only set IndexType to != UNKNOWN when querying RTAS sizes.
This contradicts D3D12 docs, but this matches Vulkan behavior, so do the
same thing. Adds a warn when IBO VA is NULL with non-null format to catch app
bugs.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-25 17:51:02 +02:00
Hans-Kristian Arntzen 11c82c84d1 vkd3d: Add some trace debug logs of RTAS build infos.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-25 17:51:02 +02:00
Hans-Kristian Arntzen c0b9682c69 vkd3d: Small warning fixes.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-25 17:09:07 +02:00
Hans-Kristian Arntzen 9d8abd2db5 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-25 11:32:58 +02:00
Derek Lesho df1829e407 vkd3d: Implement ID3D12Fence sharing on top of D3D12-Fence exportable Vulkan timeline semaphores.
Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-25 11:16:53 +02:00
Hans-Kristian Arntzen be2aafff1a vkd3d: Resolve fence waiters early.
Temporarily abandons the idea to fuse waiters with execution.
For whatever reason, this seemed to cause random flicker in Halo Infinite
with async compute on, and I have failed to figure out exactly why.
By playing around with how commands are fused, the results changed
dramatically, which means I doubt vkd3d-proton was actually at fault
here.

There is some questionable code around UpdateTileMappings in the game
where a COPY queue is used, and it does not seem to synchronize this with other
queues as far as I can tell. It is uncertain at this time if D3D12
requires a tile update to synchronize with *every* queue or just the
queue being submitted to. We assume the latter, as it's the only
behavior that makes sense.

It is possible that submitting waits as they are queued up
affects synchronization between queues in unexpected ways.

When separating out the wait operations, everything appears to work.
It is also simpler code.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-21 21:10:34 +02:00
Derek Lesho 849537614a vkd3d: HACK: Don't create host pointer heap for Halo Infinite.
Some usage pattern here is causing a failure inside amdgpu.

Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-21 20:48:56 +02:00
Derek Lesho f487db4756 vkd3d: Implement ID3D12Resource sharing.
Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-21 20:48:56 +02:00
Hans-Kristian Arntzen 6265a7b5ce tests: Add test creating root signature without RTS0 blob.
We're supposed to fail here, but we ended up failing
due to parsing uninitialized version instead, meaning
it could spuriously succeed or read garbage.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-20 12:00:07 +02:00
Hans-Kristian Arntzen 4f4c96bb11 vkd3d: Fail creating root signatures from blobs without RTS0.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-20 12:00:07 +02:00
Derek Lesho a2439e766f vkd3d: Flush queued waiters before waiting for the sparse binding semaphore.
Fixes a bug in the logic trying to combine the waits by simplifying the code.
Problem discovered by HK.

Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-20 01:27:20 +02:00
Hans-Kristian Arntzen 21799b202b tests: Add test verifying private ref behavior of ID3D12Fence.
Attempt to release fences before their signal/waits have been satisfied.
Also tests this behavior for shared fences.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-18 19:00:25 +02:00
Hans-Kristian Arntzen 4ff504b52d vkd3d: Match native runtime better in command allocator reset.
Even when misusing the API, S_OK is still returned on native runtimes.
Keep the error log, and add an error report to command allocator release
if there are still pending submissions.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-18 19:00:25 +02:00
Hans-Kristian Arntzen 6335e411bb vkd3d: Rewrite submission logic for wait fences.
D3D12 has some unfortunate rules around CommandQueue::Wait().
It's legal to release the fence early, before the fence actually
completes its wait operation.

The behavior on D3D12 is just to release all waiters.
For out of order signal/wait, we hold off submissions,
so we can implement this implicitly through CPU signal to UINT64_MAX
on fence release. If we have submitted a wait which depends on the
fence, it will complete in finite time, so it still works fine.

We cannot release the semaphores early in Vulkan, so we must hold on
to a private reference of the ID3D12Fence object until we have observed
that the wait is complete.

To make this work, we refactor waits to use the vkd3d_queue wait list.
On other submits, we resolve the wait. This is a small optimization
since we don't have to perform dummy submits that only performs the wait.
At that time, we signal a timeline semaphore and queue up a d3d12_fence_dec_ref().

Since we're also adding this system where normal submissions signal
timelines, handle the submission counters more correctly by deferring
the decrements until we have waited for the submission itself.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-18 19:00:25 +02:00
Hans-Kristian Arntzen 11c943dd7e vkd3d: Unblock all fence waiters when public ref-count hits 0.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-18 19:00:25 +02:00
Hans-Kristian Arntzen 5b73139f18 vkd3d: Fail creation of command signature if DGC is not supported.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-12 14:31:53 +02:00
Hans-Kristian Arntzen 73700f4c3a tests: Be robust against missing features when testing indirect state.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-12 14:31:53 +02:00
Hans-Kristian Arntzen a917d60ca5 profiler: Add --delta to profile helper tool.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:59:41 +02:00
Hans-Kristian Arntzen 8d780458f1 profiler: Use rdtsc instead of QPC.
Runs much faster and we don't really need accurate ns readings.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:59:41 +02:00
Hans-Kristian Arntzen 8da6ca6772 common: Add rdtsc helper.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:59:41 +02:00
Hans-Kristian Arntzen 766da69afb vkd3d: Also add profiles for RE3/RE7.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:58:21 +02:00
Hans-Kristian Arntzen b7a960f94f vkd3d: Also add RE workaround for RE2 DXR.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:58:21 +02:00
Hans-Kristian Arntzen ee39209798 vkd3d: Add flag to force native FP16 paths.
Apparently RT shaders in RE Engine require min16float to
be implemented as native FP16. Fun ... ._.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:58:21 +02:00
Hans-Kristian Arntzen afb87e013f vkd3d: Add per-application feature overrides.
With DXR, it seems like some applications require other FL 12.2 features
to be enabled even if they are not actually used. Various RE engine
titles seem to be affected by this.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:58:21 +02:00
Hans-Kristian Arntzen 433262c254 tests: Add headless D3D12 RenderDoc capture support.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:34:14 +02:00
Hans-Kristian Arntzen 277bbe35e8 tests: Test both aligned and "unaligned" argument buffer offsets.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:31:30 +02:00
Hans-Kristian Arntzen 9451fdcab9 tests: Add large root constant CBV to execute indirect advanced.
Tests that we can handle > 128 byte push constant blocks.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:31:30 +02:00
Hans-Kristian Arntzen 0640f44560 tests: Add test for early and late indirect patching.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:31:30 +02:00
Hans-Kristian Arntzen b287864cd1 tests: Remove TODOs from ExecuteIndirect state test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:31:30 +02:00
Hans-Kristian Arntzen 0a7b13fe7f tests: Add test for advanced ExecuteIndirect features.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:31:30 +02:00
Hans-Kristian Arntzen f704cb9776 vkd3d: Use index type LUT for DGC.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:14:13 +02:00
Hans-Kristian Arntzen e17a7cb40c vkd3d: Attempt to reuse application indirect command buffer.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:14:13 +02:00
Hans-Kristian Arntzen 9e45c72256 tests: Test UAV counter behavior with NULL counters.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:07:47 +02:00
Hans-Kristian Arntzen 2a8c762025 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:07:47 +02:00
Hans-Kristian Arntzen 3b8a13e63d vkd3d-shader: Implement robust UAV counters.
It's technically undefined to use NULL UAV counters,
but drivers all implement some form of robust behavior here
when presented with NULL counters, so we'll have to follow suit.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 15:07:47 +02:00
Hans-Kristian Arntzen 65804bbde5 vkd3d: Ignore cpu_access_domain when reporting heap tier.
For host visible, we only place buffers anyways.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:24 +02:00
Hans-Kristian Arntzen 233ff38175 vkd3d: Force LINEAR images to be allocated as committed resources.
We have no way of expressing size / alignment requirements to
applications since the API query does not provide us with heap
information. Reuse the fallback path for promoting placed to committed.

Guardians of the Galaxy hits a case where it tries to place 3x
host-visible 3D images in one heap, and they end up overlapping in
memory due to a 16x16x80 3D texture taking up far less space in optimal
tiling compared to linear tiling on AMD.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:24 +02:00
Hans-Kristian Arntzen 4a07d9c038 debug: Add concept of implicit instance index to debug ring.
For internal debug shaders, it is helpful to ensure in-order logs when
sorted for later inspection.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:00 +02:00
Hans-Kristian Arntzen bcdac3180a debug: Make Instance sorting easier.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:00 +02:00
Hans-Kristian Arntzen df11b5ba5a debug: Pretty-print execute template debug messages.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:00 +02:00
Hans-Kristian Arntzen e138a5117a vkd3d: Encode in detail which commands we're emitting in template.
Feed this back to debug ring for less cryptic logs.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:00 +02:00
Hans-Kristian Arntzen 96fdb71ae4 vkd3d: Refactor out patch command token enum.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:00 +02:00
Hans-Kristian Arntzen fe707989fe vkd3d: Clamp command count in execute indirect path.
Shouldn't be required, but take no chances.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:00 +02:00
Hans-Kristian Arntzen 6d3c5d53b0 vkd3d: Add debug ring path for execute indirect template patches.
Somehow inspect draw parameters this way.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:00 +02:00
Hans-Kristian Arntzen f93a581dae vkd3d: Trace breadcrumbs for execute indirect templates.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:59:00 +02:00
Hans-Kristian Arntzen b7bbdcabd4 tests: Test that we can deal with local samplers in COLLECTIONS.
We cannot handle all scenarios if COLLECTIONS are incompatible,
but test the easier cases.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:58:19 +02:00
Hans-Kristian Arntzen a28e4b6e11 tests: Add test for querying identifiers from COLLECTION objects.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:58:19 +02:00
Hans-Kristian Arntzen eda0b2fab2 vkd3d: Do a best effort in handling COLLECTION local static samplers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:58:19 +02:00
Hans-Kristian Arntzen 7f5dbcfc40 vkd3d: Add workaround to allow identifiers to be queried from library.
CP77 relies on this to work somehow ...
The DXR spec seems to suggest this is allowed, but there is no direct
concept for this in Vulkan.

This seems to work on NVIDIA at least, but we're on very shaky ground
here ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:34:34 +02:00
Hans-Kristian Arntzen d333159c86 vkd3d: Disallow querying identifiers from COLLECTION objects.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:34:34 +02:00
Hans-Kristian Arntzen 74eb676cfb vkd3d-shader: Normalize root signature compatibility hashing.
The hash should only depend on the raw byte stream, not the entire DXBC
blob. Useful now since we can declare root signatures either through
DXBC blob or as RDAT object (which is raw).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:34:34 +02:00
Hans-Kristian Arntzen 5033904e10 debug: Add GLSLC_FLAGS to debug shader build.
When building ray query shaders, need --target-env=spv1.4.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:23:38 +02:00
Hans-Kristian Arntzen b34931eb17 vkd3d: Log how shader identifiers are queried.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:23:38 +02:00
Hans-Kristian Arntzen 7410f53912 vkd3d: Add debug ring support to raytracing shaders.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:23:38 +02:00
Hans-Kristian Arntzen 089d2c6cb7 debug: Add shader override build for ray tracing as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:23:38 +02:00
Hans-Kristian Arntzen 03fdbac59e vkd3d: Dump TraceRays parameters to breadcrumbs.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:04:38 +02:00
Hans-Kristian Arntzen 7832eeb60d vkd3d: Add detailed tracing for RTPSO creation.
So much state floating around ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:04:38 +02:00
Hans-Kristian Arntzen 8a94c3ce0e vkd3d: Add more detailed breadcrumb logging for TraceRays.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:04:38 +02:00
Hans-Kristian Arntzen ddb425c5cb vkd3d: Add support for tag logging in breadcrumbs.
To keep things simple, outer code is responsible for keeping string
alive. Intended to be used for RTPSO entry point name debugging.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:04:38 +02:00
Hans-Kristian Arntzen ad7459551d vkd3d: Trivially ensure tighter packing of entry point struct.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 14:04:38 +02:00
Hans-Kristian Arntzen e3c36a47dd tests: Add test for default association tiebreak rules.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 13:41:06 +02:00
Hans-Kristian Arntzen ee8b8374b4 tests: Add test for how we handle DXIL embedded subobjects.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 13:41:06 +02:00
Hans-Kristian Arntzen ce00c9322d tests: Add some basic RTPSO validation rules tests.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 13:41:06 +02:00
Hans-Kristian Arntzen b88b04e4f1 vkd3d: Rewrite how submodules are associated with exports.
Handle embedded DXIL subobjects and fix various issues exposed by the
upcoming new tests.

Associating with global root signatures, shader config and pipeline
config needs to be rewritten so that we validate uniqueness late.

The strategy here is to look at all exports we care about and find an
association.

There are many priority levels which are implied by how I understand the
DXR docs. State objects in the API win over embedded DXIL state objects.
Any DXIL state object wins over a collection.

Hit group associations can trump an entry point. It's not entirely clear
how this works, but we let it win if it has higher priority, i.e.
an explicit association directed at the hit group.

There's also cases where explicit assignment trumps explicit default
assignment, which then trumps just declaring a state object.

Collection state is inherited in some cases like AddToStateObject() even
if this seems to be undocumented behavior.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 13:41:06 +02:00
Hans-Kristian Arntzen 4a121b9aaa vkd3d-shader: Forward RDAT subobjects.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 12:37:34 +02:00
Hans-Kristian Arntzen 0ef6a8b798 vkd3d: Expose utility for creating root signature from raw blob.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 12:37:34 +02:00
Hans-Kristian Arntzen 49b6e67e7d vkd3d-shader: Expose entry point for raw root signature parsing.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 12:37:34 +02:00
Hans-Kristian Arntzen 2ef3fd469c vkd3d-common: Add strequal_mixed between WCHAR and ASCII.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 12:37:34 +02:00
Hans-Kristian Arntzen 22778b99be vkd3d: Handle default global root signature in RTPSO.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 12:37:34 +02:00
Hans-Kristian Arntzen b8b2a93aa6 tests: Add test coverage for two stages of AddToStateObject().
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 12:11:27 +02:00
Hans-Kristian Arntzen 14470d5456 tests: Add test for AddToStateObject.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 12:11:27 +02:00
Hans-Kristian Arntzen 3aad4edf6e tests: Add default NODE_MASK state object to RTPSO tests.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 12:11:27 +02:00
Hans-Kristian Arntzen 3c92b3a1bc vkd3d: Implement AddToStateObject().
This is barely implementable, and relies on implementations to do kinda
what we want.

To make this work in practice, we need to allow two pipelines per state
object. One that is created with LIBRARY and one that can be bound. When
incrementing the PSO, we use the LIBRARY one.

It seems to be allowed to create a new library from an old library.
It is more convenient for us if we're allowed to do this, so do this
until we're forced to do otherwise.

DXR 1.1 requires that shader identifiers remain invariant for child
pipelines if the parent pipeline also have them.
Vulkan has no such guarantee, but we can speculate that it works and
validate that identifiers remain invariant. This seems to work fine on
NVIDIA at least ... It probably makes sense that it works for
implementations where pipeline libraries are compiled at that time.

The basic implementation of AddToStateObject() is to consider
the parent pipeline as a COLLECTION pipeline. This composes well and
avoids a lot of extra implementation cruft.

Also adds validation to ensure that COLLECTION global state matches with
other COLLECTION objects and the parent. We will also inherit global
state like root signatures, pipeline config, shader configs etc when
using AddToStateObject().

The tests pass on NVIDIA at least.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 12:11:27 +02:00
Hans-Kristian Arntzen 8473355a98 vkd3d: Hold private ownership over global root signature.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 11:49:44 +02:00
Hans-Kristian Arntzen 1438ff5637 vkd3d: Allow different but compatible global root signature objects.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 11:49:44 +02:00
Hans-Kristian Arntzen c3ee963d2f vkd3d: Ignore NODE_MASK subobjects.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-07-11 11:49:44 +02:00
Hans-Kristian Arntzen 684e41fabe vkd3d: Do not perform initial layout transition for placed RTV / DSV.
Docs explicitly specify that placed RTV / DSV resource must be properly
initialized before use, either on first use or after aliasing barriers,
so there should be no need to perform initial layout transition.

Fixes spurious GPU hangs in Hitman III where application aliases
an indirect buffer and a DSV. The DSV is cleared after the indirect
buffer is consumed, but the initial_layout_transition is triggered and
HTILE init clobbered the buffer.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-30 15:06:59 +02:00
Philip Rebohle 1d869e3e21 vkd3d: Do not execute indirect commands if count buffer is unsupported.
Also be a bit more uniform with using break/return on fail conditions.

Otherwise, the indirect command will read data from the count buffer
instead, which may lead to bugs or GPU hangs.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-06-28 14:57:11 +02:00
Tatsuyuki Ishi 02c7ec404c vkd3d: Fix transfer batch clobbering state in begin_render_pass.
Transfer batch can clobber graphics pipeline for e.g. depth->color copies.
Hence, flushing the batches after applying the graphics pipeline set by the
app can cause correctness issues.

To prevent that, do the transfer batch flush first before we apply any
render-related states.

Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
2022-06-28 13:53:03 +02:00
Hans-Kristian Arntzen 9b5f3bfc26 vkd3d-shader: Fix GRAD sample on cubes.
offset_component_count was set to 0 for cubes, but GRAD path also
uses the variable to check how many components to use for GRAD.
OFFSET is not supported for cubes, so that's likely why it was bugged.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-28 12:14:41 +02:00
Hans-Kristian Arntzen b4ab6c3f08 cache: Unmap files before attempting to delete.
Native Win32 does not like it.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-28 12:13:03 +02:00
Hans-Kristian Arntzen 707af8152e vkd3d: Add workaround for forced clearing of certain buffers.
If game uses NOT_ZEROED, it might still rely on buffers being properly
cleared to 0.
Enable this and FORCE_RAW_VA_CBV for Halo Infinite.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-24 15:11:19 +02:00
Hans-Kristian Arntzen bc759be2af vkd3d: Optimize ExecuteIndirect() if no INDIRECT transitions happened.
The D3D12 docs outline this as an implementation detail explicitly, so
we should do the same thing.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-24 14:55:39 +02:00
Hans-Kristian Arntzen 18f1d1c72e vkd3d: Implement ExecuteIndirect with state update.
Implements the most basic iteration where we don't try to take advantage
of index LUT, hoisting CS patching or attempting to reuse application
indirect buffer directly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-24 14:55:39 +02:00
Hans-Kristian Arntzen 1b704287e5 vkd3d: Enable NV_device_generated_commands extension.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-24 14:55:39 +02:00
Hans-Kristian Arntzen f975f09bb1 meta: Add ExecuteIndirect patch meta shader.
Currently we are translating the index type. This will be changed in a
follow up commit where we move over to index LUT.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-23 14:39:22 +02:00
Hans-Kristian Arntzen 619a54810d vkd3d: Pass down required memory types to scratch allocators.
Separate scratch pools by their intended usage.
Allows e.g. preprocess buffers to be
allocated differently from normal buffers, which is necessary on
implementations that use special memory types to implement preprocess
buffers.

Potentially can also allow for separate pools for
host visible scratch memory down the line.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-23 14:39:22 +02:00
Hans-Kristian Arntzen cecb8d6ebc vkd3d: Don't suballocate scratch buffers.
Scratch buffers are 1 MiB blocks which will end
up being suballocated. This was not intended and a fallout from the
earlier change where VA_SIZE was bumped to 2 MiB for Elden Ring.

Introduce a memory allocation flag INTERNAL_SCRATCH which disables
suballocation and VA map insert.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-23 14:39:22 +02:00
Hans-Kristian Arntzen 8ae391e675 vkd3d: Add more stringent validation for CreateCommandSignature.
The runtime is specified to validate certain things.
Also, be more robust against unsupported command signatures, since we
might need to draw/dispatch at an offset. Avoids hard GPU crashes.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-23 12:52:29 +02:00
Hans-Kristian Arntzen a30205589f common: Assert that alignment is > 0 and POT.
Found bug when allocating device generated commands.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-23 12:52:29 +02:00
Hans-Kristian Arntzen abdef77695 vkd3d: Add helper to invalidate all state.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-23 12:52:29 +02:00
Hans-Kristian Arntzen c132073df8 vkd3d: Refactor index buffer state to be flushed late.
With ExecuteIndirect state we'll need to modify or refresh index buffer
state.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-23 12:52:29 +02:00
Hans-Kristian Arntzen 128852200a vkd3d: Store the raw VA index in root signature for root descriptors.
Needed when building device generated commands later.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-23 12:52:29 +02:00
Hans-Kristian Arntzen 717026f903 vkd3d: Add VKD3D_CONFIG option to force raw VA CBV descriptors.
For certain ExecuteIndirect() uses, we're forced to use this path
since we have no way to update push descriptors indirectly yet.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-23 12:52:29 +02:00
Hans-Kristian Arntzen b849bd4256 vkd3d: Enable F1 2020 quirks on 2019 as well.
Same game bug.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-20 14:53:16 +02:00
Georg Lehmann d8905afd5d demos: Don't pretend to handle allocation failure.
This function doesn't indicate failure and the possibility of a return
causes -Wmaybe-uninitialized warnings.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2022-06-20 11:36:17 +02:00
Hans-Kristian Arntzen de5b751468 vkd3d: Enable VK_KHR_depth_stencil_resolve.
Required by KHR_dynamic_rendering. Caught by updated validation layers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-17 11:54:31 +02:00
Hans-Kristian Arntzen 219d9698b3 tests: Fix compiler warnings in various tests.
Mostly related to casting vec4 struct to float where array[4] is expected.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-17 11:54:07 +02:00
Hans-Kristian Arntzen acef5429c5 vkd3d-shader: Workaround trivial compiler warning.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-17 11:54:07 +02:00
Hans-Kristian Arntzen 135aff4685 vkd3d: Remove the global VkPipelineCache.
Just use VK_NULL_HANDLE. We rely on the disk cache to exist anyways
here. We never serialize the global pipeline cache, so it might just
confuse drivers into disable disk cache if anything.

Also reduce memory bloat.

Also gets rid of very old NV driver workaround where we forced global
pipeline cache.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-17 11:53:46 +02:00
Hans-Kristian Arntzen 2f6a9e0d55 vkd3d: Do not attempt to clear dedicated memory allocations.
We rely on zerovram behavior in drivers. Opt-in to this path where we
know implementation does what we want (backed up by testing).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-17 11:53:28 +02:00
Hans-Kristian Arntzen 3a19dea7c7 tests: Ensure we try to allocate some larger buffers as well.
The suballocation test should also try to allocate >= 2 MiB buffers so
we can verify VRAM clear behavior for dedicated allocations as well.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-17 11:53:28 +02:00
Tatsuyuki Ishi 39d07dea2c vkd3d: Check for alias and batch barriers in CopyTextureRegion batches.
Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
2022-06-16 11:54:26 +02:00
Tatsuyuki Ishi 3577ca3144 vkd3d: Introduce transfer batches.
Transfer batches buffers CopyTextureRegion calls for batching.

The flushes needs to happen in a few places:
1. ResourceBarrier: This is where the transition from COPY_DEST to other
   might happen, at which point the writes must be visible. This might
   also transition away from COPY_SRC which invalidates the
   precondition.
2. Copy operations. Copies to the same resource are implicitly ordered.
3. Draws and dispatches. These are not strictly necessary, but we don't
   want too much command reordering so flushing here seems good.
4. Close. So that we don't throw commands into the void.

Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
2022-06-16 11:54:26 +02:00
Tatsuyuki Ishi 829ac72e3d vkd3d: Break up CopyTextureRegion into three stages.
A parameter preparation stage, a pre-execution barrier stage, then finally
the execution and post-execution barrier stage.

Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
2022-06-13 14:40:23 +02:00
Hans-Kristian Arntzen c64916686d vkd3d: Clear SUSPENDED flag properly.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-13 13:46:49 +02:00
Hans-Kristian Arntzen c4b00bbe1e tests: Avoid tripping out of spec UAV casts.
5.3.9.5 in D3D11 spec explicit outlines when we can
cast to R32{U,I,F}. The D3D12 validation layers
seem to have missed this.

Fixes assertions in RADV when running test under debug.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-08 17:09:40 +02:00
Hans-Kristian Arntzen fd05839eb9 vkd3d: Only enable native FP16 codegen for RADV.
Regression in Deathloop on NV with native FP16 FSR.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-03 16:15:54 +02:00
Hans-Kristian Arntzen 46470017a3 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-03 16:15:54 +02:00
Georg Lehmann cbca29dd90 tests: Fix -Wstringop-overread warnings.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2022-06-01 20:41:36 +02:00
Hans-Kristian Arntzen c3fb6a6c5e dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-01 15:53:02 +02:00
Hans-Kristian Arntzen e8f1936ee2 vkd3d: Convert VKD3D_CONFIG flags to 64-bit constants.
We're soon running out of 32-bit space.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-01 15:31:48 +02:00
Hans-Kristian Arntzen 4166eb042b tests: Add exploratory test for accessing root descriptors with overflow.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-01 15:31:38 +02:00
Hans-Kristian Arntzen 7a002698f3 vkd3d-shader: Prefer InBounds access chains for root descriptors.
Gets better codegen, since compiler no longer has to assume
that negative indices can be generated, which means full 64-bit sign
extension and addressing math (slow).

Based on experiments, no native driver lets -1 indices work,
so it's safe to make the u32 assumption.

See test_root_descriptor_offset_sign as a justification for this change.

Also, see https://gitlab.freedesktop.org/mesa/mesa/-/issues/6562
for discussion on InBounds.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-01 15:31:38 +02:00
Hans-Kristian Arntzen 896e6fb868 vkd3d-shader: Enable native 16-bit path for min16float DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-01 15:31:22 +02:00
Hans-Kristian Arntzen 8989360087 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-01 15:31:22 +02:00
Hans-Kristian Arntzen f804ddc4c7 vkd3d: Allow integer dot product unconditionally.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-06-01 15:31:22 +02:00
Hans-Kristian Arntzen 3b0d7e043d tests: Add more small resource tests to get_resource_tiling test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-31 16:00:11 +02:00
Hans-Kristian Arntzen 75e0506404 tests: Add test for RTV count > 0 and no pixel shader.
Attempt to bind mismatching format. Observe it is ignored.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-31 16:00:11 +02:00
Hans-Kristian Arntzen 0f9d7dd10d vkd3d: Force RT count to 0 when PS does not exist.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-31 16:00:11 +02:00
Hans-Kristian Arntzen 7acc33ae39 vkd3d: Always return tile shape.
Docs are lying. :\

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-31 16:00:11 +02:00
Hans-Kristian Arntzen 7916d2a6d8 vkd3d: Enable and use VK_KHR_fragment_shader_barycentric.
For now, just keep the NV path as well. It's the exact same extension
basically as the KHR one.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-31 15:59:49 +02:00
Hans-Kristian Arntzen 48157c29e8 khronos: Update Vulkan headers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-31 15:59:49 +02:00
Hans-Kristian Arntzen 467db76f90 vkd3d: Remove obsolete COLOR -> COMPUTE workaround for Deathloop.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-31 15:59:35 +02:00
Hans-Kristian Arntzen 2953ef8688 tests: Remove query TODOs from ray tracing tests.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-30 20:26:50 +02:00
Hans-Kristian Arntzen f964532619 vkd3d: Implement extended DXR queries.
Requires ray_tracing_maintenance1.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-30 20:26:50 +02:00
Hans-Kristian Arntzen 5a0c8289d8 tests: Add test for FirstWSlice/WSlice on 3D UAV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-30 15:09:09 +02:00
Hans-Kristian Arntzen cca7613bca dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-25 13:08:39 +02:00
Philip Rebohle 910f15dff8 vkd3d: Only set VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT for color attachments.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-05-23 17:17:17 +02:00
Hans-Kristian Arntzen a94e9b8b6a vkd3d: Don't create user descriptors until we have observed a pipeline.
If we don't get a swapchain on first frame for whatever reason, defer
creating the descriptors.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-23 16:58:15 +02:00
Hans-Kristian Arntzen 4ac0a3b455 vkd3d: Robustly fall back to user buffers if we fail to present twice.
If we fail to present after a swapchain recreation, force a SURFACE_LOST
scenario and try again later when things hopefully stabilize.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-23 16:58:15 +02:00
Hans-Kristian Arntzen 300058d9a7 vkd3d: Handle all errors after present, not just OUT_OF_DATE.
Can have SURFACE_LOST here as well for example.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-23 16:58:15 +02:00
Hans-Kristian Arntzen 2e16a777ca vkd3d: Get rid of redundant recreate swapchain call.
It just called create_vulkan_swapchain anyways.
Also, add in extra parameter to support temporary user buffer fallbacks.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-23 16:58:15 +02:00
Hans-Kristian Arntzen ac211d5f6a vkd3d: Remove direct calls to d3d12_swapchain_destroy_views.
Refactor destroy_buffers to destroy_resources as it's more obvious what
it's doing that way.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-23 16:58:15 +02:00
Hans-Kristian Arntzen 1dc4bbe5f2 utils: Report Wine segfault VkResult directly.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-23 16:58:15 +02:00
Tatsuyuki Ishi 2965b7e379 vkd3d/tests: Fix Release orders.
Fixes ASan use-after-free warnings on Release.

Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
2022-05-23 09:58:30 +02:00
Tatsuyuki Ishi 0d9c0a3903 vkd3d: Fix aligned_alloc ASan errors on native.
Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
2022-05-23 09:58:30 +02:00
Robin Kertels 1a773cfb71 tests: Add test for indirect ray tracing.
Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
2022-05-11 19:11:01 +02:00
Robin Kertels cdabda7805 vkd3d: Implement indirect ray tracing.
Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
2022-05-11 19:11:01 +02:00
Robin Kertels 8ac7aaca99 vkd3d: Enable VK_KHR_ray_tracing_maintenance1.
Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
2022-05-11 19:11:01 +02:00
Robin Kertels 7e7c472005 khronos: Update Vulkan headers
Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
2022-05-11 19:11:01 +02:00
Hans-Kristian Arntzen 71940797d1 vkd3d: Check for redundant dynamic state in some cases.
Some dynamic state is at risk of being spammed with same arguments many
times. For the dynamic state that is trivial to check, do so.

Ghostwire: Tokyo has been observed to spam the same OMSetStencilRef
value causing some context rolls, also RSSetShadingRate has been set
redundantly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-05-03 16:30:42 +02:00
Hans-Kristian Arntzen 4603c25d69 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-28 13:54:11 +02:00
Hans-Kristian Arntzen 97201b8e93 vkd3d: Clean up straggling getenv() calls.
Replace with the new vkd3d_get_env wrapper.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-25 16:42:41 +02:00
Hans-Kristian Arntzen 51199752dd vkd3d: Fix queue creation for queue family -1.
Fixes validation error on Intel where we are trying to create
CONCURRENT family with {0, -1}.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-25 15:54:13 +02:00
Hans-Kristian Arntzen ebe589d622 tests: Add test for waveop in infinite loop convergence.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-25 14:42:18 +02:00
Hans-Kristian Arntzen 55a6847c61 vkd3d: Fix MSVC warning about redundant snprintf argument.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-25 14:41:44 +02:00
Hans-Kristian Arntzen 04c020525c common: Fix missing include.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-22 18:31:59 +02:00
Dean Beeler 063ce7e4bd Use Windows specific environment calls for better Windows compatibility.
Signed-off-by: David McCloskey <davmcclo@gmail.com>
2022-04-22 17:40:21 +02:00
Hans-Kristian Arntzen 2c54e18245 common: Fix _BitScanForward usage on MSVC.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-22 17:11:07 +02:00
Philip Rebohle bb2e35c539 vkd3d: Use vkGetDevice{Buffer,Image}MemoryRequirementsKHR in vkd3d_memory_info_init.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-22 11:36:02 +02:00
Philip Rebohle d5ad5bb1de vkd3d: Use vkGetDeviceImageMemoryRequirementsKHR in vkd3d_get_image_allocation_info.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-22 11:36:02 +02:00
Philip Rebohle beb58f8472 vkd3d: Enable and require VK_KHR_maintenance4.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-22 11:36:02 +02:00
Hans-Kristian Arntzen 358f95aff2 vkd3d: Ignore cached SPIR-V if we're dumping SPIR-V.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-22 11:29:27 +02:00
Philip Rebohle 119e00ed45 vkd3d: Do not add uint format to image format list.
Fixes #1069.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-21 13:51:58 +02:00
Philip Rebohle beaedbd857 vkd3d: Use UAV clear fallback based on format compatibility.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-21 13:51:58 +02:00
Philip Rebohle 81927c5895 vkd3d: Fix handling of non-zero base layer in ClearUAV fallback path.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-21 13:51:58 +02:00
Philip Rebohle e7a6af4971 vkd3d: Use texel buffer views for UAV clears with buffer to image copy.
Allows this to more easily work with more formats.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-21 13:51:58 +02:00
Philip Rebohle a1d5e6f39a vkd3d: Re-add R11G11B10 format compatibility info.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-21 13:51:58 +02:00
Hans-Kristian Arntzen 4a05360a0a dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-20 16:56:26 +02:00
Hans-Kristian Arntzen 0c4df9b32c ci: Workaround safe directory errors in vkd3d_build generation.
See https://github.com/actions/checkout/issues/760 for reference.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-20 15:54:30 +02:00
Hans-Kristian Arntzen 25c4bc18e7 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-08 13:04:26 +02:00
Hans-Kristian Arntzen 30ec6b7f1f dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-07 13:06:04 +02:00
Hans-Kristian Arntzen c47a6a904b meta: Add docs for magic shader cache.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-06 16:36:26 +02:00
Hans-Kristian Arntzen 5044975152 vkd3d: Drop redundant validate of PSO state blob from disk cache.
If we get an entry, it's implicitly validated.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-06 16:36:26 +02:00
Hans-Kristian Arntzen 8dc8b72807 cache: Add some performance information for shader cache operations.
They can take a long time and it's useful to have some reports here.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-06 16:36:26 +02:00
Hans-Kristian Arntzen ae0dafa3a1 cache: Attempt to use disk cache instead when appropriate.
When the disk cache is used, the cache we give back to applications is a
dummy. Therefore, try to use the disk cache blob if we detect a useless
application blob.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-06 16:36:26 +02:00
Hans-Kristian Arntzen 6c8542f7d6 vkd3d: Make use of internal pipeline library if we're asked to.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-06 16:36:26 +02:00
Hans-Kristian Arntzen 2dcb1e2efc cache: Implement an on-disk pipeline library.
With VKD3D_SHADER_CACHE_PATH, we can add automatic serialization of pipeline
blobs to disk, even for games which do not make any use of GetCachedBlob
of ID3D12PipelineLibrary interfaces. Most applications expect drivers to
have some kind of internal caching.

This is implemented as a system where a disk
thread will manage a private ID3D12PipelineLibrary, and new PSOs are
automatically committed to this library. PSO creation will also consult
this internal pipeline library if applications do not provide their own
blob.

The strategy for updating the cache is based on a read-only cache which
is mmaped from disk, with an exclusive write-only portion for new blobs,
which ensures some degree of safety if there are multiple
concurrent processes using the same cache.

The memory layout of the disk cache is optimized to be very efficient
for appending new blobs, just simple fwrites + fflush.
The format is also robust against sliced files, which solves the problem
where applications tear down without destroying the D3D12 device
properly.

This structure is very similar to Fossilize, and in fact the idea is to
move towards actually using the Fossilize format directly later.
This implementation prepares us for this scenario where e.g. Steam could
potentially manage the vkd3d-proton cache.

The main complication in this implementation is that we have to merge
the read-only and write caches.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-06 16:36:26 +02:00
Hans-Kristian Arntzen 3095ed84d3 cache: Add concept of internal pipeline libraries.
For internal pipeline libraries, we want a somewhat different strategy.

- PSOs are keyed by hash instead of user key.
- We want the option to conditionally store SPIR-V and PSO blobs.
  For internal caches, there isn't much of a reason to store PSO blobs
  since the disk cache is going to be primed anyways.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-05 14:12:20 +02:00
Hans-Kristian Arntzen db9b9a13de cache: Fix misleading comment about chunk alignment.
It's 8. Used to be 4 before some other fixes ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-05 14:12:20 +02:00
Hans-Kristian Arntzen 637834dc75 vkd3d: Make private_root_signatures actually private.
Makes sure that we drop private root signature device references when
public pipeline state refcount hits 0.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-05 14:12:20 +02:00
Hans-Kristian Arntzen 93928424a9 common: Move time query to common header.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-05 14:12:20 +02:00
Hans-Kristian Arntzen c8b143c0bd common: Add wrapper for _ftelli64/_fseeki64.
MSVC doesn't have ftello64/fseeko64, nor off64_t.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-05 14:12:20 +02:00
Hans-Kristian Arntzen ca0a186a4b common: Add some file utils.
Supports more advanced file operations than we'd normally need.
Intended to be used by magic disk cache.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-04-05 14:12:20 +02:00
Philip Rebohle c9101b8ec3 tests: Add test to clear R11G11B10 UAV to zero.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-05 11:52:23 +02:00
Philip Rebohle 829c02bf90 vkd3d: Remove format compatibility info for R11G11B10.
Not allowing R32 views may give us compression back in some scenarios.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-05 11:52:23 +02:00
Philip Rebohle e4184830c5 vkd3d: Add ClearUAV path that uses buffer-to-image copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-05 11:52:23 +02:00
Philip Rebohle d1425ee4d1 vkd3d: Use VK_ACCESS_MEMORY_{READ,WRITE}_BIT where appropriate
Buggy RADV versions no longer work due to missing extension support.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-04-05 11:52:23 +02:00
Denis Barkar 8dda6df729 vkd3d: Force non-invariant position for Serious Sam 4.
Signed-off-by: Denis Barkar <dbarkar@nvidia.com>
2022-04-01 15:34:52 +02:00
Joshua Ashton 2ed513b99a vkd3d: Remove VKD3D_MAX_DYNAMIC_STATE_COUNT
This was off by one, at some point, which could cause a stack buffer overrun which is naughty.

Replace this with just an ARRAY_SIZE on the dynamic_state_list for the array size.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2022-04-01 15:19:18 +02:00
Hans-Kristian Arntzen 19e088cdfc tests: Add test for weird CBV layouts.
CBufferLoad and 16-bit/64-bit tests.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-30 20:13:32 +02:00
Hans-Kristian Arntzen 241078d7e8 vkd3d: Add scalar UBO layout requirement for SM 6.0.
Needed to support SM 6.0 CBufferLoad.
This path is mostly unused since it's opt-in in DXC and horribly broken
...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-30 20:13:32 +02:00
Hans-Kristian Arntzen e01589a33b dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-30 20:13:32 +02:00
Hans-Kristian Arntzen 2e704c5a5e tests: Test primitive restart behavior on list primitives.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-30 16:12:16 +02:00
Hans-Kristian Arntzen 6f43f450c8 vkd3d: Disable primitive restart when using non-compatible topologies.
Primitive restart is only used for strip primitive types, and must be
ignored for lists. Use and require extended_dynamic_state2 for this
purpose.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-30 16:12:16 +02:00
Hans-Kristian Arntzen cfeaa18b09 vkd3d: Enable MUTABLE_SINGLE_SET for Intel GPUs.
There are strict limits on number of descriptors which can be used,
and we have to use MUTABLE + single set to make this work.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-30 12:25:20 +02:00
Hans-Kristian Arntzen da63f0beac vkd3d: Compute range_end after sparse checks in copy tracking.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-30 12:13:25 +02:00
Hans-Kristian Arntzen 35e777f8a0 meta: Update docs for latest breadcrumbs/debug-ring work.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-30 12:13:16 +02:00
Hans-Kristian Arntzen 095a36cbaf meta: Update stale notes about driver versions.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-30 12:13:16 +02:00
Philip Rebohle 6378f1b880 vkd3d: Optimize WriteBufferImmediate for consecutive writes.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-30 11:51:10 +02:00
Philip Rebohle 307190e96b tests: Test WriteBufferImmediate with disjoint ranges.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-30 11:51:10 +02:00
Hans-Kristian Arntzen 2e8fb27182 vkd3d: Correctly handle dynamic depth/stencil attachment infos.
{depth,stencil}AttachmentFormat and p{Depth,Stencil}Attachment are only
allowed if the format contains that aspect. Check this explicitly.

Fixes some validation errors.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-24 17:55:32 +01:00
Hans-Kristian Arntzen 1b5f7e8fc3 vkd3d: Use VkImageViewCreateInfo correctly.
For EXTENDED_USAGE, we still need to restrict image usage when creating
concrete views.
Use VkImageViewUsageCreateInfo to restrict usage flags to the kind of
view we're creating.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-24 17:55:32 +01:00
Hans-Kristian Arntzen cf65a78570 vkd3d: Rename DSV UNKNOWN workaround query.
Make it more obvious what it's really trying to check.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-23 22:36:00 +01:00
Philip Rebohle 1d3957fe6d vkd3d: Do not create pipeline variants for NULL DSV.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-23 22:22:09 +01:00
Philip Rebohle c9abcfa656 vkd3d: Use d3d12_graphics_pipeline_state_has_unknown_dsv_format more consistently.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-23 22:22:09 +01:00
Hans-Kristian Arntzen 03427c6ee6 vkd3d: Explicitly use NULL RTV mask for dual source blending.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-23 14:29:51 +01:00
Hans-Kristian Arntzen 09682f8417 tests: Extend validation tests for dual source blending.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-23 14:29:51 +01:00
Hans-Kristian Arntzen 6273780e50 vkd3d: Accurately validate dual source blend state.
We need to check RTVFormats and IO signature.
If both RTVFormat uses non-null format and IO signature has an active
entry, we must fail compilation.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-23 14:29:51 +01:00
Hans-Kristian Arntzen 6e915dd2c0 vkd3d: Use rt_count as basis for binding RTVs.
Found some validation errors where rt_count != rtv_active_mask,
and blending used rt_count instead of rtv_active_mask. If shader renders
to a NULL attachment, we must make sure that it's part of the PSO
interface.

Also, use rt_count rather than active mask when beginning render pass.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-23 14:29:51 +01:00
Philip Rebohle 34f5fc6a31 vkd3d: Do not create pipeline variants for NULL RTVs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-22 13:06:00 +01:00
Hans-Kristian Arntzen 63530501a5 vkd3d: Require VK_EXT_extended_dynamic_state.
This is basically required for not horrible stutter and performance and
is widely supported.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-16 17:48:21 +01:00
Hans-Kristian Arntzen dd6534f3f8 vkd3d: Report enabled debug ring size as INFO instead of WARN.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen 09997b4dd8 vkd3d: Fish for message clues on device lost.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen 6d35f98e59 vkd3d: Emit deadca7 cookie for num_words in debug ring.
Makes it somewhat feasible to fish for message begin codes in the
stream.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen e61cc0234a vkd3d: Allow debug ring to know about device lost scenarios.
For this case, we want to block and teardown the debug ring thread.
It's okay to fish for dead messages in the ring, since we know there
won't be more GPU work submitted.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen c54895b4b7 vkd3d: Fix overflow of ring_size.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen a6700d3d85 vkd3d: Make debug ring aware of potential crash scenarios.
If we expect device losts (breadcrumb debug), we need to use DEVICE uncached/coherent,
since we might not be able to flush GPU caches properly.

We also need to remove the idea of being able to copy out the control
block back to host. This is too brittle and we should instead just place
the control block in PCI-e BAR instead. Rethink how we pass messages
from GPU to CPU to make it more robust.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen f0cac9d97c debug: Make elects helper-lane aware.
The elected lane must be able to perform side effects, so make sure
helper lanes don't participate.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen 08c0ea209f debug: Add helper Makefile to easily build shader override modules.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen 64d42c08ee debug: Add helpers to do wave uniform debug messages.
If we know the input is wave uniform (progress markers for example),
no need to spam the log.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen 3d8ef2b349 debug: Emit messages more robustly in face of crashes.
Attempt to enforce memory order on the num_words
to only commit complete messages.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:26:27 +01:00
Hans-Kristian Arntzen 33b9166fec vkd3d: Make device coherency extension optional for breadcrumbs.
Some implementation can support marker, but not explicit coherency.
Buffer markers are often uncached either way, so should be fine ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:07:56 +01:00
Hans-Kristian Arntzen 972ce74ac6 vkd3d: When using breadcrumbs, consider that WaitSemaphore can be buggy.
Spec says that in device lost, driver must return DEVICE_LOST in finite
time, but this does not happen on NV drivers. Use a long timeout instead
in this scenario.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:07:56 +01:00
Robin Kertels 5f97d1eb70 vkd3d: Implement NV_checkpoint path for breadcrumbs.
Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
Co-authored-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:07:56 +01:00
Robin Kertels a6ea442819 vkd3d: Enable VK_NV_device_diagnostic_checkpoints.
Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
2022-03-11 13:07:56 +01:00
Hans-Kristian Arntzen 365dd05557 vkd3d: Add breadcrumbs support.
AMD path for this commit.
Idea is that we can automatically instrument markers with command list
information we can make some sense of in vkd3d-proton.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:07:56 +01:00
Hans-Kristian Arntzen 5017b3723c vkd3d: Enable VK_AMD_device_coherent_memory.
For breadcrumbs support, along with buffer marker.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 13:07:56 +01:00
Hans-Kristian Arntzen 6a4f2842cb cache: Move d3d12_pipeline_library to internal references.
Allow us to hold internal magic pipeline libraries without creating
cycles.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 12:29:32 +01:00
Hans-Kristian Arntzen 18a5315db4 cache: Refactor lock strategy of internal hashmaps.
Rather than having to take writer lock on serialize calls from the
outside, we should just take locks when accessing the internal hashmaps
instead.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 12:29:32 +01:00
Hans-Kristian Arntzen 7c228139c3 cache: Refactor out pipeline library serialization.
If outer code has taken a reader lock, we don't need to lock again.
Also allows a reader lock to go GetSerializedSize + Serialize with one
reader lock.

This will be relevant for magic cache implementation.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-11 12:29:32 +01:00
Hans-Kristian Arntzen 30b4abcea1 vkd3d: Do not discard images in Clear*View() unless we have to.
It's redundant to add an UNDEFINED transition here for committed
resources. We need it for sparse and placed resources to handle aliasing
rules, but that's it.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-10 15:14:55 +01:00
Hans-Kristian Arntzen 17b1ffb41a vkd3d: Add path to use GENERAL depth-stencil images.
On some implementations, it doesn't matter for performance what we use,
and we can avoid a lot of ugly barriers this way.

Opt-in to use this extensions on GPUs we know handles it well,
otherwise, keep using the tracking paths.

With VK_KHR_dynamic_rendering, this is now feasible to do since we no longer
have to deal with shenanigans related to VkRenderPass layouts and
complicated compatibility rules.

To make this work with the existing framework, just need to consider
that GENERAL can be a common layout alongside DEPTH_STENCIL_OPTIMAL,
which are both common layouts that do not need to be tracked at all.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-10 15:14:55 +01:00
Hans-Kristian Arntzen f9da3bf564 vkd3d: Add VK_KHR_driver_properties.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-10 15:14:55 +01:00
Hans-Kristian Arntzen 5c70a24de1 tests: Test ref-count behavior of pipeline libraries.
It seems like we have to internally hold ID3D12PipelineState with
private references and hand it out to applications on request.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-09 18:35:09 +01:00
Hans-Kristian Arntzen c6149b47cd cache: Handle ref-count rules for multiple LoadPipeline/StorePipeline.
In pipeline libraries, the library holds on to private references of the
libraries so that they can be rapidly loaded on-demand.

This behavior is verifed by API tests.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-09 18:35:09 +01:00
Hans-Kristian Arntzen cc08339624 vkd3d: Use internal_refcounts for pipeline state.
When we store pipeline state in libraries we have to manage lifetime a
bit differently, which requires internal refcounts of some sort.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-09 18:35:09 +01:00
Hans-Kristian Arntzen 422f6804fb vkd3d: Enable VK_KHR_create_renderpass2.
Required extension by VK_KHR_fragment_shading_rate and
VK_KHR_separate_depth_stencil_layouts, but we don't care about enabling
any features or use it directly.

Needed to silence validation errors.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-09 16:35:05 +01:00
Georg Lehmann 7d4ed66881 meta: Remove VK_KHR_create_renderpass2 from README.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2022-03-08 18:34:18 +01:00
Georg Lehmann 14a06680d9 vkd3d: Remove unused renderpass remains.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2022-03-08 18:34:18 +01:00
Hans-Kristian Arntzen c9bac85dd1 tests: Add test for DSV plane tracking.
Tests various scenarios where we need to handle DSV layouts:
- Clears
- Discards
- Draw
- Transitions

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-08 18:11:50 +01:00
Hans-Kristian Arntzen 409dc57645 vkd3d: Properly decay depth-stencil images.
When performing a decay of a DSV resource, make sure to transition all
subresources, not just the particular aspect being transitioned.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-08 18:11:50 +01:00
Hans-Kristian Arntzen b330900659 vkd3d: Do not transition all aspects for single subresource.
We require separate DS layouts.
Fixes validation errors where we transition from read-only, but our
neighbor aspect might have been optimal.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-08 18:11:50 +01:00
Hans-Kristian Arntzen 92a8c0ad78 meta: Add KHR_dynamic_rendering to list of required features.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-08 18:05:51 +01:00
Hans-Kristian Arntzen c864f1322f khronos: Update Vulkan headers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-08 18:05:35 +01:00
Philip Rebohle 9a408367dc vkd3d: Remove render pass cache.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle 51e6b2bbbe vkd3d: Remove render pass from command list state.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle 94f82d1085 vkd3d: Get rid of pipeline variant flags.
These only existed for VRS attachment, which is no longer
necessary with VK_KHR_dynamic_rendering.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle 1a68267962 vkd3d: Remove framebuffer list from d3d12_command_allocator.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle c4f88951fc vkd3d: Use dynamic rendering for regular draw calls.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle 9673ac173d vkd3d: Use dynamic rendering for pipeline creation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle 3783eaf4f7 vkd3d: Implement swap chain blits using dynamic rendering.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle 024ef02f9b vkd3d: Implement meta image copies using dynamic rendering.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle 549d4ee63f vkd3d: Remove render pass list from d3d12_command_allocator.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle 6186cc1f0e vkd3d: Implement clears using dynamic rendering.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle 2c92ab7d1e vkd3d: Enable and require VK_KHR_dynamic_rendering.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Philip Rebohle ba04b02bf6 khronos: Update Vulkan headers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-03-08 17:44:47 +01:00
Hans-Kristian Arntzen 9fbae668fe vkd3d: Ensure that all SPIR-V modules are properly cached.
When we require inter-stage fixups, we need a solution for partial
validity of the cache. Accept the modules all or nothing.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-08 16:43:30 +01:00
Hans-Kristian Arntzen ce45297695 vkd3d: Enable debug_utils if vk_debug is enabled.
Allows debug callbacks to go through in Wine.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-08 16:40:51 +01:00
LemiSt24 c411d0d0c2 vkd3d: Add case for D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE
Signed-off-by: LemiSt24 <lennard.strohmeyer@gmail.com>
2022-03-07 16:15:22 +01:00
Hans-Kristian Arntzen 3e5aab6fb3 meta: Update version to 2.6.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-04 16:49:28 +01:00
Hans-Kristian Arntzen bc40528b6f meta: Add CHANGELOG for 2.6.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-04 14:54:16 +01:00
Hans-Kristian Arntzen 7cd3b9c917 idl: Fix type of D3D12_ERROR defines.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-04 14:53:57 +01:00
Hans-Kristian Arntzen 9a63df07b8 vkd3d: Add punchthrough path for descriptor copies.
Proves out the viability of this style of implementation. Ideally we'd
have a more officially sanctioned way of doing similar things later :)

Unfortunately, the overhead removal is too great to ignore on target
platform. Makes use of a private (reserved) extension for now ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-04 13:34:18 +01:00
Hans-Kristian Arntzen 277f485321 vkd3d: Add private extension header.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-03-04 13:34:18 +01:00
Mike Blumenkrantz 1d76803aff vkd3d: optimize memory access pattern for sampler descriptors
this removes them from the bitscan path

Signed-off-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
2022-03-01 22:50:45 +01:00
Hans-Kristian Arntzen dc622fc715 vkd3d: Recycle command pools in Elden Ring.
Very churny.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 18:40:52 +01:00
Hans-Kristian Arntzen 9817c52d24 vkd3d: Add workaround to ignore mismatch driver/device in PSO library.
Elden Ring does not detect the proper error code and create a new
pipeline library. Instead, create a fresh new library, which works
around the issue.

The game has a pattern of LoadPipeline -> if fail -> CreatePSO ->
StorePipeline. Sometimes, in the same process it will LoadLibrary from
its own cache (could explain some stutters),
so it's very useful to have this either way.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 14:50:57 +01:00
Hans-Kristian Arntzen a8229390f9 vkd3d: Add more pipeline_library_log snippets.
Hook GetCachedBlob and various attempts to use LoadPipeline.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 14:50:57 +01:00
Hans-Kristian Arntzen 12c73ee18a swapchain: More gracefully handle SURFACE_LOST.
Just like handling min/maxImageExtent of 0, we can just fall back to
user buffers.

Elden Ring hits this case on application teardown.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 14:04:06 +01:00
Hans-Kristian Arntzen f39ece9a7c vkd3d: Enable performance workarounds for Elden Ring.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 13:59:08 +01:00
Hans-Kristian Arntzen c19eaac376 vkd3d: Add VKD3D_CONFIG option for command pool recycling.
Normal behaving apps should not benefit from any of this.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 13:59:08 +01:00
Hans-Kristian Arntzen 54fbadcc94 vkd3d: Recycle command pools.
Elden Ring in particular spam frees and allocates command pools despite
this being a very bad idea.

Add a simple 8-entry cache which seems to take care of it.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 13:59:08 +01:00
Hans-Kristian Arntzen 4b07535909 vkd3d: Optimize memory access pattern for single descriptor copies.
We can mark a descriptor as being SINGLE_DESCRIPTOR, which means we
only need one descriptor copy. This way, we can avoid doing somewhat
expensive work (every nanosecond counts here):

- Bitscan loop
- Read deep into d3d12_device guts (often a cache miss). The memory
  index depends on the bitscan, which causes bubble.

When we have a single descriptor, we can just store the binding
information inline and avoid this jank.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 13:04:43 +01:00
Hans-Kristian Arntzen 84d632f194 vkd3d: Rewrite memory layout for resource descriptors.
Tune memory layout so that we can deduce various information without
making a single pointer dereference:

- d3d12_descriptor_heap*
- heap offset
- Pointer to various side data structures we need to keep around.

Instead of having one big 64 byte data structure with tons of padding,
tune it down to 32 + 8 bytes per descriptor of extra dummy data.

To make all of this work, use a somewhat clever encoding scheme for CPU
VA where lower bits store number of active bits used to encode
descriptor offset. From there, we can mask away bits to recover
d3d12_descriptor_heap. Metadata is stored inline in one big allocation,
and we can just offset from there based on extracted log2i_ceil(descriptor count).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 13:04:43 +01:00
Hans-Kristian Arntzen b309913b6d vkd3d: Use unsafe_impl in CopyDescriptorsSimple.
This is an ultra-hot path and seems to show up somehow on profile.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 13:04:43 +01:00
Hans-Kristian Arntzen dc752991ef common: Add vkd3d_log2i_ceil.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-25 13:04:43 +01:00
Hans-Kristian Arntzen c29d005ef4 vkd3d: Don't enable fast descriptor copy path for descriptor QA.
The hooks are in the generic function.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-24 16:42:00 +01:00
Hans-Kristian Arntzen 8a46c21254 vkd3d: Add VKD3D_CONFIG to skip memory allocator clears.
For cases where games spam committed allocations and don't use
NOT_ZEROED. We still rely on zerovram behavior for initial backing which
should be enough in most cases.

Strictly speaking however, we are forced to clear the allocations every
time if application does not use the flag correctly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-24 12:52:05 +01:00
Hans-Kristian Arntzen 76ca492a39 vkd3d: Add some debug logging for when clear passes happen.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-24 12:52:05 +01:00
Hans-Kristian Arntzen 83c4e62660 vkd3d: Bump suballocation limit to 2 MiB.
This is a more principled limit since that's the huge page size.

Avoids some allocation spam.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-24 12:14:22 +01:00
Hans-Kristian Arntzen 4bea653504 vkd3d: Fix CopyTiles for suballocated linear resources.
Forgot to offset buffer offset. Fun!
Found when bumping VA allocation limit to 2 MiB instead of 1 MiB.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-24 12:14:22 +01:00
Hans-Kristian Arntzen edbf49aad4 vkd3d: Support opt-in to single MUTABLE set.
Useful for Intel since Intel hardware cannot support more than 1M
descriptors in general, and opting in to correct behavior should improve
CPU overhead as well when copying descriptors.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-21 17:08:25 +01:00
Hans-Kristian Arntzen e0af8f2810 vkd3d: Make error message for buffer alignment more direct.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-21 16:37:12 +01:00
Hans-Kristian Arntzen b066e72243 swapchain: Add env-var to override swapchain images.
For perf debug mostly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-21 16:36:36 +01:00
Hans-Kristian Arntzen 15704b2419 vkd3d: Optimize descriptor copies for common code paths.
The common path that we really need to optimize for is CBV_SRV_UAV +
Simple + 1 descriptor.

Descriptor benchmark shows an almost 50% reduction in overhead now.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-21 16:35:36 +01:00
Hans-Kristian Arntzen c725c29bb6 vkd3d: Inline query for set/binding from set_index.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-21 16:35:36 +01:00
Hans-Kristian Arntzen 2f6a91e772 vkd3d: De-virtualize query for descriptor size.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-21 16:35:36 +01:00
Hans-Kristian Arntzen 719a38a5fe tests: Add individual descriptor copy tests to descriptor benchmark.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-21 16:35:36 +01:00
Joshua Ashton 2278da339a build: Bump arch-mingw-github-action to v7
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2022-02-20 03:40:40 +00:00
Hans-Kristian Arntzen 1cc8afcc8e vkd3d: Fix potential crashes when VK_KHR_dynamic_rendering is added.
Checking for pNext here is too brittle and causes crashes when dynamic
rendering path is added.
Also need to chain in existing pNexts.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-17 11:27:25 +01:00
Hans-Kristian Arntzen 1112106db0 tests: Verify that runtime validates invalid PSO description for blob.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-17 11:00:03 +01:00
Hans-Kristian Arntzen 624bf53f8b tests: Verify that runtime must validate DXBC blob and RS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-17 11:00:03 +01:00
Hans-Kristian Arntzen b363d8d2e4 tests: Remove TODO from PSO library test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-17 11:00:03 +01:00
Hans-Kristian Arntzen 5d345f47cc vkd3d: Rewrite the pipeline library implementation.
This became basically a rewrite in the end, and it got too awkward to
split these commits in any meaningful way.

The goals here were primarily to:

- Support serializing SPIR-V and load SPIR-V.
  To do this robustly requires a lot more validation and checks to make
  sure end up compiling the same SPIR-V that we load from cache.
  This is critical for performance when games have primed their pipeline
  libraries and expect that loading a PSO should be fast. Without this,
  we will hit vkd3d-shader for every PSO, causing very long load times.
- Implement the required validation for mismatched PSO descriptions.
- Rewrite the binary layout of the pipeline library for flexibility
  concerns and performance.
  If the pipeline library is mmap-ed from disk - which appears to be
  the intended use - we only need to scan through the TOC to fully parse
  the library contents.
  From a flexibility concern, a blob needs to support inlined data,
  but a library can use referential links. We introduce separate
  hashmaps which store deduplicated SPIR-V and pipeline cache blobs,
  which significantly drop memory and storage requirements.
  For future improvements, it should be fairly easy to add information
  which lets us avoid SPIR-V or pipeline cache data altogether if
  relevant changes to Vulkan/drivers are made.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-17 11:00:03 +01:00
Georg Lehmann a078197e16 build: Avoid meson warning.
WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2022-02-11 16:21:52 +01:00
Krzysztof Bogacki 9029d1ae23 build: Merge Prepare and Build steps on Windows CI.
Signed-off-by: Krzysztof Bogacki <krzysztof.bogacki@leancode.pl>
2022-02-07 11:12:15 +01:00
Krzysztof Bogacki ae7081eb62 build: Use MSBuild backend on Windows CI.
Signed-off-by: Krzysztof Bogacki <krzysztof.bogacki@leancode.pl>
2022-02-07 11:12:15 +01:00
Hans-Kristian Arntzen 33f17cc74d vkd3d: Add VK_EXT_pipeline_creation_feedback.
Useful when used together with pipeline library logging. Confirms that
we can load pipeline caches as expected.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-04 14:31:34 +01:00
Hans-Kristian Arntzen 3b8265dccc common: Add a timedwait condvar API.
To be used for upcoming disk driver cache implementation which needs to
live on a thread.

Need a separate wrapper since pthread and SRWLock interface is quite
different. Similar rationale as rwlock_t.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-04 14:31:34 +01:00
Hans-Kristian Arntzen a2eddc181b common: Add f32/string hashing utils as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-04 14:31:34 +01:00
Hans-Kristian Arntzen 47337d5e0b vkd3d: Add VKD3D_CONFIG flags for various pipeline library logging.
Additionally, add option to ignore cached SPIR-V.
Will be useful for debugging, and also required for VKD3D_SHADER_OVERRIDE.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-04 14:31:34 +01:00
Hans-Kristian Arntzen f03940ef4b vkd3d: Add global_pipeline_cache option.
Avoids saving out pipeline cache blobs which are likely going to be
cached by on-disk cache anyways.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-04 14:31:34 +01:00
Hans-Kristian Arntzen e5e662ce22 vkd3d: Record root signature compatibility hashes.
For pipeline libraries and DXR to some extent later, we'll need an easy
way to compare root signature objects.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-04 14:31:34 +01:00
Hans-Kristian Arntzen bc3b25fb0e tests: Extend unbound RTV rendering test to cover invalidation of PSO.
Similar issue with this as with NULL DSV rendering test. We did not test
the scenario where RTV is bound, then it is not bound anymore with same
PSO.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-04 13:10:16 +01:00
Hans-Kristian Arntzen 05a5d366d5 tests: Test rendering to non-NULL DSV, then NULL DSV.
Uncovered CPU crash where we did not invalidate pipeline/render pass
properly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-04 13:10:16 +01:00
Hans-Kristian Arntzen 1d39c25a59 vkd3d: Properly invalidate pipeline when binding NULL DSV.
We did not test the scenario where we first render with depth enabled,
and then bind a NULL DSV with the same pipeline.
Also fix issues if we bind NULL RTVs with same pipeline bound.

Fixes crash in Guardians of the Galaxy.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-04 13:10:16 +01:00
Hans-Kristian Arntzen 5e526d506b vkd3d: Remove warning for setting NULL index buffer.
This is benign and easily gets spammed a TON.
We will warn if an indexed draw is actually made like this.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-03 18:16:36 +01:00
Hans-Kristian Arntzen 91ca2ed8ba tests: Mark COLOR -> STENCIL copy test as TODO.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-03 15:43:41 +01:00
Hans-Kristian Arntzen 2ca7ce62da tests: Add test for color <-> stencil copies.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-03 15:43:41 +01:00
Hans-Kristian Arntzen 907acce30c tests: Fix D3D12 validation error in copy_texture test.
Copy out of bounds now seems to trigger device lost.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-03 15:43:41 +01:00
Hans-Kristian Arntzen 8b92d8e0bc tests: Add test for copying single aspects between DS images.
Also fixes test bug where texture was sampled as float, despite having
uint aspect.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-03 15:43:41 +01:00
Hans-Kristian Arntzen 81a215d0bf vkd3d: Implement COLOR -> STENCIL copy if stencil export is supported.
Fallback is a bit more involved. Cleans up the FIXME to not report
benign issues.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-03 15:43:41 +01:00
Hans-Kristian Arntzen 29d956c6c4 vkd3d: Fix memory leak of D3D12 device singleton.
Fairly trivial, caught by ASAN.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-02 13:56:36 +01:00
Hans-Kristian Arntzen 49d0eb37e3 vkd3d: Properly align d3d12_command_list allocations.
UBSAN found a bug here since we store RTV descriptors inline, the
compiler can assume the pointer is 64 byte aligned.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-02 13:56:36 +01:00
Hans-Kristian Arntzen 1da9ad900c hashmap: Avoid redundant copy of entry data.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-02-02 13:56:36 +01:00
Philip Rebohle 8f81aaa710 vkd3d: Fix reporting of WriteBufferImmediateSupportFlags.
Oversight from when we added bundles.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-02-01 16:21:43 +01:00
Philip Rebohle 91976b2edd tests: Add mesh and amplification shader tests.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-01-28 17:06:30 +01:00
Philip Rebohle 6aa73b3d53 tests: Move pipeline stream structs to common header.
We'll need to use the CreatePipelineState API for more tests.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-01-28 17:06:30 +01:00
Krzysztof Bogacki ab47aaf36d build: Add workflow for MSVC builds
Signed-off-by: Krzysztof Bogacki <krzysztof.bogacki@leancode.pl>
2022-01-25 16:19:11 +00:00
Hans-Kristian Arntzen 833f56154c cache: Store shader interface key in pipeline library as well.
If we're going to create different SPIR-V files from what the
VkPipelineCache represents, it's meaningless to load it.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Hans-Kristian Arntzen 86f8f41490 vkd3d: Compute a global shader interface key for a D3D12 device.
This key represents the variations of SPIR-V which would be generated
from otherwise identical inputs like DXBC blobs and root signatures.

Typically, changing VKD3D_CONFIG flags or enabled extensions will affect
this key. This ensures that we will not attempt to use a cached SPIR-V
file unless we can trust that the SPIR-V interface will match.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Hans-Kristian Arntzen a3f1a0e3cd vkd3d-shader: Add mechanism to get vkd3d-shader implementation revision.
Not immediately useful, might be nuked later in development.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Hans-Kristian Arntzen e90b573896 vkd3d-shader: Use flag for vkd3d_shader_meta bools.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Hans-Kristian Arntzen 8196b85408 vkd3d-shader: Make vkd3d_shader_hash public.
Prepare for meta struct to be serialized to a cache.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Hans-Kristian Arntzen a2c1527acd vkd3d-shader: Reuse hashmap.h hasher for shader hash.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Hans-Kristian Arntzen 3839144848 vkd3d: Add FNV-1a hash util.
To be used for pipeline library hashing.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Hans-Kristian Arntzen 6e697a54b6 vkd3d: Add d3d12_cached_pipeline_state.
Wraps the D3D12 struct with a pipeline library handle.
This is needed if the blob contains references to external data,
which then needs to be resolved.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Hans-Kristian Arntzen 41c977d616 cache: Move cache implementation over to read-writer locks.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Hans-Kristian Arntzen 7da708ea69 vkd3d: Add an RW lock wrapper.
For longer-lived locks where spinlock is bad form. To be used for
pipeline library.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-25 14:07:07 +01:00
Georg Lehmann 2c76840ff8 meta: Update COPYING year.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2022-01-25 11:11:51 +01:00
Georg Lehmann 182ebd7e00 meta: Update AUTHORS.
git log --pretty="%aN" | sort | uniq > AUTHORS

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2022-01-25 11:11:51 +01:00
Georg Lehmann c69b73ffcf meta: Create a .mailmap file.
Replaces some of the github account name authors with their real name from
the Signed-off-by.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2022-01-25 11:11:51 +01:00
Hans-Kristian Arntzen 1409ebab1f vkd3d: Consider sparse buffers to alias any other buffer.
Technically cannot alias committed buffers, but 🤷 ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-20 15:14:27 +01:00
Hans-Kristian Arntzen 7d0743345a vkd3d: Remove useless buffer barrier tracking.
This copy is to a scratch buffer, which needs no tracking.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-20 15:14:27 +01:00
Hans-Kristian Arntzen 2b0a161a0d tests: Sanitize test_hull_shader_vertex_input_patch_constant_phase.
Was using w = 0.0, causing weird issues.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-19 17:10:19 +01:00
Philip Rebohle 1af62abfe7 vkd3d: Enable quirk for further UE4 shaders.
Fixes artifacts in The Ascent.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-01-19 16:49:42 +01:00
Hans-Kristian Arntzen 338157eb04 tests: Add test for overlapped buffer copies.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-19 14:44:33 +01:00
Hans-Kristian Arntzen 5c492e9e6c vkd3d: Handle overlapped transfer writes.
D3D12 expects drivers to implicitly synchronize transfer operations,
since there is no TRANSFER barrier ala UAV barriers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-19 14:44:33 +01:00
Hans-Kristian Arntzen 68ce4b4116 vkd3d: MSVC build fix.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-19 14:21:09 +01:00
Hans-Kristian Arntzen 0f46a8a7d5 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-14 16:09:16 +01:00
Hans-Kristian Arntzen 6cba8b9945 vkd3d: Workaround broken barriers in DEATHLOOP.
In DEATHLOOP, there is a render pass which renders out a simple image,
which is then directly followed by a compute dispatch, reading that
image. The image is still in RENDER_TARGET state, and color buffers are
*not* flushed properly on at least RADV, manifesting as a very
distracting glitch pattern. This is a game bug, but for the time being,
we have to workaround it, *sigh*.

For a simple workaround, we can detect patterns where we see these
events in succession:

- Color RT is started
- StateBefore == RENDER_TARGET is not observed
- Dispatch()

In particular, when entering the options menu, highly distracting
glitches are observed in the background.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-12 12:20:03 +01:00
Hans-Kristian Arntzen e5efa8594e tests: Remove RADV bugs which have been fixed.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-12 12:18:56 +01:00
Hans-Kristian Arntzen 39c1f9d07a tests: Add test for invalid (?) alias barrier behavior.
Verifies that aliasing barriers on their own do not trigger image layout
transitions.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-12 12:16:52 +01:00
Robin Kertels 35be1329ed vkd3d: Don't do layout transition in aliasing barrier.
HZD issues an aliasing barrier for an alias of a resource that it
still needs.
Because D3D12 requires you to call DiscardResource or a full resource
clear/copy, we can just rely on those to do the actual image layout
transition and treat the aliasing barrier as a pure sync + flush.

This behavior is also observed in a test case where D3D12 drivers
do not seem to discard / fast-clear anything in an aliasing barrier.

Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Co-authored-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-12 12:16:52 +01:00
Samuel Pitoiset f6a4e0fb71 vkd3d: Use VK_KHR_copy_commands2
Mesa RADV translates these legacy entrypoints to the 2 variants. Using
them directly will cost a bit less CPU cycles.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2022-01-12 12:06:06 +01:00
Samuel Pitoiset f6fe3e0183 vkd3d: Require VK_KHR_copy_commands2
This extension is trivial to implement for vendors and should be
widely supported.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2022-01-12 12:06:06 +01:00
Samuel Pitoiset 870dda927d vkd3d: Use VK_KHR_bind_memory2
Mesa RADV translates these legacy entrypoints to the 2 variants. Using
them directly will cost a bit less CPU cycles.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2022-01-12 12:06:06 +01:00
Samuel Pitoiset b42a7193fc vkd3d: Require VK_KHR_bind_memory2
This extension is trivial to implement for vendors and should be
widely supported.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2022-01-12 12:06:06 +01:00
Hans-Kristian Arntzen db943f2341 tests: Add DXIL test for FP32 -> FP16 conversions.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-12 12:04:49 +01:00
Hans-Kristian Arntzen 9162e82fb3 tests: Add DXBC test for f32tof16 behavior.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-12 12:04:49 +01:00
Hans-Kristian Arntzen d13424bf22 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2022-01-11 15:21:06 +01:00
Philip Rebohle 5923c53111 vkd3d: Only use VK_IMAGE_CREATE_EXTENDED_USAGE_BIT if necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-01-11 15:14:30 +01:00
Joshua Ashton bd2be76132 build: Update arch-mingw-github-action to v6 for test builds 2022-01-10 11:49:34 +00:00
Joshua Ashton d94fdd1ca9 build: Update arch-mingw-github-action to v6 2022-01-10 11:46:01 +00:00
Philip Rebohle 1354ecabb4 vkd3d: Consider query pool when merging query ranges.
Otherwise, we accidentally merge ranges from different pools if
the indices happen to align.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-01-06 14:27:36 +01:00
Hans-Kristian Arntzen c0a3fa8adc vkd3d: Attempt to create linear image without EXTENDED_USAGE.
NVIDIA drivers apparently cannot support EXTENDED_USAGE linear
images for whatever reason, so attempt to create these images without
the creation flag.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-12-03 12:47:09 +01:00
Hans-Kristian Arntzen 459cae5673 vkd3d: Fix redundant return from void.
Fix MSVC warning.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-12-02 22:48:48 +01:00
Hans-Kristian Arntzen 7502b4c4c8 vkd3d: Fix MSVC build.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-12-02 22:48:48 +01:00
Hans-Kristian Arntzen 18b31a73ec tests: Add additional test cases to minLOD test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-12-02 22:40:44 +01:00
Hans-Kristian Arntzen fffd6e935c vkd3d: Add R64_UINT to format compatibility list when needed.
For 64-bit image atomics, we should at the very least add 64-bit format
to compatibility list to avoid potential problems.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-12-02 22:40:32 +01:00
Hans-Kristian Arntzen 72f26c5699 vkd3d: Remove misleading FIXME.
We can bind texel buffers at scalar alignment now.
The warning is misleading for placed resources, since 64k never aligns
with a float3.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-12-02 22:40:21 +01:00
Arkadiusz Hiler 93d105adae vkd3d: Retry to create Vk device without NVX extensions.
The creation with those extensions may fail in few cases:
 * older 32 bit drivers
 * missing or inaccessible /dev/nvidia-uvm

There's also a mysterious crash that some Debian users experience with
64bit titles and a correct /dev/nvidia-uvm.

Signed-off-by: Arkadiusz Hiler <ahiler@codeweavers.com>
2021-12-02 12:44:37 +01:00
Hans-Kristian Arntzen 9c3549360d tests: Add more TODO for map_texture_validation.
NV really doesn't like linear images, huh ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-26 20:02:14 +01:00
Hans-Kristian Arntzen d2fd3de7c1 vkd3d: Handle somewhat common VkResult.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-26 20:02:14 +01:00
Hans-Kristian Arntzen d9636d5c67 vkd3d: Fix check for vkBindImageMemory.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-26 20:02:14 +01:00
Hans-Kristian Arntzen 2c80431003 tests: Remove TODO for MinLod test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-26 16:51:18 +01:00
Hans-Kristian Arntzen 9a59ded1c4 vkd3d: Simplify MinLod setup.
Only bother if we actually need to clamp LOD.
Simplifies some clamping logic as well.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-26 16:51:18 +01:00
Philip Rebohle f5a6d49e87 tests: Add test for clearing BGRA8 UAVs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-26 16:51:01 +01:00
Philip Rebohle a99914b6ea vkd3d: Fix clear color swizzle for various UAV formats.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-26 16:51:01 +01:00
Philip Rebohle 4000397570 vkd3d: Remove legacy format compatibility info.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-26 16:51:01 +01:00
Philip Rebohle 0de25ac3cd vkd3d: Do not use vkd3d_find_uint_format in ClearUAV.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-26 16:51:01 +01:00
Philip Rebohle ab111dcdbe vkd3d: Don't use vkd3d_get_typeless_format to determine shader copy usage.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-26 16:51:01 +01:00
Philip Rebohle 99d949f5fb vkd3d: Fix enablement of MUTABLE_FORMAT_BIT and EXTENDED_USAGE_BIT.
We previously did not take into account the new relaxed format compatibility
rules that we allow with CastingFullyTypedFormatSupported being supported.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-26 16:51:01 +01:00
Philip Rebohle 9624102dcb vkd3d: Rework format compatibility lists.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-26 16:51:01 +01:00
Philip Rebohle 42b8fc3338 vkd3d: Introduce new format compatibility table.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-26 16:51:01 +01:00
Hans-Kristian Arntzen 6a7eee33b5 tests: Remove obsolete format feature check.
BGRA8 UAV is allowed now.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-26 16:32:05 +01:00
Hans-Kristian Arntzen 8305ddec92 tests: Add test for various clear patterns with fully typed cast.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-26 15:56:43 +01:00
Hans-Kristian Arntzen 3c9b8cb040 tests: Add detailed meta-test for CastFullyTypedFormat.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-26 15:56:43 +01:00
Georg Lehmann 4240ab7559 vkd3d: Allow B8G8R8A8 UAVs.
This is now allowed according to
https://microsoft.github.io/DirectX-Specs/d3d/RelaxedCasting.html

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-11-24 15:15:14 +01:00
Hans-Kristian Arntzen 7391e38602 vkd3d: Fix some type errors after idl update.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-22 16:25:13 +01:00
Philip Rebohle 9185edb42a vkd3d: Implement ID3D12GraphicsCommandList6.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-19 14:57:51 +01:00
Philip Rebohle b03c1fcb5f vkd3d: Implement ID3D12Device9.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-19 14:57:51 +01:00
Philip Rebohle 3b6a4ab988 vkd3d: Implement ID3D12Device8 and ID3D12Resource2.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-19 14:57:51 +01:00
Philip Rebohle d61f562a3e vkd3d: Implement ID3D12Device7.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-19 14:57:51 +01:00
Philip Rebohle 930e7cb251 idl: Add new interfaces up to ID3D12Device9.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-19 14:57:51 +01:00
Hans-Kristian Arntzen 6ad67bdecd dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-18 14:05:20 +01:00
Joshua Ashton 046524f2a1 vkd3d: Implement MinLODClamp using VK_EXT_image_view_min_lod
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-11-17 20:51:20 +01:00
Joshua Ashton 7241164e2d khronos: Update Vulkan headers.
Update to v1.2.199.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-11-17 20:51:20 +01:00
Hans-Kristian Arntzen 99e067d681 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-16 20:50:46 +01:00
Georg Lehmann 344f8d1ed4 tests: Fix various alignment warnings on 32bit clang.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-11-16 20:29:18 +01:00
Robin Kertels 19a1dce393 vkd3d: Set GetCopyableFootprints total_bytes late.
Halo Infinite uses &desc->Width for total_bytes.
We can't set total_bytes early because code after this relies on desc->Width.

Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
2021-11-16 11:53:18 +01:00
Hans-Kristian Arntzen 3fefc540c8 vkd3d: Handle 64KB_UNDEFINED_SWIZZLE.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-12 10:32:13 +01:00
Hans-Kristian Arntzen 16d8bae263 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-11 17:13:16 +01:00
Hans-Kristian Arntzen 0251b4045c dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-10 15:17:36 +01:00
Hans-Kristian Arntzen 54da1dc9b2 tests: Only test FP64 if device supports it.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 15:57:48 +01:00
Hans-Kristian Arntzen a0eb938c7f tests: Only check lower 24-bit when testing D24 copies.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 15:57:16 +01:00
Hans-Kristian Arntzen 2da535fbbf tests: Remove TODO from test_depth_stencil_test_no_dsv.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 15:56:45 +01:00
Hans-Kristian Arntzen 3937e1a298 vkd3d: Handle illegal rendering to NULL DSV.
Guardians of the Galaxy hits this case. Fallback is to disable depth
attachment entirely in a fallback pipeline.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 15:56:45 +01:00
Hans-Kristian Arntzen 45ae742526 vkd3d: Pretend that SSBO alignment on NV is 4 bytes.
The 16-byte requirement is kind of a lie. The real requirement is tied
to how vectorized load-store instructions are emitted in the shader
itself since I guess it allows compiler to assume something about
alignment of the base pointer.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 14:47:10 +01:00
Hans-Kristian Arntzen b53a4a98a6 vkd3d: Enable per component robustness on AMD.
Tested and verified to work as expected, not so much on NV.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 14:47:10 +01:00
Hans-Kristian Arntzen 3210832ad9 vkd3d: Enable VK_EXT_scalar_block_layout.
dxil-spirv can take advantage of this now.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 14:47:10 +01:00
Hans-Kristian Arntzen 58aab78a5b vkd3d-shader: Add PER_COMPONENT_ROBUSTNESS shader extension.
Signals that we can use vectorized vec3 byte address buffers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 14:47:10 +01:00
Hans-Kristian Arntzen e605d19ef7 vkd3d-shader: Add shader extension for scalar block layout.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 14:47:10 +01:00
Hans-Kristian Arntzen 7986e241f3 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 14:47:10 +01:00
Hans-Kristian Arntzen 164273521f tests: Add test for vectorized byte address buffers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-09 14:47:10 +01:00
Hans-Kristian Arntzen db89d403d6 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-02 17:51:39 +01:00
Hans-Kristian Arntzen 35d2f1e87f vkd3d: Correctly check for SM 6.6 required features.
Remove the experimental flag and unconditionally enable SM 6.6 if
available.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen 2b11c70129 vkd3d: Hook up WaveSize implementation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen 6966cd2f33 vkd3d-shader: Reflect CS WaveSize.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen 7cc435c0bc vkd3d: Enable feature bits for 64-bit atomics.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen de64ebd1d1 vkd3d: Expose Int64 feature.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen 23ad0247e3 vkd3d: Enable 64-bit atomics extensions.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen a392e82d1c tests: Add test for SM 6.6 packed intrinsics.
To get any performance out of these, we require Int8, which is
fortunately widely supported.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen 570ecd5f79 tests: Add SM 6.6 WaveSize test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen 1d99a80f22 tests: Add test for SM 6.6 IsHelperLane().
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen b47282e78a tests: Add test for SM 6.6 64-bit atomics.
Tests all major scenarios:
- Root descriptor
- Table
- Typed
- Groupshared

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen cd2218e9c3 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen 6255eaec32 vkd3d: Stub out the more recent FEATURE_DATA structs.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
Hans-Kristian Arntzen daa96ba879 idl: Add new OPTIONS feature structs.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-11-01 14:20:38 +01:00
David Gow 2a8b5471ca vkd3d: Handle D3D12_APPEND_ALIGNED_ELEMENT for <4 byte wide elements
In d3d12, input element alignment needs to be the _minimum_ of 4 and the size of
the type. See the D3D11 spec, section 4.4.6, which behaves similarly:
https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#4.4.6%20Element%20Alignment

This is correctly taken into account when generating, e.g., the
vertex_buffer_stride_align_mask used for validation, but is not taken
into account when D3D12_APPEND_ALIGNED_ELEMENT is used to automatically
place input elements. Currently, vkd3d always assumes the alignment is
4.

This means that, for example, bytes or shorts should be packed tightly
together when D3D12_APPEND_ALIGNED_ELEMENT is used, but are instead
padded to 4 bytes.

Fixing this makes units appear in Age of Empires IV (see vkd3d-proton
issue #880 for examples.)

Signed-off-by: David Gow <david@ingeniumdigital.com>
2021-11-01 13:30:04 +01:00
Robin Kertels 430c77d3b3 vkd3d: Don't add xfb struct to rasterization state when NumEntries is 0.
Wine VKD3D version of my original commit.

Co-authored-by: Conor McCarthy <cmccarthy@codeweavers.com>

Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
2021-10-29 18:06:31 +02:00
Hans-Kristian Arntzen c20852435d tests: Add tests for SM 6.6 compute derivatives.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-27 17:00:33 +02:00
Hans-Kristian Arntzen cd04aa63e6 tests: Test semantics for quad ops in SM 6.6.
Depending on the shader model used, quads are assigned to lanes differently.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-27 17:00:33 +02:00
Hans-Kristian Arntzen 85c75a042f vkd3d: Enable VK_NV_compute_shader_derivatives.
Supported on more implementations too :)

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-27 17:00:33 +02:00
Hans-Kristian Arntzen 30436436cd dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-27 17:00:33 +02:00
Georg Lehmann eb48213bfa vkd3d: Follow the new shaderStorageImage{Read, Write}WithoutFormat rules.
The Vulkan spec update 1.2.195 restricted these features to a very limited
format subset, and somehow this is supposed to not be an API break?
Anyway, let's follow the new rules.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-10-27 17:00:21 +02:00
Georg Lehmann fd690e3831 vkd3d: Enable typed uav loads based on KHR_format_feature_flags2.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-10-27 17:00:21 +02:00
Georg Lehmann 07d53a82cc vkd3d: Init shader extensions later.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-10-27 17:00:21 +02:00
Georg Lehmann 4c37b4c341 vkd3d: Use vkGetPhysicalDeviceFormatProperties2.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-10-27 17:00:21 +02:00
Georg Lehmann c8d633cb51 vkd3d: Enable VK_KHR_format_feature_flags2.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-10-27 17:00:21 +02:00
Hans-Kristian Arntzen 8ff91b23d6 vkd3d-shader: Hook up global descriptor heap for DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-26 15:32:36 +02:00
Hans-Kristian Arntzen aadccb66cf vkd3d: Add more root signature flags to the list of flags we recognize.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-26 15:32:36 +02:00
Hans-Kristian Arntzen 8977eaef88 vkd3d: Initialize global heap bindings for SM 6.6.
Refactor code which emits SRV/UAV bindings to common code.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-26 15:32:36 +02:00
Hans-Kristian Arntzen cbef48f90a vkd3d: Refactor out how binding counts are parsed.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-26 15:32:36 +02:00
Hans-Kristian Arntzen 6548e4fd00 vkd3d: Add VKD3D_CONFIG for experimentally enabling SM 6.6.
To be used for bringup and removed when we complete the support.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-26 15:32:36 +02:00
Hans-Kristian Arntzen ae185271ff tests: Add SM 6.6 bindless heap test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-26 15:32:36 +02:00
Hans-Kristian Arntzen 1a57aa841a idl: Add new SM 6.6 root signature flags.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-26 15:32:36 +02:00
Hans-Kristian Arntzen e74213c576 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-26 15:32:36 +02:00
Danylo Piliaiev f6c61a3eae tests: Use 4 samples in test_shader_get_render_target_sample_count
Spec for CheckMultisampleQualityLevels says:
 "FEATURE_LEVEL_11_0 devices are required to support 4x MSAA for all
  render target formats, and 8x MSAA for all render target formats
  except R32G32B32A32 formats."

Test uses R32G32B32A32_FLOAT and since we don't check if this format
supports 8x MSAA, reduce MSAA to the minimum required by spec.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
2021-10-26 10:35:30 +02:00
Hans-Kristian Arntzen 5657f79974 tests: Test that buffer -> DS copies RowPitch is handled correctly.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-20 15:48:12 +02:00
Hans-Kristian Arntzen a0a29bae43 vkd3d: Use correct formats for image -> buffer copies.
Need to use placed format explicitly if we're copying planar resources.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-20 15:48:12 +02:00
ifedorov 0abe8a21dd Fixed row length calculation in CopyTextureRegion()
Signed-off-by: Ivan Fedorov <ifedorov@nvidia.com>
2021-10-20 14:28:35 +02:00
Hans-Kristian Arntzen 9a1b7ab002 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-20 14:12:50 +02:00
Hans-Kristian Arntzen 55e16539db meta: Update Meson build version to 2.5.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 17:31:03 +02:00
Philip Rebohle 9477d4af3d meta: Add Anno fix to change log.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-10-18 17:29:29 +02:00
Hans-Kristian Arntzen d4dfccece9 meta: Update CHANGELOG for 2.5.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 17:25:45 +02:00
Philip Rebohle 890ba87a7c vkd3d-shader: Merge i/o variables using the same location.
Fixes a number of issues observed in tessellation shaders,
and potentially geometry shaders, when inputs and/or outputs
are array variables.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-10-18 17:25:18 +02:00
Hans-Kristian Arntzen 740e23ea8a vkd3d: Add VKD3D_CONFIG to force non-invariant position.
It's common enough that new games break on RDNA2 because of this that we
should enable this by default. This matches DXVK behavior.

SOTTR gets a special weird exception, just like DXVK. The shaders are
broken enough that the proper fix is actually precise, not invariant.
This will be addressed at some later point.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 15:51:20 +02:00
Hans-Kristian Arntzen be8d6ec7ad vkd3d: Make global quirks info struct a value.
Allows us to fiddle with it after the fact.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 15:51:20 +02:00
Hans-Kristian Arntzen 26bd08bbde vkd3d-shader: Add global quirks for vkd3d_shader_quirk_info.
Will be used for VKD3D_CONFIG overrides.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 15:51:20 +02:00
Hans-Kristian Arntzen 32c5abf496 vkd3d-shader: Add INVARIANT_POSITION quirk.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 15:51:20 +02:00
Hans-Kristian Arntzen 2152500014 vkd3d-shader: Refactor out quirk selection.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 15:51:20 +02:00
Hans-Kristian Arntzen 4a774f872c dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 15:51:20 +02:00
Hans-Kristian Arntzen 3b415dbc89 vkd3d: Don't spam error if ReleaseSemaphore fails.
This function fails if the counter overflows.
CP77 hits this case a lot and we should just warn the specific failure
instead of a random error.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 14:58:49 +02:00
Hans-Kristian Arntzen dda02faf89 vkd3d: Pad reserved resources to 64k alignment.
Fix GPU crashes when attempting to bind non-aligned reserved resource.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-18 14:58:34 +02:00
Hans-Kristian Arntzen c3a92a0dad tests: Test more weird GetResourceTiling edge cases.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-15 15:12:41 +02:00
Hans-Kristian Arntzen 8beb7dde89 vkd3d: Handle NULL pointers in GetResourceTiling in more places.
DEATHLOOP uses all NULL at some point ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-15 15:12:41 +02:00
Philip Rebohle dd23492348 vkd3d: Reduce memset overhead for query map.
Potentially reduces the size of the query map, and makes each entry
versioned so that we no longer have to clear the entire map for multiple
dispatches even if it is sparsely populated.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-10-14 17:48:13 +02:00
Hans-Kristian Arntzen 0c60791bb1 vkd3d: Pass down PrimitiveCulling extension to vkd3d-shader.
DXR 1.1 only feature.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen f98702603d vkd3d-shader: Add SPIR-V extension for PrimitiveCulling.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen 1417eb6244 tests: Add test for RayQuery.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen ae204143d5 tests: Add test for RTPSO side TRI/AABB culling.
DXR 1.1 feature.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen 3b0a430975 tests: Test various interaction with TraceRay flags.
Also test DXR 1.1 SKIP_TRIANGLES/AABB.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen e522053954 tests: Test more advanced RT geometry and shaders.
Add basic test for intersection + anyhit + AABB primitives.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen 1c0b760b7d tests: Add tier parameter to RT context creation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen 6866b45637 vkd3d: Add CONFIG flag for enabling DXR 1.1.
We cannot support ExecuteIndirect with TraceRays() for time being.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen e6836c6255 vkd3d: Support RTPSO CONFIG1 flags.
DXR 1.1 and requires PrimitiveCullingFlags feature.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen 105882466b vkd3d: Validate that we cannot mix and match geom types in BLAS.
Runtime will error out and return 0 size.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen a3202444c8 vkd3d: Fix stack deduction for anyhit shaders.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 16:04:30 +02:00
Hans-Kristian Arntzen a36b987bf1 vkd3d: Add static pipeline variant flag to pipeline key.
If we need to fallback in both VRS and non-VRS scenarios, we need to key
on it. Fixes segfault in DIRT5 when toggling VRS.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 12:35:58 +02:00
Hans-Kristian Arntzen 3182882e21 d3d12: Do not export ordinals for most symbols.
The ordinals except for D3D12CreateDevice and GetDebugInterface are not
part of the ABI apparently.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-12 11:09:16 +01:00
Hans-Kristian Arntzen 99365bcaec vkd3d: Enable VK_NV_fragment_shader_barycentric.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-11 13:53:19 +01:00
Hans-Kristian Arntzen 158deeff22 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-11 13:29:49 +02:00
Hans-Kristian Arntzen 1ca9ec7284 tests: Add test for local root signature static samplers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen 08a7d7a165 vkd3d: Bind local root signature static set.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen d83ce4392b vkd3d: Check root signature associations in hit groups as well.
If we don't find a clear association to an entry point,
we can also find it in the hit group.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen c672429c70 vkd3d: Fix demangling of RT entry points.
Digits are of course also valid identifiers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen 235541ace5 vkd3d: Build local static sampler set/pipeline layouts and allocate set.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen f605b88e90 vkd3d: Make some RS related functions non-static.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen 90d52abe94 vkd3d: Parse local RS static samplers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen 74f62784e4 vkd3d: Cleanup redundant parameter_count assignment.
parameter_count == NumParameters for local RS since
hoisting is explicitly ignored for those.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen 393ef6261b vkd3d: Add local root signature objects to RTPSO.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen 6802d9e5a3 vkd3d: Add helper to create augmented pipeline layout.
For local root signature static samplers, this is handy.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen 67be905421 vkd3d: Bump max number of descriptor sets.
Need one potentially for local root signature static samplers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen b661c9b8ba vkd3d: Store set layout array in root signature.
With RTPSOs we might have to create static sampler sets for local root
signatures. In this case we will have to create a compatible pipeline
layout which is equal to global pipeline layout, except for an extra
set.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 11:51:47 +02:00
Hans-Kristian Arntzen ac9d98b2b4 tests: Verify that we can use UPDATE mode in PrebuildInfo.
As expected, the flag is ignored unless we're actually building.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 07:21:47 +01:00
Hans-Kristian Arntzen 1e42acf492 vkd3d: Allow BUILD_MODE_UPDATE in PrebuildInfo check.
Metro Exodus Enhanced Edition hits this a lot.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-08 07:21:47 +01:00
Hans-Kristian Arntzen 4244441aca tests: Test that we can pass in NULL to ppData in CreatePipelineLibrary.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 17:55:57 +02:00
Hans-Kristian Arntzen 0f2e448659 vkd3d: Handle CreatePipelineLibrary with NULL ppData.
Supposed to return S_FALSE.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 17:55:57 +02:00
Hans-Kristian Arntzen c58edfabe1 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 16:03:16 +02:00
Hans-Kristian Arntzen ab4e847e74 renderdoc: Add global capture support.
Useful for test suite since a test can be comprised of several smaller
submissions, and it's easier to debug if we have one trace.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:33:06 +02:00
Hans-Kristian Arntzen 385c3dc012 vkd3d: Add bug reference for split fallback types.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:32:54 +02:00
Hans-Kristian Arntzen d74cfe1883 tests: Add stress test for allocating RT/DS heaps.
Without a specific workaround, we will fail this test on NV.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:32:54 +02:00
Hans-Kristian Arntzen a2f350117f tests: Add simple stress test for UPLOAD allocation.
Try to allocate a lot of memory at once. Useful for seeing if fallbacks
work as intended.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:32:54 +02:00
Hans-Kristian Arntzen 26dc9e7da5 vkd3d: Allow CreateHeap to fail in certain fallback situations.
If we deduce that fallback heap allocation is impossible, we will accept
this, and defer allocation to CreatePlacedResource() instead where we make a committed resource.
This breaks aliasing, but in practice, this situation will only arise for render
targets, and it's not like we have a choice in the matter here on NV :\

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:32:54 +02:00
Hans-Kristian Arntzen 7ee8eac818 vkd3d: Add allocation flag for DEDICATED.
When allocating dedicated memory, ignore heap_flag requirements we
deduce from memory info. Any memory type is allowed. This is important
on NV when allocating fallback render targets.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:32:54 +02:00
Hans-Kristian Arntzen cddb98acc6 vkd3d: Consider that we might attempt to free NULL memory.
For deferred heaps, we will accept NULL allocations.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:32:54 +02:00
Hans-Kristian Arntzen 4075809a91 vkd3d: Make error message more precise when failing to allocate memory.
There are situations where we cannot fallback to system memory, so don't
log that we're going to do so.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:32:54 +02:00
Hans-Kristian Arntzen 9065f312d5 vkd3d: Refactor out validation of CUSTOM heap types.
Don't attempt to enter memory allocation when we can invalidate a heap
allocation up front. Avoids some dumb edge cases later.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:32:54 +02:00
Hans-Kristian Arntzen 9415191111 vkd3d: Add LOG_MEMORY_BUDGET logging for non-budget as well.
Useful to be able to debug which allocations happen.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-07 15:32:54 +02:00
Joshua Ashton c9ff20d4ac vkd3d: Make a generic UE4 shader quirk collection
Many UE4 games have this broken bloom shader that samples a texture with implicit lod in divergent control flow.

Fixes Bus Simulator 21

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-10-07 10:18:47 +01:00
Joshua Ashton 7a66669e92 vkd3d: Add empty element to shader quirks
If we ever remove these, we need this for MSVC.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-10-07 10:18:47 +01:00
Joshua Ashton d91d47d827 vkd3d: Use vkd3d_string_compare for shader quirks
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-10-07 10:18:47 +01:00
Joshua Ashton 70ee02bce0 vkd3d: Use vkd3d_string_compare for application overrides
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-10-07 10:18:47 +01:00
Joshua Ashton 4c959c8a77 vkd3d: Add vkd3d_string_compare helper
Compares a string with a given comparison mode.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-10-07 10:18:47 +01:00
Joshua Ashton 6dbb4f6dfe vkd3d: Add vkd3d_string_ends_with helper
Checks if a string ends with another string.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-10-07 10:18:47 +01:00
Hans-Kristian Arntzen 0f802b151e vkd3d-shader: Avoid undefined result for Ibfe/Ubfe/Bfi.
Width + offset must not overflow in SPIR-V. SM 5+ is well-defined here.
It's enough to just clamp the width against 32 - offset in all cases.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-05 15:45:02 +02:00
Hans-Kristian Arntzen cd3d759b95 vkd3d: Enable VK_KHR_shader_integer_dot_product.
Accelerates SM 6.4 packed ops if present.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-05 15:38:59 +02:00
Hans-Kristian Arntzen 50d41d8f02 khronos: Update SPIR-V and Vulkan headers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-05 15:38:59 +02:00
Hans-Kristian Arntzen f58b23e8e7 tests: Verify that integer dot products do not saturate.
SPIR-V has a saturating and non-saturating variant, so to be sure ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-05 15:38:59 +02:00
Hans-Kristian Arntzen 807232ceff dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-05 14:49:49 +02:00
Danylo Piliaiev 77c67e2bf5 vkd3d: Use 64bit atomics on all 64bit platforms
Previous check was not exhausting.

Closes: #830

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
2021-10-05 13:22:25 +02:00
Hans-Kristian Arntzen 4ff1166230 tests: Remove obsolete check for lack of wait-before-signal support.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-05 11:44:42 +02:00
Hans-Kristian Arntzen d9cd18b1ca vkd3d-shader: Handle vectorized FIRSTBIT_HI.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-01 16:23:52 +02:00
Hans-Kristian Arntzen 7b4423eee5 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-10-01 16:14:37 +02:00
Hans-Kristian Arntzen 4edd76d8bb tests: Fix validation error in test_null_rtv.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-30 16:50:02 +02:00
Hans-Kristian Arntzen 4f7e4ee753 tests: Add test for rendering to unbound RTV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-30 16:50:02 +02:00
Hans-Kristian Arntzen af822939fb vkd3d: Implement support for rendering to NULL/unbound RTV.
Need to use fallback pipeline system here.
Keep track of active masks for PSO and current render target.
The intersection of those sets are the attachments which should be
active in the render pass.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-30 16:50:02 +02:00
Hans-Kristian Arntzen b0f3512b8b tests: Add test for discarding UAVs in compute list.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-29 14:17:31 +02:00
Hans-Kristian Arntzen 173b565ccf vkd3d: Optimize DiscardResource when all subresources are discarded.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-29 14:17:31 +02:00
Hans-Kristian Arntzen 0b11fad67c vkd3d: Allow discarding UAV resources.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-29 14:17:31 +02:00
Hans-Kristian Arntzen 6f0677eb2e vkd3d: Refactor out queue flags -> stages conversion.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-29 14:17:31 +02:00
Hans-Kristian Arntzen 0c2ddb89cd vkd3d: Add CONFIG for forced CACHED memory.
Very useful for capturing. Speeds up a ton.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-27 14:48:26 +02:00
Hans-Kristian Arntzen 6863f1c6a8 vkd3d: Fix test suite regression on NV.
Fix failure in test_create_heap where a TIER_2 host visible heap was
attempted, but failed due to recent DEATHLOOP fixes.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-24 16:48:34 +02:00
Joshua Ashton bde3ad8e01 vkd3d: Move ID3D12StateObject impl_froms to header
Basic casts should not be function calls.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton cabc31fc4c vkd3d: Move ID3D12Device impl_froms to header
Basic casts should not be function calls.
2021-09-23 12:12:13 +02:00
Joshua Ashton bfaf72386f vkd3d: Move ID3D12CommandSignature impl_froms to header
Basic casts should not be function calls.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton b84c3ff163 vkd3d: Move ID3D12PipelineState impl_froms to header
Basic casts should not be function calls.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton 7c993ae1a6 vkd3d: Move ID3D12RootSignature impl_froms to header
Basic casts should not be function calls.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton 875fbe5f50 vkd3d: Move ID3D12QueryHeap impl_froms to header
Basic casts should not be function calls.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton 2334c136e3 vkd3d: Move ID3D12DescriptorHeap impl_froms to header
Basic casts should not be function calls.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton 8d5308c9a1 vkd3d: Move ID3D12Resource impl_froms to header
Basic casts should not be function calls.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton 27e66b5c4a vkd3d: Move ID3D12Heap impl_froms to header
Basic casts should not be function calls.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton 26d8011b06 vkd3d: Move ID3D12Fence impl_froms to header
Basic casts should not be function calls.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton e597adb83a vkd3d: Move d3d12_query_heap_type_get_data_size to header
This should be inlined.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Joshua Ashton 3b3bd37f93 vkd3d: Avoid tracking + ending render passes when calling ResolveQueryData with 0 queries
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-23 12:12:13 +02:00
Conor McCarthy da8daa860b tests: Add test for SampleDesc.Count == 0 in test_create_committed_resource().
Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
2021-09-23 11:00:04 +01:00
Conor McCarthy 446c7423ce vkd3d: Return E_INVALIDARG for texture creation if SampleDesc.Count == 0.
Windows returns E_INVALIDARG at least on AMD and Intel.
Psychonaughts 2 seems to use this as a de facto "do not create"
value, and reasonable vram usage depends on the call failing.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
2021-09-23 11:00:04 +01:00
Conor McCarthy d366ba47ac Revert "vkd3d: Support SAMPLE_DESC.Count of 0"
Windows returns E_INVALIDARG in this case.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
2021-09-23 11:00:04 +01:00
Georg Lehmann cf4fb44629 vkd3d: Remove almost unused variable.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-09-21 11:22:34 +01:00
Georg Lehmann edeb0658b7 vkd3d: Fix memory leak on failure.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-09-21 11:22:34 +01:00
Georg Lehmann 0afa6732ad vkd3d: Cleanup weird assignment.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-09-21 11:22:34 +01:00
Georg Lehmann 1946e42367 vkd3d-shader: Fix use-after-free on failure.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-09-21 11:22:34 +01:00
David McCloskey a19619ccbf vkd3d: Fixing compile errors on Windows. 2021-09-18 21:40:30 +01:00
Hans-Kristian Arntzen 173b8ecef0 vkd3d: Add workaround for DEATHLOOP.
Game attempts to create a host visible resource with
ALLOW_RENDER_TARGET flag. We cannot make this work on NVIDIA, but the
game never seems to actually create an RTV, so as a workaround, nop out
the flag, which does make it work after all :3

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-17 14:21:09 +02:00
Hans-Kristian Arntzen fa4d2182b1 vkd3d: Copy all aspects in CopyResource.
Just like we're promoting layer count, also promote aspect mask.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-17 14:21:09 +02:00
Hans-Kristian Arntzen 2b13d06f82 tests: Add test for how blending on integer RTVs are validated.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:57:28 +02:00
Hans-Kristian Arntzen e687d489ab vkd3d: Validate blend state against output signature.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:57:28 +02:00
Hans-Kristian Arntzen a4b082a828 vkd3d-shader: Add helper to parse output signature.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:57:28 +02:00
Hans-Kristian Arntzen 1d51818d8f vkd3d: Fix compile error introduced by bad rebase.
Somehow the rebase got really screwed up :\

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:42:30 +02:00
Hans-Kristian Arntzen a8f623e60d vkd3d: Negate upload_hvv config.
Enable resizable BAR style allocations by default, and add option to
disable it.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:10:57 +02:00
Hans-Kristian Arntzen 12066a2b67 vkd3d: Add debug config to log resizable BAR allocations.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:10:57 +02:00
Hans-Kristian Arntzen 710fa98918 vkd3d: Setup resizable bar budget.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:10:57 +02:00
Hans-Kristian Arntzen cec741706d vkd3d: Refactor out memory topology queries.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:10:57 +02:00
Hans-Kristian Arntzen abdaeb136d vkd3d: Add a memory budget per memory type.
For resizable BAR, we don't want to endlessly promote UPLOAD heaps to
BAR since VRAM is precious. The aim is to set a fixed budget where we
can keep allocating until full, at which point we fall back to plain HOST.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:10:57 +02:00
Hans-Kristian Arntzen e0451bb541 vkd3d: Handle fallbacks properly in suballocator.
With BAR budgets, what will happen is that
- Small allocation is requested
- A new chunk is requested
- try_suballocate_memory will end up calling allocate_memory, which
  allocates a fallback memory type
- Subsequent small allocators will always end up allocating a new
  fallback memory block, never reusing existing blocks.
- System memory is rapidly exhausted once apps start hitting against
  budget.

The fix is to add flags which explicitly do not attempt to fallback
allocate. This makes it possible to handle fallbacks at the appropriate
level in try_suballocate_memory instead.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:10:57 +02:00
Hans-Kristian Arntzen cb94cfd10c vkd3d: Fix silly typo in global mask.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:10:57 +02:00
Hans-Kristian Arntzen 426cdc9218 vkd3d: Destroy GLOBAL_BUFFER for some early error out paths.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:10:57 +02:00
Hans-Kristian Arntzen 69d4f55219 vkd3d: Refactor VkDeviceMemory allocation to keep track of type/size.
We will need to consider some form of budgeting, so make sure that all
allocation and freeing is done in a central place.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 16:10:57 +02:00
Hans-Kristian Arntzen a590db2508 tests: Add test for host visible render target.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 15:35:57 +02:00
Hans-Kristian Arntzen d402255349 tests: Add reduced test for ReadWriteSubresource to 2D images.
3D linear images are not well supported.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 15:35:57 +02:00
Hans-Kristian Arntzen b4521ebbd8 tests: Add tests for various ways to map 2D textures.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 15:35:57 +02:00
Hans-Kristian Arntzen 8d49d3e9ae vkd3d: Add extra validation for mapping textures.
D3D12 validation layers complain if you try to map mipmapped 3D volumes
for ... some reason. The error is very explicit, so I assume it's
intentional :)

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 15:35:57 +02:00
Hans-Kristian Arntzen 9fd422a0fd vkd3d: Fix default layout check when using LINEAR tiled images.
Match behavior of d3d12_resource_pick_layout.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 15:35:57 +02:00
Hans-Kristian Arntzen 41295eff6c vkd3d: Consider CPU availibility when selecting memory types.
Need to consider that based on host visibility requirements, we need to
select either LINEAR or OPTIMAL image types, and those tiling modes can
have different memory requirements.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 15:35:57 +02:00
Hans-Kristian Arntzen 132638be67 vkd3d: Add more logging when linear image allocation fails.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 15:35:57 +02:00
Hans-Kristian Arntzen 50f2c35b44 vkd3d: Add stricter ROW_MAJOR texture validation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 15:35:57 +02:00
Hans-Kristian Arntzen 961fef84de vkd3d: Allow map of texture as long as ppData is NULL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-16 15:35:57 +02:00
Joshua Ashton 9c0fa91ca5 vkd3d: Add shader quirks for Psychonauts 2
Works around a game bug. It uses texture() inside divergent control flow.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-09-15 11:52:39 +02:00
Hans-Kristian Arntzen 3081887757 vkd3d: Add 12_2 to list of valid feature levels.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-14 21:18:29 +02:00
Hans-Kristian Arntzen 0e216b2b10 vkd3d: Narrow workaround for global pipeline cache.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-08 18:37:55 +02:00
Hans-Kristian Arntzen 11086a94e0 vkd3d: Add macros to parse/build NV driver versions.
The bit offsets are a bit different from Vulkan API.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-08 18:37:55 +02:00
Hans-Kristian Arntzen d2b3238b2d tests: Add tests for creating DS formats without ALLOW_DEPTH_STENCIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-07 13:31:28 +02:00
Hans-Kristian Arntzen fcaeca8d27 vkd3d: Allow typeless depth-stencil formats without ALLOW_DEPTH_STENCIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-07 13:31:28 +02:00
Hans-Kristian Arntzen 403d1f9743 vkd3d: Workaround huge memory overhead for individual VkPipelineCaches.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-07 13:21:54 +02:00
Hans-Kristian Arntzen b8f0cd6eb6 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-07 12:10:06 +02:00
Hans-Kristian Arntzen 1d5acef691 tests: Add test for footprint -> depth-stencil copy.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-06 17:00:51 +02:00
Hans-Kristian Arntzen a3267ba8e5 vkd3d: Fix copies between footprint and DS aspects.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-06 17:00:51 +02:00
Hans-Kristian Arntzen fa1d82e141 vkd3d: Fix regressions when introducing null-copy elision.
Need to initialize the set mask so that copies happen properly
on default-initialized descriptors. Also, move the current_null_type to
metadata so that it's properly copied on descriptor copy.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-03 12:24:26 +02:00
Rodrigo Locatti b4cb5a37f8 vkd3d: Optimize repeated null descriptor updates
There are titles clearing the same descriptors constantly.
This leads to unnecessary updates that can become costly.

This commit introduces a new flag to track when D3D12 descriptors are
not null, and skips clearing them if they are already null.
Descriptors are assumed to be null by default.

This fixes a performance regression introduced by
9983a1720f

Signed-off-by: Rodrigo Locatti <rlocatti@nvidia.com>
2021-09-02 21:21:34 +02:00
Philip Rebohle 7fea3527ed vkd3d: Remove deferred clears.
Emitting render pass clears while we're in the process of starting
a render pass overrides dsv layout tracking info.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-09-02 17:11:35 +02:00
Hans-Kristian Arntzen b05145b421 tests: Add test for depth testing against null DSV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-02 17:10:47 +02:00
Hans-Kristian Arntzen ff74ad0ec5 vkd3d: Skip draw call if doing depth test on null DSV.
D3D12 validation layer errors out, so unless we can prove that specific
behavior is relied upon, we should be okay to just ignore.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-02 17:10:47 +02:00
Hans-Kristian Arntzen b54a1a6c2b vkd3d: Fix MSVC build.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-02 16:56:39 +02:00
Hans-Kristian Arntzen 00e4397467 vkd3d: Ignore depth/stencil test if DSVFormat does not have that aspect.
Fix some validation errors in F1 2021.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-02 16:25:27 +02:00
Hans-Kristian Arntzen 6f8ebaae7e tests: Add test for planar footprints.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-02 12:21:22 +02:00
Hans-Kristian Arntzen bc9bd9c482 vkd3d: Fix member types in vkd3d_format.
No need to use size_t.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-02 12:21:22 +02:00
Hans-Kristian Arntzen 7b67de7d0e vkd3d: Generalize get_plane_footprints.
Get information directly from vkd3d_format and allow for subsampled
formats in the future.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-02 12:21:22 +02:00
Hans-Kristian Arntzen 3d5010555e vkd3d: Add d3d12_resource_desc_get_sub_resource_count.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-02 12:21:22 +02:00
Hans-Kristian Arntzen 5c2376faf5 vkd3d: Handle multiplanar formats in GetCopyableFootprints.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-02 12:21:22 +02:00
Hans-Kristian Arntzen b8881ff693 vkd3d-common: Log TID in Wine's format.
Allows us to stay sane when correlating logs.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-09-01 15:41:59 +02:00
Hans-Kristian Arntzen d9bdd515a4 tests: Check for Native16Bit support before testing dot2add.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-30 23:06:26 +02:00
Hans-Kristian Arntzen 566cf1ed78 tests: Rename get_rt_lib() to something that allows for more libs.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen 9a92d62465 tests: Use RT factory for main RT PSO as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen fb8d8616b7 tests: Introduce a factory for building RTPSO subobject lists.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen 6aecbe2482 tests: Refactor out RT collection creation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen dda18f0fcd tests: Hoist out helper function to create a complete RTAS.
Have a single helper function to create RTASes with X * Y quads.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen c1f848ed3b vkd3d: Only look at SourceRTAS when updating.
Be more robust against garbage inputs.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen af2d41f6f8 tests: Use helper functions to build top-level acceleration structures.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen 17d5984c2c tests: Add helpers for creating and copying RTASes.
Move bottom RTAS building over to new helpers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen 82db981b26 tests: Refactor out transform buffer creation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen 99d2e39dfa tests: Refactor out test geometry allocation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen 830b9ef4e3 tests: Refactor out RT DXIL library declaration.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
Hans-Kristian Arntzen d44d359a18 tests: Refactor out RT context creation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-28 12:16:42 +02:00
rochaudhari 0828aec4f6 vkd3d: Implement new interfaces required for DX12 DLSS support.
Adds ID3D12GraphicsCommandListExt and ID3D12DeviceExt interfaces.

Signed-off-by: Roshan Chaudhari <rochaudhari@nvidia.com>
2021-08-27 11:37:15 +02:00
Joshua Ashton e9f04e8e0e vkd3d: Support SAMPLE_DESC.Count of 0
Psychonauts 2 uses a SAMPLE_DESC.Count of 0 for some things, which
previously was forcing it down the MSAA alignment placement path.

Found from playing a native D3D12 apitrace back and seeing
the log spam.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-08-26 14:23:37 +02:00
Philip Rebohle 715eca1b95 vkd3d: Reimplement frame latency event as a semaphore.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-08-26 14:21:38 +02:00
Philip Rebohle fef30f5037 vkd3d: Support releasing semaphores from a D3D12 fence.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-08-26 14:21:38 +02:00
Joshua Ashton 68a035c605 vkd3d-shader: Fix vkd3d-compiler crash
Since we added validation here for FH4, this crashes now as vkd3d-compiler passes a NULL shader_interface_info.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-08-26 14:06:47 +02:00
Joshua Ashton 56e12d88ce vkd3d-shader: Fix multiple constant buffers with RAW_VA
Consider we have declarations of CB0 of size 36 and CB1 of size 153.
Previously we'd just return the struct of CB0 when accessing CB1 because it came first as we didn't consider the size.

Psychonauts 2 indexes into CB1 by constant values above 36.
There is no reason a compiler could not eliminate these reads as it is technically out of bounds for the underlying array type.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-08-26 14:05:52 +02:00
Hans-Kristian Arntzen 5ef3d4bff9 tests: Move test implementations to appropriate files.
Avoids crippling 50+ ksloc files which are impossible to navigate
efficiently. IDEs tend to give up on files these large and editors start
to chug hard.

This commit is essentially pure cut 'n paste, which is why it's all in
one large commit. There is little to no reason to attempt to split this
up into multiple smaller commits.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-26 14:05:23 +02:00
Hans-Kristian Arntzen c2473fb873 tests: Improve log quality.
Set test name equal to the test that is actually running, not a global
"d3d12" which isn't very useful for a case with multiple files since
line number alone isn't enough to know where to look.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-26 14:05:23 +02:00
Hans-Kristian Arntzen 1a7ea5e0a6 tests: Make tests extern.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-26 14:05:23 +02:00
Hans-Kristian Arntzen 195e1a3447 tests: Declare test prototypes in separate header.
Allows for moving test implementations to their own translation units.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-26 14:05:23 +02:00
Hans-Kristian Arntzen 4a6fba9f56 tests: Make some statics in headers extern.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-26 14:05:23 +02:00
Hans-Kristian Arntzen 9d5cf16fc3 tests: Move common test code to its own file.
Some ifdef jank required since the various headers declare the main function.
Some additional jank with INITGUID, otherwise we get multiple
declaration errors.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-26 14:05:23 +02:00
Hans-Kristian Arntzen f589462ab5 tests: Move math MATH defines to d3d12_crosstest.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-26 14:05:23 +02:00
Hans-Kristian Arntzen aaaac271bd tests: Make other entry points extern.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-26 14:05:23 +02:00
Hans-Kristian Arntzen 8c89dacf76 tests: Make common test functionality extern.
Prepares for a situation where tests can be spread across multiple
translation units.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-26 14:05:23 +02:00
Hans-Kristian Arntzen 7ff3ef2654 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-24 12:52:56 +02:00
Hans-Kristian Arntzen f3fd2bf70b vkd3d: Use BAR memory type for descriptor heap helpers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-23 13:24:43 +02:00
Hans-Kristian Arntzen 7e165238e6 vkd3d: Allow all memory types if UPLOAD_HVV is used.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-23 13:24:43 +02:00
Joshua Ashton 1b957a1f74 vkd3d: Add config to use host-visible vram for UPLOAD heap
Adds the "upload_hvv" config flag, which will make D3D12_HEAP_TYPE_UPLOAD attempt to use host-visible VRAM for allocations.

This takes advantage of large or resizable BAR if available.

I see a perf delta of 83-84 -> 92-94 (~12%) when using this in Horizon Zero Dawn.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-08-23 13:24:43 +02:00
Hans-Kristian Arntzen 05e31bfba9 vkd3d: Ensure we do not fallback device allocations to BAR.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-08-23 13:24:43 +02:00
Robin Kertels 76f37c3cbf vkd3d: Only disable raster based on SO stream if SO is used.
Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
2021-08-23 13:10:14 +02:00
Hans-Kristian Arntzen b2c99b035a vkd3d: Allow SM 6.2 on NV.
FloatControlProperties struct appears to be broken, and it does seem to
work just fine.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-30 15:19:35 +00:00
Hans-Kristian Arntzen 41d54e19f4 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-30 13:03:48 +02:00
Hans-Kristian Arntzen 093a8c49f3 vkd3d: Expose shader model 6.5.
WaveMatch and WaveMultiPrefix are implemented and pass test.
Other features are gated behind feature bits.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-29 20:42:32 +02:00
Hans-Kristian Arntzen 3c350ec0f5 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-29 20:42:32 +02:00
David McCloskey a2a7d78c27 vkd3d: Fixing CopyTextureRegion going out of bounds when src_box is null.
Signed-off-by: David McCloskey <davmcclo@gmail.com>
2021-07-29 17:28:52 +02:00
David McCloskey 155195ef99 tests: Adding test for crash caused by CopyTextureRegion with null source box from larger texture to smaller.
Signed-off-by: David McCloskey <davmcclo@gmail.com>
2021-07-29 17:28:52 +02:00
Hans-Kristian Arntzen 3f3162ab5f tests: Add test for fence signal with NULL event.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-29 17:21:20 +02:00
Hans-Kristian Arntzen e1bb5f3b77 vkd3d: Handle NULL event handles in ID3D12Fence::SetEvent*().
We need to block here for whatever reason.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-29 17:21:20 +02:00
Hans-Kristian Arntzen 455f00fe26 vkd3d: Log failures when signaling external events.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-29 17:21:20 +02:00
Hans-Kristian Arntzen 88978ab059 tests: Add SM 6.5 wave intrinsics test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-29 16:58:07 +02:00
Hans-Kristian Arntzen a7e77fa777 tests: Add test for SM 6.4 packed arithmetic instructions.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-28 15:28:19 +02:00
Hans-Kristian Arntzen 4d97efc9d4 tests: Add test for SM 6.2 FP32 denorm attribute.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-28 15:28:19 +02:00
Hans-Kristian Arntzen 435a087047 vkd3d: Rework how shader model versions are exposed.
From native testing, we can expose higher shader models if
cap bits features are not supported. E.g. Polaris exposes SM 6.5, even
when 16-bit and barycentrics are not supported.

With latest dxil-spirv updates we can support the required SM 6.4
features.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-28 15:28:19 +02:00
Hans-Kristian Arntzen 760e8e1565 tests: Add tests for FP16 and how features are handled.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-28 15:28:19 +02:00
Hans-Kristian Arntzen 5b013d0b02 vkd3d: Validate shader meta against features.
We're supposed to validate and fail compilation if certain features are
not supported.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-28 15:28:19 +02:00
Hans-Kristian Arntzen 5df4a5c083 vkd3d-shader: Add 16-bit feature usage to meta.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-28 15:28:19 +02:00
Hans-Kristian Arntzen ab9e99cbfa vkd3d: Check for Int16 capability as well as extended subgroup types when exposing 16-bit ops.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-28 15:28:19 +02:00
Hans-Kristian Arntzen 27e0ca9bc1 dxil-spirv: Update submodule.
Add support for SM 6.2 denorm, SM 6.4 packed arith intrinsics.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-28 14:53:11 +02:00
Hans-Kristian Arntzen 6fd564db91 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-21 16:10:49 +02:00
Hans-Kristian Arntzen 229db9008a tests: Add test for SV_Barycentrics.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-21 14:34:29 +02:00
Hans-Kristian Arntzen cafe99e223 meta: Update version to 2.4.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-08 15:06:39 +00:00
Joshua Ashton 1d23bdbab7 vkd3d: Don't store pointer to QA info when not building with QA
This is entirely unnecessary and a waste of space as it will never be used.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-07-08 16:52:58 +02:00
Joshua Ashton a53a7f8d7c vkd3d-shader: Restrict descriptor-qa extras and logic to VKD3D_ENABLE_DESCRIPTOR_QA
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-07-08 16:52:58 +02:00
Joshua Ashton 309fc817e8 vkd3d: Fix RT local root signature interface flags
This was passing through flags of the root signature not the shader interface flags of it.

Need to get the shader interface flags of the root signature instead.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-07-08 16:52:58 +02:00
Hans-Kristian Arntzen 9197625fbf meta: Update CHANGELOG for 2.4.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-08 14:50:33 +02:00
Hans-Kristian Arntzen 4ed8931401 tests: Add test for ResolveSubresourceRegion.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-08 13:54:05 +02:00
Hans-Kristian Arntzen 29a9ccd356 vkd3d: Basic implementation of ResolveSubresourceRegion.
Used by DIRT5.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-08 13:54:05 +02:00
Hans-Kristian Arntzen f3c3e53f7a vkd3d: Add resolve mode argument to resolve helper.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-08 13:54:05 +02:00
Hans-Kristian Arntzen 591d47a6c5 vkd3d: Refactor out ResolveSubresource.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-08 13:54:05 +02:00
Hans-Kristian Arntzen 732d1dd234 vkd3d-shader: Reflect patch vertex count for DXIL HS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:58:45 +02:00
Hans-Kristian Arntzen 4f3b4d1f79 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:58:45 +02:00
Hans-Kristian Arntzen 37e8f42f4a vkd3d: Move patch vertex count to meta struct.
Will make it easier to implement for DXIL.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:58:45 +02:00
Hans-Kristian Arntzen d19821ba84 vkd3d-shader: Change cs_workgroup_size type.
DXIL C API takes unsigned* not uint32_t*, avoid potential warnings.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:58:45 +02:00
Hans-Kristian Arntzen 3915090c12 vkd3d: Track depth-stencil image layouts over a command buffer.
Goal here is to avoid unnecessary image layout transitions when render
passes toggle depth-stencil PSO states. Since we cannot know which
states a resource is in, we have to be conservative, and assume that
shader reads *could* happen.

The best effort we can do is to detect when writes happen to a DSV
resource. In this scenario, we can deduce that the aspect cannot be
read, since DEPTH_WRITE | RESOURCE state is not allowed.

To make the tracking somewhat sane, we only promote to OPTIMAL if an
entire image's worth of subresources for a given aspect is transitioned.
The common case for depth-stencil images is 1 mip / 1 layer anyways.

Some other changes are required here:
- Instead of common_layout for the depth image, we need to consult the
  command list, which might promote the layout to optimal.
- We make use of render pass compatibility rules which state that we can
  change attachment reference layouts as well as initial/finalLayout.
  To make this change, a pipeline will fill in a
  vkd3d_render_pass_compat struct.
- A command list has a dsv_plane_optimal_mask which keeps track
  of the plane aspects we have promoted to OPTIMAL, and we know cannot
  be read by shaders.
  The desired optimal mask is (existing optimal | PSO write).
  The initial existing optimal is inherited from the command list's
  tracker.
- RTV/DSV/views no longer keep track of VkImageLayout. This is
  unnecessary since we always deduce image layout based on context.

Overall, this shows a massive gain in HZD benchmark (RADV, 1440p ultimate, ~16% FPS on RX 6800).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:45:46 +02:00
Hans-Kristian Arntzen 515ed7fbd1 vkd3d: Make sure memory is available before change image layout.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:45:46 +02:00
Hans-Kristian Arntzen 8f05ac298c vkd3d: Add implementation for plane optimal tracker.
Idea is to keep track of scenarios where we know a resource's aspect is
known to be in a OPTIMAL state. Based on this, we can override the image
layout from the common_layout in order to avoid unnecessary full
barriers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:45:46 +02:00
Hans-Kristian Arntzen 1288d0f9b1 vkd3d: Remove obsolete all_aspect parameter.
For copies, we can always use the intended aspects, since we have
separate DS layouts now.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:31:52 +02:00
Hans-Kristian Arntzen c29a2d1fa8 tests: Add test for COLOR -> DEPTH copies.
Only had DEPTH -> COLOR.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:31:52 +02:00
Hans-Kristian Arntzen 68ce7bd324 vkd3d: Handle separate DS layout for destination copies.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:31:52 +02:00
Hans-Kristian Arntzen fbe6f4a210 tests: Make sure that we exercise separate DS clears in test suite.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:31:52 +02:00
Hans-Kristian Arntzen 81d472242b vkd3d: Clear single depth-stencil aspect correctly.
When clearing a DSV, we must get aliasing guarantees, so we must
transition away from UNDEFINED. This is only possible when using
separate_ds_layouts and for render pass clears we need to use
renderpass2 mechanisms to do this.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 15:31:52 +02:00
Hans-Kristian Arntzen a87d086a39 tests: Update min_lod test with TODO which reflect existing impl.
An extension should be able to remove all the TODOs.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 12:50:23 +02:00
Hans-Kristian Arntzen 35c555c479 vkd3d: Use more correct fallback path for minLODClamp.
The clamp is absolute, not relative to baseMip. Also avoids validation
error and potential crash when LODClamp > numLevels.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 12:50:23 +02:00
Joshua Ashton a361bcb0f8 tests: Add a test for MinLODClamp
Signed-off-by: Joshua Ashton <joshua@froggi.es>
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-07 12:20:24 +02:00
Joshua Ashton 61ccdb9037 vkd3d: Make invalid RTV for attachment FIXME_ONCE
This spams constantly in Dirt 5.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-07-07 11:49:18 +02:00
Hans-Kristian Arntzen cf632186fd vkd3d: Add workaround for MinLODClamp.
Not correct, will need spec additions to handle it properly.
Fixes ground rendering in DIRT 5.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-06 16:45:19 +02:00
Hans-Kristian Arntzen 1e4628376f tests: Add test for VBV stride edge cases.
Verifies that AMD native driver behaves oddly with stride < offset
cases.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-06 15:29:51 +02:00
Hans-Kristian Arntzen 55bbea5d29 tests: Test depth-stencil discards as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-02 15:18:16 +02:00
Hans-Kristian Arntzen 3090ae01c1 vkd3d: Support discarding single aspects as required.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-02 15:18:16 +02:00
Hans-Kristian Arntzen 398724cd6e vkd3d: Require VK_KHR_separate_depth_stencil_layouts.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-02 15:18:16 +02:00
Hans-Kristian Arntzen 419790ac77 vkd3d: Add wave size workaround for GravityMark.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-02 15:15:42 +02:00
Hans-Kristian Arntzen 92c4f861e7 vkd3d-shader: Report CS workgroup size metadata.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-02 15:15:42 +02:00
Hans-Kristian Arntzen 17fd01a2c8 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-02 15:15:42 +02:00
Hans-Kristian Arntzen 7a00e56792 vkd3d: Handle multiple planes in d3d12_resource_get_subresource_count.
Separate out an explicit per_plane query for the cases where we need it.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-02 14:16:18 +02:00
rochaudhari be2362268c vkd3d: Return format2 information for d3d12_device_CheckFeatureSupport
Currently only format1 information is being returned for D3D12_FORMAT_SUPPORT.

Signed-off-by: Roshan Chaudhari <rochaudhari@nvidia.com>
2021-07-02 14:07:39 +02:00
Hans-Kristian Arntzen 33edd1b926 tests: Ensure we hit viewport count 0 case in test suite.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-01 13:53:19 +02:00
Hans-Kristian Arntzen 3ea20a91ad vkd3d: Handle zero viewports.
This can be used for rasterizer discard, just bind dummy viewport and
scissor.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-07-01 13:53:19 +02:00
Hans-Kristian Arntzen cb5283b6fb vkd3d: Allow dynamic vertex stride == 0 to go through.
Eliminates all late pipeline compiles in Scarlet Nexus DX12 (and several
other games).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-29 16:00:33 +02:00
Hans-Kristian Arntzen c1860a1ead vkd3d: Add VKD3D_CONFIG flags for forcing EXCLUSIVE queue modes.
Helps in some cases, but we cannot do this by default :(

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-29 12:24:24 +02:00
Joshua Ashton 5e3ec4337b vkd3d: Fix top-most handling when restoring from fullscreen
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-06-25 17:28:35 +02:00
Hans-Kristian Arntzen ba7c2b7c5f swapchain: Log window rects for leaving and entering fullscreen.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-25 08:01:26 -07:00
Paul Gofman ca2ae195fb swapchain: Update original_window_rect in d3d12_swapchain_SetFullscreenState().
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-25 08:01:26 -07:00
Hans-Kristian Arntzen 84f4b893ee swapchain: Use VK_CALL macro.
There's a mix and match of vk_procs-> and CALL conventions. Harmonize
this.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-25 15:18:27 +02:00
Hans-Kristian Arntzen b5023bab32 swapchain: Synchronize before resetting blit command buffer.
Randomly appears in GravityMark, odd that validation didn't find this in
other cases.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-25 15:18:27 +02:00
Hans-Kristian Arntzen 7c80c92304 vkd3d: Use ALLOW_VARYING_SUBGROUP_SIZE flag as appropriate.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-25 15:08:53 +02:00
Hans-Kristian Arntzen 12e0aa2a46 vkd3d-shader: Query if subgroup size is used.
Lets calling code know if it should use ALLOW_VARYING_SUBGROUP_SIZE.
To avoid too much churn on pipeline caches, only add the flag when
needed.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-25 15:08:53 +02:00
Hans-Kristian Arntzen d1286f5ae1 dxil-spirv: Add support for querying subgroup size usage.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-25 15:08:53 +02:00
Hans-Kristian Arntzen 8a82b718e4 tests: Remove TODO in stencil_export test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-24 16:22:24 +02:00
Hans-Kristian Arntzen cc324cadd1 dxil-spirv: Support SV_StencilRef.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-24 16:22:24 +02:00
Hans-Kristian Arntzen 27fdc39e67 vkd3d: Be more robust with out of bounds clear/discard rects.
GravityBench ends up using ClearView with too large dimensions.
This is a validation error in Vulkan, so just clamp the extents.

To make full rect detection a bit more robust, do a range check instead
of memcmp().

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-24 16:18:38 +02:00
Hans-Kristian Arntzen 0a732a3b27 tests: Add DXIL path to test_atomic_instructions.
It exercises root descriptor atomics, so it's useful.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-24 15:23:52 +02:00
Hans-Kristian Arntzen d0dd116bea dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-24 15:23:52 +02:00
Georg Lehmann a7922a7c85 vkd3d: Introduce vkd3d_internal_get_vk_format.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-06-24 12:55:17 +02:00
Georg Lehmann 0d9c7bc3ad vkd3d: Index formats by format.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-06-24 12:55:17 +02:00
Georg Lehmann c915f237e3 vkd3d: Index depth stencil formats by format.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-06-24 12:55:17 +02:00
Georg Lehmann 1af017c284 include: Add some new dxgi formats.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-06-24 12:55:17 +02:00
Hans-Kristian Arntzen c108bec58f vkd3d: Fix trivial indentation nit.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-22 14:41:09 +02:00
Hans-Kristian Arntzen 9900301886 vkd3d: Use read-write lock for fallback pipeline cache.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-22 14:41:09 +02:00
Hans-Kristian Arntzen bb723e859b vkd3d: Use read-write locks for render pass cache.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-22 14:41:09 +02:00
Hans-Kristian Arntzen 5fe135f3fb vkd3d: Ensure shader visibility happens for DEPTH_READ | RESOURCE scenarios.
If we're doing a layout transition of depth-stencil aspects, we need to ensure all potential
accesses are made visible.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-22 14:32:48 +02:00
Hans-Kristian Arntzen 8225edc726 vkd3d: Rewrite resource state implementation.
- Honor resource barriers for resource states which cannot automatically
  decay or promote. This includes COLOR_ATTACHMENT, UNORDERED_ACCESS and
  VRS image. If SIMULTANEOUS_ACCESS is used, we can still promote, and
  we handle that by setting common layout to GENERAL for these resources.

- Avoid redundant barriers in render passes since normal resource
  barriers will always make sure we are already in
  COLOR_ATTACHMENT_OPTIMAL.

- Do not force GENERAL layout if resource has UNORDERED_ACCESS flag set.
  As this is not a promotable state, we have to explicitly transition
  into it. I tested this on validation layers, where even COMMON state
  refuses to promote to UAV state. The exception here of course is
  SIMULTANOUS_ACCESS, but we handle that properly now.

- Verify that UAV or SIMULTANEOUS access is not used together with DSV
  state. This is explicitly banned in the API docs.

- Actually emit image barriers. Batch the image transitions as that's
  what D3D12 docs encourage app developers to do, and it also expects
  that drivers can optimize this. Ensure that we respect the in-order
  resource barrier rules by splitting batches if there are overlaps in
  the transitions.

- Ensure that correct image layout is used when clearing a suspended
  render pass attachment.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-22 14:32:48 +02:00
Hans-Kristian Arntzen 177679a766 vkd3d: Add VKD3D_RESOURCE_SIMULTANEOUS_ACCESS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-22 14:32:48 +02:00
Hans-Kristian Arntzen 02398c4eef vkd3d: Normalize depth-stencil layouts if only one aspect is used.
Avoid using the separate layouts if we're only using formats with one
aspects. This makes it more likely to match layouts with common layout,
and we can avoid awkward transition barriers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-22 14:32:48 +02:00
Philip Rebohle 014a3c0b94 vkd3d: Handle plane slice index in descriptor creation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-06-21 21:23:03 +02:00
Samuel Pitoiset bf04b324c6 vkd3d: remove few occurrences of RADV/ACO
We recently dropped this from Mesa because ACO is the default
compiler since August 2020, so it's implicit.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2021-06-18 16:11:26 +02:00
Samuel Pitoiset 72d9b322b8 vkd3d: reject creating a resource that is placed if the heap is too small
The spec is pretty clear that it's invalid usage. Return E_INVALIDARG
like native drivers.

This is a workaround for the inventory GPU hang with Cyberpunk 2077
which is actually a game bug. Luckily the game handles this error
properly.

The problem is that the game always assume that an image with 2 mips
is smaller than the same image but with 6 mips. This is not always
true if the swizzle mode is different and a recent Mesa update changed
that. Then the game creates a D3D12 heap that is too small and this
triggered a memory violation and then a GPU hang with RADV.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
2021-06-17 16:42:23 +02:00
Hans-Kristian Arntzen 1ea31701c5 vkd3d: Move F1 2020 workaround over to quirks system.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen 28c8a595fa vkd3d: Pass down shader quirks for Necromunda.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen cb61a4c83a vkd3d-shader: Implement sample explicit LOD override.
In control flow, we can force LOD 0.0 to avoid undefined result when
games sample with implicit LOD in non-quad uniform control flow.

Behavior on different implementations is:
- Helper lanes come to life and interpolate shader input.
- LOD is clamped to 0.0 in divergent control flow.

This hack is not safe in general, since we force 0.0 even when the
control flow is quad uniform.

This is the most practical solution for the problem for now.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen a08e493a3a vkd3d-shader: Add interface for shader workarounds.
Don't really have much of a choice for the short term. :\

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen 4c101a4e81 vkd3d-shader: Keep track of early returns.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen 9207d4f019 vkd3d: Ignore BlendEnable if write mask is 0.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:42:14 +02:00
Hans-Kristian Arntzen 8589a425fe vkd3d-shader: Emit NoContraction for MAD/DFMA.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 16:01:46 +02:00
Hans-Kristian Arntzen 5c971f216e vkd3d: Invalidate binding state on query resolve.
Fixes random broken AO in Necromunda on RADV.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 15:59:05 +02:00
Hans-Kristian Arntzen 7ab0846242 tests: Add test for placed resource runtime validation.
Runtime validates resource size.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-17 15:53:35 +02:00
Philip Rebohle 6d1d60e898 tests: Test tile mappings for 3D textures.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-06-14 15:53:33 +02:00
Philip Rebohle 14617a7bb2 tests: Test resource tiling for 3D textures.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-06-14 15:53:33 +02:00
Philip Rebohle b97a012787 vkd3d: Enable tiled resources tier 3.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-06-14 15:53:33 +02:00
Hans-Kristian Arntzen 42fb018d85 vkd3d: Fix leak of command pools on device destruction.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-11 15:17:45 +02:00
Hans-Kristian Arntzen d7843fa012 vkd3d: Fix potential deadlock in debug ring.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-11 11:04:38 +02:00
Hans-Kristian Arntzen 58854b0a9c vkd3d: Fix potential deadlock in descriptor QA checks.
If we destroy device right after creating it, we risk a deadlock.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-11 11:04:38 +02:00
Hans-Kristian Arntzen 76a8914d6b vkd3d: Add validation error workaround.
Our internal copy shaders are fine, but we get benign errors about
sample count being wrong since we alias descriptors.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-10 14:19:04 +02:00
Hans-Kristian Arntzen abe0995e88 vkd3d: Use correct allocation size for memory block.
We cannot use the memory requirement output, since we will zero-clear
memory with a size that might be larger than the VkBuffer size.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-10 14:16:01 +02:00
Hans-Kristian Arntzen fda8cba2b8 tests: Add missing resource barrier to some tests.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-10 13:57:32 +02:00
Hans-Kristian Arntzen 8056a71415 tests: Fix wrong resource state in test_bufinfo_instruction.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-10 13:57:32 +02:00
Hans-Kristian Arntzen 3c6174cafc tests: Fix type mismatch in test_draw_uav_only.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-10 13:57:32 +02:00
Hans-Kristian Arntzen b922292852 vkd3d: Fix view object leak when creating fallback UAV clear view.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-10 13:50:54 +02:00
rochaudhari 1699743c37 vkd3d: Enable binary import and image view handle extensions
Signed-off-by: Roshan Chaudhari <rochaudhari@nvidia.com>

Reviewed-by: Liam Middlebrook <lmiddlebrook@nvidia.com>
2021-06-10 11:26:34 +02:00
rochaudhari ba997f0736 vk-headers: Update subprojects/Vulkan-Headers to 1.2.180
This is needed for VK_NVX_binary_import and VK_NVX_image_view_handle.

Signed-off-by: Roshan Chaudhari <rochaudhari@nvidia.com>

Reviewed-by: Liam Middlebrook <lmiddlebrook@nvidia.com>
2021-06-10 11:26:34 +02:00
conor42 3b1f34217c vkd3d-shader: Fix a bug in constant double vector handling.
Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
2021-06-09 20:54:02 -07:00
conor42 2ad16f89d3 tests: Modify dadd test to use a double2 vector.
Tests a codepath in vkd3d_dxbc_compiler_get_constant() where
component_count != 1.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
2021-06-09 20:54:02 -07:00
Hans-Kristian Arntzen 20a96cab57 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-08 15:35:20 +02:00
Hans-Kristian Arntzen a09819250f tests: Add null descriptor mismatch type test.
Verifies that we splat null descriptors appropriately.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-07 13:21:31 +02:00
Hans-Kristian Arntzen 47f978fec3 tests: Test clearing a NULL UAV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-07 13:21:31 +02:00
Hans-Kristian Arntzen 9983a1720f vkd3d: Splat null descriptors to all sets.
Some games end up writing the wrong descriptor type when using null
descriptors, and to be robust against that, we have to clear out
all descriptors when creating null descriptors.

If we copy a null descriptor, we will also have to copy from all sets.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-07 13:21:31 +02:00
Hans-Kristian Arntzen 969776c1f8 vkd3d: Ignore NULL descriptor ClearUAV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-07 13:21:31 +02:00
Hans-Kristian Arntzen c7c17d05ed vkd3d: Fix descriptor QA checks for CBV_AS_SSBO.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-07 13:21:06 +02:00
Hans-Kristian Arntzen ec5b4ccecf vkd3d: Ensure that swapchain is eventually recreated.
Latch SUBOPTIMAL state.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-02 19:46:05 +02:00
Joshua Ashton efa0eccc59 vkd3d: Low latency presentation and acquire semaphores
In cases where acquire image is blocking, we should call that after
presentation to avoid latency when the app calls present.

This avoids weird inverse frame cadences with Mesa WSI right now,
as acquiring an image is always a blocking call until it is complete.

In cases when we aren't blocking, this kicks off the acquisition so
it can be waited upon by the next present blit pass.

Use another set of semaphores to wait for the image acquisition on the
GPU.

In the non-blocking vkAcquireNextImageKHR case, this means that a
potential bubble of time between waiting on the fence and submitting
the blit + presentation is eliminated.

Runaway presentation in this setup is avoided by frame latency objects
and normal frame latency which is always 3 according to documentation.

Be careful about handling SUBOPTIMAL. Semaphores will be signaled, but
we might want to tear down the swapchain. In these cases, we need to
wait for the semaphore to be signaled first, which can only be done by
submitting a wait, since QueueWaitIdle or DeviceWaitIdle don't cover
WSI.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Co-authored-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-02 19:46:05 +02:00
Joshua Ashton 92ed98ccea vkd3d: Handle frame latency without WAITABLE_OBJECT
Documentation says that this should always be 3 without WAITABLE_OBJECT
unlike in D3D11 where it will use the DXGI device's frame latency.

This stops runaway presentations in the non-blocking acquire image case
with the new semaphore setup.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-06-02 19:46:05 +02:00
Hans-Kristian Arntzen 6f5f55c84a vkd3d: Avoid oldSwapchain.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-06-02 19:46:05 +02:00
Hans-Kristian Arntzen 582138b063 tests: Fix Clear UAV test constant.
Was using 0x8000 / 0xffff instead of 0x200 / 0x3ff, rounded differently
on NV.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-28 17:42:00 +02:00
Hans-Kristian Arntzen 616538aa47 tests: Add missing UAV barrier in bindless counter test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-28 15:56:18 +02:00
Hans-Kristian Arntzen fee18f1820 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-28 15:41:49 +02:00
Hans-Kristian Arntzen a83c99ba77 vkd3d-shader: Don't apply offset buffers for non-bindless resources.
Fixes root descriptors when BDA support is disabled.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-27 23:30:51 +02:00
Hans-Kristian Arntzen 1a7b470681 tests: Add clear UAV test for RGB10A2 format.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-27 15:34:53 +02:00
Hans-Kristian Arntzen 32a2bd65f9 tests: Remove TODOs in ClearUAV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-27 15:34:53 +02:00
Hans-Kristian Arntzen fa471962dc vkd3d: Mask clear color in ClearUAVUint.
Fixes test TODOs. Apparently Vulkan drivers can saturate here, which
caused the TODO to appear, at least on AMD Windows.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-27 15:34:53 +02:00
Hans-Kristian Arntzen 3c7f188863 vkd3d: Nuke code paths for !nullDescriptor.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-27 10:39:22 +02:00
Hans-Kristian Arntzen 7bf93b844d vkd3d: Require VK_EXT_robustness2.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-27 10:39:22 +02:00
Hans-Kristian Arntzen 0b8490a6b9 meta: DXBC descriptor QA is supported.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen a3fb2f1cd6 vkd3d-shader: Opt-in to early fragment tests with descriptor QA.
Since we introduce side effects, avoid full late-Z for everything, which
is slow, and not necessarily correct either.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen 077740f15c vkd3d-shader: Implement descriptor QA for DXBC as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen e60fab591b vkd3d: Add more enums/name LUTs for descriptor QA.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen 3470feceb4 meta: Add descriptor_qa_checks to README.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen a256a9266e vkd3d: Rewrite descriptor QA.
Adds support for GPU-assisted validation of descriptor usage in the
CBV_SRV_UAV heap.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen 815277e392 vkd3d: Add data structures for descriptor QA.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen 5e67d30883 vkd3d: Add config option for descriptor QA.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen 0d5f1d7784 vkd3d-shader: Add way to pass down descriptor QA buffers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen b49df76367 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen c7d9faedea vkd3d: Add atomic OR support.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Hans-Kristian Arntzen 96a84e2633 vkd3d: Fix build with DESCRIPTOR_QA.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-26 17:26:01 +02:00
Joshua Ashton 925a930d1e vkd3d: Fix missing trace arg in SetPipelineStackSize
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-05-20 11:36:21 +02:00
Joshua Ashton 2a82358c3f build: Don't strip binaries when doing a --dev-build
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-05-19 17:29:13 +02:00
Hans-Kristian Arntzen 9d405f0366 vkd3d: Don't try to use fallback SRV aux heap.
DXR requires buffer_device_address, so it's meaningless to attempt a
fallback.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-13 08:25:10 +01:00
David McCloskey 1744896142 vkd3d: Fix for freeing memory created with aligned_malloc
Signed-off-by: David McCloskey <davmcclo@gmail.com>
2021-05-07 06:42:12 +01:00
David McCloskey 217ffc27d2 vkd3d: Type error fix for d3d12_device_get_query_pool.
Signed-off-by: David McCloskey <davmcclo@gmail.com>
2021-05-07 06:41:59 +01:00
David McCloskey 09f5366941 build: clang-cl support for native Windows builds.
Signed-off-by: David McCloskey <davmcclo@gmail.com>
2021-05-07 06:41:39 +01:00
Hans-Kristian Arntzen 8734589e92 dxil-spirv: Update submodules.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-05 14:47:16 +02:00
Hans-Kristian Arntzen 47cae1095e tests: Test copying depth-stencil to color.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-05 00:11:10 +02:00
Hans-Kristian Arntzen 43bf0ed8c1 vkd3d: Ensure SAMPLED | COLOR_ATTACHMENT for R8_TYPELESS.
Needed for stencil -> color copies potentially.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-05 00:11:10 +02:00
Hans-Kristian Arntzen 4f0872152a meta: Add fs_copy_uint path.
For stencil -> color copies.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-05 00:11:10 +02:00
Hans-Kristian Arntzen ef5ad082a0 vkd3d: More precise logging for fallback copy fixmes.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-05 00:11:10 +02:00
Hans-Kristian Arntzen 0e93af9700 vkd3d: Handle multiple planes in subresource conversion for copies.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-05 00:11:10 +02:00
Hans-Kristian Arntzen e02031220a dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-05-04 15:41:37 +02:00
Georg Lehmann a411256c7f vkd3d: Enable and require shaderDrawParameters.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-04-29 06:48:37 +01:00
Joshua Ashton 3ed3526332 meson: Update to version 2.3.1
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-27 15:03:38 +01:00
Joshua Ashton 7d123c4774 meta: Update CHANGELOG for 2.3.1
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-27 15:03:38 +01:00
Joshua Ashton 1267b2a985 build: Fix installing vkd3d-proton when Wine is built without vkd3d
This would fail previously as Wine does not have d3d12.dll for us to make .old

Closes: #559
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-27 12:54:44 +01:00
Joshua Ashton 68d5510bdf build: Avoid Wine Mono and Gecko installs in the setup script
Co-authored-by: Alexis Peypelut <iroalexis@outlook.fr>
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-27 12:54:44 +01:00
Hans-Kristian Arntzen c7890219e7 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-27 12:21:21 +02:00
Georg Lehmann b858f8a478 vkd3d: Don't error out if vkGetPhysicalDeviceFragmentShadingRatesKHR isn't found.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-04-24 18:23:46 +01:00
Hans-Kristian Arntzen 26584b4d7c meson: Update to version 2.3.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-22 17:28:44 +02:00
Hans-Kristian Arntzen f4afcabed8 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-22 17:28:35 +02:00
Hans-Kristian Arntzen 99a180f7a1 vkd3d-utils: Fix .def version.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-22 15:30:58 +01:00
Joshua Ashton 364402c5ac meta: Add some extra stuff to the 2.3 CHANGELOG
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-21 16:30:26 +02:00
Hans-Kristian Arntzen be1b941e06 vkd3d: Workaround buggy NV driver in sparse update.
test_update_tile_mappings fails if we don't do this.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-21 16:29:05 +02:00
Hans-Kristian Arntzen 701ea350e1 meta: Update CHANGELOG for 2.3.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-21 13:04:19 +02:00
Georg Lehmann 0d727274f9 build: Conditionally enable --quiet for glslang.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-04-21 13:01:17 +02:00
Joshua Ashton 3d0913dc19 d3d12: Initialize optional extensions
This was missed and somehow magically worked fine when running the test suite for me.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-21 00:48:43 +02:00
Joshua Ashton 0e7e6e9520 build: Make package-release version independent
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton 3118696706 vkd3d-utils: Bump SONAME version to 3.0.0
We made breaking ABI changes.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton 911a202bd1 vkd3d: Bump SONAME version to 3.0.0
We made breaking ABI changes.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton 1970051e7a tests: Use vkGetPhysicalDeviceProperties2 in d3d12_crosstest
We require Vulkan 1.1.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton a3ad7cae90 vkd3d-shader: Remove type/next from interface structures
This was never really used for anything useful.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton 0c8349cb8e vkd3d-shader: Remove vkd3d_shader_domain_shader_compile_arguments
This is never used by anything, and all the info is in the shader anyway.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton 220e1146ee vkd3d-shader: Make vkd3d_shader_transform_feedback_info a member
Moves it into vkd3d_shader_interface_info, this doesn't need to be
a pNext.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton 3e4a8b1504 vkd3d: Remove type/next from vkd3d device/instance structures
There's really no reason to overcomplicate adding optional extensions this way.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton bd988f2b74 vkd3d: Remove vkd3d_optional_device_extensions_info
Roll this into vkd3d_device_create_info, no need for this to be a pNext thing.

Additionally, fix some memory leaks on device creation failure.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Joshua Ashton 59148c1932 vkd3d: Remove vkd3d_optional_instance_extensions_info
Roll this into vkd3d_instance_create_info, no need for this to be a pNext thing.

Additionally, fix some memory leaks on instance creation failure.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-20 18:25:41 +02:00
Philip Rebohle f06f94bfb4 vkd3d: Enable multi_queue by default.
And replace option with a single_queue flag to do the opposite.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-19 16:40:49 +02:00
Hans-Kristian Arntzen 91dc8249f2 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-19 14:01:33 +02:00
Hans-Kristian Arntzen afb2067d72 tests: Test that we can safely read ClipDistance in DS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-19 12:38:37 +01:00
Joshua Ashton 1761cf3aa1 tests: Add a SV_ClipDistance in HULL shader test
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-19 13:19:44 +02:00
Joshua Ashton 07e801192f vkd3d-shader: Resolve arguments to variable before passing to epilogue
Otherwise we pass in a pointer which is bad, or a local value which is also illegal for some reason.

It has to be a "memory object declaration".

Found via. spirv-val

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-19 13:19:44 +02:00
Joshua Ashton 4470ec63cc vkd3d-shader: Don't emit builtin clip/cull arrays for hull shaders
There are no output built-ins here, just per-vertex stuff passed directly to DS to deal with there.

Closes: #227

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-19 13:19:44 +02:00
Joshua Ashton 94a9719557 vkd3d-shader: Rename vkd3d_dxbc_compiler_emit_shader_signature_outputs to vkd3d_dxbc_compiler_emit_clip_cull_outputs
This only ever emits these.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-19 13:19:44 +02:00
Joshua Ashton 000407d74c vkd3d-shader: Enable Clip/Cull distance capabilities
Found via. spirv-val

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-19 13:19:44 +02:00
Georg Lehmann 21dabb315d vkd3d: Unify _mm_pause detection.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-04-19 12:05:12 +02:00
Hans-Kristian Arntzen c7eb6fdf61 vkd3d: Add some tracing to help narrow down compiler crashes.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-15 16:24:05 +02:00
Hans-Kristian Arntzen 6292078433 vkd3d-shader: Return INVALID_ARGUMENT instead of SHADER.
For invalid bindings, we expect E_INVALIDARG in D3D12.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-15 16:24:05 +02:00
Hans-Kristian Arntzen 744497274c vkd3d-shader: Verify that we compile expected shader stage.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-15 16:24:05 +02:00
Hans-Kristian Arntzen 8f17fdd1fa vkd3d: Don't leak pipeline cache if we fail compile.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-15 16:24:05 +02:00
Hans-Kristian Arntzen 4925495e0a tests: Verifies behavior if we pass mismatching stages.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-15 16:24:05 +02:00
Hans-Kristian Arntzen 70f3f769a5 tests: Add test which verifies what happens with missing RS bindings.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-15 16:24:05 +02:00
Hans-Kristian Arntzen e7b6cf4089 vkd3d-shader: Report error if binding is not found in root signature.
Error out early.

Fixes some crashes when we keep going after having seen completely
broken bindings.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-15 16:24:05 +02:00
Georg Lehmann 2c3988e6df tests: Add env var to exclude tests.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-04-15 15:10:25 +02:00
Philip Rebohle 48536b2222 tests: Test command allocator reset behaviour with bundles.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-14 16:24:55 +02:00
Philip Rebohle 3fbce3c450 tests: Do not skip test_bundle_state_inheritance test.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-14 16:24:55 +02:00
Philip Rebohle 62cbf3d78a vkd3d: Remove unused unsafe_impl_from_ID3D12CommandAllocator.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-14 16:24:55 +02:00
Philip Rebohle 4f9ca6c3df vkd3d: Create bundles and bundle allocators as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-14 16:24:55 +02:00
Philip Rebohle 1bbbabcb94 vkd3d: Implement ExecuteBundle.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-14 16:24:55 +02:00
Philip Rebohle 728ce6c370 vkd3d: Validate command list type in ExecuteCommandLists.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-14 16:24:55 +02:00
Philip Rebohle 1990270bbb vkd3d: Implement CreateCommandList on top of CreateCommandList1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-14 16:24:55 +02:00
Philip Rebohle 2ca62ecd12 vkd3d: Add bundle allocator and command list implementation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-14 16:24:55 +02:00
Joshua Ashton 2860b0a548 vkd3d: Enable force_tgsm_barriers for F1 2020
Signed-off-by: Joshua Ashton <joshua@froggi.es>

Closes: #611
2021-04-12 16:29:57 +02:00
Joshua Ashton 043fd304f8 vkd3d-shader: Add force_tgsm_barriers config flag
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 16:29:57 +02:00
Joshua Ashton 7cfe17d2f5 vkd3d-shader: Passthrough vkd3d_config_flags
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 16:29:57 +02:00
Joshua Ashton 41df41305e include: Move vkd3d_config_flags to public header
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 16:29:57 +02:00
Joshua Ashton bc87d60ad8 tests: Add a test for RSSetShadingRateImage
Passes on D3D12 and VKD3D-Proton.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Joshua Ashton 3284f062de tests: Fix comparisons in test_vrs
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Joshua Ashton 82a1dc22a2 tests: Add a SV_ShadingRate test
Tests both VS primitive rate and the PS input.

Fails currently on Windows as both vendors have broken combiner
logic in their D3D12 drivers right now.
NV: Fails right now on Min/Max when mixing 2x1 and 1x2.
AMD: Everything is broken. Did they even test this?

Tests pass with Vulkan/vkd3d-proton and the expected values
are based on the D3D12 spec/docs around VRS.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Joshua Ashton 14cef6cf3f tests: Enable D3D12ExperimentalShaderModels
We need these for VRS shader tests and probably also for RT.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Joshua Ashton 4e20fd2f58 include: Define D3D12EnableExperimentalFeatures
Including associated UUIDs.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Joshua Ashton 5978f5958e vkd3d: Expose TIER_2 Variable Rate Shading
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Joshua Ashton 9fb624a429 vkd3d: Implement RSSetShadingRateImage
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Joshua Ashton 5d17f71441 vkd3d: Handle usage and implicit views for VRS capable resources
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Joshua Ashton 135c7332e4 vkd3d: Implement D3D12_RESOURCE_STATE_SHADING_RATE_SOURCE
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Joshua Ashton 601357c7c5 vkd3d: Implement a static pipeline variant system
Needed so we can switch between having a VRS and non-VRS attachment on the fly.
Extensible enough for this to work for other things down the line also.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-04-12 13:22:01 +02:00
Fabian Bornschein eb4909ea67 build: Switch to the portable shebang in scripts
Signed-off-by: Fabian Bornschein <fabiscafe@mailbox.org>
2021-04-12 11:26:39 +01:00
Philip Rebohle 4e777b9182 vkd3d: Use depth attachment when depth bounds test is enabled.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-12 11:23:51 +02:00
Hans-Kristian Arntzen 7dc2a5cad7 vkd3d: Enable VK_KHR_sampler_mirror_clamp_to_edge.
CP77 requires it now.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-04-07 21:57:50 +02:00
Philip Rebohle a0a04f9488 tests: Test root signature priority.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-04-06 11:13:35 +02:00
Philip Rebohle 2f1b23ece6 vkd3d: Enable conservative rasterization tier 3.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-25 18:00:59 +01:00
Philip Rebohle 6476fabb0b vkd3d-shader: Implement support for SV_InnerCoverage.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-25 18:00:59 +01:00
Philip Rebohle 698279ec90 vkd3d: Enable conservative rasterization state as requested.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-25 18:00:59 +01:00
Philip Rebohle 8a61128152 vkd3d: Enable VK_EXT_conservative_rasterization if available.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-25 18:00:59 +01:00
Philip Rebohle 9c8377c2d4 tests: Add test for conservative rasterization.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-25 18:00:59 +01:00
Philip Rebohle fdf4df18a4 vkd3d: Add Feature Level 12_2 detection.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-25 18:00:59 +01:00
Hans-Kristian Arntzen 0a8b5bca4e dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-25 18:00:41 +01:00
Hans-Kristian Arntzen 2f60a3bf66 vkd3d: Fix broken debug_vk_memory_{property,heap}_flags.
C is fun, yo. Returned data from dead stack variable, also triggered
overflow in some cases.

Uncalled in release mode, but can crash debug builds.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-25 17:58:18 +01:00
Joshua Ashton fe28436c34 vkd3d: Refactor vkd3d_render_pass_key to use flags
We're going to need more state in this key for VRS TIER_2 and we need to keep this aligned.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-24 15:20:10 +01:00
Joshua Ashton f812442199 meta: Add VK_KHR_create_renderpass2 to README
This is required now.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-24 15:20:10 +01:00
Joshua Ashton 65b13f6cd6 vkd3d: Use VK_KHR_create_renderpass2
We need this before implementing TIER_2 variable rate shading.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-24 15:20:10 +01:00
Hans-Kristian Arntzen e89dd8cf87 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 19:15:36 +01:00
Hans-Kristian Arntzen 93d042f9ce dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 18:35:35 +01:00
Hans-Kristian Arntzen 5197edb03b vkd3d: Enable 16-bit storage features.
Don't need extension, since VK_KHR_16bit_storage is core in Vulkan 1.1.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 18:35:35 +01:00
Hans-Kristian Arntzen 4afd4d355b vkd3d: Handle more DXR cases.
Found in Ghostrunner, still not working ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 18:35:35 +01:00
Hans-Kristian Arntzen e0374d735d vkd3d-shader: Add shader replacement support for DXR as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 18:35:35 +01:00
Hans-Kristian Arntzen 5abc4b9af2 vkd3d: Add all relevant RT stages to push constant layout.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 18:35:35 +01:00
Hans-Kristian Arntzen 9d3603c336 vkd3d: Fix root descriptor RTAS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 18:35:35 +01:00
Hans-Kristian Arntzen 9fa668867e vkd3d: Hold private reference to collection objects.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 18:35:35 +01:00
Hans-Kristian Arntzen bd16d1a88d vkd3d: Support RTPSO object collections.
This is quite complicated, but we can use VK_KHR_pipeline_library
to implement this functionality.
2021-03-23 18:35:35 +01:00
Hans-Kristian Arntzen 89679cbff1 tests: Test local definition exports.
Attempts to create a hit group out of shaders found in collection objects.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 18:35:35 +01:00
Hans-Kristian Arntzen b306d605f3 tests: Add basic RT collection test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-23 18:35:35 +01:00
Joshua Ashton bc1b18dc02 vkd3d: Add some missing flags in debug_vk helpers
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-22 14:29:45 +01:00
Joshua Ashton d97683a8a4 d3d12: Rename d3d12_get_physical_device to d3d12_find_physical_device
A more accurate description of what's going on here.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-22 14:29:45 +01:00
Joshua Ashton 9f778bc871 d3d12: Use vkGetPhysicalDeviceProperties2
This is core in Vulkan 1.1.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-22 14:29:45 +01:00
Joshua Ashton 2fa97aa0fb vkd3d: Move API versions to public header
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-22 14:29:45 +01:00
Hans-Kristian Arntzen b7dfa99e57 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-19 13:42:47 +01:00
Hans-Kristian Arntzen cf39639f5b dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-18 20:58:58 +01:00
Joshua Ashton b71bc5ef6b tests: Don't crash if WRITE_WATCH is broken
This can happen under Wine.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-18 16:56:36 +01:00
Joshua Ashton 4b6a1ef40d tests: Add a WRITE_WATCH test
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-18 16:10:05 +01:00
Joshua Ashton 258173a0a7 vkd3d: Fix return value when WRITE_WATCH is forbidden
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-18 16:10:05 +01:00
Joshua Ashton aa12817ccf vkd3d: Implement D3D12_HEAP_TYPE_WRITE_WATCH
Needed for D3D12 APITrace

Closes: #373
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-18 14:41:46 +01:00
Hans-Kristian Arntzen 52a9c85bf2 vkd3d: Implement ClearState.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-18 10:50:21 +01:00
Joshua Ashton 4e31f5d54d vkd3d: Align d3d12_rtv_desc to D3D12_DESC_ALIGNMENT
Otherwise we can do an alligned_malloc with a non-aligned size as the descriptor size is 48 for a d3d12_rtv_desc otherwise.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-16 21:45:28 +01:00
Joshua Ashton 5b5293ec93 vkd3d: Fix out of range in UpdateTileMappings
Previously this incremented and indexed before the loop checked this.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-16 21:45:13 +01:00
Joshua Ashton 43e7316591 tests: Default VKD3D_TEST_DEBUG to 1
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-16 21:43:01 +01:00
Philip Rebohle dadace33b1 vkd3d: Fix potential hang in d3d12_command_queue_Release.
This can happen if the fence thread starts with a delay and
the queue gets destroyed shortly after being created.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-16 21:42:39 +01:00
Hans-Kristian Arntzen 34a09967d5 vkd3d: Prefer compute queues for TRANSFER.
TRANSFER + CONCURRENT is generally death for compression.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-16 21:41:37 +01:00
Hans-Kristian Arntzen 95fe4b61a6 vkd3d: Do not drop pending signals when signaling fence on CPU.
There isn't much of a reason why we should have to do this. The original
implementation was more of a hack if anything.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-16 21:41:37 +01:00
Hans-Kristian Arntzen e7672c3233 vkd3d: Refactor where max pending timeline value is computed.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-16 21:41:37 +01:00
Hans-Kristian Arntzen dbdbf94083 vkd3d: Ensure that virtual timeline values are updated in-order.
Increment physical value one by one, find the exact timeline value we're
supposed to signal and perform the update.

Select lowest physical timeline value correctly.
Array can be reordered now, so lowest value isn't necessarily first.

Fixes some super weird hangs in Control DXR.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-16 21:41:37 +01:00
Philip Rebohle eab288bb4e vkd3d: Simplify fence worker implementation.
Avoids potential busy-waiting on the driver with WAIT_ANY_BIT.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-16 12:43:24 +01:00
Philip Rebohle 93a80d5eaa vkd3d: Create one fence worker per command queue.
Rather than one per device. This solves issues with D3D12 fences
being signalled too late because the fence worker is waiting on
a different set of semaphores while the fence is being enqueued.

Greatly increases performance in Horizon Zero Dawn and Death
Stranding with multi-queue mode enabled.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-16 12:43:24 +01:00
Philip Rebohle 34bca90a9c vkd3d: Implement internal reference counting for d3d12_fence.
This will be necessary once we introduce fence workers per
command queue, since we cannot reliably store pointers to
queues.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-16 12:43:24 +01:00
Hans-Kristian Arntzen 102ea2211b vkd3d: Ignore IASetVertexBuffers for NULL pViews.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-15 14:55:53 +00:00
Hans-Kristian Arntzen 5b2cc545e8 vkd3d: Convert RTAS geometry flags.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-15 14:55:03 +00:00
Hans-Kristian Arntzen c425343f41 vkd3d: Remove FIXME spam for pResourceAfter = NULL cases. 2021-03-15 14:10:27 +01:00
Philip Rebohle 0e4ef88d18 vkd3d: Don't broadcast semaphore waits when zeroing memory.
Instead, let queues wait on demand.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Philip Rebohle 7185e9776d vkd3d: Introduce vkd3d_queue_add_wait.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Philip Rebohle 724257c0d8 vkd3d: Add multi_queue config flag.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Philip Rebohle 859aa3fd5a vkd3d: Use VK_SHARING_MODE_CONCURRENT if multi-queue is enabled.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Philip Rebohle 1e3c91579e vkd3d: Create one vkd3d queue per Vulkan device queue.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Philip Rebohle 3cd93781ff vkd3d: Create multiple queues per queue family if possible.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Philip Rebohle 6967b1e92b vkd3d: Wait for queue idle before destroying vkd3d queue.
Fixes a potential issue where we may destroy objects that
are still in use by the GPU.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Philip Rebohle b0309f6f90 vkd3d: Introduce d3d12_device_allocate_vkd3d_queue.
Replaces d3d12_device_get_vkd3d_queue when mapping D3D12
command queues to Vulkan device queues.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Philip Rebohle 7359686609 vkd3d: Introduce d3d12_device_get_vkd3d_queue_family.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Philip Rebohle 4c0a0b0467 vkd3d: Introduce vkd3d_queue_family_info.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-15 12:52:00 +01:00
Hans-Kristian Arntzen b4f48bf2d6 meta: Update README with new VKD3D_CONFIG flags.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-13 06:26:27 +00:00
Hans-Kristian Arntzen b44bfa7066 vkd3d: Remove obsolete comment.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-13 06:26:27 +00:00
Hans-Kristian Arntzen 43370c6426 vkd3d: Only enable DXR if requested.
The implemnentation is not complete enough to safely enable it, since
some games will try to create RTPSOs by default, leading to crashes.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-12 12:20:10 +01:00
Hans-Kristian Arntzen 58615cd5dc vkd3d: Allow devices with recursion of 1 to be accepted.
We can fail RTPSOs later if they for whatever reason use recursion.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-12 12:20:10 +01:00
Hans-Kristian Arntzen d9be9b57f2 vkd3d: Actually use RGBA16 formats for RT VBO.
It's really supposed to load 4 components and ignore. RGB16 is not
mandatory, so just use the "expected" formats after all.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-12 12:20:10 +01:00
Hans-Kristian Arntzen 2b6658da67 vkd3d: Enable RT tier 1.0 if possible.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-12 12:20:10 +01:00
Hans-Kristian Arntzen 3adc385167 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-12 12:20:10 +01:00
Hans-Kristian Arntzen c5c45b851f vkd3d-shader: Add missing stage conversion for RT.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-12 12:20:10 +01:00
Hans-Kristian Arntzen 4f2776ff93 vkd3d-shader: Dump RT export SPIR-V.
Need one unique blob per export.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-12 12:20:10 +01:00
Hans-Kristian Arntzen 3358fca922 vkd3d: Implement local root signature association.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-12 12:20:10 +01:00
Hans-Kristian Arntzen 028b87ab61 vkd3d: Fix some trivial bugs with local root signatures.
Did not properly allocate bindings.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-12 12:20:10 +01:00
Hans-Kristian Arntzen 4f40a5a6d2 tests: Tests multiple local root signatures.
Runtime behavior here is extremely weird and contradicts spec wording in
many ways:

- Default local root signatures can override explicit ones.
- Runtime silently fails if the associated subobject is not part of the
  PSO array.
- Order of default local root signatures doesn't appear to matter at
  all.

All in all, very confusing, and there is zero help from validation
layer, so we'll have to deduce this from whatever applications want.
Hopefully they are somewhat sane, and don't try to rely on very awkward
matching rules.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-11 13:57:55 +01:00
Philip Rebohle 85f15916c4 vkd3d: Optimize unmapping adjacent resource regions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-11 13:57:45 +01:00
Philip Rebohle 2ef8106136 vkd3d: Optimize sparse binding for buffers and full subresources.
Compacts ranges and only issues one bind for buffer ranges and
full subresource updates, rather than one bind per tile.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-10 13:18:44 +01:00
Philip Rebohle ead9f2d620 vkd3d: Store subresource index in d3d12_sparse_image_region.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-10 13:18:44 +01:00
Hans-Kristian Arntzen ff78b2df1c vkd3d: Dump DXIL when parsing entry points as well.
Parse can fail, and it's is useful to debug that.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 13:08:25 +01:00
Hans-Kristian Arntzen 73d55ec65a dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 13:08:25 +01:00
Hans-Kristian Arntzen cd876284e0 vkd3d: Fix some const warnings on MSVC.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 10:48:01 +00:00
Hans-Kristian Arntzen ce62d3d700 vkd3d: Fix MSVC build errors.
args... is a GNU extension.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 10:48:01 +00:00
Hans-Kristian Arntzen 369f48e499 tests: Add test for RTAS update.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 11:46:22 +01:00
Hans-Kristian Arntzen 0bf3a1d441 vkd3d-shader: Recognize recent descriptor range flag.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 11:46:05 +01:00
Hans-Kristian Arntzen 56e7cbec80 test: Test CBV table hoisting.
Adds some spicy edge cases with array size of 1 w/ nonuniform access, etc.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 11:46:05 +01:00
Hans-Kristian Arntzen 13d132f1c4 vkd3d: Add support for hoisting CBV descriptors to push descriptors.
Bindless CBV is *pretty* bad on NVIDIA, so add a code path which can
promote descriptor table CBVs into push descriptors.

We can safely do this with Root Signature 1.1 STATIC or
the somewhat obscure STATIC_KEEPING_BUFFER_BOUNDS_CHECKS.

With VOLATILE, which basically all titles are using,
we can still force this behavior through a config flag,
but this is an incorrect speed hack. It works in most
titles however, since bindless CBV is exceptionally rare.

We only hoist descriptors when the root signature range has 1 descriptor
anyway, so we should avoid any reasonable bindless scenario.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 11:46:05 +01:00
Hans-Kristian Arntzen d758a6e296 vkd3d: Convert Root Signatures to 1.1.
We will be able make use of the use STATIC vs VOLATILE flags.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 11:46:05 +01:00
Hans-Kristian Arntzen c409d0f30a vkd3d: Optimize R32UI texel buffer creation.
There is no need to scan through the Vulkan format list,
especially since texel buffer creation happens in the hot path
in cases where we know we need to create R32UI texel buffer views.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 11:46:05 +01:00
Hans-Kristian Arntzen 3e876c2857 vkd3d: Log VKD3D_CONFIG with INFO.
Useful to make sure we actually passed it correctly ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-10 11:46:05 +01:00
Hans-Kristian Arntzen c351dfc8d3 vkd3d: Remove dead code from d3d12_command_list.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-05 15:49:28 +01:00
Joshua Ashton ce9ae01c79 build: Warn about VLA usage
Using consts for array sizes is a C++-ism, and in GCC in C-mode it won't fold literal constants, and will instead prefer to make a VLA.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-04 15:50:28 +00:00
Hans-Kristian Arntzen 38bb845800 tests: Refactor raytracing test to be a bit more extensible.
Fixes a lot of the worst hardcoding, test different IBO / VBO formats.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-04 16:30:29 +01:00
Hans-Kristian Arntzen f2c5a6561c tests: Test RTAS clone and compact.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-04 16:30:29 +01:00
Hans-Kristian Arntzen b34af6a7fa vkd3d: Convert RT vertex format correctly.
Context sensitive formats, oh boy!

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-04 16:30:29 +01:00
Hans-Kristian Arntzen 686a3efc08 vkd3d: Verify VBO RTAS support when checking RT tier.
Format conventions for RT are ... special.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-04 16:30:29 +01:00
Hans-Kristian Arntzen b5d433baaa vkd3d: Implement RTAS clone and compact copy operations.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-04 16:30:29 +01:00
Philip Rebohle 39513d6503 vkd3d: Silence log spam around Min LOD Clamp.
This seriously hurts performance in AC:Valhalla.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-04 13:37:05 +01:00
Philip Rebohle 5e94183975 vkd3d-shader: Do not insert branch to loop header if outside of block.
Fixes invalid SPIR-V in case there is an unconditional break right
before the loop ends.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-04 13:36:31 +01:00
Philip Rebohle ba8e306452 vkd3d-shader: Ignore break instructions if there is no active block.
This can happen if a continue statement is immediately followed
by a break instruction in a switch case.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-03-04 13:36:31 +01:00
Joshua Ashton 96888b0663 build: Use --file-alignment=4096 with MinGW
Avoids a copy in the Wine loader as well as enables debug symbols to work in perf.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-03 19:22:44 +01:00
Joshua Ashton 47606f4339 build: Rename vkd3d_msvc and vkd3d_clang
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-03 19:22:44 +01:00
Hans-Kristian Arntzen 031ad9e139 vkd3d: Track dynamic pipeline stack size
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Hans-Kristian Arntzen 600a296ca7 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Hans-Kristian Arntzen 9588ec082e vkd3d: Fix warnings when AS is used without support.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Hans-Kristian Arntzen fcd00f0559 vkd3d: Implement DispatchRays.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Hans-Kristian Arntzen b162e5ec72 vkd3d: Refactor descriptor updates.
We might have to emit to different bind point than our binding entry
suggests due to DXR, so pass down information explicitly to leaf
functions.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Hans-Kristian Arntzen eeaca4a500 vkd3d: Pass down raygen pipeline layout to command list.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Hans-Kristian Arntzen 0b161f5693 vkd3d: Implement SetPipelineState1.
Refactor push constant invalidation to SetPipelineState,
it is technically more correct to only invalidate when actually pushing
constants, but we need to do full state invalidation when transitioning
between RT pipelines and non-RT pipelines due to bind point aliasing
shenanigans in D3D12, so it makes more sense to invalidate state based
on active bind point there.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Hans-Kristian Arntzen 77089065cd vkd3d: Compute default pipeline stack size.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Hans-Kristian Arntzen 9ffa3bf351 vkd3d: Support CreateSRV with RTAS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Hans-Kristian Arntzen 9ff7b82235 vkd3d: Rename VKD3D_DESCRIPTOR_FLAG_UAV_COUNTER to RAW_VA_BUFFER.
We're going to place acceleration structures here.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-03-03 19:19:47 +01:00
Joshua Ashton 3224688295 vkd3d: Enable VK_EXT_debug_utils conditionally
Enabling VK_EXT_debug_utils comes at some overhead in Wine due to the object tracking required. There is also likely a non-zero overhead in some native implementations also.

By enabling this conditionally, we can also avoid additional overhead from apps that set debug labels on both the Vulkan and front-end side.

The default condition is to enable it when building with Renderdoc integration or in debug builds.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-02 11:09:29 +01:00
Joshua Ashton 91fc472601 vkd3d: Add mechanism for conditional extensions
Add a way to enable an extension via config flags.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-02 11:09:29 +01:00
Joshua Ashton 4c6f5375a6 vkd3d: Refactor config_flags to be global rather than instance state
Makes it so we can access it in code where we have no concept of a device/instance.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-02 11:09:29 +01:00
Joshua Ashton 64a6bae1a0 vkd3d: Remove vkd3d_application_info structure
This thing has no right to exist.

We don't get this information in D3D12 and it's getting in the way of me refactoring config flags.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-02 11:09:29 +01:00
Joshua Ashton 78b5b347b8 build: Disable TRACE calls in release builds
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-02 11:09:29 +01:00
Joshua Ashton 4da76cb51b vkd3d: Simplify properties/features tracing
Simplifies this to make it easier to add new properties/features
so we don't have a bunch of pointers to things that are just a child
of the device info structure.

Fixes warnings when compiling without traces too.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-02 11:09:29 +01:00
Joshua Ashton 615b2d714f build: Minor meson formatting change
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-03-02 11:09:29 +01:00
Georg Lehmann 7d518ea78f meta: Remove .gitlab-ci.
Github Actions replaced the frogs.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-02-27 13:57:53 +00:00
Hans-Kristian Arntzen 91fad86e4d tests: Test that root parameters are correctly invalidated.
When emitting push constants for graphics, these should invalidate push
constants for compute and vice versa. In Vulkan, vkCmdPushConstants is
not tied to a bind point.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-26 17:06:18 +01:00
Hans-Kristian Arntzen 89fbe334df vkd3d: Redirect push constants to their bind point stages.
Gives a massive boost on NVIDIA for some reason.
RADV defers push constant update, so ALL_STAGES doesn't have
that much of a perf hit.

~20% uplift in RE2, ~5% uplift in CP77 from some quick and dirty testing.
Seems to be heavily content dependent either way.

Also a bug fix, since we would clobber graphics push constants from
compute and vice versa if both graphics and compute used the same root
signature.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-26 17:06:18 +01:00
Hans-Kristian Arntzen 3839f5e17c vkd3d: Ignore known useless validation warnings.
These only clutter up validation in testing.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-26 15:04:11 +01:00
Joshua Ashton 29b410928b tests: Add a suite of tests for SetName
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-25 21:51:43 +01:00
Joshua Ashton 8c9527cdf7 vkd3d: Refactor SetName implementation
As per MSDN, SetName is just a wrapper around SetPrivateData and a specific GUID.

Some apps and tools will use this to retrieve their name back.

So instead, just forward the name to Vulkan in the SetPrivateData call.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-25 21:51:43 +01:00
Joshua Ashton 04b86b80b6 include: Define WKPID_D3DDebugObjectName and friends
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-25 21:51:43 +01:00
Joshua Ashton a76daad03f vkd3d-common: Add vkd3d_strdup_n
There is no strndup on Windows.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-25 21:51:43 +01:00
Philip Rebohle 26f5745ea1 vkd3d: Don't use SHADER_STAGE_ALL for push constants.
Instead, infer the required stages from the D3D12 shader visibility
field from all root parameters that we map to push constants.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-25 20:28:07 +01:00
Philip Rebohle c37e705761 vkd3d: Use push constant stage mask from root signature.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-25 20:28:07 +01:00
Hans-Kristian Arntzen 96b44fddbc tests: Remove some todo/is_bug()s for RADV.
Some tests are now passing.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 18:28:06 +01:00
Hans-Kristian Arntzen 4fe5b9388d vkd3d: Do not disable robustness, ever.
There are pragmatic reasons for not following spec 100% here.
The only known case where UpdateAfterBind robustness is not exposed
seems to be somewhat bogus, and we cannot run D3D12 correctly without
robustness either way.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 17:53:48 +01:00
Hans-Kristian Arntzen be9c376fde vkd3d: Implement postbuild info queries.
Can only support a subset in Vulkan without extra heroics. The DXR API
lets you query things that you technically should know apriori in the
application. We might need to allocate some side-channel buffers on
demand, but let's defer that until actually needed ... :\

DXR is also very awkward in that we have a query which is resolved in
UNORDERED_ACCESS state instead of COPY_DEST state, so we'll have to
ping-pong through some barriers redundantly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen 4365f9962f vkd3d: Allocate query pools based on type index instead of D3D12 type.
Postbuild info is a query in Vulkan, but not so in D3D12.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen d88ce7cdea tests: Test post-build info output.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen a5aac500bc vkd3d: Basic implementation of GraphicsCommandList::BuildRTAS().
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen 3353ed14de vkd3d: Implement RTAS object creation.
When building acceleration structures, we need to have an
VkAccelerationStructureKHR object, but the D3D12 API just uses a plain
VA = ID3D12Resource::GetGPUVA() + offset.

For this to work, we need to resolve the VA back to VkBuffer + offset.
The only VkBuffer we can lookup is the original backing memory
allocation in the VA map, and that allocation itself must own a view
map, since we cannot tie the VA to any specific ID3D12Resource.

Since creating an RTAS is not the common path, we allocate the view map
on-demand with CAS.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen 0fc80d9067 vkd3d: Emit RT barriers as required.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen 221a658884 vkd3d: Mark resources as being RTAS depending on initial resource state.
RTAS must stay in this resource state forever. The only way to
synchronize them is UAV barriers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen 86f7fdfe7a vkd3d: Add RTAS buffer usage flags.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen 83861cceed vkd3d: Allow RTAS initial resource state.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen 2afe25c0c8 vkd3d: Implement GetRaytracingAccelerationStructurePrebuildInfo.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen d773e67fff vkd3d: Add helper query to check if RT should be used.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-25 16:14:16 +01:00
Hans-Kristian Arntzen a90ed938b4 vkd3d-shader: Pass down SBT descriptor size to dxil-spirv.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-23 12:28:19 +01:00
Hans-Kristian Arntzen 15e36a0430 vkd3d: Use virtual VAs for descriptor heap GPU VAs.
Allows local root signatures to work correctly and is also a good
optimization since we no longer need to dereference memory (potentially
cold cache lines) to figure out heap offset in command buffer.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-23 12:28:19 +01:00
Hans-Kristian Arntzen 1af3f9c65f vkd3d: Use calloc for d3d12_device instead of manual memset.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-23 12:28:19 +01:00
Hans-Kristian Arntzen 1586a75ada vkd3d: Align d3d12_desc to 64 bytes.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-23 12:28:19 +01:00
Hans-Kristian Arntzen 3442d44649 vkd3d: Add aligned allocation helpers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-23 12:28:19 +01:00
Hans-Kristian Arntzen 0c94e07ab2 vkd3d: Elide timeline semaphore waits which can be satisfied implicitly.
If we're signalling and waiting on same physical queue (always true for
current SINGLE_QUEUE define), we can rely on submission boundary
synchronization which doesn't require any extra submissions to resolve.

Avoids awkward GPU driver bubbles with back to back signal -> wait pairs
with timeline.

Observed 2% GPU uplift on RE2 on AMD.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-22 13:00:22 +01:00
Hans-Kristian Arntzen dc246a70fc meson: Bump version to 2.2. 2021-02-19 20:23:10 +01:00
Philip Rebohle 1d7e424c44 vkd3d: Mask certain heap flags when suballocating memory.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-19 20:18:24 +01:00
Philip Rebohle f6c6a76735 vkd3d: Store original heap flags in d3d12_resource again.
Otherwise, when suballocating memory, GetHeapProperties may
not return the exact same set of flags if we ignore flags
when looking up suitable chunks.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-19 20:18:24 +01:00
Philip Rebohle be080edc7f vkd3d: Remove vkd3d_allocate_resource_memory.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-19 19:51:44 +01:00
Philip Rebohle a1e5b78bc4 vkd3d: Suballocate committed images if possible and if supported by the driver.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-19 19:51:44 +01:00
Philip Rebohle a1ffea1800 vkd3d: Fix integer underflow when checking for suitable free ranges.
The difference between a range's offset and the aligned
offset may be greater than the size of that range.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-19 18:11:36 +01:00
Hans-Kristian Arntzen 0fdf69ff46 changelog: Update for 2.2.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-19 13:49:25 +01:00
Hans-Kristian Arntzen d6d8e70955 tests: Add image placement alignment test.
Validates that we can create RTVs at 64k alignment without issues.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-19 13:19:51 +01:00
Joshua Ashton bb3e5f6cad vkd3d: Account for front buffer in swapchain image count
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-19 13:17:15 +01:00
Philip Rebohle be4391b972 vkd3d: Align images manually to meet Vulkan requirements if necessary.
Allows us to not allocate device memory for certain render targets on
Polaris GPUs.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 18:25:23 +01:00
Philip Rebohle d6a4826099 vkd3d: Remove heap_offset member from d3d12_resource.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 56ff4622b6 vkd3d: Remove cookie member from d3d12_resource.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 6e81621b82 vkd3d: Remove gpu_address member from d3d12_resource.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 833d7e207c vkd3d: Remove vk_buffer/vk_image union from d3d12_resource.
Use the unique_resource struct instead.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 5a0a5ef44b vkd3d: Remove unused resource flags and rename SPARSE -> RESERVED.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 6a34d3d204 vkd3d: Remove _2 suffix from memory allocation functions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 53f6a9c78a vkd3d: Rename _2 suffix from resource creation functions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle a2e14d7d1d vkd3d: Remove _2 suffix from d3d12_heap_2 and related functions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 6f8bb2a4c0 vkd3d: Use vkd3d_allocate_device_memory_2 for sparse metadata.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 12f0c11c7f vkd3d: Simplify vkd3d_allocate_image_memory helper.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle ab2c190da5 vkd3d: Simplify vkd3d_allocate_buffer_memory helper.
This is still useful as a low-level memory allocation function when
we don't want to bother with buffer offsets or D3D12 validation.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle db2e0c7587 vkd3d: Remove vkd3d_gpu_va_allocator.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 8826f3c5bc vkd3d: Remove d3d12_heap and old resource creation functions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle 9792b02b26 vkd3d: Use vkd3d_memory_allocation for scratch buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Philip Rebohle db1b425d2a vkd3d: Use new resource and heap implementations.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-18 14:17:22 +01:00
Hans-Kristian Arntzen 8437eea2c0 vkd3d: Remove clamping assumption in RTPSO stack size.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-18 14:16:31 +01:00
Hans-Kristian Arntzen e228367e98 tests: Allow SetPipelineStackSize to propagate properly.
AMD and NV driver behaviors don't agree here, choose NV behavior as it
makes more sense.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-18 14:16:31 +01:00
Hans-Kristian Arntzen 3a48b97dd1 tests: Clean up some manual WCHAR strings.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-18 14:16:31 +01:00
Hans-Kristian Arntzen 20c4dfc685 tests: Add multithreaded suballocation test.
Also stresses VA mapping.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-18 14:16:31 +01:00
Joshua Ashton f01935d69e vkd3d: Fix SetName for inline query types
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-18 02:41:45 +01:00
Philip Rebohle 6fc8b67576 vkd3d: Fix incorrect chunk assignment for chunk allocations.
Our clear code assume that this is NULL for allocations owned
by a chunk, so we should actually do it that way. Fixes some
issues where we do not wait for clears to complete if a chunk
gets destroyed.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-17 16:38:47 +01:00
Philip Rebohle e12afd31d9 vkd3d: Actually use VKD3D_VA_BLOCK_COUNT.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-17 16:38:47 +01:00
Philip Rebohle 35f90c4b2f vkd3d: Only print some swapchain FIXMEs once.
Silences a whole bunch of log spam in Control.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-17 13:37:41 +01:00
Hans-Kristian Arntzen ea088ceecf vkd3d: Use UINT64* instead of uint64_t* in 64-bit CAS.
Avoids alignment warnings on 32-bit.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-16 16:14:14 +00:00
Hans-Kristian Arntzen 7051bf76f7 vkd3d: Fix validation errors with KHR_fragment_shading_rate.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-16 16:07:55 +00:00
Philip Rebohle a39bab95a1 vkd3d: Clear suballocated memory to zero.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-16 16:06:26 +01:00
Philip Rebohle 668a4e1f2c vkd3d: Do not suballocate small image-only heaps.
We have no way to manually reset these.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-16 16:06:26 +01:00
Philip Rebohle 4d68130be7 vkd3d: Add functionality to clear newly allocated memory.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-16 16:06:26 +01:00
Philip Rebohle 78713062fe vkd3d: Introduce unique_queue_mask.
Has one bit set for each vkd3d_queue_family that points to a
unique queue. This can be used to iterate over device queues
without having to check for duplicates manually.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-16 16:06:26 +01:00
Philip Rebohle 812c82f8ac vkd3d: Introduce VKD3D_QUEUE_FAMILY_INTERNAL_COMPUTE.
This needs a rework when we re-enable multi-queue support.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-16 16:06:26 +01:00
Hans-Kristian Arntzen da06323b87 tests: Add test which stresses suballocation implementation.
Designed to stress internal implementation details for memory rewrite.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-16 14:27:06 +01:00
Hans-Kristian Arntzen dc1b4b56ed tests: Fix build with vkd3d-utils Windows test suite.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-16 14:27:06 +01:00
Joshua Ashton bf2aa9ab99 build: Link against libatomic on x86 when using Clang
Needed for 64-bit atomics on 32-bit architectures on Clang.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-16 10:18:26 +01:00
Joshua Ashton a0f9891b11 tests: Fix -Wincompatible-pointer-types warnings
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Joshua Ashton b168a9278b tests: Fix missing hresult check in RTV descriptor copy test
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Joshua Ashton 485399ff81 tests: Fix -Wenum-conversion warnings
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Joshua Ashton 3bd5ba0681 tests: Fix -Wunused-variable warnings
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Joshua Ashton 2e1a5e75ac tests: Fix -Wabsolute-value warnings
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Joshua Ashton b91568b717 tests: Fix -Wdeclaration-after-statement warnings
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Joshua Ashton b6444b4728 tests: Fix -Wunused-function warnings
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Joshua Ashton 9b2841b50f tests: Fix -Wsign-compare warnings
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Joshua Ashton f32a2d5c70 tests: Fix -Wmissing-brace warnings
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Joshua Ashton 9953928379 meta: Remove autotools elements from gitignore
Additionally, fixes detecting packages and other build directories.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 17:54:54 +01:00
Philip Rebohle ba632148d7 vkd3d: Add new functions to create and destroy resources.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 17:04:52 +01:00
Philip Rebohle fee47ef695 vkd3d: Introduce d3d12_resource_validate_create_info.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 17:04:52 +01:00
Philip Rebohle 22f61611d1 vkd3d: Add d3d12_heap_2.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 17:04:52 +01:00
Philip Rebohle 229273fb3b vkd3d: Add memory allocator instance to device.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 17:04:52 +01:00
Philip Rebohle 6e1867b001 vkd3d: Add some more debug output to memory allocation functions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 17:04:52 +01:00
Philip Rebohle 5e54c1fc5d vkd3d: Register allocation cookie for descriptor debugging.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 17:04:52 +01:00
Philip Rebohle 8f6e94dc30 vkd3d: Suballocate small allocations from larger chunks.
This is necessary to keep the amount of allocated memory manageable
in games that allocate a lot of small heaps or committed resources.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 16:38:16 +01:00
Georg Lehmann eaab2388b1 vkd3d: Fix warning with vkd3d_atomic_ptr*.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-02-15 15:47:17 +01:00
Philip Rebohle d65363b6b6 vkd3d: Add VA map to memory allocator.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 15:19:11 +01:00
Philip Rebohle 7c017c1dba vkd3d: Add VA->resource map and new VA allocator.
This is designed to work with actual device addresses if supported by
the Vulkan implementation.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 15:19:11 +01:00
Philip Rebohle f536daaacb vkd3d: Introduce new memory allocation functions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 15:19:11 +01:00
Philip Rebohle 417b3b746e vkd3d: Introduce vkd3d_allocate_cookie.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-15 14:04:16 +01:00
Joshua Ashton 344f75aafd build: Enable --quiet on glslangValidator
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 11:25:51 +01:00
Joshua Ashton 00c8d1df9d vkd3d: Refactor vkd3d_physical_device_info_init
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-15 11:25:21 +01:00
Hans-Kristian Arntzen 22f052c366 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-12 14:28:49 +01:00
Joshua Ashton fb024f493f build: Add GCC problem matcher to build tests
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-12 13:41:34 +01:00
Joshua Ashton 7bb8346553 tests: Add test for Variable Rate Shading TIER_1
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-12 13:39:05 +01:00
Joshua Ashton c0d4ead8ca vkd3d: Implement TIER_1 variable rate shading
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-12 13:39:05 +01:00
Joshua Ashton fdf3d30792 build: Add Github Actions workflows
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-12 10:57:57 +01:00
Joshua Ashton 8e64da0eee
build: Add debug build option to package-release.sh
Co-authored-by: David McCloskey <davmcclo@gmail.com>
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-11 16:42:02 +00:00
Philip Rebohle 7549d70fbf vkd3d: Fix compiler errors when using vkd3d_atomic_ptr_store_explicit.
Atomic stores do not return anything, so we cannot cast to void* here.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-11 15:15:59 +00:00
Joshua Ashton fccbd3b5e2 vkd3d: Eliminate wchar_size, use UTF-16 string literals
Achieves this with C standard stuff alone, and no compiler hacks.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-09 11:26:28 +01:00
Joshua Ashton 38d2de9f4c vkd3d: Fix warning in query logging
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-08 16:36:15 +01:00
Hans-Kristian Arntzen 6e9bd28481 tests: Test more raytracing PSO details.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen c558c8f423 vkd3d: Implement Get*StackSize().
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen 13b737214b vkd3d: Remove owned root signatures.
Apparently the docs are lying and RTPSO does not hold references to the
root signatures after all.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen 13af141e84 common: Add truncated wide export strcmp.
Needed for GetShaderStackSize().

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen b41d01d580 tests: Verify refcount semantics for ID3D12StateObjectProperties.
The refcount is shared.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen bfe9a39c3b vkd3d: Implement the basics of RTPSO.
Implement enough that the test case compiles correctly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen 859066cd9b vkd3d-shader: Add ray-tracing pipeline support to DXIL.
Also updates relevant submodules.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen d8d1e82024 vkd3d-shader: Refactor DXIL resource remapping.
Prepare for local root signatures.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen 1784351dcf vkd3d-shader: Move root parameter structs to vkd3d-shader.
Need it here since local root signatures need to know
the physical layout of the record buffer up front.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen fdcf583cbc vkd3d: Rename COUNTER buffer to AUX_BUFFER.
We will use the same pointer buffer to handle acceleration structures,
so unify this buffer under a new name. Simplifies some of the binding
code since SRV path and UAV path looks more similar now.

Only difference is that UAV path uses BDA -> uint32_t,
and SRV uses BDA -> RTAccelerationStructure.

RT requires BDA, so the fallback descriptor set (storage texel buffer) is never used for RT.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen f3becc21a4 vkd3d: Implement local root signatures.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen 9b856ed124 vkd3d: Add entry points for VK_KHR_ray_tracing_pipeline.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen 86da5d9bad common: Add string utilities for dealing with entry point conventions.
Used across both vkd3d-shader and vkd3d, so makes sense to move this to
common code.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen 4957d561dc vkd3d: Add dummy entry to app overrides.
Empty array declaration is not legal C.
Fixes compilation error on MSVC.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Hans-Kristian Arntzen 547867d505 tests: Make raytracing test robust against stubbed implementation.
Don't crash if some things are not implemented fully.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-02-05 10:05:07 +01:00
Joshua Ashton 51bf939743 vkd3d: Implement DXGI_FORMAT_B4G4R4A4_UNORM
Uses VK_EXT_4444_formats.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-02-04 12:04:10 +01:00
Philip Rebohle 00872471eb vkd3d: Set WriteBufferImmediateSupportFlags properly.
We do not support bundles, but advertizing WriteBufferImmediate
support for bundles is required for Feature Level 12_2.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-02-01 11:09:56 +01:00
Philip Rebohle 2560c76861 vkd3d: Disable accelerationStructureCaptureReplay feature.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-28 18:55:52 +01:00
Philip Rebohle b4bc92714a vkd3d: Always align scratch buffer for query data to 8 bytes.
Fixes a validation error. With VK_QUERY_RESULT_64_BIT we need
to use 8-byte alignment, but ssbo_alignment may be less.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-26 21:04:11 +01:00
Hans-Kristian Arntzen 2bc9dc7909 vkd3d: Add FL override for 12.2 (DX12 Ultimate).
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-26 15:00:15 +01:00
Hans-Kristian Arntzen dd2a963ae7 idl: Add D3D_FEATURE_LEVEL_12_2.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-26 15:00:15 +01:00
Hans-Kristian Arntzen 9893b7f52c vkd3d: Enable SM 6.3.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-26 15:00:15 +01:00
Hans-Kristian Arntzen 31fa512512 vkd3d: Add checks for RayTracing tier.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-26 15:00:15 +01:00
Hans-Kristian Arntzen c8f8b24674 vkd3d: Enable ray tracing extensions.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-26 15:00:15 +01:00
Hans-Kristian Arntzen e89c286075 vkd3d: Report OPTIONS7 features.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-26 15:00:15 +01:00
Georg Lehmann c76f37d41c vkd3d: Introduce VKD3D_FILTER_DEVICE_NAME.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2021-01-25 15:29:34 +01:00
Hans-Kristian Arntzen 326d1cde60 vkd3d-shader: Remove DXIL being optional.
We always build with DXIL, not using autotools anymore.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-25 14:03:37 +01:00
Philip Rebohle c5958d36bc tests: Add test to stress-test virtual query implementation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle c6095e740d vkd3d: Do not create query pool for inline query types.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 7b524590ab vkd3d: Introduce d3d12_query_heap_type_is_inline.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 098ad5c071 vkd3d: Remove disable_query_optimization workaround.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 7ea11ededb vkd3d: Use virtual queries for transform feedback queries as well.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle c9525cf5ca vkd3d: Allocate new virtual query for active queries as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle b995780de1 vkd3d: Reimplement binary occlusion query resolve.
No longer requires BDA support since it's easier now to work
around buffer alignment issues.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 5c550b5cda vkd3d: Rewrite binary occlusion query resolve shader.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 32f7ba6630 vkd3d: Use virtual queries for inline query types.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 4a558ce501 vkd3d: Compute query stride from heap type rather than query type.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle abc204cea4 vkd3d: Create buffer for query heap as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 39c7f8f32d vkd3d: Introduce pending query list.
This will store the list of queries to resolve.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 6e3a7d37cc vkd3d: Store more information in active query list.
Allows us to map D3D12 queries to virtual queries and vice versa.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 59acbfeb41 vkd3d: Add query resolve pipelines to meta ops.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle cc8fb3ae1c vkd3d: Add query resolve shader.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Philip Rebohle 16f5cff061 vkd3d: Implement virtual query allocation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-19 14:11:46 +01:00
Hans-Kristian Arntzen 634d8fd0fa dxil-spirv: Update submodule.
Fixes HZD SSR regression.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-15 13:47:04 +01:00
Hans-Kristian Arntzen 6e50aaf11f tests: Modify typed_as_untyped test to test copies.
Verifies that copying multiple descriptors works as expected.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-14 15:34:20 +01:00
Hans-Kristian Arntzen a531ee5fd4 vkd3d: Remove force_bindless_texel_buffer workaround.
Obsolete now that we fully split typed and untyped buffer descriptors.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-14 15:34:20 +01:00
Hans-Kristian Arntzen 57f2124721 tests: Remove todo on typed_as_untyped test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-14 15:34:20 +01:00
Hans-Kristian Arntzen 97e0d8e751 vkd3d: Move bindless SSBO out of MUTABLE set and fill both descriptors.
We will need separate descriptor sets to be able to handle typed vs
untyped buffer workarounds.

Also writes multiple descriptors for buffers views to make sure MUTABLE
and SSBO sets are filled (or TEXEL_BUFFER + SSBO for non-mutable).

Applications often get this wrong and use raw buffer in shader where
typed view was written and vice versa.
To mitigate this, just write a typed and untyped view together.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-14 15:34:20 +01:00
Philip Rebohle 6bddcb4352 vkd3d: Store both byte range and element range in offset buffer.
The first range will store the byte offset, the second one will
be the typed buffer range. Typed descriptors should write both.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Co-authored-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-14 15:34:20 +01:00
Hans-Kristian Arntzen dbbde3c6f1 vkd3d: Remove VKD3D_DESCRIPTOR_FLAG_DEFINED.
This is redundant now since this information is carried by set_info_mask.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-14 15:34:20 +01:00
Hans-Kristian Arntzen 1bddaa0fff vkd3d: Allow a heap binding to cover multiple descriptors.
This begins the refactor toward letting us to use both texel buffer and
SSBO descriptors for typed buffers, which is a better workaround than
force_bindless_texel_buffers.

In this new approach, we store a mask in metadata instead of
set/binding.

When copying a descriptor, we will iterate over the masks and look up
binding directly from device->bindless_state.set_info[].

The mask is represented in terms of info index rather than set index to
avoid needless lookups. Add some new helpers to make this process
easier.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2021-01-14 15:34:20 +01:00
Philip Rebohle f25df5b453 vkd3d: Reset inline queries in BeginQuery.
We currently never reset occlusion queries. For some reason,
validation layers do not report this.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-14 13:38:21 +01:00
Henri Verbeet c42f4d11e2 vkd3d-shader: Decorate "precise" arithmetic instructions with SpvDecorationNoContraction.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
2021-01-12 15:22:11 +01:00
Philip Rebohle 29e3d292ae tests: Mark sparse depth image test as TODO on RADV.
Currently, RADV does not support sparse depth images.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-11 14:46:07 +01:00
Philip Rebohle 037efbdcda vkd3d: Add mapping for PACK16 formats.
Dirt 5 fails with an error message otherwise.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-01-08 18:37:26 +01:00
Hans-Kristian Arntzen d003424bc8 meta: Bump Meson build version to 2.1.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-14 12:12:12 +01:00
Hans-Kristian Arntzen 793fce068e meta: Slight modification to CHANGELOG.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-12 16:16:59 +01:00
Philip Rebohle a3d21494f7 vkd3d: Enable query workaround for AC:Valhalla.
Fixes #458.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-12 13:01:52 +01:00
Philip Rebohle b8c96d9b30 vkd3d: Add workaround to disable occlusion query optimization.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-12 13:01:52 +01:00
Hans-Kristian Arntzen e99a2c9da7 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-12 12:19:10 +01:00
Hans-Kristian Arntzen 49ed5beb63 meta: Add Cyberpunk 2077 to supported list with (huge) caveats.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-11 11:22:45 +01:00
Hans-Kristian Arntzen 9cbd1b2a0d vkd3d: Add Cyberpunk2077.exe to workaround detection.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-11 11:22:45 +01:00
Hans-Kristian Arntzen c2f1596b3e tests: Add test for reading typed R32 buffer as untyped.
Invokes undefined behavior that many games rely on by accident.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-11 11:20:55 +01:00
Philip Rebohle 946bcd7922 vkd3d: Do not store counter address in descriptor.
Unnecessary because the UAV counter buffer is a host memory
allocation anyway in case of host-only descriptor heaps, so
we will not read from uncached memory.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-10 18:14:16 +01:00
Hans-Kristian Arntzen 0cc374e0f8 meta: Add changelog for 2.1.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-09 14:56:24 +01:00
Hans-Kristian Arntzen 8797e15ddd meta: Add 2.0 change log as a file.
Makes it possible to review change logs with Git going forward.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-09 14:56:24 +01:00
Hans-Kristian Arntzen 193abc395b README: Document how to use VKD3D_DESCRIPTOR_QA_LOG.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-09 14:51:53 +01:00
Hans-Kristian Arntzen 22a907e11a vkd3d: Add descriptor QA logging.
When reading GPU hang dumps, we can figure out what happened to
descriptor types along the way.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-09 14:51:53 +01:00
Philip Rebohle 1d9f28b25f vkd3d: Add fast path for mutable descriptor copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-09 14:31:22 +01:00
Philip Rebohle 7d40d8a22e vkd3d: Rework descriptor copies to copy ranges.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-09 14:31:22 +01:00
Hans-Kristian Arntzen e2185df7de tests: Remove is_bug for MSAA clear test.
Fixed on Mesa master now (FMASK bug).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-07 20:56:48 +01:00
Hans-Kristian Arntzen a888d81422 vkd3d: Fix embarassing enum bug.
Caused crash when using a driver that did not support
mutable_descriptor_type.
Was using the wrong enum bitfields ... Sigh, type safe enums would be nice.
Regression caused during refactor in review most likely.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-07 20:55:56 +01:00
Hans-Kristian Arntzen 051ba691be vkd3d: Clarify comment about not using MEMORY_READ/WRITE.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-07 20:45:02 +01:00
Philip Rebohle c057e881dc vkd3d: Do not interrupt render pass for occlusion queries.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-07 15:18:12 +01:00
Hans-Kristian Arntzen 7711b9ba1a README: Mention VK_VALVE_mutable_descriptor_type as a key extension.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-07 15:17:08 +01:00
Hans-Kristian Arntzen aa21d2d03d vkd3d: Add support for VK_VALVE_mutable_descriptor_type.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-07 15:17:08 +01:00
Hans-Kristian Arntzen 76a7eb7c57 vulkan-headers: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-07 15:17:08 +01:00
Hans-Kristian Arntzen 4fa24bb4ee tests: Remove old is_bug for conditional rendering.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-07 14:10:51 +01:00
Hans-Kristian Arntzen 8fb88855e5 vkd3d: Hash buffers and views based on format, not vk_format.
The creation infos use the format, which potentially contains other
information as well.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-05 15:09:39 +01:00
Hans-Kristian Arntzen 6b363e53d2 vkd3d: Actually compare against hashmap entry and not against itself.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-05 15:09:39 +01:00
Hans-Kristian Arntzen e6961afca6 vkd3d-shader: Emit typed format for UAVs which use atomics.
Mesa will assert if not, and the format must be known here.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-04 16:08:26 +01:00
Philip Rebohle c4fbe47106 vkd3d: Do not interrupt render pass for timestamp queries.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-03 16:54:35 +01:00
Philip Rebohle e13d69ad27 vkd3d: Batch query pool reset commands if possible.
By resetting query pools in advance, we can reduce the number of
stalls between draw calls in passes with occlusion queries, which
is currently causing serious performance issues in some games.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-03 16:21:43 +01:00
Philip Rebohle 648e41716b vkd3d: Add additional command buffer to batch intialization commands.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-03 16:21:43 +01:00
Philip Rebohle d0fc57413e vkd3d: Merge adjacent query ranges on insertion.
Since we'll be inserting lots of single queries, we want to
avoid having to resize the range array since that is an O(n)
operation at worst.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-03 16:21:43 +01:00
Philip Rebohle 81e6449f67 vkd3d: Add code to track query ranges used within a command list.
Useful to batch vkCmdResetQueryPool calls.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-12-03 16:21:43 +01:00
Hans-Kristian Arntzen ee4508ba97 vkd3d: Fix sign vs unsigned compare warning.
UINT16 promotes to int rather than UINT here.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-03 15:05:13 +01:00
Hans-Kristian Arntzen f67f55827e vkd3d: Parse patch version of PACKAGE_NAME as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-03 15:05:13 +01:00
Hans-Kristian Arntzen adf0be5bf1 vkd3d: Lower contention when spinlocking writers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-02 13:12:56 +01:00
Hans-Kristian Arntzen b85a345d48 vkd3d: Fix const-ness warning on MSVC.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-02 13:12:56 +01:00
Hans-Kristian Arntzen 5f8659f4bb vkd3d: Use reader-writer spinlock in view map.
The common case is that we find an entry, so taking a writer lock should
be the rare case. We need to optimize for the case where the application
hammers the view map with e.g. buffers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-02 13:12:56 +01:00
Hans-Kristian Arntzen b3024365d0 vkd3d: Add a reader-writer spinlock.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-02 13:12:56 +01:00
Hans-Kristian Arntzen c2c674194d vkd3d: Add Add/Sub/And atomic u32 intrinsics.
Will be used for reader-writer spinlocks.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-02 13:12:56 +01:00
Hans-Kristian Arntzen f96e60b6ac vkd3d: Make hashmap compatible with reader-writer locks.
Yield insertion when there is a match.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-12-02 13:12:56 +01:00
Hans-Kristian Arntzen e0382cc451 vkd3d: Add extra typeless copy usage flags after clearing them.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-27 16:27:39 +01:00
Hans-Kristian Arntzen f46756ed85 vkd3d: Report if RTV/DSV resource does not set render target usage.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-27 16:27:39 +01:00
Hans-Kristian Arntzen c38fd9bfc3 vkd3d: Bind WHOLE_SIZE when using null SSBO descriptor.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-27 13:13:39 +01:00
Philip Rebohle 8c0958824a tests: Remove todo from 64-bit predicate test.
This is supported properly now as long as the device supports
buffer_device_address.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-27 12:43:39 +01:00
Philip Rebohle 2ec68af1d5 vkd3d: Add fallback path for predication using indirect draws.
Official AMD drivers do not support VK_EXT_conditional_rendering,
so we'll use indirect draws instead to emulate the feature.

This also handles 64-bit predicates in combination with the
Vulkan extension, which was not possible previously.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-27 12:43:39 +01:00
Philip Rebohle 82d9ba1ebf vkd3d: Add meta shader to generate predicated draw/dispatch commands.
The idea is to use indirect draws and dispatches to implement
predication. For predicated indirect draws, we'll use indirect
count.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-27 12:43:39 +01:00
Joshua Ashton e27a153a22 vkd3d-shader: Fix saturates of fp64 types
Closes: #419

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-27 11:11:59 +01:00
Hans-Kristian Arntzen 9cd082da69 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-25 20:22:37 +01:00
Joshua Ashton 22794c67a4 include: Add missing enum flag operator definitions
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-25 15:58:45 +01:00
Joshua Ashton 3e5a3c835a include: Fix definition of D3D12_RESOURCE_ALIASING_BARRIER
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-25 15:58:45 +01:00
Joshua Ashton 6b9f7b7339 include: Fix typo in d3d12 header
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-25 15:58:45 +01:00
Joshua Ashton fcb4764228 include: Update D3D12 headers
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-25 15:58:45 +01:00
Hans-Kristian Arntzen 1ce5ea8073 vkd3d: Fix segfault when freeing pipeline library.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-25 10:26:36 +01:00
Hans-Kristian Arntzen 8a102d6a1c dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-24 18:58:06 +01:00
Philip Rebohle 2c9bacd760 vkd3d: Perform binary occlusion query fixup on scratch buffer.
Potentially avoids some unnecessary host memory access. Use BDA for
the compute shader so that we can ignore alignment restrictions on
some GPU architectures.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-24 16:45:55 +01:00
Philip Rebohle 78076a9a84 vkd3d: Introduce d3d12_resource_get_va.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-24 16:45:55 +01:00
Philip Rebohle afb85c79cd vkd3d: Add code to create, destroy and recycle scratch buffers.
Command lists may need to allocate temporary device memory for
certain operations. In order to avoid frequent alloc/free calls,
we'll recycle these scratch buffers until a certain threshold.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-24 16:45:55 +01:00
Hans-Kristian Arntzen c0b34fdb7b tests: Add unaligned VBO read test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-24 15:07:29 +01:00
Hans-Kristian Arntzen 19193bf932 vkd3d: Sanitize VBO strides and VBO offsets.
Realign VBO strides and offsets if we have to, for sake of
robustness. Violating these rules is against D3D12 spec, but it does not
cause crashes on native drivers. On RDNA we can hit hangs with unaligned
vertex attributes. It appears that native drivers apply some kind of
fixup here to avoid the crash, even if the result is not what we expect.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-24 15:07:29 +01:00
Hans-Kristian Arntzen 10b503c893 vkd3d: Fallback to NULL VA when binding non-existent VBO.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-24 15:07:29 +01:00
Philip Rebohle 9d57489225 vkd3d-shader: Correctly handle infinity in f32tof16.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-23 15:46:55 +01:00
Philip Rebohle ced72326be tests: Test f32tof16 behaviour with infinity and high numbers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-23 15:46:55 +01:00
Philip Rebohle 8cbecfb9f6 vkd3d: Fix offset for predicate buffer.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-20 11:23:06 +01:00
Philip Rebohle 35f6aa22c7 tests: Remove todo for binary occlusion query test.
This test passes correctly now.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-19 22:08:42 +01:00
Philip Rebohle fb6f078ba9 vkd3d: Fix up binary occlusion query results.
In D3D12, these return 1 rather than an actual sample count.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-19 22:08:42 +01:00
Philip Rebohle 89aea3304c vkd3d: Always add STORAGE_BUFFER_BIT to readback buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-19 22:08:42 +01:00
Philip Rebohle fdd0dbafe4 vkd3d: Add meta compute shader to resolve binary occlusion queries.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-19 22:08:42 +01:00
Philip Rebohle 6886bb7f11 vkd3d: Handle empty viewports.
Assassin's Creed Valhalla relies on this.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-19 14:31:39 +01:00
Philip Rebohle ecc504922e vkd3d: Consider mip level for 3D UAV slice check.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-19 14:20:28 +01:00
Hans-Kristian Arntzen ffc1fa646c vkd3d: Mask out attachments which cannot safely be written to.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-19 14:13:59 +01:00
Hans-Kristian Arntzen 0dc0d75967 vkd3d: Use VK_IMAGE_LAYOUT_UNDEFINED for unused attachments.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-19 14:13:59 +01:00
Georg Lehmann 11bdc76aa0 vkd3d: Use static init for device map.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2020-11-18 18:29:48 +00:00
Georg Lehmann 24100cac07 vkd3d: Add Win32 PTHREAD_MUTEX_INITIALIZER.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2020-11-18 18:29:48 +00:00
Hans-Kristian Arntzen d0328e8760 vkd3d: Fix uninitialized variable in initial WSI transition.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-18 16:40:17 +01:00
Hans-Kristian Arntzen 9617a0f598 vkd3d: Disable RAW_VA root CBVs on NVIDIA.
BDA cannot map to their hardware, and we observe a large performance
loss in games which use root CBVs. For this reason, fall back to push
descriptors here.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-18 15:49:31 +01:00
Hans-Kristian Arntzen 52ee2edc3d vkd3d: Separate root VA use for CBV and SRV/UAV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-18 15:49:31 +01:00
Philip Rebohle 5a288b7d0f tests: Adjust todos in some query tests.
Query init changes broke unissued timestamp queries, but
test_resolve_query_data_in_reordered_command_list passes.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-18 15:45:28 +01:00
Philip Rebohle 215989f6d5 vkd3d: Rework query pool initialization.
Ensures that queries are always available and initialized
in the correct order on the GPU timeline.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-18 15:45:28 +01:00
Philip Rebohle bb9d0f2741 vkd3d: Rework initial transitions to allow for different types.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-18 15:45:28 +01:00
Philip Rebohle 10e82fa7a0 tests: Add missing UAV barriers in test_cs_uav_store.
Fixes some random test failures.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-18 15:05:29 +01:00
Hans-Kristian Arntzen 27f91b99b0 vkd3d-shader: Add debug log callback to DXIL.
Allows us to capture dxil compiler messages in log.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-18 14:37:58 +01:00
Joshua Ashton a950191008 vkd3d: Implement singleton devices.
Matches D3D12 behaviour.

Co-authored-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-18 12:39:14 +01:00
Philip Rebohle 1563b80852 include: Fix various issues with atomic CAS.
- fail/success memory orders exist for a reason, we can't
  e.g. do release on fail since it's a read-only operation
- silence some warnings about pointer->integer casts
- fix linker errors on mingw by marking functions as static

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-18 12:39:14 +01:00
Hans-Kristian Arntzen f54ac3b9c5 vkd3d: Add app detection for buggy game: ds.exe.
Game renders the map with wrong descriptor type, which means we must
implement everything as texel buffers to make this work.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-18 12:27:19 +01:00
Hans-Kristian Arntzen 6f8ae20015 vkd3d: Add VKD3D_CONFIG option to disable bindless SSBO.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-18 12:27:19 +01:00
Hans-Kristian Arntzen d947c17fc2 meta: Add missing VKD3D_DEBUG level to README.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-18 12:27:19 +01:00
Philip Rebohle bab9b0af92 vkd3d: Support offset buffers for raw/structured texel buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Co-authored-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-18 12:27:19 +01:00
Hans-Kristian Arntzen 3e15a3f06a vkd3d: Remove manual tracking of host barriers.
Just emit host barrier on submit unconditionally.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-17 16:34:03 +01:00
Hans-Kristian Arntzen 0f25b827e0 vkd3d: Use pipeline barrier command buffers for queue serialization.
We have observed a lot of large GPU bubbles when using back-to-back
timeline semaphores to synchronize GPU submissions. Use prebaked
pipeline barrier command buffers instead.

To resolve queue sparse serialization, use two binary semaphore pairs to
resolve this. There is no need to use timeline semaphores in this case.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-17 16:34:03 +01:00
Philip Rebohle 8fe83f5e9c vkd3d-shader: Correctly handle bit shifts greater than 31 bits.
This is undefined behaviour in SPIR-V, but well-defined in
DXBC, so we should explicitly 'and' the shift amount with 31.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-17 15:26:36 +01:00
Hans-Kristian Arntzen 0749f46d8e vkd3d: Re-enable wave ops.
dxil-spirv update fixed the issue for me.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-17 10:49:40 +01:00
Hans-Kristian Arntzen de4293f990 vkd3d: Use SHADER_READ for CBV visibility when using ROOT_VA CBV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-16 17:01:58 +01:00
Hans-Kristian Arntzen 30c417bdbf dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-16 16:55:55 +01:00
Joshua Ashton 4d95cafe10 vkd3d: Implement compare exchange atomics
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-16 09:33:26 +01:00
Joshua Ashton 1e810e8f9e vkd3d: Use consistent comment style in atomic header
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-16 09:33:26 +01:00
Joshua Ashton 093f0eb053 vkd3d: Implement 64-bit and pointer atomics
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-16 09:33:26 +01:00
Joshua Ashton 71328b9be7 vkd3d: Handle reserved resources in host barrier code
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-16 09:25:50 +01:00
Joshua Ashton 08135f7746 vkd3d: Fix validation spam for null descriptor buffers
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-16 09:25:17 +01:00
Hans-Kristian Arntzen 412ec7ac2f vkd3d: Enable root descriptor BDA support.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-13 17:10:48 +01:00
Hans-Kristian Arntzen a1d851e717 vkd3d-shader: Do not require Int64 to use root descriptors.
Can just use uvec2. Also improves performance on ACO since ACO cannot
promote uint64_t to SGPR yet, u32x2 however, works fine and can be
bitcast to pointer as well.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-13 17:10:48 +01:00
Hans-Kristian Arntzen 009b3a69e0 vkd3d-shader: Update dxil-spirv with BDA root descriptor support.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-13 17:10:48 +01:00
Hans-Kristian Arntzen 74a654e273 vkd3d: Disable waveops for time being.
The fix which enabled waveops detection broke HZD, since we never tested
with that feature enabled.

Keep it disabled until we can figure out what is going on.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-13 12:58:22 +01:00
Philip Rebohle 3da44beb5d vkd3d: Change USE_PUSH_DESCRIPTORS to USE_ROOT_DESCRIPTOR_SET for clarity.
USE_PUSH_DESCRIPTORS may be misleading since it would be set even when
we're not using push descriptors at all due to root descriptors being
passed in via VAs. Instead, make the flag represent whether or not we
use a regular descriptor set for root parameters.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle baf265c666 vkd3d: Update root descriptor VAs as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 8999093c54 vkd3d: Add new field to store root descriptor VA.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 677422993e vkd3d: Add root descriptor VAs to push constant range.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle cd01371756 vkd3d: Always enable BUFFER_DEVICE_ADDRESS usage for buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle c11b58418a vkd3d-shader: Support physical storage buffer root SRVs/UAVs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 4313eaa59c vkd3d-shader: Support physical storage buffer root CBVs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 5d2b0e6632 vkd3d-shader: Add loadv/storev helpers for aligned memory access.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 6c9d0cea69 vkd3d-shader: Rename descriptor_table_var_id -> root_parameter_var_id.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 4b3cec53fc vkd3d-shader: Declare push constants for root descriptor VAs.
We'll always place them at the beginning of the push constant
buffer in order to avoid potential alignment issues.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle 2689c9e0a3 vkd3d-shader: Enable Int64 capability as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle f69564c6c1 vkd3d-shader: Implement buffer reference type declarations.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-12 15:21:56 +01:00
Philip Rebohle b536723f5a vkd3d: Fix shader model-related feature detection.
We need to know the supported shader model to detect support
for certain features like wave ops correctly.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-11 10:41:11 +01:00
Joshua Ashton d4d14dfca0 vkd3d: Ignore DXGI_PRESENT_ALLOW_TEARING
Fixes warning spam in Horizon Zero Dawn.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-09 15:34:08 +01:00
Joshua Ashton 536ed0427a vkd3d: Create user buffers for degenerate surfaces
Previously this would make the user buffer count == 0, which obviously makes apps and assertions not happy.

Fixes a crash in Horizon Zero Dawn when minimized (therefore having a degenerate surface region)

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-09 15:34:08 +01:00
Joshua Ashton c77428ba44 vkd3d: Implement DXGI_PRESENT_TEST
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-09 15:34:08 +01:00
Alexander Gabello da4a96a25b vkd3d: Free string after PIX decoding
Signed-off-by: Alexander Gabello <alexandergabello@mail.weber.edu>
2020-11-09 10:55:05 +01:00
Hans-Kristian Arntzen 60ac9b4d51 Mark version 2.0.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-06 17:13:19 +01:00
Philip Rebohle 432ba00e3c vkd3d: Only care about DSV mismatch if pipeline actually uses it.
Avoids some unnecessary late compiles in Monster Hunter World.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-06 16:36:27 +01:00
Philip Rebohle 58548a3db2 vkd3d: Fix image memory barrier after fragment shader-based copy.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-06 16:07:47 +01:00
Philip Rebohle 408fed0910 vkd3d: Fix root descriptor indexing.
The packed descriptor index is no longer needed, and causes issues in
case a game sets a root signature, then binds a root descriptor, and
then sets a different root signature which maps the given root parameter
index to a different descriptor since we may now read undefined data
when updating push descriptors.

Fixes #366.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-06 16:07:47 +01:00
Hans-Kristian Arntzen 6b37d36de4 meta: Update COPYING year/name.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-06 16:03:39 +01:00
Hans-Kristian Arntzen 5a666c5f70 meta: Take a pass over the README.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-06 16:03:39 +01:00
Hans-Kristian Arntzen 210ce3b1e2 meta: Update AUTHORS.
Add the main contributors to vkd3d-proton.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-06 16:03:39 +01:00
Hans-Kristian Arntzen 9425dceace meta: Remove old vkd3d 1.1 ANNOUNCE.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-06 16:03:39 +01:00
Joshua Ashton c5e3779257 build: Replace build_linux32 with env vars
This is much distro-agnostic.

(Only sane distros [Arch] use /usr/lib32 and not /usr/lib/i386-linux-gnu)

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-05 16:46:22 +00:00
Juuso Alasuutari 6bfead391d build: fix build_arch() in package-release.sh so that quoted input arguments behave normally
Signed-off-by: Juuso Alasuutari <juuso.alasuutari@gmail.com>
2020-11-05 16:35:40 +00:00
Joshua Ashton 8dea487861 meta: Add missing newlines to end of files
Remove trailing whitespace also

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-05 17:16:57 +01:00
Joshua Ashton a18da4560d build: Fix pkgconfig and install target
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-05 17:16:57 +01:00
Hans-Kristian Arntzen 490d803581 vkd3d-shader: Add OpSource support to DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-05 15:57:16 +01:00
Hans-Kristian Arntzen 7e14f80e2a vkd3d-shader: Emit OpSource with DXBC hash.
Makes it possible to backtrace which shader we're working with
when we get raw SPIR-V from unrelated sources (Fossilize or RADV crash
dumps for example).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-05 15:57:16 +01:00
Philip Rebohle a8f9cc15b3 vkd3d: Create root signature from shader blobs as necessary.
MSDN states that root signatures across multiple stages in a graphics
pipeline must be identical, but the D3D12 runtime does not validate
this and mixing different root signatures results in undefined
behaviour, so just taking this from the VS should be safe.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-05 15:21:16 +01:00
Philip Rebohle 1d823f8659 vkd3d: Do not store root signature in graphics pipeline state.
We only need to know the pipeline layout for pipeline variant
creation. We are not holding a strong reference to the root
signature anyway, which may be problematic, but this should
not introduce a regression.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-05 15:21:16 +01:00
Philip Rebohle a1198f2af8 tésts: Add test for creating pipeline states with a null root signature.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-11-05 15:21:16 +01:00
Georg Lehmann 8c93ebc83a build: Fix quotes in package-release.sh.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2020-11-05 11:33:37 +01:00
Georg Lehmann 98f005116b build: Replace enable_standalone_d3d12 with tristate enable_d3d12.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2020-11-04 23:38:02 +00:00
Hans-Kristian Arntzen f37254e6b6 tests: Add test for many typed buffers.
Verifies that can we can spam unique typed views without problems ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen e4600edb03 vkd3d: Always enable typed offset buffer.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen f1991d4458 vkd3d: Init descriptor heap offset buffer if we're only using typed.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen 670fba6c6f vkd3d: Enable typed offset buffer in root signature.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen 320b643c77 vkd3d-shader: Add typed offset to DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen bcd03de770 vkd3d-shader: Implement typed buffer offset.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen 1c14fc9334 vkd3d: Write typed buffer offsets to buffer.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen d23c7200a2 vkd3d: Always copy offset buffer descriptor info.
Offset buffer state might be the only relevant difference between two
descriptors. We won't need to copy descriptors, but the offsets must be.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen 572ea9da7f common: Enable popcount and clz paths based on compiler.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen 5832d2fbdd vkd3d: Refactor out typed buffer view creation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen 749ac13f5e vkd3d: Rename vkd3d_buffer_view_get_bound_range.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen f0754c4460 vkd3d: Apply offset to typed UAV as well in ClearUAV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen b30d8788bf vkd3d: Rename SSBO_OFFSET descriptor flag to BUFFER_OFFSET.
It is used for typed as well.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen 5d88e4d435 vkd3d: Add a definition for typed offset buffer as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen 2158ed716b vkd3d-shader: Add a TYPED_OFFSET_BUFFER to shader interface as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen fdd16168be vkd3d: Rename SSBO_OFFSET_BUFFER to a more generic offset buffer.
We will use it for typed buffers as well.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen 5674ced973 vkd3d: Report if view maps have intense pressure.
This will lead to a crash if it goes too far.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Hans-Kristian Arntzen e31eae075b vkd3d: Fix deadlock after failing to create view map entry.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-11-04 19:05:28 +01:00
Joshua Ashton 5c1b40b856 vkd3d: Init hashmap in vkd3d_create_image_resource
Closes: #353
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-03 09:39:35 +01:00
Joshua Ashton f50c897868 build: Merge vkd3d_headers into vkd3d_common
Fixes MSVC build.
Closes: #343

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-03 09:37:24 +01:00
Joshua Ashton 43d94a9b2f vkd3d-compiler: Define debug channel
We need this if we include vkd3d_shader since the memory include header got fixed.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-03 09:35:44 +01:00
Joshua Ashton 7325a49bd6 vkd3d: Include correct memory header in hashmap
Fixes warnings about implicit declaration of these functions
when building demos/programs which could be very bad on x64 if used.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-11-03 09:35:44 +01:00
Philip Rebohle 624f96e820 tests: Add test for RTV descriptor copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-30 17:02:17 +01:00
Philip Rebohle 13a95bb7bc tests: Add test for NULL RTV creation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-30 17:02:17 +01:00
Philip Rebohle 601abe7408 vkd3d: Reset RTV/DSV descriptors when creating NULL descriptor.
Otherwise, we may run into issues with an app accessing stale resource
or pointers. NULL descriptors are handled in OMSetRenderTargets.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-30 17:02:17 +01:00
Philip Rebohle f29b397a9f vkd3d: Implement RTV/DSV descriptor copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-30 17:02:17 +01:00
Philip Rebohle f3c35b2992 vkd3d: Remove unused descriptor magic from RTV/DSV descriptors.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-30 17:02:17 +01:00
Philip Rebohle 211704be3f vkd3d: Use per-resource view maps to create render target views.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-30 17:02:17 +01:00
Philip Rebohle 109c881ccb vkd3d: Unify RTV and DSV descriptor types.
The struct definitions were identical anyway, and unifying
these will prevent unnecessary code duplication.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-30 17:02:17 +01:00
Philip Rebohle bd1de243d3 vkd3d: Don't skip indirect dispatches with count buffer.
The only currently known use case for this requires us to actually
perform the dispatch operation. Executing more than one indirect
dispatch command is not meaningful, however there might be
differences in behaviour in case the indirect count is zero.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-30 16:56:18 +01:00
Philip Rebohle c50e529be0 vkd3d: Fix descriptor table mask when populating inline uniform block data.
This logic has to be the same as in d3d12_command_list_update_descriptor_table_offsets,
since not all active descriptor tables are necessarily used by the root signature.

Fixes an assert in the StarsX IrradianceMap demo (Github issue #347).

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-30 16:56:18 +01:00
Hans-Kristian Arntzen 3f0d2f3362 tests: Use more precise todo_if in buffer feedback tests.
We should still pass typed buffer tests.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen f6fa91ae5d tests: Remove marked bug which appears to be fixed.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen 64adb271a1 tests: Fix some UNORM precision inconsistencies.
NV rounds down to 0.5 - epsilon where AMD rounds up. Use a stable value
for UNORM8/16 testing.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen f991dea51a tests: Report successful TODOs separately from failures.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen cd416a866e tests: Do not test so many queues.
AMD Windows will actually fail eventually since we're trying to create
too many queues.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen cf7ac276d6 tests: Skip calibrated timestamp test on Linux.
Meaningless to test and triggers errors.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen 4b5b14ca4b tests: Mark buffer feedback as TODO.
With SSBOs we cannot implement sparse buffer feedback.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen 8c24e2c5c5 tests: Mark stencil export as TODO on DXIL.
Not implemented yet, but will not crash.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen dba2812998 tests: Skip bindless bufinfo tests for now on RADV.
Can hang system in the worst case.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen 922a67f910 tests: Mark MSAA array clear test as buggy on RADV.
See Mesa issue #3710.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen 10d13dd2c1 tests: Fix up some TODO is dual_source_blending test.
Some calls are apparently supposed to fail, and we were not cleaning up
handles correctly if the calls succeeded.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen 4ed553acc4 tests: Mark patch constant test as bug on RADV.
Don't see anything obviously wrong with the test or implementation.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen 0db76f85a4 tests: Unmark some signed atomic tests as TODO.
They pass on RADV.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen ddbdd81675 tests: Mark some multisample tests as TODO on RADV.
Likely a mismatch in sample positions?

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen 00ccf0b2d3 tests: Fix test sync bug in draw_uav_only.
Test was missing a UAV barrier, which triggered "bug" on RADV.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Hans-Kristian Arntzen f9679e9e8d tests: Remove RGB9E5 from todo condition.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-30 08:16:16 +01:00
Joshua Ashton 5ca255d7c1 build: Eliminate need for x86-linux-gnu cross file
Replace this with our own build-linux32.txt

Closes: #336

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-29 15:56:54 +01:00
Philip Rebohle 1abae6eb06 vkd3d-shader: Remove unused sampler comparison mask.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-29 15:39:40 +01:00
Philip Rebohle a2d85f6040 vkd3d-shader: Use new register map to store UAV flags.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-29 15:39:40 +01:00
Philip Rebohle 0d82bf67aa vkd3d-shader: Add hash map for register flags to scan info.
This way we won't have arbitrary register count limitations.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-29 15:39:40 +01:00
Philip Rebohle 9832d1639d vkd3d-shader: Remove pNext chain from vkd3d_shader_scan_info.
Unused.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-29 15:39:40 +01:00
Philip Rebohle c53a0d6365 include: Fix hashmap constness issues.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-29 15:39:40 +01:00
Joshua Ashton c72fb12353 build: Only generate headers once
This makes headers a dependency rather than a generator target.
This also means we get proper dependency tracking of them between projects.

Supercedes: #225
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-29 10:02:48 +01:00
Joshua Ashton a1a6840fb5 vkd3d-utils: Move to .def exports
Otherwise this won't work in MSVC because it'd technically be re-defining the D3D12 function prototypes with the decltypes.

There is no other nice way around this.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-28 17:05:13 +01:00
Joshua Ashton 37e6647ab0 vkd3d-utils: Add D3D12EnableExperimentalFeatures interface
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-28 17:05:13 +01:00
Hans-Kristian Arntzen bb1d57b769 vkd3d: Use INFO rather than TRACE for some relevant messages.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 17:03:54 +01:00
Hans-Kristian Arntzen d8bd309ab2 vkd3d: Log vkd3d applicationVersion and build hash.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 17:03:54 +01:00
Hans-Kristian Arntzen cd9c1fb9f3 vkd3d: Add an INFO debug level.
Useful for cases where we want to communicate important information to
the log by default, but not consider it an error.

Requested information which would only be logged when explicitly asked
for should also be considered INFO.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 17:03:54 +01:00
Hans-Kristian Arntzen f62f5e4fd7 build: Update package-release for rename.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 15:38:20 +00:00
Hans-Kristian Arntzen 28271ed854 README: Update old vkd3d references.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 15:38:20 +00:00
Hans-Kristian Arntzen 8cd30ee1c7 build: Rename exposed APIs to reflect vkd3d-proton and update to 2.0.
Rename so objects we build so we don't conflict with vkd3d and don't
accidentially attempt to be built against Wine natively (it won't work).

Not quite ready for a 2.0 release yet, but bump the version to reflect
the intent. This creates a new timeline, completely separate from vkd3d.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 14:39:09 +01:00
Hans-Kristian Arntzen 7359720448 Update so-version to 2.0.
We've broken ABI compatibility with 1.1 with swapchain rework.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 14:39:09 +01:00
Hans-Kristian Arntzen bbdbc40359 build: Do not install test binaries.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 14:39:09 +01:00
Hans-Kristian Arntzen 4d961f96ea vkd3d: Fix some nits with declaration-after-statement.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 11:04:06 +01:00
Hans-Kristian Arntzen 336ca7e79f meson: Enable -Wdeclaration-after-statement
Makes it easier to enforce existing coding style.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 11:04:06 +01:00
Krzysztof Bogacki 61b13cc278 build: Use separate version string and build hash
Version string is used in logging for information purposes, but pipelines blobs and libraries use uint64_t–based commit hash. Using fixed–size integer silences warnings about string length and makes storing build info a little more efficient.

The hash is obtained separately from version string and is shifted to the left by 4 bits if the working tree is dirty.

Signed-off-by: Krzysztof Bogacki <krzysztof.bogacki@leancode.pl>
2020-10-28 10:40:28 +01:00
Philip Rebohle 49d3fa30a7 vkd3d: Enable offset buffer as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Hans-Kristian Arntzen a4f68931bb vkd3d-shader: Add offset buffer path to DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-28 10:30:12 +01:00
Philip Rebohle 127b498a5a vkd3d: Adjust SSBO descriptors based on alignment requirements.
And write data to the offset buffer.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle 374adc8bb7 vkd3d: Account for buffer offset info in clear_uav.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle b57a5dd96d vkd3d: Add extra binding for SSBO offset buffer.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle 811235858c vkd3d: Allocate descriptor heap buffer storage for bound SSBO ranges.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle 7aaae61c64 vkd3d: Refactor descriptor heap buffer creation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle 36bdc02a05 include: Introduce void_ptr_offset.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle 15b1fb7128 vkd3d: Restore d3d12_device_use_ssbo_root_descriptors.
We will not have offset information for root descriptors, so
we can still only use them with four-byte aligned SSBOs.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle d59317e11b vkd3d-shader: Use offset buffer for bufinfo instruction.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle fc9efddbd4 vkd3d-shader: Use offset buffer when indexing into raw SSBO.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Philip Rebohle bea196e449 vkd3d-shader: Declare offset buffer.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-28 10:30:12 +01:00
Krzysztof Bogacki f7cca758a6 vkd3d: Bit–shift last argument of MAKE_MAGIC
Signed-off-by: Krzysztof Bogacki <krzysztof.bogacki@leancode.pl>
2020-10-27 19:52:57 +01:00
Hans-Kristian Arntzen 3772e706a6 tests: Add exhaustive OOB test for UAV writes.
Tests and verifies behavior for writing out-of-bounds.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-26 13:16:09 +01:00
Joshua Ashton c3e3965797 tests: Add some simple double float tests
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton 7609c5e59e vkd3d-shader: Implement 64-bit immediate constants
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton 73a2ad19ea vkd3d-shader: Implement DRCP
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton e3a61ebad1 vkd3d-shader: Implement DTOF, FTOD, DTOI, DTOU, ITOD and UTOD
Implement double -> other type conversions

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton aff1391026 vkd3d-shader: Implement DEQ, DGE, DLT and DNE
Implement double comparisons

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton cdedfd596e vkd3d-shader: Implement DMOVC
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton f8646bff5a vkd3d-shader: Implement DADD, DMUL, DDIV, DMAX, DMIN, DFMA and DMOV
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton a581f296ea vkd3d-shader: Handle double-related global flags
Decode and handle DOUBLE_PRECISION_FLOAT_OPS and 11_1_DOUBLE_EXTENSIONS

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton ac2456b01f vkd3d-shader: Implement double data type
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Joshua Ashton 8e896cd25a vkd3d-shader: Support 64-bit constants
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-23 12:40:38 +02:00
Philip Rebohle dd13d44bd5 vkd3d: Use UAV counter address binding from descriptor heap.
Instead of binding it via push descriptors at draw time.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-23 12:36:17 +02:00
Philip Rebohle a76e311c5e vkd3d: Add UAV counter address buffer to descriptor heap bindings.
Introduces 'extra' bindings to bindless sets which can be used to
bind additional storage buffers to the pipeline, which will occur
before the bindless descriptor array in the descriptor set.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-23 12:36:17 +02:00
Philip Rebohle 7e32f833ed vkd3d: Store binding index in descriptor.
Needed for when we add additional descriptors to the bindless
descriptor sets.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-23 12:36:17 +02:00
Hans-Kristian Arntzen 16f09a0ba0 vkd3d: Do not perform any alignment analysis for SSBOs.
We cannot rely on alignment analysis since games are buggy and screw up
RAW vs structured on occasion.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-22 13:07:05 +02:00
Joshua Ashton c319a95d4e tests: Remove lingering INITIAL_STATE_TRANSITION
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-22 09:30:24 +02:00
Joshua Ashton ae93fe0941 vkd3d: Remove VKD3D_RESOURCE_PUBLIC_FLAGS
There was no reason to mask this anyway when importing images.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-22 09:30:24 +02:00
Joshua Ashton 4fb3e277f1 vkd3d: Remove VKD3D_RESOURCE_PRESENT_STATE_TRANSITION
All this flag does is make resource creation fail.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-22 09:30:24 +02:00
Joshua Ashton 85d4d4b7cf build: Fix globbing in package-release
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-21 16:58:28 +01:00
Joshua Ashton a027b9732a build: Add install script to packaged releases
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-21 16:58:28 +01:00
Hans-Kristian Arntzen eed4f54a80 vkd3d: Enable SSBO path.
For now, don't enable it on NV due to a very likely driver bug.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-21 14:34:37 +02:00
Hans-Kristian Arntzen 0801b0d55f vkd3d-shader: Hook up typed uav read without format on DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-21 14:34:37 +02:00
Hans-Kristian Arntzen 216f04d8f1 vkd3d-shader: Hook up new SSBO path for DXIL.
Update dxil-spirv submodule.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-21 14:34:37 +02:00
Hans-Kristian Arntzen 463d398c74 tests: Don't crash in buffer_feedback test.
With SSBOs enabled, sparse feedback won't work.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-21 14:34:37 +02:00
Hans-Kristian Arntzen 5b115b1f89 tests: Don't return garbage in create_*_state on failure.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-21 14:34:37 +02:00
Hans-Kristian Arntzen 50ffdb1850 vkd3d-shader: Don't warn about not finding a RAW_SSBO binding.
This is expected if host implementation does not support RAW_SSBO
alignment.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-21 14:34:37 +02:00
Joshua Ashton 1e828e4d1d demos: Fix compiling demos on Linux
These failed to compile previously due to us removing INITIAL_STATE_TRANSITION and deprecating PRESENT_STATE_TRANSITION.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-21 14:27:16 +02:00
Joshua Ashton aadf3e15f9 vkd3d-shader: Hook up EMIT_THEN_CUT_STREAM
Still needs work to handle emitting a specific stream.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-21 11:49:31 +02:00
Joshua Ashton b70182420a vkd3d-shader: Implement EMIT_THEN_CUT
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-21 11:49:31 +02:00
Joshua Ashton 31901597d9 vkd3d-shader: Implement EVAL_SNAPPED
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-21 11:49:31 +02:00
Joshua Ashton 1673d14841 vkd3d-shader: Implement UMUL
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-21 11:49:31 +02:00
Joshua Ashton 7c693fe26f vkd3d-shader: Implement UMAD
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-21 11:49:31 +02:00
Philip Rebohle a64a34eb9d vkd3d-shader: Implement coherent qualifier for UAVs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-20 14:44:55 +02:00
Joshua Ashton 36f6715b38 vkd3d-shader: Rename TEXKILL to DISCARD
TEXKILL is the old D3D9 style naming that comes with funky .w implications.
Calling DXBC's discard texkill is misleading.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-19 19:12:48 +02:00
Joshua Ashton 69bfad91a8 vkd3d-shader: Remove d3d9 clutter
All of this is entirely unused and just cluttering up.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-19 19:12:48 +02:00
Joshua Ashton b65f6ad02c vkd3d-shader: Add missing opcodes
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-19 17:27:07 +02:00
Philip Rebohle f9c712ded0 vkd3d: Fix descriptor layout mismatch for ClearUAV.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 17:38:58 +02:00
Philip Rebohle 544a6184e9 vkd3d: Enable raw SSBOs for root descriptors on supported hardware.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 16:20:26 +02:00
Philip Rebohle 4841630876 vkd3d: Store descriptor type with root descriptors.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 16:20:26 +02:00
Hans-Kristian Arntzen 1c76072819 vkd3d: Use EXTENDED_USAGE_BIT on mutable format images.
If the image itself is sRGB or some other format that does not support
STORAGE, we need this flag.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Hans-Kristian Arntzen 5b44ffa831 swapchain: Fix warnings.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Hans-Kristian Arntzen 69f54ae049 swapchain: Handle maxImageExtent of 0.
This can happen on Windows when windows are minimized.
Might not happen in winevulkan, but Vulkan spec outlines this Win32 case
explicitly and it happens on native Windows.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Hans-Kristian Arntzen 65031753ae swapchain: Blit to screen with render pass.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Hans-Kristian Arntzen 09b0675b53 swapchain: Handle VK_SUBOPTIMAL_KHR.
It is considered a "success", in that fences must be signalled, so make
sure we wait and reset it so we don't risk calling vkAcquireNextImageKHR
later with an already signalled fence.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Hans-Kristian Arntzen 9b25141bb8 swapchain: Only support user images.
Only way to implement a D3D12 swapchain.
For now, disable compute paths, we'll introduce it properly after refactor.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Hans-Kristian Arntzen 4f0bc383b7 swapchain: Make use of initial image transition.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Hans-Kristian Arntzen d7e9713c4c vkd3d: Add external API to perform initial transition.
Relevant for swapchain since a swapchain resource can be presented right
away without ever having been touched by an API call.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Hans-Kristian Arntzen a8ef7384b4 vkd3d: Remove support for obsolete PRESENT_STATE_TRANSITION.
It is broken by design and won't be needed by a swapchain
implementation which uses user buffers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 13:25:59 +01:00
Philip Rebohle 677e55c6f9 vkd3d: Store UAV counter address in d3d12_desc.
May improve performance since the UAV counter buffer is
stored in uncached memory.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 991d40006b vkd3d: Fix maximum workgroup count for clearing buffer UAVs.
Buffer views do not necessarily cover the entire resource, so we
should not spawn more workgroups than necessary to clear the view.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 6401cc353e vkd3d: Support raw buffer views in ClearUnorderedAccessView*.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 3e1445eacb vkd3d: Add meta pipeline to clear raw storage buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 290f44254a vkd3d: Implement descriptor updates for SSBOs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 993cdd254e vkd3d: Emit resource declarations for raw SSBOs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 3eac9f9c7d vkd3d: Introduce vkd3d_bindless_set_flag.
This will allow us to use the same bindless descriptor set for
different types of descriptor ranges.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle c097c00167 vkd3d: Explicitly set descriptor types for bindless sets.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle d3abc66399 vkd3d: Do not store UAV counter info in vkd3d_view.
We won't necessarily have a view once we support raw SSBOs.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 07e6687f6a vkd3d: Rework descriptor set lookup.
This is no longer performance-critical, so in order to simplify changing
the binding model, remove hard-coded descriptor set numbers and instead
look them up based on the requested descriptor properties.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle bffadd1f23 vkd3d: Rename vk_cbv_info -> buffer.
This will no longer be exclusive to constant buffer views.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 6461ab8272 vkd3d-shader: Implement bufinfo instruction on SSBOs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 89dbd9254f vkd3d-shader: Implement atomic operations on SSBOs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle f12f15ff38 vkd3d-shader: Implement raw and structured stores to SSBOs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle 2d2dc323d5 vkd3d-shader: Implement raw and structured loads from SSBOs. 2020-10-16 14:24:36 +02:00
Philip Rebohle 367cda017f vkd3d-shader: Implement resource declarations with raw SSBOs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Philip Rebohle b82bbe265e vkd3d: Pass storage buffer alignment to shader compiler.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-10-16 14:24:36 +02:00
Hans-Kristian Arntzen 3a4e555e9c vkd3d: Track if we have a valid index buffer bound.
Ignore any indexed draw calls which uses a NULL index buffer.
This is not fully correct, but there is no easy way to emulate D3D12
behavior exactly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 12:27:20 +02:00
Hans-Kristian Arntzen 9a8d2a1ac5 tests: Add a test for rendering with NULL index buffer.
This is well-defined in D3D12 for some reason.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 12:27:20 +02:00
Hans-Kristian Arntzen de3f572c8b tests: Add test for bindless bufinfo/resinfo.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-16 11:43:35 +02:00
Hans-Kristian Arntzen f1818c267f vkd3d: Fix menu regression in RE2.
If rendering to A8 format, do not apply output swizzle in non-PS stages.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-14 10:46:46 +02:00
Hans-Kristian Arntzen f0f1ca161f vkd3d: Always pass down compiler args.
Needed for all stages since typed UAV read can happen in all stages.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-12 14:55:24 +02:00
Hans-Kristian Arntzen 202a3257d7 vkd3d: Make use of StorageImageReadWithoutFormat if supported.
Death Stranding makes use of typed load from RGB10A2.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-12 14:55:24 +02:00
Hans-Kristian Arntzen 85dbb6c569 vkd3d-shader: Support StorageImageReadWithoutFormat.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-12 14:55:24 +02:00
Hans-Kristian Arntzen af5a4cf311 vkd3d: Use a unique cookie per resource/view.
We cannot compare resource pointers or view pointers,
since the pointers might have been recycled.
This leads to a scenario where we're not updating descriptors we're
supposed to, and the GPU reads a stale descriptor.

Fixes a GPU hang in Death Stranding (and possibly lots of other weird
crashes as well).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-12 12:46:07 +02:00
Hans-Kristian Arntzen 3f1132ee8c vkd3d: Add support for InterlockedIncrement64.
To be used for cookies. Works on 32-bit as well, compiler emits 8b CAS loop
for us.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-12 12:46:07 +02:00
Hans-Kristian Arntzen 4dff80661a vkd3d: Rewrite initial resource state tracking.
For correctness, we will need to defer any initial resource state
handling to the queue timeline. Here, we will build an UNDEFINED ->
common layout barrier if (and only if):

- The resource is marked to care about initial layout transition.
- We are the first queue thread to observe that initial_transition
  member is 1 (atomic exchange).
- The first use of the resource was not marked to be a discard.
  E.g., if the first use of the resource is an alias barrier, we must
  not emit an early barrier. The only we should do here is to clear the
  initial_transition member, and leave it like that.

A command list maintains a list of d3d12_resources which *might* need a
transition. For the first frame a resource is used (or so), it will not
have the flag cleared yet, so multiple command lists might add the
d3d12_resource to its own transition list. This is fine, as the queue
will resolve it.

If multiple queues see the same initial transition, there might be
shenanigans, but the application must ensure there is either a
submission boundary or fence boundary between the uses. Any initial
layout transition will only be submitted after a Wait() is observed, as
submission of the transition command buffer will be in-order with other
submissions.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-08 14:30:50 +02:00
Hans-Kristian Arntzen 6d2f540a40 vkd3d: Transition from UNDEFINED if a copy command writes everything.
An optimization and a requirement in D3D12. Clearing out an image
through a copy is considered enough to satisfy the requirement to acquire an
alias in the advanced usage model.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-08 14:30:50 +02:00
Hans-Kristian Arntzen 9c04f35757 vkd3d: Fix validation error when render pass is used without attachment.
Just drop the VkSubpassDependency in this case to satisfy the validator,
since stages == 0 is not allowed.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-07 17:43:53 +02:00
Hans-Kristian Arntzen 89235b7bc0 meta: Implement meta for swapchain pipelines.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-06 13:15:31 +02:00
Hans-Kristian Arntzen 97d8568f88 meta: Add vert/frag shaders for fullscreen swapchain pass.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-06 13:15:31 +02:00
Hans-Kristian Arntzen d626a0bde9 meta: Add custom vertex shaders to vkd3d_meta_create_graphics_pipeline.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-06 13:15:31 +02:00
Hans-Kristian Arntzen c59a6abfbd meta: Introduce vkd3d_meta_create_sampler.
Will be used for immutable samplers for scalers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-06 13:15:31 +02:00
Hans-Kristian Arntzen 44977b63b2 vkd3d: Move vkd3d_view_key to private header.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-06 13:15:31 +02:00
Hans-Kristian Arntzen 70af36a6e2 swapchain: Actually use matching mode when going fullscreen.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-05 19:53:05 +02:00
Hans-Kristian Arntzen d02d95f606 swapchain: Workaround weird behavior with FindClosestMatchingMode.
Use a default format if there is no format specified.
Otherwise, the call fails on both Wine and DXVK DXGIs.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-05 19:53:05 +02:00
Hans-Kristian Arntzen 624e42f742 swapchain: Add thread safety.
IDXGISwapchain should be thread safe, doesn't cost much to add it.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-10-05 19:53:05 +02:00
Joshua Ashton f5b2f45f13 vkd3d: Use already existing format for sparse multi-planar test
This was wrong anyway as it assumed depth always.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-05 10:50:28 +02:00
Joshua Ashton eee64787c7 vkd3d: Keep track of vkd3d_format for resources
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-05 10:50:28 +02:00
Joshua Ashton a991fddeeb build: Use `-fvisibility=hidden` and define exports manually
When building natively on Windows we use dllexport/dllimport for vkd3d/vkd3d_utils public exports.

When building natively on Linux we simply make those visibility default.

Nothing changes for standalone here.

Closes #152

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-05 10:44:10 +02:00
Joshua Ashton be2c0c1f1e include: Remove DECLSPEC_HIDDEN from headers
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-10-05 10:44:10 +02:00
Joshua Ashton e09f129064 vkd3d: Use enum for VKD3D_META_COPY_MODE
Just some extra type-safety.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-09-30 13:00:32 +02:00
Joshua Ashton 2d3df0838a vkd3d: Use generated shaders
Now we don't have the autotools path, we can use what we make now.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-09-30 13:00:32 +02:00
Joshua Ashton fa60742114 build: Remove autotools build path
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-09-30 13:00:32 +02:00
Joshua Ashton 3c54cf8ad6 vkd3d: Use VK_NULL_HANDLE instead of NULL for VkPipelineCache
Fixes a warning in MSVC.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-09-30 01:44:50 +02:00
Philip Rebohle 759e21d821 vkd3d: Remove d3d12_descriptor_heap_set_index_from_magic.
Unused, should have been in previous commit. Whoops.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-29 15:15:49 +02:00
Hans-Kristian Arntzen 2572b370d5 README: Add docs for shader logging.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-29 15:00:36 +02:00
Hans-Kristian Arntzen 9d36ab59d6 vkd3d: Add support for a shader debug ring.
Will allow replaced shaders to emit debug messages to a buffer.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-29 15:00:36 +02:00
Philip Rebohle 29fe4da015 vkd3d: Remove unused fields from d3d12_desc.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-29 14:48:26 +02:00
Philip Rebohle 0450ae9f85 vkd3d: Introduce VKD3D_DESCRIPTOR_FLAG_VIEW.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-29 14:48:26 +02:00
Philip Rebohle eb0ada76e8 vkd3d: Remove unused code for descriptor updates.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-29 14:48:26 +02:00
Philip Rebohle 3682e4d9f7 vkd3d: Rework UAV descriptor updates.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-29 14:48:26 +02:00
Philip Rebohle 3177d80814 vkd3d: Rework SRV descriptor updates.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-29 14:48:26 +02:00
Philip Rebohle c2439d67b8 vkd3d: Rework sampler descriptor updates.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-29 14:48:26 +02:00
Philip Rebohle 5c066940a0 vkd3d: Rework CBV descriptor updates.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-29 14:48:26 +02:00
Hans-Kristian Arntzen 7238802806 README: Add docs for auto capturing.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-22 12:44:18 +02:00
Hans-Kristian Arntzen 250357c998 debug: Integrate automatic RenderDoc capturing.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-22 12:44:18 +02:00
Hans-Kristian Arntzen 1ce14c2ef3 vkd3d: Remove bindless CBV workaround.
Not relevant anymore, and should see good uplift on NV depending on
content.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-11 16:54:00 +02:00
Hans-Kristian Arntzen 1b2e190877 tests: Clean up misc warnings from tests.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-11 15:20:52 +02:00
Hans-Kristian Arntzen a015ab04cd tests: Cleanup warnings in pipeline library tests.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-11 15:20:52 +02:00
Hans-Kristian Arntzen e823715ac8 vkd3d: Clean up warnings.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-11 15:20:52 +02:00
Philip Rebohle cea17b2440 vkd3d: Don't call vkGetPipelineCacheData on a null handle.
On systems without extended dynamic state, or for certain pipelines,
it is possible for vk_pso_cache to be VK_NULL_HANDLE, so we need to
check for this during serialization.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 18:11:41 +02:00
Hans-Kristian Arntzen 5872257e31 README: Update to mention VKD3D_SHADER_OVERRIDE.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 15:03:41 +02:00
Hans-Kristian Arntzen 52ecd35dee vkd3d: Set shader module name to the hash.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 15:03:41 +02:00
Hans-Kristian Arntzen adde8947c6 vkd3d: Trace which pipelines are being bound and if they are replaced.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 15:03:41 +02:00
Hans-Kristian Arntzen 586f002536 vkd3d-shader: Add shader replacement.
For debugging purposes, it can be extremely useful to be able to
pinpoint and replace specific shaders for testing hypotheses.

To make this practical, change the shader dumping to use hashes rather
than monotonically incrementing indices.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 15:03:41 +02:00
Hans-Kristian Arntzen f473370678 vkd3d-shader: Add hash function for shader blobs.
Simple FNV-1.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 15:03:41 +02:00
Hans-Kristian Arntzen b93963b6ce debug: Log thread ID as well.
For multi-threaded apps, this is vital to make any sense of the log.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 15:03:41 +02:00
Philip Rebohle 6ba9656b12 tests: Add tests for GetCachedBlob and pipeline libraries.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle 3a39f38fc5 vkd3d: Advertize support for relevant shader cache features.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle dcb03257f9 vkd3d: Implement pipeline library functionality based on VkPipelineCache.
This is used extensively by Horizon Zero Dawn, and allows us
to skip the compile screen after the initial first run.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle 3002d52ed4 include: Define D3D12 error codes as necessary.
These are technically supposed to be defined in winerror.h,
but current MinGW headers do not support these yet.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle c06e2bdc83 vkd3d: Introduce vkd3d_wcslen.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle 92b6e71ce4 vkd3d: Factor out pipeline state struct conversion.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle d4f4e34656 vkd3d: Remove pipeline cache from d3d12_device.
Unused now, instead we should implement D3D12 caching primitives
correctly and rely on the Vulkan driver otherwise.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle 15ed944e40 vkd3d: Implement ID3D12PipelineState::GetCachedBlob.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle 0396ee544c vkd3d: Implement support for cached PSO pipeline state.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Philip Rebohle 2b885c4981 vkd3d: Move ID3D12PipelineLibrary imlpementation to separate file.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-09-08 12:31:32 +02:00
Hans-Kristian Arntzen eb4ce56139 vkd3d: memset instance and device structs.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 09:34:26 +02:00
Hans-Kristian Arntzen 254868a326 vkd3d: Enable pthread workaround paths on MinGW as well.
winpthread is slow on Wine as it requires OS synchronization
objects, which involves wineserver.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 09:34:26 +02:00
Hans-Kristian Arntzen 7d8ab2fb06 vkd3d: Replace CS with SRW.
On Wine, this is more efficient as it can use futex paths.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-08 09:34:26 +02:00
Robin Kertels 51d2a3bad2 vkd3d: Set VKD3D_DYNAMIC_STATE_VERTEX_BUFFER when binding a new pipeline
... if we have dirty vbo slots left.

Fixes textures when inspecting items in the inventory in RE2 and RE3.

Signed-off-by: Robin Kertels <robin.kertels@gmail.com>
2020-09-06 10:08:33 +02:00
Hans-Kristian Arntzen c4bccbb8ee dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-04 16:44:31 +02:00
Hans-Kristian Arntzen ec441808c8 vkd3d: Emit host memory barrier as needed.
There is no resource state associated with this, so emit the barrier at
the end of a command buffer based on trivial tracking.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-09-02 14:46:12 +02:00
Hans-Kristian Arntzen 92b4f13f76 vkd3d: Zero out descriptor heaps on allocation.
Only bother if nullDescriptors are supported.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-31 17:22:17 +02:00
Philip Rebohle 630b70cbbd tests: Remove todos from test_write_buffer_immediate.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-28 17:27:05 +02:00
Philip Rebohle 2fd2cb1be2 vkd3d: Implement generic fallback for WriteBufferImmediate.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-28 17:27:05 +02:00
Philip Rebohle c71e70335a vkd3d: Implement WriteBufferImmediate with AMD_buffer_marker.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-28 17:27:05 +02:00
Philip Rebohle 6940716417 vkd3d: Enable VK_AMD_buffer_marker if available.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-28 17:27:05 +02:00
Hans-Kristian Arntzen e3d2484a49 vkd3d: Rewrite timeline semaphore handling.
Need to handle large (> 4G) jumps in timeline value, which is not
supported by all implementations.

There is no good way to handle that, so rewrite and clean up timeline
semaphore handling by separating the timeline into a virtual timeline
(which can rewind and jump around arbitrarely) and a physical timeline
which increments by one each time.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-28 14:13:47 +02:00
Hans-Kristian Arntzen 2d22317f31 vkd3d: Never attempt to use PCI-pinned memory types.
These memory types might end up being used as fallback memory types,
which is problematic due to their tiny sizes, and unexpected performance
behavior. Generally, when we want to fallback, we should cleanly fall
back to system memory rather than a different device local type.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-27 12:45:58 +02:00
Hans-Kristian Arntzen 4ec05b99b4 vkd3d: Fix crash in validation layer when freeing static descriptor set.
vk_pool cannot be NULL.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-27 12:37:45 +02:00
Philip Rebohle 0d0917508b vkd3d: Remove VKD3D_DESCRIPTOR_POOL_TYPE_IMMUTABLE_SAMPLER.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-26 14:56:17 +02:00
Philip Rebohle 17cf1f69d7 vkd3d: Use global descriptor sets for static samplers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-26 14:56:17 +02:00
Philip Rebohle a862d02c4c vkd3d: Introduce global descriptor pools for static samplers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-26 14:56:17 +02:00
Philip Rebohle d4f13b755f vkd3d: Use new global sampler state for static samplers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-26 14:56:17 +02:00
Philip Rebohle d4bbd4b43e vkd3d: Add sampler state object to d3d12_device.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-26 14:56:17 +02:00
Philip Rebohle a09a0ed86d vkd3d: Introduce vkd3d_sampler_state.
Manages unique static samplers for now, in order to reduce duplicates.
Can be extended to also manage descriptor pools for static samplers in
the future.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-26 14:56:17 +02:00
Hans-Kristian Arntzen 409af5de20 vkd3d-shader: Use per-thread allocators in DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-26 12:39:26 +02:00
Hans-Kristian Arntzen 528d2decad dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-26 12:39:26 +02:00
Hans-Kristian Arntzen 50eeb42137 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:51:34 +02:00
Hans-Kristian Arntzen d416d65d40 vkd3d: Fallback allocate memory for OpenExistingHeapFrom*.
RenderDoc does not support external_memory_host yet, and these heaps are
generally only used for debugging, so we should be able to get away with
this in practice.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen 23968fc423 vkd3d: Fall back to visible/coherent for host imported memory.
On NVIDIA, we can only import as uncached, introduce a fallback for that
scenario.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen b5e521fd6a vkd3d: Validate resource sharing flag.
If heap is cross adapter, resource must also be cross adapter.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen 01a7ec6310 tests: Use fflush()
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen 6260d18716 vkd3d: Implement OpenExistingHeapFromFileMapping.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen 0c1b49d681 vkd3d: Implement OpenExistingHeapFromAddress.
Refactors out some common code in d3d12_heap_init.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen 6e2b153235 vkd3d: Add host import to allocate_buffer_memory.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen aafc9aec96 vkd3d: Add helper to allocate imported host memory.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen 95b6596d75 vkd3d: Enable VK_EXT_external_memory_host.
Needed for OpenExistingHeapFromAddress and friends.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen b2b730ea8b tests: Add test for open heap from address/file.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-25 11:48:41 +02:00
Hans-Kristian Arntzen e9aab2b8b8 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-21 11:58:21 +02:00
Philip Rebohle 5a9d132b20 vkd3d: Get rid of descriptor spinlocks.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 73d578e5ab vkd3d: Do not ref-count views in descriptor updates.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 684c658e22 vkd3d: Do not ref-count view in ClearUnorderedAccessView.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 9098221f0a vkd3d: Add sampler map to device.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 28c1b7757c vkd3d: Add sampler support to view map.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 0303c396bc vkd3d: Add float_bits_to_uint32.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle daf9f5c69f vkd3d: Store views created from resource in resource's view map.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 6545cb4f7d vkd3d: Add view map to null resources.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 4f3fce5914 vkd3d: Introduce vkd3d_view_map_create_view.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle ff69d59fa6 vkd3d: Add view map to d3d12_resource.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 50eb972c15 include: Add hash map implementation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 7785c60a08 vkd3d: Add image parameter to vk_image_view_desc.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 3c9a54cb73 vkd3d: Introduce vkd3d_buffer_view_desc.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 05381caac9 vkd3d: Use vkUpdateDescriptorSets for descriptor copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle a056922293 vkd3d: Create separate descriptor set layout for host-only pools.
D3D12 allows much larger pools to be created for heaps that are not
shader-visible, which some games make use of. Fixes crashes on Nvidia.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 68fc3f9322 vkd3d: Create descriptor pools for all descriptor heaps.
Not just the shader visible ones, since we'll be using Vulkan
descriptor set copies to implement D3D12 descriptor copies.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle 8e4aaeff05 vkd3d: Introduce new descriptor metadata struct.
Stores info about where exactly the descriptor is stored in the
Vulkan descriptor pool, and whether we have to worry about an
additional UAV counter descriptor.

This is meant to replace all the other non-static data stored
inside d3d12_desc.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Philip Rebohle fcc0c4c163 vkd3d: Remove default null image views.
We're not using these anywhere because we need formats to be correct
for image views. Buffer views are used for root descriptors and null
UAV counters.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-08-19 12:54:56 +02:00
Jens Peters 9560612bd7 build: Use widl from mingw-tools.
This removes the wine dependency for cross-builds but adds a dependency for mingw-tools instead.

Signed-off-by: Jens Peters <jp7677@gmail.com>
2020-08-04 01:22:11 +02:00
Hans-Kristian Arntzen 4cc7eed2ab dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-08-01 13:01:13 +02:00
Hans-Kristian Arntzen df033cbec1 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-31 18:31:03 +02:00
Hans-Kristian Arntzen 2cb6b063fe tests: Fix uninitialized Layout member.
C is fine ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-30 16:48:31 +01:00
Hans-Kristian Arntzen 00618cb2c1 vkd3d: Load VK_LAYER_KHRONOS_validation if we enable debug mode.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-30 17:36:53 +02:00
Hans-Kristian Arntzen 27d14cb0ce meson: Target native d3d12 for Windows test binaries.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-30 17:34:10 +02:00
Philip Rebohle 9e8b2a22ed vkd3d: Don't destroy UAV counter view if it's the null view.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-30 16:35:15 +02:00
Philip Rebohle 651ecfe7f6 vkd3d: Set counter buffer view to null view for buffer UAVs.
Fixes a crash on drivers that don't support null descriptors.
Image UAVs and other descriptor types cannot have counters.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-30 15:16:51 +02:00
Jens Peters a0314c4818 build: Use the commit hash as fallback for the built-in version.
The `git describe` command currently fails because there are no tags yet. Using `--always` lets it fall back to the current commit hash.

Signed-off-by: Jens Peters <jp7677@gmail.com>
2020-07-30 15:03:06 +02:00
Hans-Kristian Arntzen b47dae95e5 vkd3d: Lower MAX_DESCRIPTOR_SETS to 9.
We just removed packed set.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-30 11:58:58 +02:00
Philip Rebohle 3364758746 vkd3d: Remove volatile packed descriptor handling.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-30 11:56:24 +02:00
Philip Rebohle c580866648 vkd3d: Remove packed descriptor set from root signature.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-30 11:56:24 +02:00
Philip Rebohle fd249acb64 vkd3d: Remove packed descriptor set update code.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-30 11:56:24 +02:00
Philip Rebohle 2cd23f5305 vkd3d: Require bindless samplers and SRV/UAV/CBV.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-30 11:56:24 +02:00
Hans-Kristian Arntzen 029f1cec4f dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-30 11:39:48 +02:00
Hans-Kristian Arntzen e7281f22c6 vkd3d-shader: Add NonUniformEXT decoration where required.
It's the argument to the opcode which consumes the final resource handle
or pointer which needs to marked as NonUniformEXT. Was missing this for
sampled images and bindless UAV counters.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-30 10:57:50 +02:00
Hans-Kristian Arntzen c695c1438b tests: Add a simple micro-benchmark for descriptor performance.
Tests CPU descriptor creation as well as copies in various scenarios.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-29 17:16:29 +02:00
Hans-Kristian Arntzen 06cf1441ad vkd3d-shader: Support non-BDA bindless UAV counters in DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-29 17:15:00 +02:00
Hans-Kristian Arntzen 301a0685a9 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-29 17:15:00 +02:00
Hans-Kristian Arntzen 1b100aa40d vkd3d: Fix broken access to dead stack variable.
Fallout from UAV counter bindless PR.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-29 17:15:00 +02:00
Philip Rebohle d0f64cfbb7 vkd3d: Always use bindless UAV counters if UAVs are bindless.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-29 15:23:25 +02:00
Philip Rebohle 3766e7e994 vkd3d: Rename BINDLESS_UAV_COUNTERS -> RAW_VA_UAV_COUNTERS.
For clarity, since we'll be moving to full bindless anyway.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-29 15:23:25 +02:00
Philip Rebohle 7f36039c9c vkd3d: Update uav counter set as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-29 15:23:25 +02:00
Philip Rebohle 949e38e0b3 vkd3d: Add binding for uav counter views.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-29 15:23:25 +02:00
Philip Rebohle b16276f9d6 vkd3d-shader: Support bindless UAV counters through texel buffer array.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-29 15:23:25 +02:00
Philip Rebohle 40764d82ef vkd3d-shader: Introduce VKD3D_SHADER_BINDING_FLAG_RAW_VA.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-29 15:23:25 +02:00
Hans-Kristian Arntzen e9681095e4 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-27 17:18:18 +02:00
Hans-Kristian Arntzen 8800ae7323 vkd3d-shader: Add declspec hidden to shader dumping entry points.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-27 11:14:49 +02:00
Hans-Kristian Arntzen 7083b30fd5 vkd3d-shader: Dump DXIL blobs to .dxil.
Makes it easier to extract all DXIL shaders when debugging.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-27 11:14:49 +02:00
Hans-Kristian Arntzen 376a05e722 dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-24 16:54:37 +02:00
Philip Rebohle fa3085400d vkd3d: Handle pRegion == NULL in DiscardSubresource.
Fixes a crash in Shadow of the Tomb Raider.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-23 16:23:31 +02:00
Philip Rebohle 54f23f18b9 meson: Drop d3d12_invalid_usage target.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-23 15:48:12 +02:00
telans 8b6b3f6942 meson: install headers, pkgconfig files 2020-07-22 12:00:06 +02:00
Hans-Kristian Arntzen 4611c9a96f vkd3d: Fix warnings in calibrated timestamp implementation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-22 10:52:03 +02:00
Philip Rebohle 1a015e134b programs: Fix building vkd3d-compiler.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-20 18:49:17 +01:00
Philip Rebohle abb8d32642 vkd3d: Add DXGI_FORMAT_R9G9B9E5_SHAREDEXP.
Needed by Battlefield 1.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-20 19:42:44 +02:00
Hans-Kristian Arntzen d2d71bffd1 README: Update notes about profiling.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-20 16:39:15 +02:00
Hans-Kristian Arntzen fbfbab7f31 programs: Add a simple Python tool to inspect profiling blocks.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-20 16:39:15 +02:00
Hans-Kristian Arntzen 7df9a48528 vkd3d: Add some other interesting profiling regions.
Useful to measure submission times, as well as time spent acquiring the
Vulkan queues. This correlates 1:1 with swapchain as well, so it's
useful when we want to get some "X / frame" metrics.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-20 16:39:15 +02:00
Hans-Kristian Arntzen 99b0421c32 meson: Add build option to enable a profiled build.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-20 16:39:15 +02:00
Hans-Kristian Arntzen 6a60834379 vkd3d: Make profiled vtable for ID3D12GraphicsCommandList4.
Similar to ID3D12Device profiled vtable, disgusting, but it should do
the trick.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-20 16:39:15 +02:00
Hans-Kristian Arntzen 37e4ce7ce7 vkd3d: Make a profiled vtable for ID3D12Device.
There are two advantages of doing it like this:
- When profiling is not enabled, we get no overhead for device calls.
- Avoids cluttering up the main implementation.

Disadvantage is that rolling inherited vtables like this is quite
disgusting, but this is C, what you gonna do ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-20 16:39:15 +02:00
Hans-Kristian Arntzen 9a1943d57b vkd3d: Init profiling when we create an instance.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-20 16:39:15 +02:00
Hans-Kristian Arntzen e3c1b66aed common: Add a simple profiling module.
Works by mapping a memory block on disk, and then we simply increment
u64s. The caller code only needs to use VKD3D_REGION_{DECL,BEGIN,END}
macros.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-20 16:39:15 +02:00
Joshua Ashton b38a18dbd8 vkd3d: Move copy descriptors implementation into a new func
Calling this from CopyDescriptorsSimple on its own is a bad idea given its __stdcall and GCC doesn't like optimizing that.

Also marked it as inline given it can easily be optimized greatly contextually for CopyDescriptorsSimple

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-17 14:02:18 +02:00
Philip Rebohle 79ee5ccf60 tests: Add test for GetClockCalibration.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-17 11:49:38 +02:00
Philip Rebohle 62990c3514 tests: Introduce vkd3d_sleep.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-17 11:49:38 +02:00
Philip Rebohle 2729c4ad41 vkd3d: Implement GetClockCalibration.
Manually uses QPC if the Vulkan implementation does not support
the QPC domain by itself.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-17 11:49:38 +02:00
Philip Rebohle 1af4c6c719 vkd3d: Enable VK_EXT_calibrated_timestamps if available.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-17 11:49:38 +02:00
Philip Rebohle e7d8f1c020 tests: Add test for DiscardResource.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-16 16:53:17 +02:00
Philip Rebohle c3d5a60e01 vkd3d: Implement DiscardResource.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-16 16:53:17 +02:00
Philip Rebohle ef2eacefee vkd3d: Rework d3d12_command_list_find_attachment.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-16 16:53:17 +02:00
Philip Rebohle 37e7fbd5c5 vkd3d: Rework d3d12_get_view_rect.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-16 16:53:17 +02:00
Philip Rebohle b212b3fb9c vkd3d: Introduce d3d12_resource_get_vk_subresource.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-16 16:53:17 +02:00
Philip Rebohle def7cf409a vkd3d: Introduce discard mask for deferred clear operations.
Allows us to skip clears while still initializing the image.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-16 16:53:17 +02:00
Joshua Ashton 583253b0c4 meta: Update readme for cross building
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-16 14:08:11 +02:00
Joshua Ashton cbf75e4fcf build: Add cross-build support to package-release.sh
This also makes that the default behaviour, which is what we want for end users.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-16 14:08:11 +02:00
Hans-Kristian Arntzen 96402f1164 vkd3d: Fix straggling warnings for MSVC.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-16 13:00:09 +02:00
Hans-Kristian Arntzen 812634b68b meson: Disable the more useless warnings in MSVC.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-16 13:00:09 +02:00
Thomas Crider 4e9b341d45 vkd3d-utils: vkd3d-utils needs pthread libraries, otherwise it causes compilation of vkd3d-common to fail
Details:

libtool: link: gcc -shared  -fPIC -DPIC  libs/vkd3d-utils/.libs/vkd3d_utils_main.o  -Wl,--whole-archive ./.libs/libvkd3d-common.a -Wl,--no-whole-archive  -Wl,-rpath -Wl,/home/vagrant/build-Proton-5.12-GE-1/obj-vkd3d32/.libs -Wl,-rpath -Wl,/home/vagrant/build-Proton-5.12-GE-1/obj-tools32/lib -L/home/vagrant/build-Proton-5.12-GE-1/obj-tools32/lib ./.libs/libvkd3d.so -lm  -Wl,--no-undefined -g -O2 -march=nocona -mtune=core-avx2 -mfpmath=sse -Wl,--version-script=/home/vagrant/proton/vkd3d/libs/vkd3d-utils/vkd3d_utils.map   -Wl,-soname -Wl,libvkd3d-utils.so.1 -o .libs/libvkd3d-utils.so.1.0.1

./.libs/libvkd3d-common.a(debug.o): In function `vkd3d_dbg_get_level':
debug.c:(.text+0x16b): undefined reference to `pthread_once'
./.libs/libvkd3d-common.a(debug.o): In function `vkd3d_dbg_printf':
debug.c:(.text+0x1d6): undefined reference to `pthread_once'

Signed-off-by: Thomas Crider <gloriouseggroll@gmail.com>
2020-07-15 23:22:17 +02:00
Hans-Kristian Arntzen debb93f38a dxil-spirv: Update submodule.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-15 00:25:38 +02:00
Andrew Eikum 88e6c9b2dd build: Drop minimum meson version
Debian 10 ships 0.49.

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
2020-07-15 00:21:52 +02:00
Hans-Kristian Arntzen dd6656fbe9 vkd3d: Avoid redundant pipeline binds.
When we're using extended dynamic state, we will often end up with dummy
pipeline binds, which we should try to avoid if we can.
Also avoids having to rebind dynamic state redundantly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 84d9e4b0db vkd3d: Emit vertex buffer sizes even when not using dynamic stride.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 0f91099dd4 vkd3d: Refactor dynamic state to be per-pipeline.
Cleans up dynamic state such that we do not have to keep dynamic state
create infos around.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 69fdd87aa0 vkd3d: Add more debug logging when we fall back.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen d8ba75e160 vkd3d: Use strip type by default when using primitive restart.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 0e9a1555c1 vkd3d: Add dynamic state information to vkd3d_pipeline_key.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen e9dcdc1308 vkd3d: Move vkd3d_pipeline_key to private header.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 5968d28e75 vkd3d: Refactor out dynamic stride checks to its own function.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 10d6823e34 vkd3d: Do not attempt to create a pipeline with invalid DS format.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 2e57b3d27e vkd3d: Do not attempt to create pipelines with unknown topology type.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 6967576904 vkd3d: Statically deduce patch vertex count for HS.
Fall back when there is a mismatch, which can happen if application does
not declare inputs to hull shader (unlikely).

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 7b0345a149 vkd3d-shader: Add way to scan for expected patch vertex count from HS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 084a3e6928 vkd3d: Validate minimum vertex buffer stride when using dynamic stride.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen c8bbed15d7 vkd3d: Implement 32-bit bitmask iteration.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 5ef3ebce61 vkd3d: Implement extended dynamic state.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 7139621c3f vkd3d: Add conversion for topology type to Vulkan.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 85f8a6ac7c vkd3d: Add helper to check if topology type can use primitive restart.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 66b252e08f vkd3d: Remove reliance on HAVE_BUILTIN_CTZLL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 1f2499f64a vkd3d: Add 32-bit bitmask iteration with scanning.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 551bc54546 vkd3d: Add topology type to pipeline state.
Needed to build dynamic pipeline.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen fc0a94ad04 vkd3d: Add a common pipeline for graphics pipeline state.
When using EXT_extended_dynamic_state, we will be able to compile a
master pipeline. Only in special cases will we have to fallback.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen b52a9c46bd vkd3d: Refactor graphics pipeline creation out to separate function.
Preparation for extended dynamic state refactor.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 926f2033a9 vkd3d: Enable VK_EXT_extended_dynamic_state.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 14:29:34 +02:00
Hans-Kristian Arntzen 9425b4d438 vkd3d: Bump VKD3D_MAX_DESCRIPTORS_SETS to 9.
This can happen in the worst case where we have all bindless sets, and:

- Static samplers
- Packed descriptors (UAV counters on drivers without support for this)
- Root descriptors

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-14 10:08:38 +02:00
Philip Rebohle 15106808f9 vkd3d: Implement IDXGISwapChain4.
SetHDRMetaData implementation taken from DXVK.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-13 10:25:51 +02:00
Philip Rebohle 90d44eeac5 vkd3d: Make swap chain implementation more easily extensible.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-13 10:25:51 +02:00
Biswapriyo Nath 41b0f5a96c vkd3d: remove redeclaration of IWineDXGISwapChainFactory
IWineDXGISwapChainFactory will be in header from vkd3d_swapchain_factory.idl

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
2020-07-11 20:33:59 +02:00
Hans-Kristian Arntzen f0269739b1 debug: Add support for a log file.
Simplistic implementation. Also, make sure lines are written atomically
to not get garbled logs.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-10 16:09:00 +02:00
Hans-Kristian Arntzen 7fb97940f1 vkd3d: Initialize debug code once with pthread_once_t.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-10 16:09:00 +02:00
Hans-Kristian Arntzen b16b98e77d d3d12: Initialize Vulkan library once with pthread_once_t.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-10 16:09:00 +02:00
Hans-Kristian Arntzen 8743577ca5 vkd3d: Add MSVC path for pthread_once_t.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-10 16:09:00 +02:00
Hans-Kristian Arntzen 7f29d25611 debug: Flush logging output.
On Windows, we don't get a flush naturally after every newline,
so flush manually every time to make sure we get everything in a timely
fashion.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-10 16:09:00 +02:00
Hans-Kristian Arntzen 7bccab7427 debug: Re-introduce different debug channels.
vkd3d-shader is currently kinda buggy and crashes when you try to trace
DXBC. This used to never be run since it was guarded by
VKD3D_SHADER_DEBUG, but with the move to a static build we merged all
debug logging under VKD3D_DEBUG. Reintroduce different debug channels in
a way that is compatible with a statically linked vkd3d.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-10 14:18:15 +02:00
Hans-Kristian Arntzen 854814d81c vkd3d: Fix various minor warnings.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-10 14:18:15 +02:00
Hans-Kristian Arntzen 337f75b76a vkd3d: Workaround broken MEMORY_READ/WRITE on RADV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-09 14:50:50 +02:00
Hans-Kristian Arntzen 1341409b88 vkd3d: Implement aliasing barriers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-09 14:50:50 +02:00
Hans-Kristian Arntzen d919c74276 vkd3d: Add test for aliasing barriers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-09 14:50:50 +02:00
Philip Rebohle fee4781f2b vkd3d: Fix suspended render pass state tracking.
Otherwise, if a render pass gets suspended twice in a row, we
never emit the barrier because render_pass_suspended will be
set to false the second time.

Fixes validation errors in Hitman 2.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-07-08 17:31:58 +02:00
Joshua Ashton 2b2c4a2e33 d3d12: Fix ordinal exports
These were originally copied from d3d12.crosslib.def but it turns out those are wrong.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-07 17:42:21 +01:00
Joshua Ashton 6056df3332 d3d12: Declare exports as __declspec(dllexport) on MinGW
Otherwise the stdcall-alias/fixup doesn't get exported.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-07 17:44:36 +02:00
Joshua Ashton 3fe9dd765d build: Add stdcall alias/fixup when building x86
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-07 17:44:36 +02:00
Hans-Kristian Arntzen 0c59c30e08 vkd3d: Fix tzcnt64 on MSVC 32-bit and 64-bit.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-07 16:31:29 +01:00
Hans-Kristian Arntzen c97a8ba253 vkd3d-compiler: Fix build on MSVC.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-07 16:31:29 +01:00
Hans-Kristian Arntzen b6e5760b6e d3d12: Use CreateDXGIFactory1 instead of 2.
MinGW-w64 somehow does not export 32-bit symbols of DXGIFactory2.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-07 16:31:29 +01:00
Joshua Ashton 9625096577 vkd3d: Correctly handle output + fix NULL old targets for fullscreen
The output here is actually for secure presentation and restricting a swapchain to a certain output.

Correctly handle NULL (desktop) targets that we used to have.

Fixes crashes with titles that use fullscreen via an initial fullscreen desc.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-07 01:42:34 +02:00
Hans-Kristian Arntzen cb1da02af9 vkd3d: Fix some warnings.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-06 21:32:16 +02:00
Hans-Kristian Arntzen c3392dad97 vkd3d: Fix automake build.
Missing IDL header.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-06 21:32:16 +02:00
Hans-Kristian Arntzen a6d8ea4800 vkd3d: Update clone link in README.md.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-06 21:32:06 +02:00
Hans-Kristian Arntzen 1ea32a66ce vkd3d: Update README.md.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-06 20:32:00 +02:00
Joshua Ashton 5e5eee368c subprojects: Update dxil-spirv to fix Windows builds 2020-07-06 18:56:54 +01:00
Joshua Ashton 7204c8d76f d3d12: Add standalone d3d12 library
When building for Windows, specify `-Denable_standalone_d3d12=True` in Meson to enable.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton aa3b7c3b26 vkd3d: Use newer ID3D12Device funcs for COM
Fixes warnings under MSVC and MinGW.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton 9c105a78a9 vkd3d: Implement swapchain and swapchain factory
Needed for standalone D3D12.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton cbebf9efed build: Add build_standalone_d3d12 option
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton 3d52186d3a build: Move build options to top of build script
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton cb4fcd5a98 include: Replace MinGW hack with Win32 platform header
Replace this hack with a more versatile one that works for multiple compilation objects.

Consolidates this hack across all the code bases (soon to be used in a D3D12 standalone patch)

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton e24914b11f include: Pull in Win32 Vulkan exts when building for Win32
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton dff27c9e9c vkd3d: Load INSTANCE_EXT procs into device table
We need these for the upcoming swapchain factory implementation
for standalone D3D12.

They're also probably good to have around in future for the
d3d12 device.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Joshua Ashton ba3dabe3bb vkd3d: Add debug_dxgi_format helper
DXGI_FORMAT -> string

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-06 19:29:30 +02:00
Hans-Kristian Arntzen d6b6da6206 Revert "vkd3d: Add support for serializing root signature version 1.1"
This reverts commit 0384362065.

It is not allowed to use RS 1.1 serialization for the non-versioned
entry point. RS 1.1 serialization must use the versioned entry point.

Reverting this fixes the relevant test case in d3d12.c:12522.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-06 17:41:03 +01:00
Joshua Ashton 10f7ec4ad8 build: Remove -Wno-incompatible-pointer-types
No longer needed with recent changes.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-03 16:56:10 +02:00
Joshua Ashton 19c910904b vkd3d-shader: Use uint32 for immediate constants
DWORD and uint32_t are different types on Windows.
Fixes warnings.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-03 16:56:10 +02:00
Joshua Ashton 77679e8b32 vkd3d-shader: Split read_dword into read_uint32
On Windows, DWORD is unsigned long, which means it's technically a different pointer type.

Let's keep type safety (as much as we can in C) and remove some warnings.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-03 16:56:10 +02:00
Joshua Ashton ec8d14593a build: Remove -Wno-discarded-qualifiers
We don't need this since the CONST_VTBL change.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-03 16:56:10 +02:00
Joshua Ashton 08544fb938 vkd3d: Use CONST_VTBL instead of const for vtable decls
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-03 16:56:10 +02:00
Joshua Ashton b05371432a build: Remove -Wno-missing-braces
Hold over from autotools that isn't needed.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-03 16:56:10 +02:00
Joshua Ashton 12e4014b54 vkd3d-shader: Fix incorrect assertion
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-03 16:56:10 +02:00
Hans-Kristian Arntzen 6e944dab6b vkd3d: Use ptrdiff in utf8 strdup.
max_elements is in number of elements, not bytes.
Fix regression from refactor.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-02 12:28:03 +02:00
Hans-Kristian Arntzen 49190da623 vkd3d: Fix pointer type mismatch.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-07-02 12:28:03 +02:00
Joshua Ashton ae5da7bda6 build: Add public include dirs to demos
Fixes building on Windows...

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-01 21:31:43 +02:00
Joshua Ashton f232ca1b87 build: Link tests against DXGI on Windows
Fixes compilation

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-01 21:31:43 +02:00
Joshua Ashton a16afe7c8f build: Fix checking for xcb when building on Windows
It goes unused anyway, just makes Meson fail.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-01 21:31:43 +02:00
Joshua Ashton 0384362065 vkd3d: Add support for serializing root signature version 1.1
Make this code more extensible too...

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-01 19:46:09 +02:00
Joshua Ashton 211b9c37b0 meta: Make README markdown and update for Meson
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-07-01 12:01:26 +02:00
Philip Rebohle ee949c0916 vkd3d: Avoid UAV counter address updates for non-UAV descriptors.
Saves a few CPU cycles. We expect things to explode anyway when
the app uses a non-UAV descriptor as a UAV in the shader.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-29 17:18:29 +02:00
Philip Rebohle d524b770bc vkd3d: Do not create view for NULL UAV descriptors if possible.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-29 17:18:29 +02:00
Philip Rebohle e50b707709 vkd3d: Do not create view for NULL SRV descriptors if possible.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-29 17:18:29 +02:00
Philip Rebohle e10b9a72e2 vkd3d: Handle views being null in non-bindless descriptor updates.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-29 17:18:29 +02:00
Philip Rebohle 3434c4ef6f vkd3d: Handle views being null in bindless descriptor updates.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-29 17:18:29 +02:00
Philip Rebohle c8e97a581d vkd3d: Use NULL descriptors for constant buffer views.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-29 17:18:29 +02:00
Philip Rebohle fbbcb30590 vkd3d: Use NULL descriptors for vertex buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-29 17:18:29 +02:00
Philip Rebohle 87bf1e8937 vkd3d: Use NULL descriptors for undefined root descriptors.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-29 17:18:29 +02:00
Philip Rebohle d43f70bb1b vkd3d: Enable VK_EXT_robustness2 if available.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-29 17:18:29 +02:00
Joshua Ashton 9770eea1f3 build: Add .gitlab-ci
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-29 17:04:56 +02:00
Joshua Ashton 4140ea0d31 build: Add package-release helper
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-29 17:04:56 +02:00
Joshua Ashton bc7aebda33 build: Disable some extra warnings
Disabled -Wmissing-field-initializers and -Wunused-parameters

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-29 17:04:56 +02:00
Joshua Ashton 25b40c5df8 build: Only find demo dependencies if building demos
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-29 17:04:56 +02:00
Joshua Ashton 8af31b5105 vkd3d-shader: Fix potential buffer overrun for image_operands
This would happen if you both sampled with both a texel offset and were LOD masked.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-29 15:26:54 +02:00
Joshua Ashton d1b58f954e vkd3d-shader: Fix buffer overrun for bindless constant loads
Previously, last_index would be 4 by the time it got to the loop if we were bindless -- which corrupted the component_ids that were being written.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-29 15:26:54 +02:00
Joshua Ashton 02fca8d190 build: Enable warning level 2
Equivelant to -Wall -Wextra

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-27 15:23:09 +02:00
Joshua Ashton d70223e57d vkd3d: Cast down tile extents in offsets explicitly
Fixes a signedness comparison warning -- shouldn't be a problem as we aren't going to get images with 2m+ tiles.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-27 15:23:09 +02:00
Joshua Ashton ed6adc3fa2 vkd3d-common: Refactor string loop code
Also fix some bad signed comparison problems.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-27 15:23:09 +02:00
Joshua Ashton 079a012dab build: Use Meson subproject for dxil-spirv
Removes the CMake dependency and solves some trouble building.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-26 18:33:27 +02:00
Joshua Ashton 9564f57a69 vkd3d-shader: Fix incorrect use of static in ext arrays
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-26 15:42:41 +02:00
Joshua Ashton fdcf33ff47 vkd3d-shader: Fix incorrect enum being used for tesselator partitioning
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-26 15:42:41 +02:00
Joshua Ashton ce7eba6210 vkd3d-shader: Fix incorrect type enum in global binding
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-26 15:42:41 +02:00
Joshua Ashton 0b6d460813 vkd3d-shader: Fix wrong enum for {CLIP,CULL}_DISTANCE
The wrong enum was used here... It was just returning the same thing

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-26 15:42:41 +02:00
Krzysztof Bogacki 12b71b9f5a build: Remove SPIRV-Tools dependency
For autotools–based builds only, Meson never used it anyway.

Signed-off-by: Krzysztof Bogacki <krzysztof.bogacki@leancode.pl>
2020-06-26 13:43:08 +02:00
Krzysztof Bogacki c11d3eed17 vkd3d: Remove SPIRV-Tools-based debugging code
Signed-off-by: Krzysztof Bogacki <krzysztof.bogacki@leancode.pl>
2020-06-26 13:43:08 +02:00
Joshua Ashton 5f4c383c1a vkd3d: Remove _spv suffix from prebuilt shaders
Matches what we build from glslang in Meson now.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-25 13:51:06 +02:00
Joshua Ashton f3f0887c43 vkd3d: Compile glsl shaders at compile time
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-25 13:51:06 +02:00
Joshua Ashton 61dcb5d0dd vkd3d: Move shader contents out of header
This way we can use a glsl generator on them in future in Meson.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-25 13:51:06 +02:00
Joshua Ashton e46b0ef3c5 build: Add glsl generator to root build script
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-25 13:51:06 +02:00
Joshua Ashton a46fb17973 vkd3d: Make enqueued_fence_count a uint32_t
Fixes atomic usage with it.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton d709fd3306 vkd3d: Add vkd3d_atomic_uint32_{dec, inc}rement helper
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 45d4296a54 vkd3d: Rename vkd3d_uint32_atomic to vkd3d_atomic_uint32
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 033f76e3ae vkd3d: Define our own memory orders
We shouldn't potentially override stuff in the std library and this allows us to map directly to __ATOMIC_* memory orders which is more correct.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 25f6e1d0a9 vkd3d: Use __atomic builtins instead of stdatomic
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 26c9dc90f4 vkd3d: Implement sequential consistency on MSVC
Also optimize and reduce unnecessary barriers.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 21:13:35 +02:00
Joshua Ashton 0d1dea607a demos/gears: Don't redefine _GNU_SOURCE
We define this globally now.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:27:22 +02:00
Joshua Ashton 4c819baad3 vkd3d: Use pthread reimplementation only on MSVC
We can use pthreads properly under MinGW
2020-06-24 15:27:22 +02:00
Joshua Ashton fb02f28c41 vkd3d: Don't redefine InterlockedIncrement under MinGW
Fixes compiler warnings

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:27:22 +02:00
Joshua Ashton 2e32cb11ba programs/vkd3d-compiler: Add build script
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:27:22 +02:00
Joshua Ashton c79d073b67 build: Fallback to vkd3d-utils if no d3d12 lib is present
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:27:22 +02:00
Philip Rebohle 945ec70f4d tests: Don't build uninteresting tests.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-24 15:19:18 +02:00
Joshua Ashton 161dc007c5 build: Link dxil-spirv statically
Don't need to link this in any fancy way

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:18:56 +02:00
Joshua Ashton 8931770654 subprojects: Update dxil-spirv submodule
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:18:56 +02:00
Joshua Ashton 22545c189a vkd3d-shader: Build statically
We don't need this to be another random so floating around...

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:18:56 +02:00
Joshua Ashton 4521b253dd vkd3d: Toss VKD3D_DEBUG_ENV_NAME
Creates linking problems if we want to build vkd3d-shader statically given this links back to something in vkd3d-common.

We don't need this distinction anyways...

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-24 15:18:56 +02:00
Hans-Kristian Arntzen 69f338be8f build: Fix MinGW build.
Revert removal of MinGW forceinline hacks.
They are necessary or MinGW fails to build.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-24 14:17:34 +01:00
Hans-Kristian Arntzen 2b7ef38248 Revert "vkd3d: make spinlock_t atomic to make clang happy"
This reverts commit 7b1dce2667.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-24 13:40:03 +02:00
Georg Lehmann 7b1dce2667 vkd3d: make spinlock_t atomic to make clang happy
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2020-06-24 13:26:31 +02:00
Hans-Kristian Arntzen 24be81fdfb vkd3d/meta: Initialize flags variable.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-24 12:43:19 +02:00
Joshua Ashton 8c216e637c build: Add Meson build system
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-23 14:55:43 +02:00
Joshua Ashton 45f9836c60 vkd3d: Eliminate config.h
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-23 14:55:43 +02:00
Joshua Ashton da2c9a1043 vkd3d: Eliminate HAVE_SPIRV_UNIFIED1_SPIRV_H and HAVE_SPIRV_UNIFIED1_GLSL_STD_450_H
These are submodules now.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-23 14:55:43 +02:00
Joshua Ashton 1f266cc16b vkd3d: Eliminate HAVE_PTHREAD_H
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-23 14:55:43 +02:00
Joshua Ashton e34eb3bf0f subprojects: Add submodules for dependencies
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-23 14:55:43 +02:00
Georg Lehmann a95e56675a vkd3d: use pause while spinning on x86
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
2020-06-17 09:49:08 +02:00
Joshua Ashton bfd7127284 vkd3d-shader: Don't use return value semantics in void functions
Fixes warnings in MSVC.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-16 12:13:54 +02:00
Joshua Ashton 0b1a25a9e5 vkd3d: Add vkd3d_atomic.h to Makefile.am
This was missing previously.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-16 11:07:50 +02:00
Joshua Ashton 287ceb207d vkd3d: Refactor platform-specific code
This commit moves the module handling code which was previously dumped in device.c and the code to retrieve the current executable path to its own file.

This also eliminates HAVE_DECL_PROGRAM_INVOCATION_NAME from config.h

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-16 11:07:50 +02:00
Joshua Ashton f3ec53cb5d vkd3d: Implement vkd3d_get_program_name for Win32
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-16 11:07:50 +02:00
Hans-Kristian Arntzen da782831e4 Revert "vkd3d: Use monotonically increasing fence values in test suite."
Rewinding fence values were undocumented at the time, but new
documentation makes it clear that it is allowed to rewind a fence, even
if behavior is unpredictable in nature.

This reverts commit 3b9f1f8a9c.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-16 11:00:08 +02:00
Hans-Kristian Arntzen 349412f19f vkd3d: Support rewinding ID3D12Fence.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-16 11:00:08 +02:00
Hans-Kristian Arntzen 5ef7b99e0b vkd3d: Fix uninitialized return value in CPU fence signaling.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-16 11:00:08 +02:00
Joshua Ashton 75089f0e1d demos/gears: Use hpc for getting time on Win32
There's no sys/time.h on MSVC.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-16 10:55:56 +02:00
Joshua Ashton b711125f60 demos/gears: Define _USE_MATH_DEFINES
Needed for M_PI on MSVC

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-16 10:55:56 +02:00
Joshua Ashton 697dc565a9 demos: Use WinMain instead of wmain on Win32
We're going to want to build as a GUI app, so we need
to use real WinMain on Windows for this.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-16 10:55:56 +02:00
Joshua Ashton f3c85328f1 vkd3d: Remove PACKAGE_NAME usage for engine version
This isn't going to change. Drivers use this to do special things,
so changing it would probably cause a bunch of random problems anyway.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-15 21:45:35 +02:00
Joshua Ashton cd5d01d25c vkd3d: Refactor atomics
There is no stdatomic available on MSVC so let's clean things up.

This moves all the atomic helpers to vkd3d_atomic.h and implements all platform's spinlocks in entirely the same way.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-15 20:40:10 +02:00
Joshua Ashton b9909854fe vkd3d: Make nameless unions really nameless
This makes it consistent across tests and vkd3d.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2020-06-15 19:59:52 +02:00
Hans-Kristian Arntzen cbdf6f88d2 vkd3d: Remove dependency on linking directly against libvulkan.
There is no reason to not load Vulkan dynamically, otherwise, we must
have loader dev packages installed, which is not ideal.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-15 15:47:18 +02:00
Philip Rebohle 4cf8467b9d vkd3d-shader: Introduce vkd3d_dxbc_compiler_find_register_info.
Does not generate logs when not finding a register, which reduces
some misleading spam in Anno 1800 tessellation shaders.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-15 13:32:55 +02:00
Hans-Kristian Arntzen 9defd87f95 vkd3d: Implement BeginEvent/EndEvent.
Only support ANSI/UNICODE version for now. The PIX3BLOB format is
extremely weird, complicated and undocumented.
We can refer to RenderDoc if we need it later ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-11 13:02:50 +02:00
Hans-Kristian Arntzen cae30f8602 utils: Add a max_elements parameter to wchar conversion.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-11 13:02:50 +02:00
Hans-Kristian Arntzen 9534c1a345 vkd3d: Move to VK_EXT_debug_utils.
debug_marker/debug_report are both deprecated in favor of debug_utils and vkd3d was using marker in a
buggy way anways, as debug_marker requires debug_report to work, but it was
only conditionally enabled.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-11 13:02:50 +02:00
Hans-Kristian Arntzen 6a038003e2 vkd3d: Always enable instance debug extension.
Prepare for moving to VK_EXT_debug_utils.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-11 13:02:50 +02:00
Hans-Kristian Arntzen 726356ebb1 vkd3d: Always use PDF2/PDP2 without KHR extensions.
It is core in Vulkan 1.1.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-11 13:02:50 +02:00
Hans-Kristian Arntzen d8ca2cef6d vkd3d: Serialize all queue submissions.
Gets rid of the full barrier on command buffer end.
Instead, do what D3D12 wants, which is to serialize all
ExecuteCommandLists. Simplify the existing timeline sempahore setup for
sparse queues and use it for all submissions.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-09 14:28:13 +02:00
Philip Rebohle bc7426ceb0 vkd3d-shader: Fix modifier handling.
This is a set of flags, so we should treat it as such.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-09 13:20:36 +02:00
Philip Rebohle 1fa3686638 vkd3d: Use ALLOW_ONLY_BUFFERS for committed buffer resources.
Otherwise, we may end up failing to allocate memory on Tier 1
hardware, and also fail to use dedicated allocations in some
cases.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle 8ca1a5aab4 tests: Test image creation on ALLOW_ONLY_BUFFERS heap.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle d49f47dbc2 vkd3d: Validate heap flags for placed resources.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle eda59ea66c vkd3d: Remove vkd3d_select_memory_type.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle 2b88df93a2 vkd3d: Use new memory allocation code in d3d12_resource_bind_sparse_metadata.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle 5bf492c207 vkd3d: Rework vkd3d_allocate_device_memory.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle 95716029a8 vkd3d: Use new memory allocation code in vkd3d_allocate_image_memory.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle 615e933db6 vkd3d: Use new memory allocation code in vkd3d_allocate_buffer_memory.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle 43e2c3ffe6 vkd3d: Add new memory allocation helpers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle 8ced3b53b9 vkd3d: Expose D3D12_RESOURCE_HEAP_TIER_1 based on hardware capabilities.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Philip Rebohle bbcaeee69d vkd3d: Determine compatible memory types for different resource types.
We'll need this to more accurately select the memory type for D3D12
heaps based on which resources are allowed to be placed in it.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-08 15:09:21 +02:00
Hans-Kristian Arntzen f0c9627db9 configure.ac: Report that 1.2.140 is required, not 1.1.140.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-06-03 15:39:32 +02:00
Philip Rebohle e6857939e7 vkd3d: Do not enable VK_KHR_dedicated_allocation.
Core in 1.1.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-02 16:23:38 +02:00
Philip Rebohle 45109686be vkd3d: Do not enable VK_KHR_maintenance3.
Core in 1.1.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-02 16:23:38 +02:00
Philip Rebohle 317868ab2b vkd3d: Remove required extensions.
Both of these are core in 1.1.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-02 16:23:38 +02:00
Philip Rebohle 9852b1702d vkd3d: Require Vulkan 1.1 device.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-02 16:23:38 +02:00
Philip Rebohle 3880e61be2 vkd3d: Require Vulkan 1.1 instance.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-06-02 16:23:38 +02:00
Hans-Kristian Arntzen 9875d65d35 vkd3d: Apply heap offsets for ExecuteIndirect buffers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-05-29 13:03:32 +02:00
Philip Rebohle 1ade8c0cc5 vkd3d: Issue full barrier at the end of command lists.
D3D12 apparently does this implicitly. Fixes rendering issues in
the AMD COCOA demo on Polaris with RADV, which does not emit a
barrier between the AO compute passes and the tone mapping pass
in the next command buffer.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-27 14:59:21 +02:00
Hans-Kristian Arntzen 7e229213f5 vkd3d: Enable SM 6.2 features.
Need float16_int8 and subgroup with extended types to implement new SM
6.2 features. For now, skip over SM 6.1 features until someone makes use
of them.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-05-27 14:33:24 +02:00
Hans-Kristian Arntzen b3be23c066 vkd3d-shader: Only sample with the required number of components.
Works around a driver bug on NV which affected RE2 in particular, but
probably other titles as well.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-05-22 11:54:04 +02:00
Hans-Kristian Arntzen 71034acc76 configure: Check for 1.1.140 headers.
Needed for VK_EXT_custom_border_color.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-05-14 14:06:45 +02:00
Philip Rebohle 50a9fae263 vkd3d: Silence SetMarker/BeginEvent/EndEvent log spam.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:27:02 +02:00
Philip Rebohle 6707f3fc30 vkd3d: Invalidate descriptor heaps on root signature change.
Apparently we need to do this if the push constant layout changes.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:27:02 +02:00
Philip Rebohle c75bbb9997 vkd3d: Handle null root descriptors.
We should hook this up to the robustness2 feature at some point,
but for now, just use the dummy descriptors. Fixes a crash in
the AMD CACAO demo.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:27:02 +02:00
Philip Rebohle e99d92bef9 vkd3d: Expose Tiled Resources Tier 2.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 7e02541003 vkd3d: Implement sampler reduction modes.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 6cbf61ca92 vkd3d: Enable VK_EXT_sampler_filter_minmax if available.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 6478632dca vkd3d-shader: Remove old Nvidia workaround for dref instructions.
This was fixed two years ago in the 396 and later 390 drivers.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 37b9875e98 vkd3d-shader: Implement sparse ld_uav_typed instruction.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle a1b2cef928 vkd3d-shader: Implement sparse ld_raw and ld_structured instructions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 7b9dbdc4ce vkd3d-shader: Implement sparse ld instructions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle bb5e0969b2 vkd3d-shader: Implement sparse gather instructions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 1839d13ef3 vkd3d-shader: Implement sparse sample_c instructions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 45ec9b7f27 vkd3d-shader: Implement sparse sample instructions.
In addition to sparse feedback, these instructions also clamp the
LOD, with the minimum LOD being passed in as the last parameter.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle c09b66f404 vkd3d-shader: Implement check_access_fully_mapped instruction.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 277f731bd7 vkd3d-shader: Add helpers to deal with sparse instruction results.
OpImageSparse* operations return a struct containing a status value
and the sampled value, so we need to take it apart when storing results.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 26f6e59f3e vkd3d-shader: Add helper to declare a struct once.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 6d0c1b4dd3 vkd3d-shader: Handle feedback instructions in UAV read scanner.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle fa029a1a84 vkd3d-shader: Add definitions for sparse feedback instructions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 13c6d064ab tests: Add tests for sparse feedback shader instructions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-12 12:13:30 +02:00
Philip Rebohle 8588b46900 vkd3d: Implement d3d12_command_list_CopyTiles.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-08 16:30:54 +02:00
Philip Rebohle 347f0e8b92 vkd3d: Fix d3d12_resource_init_sparse_info for images without mip tail.
StartTileIndexInOverallResource can be 0 for images that have either
no mip tail or no standard mips, so we need to check the packed mip
count.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-08 16:30:54 +02:00
Philip Rebohle 6d227ec653 tests: Add test for CopyTiles.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-08 16:30:54 +02:00
Philip Rebohle 9e6def6326 tests: Don't test return value of GetHeapProperties.
This returns E_INVALIDARG for reserved resources.
Instead, handle this case properly.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-08 16:30:54 +02:00
Philip Rebohle 00e956dfac vkd3d: Expose Tiled Resources Tier 1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 2e0ce6a186 vkd3d: Serialize sparse binding calls.
In D3D12, Update/CopyTileMappings are implicitly synchronized with
respect to other commands executing on the same queue, which means:

- Signal and Execute have to wait for previously submitted
  sparse binding operations to complete
- Wait and Execute have to complete before subsequently
  submitted sparse binding operations can execute.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 73bcd3e79d vkd3d: Create semaphores for sparse binding operations.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 902ab95ba6 vkd3d: Factor out vkd3d_create_timeline_semaphore.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 8b999c7368 vkd3d: Bind sparse metadata on resource creation if necessary.
Some sparse resource may have a metadata aspect on some drivers,
which needs to be bound before the image can be used in any way.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle e1b75748a2 vkd3d: Implement d3d12_command_queue_CopyTileMappings.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle f56a860bc6 vkd3d: Implement d3d12_command_queue_UpdateTileMappings.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle e3eb3498c2 vkd3d: Implement sparse binding.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 7836c06204 vkd3d: Add dedicated queue for sparse binding if necessary.
This will serve as a fallback if at least one queue family
does not support sparse binding.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 98462ea1ed vkd3d: Implement d3d12_device_GetResourceTiling.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle b08477f325 vkd3d: Store tile mappings and metadata for tiled resources.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle ba712c739c vkd3d: Add d3d12_resource_get_tiling helper.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 1167611ead vkd3d: Ensure sparse resource is supported by the device.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 5eee203559 vkd3d: Add validation for sparse image type and format.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 6793bb7e08 vkd3d: Set sparse resource flags appropriately.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 20b1c4f7b3 vkd3d: Introduce flag for sparse resources.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle fe13c017ea vkd3d: Move is_power_of_two to common header.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 830f9642b5 tests: Add tests for GetResourceTiling with compressed formats.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-07 15:24:35 +02:00
Philip Rebohle 0d74a13bc4 vkd3d: Improve error handling in d3d12_command_queue_init.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-06 14:48:59 +02:00
Philip Rebohle e59d6c4c32 vkd3d: Clean up queue creation and management.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-06 14:48:12 +02:00
Philip Rebohle 8edfa29542 vkd3d: Move vkd3d_queue_family into header.
And get rid of the somewhat redundant VKD3D_QUEUE_MAX_FAMILY_COUNT.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-06 14:48:12 +02:00
Philip Rebohle d386a473c2 vkd3d: Clean up vkd3d_select_queues.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-06 14:48:12 +02:00
Philip Rebohle e7711d2926 tests: Add test for sampler border colors.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-05 11:39:25 +02:00
Philip Rebohle 90ab915ec0 vkd3d: Implement support for custom border colors.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-05 11:39:25 +02:00
Philip Rebohle 42b6ce82f0 vkd3d: Enable VK_EXT_custom_border_color if available.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-05 11:39:25 +02:00
Philip Rebohle 8e7bf8a5c3 vkd3d: Do not use VK_PIPELINE_BIND_POINT_RANGE_SIZE.
These constants were removed in Vulkan 1.2.140 headers.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-05-05 11:39:25 +02:00
Philip Rebohle d742918353 tests: Fix compiler warning.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-30 18:08:25 +02:00
Philip Rebohle 642538e0a9 tests: Add test for UpdateTileMappings and CopyTileMappings.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-30 18:08:25 +02:00
Philip Rebohle 367895ebfa tests: Add test for GetResourceTiling.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-30 18:08:25 +02:00
Philip Rebohle c564d3eb1d tests: Expand test_create_reserved_resource.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-30 18:08:25 +02:00
Philip Rebohle 6f517a3788 vkd3d: Fix UpdateTileMappings signature.
Also, formatting.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-30 18:08:25 +02:00
Philip Rebohle 830c1e7a06 include: Fix incorrect UpdateTileMappings declaration.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-30 18:08:25 +02:00
Philip Rebohle 9367fd5ee8 vkd3d: Implement deferred clears.
This allows us to perform clears inside the render pass even if
the render pass hasn't been started at the time of the clear yet.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-28 16:29:11 +02:00
Philip Rebohle 7bfe5d0bb3 vkd3d: Remove d3d12_command_list_clear.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-28 16:29:11 +02:00
Philip Rebohle fe269109ef vkd3d: Reimplement ClearRenderTargetView.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-28 16:29:11 +02:00
Philip Rebohle 1cffdb93f2 vkd3d: Reimplement ClearDepthStencilView.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-28 16:29:11 +02:00
Philip Rebohle 0bd0352073 vkd3d: Introduce d3d12_command_list_clear_attachment helper.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-28 16:29:11 +02:00
Philip Rebohle e6bd3cb305 vkd3d: Don't emit barriers when temporarily suspending render passes.
Fixes performance regressions introduced with the barrier rework.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 16:13:19 +02:00
Philip Rebohle 0061c9e6d7 vkd3d: Define external render pass dependencies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 16:13:19 +02:00
Philip Rebohle d355f03d66 vkd3d: Fix depth-stencil load/store ops.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 16:13:19 +02:00
Philip Rebohle 1b447bd2dd vkd3d: Fix image layouts for swap chain back buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 1eac9936f4 vkd3d: Transition DSV to correct layout.
Now uses the layout from the graphics pipeline.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 0ff0423538 vkd3d: Store DSV layout with graphics pipelines.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle f0570509c1 vkd3d: Fix image layouts for clear operations.
We'll need to revisit this as the current implementation is
not only inefficient but also wrong in quite a few ways.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle ae89f2d639 vkd3d: Fix image layouts for resolve operations.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 82032e9e58 vkd3d: Fix image layouts for buffer<->image copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 151f18d9ef vkd3d: Fix image layouts in d3d12_command_list_copy_image.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 8d9d23a9f9 vkd3d: Rework d3d12_command_list_ResourceBarrier.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 5bb613ac07 vkd3d: Use common layout in initial state transitions.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle fc60b6400c vkd3d: Introduce vk_access_and_stage_flags_from_d3d12_resource_state.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 608ef6e605 vkd3d: Emit layout transitions when beginning and ending a render pass.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle edb793b069 vkd3d: Infer current DSV format from DSV descriptor.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle d3128592ca vkd3d: Store RTV and DSV descriptors with command list.
We need access to the resource in order to perform render pass
layout transitions, just the view handle isn't enough.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 8c09ef838a vkd3d: Use common image layout for descriptors.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 76b2d2af89 vkd3d: Add layout property to texture views.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 45001e05d4 vkd3d: Introduce d3d12_resource_pick_layout.
Lets us enforce GENERAL layout for linear tiling.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle 82d384531e vkd3d: Determine common image layout from bind flags.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-27 15:40:39 +02:00
Philip Rebohle baa0a293e7 vkd3d: Apply heap offset to destination buffer in ResolveQueryData.
Fixes rendering issues in The Talos Principle.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-23 17:26:55 +02:00
Hans-Kristian Arntzen 404cd7270b vkd3d: Fix build on standalone.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-23 12:31:48 +02:00
Hans-Kristian Arntzen 805f92a38c vkd3d: Remove dead transfer buffer code.
Obsoleted after shader copy path.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-23 12:31:48 +02:00
Philip Rebohle bc7b016d79 vkd3d: Set required image usage flags for shader-based copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle 5a0ef00d45 vkd3d: Use d3d12_command_list_copy_image for CopyResource as well.
Monster Hunter World uses this to copy between D32 and R32 images.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle 889ab3520f vkd3d: Implement shader-based depth <-> color copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle 30e1a49f68 vkd3d: Introduce d3d12_command_list_create_framebuffer.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle aa02ee02ca vkd3d: Create pipelines for shader-based image copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle da95bd6eaa vkd3d: Create common objects for fullscreen GS/VS.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle 4923d5ac04 vkd3d: Rename some internal functions.
To avoid confusion with similar functions in state.c.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle e74a48cdc6 vkd3d: Simplify meta operation API a bit.
Passing the main struct to the public functions allows us
to share common data between multiple types of operations.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle 082999fd71 vkd3d: Introduce vkd3d_make_shader_stage.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle ed1f146c91 vkd3d: Fix vkd3d_create_shader_module parameter order.
Otherwise, the SPIRV_CODE is useless when using the function directly.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Philip Rebohle 1cac03c643 vkd3d: Add shaders for shader-based depth <-> color copies.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 18:04:29 +02:00
Hans-Kristian Arntzen e5267713ef tests: Add basic DXR bringup test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-22 18:03:05 +02:00
Hans-Kristian Arntzen 6a6aa69abb include: Add missing DXR constants to IDL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-22 16:28:19 +02:00
Hans-Kristian Arntzen 02fb0d2974 vkd3d: Functions take void as argument type in C.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-22 16:26:59 +02:00
Hans-Kristian Arntzen 4595cacc79 vkd3d: Enforce that WCHAR is actually a WCHAR.
We will need to receive 2-byte WCHARs from apps.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-22 16:26:49 +02:00
Philip Rebohle c3170731bf vkd3d: Support CastingFullyTypedFormatSupported.
Look up the typeless format for any given image format, then
look up the corresponding compatibility list. This also fixes
a potential issue with implicit SRGB <-> UNORM compatibility.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 15:18:09 +02:00
Philip Rebohle 65f2e03dd0 vkd3d: Introduce vkd3d_get_typeless_format helper.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-22 15:18:09 +02:00
Philip Rebohle 9d361c56d6 vkd3d: Rework d3d12_create_sampler.
This now takes a sampler desc like d3d12_create_static_sampler,
and supports border colors if the provided border color matches
any of the supported Vulkan ones.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-21 11:57:14 +02:00
Philip Rebohle 532cb49abb vkd3d: Introduce d3d12_create_static_sampler.
It makes sense to separate this from d3d12_create_sampler since static
samplers and regular samplers differ in border color support.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-21 11:57:14 +02:00
Philip Rebohle 73410939da vkd3d: Remove NULL sampler.
Not used anywhere.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-21 11:57:14 +02:00
Sveinar Søpler c2e79af6a1 vkd3d: Fix 32-bit compiler warnings
This fixes a couple of 32-bit compiler warnings.

Signed-off-by: Sveinar Søpler <cybermax@dexter.no>
2020-04-21 11:54:59 +02:00
Philip Rebohle fcc9346e8d vkd3d: Clean up unnecessary members from d3d12_heap and d3d12_resource.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-17 17:08:13 +02:00
Philip Rebohle 6643ab45b5 vkd3d: Persistently map heaps on host-visible memory.
And zero-initialize mapped memory allocations, which seems to
fix some font corruption occationaly seen in Resident Evil 2.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-17 17:08:13 +02:00
Philip Rebohle 4ed642f5e6 vkd3d: Clean up heap initialization and destruction.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-17 17:08:13 +02:00
Hans-Kristian Arntzen 4d602d1958 vkd3d: Fix compilation warnings in d3d12-test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-17 17:03:40 +02:00
Hans-Kristian Arntzen 98f78f039f vkd3d: Fix linking error in vkd3d-standalone.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-17 17:03:40 +02:00
Hans-Kristian Arntzen ca7c027cd1 vkd3d: Replace dummy atomic_fetch_add with atomic loads.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-17 15:46:09 +02:00
Philip Rebohle 64bd4f6404 vkd3d: Add VKD3D_FEATURE_LEVEL override.
Unblocks some games that request Feature Level 12.0, such as
Anno 1800, Monster Hunter World, The Talos Principle. May
cause issues if games use unsupported features.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-17 15:36:51 +02:00
Philip Rebohle ccb2cea919 vkd3d: Always use cached memory type for readback heap.
We no longer require coherent memory types, so we should
always prefer a HOST_CACHED memory type for the readback
heap as well as corresponding custom heaps.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-17 15:36:02 +02:00
Philip Rebohle 7ad4ea2f78 vkd3d: Explicitly flush/invalidate mapped memory if necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-17 15:36:02 +02:00
Hans-Kristian Arntzen 09af24e69b vkd3d: Avoid vkResetCommandPool if there are pending command buffers.
Works around an app-bug in SotTR, where the command pool is reset before
the command buffer completes.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-17 15:31:38 +02:00
Hans-Kristian Arntzen 334b1cab8d vkd3d: Implement threaded submission queue.
D3D12 supports out-of-order signal and wait. So does Vulkan timeline
semaphores. However, in Vulkan we don't have an infinite amount of
virtual queues. We must potentially map multiple D3D12 queues on top of
Vulkan, which might lead to a deadlock when app attempts to
wait-before-signal if the two queues are mapped to the same physical
Vulkan queue.

In order to solve this, we need to hold back submissions until we know
it is safe to do so. To make this work in practice as simply as possible, each
ID3D12CommandQueue has its own submission thread, which will block on an
ID3D12Fence's pending timeline value for a Wait command. The main reason to use a
submission thread is that resolving this directly in
ID3D12CommandQueue::Signal is extremely tricky and potentially
needs recursively locking queues and fences.

Note that we only block on the pending wait value, not the actual wait
value, so there is no real CPU <-> GPU synchronization here. In the
common case, no submission thread will block.

The added benefit is that submits are async now, so main thread CPU
overhead might slightly decrease.

To play nice with DXGI swapchain, the external entry point for acquiring
the Vulkan queue needs to drain the submission thread and lock it to ensure
submissions happen in order.

Fixes hangs in The Division 1, which makes use of this D3D12 feature.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-17 15:31:38 +02:00
Philip Rebohle f9a2a68948 vkd3d: Improve d3d12_device_SetResidencyPriority stub.
Monster Hunter World requires this function to succeed.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-16 18:38:31 +02:00
Philip Rebohle 957aec4785 vkd3d: Restore old ClearUnorderedAccessView implementation.
The current code uses D3D12 abstractions to create pipelines but
issues raw Vulkan API calls to actually implement the functionality,
which means the code makes assumptions about the exact descriptor
set layout and push constant layout, which is generally a bad idea
now that we have multiple code paths for root constants etc.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-16 18:03:39 +02:00
Hans-Kristian Arntzen edc614ab2e vkd3d: Remove legacy fence/semaphore path.
Prepares for a rewrite of queue submission, the legacy path is never
run in practice and will likely break in subtle ways.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-16 15:31:04 +02:00
Philip Rebohle bbfbf94c5e vkd3d-shader: Always use private vars for arrayed builtins.
Fixes invalid shader code being generated in Monster Hunter World.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-16 10:30:51 +02:00
Philip Rebohle 0c2057ff68 vkd3d-shader: Support texel offset for sample_c instruction.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-16 10:30:51 +02:00
Philip Rebohle 55be09fb0d vkd3d: Support 1D texture views.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-16 10:30:51 +02:00
Philip Rebohle 5bf266a8ed vkd3d: Check whether root descriptors are defined.
Fixes a crash in Monster Hunter World.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-16 10:29:17 +02:00
Philip Rebohle d6204bb993 vkd3d: Implement D3D12_FEATURE_QUERY_META_COMMAND feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 14:25:01 +02:00
Philip Rebohle 25f0af58f6 vkd3d: Implement D3D12_FEATURE_D3D12_OPTIONS6 feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 14:25:01 +02:00
Philip Rebohle 0701d87474 vkd3d: Update ID3D12CommandList to ID3D12GraphicsCommandList5.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 14:25:01 +02:00
Philip Rebohle 61530857d6 vkd3d: Update ID3D12Device to ID3D12Device6.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 14:25:01 +02:00
Philip Rebohle bfcb41706c include: Update D3D12 IDL.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 14:25:01 +02:00
Hans-Kristian Arntzen 6c9683e23c vkd3d: Do not always attempt dedicated buffer allocation for heap.
On NVIDIA we sometimes fail to place images on a heap because the memory
region was dedicated. Only bother trying this if heap flags only allow
buffers.

Fixes a GPU crash in The Division.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-04-15 13:33:44 +02:00
Philip Rebohle 78b6d291cd vkd3d: Implement D3D12_FEATURE_D3D12_OPTIONS5 feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 10:35:59 +02:00
Philip Rebohle 638dcb1afb vkd3d: Update ID3D12Device to ID3D12Device5.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 10:35:59 +02:00
Philip Rebohle 084f8ed949 vkd3d: Update ID3D12CommandList to ID3D12GraphicsCommandList4.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 10:35:59 +02:00
Philip Rebohle dbeffb0834 vkd3d: Update ID3D12Fence to ID3D12Fence1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 10:35:59 +02:00
Philip Rebohle d65cd725d9 include: Fix typos.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-15 10:35:59 +02:00
Philip Rebohle 0871f02b7e vkd3d: Implement D3D12_FEATURE_CROSS_NODE feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle 03b15571d8 vkd3d: Implement D3D12_FEATURE_SERIALIZATION feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle 26538f4377 vkd3d: Implement D3D12_FEATURE_D3D12_OPTIONS4 feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle d94b48a851 vkd3d: Update ID3D12Resource to ID3D12Resource1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle e2881e199d vkd3d: Update ID3D12Heap to ID3D12Heap1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle cc4762935f tests: Test GetResourceAllocationInfo1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle 9c119b907c vkd3d: Implement ID3D12Device4::GetResourceAllocationInfo1.
Also, support querying more than one resource at a time.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle 0c03bbe9b5 vkd3d: Implement ID3D12Device4::CreateCommandList1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle 23e2b62950 vkd3d: Implement ID3D12Device4::CreateReservedResource1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle a66e9a2ce4 vkd3d: Implement ID3D12Device4::CreateCommittedResource1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle 5fbca43bc8 vkd3d: Implement ID3D12Device4::CreateHeap1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle aa2c21b2bd vkd3d: Update ID3D12Device to ID3D12Device4.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle 108ce6409b vkd3d: Update ID3D12CommandList to ID3D12GraphicsCommandList3.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle 561675410b include: Fix typo.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-14 16:27:08 +02:00
Philip Rebohle 407c740927 vkd3d: Rework vkd3d_dxbc_compiler_get_resource_binding.
Instead of taking the resource type, take the binding flag.
This allows us to also use this function for UAV counters.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-10 14:32:33 +02:00
Philip Rebohle c44b168da2 include: Fix ID3D12Device2 GUID.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-08 14:23:28 +02:00
Philip Rebohle da07275b16 vkd3d: Implement d3d12_device_CreatePipelineLibrary.
Needed by Claybook.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-08 14:23:28 +02:00
Philip Rebohle 9647109559 vkd3d: Add stubs for ID3D12PipelineLibrary1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-08 14:23:28 +02:00
Philip Rebohle 50b5959e64 vkd3d: Implement better stub for GetCachedBlob.
We currently can't implement this in a meaningful way, but we
should return an empty blob in order to not crash applications.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-08 14:23:28 +02:00
Philip Rebohle 20aa3c3c26 vkd3d: Make ID3DBlob implementation more accessible.
We're going to need this to implement other parts of the
API, so it should be in common code.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-08 14:23:28 +02:00
Philip Rebohle ecc46fe1ec tests: Add test for exporting SV_StencilRef from PS.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-06 11:53:09 +02:00
Philip Rebohle 7f91484c28 vkd3d: Enable EXT_shader_stencil_export if available.
Allows us to expose PSSpecifiedStencilRefSupported.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-06 11:53:09 +02:00
Philip Rebohle 56df26d845 vkd3d-shader: Implement support for stencil export.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-06 11:53:09 +02:00
Philip Rebohle 0873f15f2e tests: Add test for exporting SV_RenderTargetArrayIndex from VS.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-06 11:53:09 +02:00
Philip Rebohle 4c1cc5732c vkd3d: Enable VK_EXT_shader_viewport_index_layer if available.
And expose the following feature cap on capable GPUs:
VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-06 11:53:09 +02:00
Philip Rebohle 3ee4ab56d7 vkd3d-shader: Enable SPV_EXT_shader_viewport_index_layer if necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-06 11:53:09 +02:00
Philip Rebohle c07f46f09c vkd3d-shader: Look up existing register fpr built-in outputs.
Otherwise, if two built-in outputs share the same register, we
may end up multiple redundant private variables, only one of
which gets initialized, leading to uninitialized outputs.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-06 11:53:09 +02:00
Philip Rebohle 4e3ea62e79 vkd3d: Implement depth bounds test.
Used by Resident Evil 2 and 3 if available.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 16:04:39 +02:00
Philip Rebohle 960e6f85fd vkd3d: Support multiple viewports.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 15:57:23 +02:00
Philip Rebohle ae789d9ba8 vkd3d: Pass dynamic state struct to get_or_create_pipeline.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 15:57:23 +02:00
Philip Rebohle 0cc33cb823 vkd3d: Move vertex strides and primitive topology to dynamic_state.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 15:57:23 +02:00
Philip Rebohle 9cb863f84a vkd3d: Only enable dynamic states if necessary.
Avoids some unnecessary API calls.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 15:39:33 +02:00
Philip Rebohle d48794408a vkd3d: Refactor dynamic state updates.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 15:39:33 +02:00
Philip Rebohle e08580f178 vkd3d: Refactor dynamic state enablement.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 15:39:33 +02:00
Philip Rebohle d8a6d71038 vkd3d: Introduce vkd3d_dynamic_state.
And add a function to (re-)apply dynamic state as necessary. This
will allow us to ignore dynamic state not needed by the pipeline,
and may become necessary if we implement shader-based copies etc.

Currently unused; the following commits will subsequently change
state setting methods over.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 15:39:33 +02:00
Philip Rebohle 6fbc38118a vkd3d: Implement support for logic op.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 13:54:10 +02:00
Philip Rebohle 1b41a77c19 include: Add missing logic ops.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 13:54:10 +02:00
Philip Rebohle 1d8afd85d4 vkd3d: Signal fence in EnqueueMakeResident.
Resident Evil 2 needs this method. Since we don't really have a concept
of explicit memory residency in Vulkan, we're fine not doing anything else.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 11ca844bef vkd3d: Implement CreatePipelineState.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle f032702a74 vkd3d: Extend graphics pipeline description.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle b6b4f7e8d5 tests: Add test for ID3D11Device2::CreatePipelineState.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 5ba09a9ab4 vkd3d: Implement D3D12_FEATURE_EXISTING_HEAPS feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 0a5c618e9e vkd3d: Implement D3D12_FEATURE_D3D12_OPTIONS3 feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 34180e4073 vkd3d: Implement D3D12_FEATURE_COMMAND_QUEUE_PRIORITY feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle ef937713e3 vkd3d: Implement D3D12_FEATURE_SHADER_CACHE feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 1ab7dd67a0 vkd3d: Implement D3D12_FEATURE_D3D12_OPTIONS2 feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 8687969a2a vkd3d: Implement D3D12_FEATURE_ARCHITECTURE1 feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 3dc9f7c585 vkd3d: Implement D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_SUPPORT feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 90a22df2a4 vkd3d: Implement D3D12_FEATURE_D3D12_OPTIONS1 feature query.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 7c7db3c77c vkd3d: Optionally enable VK_EXT_subgroup_size_control.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 0273292224 vkd3d: Optionally enable VK_NV_shader_sm_builtins.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle ebcc18583c vkd3d: Optionally enable VK_AMD_shader_core_properties{_2}.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 70ac2f147e vkd3d: Upgrade ID3D12Device to ID3D12Device3.
Stubs for now, will implement new functionality as needed.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle ac1942f9ac include: Fix typos and add D3D12_DEPTH_STENCIL_DESC1.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle 6b113bb629 vkd3d: Introduce d3d12_command_list_iface type alias.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle b6d5a407ce vkd3d: Define d3d12_device_iface type alias.
This way we don't have to change all function parameter types
every time we upgrade the interface version.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-04-01 10:35:40 +02:00
Philip Rebohle c41275478c vkd3d: Refactor pipeline state creation.
We need a more extensible struct to contain the pipeline
descriptions in order to be able to support new rendering
features.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-31 18:28:18 +02:00
Hans-Kristian Arntzen fce6838870 vkd3d: Fix compilation warning on 32-bit.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-31 17:27:33 +02:00
Sveinar Søpler e765145717 vkd3d: Require vulkan headers > 1.1.129
VK_KHR_buffer_device_address requires Vulkan headers > 1.1.129

Signed-off-by: Sveinar Søpler <cybermax@dexter.no>
2020-03-31 17:27:21 +02:00
Sveinar Søpler 257c38c59d vkd3d: Require Vulkan headers > 1.1.124
Implementing VK_KHR_timeline_semaphore extension requires vulkan
headers > 1.1.124.

Signed-off-by: Sveinar Søpler <cybermax@dexter.no>
2020-03-31 16:45:23 +02:00
Hans-Kristian Arntzen 09885f799c vkd3d: Implement stricter checking for timeline semaphores.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-31 12:51:05 +02:00
Hans-Kristian Arntzen 3b9f1f8a9c vkd3d: Use monotonically increasing fence values in test suite.
Microsoft documentation says that fences are monotonically increasing
values.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-31 12:51:05 +02:00
Hans-Kristian Arntzen 855c59eae5 vkd3d: Implement timeline semaphores.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-31 12:51:05 +02:00
Hans-Kristian Arntzen afdbf6edcd vkd3d: Enable VK_KHR_timeline_semaphore extension.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-31 12:51:05 +02:00
Philip Rebohle 22feb3e8be include: Update D3D12 IDL.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 15:45:05 +02:00
Philip Rebohle 8344e8224e vkd3d: Only add feature structs to pNext chain if extension is supported.
RenderDoc will sometimes report extensions as unsupported, but still
fill out and accept the respective feature structs. Since we assume
extensions to be supported if the feature is enabled, we sometimes
try to use functionality that RenderDoc disables and crash.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 11:07:53 +02:00
Philip Rebohle 00d88454ee vkd3d: Factor out extension enumeration.
Besides cleaning up the code, this also allows us to
use information about the available extensions earlier.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 11:07:53 +02:00
Philip Rebohle 34f9cae1c6 vkd3d: Disable unused BufferDeviceAddress features.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 11:07:53 +02:00
Philip Rebohle cf759d4d76 vkd3d: Only set memory device address bit if extension is supported.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 11:07:53 +02:00
Philip Rebohle f5dc3fa8c8 vkd3d: Skip redundant descriptor copies.
Greatly improves performance in Control.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 10:51:14 +02:00
Philip Rebohle 78034ecef1 vkd3d: Simplify checks whether a descriptor has a view.
SaVes a few CPU cycles on a potentially very hot code path.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 10:51:14 +02:00
Philip Rebohle 1836815222 vkd3d: Rework descriptor magic.
Changes the magic to a three-character string with flags
in the highest byte.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 10:51:14 +02:00
Philip Rebohle 33a2ace768 vkd3d: Don't copy entire descriptor when destroying view.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 10:51:14 +02:00
Philip Rebohle 09b7013f59 vkd3d: Don't use push descriptors if we exceed the device limit.
This can in theory happen if we have 32 root descriptors and
bindless UAV counters.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 10:47:47 +02:00
Philip Rebohle 29d1a5e089 vkd3d: Remove unused root descriptor count from root signature.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 10:47:47 +02:00
Philip Rebohle 643ace438e vkd3d: Store push descriptor properties in device info struct.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 10:47:47 +02:00
Philip Rebohle a7a27e3c05 vkd3d: Fix descriptor count for UAV counter binding.
Copy-paste error that causes us to exceed the push descriptor
limit in some situations.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-30 10:47:47 +02:00
Philip Rebohle 920d029100 vkd3d: Don't require bindless UAV counters for RESOURCE_BINDING_TIER_3.
Nvidia does not support VK_KHR_buffer_device_address at the moment.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-28 10:39:14 +01:00
Hans-Kristian Arntzen 671560c4e3 vkd3d-shader: Allow bindless UAV counters in DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-27 15:43:19 +01:00
Hans-Kristian Arntzen 31a2a308ee vkd3d-shader: Enable physical storage extension in DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-27 15:43:19 +01:00
Hans-Kristian Arntzen 877c3afedd vkd3d: Fix MSVC build.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-27 15:43:19 +01:00
Philip Rebohle 8843739797 vkd3d: Require bindless UAV and UAV counters for BINDING_TIER_3.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:37:59 +01:00
Philip Rebohle f8c842f03c vkd3d: Enable bindless UAV counters if supported.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle e97c5be394 vkd3d: Enable VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle b5b9f464d7 vkd3d: Enable VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR as necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle e1ad2f0f03 vkd3d: Set SHADER_DEVICE_ADDRESS_BIT for buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle 74b1831960 vkd3d: Bind UAV counter address buffer if necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle b64284d40d vkd3d: Write UAV counter addresses to the address buffer.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle 1b39b107b1 vkd3d: Create buffer for UAV counter addresses.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle 000983aa73 vkd3d: Declare bindless UAV counter binding.
We'll add this to the root descriptor set since moving the binding
to one of the bindless sets would be hard to do; we'd need to track
the binding index of each "bindless" binding for set updates etc.

In order to stay within the limit of 8 sets, we also cannot introduce
a separate set for UAV counters (currently there are 6 bindless sets,
the static sampler set, and the root descriptor set).

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle 577efe9040 vkd3d: Optionally enable VK_KHR_buffer_device_address.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle 4d896bf53c vkd3d-shader: Use correct addressing model for physical storage buffers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle aca3e7636e vkd3d-shader: Implement bindless UAV counter ops.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle cb9775ca05 vkd3d-shader: Respect bindless flag for UAV counter bindings.
Also stores the type ID of the pointer to the UAV counter struct,
since we need to load the pointer before we can access the counter.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle 11a9ac6c19 vkd3d-shader: Emit declarations for bindless UAV counters.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 15:04:23 +01:00
Philip Rebohle facae7690c vkd3d: Replace descriptor mutex with per-descriptor spinlocks.
Greatly improves performance in various games that update or
copy a large number of descriptors per frame due to the high
overhead of pthread_mutex_{un}lock.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-27 13:33:03 +01:00
Philip Rebohle b577b5c329 vkd3d-common: Implement spinlock.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-27 13:33:03 +01:00
Hans-Kristian Arntzen 1030989973 vkd3d: Fix integer cast warning in d3d12.c.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-26 12:17:55 +01:00
Philip Rebohle cdc35483c4 vkd3d: Remove default pixel shader.
Unnecessary.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:07:28 +01:00
Philip Rebohle 682838b193 vkd3d: Enable bindless UAV.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:05:47 +01:00
Philip Rebohle b6cfef09cb vkd3d: Explicitly assign UAV counter set.
Otherwise, we pass an incorrect set index when using bindless UAVs.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:05:47 +01:00
Philip Rebohle 4ee06bc5d6 vkd3d: Ignore UAV counters for unbounded UAV ranges.
We cannot support that right now.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:05:47 +01:00
Philip Rebohle 3fa194ce21 vkd3d-shader: Support nonuniform qualifier for bindless UAVs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:05:47 +01:00
Philip Rebohle fb92b7c113 vkd3d-shader: Emit bindless UAV declarations.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:05:47 +01:00
Philip Rebohle 8dd73f3e45 vkd3d-shader: Explicitly pass flags to get_global_binding.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:05:47 +01:00
Philip Rebohle a0c1ce4e55 vkd3d-shader: Explicitly pass image format to get_global_binding.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:05:47 +01:00
Philip Rebohle 18caa8adc3 vkd3d-shader: Pass resource binding struct to get_global_binding.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:05:47 +01:00
Philip Rebohle 81ee079449 vkd3d-shader: Move atomic counter declaration.
Allows us to have bindless UAVs without a special code path
for bindless UAV counters for now.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-26 12:05:47 +01:00
Philip Rebohle 31518debc2 vkd3d-shader: Always initialize modifer.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-25 19:31:33 +01:00
Hans-Kristian Arntzen 89cefd87d5 vkd3d: Add test for bindless UAV counters.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-25 14:42:32 +01:00
Hans-Kristian Arntzen 2d83388313 vkd3d: Add test for bindless UAV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-25 14:42:32 +01:00
Hans-Kristian Arntzen 7c479f6dae vkd3d: Disable index_buffer_strip_cut spam in normal runtime.
Demote this warning to TRACE only.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-25 12:54:44 +01:00
Hans-Kristian Arntzen 4939e38c14 vkd3d: Clamp RTV/DSV array sizes to their real array lengths.
Avoids overflowing vkCreateFramebuffer later with UINT_MAX layers.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-25 11:27:14 +01:00
Hans-Kristian Arntzen f7ea9967d0 vkd3d: Use minimum width/height/layer framebuffer.
All attachments must be at least as large as the framebuffer, using a
max operator is not compliant with Vulkan.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-25 11:17:01 +01:00
Hans-Kristian Arntzen afb47543d2 vkd3d: Always use CBV-as-SSBO path.
NVIDIA currently seems to have some issues with bindless CBV on Vulkan,
which have been reported. Somehow, bindless SSBO works around black
screen on SotTR, as well as some rendering glitches on Control.

AMD won't care since UBOs and SSBOs are basically the same thing.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-25 11:16:44 +01:00
Philip Rebohle b85852e733 vkd3d: Fix barriers for bindless CBV-as-SSBO.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-23 16:20:38 +01:00
Hans-Kristian Arntzen 8010c26ec4 vkd3d: Do not attempt to enable primitive restart for non-strip topology.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-23 12:56:16 +01:00
Philip Rebohle e7360fbd46 vkd3d: Fix build.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-19 14:39:58 +01:00
Philip Rebohle d4d299d765 vkd3d: Initialize feature options in d3d12_device_caps_init.
Also reworks the check for resource binding tiers.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-19 13:10:18 +01:00
Philip Rebohle 1e78cd3397 vkd3d: Determine maximium feature level in d3d12_device_caps_init.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-19 13:10:18 +01:00
Philip Rebohle bf8863568c vkd3d: Introduce d3d12_device_caps_init.
This method is meant to process d3d12 device caps after the
device itself has been fully initialized. This helps avoid
code duplication in certain instances and guarantees that we
know about all enabled Vulkan features.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-19 13:10:18 +01:00
Philip Rebohle f3e8c156c2 vkd3d: Move minimum feature level check to d3d12_device_create.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-19 13:10:18 +01:00
Philip Rebohle 19b971de0a vkd3d: Introduce d3d12_caps.
Meant to bundle all d3d12 feature caps and options, of which
we're going to have to add more over time.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-19 13:10:18 +01:00
Hans-Kristian Arntzen e85cc6288e vkd3d: Declare inline header function as static.
Fixes some linking issues on my end with undeclared external symbols.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-18 15:39:04 +01:00
Hans-Kristian Arntzen b7c14698b4 vkd3d-shader: Add CBV_AS_STORAGE_BUFFER support to DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-18 15:39:04 +01:00
Philip Rebohle 95c1faeeb9 vkd3d: Add some missing bindless feature checks.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 14:35:35 +01:00
Philip Rebohle 2ffb5396cc vkd3d: Use storage buffers for bindless CBV if supported.
Used as a fallback for older Nvidia generations which do not
support bindless uniform buffers.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 14:35:35 +01:00
Philip Rebohle 8618bc1d5b vkd3d: Enable storage buffer usage alongside uniform buffer usage.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 14:35:35 +01:00
Philip Rebohle ef80658ffb vkd3d: Do not disable storage buffer indexing features.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 14:35:35 +01:00
Philip Rebohle fda155b965 vkd3d: Adjust descriptor types if CBV_AS_SSBO is set.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 14:35:35 +01:00
Philip Rebohle 3709ae1dd8 vkd3d: Introduce VKD3D_BINDLESS_CBV_AS_SSBO flag.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 14:35:35 +01:00
Philip Rebohle a9ba32a6c4 vkd3d-shader: Add option to declare bindless CBVs as SSBOs.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 14:35:35 +01:00
Hans-Kristian Arntzen 71d8f63356 vkd3d: Split descriptor pool allocation based on usage.
Logically split up descriptor pool allocation in three types:
- STATIC: Root descriptors and internal allocation.
- VOLATILE: For packed descriptor set which comes from heaps.
- IMMUTABLE_SAMPLER: For immutable samplers. This should be removed once
  we start allocating sampler sets at sampler creation time.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-18 14:29:03 +01:00
Hans-Kristian Arntzen 291db5581c vkd3d: Fix push constant size check against D3D12_MAX_ROOT_COST.
MAX_ROOT_COST is in terms of number of u32s.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-18 14:29:03 +01:00
Philip Rebohle 5bf4b207f2 vkd3d-shader: Bound-check root constant reads.
Safety measure in case a broken app performs out-of-bounds reads.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 11:57:35 +01:00
Philip Rebohle 423bb09b46 vkd3d-shader: Unroll root constant buffers.
Fixes spec violations when we have root constant ranges not
aligned to 16 bytes.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 11:57:35 +01:00
Philip Rebohle d129e477f6 vkd3d-shader: Load constant buffer components individually.
Enables us to unroll root constant buffers. Not loading unneeded
components early may also help some drivers generate better code.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 11:57:35 +01:00
Philip Rebohle 01098e194e vkd3d-shader: Simplify vkd3d_dxbc_compiler_emit_mov.
Having a lot of special code here just makes it harder for
us to implement UBO-specific load path, not to mention that
the mov instruction itself is very rare.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-18 11:57:35 +01:00
Hans-Kristian Arntzen ceee2096a5 vkd3d: Query subgroup properties and expose SM 6.0 if present.
Does not cover every case for SM 6.0, but it's a useful start.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-18 10:58:17 +01:00
Hans-Kristian Arntzen b88f04bd21 vkd3d-shader: Add integration for DXIL shaders.
If we detect that a blob contains a DXIL chunk, use dxil-spirv to
compile the shader to SPIR-V if it is enabled in the build.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-18 10:58:17 +01:00
Hans-Kristian Arntzen e21d077a04 vkd3d: Workaround CBV bindless test.
DXC is bugged and does not emit the NonUniformResourceIndex qualifier
in DXIL, and thus we expect this test to fail on AMD (it works just fine
on NV though). Only check the first lane of the workgroup for
correctness.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-18 10:58:17 +01:00
Philip Rebohle c7af09c68c vkd3d: Allocate descriptor pool space for inline uniform blocks.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-16 20:49:56 +01:00
Philip Rebohle 87e9bb3e82 vkd3d: Use inline uniform block for push constant data if necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-16 13:54:12 +01:00
Philip Rebohle ada3890211 vkd3d: Write inline uniform block if necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-16 13:54:12 +01:00
Philip Rebohle 2688219573 vkd3d: Add inline uniform block to root descriptor set layout if desired.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-16 13:54:12 +01:00
Philip Rebohle e899b96c10 vkd3d: Introduce root signature flag to determine push descriptor usage.
For now this is enbaled based on device capabilities, but future changes
may require this to be disabled for certain root signatures.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-16 13:54:12 +01:00
Philip Rebohle d515e3efa7 vkd3d: Rename flags -> d3d12_flags in d3d12_root_signature.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-16 13:54:12 +01:00
Philip Rebohle be5cdd2e55 vkd3d-shader: Optionally declare push constant buffer as UBO.
Will be used on implementations that do not support enough
push constants to hold all root signature data.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-16 13:54:12 +01:00
Philip Rebohle c658eda3df vkd3d: Enable VK_EXT_inline_uniform_block if available.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-16 13:54:12 +01:00
Philip Rebohle 02e98e3d5c vkd3d-shader: Unroll descriptor table offsets.
Avoids having to use 16-byte array strides when using an
inline uniform block to store the table offsets.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-16 13:54:12 +01:00
Hans-Kristian Arntzen a6b61fbc1d vkd3d: Add bindless CBV test for DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-12 12:01:23 +01:00
Hans-Kristian Arntzen 8fff9c3028 vkd3d: Add bindless samplers test for DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-12 12:01:23 +01:00
Hans-Kristian Arntzen 9ebb14727d vkd3d: Add bindless SRV test for DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-12 12:01:23 +01:00
Philip Rebohle b495e94062 vkd3d: Enable bindless constant buffer views.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-12 11:32:41 +01:00
Philip Rebohle 77bc640f3f vkd3d-shader: Implement dynamic UBO indexing.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-12 11:32:41 +01:00
Philip Rebohle 6a7f1b95e5 vkd3d-shader: Add global UBO binding declarations.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-12 11:32:41 +01:00
Philip Rebohle b11b95f34d vkd3d-shader: Factor out bindless resource index computation.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-12 11:32:41 +01:00
Hans-Kristian Arntzen 912840351f vkd3d: Add test for bindless CBV.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-12 11:11:25 +01:00
Hans-Kristian Arntzen fee9b2bb05 vkd3d: Implement RS 1.0 volatile for packed descriptor set.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-11 12:20:00 +01:00
Philip Rebohle 708f26bf40 vkd3d: Only update packed descriptor set if necessary.
When changing tables that only have bindless descriptors,
only update the push constants instead.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-11 10:47:58 +01:00
Philip Rebohle 5f2d511a96 vkd3d: Store whether a descriptor table has packed descriptors.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-11 10:47:58 +01:00
Philip Rebohle 2e18afc7cb vkd3d: Introduce dirty flags for pipeline bindings.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-11 10:47:58 +01:00
Philip Rebohle 76f42069f4 vkd3d: Add comment about WoW requiring BINDING_TIER_3 support.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle fe2a4c62c9 vkd3d: Enable bindless samplers and SRVs if supported by the device.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle 8847a78f33 vkd3d: Store vkd3d_physical_device_info with d3d12_device.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle 2b45574fc2 vkd3d: Invalidate descriptor heap bindings if necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle be20e9a9c1 vkd3d: Set descriptor table offsets via push constants.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle af4c211f34 vkd3d: Bind descriptor sets for active descriptor heaps.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle 4e95975182 vkd3d: Add bindless descriptor set layouts to pipeline layouts.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle e68aa6c85c vkd3d: Pass descriptor table info to shader compiler.
Adds one push constant per descriptor table to the push constant range.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle a30f511f9a vkd3d: Declare descriptor ranges as bindless if supported.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle 83674a8a61 vkd3d: Correctly handle bindless ranges when counting descriptors.
We still need to pass binding info for each range to the shader compiler,
but bindless ranges will not contribute to the packed descriptor count.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 15:25:54 +01:00
Philip Rebohle 4e9642fa6c vkd3d: Update bindless descriptor sets if necessary.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 14:30:28 +01:00
Philip Rebohle 2f7781e3c1 vkd3d: Store heap in resource descriptors.
Otherwise, we won't know which descriptor set to write
to when using bindless.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 14:30:28 +01:00
Philip Rebohle a1e6a1510f vkd3d: Create descriptor pool and sets for descriptor heaps.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 14:30:28 +01:00
Philip Rebohle 01cbbaea81 vkd3d: Create bindless descriptor set layouts.
Don't enable any bindless features for now so that we don't
introduce regressions as features get added.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 14:07:51 +01:00
Philip Rebohle c4a173ddca vkd3d: Separate UAV counter bindings from UAV buffer/image bindings.
Now that the binding code no longer makes any wild assumptions about
the exact binding layout, we can safely do this. Will make implementing
bindless a bit easier.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 14:07:51 +01:00
Philip Rebohle 6e15ad20b4 vkd3d: Rework descriptor table binding.
Uses the new data structures to iterate over descriptor
tables and populate the packed descriptor set.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 14:07:51 +01:00
Philip Rebohle 4979953ff9 vkd3d: Rework descriptor tables.
Further changes will require a rework of how resource binding
works inside a command list, so for now, this is just a cleanup
that also removes some old code that is no longer needed.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 13:11:10 +01:00
Philip Rebohle 28bf2eec3e vkd3d: Rework static samplers.
Static samplers are embedded in the root signature, so we can create
a separate descriptor set layout and descriptor set which we only
need to rebind when the root signature itself changes.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 13:11:10 +01:00
Philip Rebohle ae12e22187 vkd3d: Rework root descriptor updates.
Updates the root descriptor set or push descriptor at draw time.
This fixes a potential issue with shader-based clear/copy commands
invalidating previously bound root descriptors.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 12:19:07 +01:00
Philip Rebohle 82bf3e810b vkd3d: Rework root descriptors.
Streamlines descriptor set layout creation for root descriptors.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 12:19:07 +01:00
Philip Rebohle 41a8587f10 vkd3d: Implement unsafe_impl_from_ID3D12DescriptorHeap.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:59:17 +01:00
Philip Rebohle a1ade15885 vkd3d: Rename and repurpose vkd3d_descriptor_set_context members.
- descriptor_index is the index of the descriptor within the packed
  descriptor set or root descriptor set. Currently unused.
- binding_index should now index into the root_signature->bindings array.
- vk_set and vk_binding refer to the Vulkan descriptor set index and
  binding number of packed descriptors or root descriptors.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:59:17 +01:00
Philip Rebohle 189bcd39af vkd3d: Store index of root descriptor set in root signature.
This allows us to put root descriptors into a set other than 0.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle 3f125ac919 vkd3d: Temporarily require VK_KHR_push_descriptor.
Allows us to more easily refactor root signature-related code
without having to worry about root descriptors for now.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle 0d071c9c37 vkd3d: Rename root signature descriptor set layout members.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle 287f4e525b vkd3d: Remove some useless null pointer checks in d3d12_root_signature_cleanup.
All vkDestroy* functions are defined to perform no operation when passed
a null handle. vkd3d_free should follow regular free semantics.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle 5e8821d561 vkd3d: Clean up root signature descriptor counting.
Removes some unused counters and repurposes the existing ones to
differentiate between bindings (i.e. the array passed to the shader
compiler) and packed descriptors.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle 7c276f5e82 vkd3d: Rework root constant updates.
Fixes an issue where push constants can be invalidated by
shader-based clear/copy commands.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle 0eed8a1080 vkd3d: Rework root constants.
Uses one push constant range with VK_SHADER_STAGE_ALL. This
will allow us to easily add descriptor table offsets as push
constants.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle aff849e7f4 vkd3d: Add helpers to iterate over 64-bit masks.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle 5700b37aa4 vkd3d-shader: Work around games not declaring bindings properly.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Philip Rebohle a7fbb728ec vkd3d-shader: Apply NonUniformEXT decorations to resources as needed.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Philip Rebohle d92d2af986 vkd3d-shader: Parse NonUniform operand modifier.
This modifier can be applied to both destination and source
operands, so for the sake of simplicity and to avoid having
to pass down modifier information explicitly, just store this
state with the register.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Philip Rebohle 1c9b07e8b3 vkd3d-shader: Scan multi-register descriptor ranges properly.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Philip Rebohle ffaa31e1d9 vkd3d-shader: Implement bindless sampler declarations and indexing.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Philip Rebohle 6f20fcc488 vkd3d-shader: Implement bindless resource indexing.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Philip Rebohle 6c4a476318 vkd3d-shader: Implement bindless resource declarations.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Philip Rebohle ade87e6c47 vkd3d-shader: Add push constants for descriptor table offsets.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Philip Rebohle 4218009e79 vkd3d-shader: Add helpers to declare runtime arrays.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Philip Rebohle 34e128897d vkd3d-shader: Pass more info from root signature to shader compiler.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 10:55:24 +01:00
Hans-Kristian Arntzen ae2a2bdbe8 vkd3d: Fix DXIL check in test_coverage.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-06 17:15:38 +01:00
Philip Rebohle 598afec8ea vkd3d: Create NULL sampler.
Defaults taken from D3D11.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-05 13:03:44 +01:00
Philip Rebohle 8fc2fb9842 vkd3d: Create NULL buffer and image views.
An upcoming change to the binding model will use these to
initialize descriptors that have the wrong resource type
bound, or were left uninitialized by the application.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-05 13:03:44 +01:00
Philip Rebohle 0ecce2ec2f vkd3d: Use different formats for UAVs than for SRVs.
Otherwise we might run into undefined behaviour if an app
tries to read a NULL UAV or perform atomic operations.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-05 13:03:44 +01:00
Hans-Kristian Arntzen 92724ce15c vkd3d: Attempt to create a Vulkan 1.1 instance and device.
Need this to support subgroup operations for SM 6.0.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-03-05 11:03:01 +01:00
Philip Rebohle dfa208f909 vkd3d: Remove d3d12_command_list_invalidate_bindings.
The primary purpose of this function was to invalidate UAV
counters upon binding a pipeline. This is no longer an issue
and we don't have any other per-pipeline bindings, so this
function can be dropped.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-03 20:58:46 +01:00
Philip Rebohle f3d89a548a vkd3d: Reintroduce UAV counters.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-02 12:16:30 +01:00
Philip Rebohle 324da790db vkd3d-shader: Simplify UAV counter interface declaration.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-02 12:16:30 +01:00
Philip Rebohle 0689d8396d vkd3d-shader: Change the way UAV bindings are tracked.
Makes UAV-related code more readable and supports up to 64
UAV bindings, which is enough to support resource binding
tier 2.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-02 12:16:30 +01:00
Philip Rebohle 0dab14ed22 vkd3d: Temporarily drop UAV counter support.
This needs a major rework as the current implementation has bugs,
is hard to reason about, and very hard to maintain as we're about
to make major changes to the binding model as a whole.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-02 12:16:30 +01:00
Hans-Kristian Arntzen f015da5e56 vkd3d-shader: Add entry point to query if DXIL is supported.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-29 14:11:57 +01:00
Hans-Kristian Arntzen d1f44ad39b vkd3d: Add dxil-spirv to autoconf
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-29 14:11:57 +01:00
Hans-Kristian Arntzen 3ebe2eb527 vkd3d-shader: Expose debug shader dumping in private header.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-27 19:46:30 +01:00
Hans-Kristian Arntzen 4928f9c094 vkd3d-shader: Add path for debug dumping SPIR-V as well.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-27 19:46:30 +01:00
Hans-Kristian Arntzen 0f971790e6 vkd3d-shader: Attempt to parse ISG1 as well when parsing input signatures.
DXIL blobs use ISG1.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-27 15:20:10 +01:00
Hans-Kristian Arntzen 4a9ab29903 vkd3d-shader: Add helper function to query if a blob is DXIL.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-27 15:20:10 +01:00
Hans-Kristian Arntzen edd4c990ed vkd3d-shader: Move vkd3d_find_shader into private header.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-27 15:20:10 +01:00
Philip Rebohle 82f9f76931 vkd3d-shader: Rework SPIR-V extension enablement.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-27 10:30:34 +01:00
Philip Rebohle 7cccf5756a vkd3d-shader: Rework SPIR-V capability enablement.
We're going to need more capabilities outside the 0-63 range
going forward, so a bitmask doesn't cut it and adding extra
struct members for each capability seems excessive.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-27 10:30:34 +01:00
Hans-Kristian Arntzen b04c2361e2 vkd3d: Add test for bindless samplers.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 20:50:33 +01:00
Hans-Kristian Arntzen 687b072b16 vkd3d: Upgrade SRV bindless test to include textures.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 20:50:33 +01:00
Hans-Kristian Arntzen 7c10922aac vkd3d: Add bindless test where root parameter space is exhausted.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 20:50:33 +01:00
Hans-Kristian Arntzen abb2ef8572 vkd3d: Add test for bindless SRV buffers in SM 5.1.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 20:50:33 +01:00
Hans-Kristian Arntzen 1da8ee9f86 vkd3d: Remove obsolete FIXME for immutable samplers with register space.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 20:50:05 +01:00
Hans-Kristian Arntzen fe1d958802 vkd3d: Add static sampler to SM 5.1 register space test.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 20:50:05 +01:00
Hans-Kristian Arntzen fd33aee854 vkd3d: Don't crash if SM 6.0 is not supported in constant buffer test.
Something must have gone wrong in rebase.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 13:00:48 +01:00
Hans-Kristian Arntzen 0c241ff54f vkd3d: Fix regression with UAV counters.
Need to report back actual bindings, not 0/0.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 13:00:10 +01:00
Hans-Kristian Arntzen d638a60776 vkd3d: Add DXIL test for vertex ID.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen c534737a3f vkd3d: Add DXIL test for instance_id.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 2ef0e43dce vkd3d: Add DXIL test for eval attribute.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 827adfc5c5 vkd3d: Add DXIL test for combined ClipCull.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen aae5564f4d vkd3d: Add DXIL test for clip distance.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 965a82c22d vkd3d: Add DXIL test for rasterizer sample count.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen cf3d3bb60b vkd3d: Add DXIL test for shader_sample_position.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen d208bc7417 vkd3d: Add DXIL test for coverage.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen a898760946 vkd3d: Add DXIL test for sample mask.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 8f413b3656 vkd3d: Add DXIL test for render_target_a8.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 7ce68df015 vkd3d: Add DXIL test for face culling.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 39eb4f7270 vkd3d: Add DXIL test for dual source blending.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 7758997e30 vkd3d: Add DXIL test for constant buffers (root const/desc).
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen f003b6a84b vkd3d: Add DXIL test for register spaces.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen a43acfce16 vkd3d: Add DXIL test for bufinfo.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 4b6b7cb831 vkd3d: Add DXIL test for stream output.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 1adf73abcf vkd3d: Add DXIL test for line tessellation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 1496ea85f2 vkd3d: Add DXIL test for tess fork phase.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 71f432e000 vkd3d: Add DXIL test for tess control point phase.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 562e990c38 vkd3d: Add DXIL test for quad_tessellation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 38e9422f35 vkd3d: Add DXIL test for ps_layer.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 1ff7940739 vkd3d: Add DXIL test for layered rendering.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Hans-Kristian Arntzen 727215958a vkd3d: Add DXIL test for geometry shader.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-26 10:19:46 +01:00
Philip Rebohle 27595a8147 vkd3d-shader: Drop support for OpenGL targets.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-26 10:18:30 +01:00
Philip Rebohle c4c9fa82b0 vkd3d-shader: Drop support for combined resource samplers.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-26 10:18:30 +01:00
Philip Rebohle c3871951ad vkd3d-shader: Factor out methods to retrieve resource binding info.
Allows us to get more detailed info about any given binding.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-26 10:18:30 +01:00
Philip Rebohle 74e706cbe3 vkd3d-shader: Introduce vkd3d_shader_descriptor_type_from_register_type helper.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-26 10:18:30 +01:00
Philip Rebohle d95762db65 vkd3d-shader: Also log register space for unmapped bindings.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-26 10:18:30 +01:00
Hans-Kristian Arntzen 0d5ccda21c vkd3d: Add create_pipeline_state_dxil test utility.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-25 13:54:40 +01:00
Hans-Kristian Arntzen 8b7b37bb71 vkd3d: Add helper test function to set up a default pipeline with DXIL.
In a pipeline, it is not possible to mix and match DXIL and DXBC.
D3D12 debug layer will complain, although vkd3d does not care about
this.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-25 13:54:40 +01:00
Hans-Kristian Arntzen a7ac017bdd vkd3d: Add test helper function to determine if DXIL is supported.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-25 13:54:40 +01:00
Hans-Kristian Arntzen 7a341a4fc3 vkd3d: Add test case for root constants in SM 5.1.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-24 12:32:29 +01:00
Hans-Kristian Arntzen 70006b7129 vkd3d: Add test case for SM 5.1 register spaces.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-24 12:32:29 +01:00
Hans-Kristian Arntzen 93e4b6ff9b vkd3d: Deal correctly with SM 5.1 register spaces.
Resource index is found in idx[0] in SM 5.0, but idx[1] when using SM
5.1, and register space is encoded separately. An rb_tree keeps track of
the internal resource index idx[0] and can map that to space/binding as
required when emitting SPIR-V.

For this to work, we must also make UAV counters register space aware.
In earlier implementation, UAV counter mask was assumed to correlate 1:1
with register_index, which breaks on SM 5.1.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-24 12:32:29 +01:00
Hans-Kristian Arntzen 96925f8a70 vkd3d: Load d3d12 dynamically in d3d12 tests.
MinGW does not ship d3d12 properly, so link against d3d12.dll
dynamically instead.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-24 11:53:29 +01:00
Hans-Kristian Arntzen 00eec801de vkd3d: Load Vulkan dynamically in d3d12 test app.
On Windows, it is not ideal to rely on Vulkan being available as a
linkable library as a full install of the Vulkan SDK must be present and
set up, be friendly and load Vulkan dynamically instead.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-24 11:53:29 +01:00
Hans-Kristian Arntzen 369f6790d7 vkd3d: Support using vkd3d-utils path when testing on Windows.
When testing vkd3d on Windows, we were only able to use the native D3D12
path. Add an ifdef to configure this.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-24 11:53:29 +01:00
Hans-Kristian Arntzen 968131ca4d vkd3d: Fix MSVC build for UAV clear tests.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-24 11:53:29 +01:00
Hans-Kristian Arntzen 69ad7c91c4 vkd3d-utils: Make vkd3d-utils compilable on MSVC.
Useful to be able to run unit tests on Windows.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-24 11:53:29 +01:00
Hans-Kristian Arntzen 484ac51267 vkd3d: Add simple pthread wrapper for MSVC.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-24 11:53:29 +01:00
Andrew Eikum f548d817e5 Merge remote-tracking branch 'philip/metro-tess-fixes' into proton_5.0 2020-02-19 15:14:12 -06:00
Hans-Kristian Arntzen 89c516e5da vkd3d: Disable async compute queues for the time being.
Cannot disable VK_EXT_descriptor_indexing as we relied on internal
behavior in RADV related to global_bo_list. Implementing bindless
properly in vkd3d will solve this correctly.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-19 15:39:51 +01:00
Hans-Kristian Arntzen 022500044f vkd3d-shader: Use correct register offset.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-12 14:15:55 +01:00
Hans-Kristian Arntzen 3d20375953 vkd3d: The line tessellation test now works again.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-12 14:15:55 +01:00
Hans-Kristian Arntzen c6fd8e442a vkd3d-shader: Fix TessFactor order for isolines.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-12 14:15:55 +01:00
Hans-Kristian Arntzen 5a7ebf7630 vkd3d-shader: Deal with reading packed TessFactor in DS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-12 14:15:55 +01:00
Hans-Kristian Arntzen 796c6843df vkd3d: Add test for reading packed tesslevel in DS.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-12 14:15:55 +01:00
Hans-Kristian Arntzen 185c037f98 vkd3d-shader: Compute XfbOffset per buffer.
Fixes Hairworks GPU crash on Metro Exodus.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-12 14:15:55 +01:00
Hans-Kristian Arntzen 66e92ded64 vkd3d: Make a basic repro case for vertex input in patch constant phase.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2020-02-12 14:15:55 +01:00
Philip Rebohle 4bdec95f37 vkd3d-shader: Clean up vkd3d_dxbc_compiler_emit_shader_phase_input.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-12 14:15:55 +01:00
Philip Rebohle 934646027a vkd3d-shader: Allow hull shader join phases to read patch constants.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-12 14:15:55 +01:00
Philip Rebohle 6e4fc511f9 vkd3d-shader: Add missing lookups to vkd3d_siv_from_sysval_indexed.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-12 14:15:55 +01:00
Philip Rebohle 7c092a0640 vkd3d-shader: Don't re-declare inputs in default control point phase.
Otherwise, we delcare certain input control points twice in shaders that
access them in a fork phase, which is not allowed as per Vulkan spec:

    "Any two inputs listed as operands on the same OpEntryPoint must not
     be assigned the same location, either explicitly or implicitly"

Fixes invalid SPIR-V and resulting RADV driver crashes in Metro Exodus.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-02-12 14:15:55 +01:00
Hans-Kristian Arntzen 40e4a74c04 Allocate one large buffer for a heap and offset into it.
Greatly reduce VA allocations we have to make and makes returned VA more
sensible, and better matches returned VAs we see on native drivers.

D3D12 usage flags for buffers seem generic enough that there is no
obvious benefit to place smaller VkBuffers on top of VkDeviceMemory.

Ideally, physical_buffer_address is used here, but this works as a good
fallback if that path is added later.

With this patch and previous VA optimization, I'm observing a 2.0-2.5%
FPS uplift on SOTTR when CPU bound.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2019-12-09 07:14:17 -06:00
Andrew Eikum c6dcf61443 Update to current vkd3d master (a59f198) 2019-12-09 07:13:39 -06:00
Andrew Eikum e935026b02 Revert "vkd3d: Allocate one large buffer for a heap and offset into it."
This reverts commit a4d13f12c5.
2019-12-09 07:13:04 -06:00
Andrew Eikum 79c2a8aa52 Revert "Revert "vkd3d: Bump RootSignature version to 1.1.""
This reverts commit 91b7be72c5.
2019-12-09 07:12:57 -06:00
Andrew Eikum 91b7be72c5 Revert "vkd3d: Bump RootSignature version to 1.1."
This reverts commit c002aee119.

This commit caused a bunch of problems which are still being worked out
upstream.
2019-11-04 08:04:36 -06:00
Hans-Kristian Arntzen a4d13f12c5 vkd3d: Allocate one large buffer for a heap and offset into it.
Greatly reduce VA allocations we have to make and makes returned VA more
sensible, and better matches returned VAs we see on native drivers.

D3D12 usage flags for buffers seem generic enough that there
is no obvious benefit to place smaller VkBuffers on top of
VkDeviceMemory.

Ideally, physical_buffer_address is used here, but this works as a
good fallback if that path is added later.

With this patch and previous VA optimization, I'm observing a 2.0-2.5%
FPS uplift on SOTTR when CPU bound.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
2019-11-04 08:04:36 -06:00
208 changed files with 132381 additions and 46506 deletions

31
.github/workflows/artifacts.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Artifacts (Package)
on: [push, pull_request, workflow_dispatch]
jobs:
build-artifacts:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build release
id: build-release
uses: Joshua-Ashton/arch-mingw-github-action@v8
with:
command: |
export VERSION_NAME="${GITHUB_REF##*/}-${GITHUB_SHA##*/}"
./package-release.sh ${VERSION_NAME} build --no-package
echo "VERSION_NAME=${VERSION_NAME}" >> $GITHUB_ENV
- name: Upload artifacts
id: upload-artifacts
uses: actions/upload-artifact@v2
with:
name: vkd3d-proton-${{ env.VERSION_NAME }}
path: build/vkd3d-proton-${{ env.VERSION_NAME }}
if-no-files-found: error

75
.github/workflows/test-build-linux.yml vendored Normal file
View File

@ -0,0 +1,75 @@
name: Test Builds on Linux
on: [push, pull_request, workflow_dispatch]
jobs:
build-set-linux:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup problem matcher
uses: Joshua-Ashton/gcc-problem-matcher@v1
- name: Build MinGW x86
id: build-mingw-x86
uses: Joshua-Ashton/arch-mingw-github-action@v8
with:
command: |
meson -Denable_tests=True -Denable_extras=True --cross-file=build-win32.txt --buildtype release build-mingw-x86
ninja -C build-mingw-x86
- name: Build MinGW x64
id: build-mingw-x64
uses: Joshua-Ashton/arch-mingw-github-action@v8
with:
command: |
meson -Denable_tests=True -Denable_extras=True --cross-file=build-win64.txt --buildtype release build-mingw-x64
ninja -C build-mingw-x64
- name: Build Native GCC x86
id: build-native-gcc-x86
uses: Joshua-Ashton/arch-mingw-github-action@v8
with:
command: |
export CC="gcc -m32"
export CXX="g++ -m32"
export PKG_CONFIG_PATH="/usr/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig"
meson -Denable_tests=True -Denable_extras=True --buildtype release build-native-gcc-x86
ninja -C build-native-gcc-x86
- name: Build Native GCC x64
id: build-native-gcc-x64
uses: Joshua-Ashton/arch-mingw-github-action@v8
with:
command: |
export CC="gcc"
export CXX="g++"
meson -Denable_tests=True -Denable_extras=True --buildtype release build-native-gcc-x64
ninja -C build-native-gcc-x64
- name: Build Native Clang x86
id: build-native-clang-x86
uses: Joshua-Ashton/arch-mingw-github-action@v8
with:
command: |
export CC="clang -m32"
export CXX="clang++ -m32"
export PKG_CONFIG_PATH="/usr/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig"
meson -Denable_tests=True -Denable_extras=True --buildtype release build-native-clang-x86
ninja -C build-native-clang-x86
- name: Build Native Clang x64
id: build-native-clang-x64
uses: Joshua-Ashton/arch-mingw-github-action@v8
with:
command: |
export CC="clang"
export CXX="clang++"
meson -Denable_tests=True -Denable_extras=True --buildtype release build-native-clang-x64
ninja -C build-native-clang-x64

View File

@ -0,0 +1,53 @@
name: Test Builds on Windows
on: [push, pull_request, workflow_dispatch]
jobs:
build-set-windows:
runs-on: windows-2022
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup widl and glslangValidator
shell: pwsh
run: |
choco install strawberryperl vulkan-sdk -y
Write-Output "C:\Strawberry\c\bin" | Out-File -FilePath "${Env:GITHUB_PATH}" -Append
Write-Output "$([System.Environment]::GetEnvironmentVariable('VULKAN_SDK', 'Machine'))\Bin" `
| Out-File -FilePath "${Env:GITHUB_PATH}" -Append
- name: Setup Meson
shell: pwsh
run: pip install meson
- name: Find Visual Studio
shell: pwsh
run: |
$installationPath = Get-VSSetupInstance `
| Select-VSSetupInstance -Require Microsoft.VisualStudio.Workload.NativeDesktop -Latest `
| Select-Object -ExpandProperty InstallationPath
Write-Output "VSDEVCMD=${installationPath}\Common7\Tools\VsDevCmd.bat" `
| Out-File -FilePath "${Env:GITHUB_ENV}" -Append
- name: Build MSVC x86
shell: pwsh
run: |
& "${Env:COMSPEC}" /s /c "`"${Env:VSDEVCMD}`" -arch=x86 -host_arch=x64 -no_logo && set" `
| % { , ($_ -Split '=', 2) } `
| % { [System.Environment]::SetEnvironmentVariable($_[0], $_[1]) }
meson -Denable_tests=True -Denable_extras=True --buildtype release --backend vs2022 build-msvc-x86
msbuild -m build-msvc-x86/vkd3d-proton.sln
- name: Build MSVC x64
shell: pwsh
run: |
& "${Env:COMSPEC}" /s /c "`"${Env:VSDEVCMD}`" -arch=x64 -host_arch=x64 -no_logo && set" `
| % { , ($_ -Split '=', 2) } `
| % { [System.Environment]::SetEnvironmentVariable($_[0], $_[1]) }
meson -Denable_tests=True -Denable_extras=True --buildtype release --backend vs2022 build-msvc-x64
msbuild -m build-msvc-x64/vkd3d-proton.sln

28
.gitignore vendored
View File

@ -1,25 +1,5 @@
aclocal.m4
autom4te.cache
config.log
config.status
configure
libtool
Makefile
Makefile.in
test-suite.log
vkd3d-compiler
build
build.*
vkd3d-proton-*.tar.zst
vkd3d-proton-*/
vkd3d-*.tar.xz
*.exe
*.la
*.lo
*.log
*.o
*.pc
*.trs
*~
.deps
.dirstamp
.libs

9
.gitmodules vendored Normal file
View File

@ -0,0 +1,9 @@
[submodule "subprojects/dxil-spirv"]
path = subprojects/dxil-spirv
url = https://github.com/HansKristian-Work/dxil-spirv
[submodule "subprojects/Vulkan-Headers"]
path = subprojects/Vulkan-Headers
url = https://github.com/KhronosGroup/Vulkan-Headers
[submodule "subprojects/SPIRV-Headers"]
path = subprojects/SPIRV-Headers
url = https://github.com/KhronosGroup/SPIRV-Headers

4
.mailmap Normal file
View File

@ -0,0 +1,4 @@
Conor McCarthy <cmccarthy@codeweavers.com>
Ivan Fedorov <ifedorov@nvidia.com>
James Beddek <telans@protonmail.com>
Roshan Chaudhari <rochaudhari@nvidia.com>

View File

@ -1,85 +0,0 @@
The Wine team is proud to announce that release 1.1 of vkd3d, the
Direct3D 12 to Vulkan translation library, is now available.
This release contains improvements that are listed in the release notes below.
The main highlights are:
- Initial support for placed resources.
- MoltenVK support.
- Support for geometry shaders.
The source is available from the following location:
https://dl.winehq.org/vkd3d/source/vkd3d-1.1.tar.xz
The current source can also be pulled directly from the git repository:
https://source.winehq.org/git/vkd3d.git/
Vkd3d is available thanks to the work of multiple people. See the file AUTHORS
for the complete list.
----------------------------------------------------------------
What's new in vkd3d 1.1
=======================
*** libvkd3d
- Initial support for memory heaps and placed resources.
- Improved support for resource views.
- ClearUnorderedAccessViewUint() is implemented for textures.
- Blend factor is implemented.
- Performance improvements.
- A new interface is available for enabling additional Vulkan instance
extensions.
- A new public function is available for mapping VkFormats to DXGI_FORMATs.
- Support for more DXGI formats.
- Various bug fixes.
*** libvkd3d-shader
- Support for geometry shaders.
- Pretty printing is implemented for shader code extracted from DXBC.
- Clip and cull distances are supported.
- Support for more shader instructions:
- round_ne,
- sincos,
- ineg,
- continue,
- continuec,
- gather4_po,
- gather4_po_c,
- gather4_c.
- Texel offsets are supported.
- Various shader translation fixes.
*** libvkd3d-utils
- Vulkan WSI extensions are detected at runtime.
*** build
- Demos are not built by default.
- libxcb is now an optional dependency required only for demos.
- MoltenVK is supported.

30
AUTHORS
View File

@ -1,4 +1,34 @@
Alexander Gabello
Alexandre Julliard
Andrew Eikum
Arkadiusz Hiler
Biswapriyo Nath
Chip Davis
Conor McCarthy
Danylo Piliaiev
David Gow
David McCloskey
Derek Lesho
Fabian Bornschein
Georg Lehmann
Hans-Kristian Arntzen
Henri Verbeet
Ivan Fedorov
Jactry Zeng
James Beddek
Jens Peters
Joshua Ashton
Józef Kucia
Juuso Alasuutari
Krzysztof Bogacki
Paul Gofman
Philip Rebohle
Rémi Bernon
Robin Kertels
Rodrigo Locatti
Roshan Chaudhari
Samuel Pitoiset
Sveinar Søpler
Sven Hesse
Thomas Crider
Zhiyi Zhang

388
CHANGELOG.md Normal file
View File

@ -0,0 +1,388 @@
# Change Log
## 2.6
It has been a long while since 2.5, and this release rolls up a lot of fixes, features and optimizations.
### Fixes
- Fix black screen rendering bug in Horizon Zero Dawn after latest game updates.
- Fix crashes on startup in Final Fantasy VII: Remake and Warframe.
- Fix crashes in Guardians of the Galaxy when interacting with certain game objects.
- Fix hang on game shutdown in Elden Ring.
- Fix broken geometry rendering in Age of Empires: IV.
### Optimization
- Improve generated shader code for vectorized load-store operations in DXIL.
- Greatly reduce CPU overhead for descriptor copy operations,
which is a key contributor to CPU overhead in D3D12.
### Features
#### Pipeline library rewrite
Support D3D12 pipeline libraries better where we can now also cache
generated SPIR-V from DXBC/DXIL.
Massively reduces subsequent load times in Monster Hunter: Rise,
and helps other titles like Guardian of the Galaxy and Elden Ring.
Also lays the groundwork for internal driver caches down the line for games which do not use this API.
Also, deduplicates binary blobs for reduced disk size requirements.
#### Shader models
Shader model 6.6 is now fully implemented. This includes support for:
- ResourceDescriptorHeap[] direct access
- 64-bit atomics
- IsHelperLane()
- Compute shader derivatives
- WaveSize attribute
- Packed math intrinsics
#### Minor features
- Handle API feature MinResourceLODClamp correctly if `VK_EXT_image_view_min_lod` is supported.
- Expose CastFullyTypedFormat feature.
- Expose some advanced shader features on Intel related to UAV formats (`VK_KHR_format_feature_flags2`).
- Support COLOR -> STENCIL copies.
### Workarounds
- Workaround DEATHLOOP not emitting synchronization commands correctly. Fixes menu flicker on RADV.
- Workaround quirky API usage in Elden Ring. Removes many kinds of stutter and chug when traversing the scenery.
- Workaround certain environments failing to create Vulkan device if some `VK_NVX_*` extensions are enabled.
- Workaround glitched foliage rendering in Horizon Zero Dawn after latest game updates.
- Workaround some questionable UE4 shaders causing glitched rendering on RADV.
### Note on future Vulkan driver requirements
2.6 is expected to be the last vkd3d-proton release before we require some newer Vulkan extensions.
`VK_KHR_dynamic_rendering` and `VK_EXT_extended_dynamic_state`
(and likely `dynamic_state_2` as well) will be required.
`VK_KHR_dynamic_rendering` in particular requires up-to-date drivers and the legacy render pass path
will be abandoned in favor of it. Supporting both paths at the same time is not practical.
Moving to `VK_KHR_dynamic_rendering` allows us to fix some critical flaws with the legacy API
which caused potential shader compilation stutters and extra CPU overhead.
## 2.5
This is a release with a little bit of everything!
### Features
#### DXR progress
DXR has seen significant work in the background.
- DXR 1.1 is now experimentally exposed. It can be enabled with `VKD3D_CONFIG=dxr11`.
Note that DXR 1.1 cannot be fully implemented in `VK_KHR_ray_tracing`'s current form, in particular
DispatchRays() indirect is not compatible yet,
although we have not observed a game which requires this API feature.
- DXR 1.1 inline raytracing support is fully implemented.
- DXR 1.0 support is more or less feature complete.
Some weird edge cases remain, but will likely not be implemented unless required by a game.
`VKD3D_CONFIG=dxr` will eventually be dropped when it matures.
Some new DXR games are starting to come alive, especially with DXR 1.1 enabled,
but there are significant bugs as well that we currently cannot easily debug.
Some experimental results on NVIDIA:
- **Control** - already worked
- **DEATHLOOP** - appears to work correctly
- **Cyberpunk 2077** - DXR can be enabled, but GPU timeouts
- **World of Warcraft** - according to a user, it works, but we have not confirmed ourselves
- **Metro Exodus: Enhanced Edition** -
gets ingame and appears to work? Not sure if it looks correct.
Heavy CPU stutter for some reason ...
- **Metro Exodus** (original release) - GPU timeouts when enabling DXR
- **Resident Evil: Village** - Appears to work, but the visual difference is subtle.
It's worth experimenting with these and others.
DXR is incredibly complicated, so expect bugs.
From here, DXR support is mostly a case of stamping out issues one by one.
#### NVIDIA DLSS
NVIDIA contributed integration APIs in vkd3d-proton which enables DLSS support in D3D12 titles in Proton.
See Proton documentation for how to enable NvAPI support.
#### Shader models
A fair bit of work went into DXIL translation support to catch up with native drivers.
- Shader model 6.5 is exposed.
Shader model 6.6 should be straight forward once that becomes relevant.
- Shader model 6.4 implementation takes advantage of `VK_KHR_shader_integer_dot_product` when supported.
- Proper fallback for FP16 math on GPUs which do not expose native FP16 support (Polaris, Pascal).
Notably fixes AMD FSR shaders in Resident Evil: Village (and others).
- Shader model 6.1 SV_Barycentric support implemented (NVIDIA only for now).
- Support shader model 6.2 FP32 denorm control.
### Performance
Resizable BAR can improve GPU performance about 10-15% in the best case, depends a lot on the game.
Horizon Zero Dawn and Death Stranding in particular improve massively with this change.
By default, vkd3d-proton will now take advantage of PCI-e BAR memory types through heuristics
as D3D12 does not expose direct support for resizable BAR, and native D3D12 drivers are known to use heuristics as well.
Without resizable BAR enabled in BIOS/vBIOS, we only get 256 MiB which can help performance,
but many games will improve performance even more
when we are allowed to use more than that.
There is an upper limit for how much VRAM is dedicated to this purpose.
We also added `VKD3D_CONFIG=no_upload_hvv` to disable all uses of PCI-e BAR memory.
Other performance improvements:
- Avoid redundant descriptor update work in certain scenarios (NVIDIA contribution).
- Minor tweaks here and there to reduce CPU overhead.
### Fixes and workarounds
- Fix behavior for swap chain presentation latency HANDLE. Fixes spurious deadlocks in some cases.
- Fix many issues related to depth-stencil handling, which fixed various issues in DEATHLOOP, F1 2021, WRC 10.
- Fix DIRT 5 rendering issues and crashes. Should be fully playable now.
- Fix some Diablo II Resurrected rendering issues.
- Workaround shader bugs in Psychonauts 2.
- Workaround some Unreal Engine 4 shader bugs which multiple titles trigger.
- Fix some stability issues when VRAM is exhausted on NVIDIA.
- Fix CPU crash in boot-up sequence of Far Cry 6 (game is still kinda buggy though, but gets in-game).
- Fix various bugs with host visible images. Fixes DEATHLOOP.
- Fix various DXIL conversion bugs.
- Add Invariant geometry workarounds for specific games which require it.
- Fix how d3d12.dll exports symbols to be more in line with MSVC.
- Fix some edge cases in bitfield instructions.
- Work around extreme CPU memory bloat on the specific NVIDIA driver versions which had this bug.
- Fix regression in Evil Genius 2: World Domination.
- Fix crashes in Hitman 3.
- Fix terrain rendering in Anno 1800.
- Various correctness and crash fixes.
## 2.4
This is a release which focuses on performance and bug-fixes.
### Performance
- Improve swapchain latency and frame pacing by up to one frame.
- Optimize lookup of format info.
- Avoid potential pipeline compilation stutter in certain scenarios.
- Rewrite how we handle image layouts for color and depth-stencil targets.
Allows us to remove a lot of dumb
barriers giving significant GPU-bound performance improvements.
~15%-20% GPU bound uplift in Horizon Zero Dawn,
~10% in Death Stranding,
and 5%-10% improvements in many other titles.
### Features
- Enable support for sparse 3D textures (tiled resources tier 3).
### Bug fixes and workarounds
- Various bug fixes in DXIL.
- Fix weird bug where sun would pop through walls in RE: Village.
- Workaround game bug in Cyberpunk 2077 where certain locales would render a black screen.
- Fix various bugs (in benchmark and in vkd3d-proton) allowing GravityMark to run.
- Improve robustness against certain app bugs related to NULL descriptors.
- Fix bug with constant FP64 vector handling in DXBC.
- Fix bug where Cyberpunk 2077 inventory screen could spuriously hang GPU on RADV.
- Add workaround for Necromunda: Hired Gun where character models would render random garbage on RADV.
- Fix bug in Necromunda: Hired Gun causing random screen flicker.
- Fix windowed mode tracking when leaving fullscreen. Fix Alt-Tab handling in Horizon Zero Dawn.
- Temporary workaround for SRV ResourceMinLODClamp. Fix black ground rendering in DIRT 5.
The overbright HDR rendering in DIRT 5 sadly persists however :(
- Implement fallback maximum swapchain latency correctly.
### Development features
Various features which are useful for developers were added to aid debugging.
- Descriptor QA can instrument shaders in runtime for GPU-assisted validation.
Performance is good enough (> 40 FPS) that games are actually playable in this mode.
See README for details.
- Allow forcing off CONCURRENT queue, and using EXCLUSIVE queue.
Not valid, but can be useful as a speed hack on Polaris when `single_queue` is not an option
and for testing driver behavior differences.
## 2.3.1
This is a minor bugfix release to address some issues solved shortly after the last release.
### Fixes
- Improved support for older Wine and Vulkan Loader versions.
- Fix blocky shadows in Horizon Zero Dawn.
- Fix the install script failing on Wine installs not built with upstream vkd3d.
- Fix minor dxil translation issues.
## 2.3
This release adds support for more D3D12 features and greatly improves GPU bound performance
in many scenarios.
### Features
#### Early DXR 1.0 support
`VK_KHR_raytracing` is used to enable cross-vendor ray-tracing support.
The implementation is WIP, but it is good enough to run some real content.
As of writing, only the NVIDIA driver works correctly.
It is expected AMD RDNA2 GPUs will work when working drivers are available
(amdgpu-pro 21.10 is known to not work).
Games which are expected to work include:
- Control (appears to be fully working)
- Ghostrunner (seems to work, not exhaustively tested)
To enable DXR support, `VKD3D_CONFIG=dxr %command%` should be used when launching game.
Certain games may be unstable if DXR is enabled by default.
#### Conservative rasterization
Full support (tier 3) for conservative rasterization was added.
#### Variable rate shading
Full support (tier 2) for variable rate shading was added.
#### Command list bundles
Allows Kingdom Hearts remaster to get past the errors, unsure if game fully works yet.
#### Write Watch and APITrace
Support for `D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH` has been added.
This means [APITraces](https://github.com/Joshua-Ashton/apitrace/releases) of titles can now be captured.
### Performance
- Improve GPU bound performance in RE2 by up to 20% on NVIDIA.
- Enable async compute queues. Greatly improves GPU performance and frame pacing in many titles.
Horizon Zero Dawn and Death Stranding see exceptional gains with this fix,
due to how the engines work. GPU utilization should now reach ~100%.
For best results, AMD Navi+ GPUs are recommended, but Polaris and earlier still
see great results. It is possible to disable this path, if for whatever reason
multiple queues are causing issues. See README.
- Optimize bindless constant buffer GPU-bound performance on NVIDIA if certain API code paths are used.
- Optimize sparse binding CPU overhead.
- `TRACE` logging calls are disabled by default on release builds.
### Fixes and workarounds
- Fix various DXIL bugs.
- Be more robust against broken pipeline creation API calls.
Avoids driver crashes in Forza Horizon 4.
- Workaround some buggy shaders in F1 2020.
- Fix bugs if depth bounds test is used in certain ways.
- Fix a read out-of-bounds in `UpdateTileMappings`.
- Fix `SV_ClipDistance` and `SV_CullDistance` in Hull Shaders.
## 2.2
This release is mostly a maintenance release which fixes bugs and regressions.
It also unblocks significant future feature development.
### Workaround removals
- Replace old `force_bindless_texel_buffer` workaround with
a more correct and performant implementation.
Death Stranding and Cyberpunk 2077 (and probably other games as well) do the right thing by default without the hack now.
- Remove old workaround `disable_query_optimization` for occlusion queries which was enabled for AC: Valhalla,
and is now replaced by a correct and efficient implementation.
#### Cyberpunk 2077 status
From recent testing on our end, it is unknown at this time if `VK_VALVE_mutable_descriptor_type` is still required for
Cyberpunk 2077. Manual testing hasn't been able to trigger a GPU hang.
The memory allocation rewrite in 2.2 can plausibly work around some of the bugs that `VK_VALVE_mutable_descriptor_type` fixed by accident.
The bugs in question could also have been fixed since release day, but we cannot prove this since the bug is completely random in nature.
### Regression fixes
- Fix regression in Horizon Zero Dawn for screen space reflections on water surfaces.
### Stability fixes
- Greatly improve stability on Polaris or older cards for certain titles.
Crashes which used to happen in Horizon Zero Dawn and Death Stranding seem to have disappeared
after the memory allocation rewrite.
GPU memory usage should decrease on these cards as well.
- DIRT 5 can get in-game now due to DXIL fixes, but is not yet playable.
### New features
- Add support for Variable Rate Shading tier 1.
### Future development
DXR is not yet supported, but has seen a fair bit of background work.
- Basic DXR pipelines can be created successfully.
- Memory allocation rewrite in 2.2 unblocks further DXR development.
## 2.1
This release fixes various bugs (mostly workarounds) and improves GPU-bound performance.
New games added to "expected to work" list:
- The Division (was working already in 2.0, but missing from list)
- AC: Valhalla (*)
(*): Game requires full D3D12 sparse texture support to work.
Currently only works on NVIDIA drivers.
RADV status remains unknown until support for this feature lands in Mesa.
New games added to "kinda works, but expect a lot of jank" list:
- Cyberpunk 2077 (**)
(**): Currently only runs correctly on AMD hardware with RADV and `VK_VALVE_mutable_descriptor_type`.
As of game version 1.03, this requires the latest Mesa Git build.
The game has some fatal bugs where it relies on undefined behavior with descriptor management
which this extension works around by accident.
The game will start and run on NVIDIA, but just like what happens without the extension on AMD,
the GPU will randomly hang, making the game effectively unplayable.
A game update to fix this bug would likely make the game playable on NVIDIA as well.
Game version 1.04 changed some behavior, and support for this game will likely fluctuate over time as future patches come in.
Bug fixes and workarounds:
- Fix various implementation bugs which caused AC: Valhalla to not work.
- Work around game bug in Death Stranding where accessing map could cause corrupt rendering.
(Several games appear to have the same kind of application bug.)
- Fix corrupt textures in Horizon Zero Dawn benchmark.
- Fix SM 6.0 wave-op detection for Horizon Zero Dawn and DIRT 5.
- Work around GPU hangs in certain situations where games do not use D3D12 correctly,
but native D3D12 drivers just render wrong results rather than hang the system.
- Fix invalid SPIR-V generated by FP64 code.
- Fix crash with minimized windows in certain cases.
Performance:
- ~15% GPU-bound uplift in Ghostrunner. Might help UE4 titles in general.
- Slightly improve GPU bound performance when fully GPU bound on both AMD and NVIDIA.
- Slightly improve GPU bound performance on RADV in various titles.
- Reduce multi-threaded CPU overhead for certain D3D12 API usage patterns.
- Add support for `VK_VALVE_mutable_descriptor_type` which
improves CPU overhead, memory bloat, and avoids potential memory management thrashing on RADV.
Also avoids GPU hangs in certain situations where games misuse the D3D12 API.
Misc:
- Implement `DXGI_PRESENT_TEST`.
- Fix log spam when `DXGI_PRESENT_ALLOW_TEARING` is used.
## 2.0
This initial release supports D3D12 Feature Level 12.0 and Shader Model 6.0 (DXIL).
Games expected to work include:
- Control
- Death Stranding
- Devil May Cry 5
- Ghostrunner
- Horizon Zero Dawn
- Metro Exodus
- Monster Hunter World
- Resident Evil 2 / 3
Please refer to the README for supported driver versions.

View File

@ -1,7 +1,7 @@
Copyright 2016-2019 the Vkd3d project authors (see the file AUTHORS for a
Copyright 2016-2022 the vkd3d-proton project authors (see the file AUTHORS for a
complete list)
Vkd3d is free software; you can redistribute it and/or modify it under
vkd3d-proton 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.

370
INSTALL
View File

@ -1,370 +0,0 @@
Installation Instructions
*************************
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without warranty of any kind.
Basic Installation
==================
Briefly, the shell command `./configure && make && make install'
should configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX `make' updates targets which have the same time stamps as
their prerequisites, which makes it generally unusable when shipped
generated files such as `configure' are involved. Use GNU `make'
instead.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf limitation. Until the limitation is lifted, you can use
this workaround:
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@ -1,276 +0,0 @@
ACLOCAL_AMFLAGS = -I m4
AM_CFLAGS = @VKD3D_CFLAGS@
AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/dummy -I$(srcdir)/include/private
AM_LDFLAGS = -no-undefined
widl_headers = \
include/vkd3d_d3d12.h \
include/vkd3d_d3d12sdklayers.h \
include/vkd3d_d3dcommon.h \
include/vkd3d_dxgi.h \
include/vkd3d_dxgi1_2.h \
include/vkd3d_dxgi1_3.h \
include/vkd3d_dxgi1_4.h \
include/vkd3d_dxgibase.h \
include/vkd3d_dxgiformat.h \
include/vkd3d_dxgitype.h
vkd3d_public_headers = \
include/vkd3d.h \
include/vkd3d_d3d12.h \
include/vkd3d_d3d12sdklayers.h \
include/vkd3d_d3dcommon.h \
include/vkd3d_dxgibase.h \
include/vkd3d_dxgiformat.h \
include/vkd3d_shader.h \
include/vkd3d_types.h \
include/vkd3d_utils.h \
include/vkd3d_windows.h
vkd3d_demos_shaders = \
demos/gears.hlsl \
demos/gears_ps_flat.h \
demos/gears_ps_smooth.h \
demos/gears_vs.h \
demos/triangle.hlsl \
demos/triangle_ps.h \
demos/triangle_vs.h
vkd3d_tests = \
tests/vkd3d_api \
tests/vkd3d_common \
tests/vkd3d_shader_api
vkd3d_cross_tests = \
tests/d3d12 \
tests/d3d12_invalid_usage
vkd3d_test_headers = \
tests/d3d12_crosstest.h \
tests/d3d12_test_utils.h
vkd3d_demos = \
demos/gears \
demos/triangle
vkd3d_demos_headers = \
demos/demo.h \
demos/demo_win32.h \
demos/demo_xcb.h
BUILT_SOURCES = $(widl_headers)
noinst_LTLIBRARIES = libvkd3d-common.la
libvkd3d_common_la_SOURCES = \
include/private/vkd3d_debug.h \
libs/vkd3d-common/debug.c \
libs/vkd3d-common/memory.c \
libs/vkd3d-common/utf8.c
lib_LTLIBRARIES = libvkd3d-shader.la libvkd3d.la libvkd3d-utils.la
libvkd3d_shader_la_SOURCES = \
include/private/list.h \
include/private/rbtree.h \
include/private/vkd3d_common.h \
include/private/vkd3d_debug.h \
include/private/vkd3d_memory.h \
include/vkd3d_shader.h \
libs/vkd3d-shader/checksum.c \
libs/vkd3d-shader/dxbc.c \
libs/vkd3d-shader/spirv.c \
libs/vkd3d-shader/trace.c \
libs/vkd3d-shader/vkd3d_shader.map \
libs/vkd3d-shader/vkd3d_shader_main.c \
libs/vkd3d-shader/vkd3d_shader_private.h
libvkd3d_shader_la_CFLAGS = $(AM_CFLAGS) @SPIRV_TOOLS_CFLAGS@
libvkd3d_shader_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0
libvkd3d_shader_la_LIBADD = libvkd3d-common.la @SPIRV_TOOLS_LIBS@
if HAVE_LD_VERSION_SCRIPT
libvkd3d_shader_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d-shader/vkd3d_shader.map
EXTRA_libvkd3d_shader_la_DEPENDENCIES = $(srcdir)/libs/vkd3d-shader/vkd3d_shader.map
endif
libvkd3d_la_SOURCES = \
include/private/vkd3d_common.h \
include/private/vkd3d_debug.h \
include/private/vkd3d_memory.h \
include/private/vkd3d_utf8.h \
include/private/vkd3d_test.h \
include/vkd3d_d3d12.idl \
include/vkd3d_d3dcommon.idl \
include/vkd3d_unknown.idl \
libs/vkd3d/command.c \
libs/vkd3d/device.c \
libs/vkd3d/resource.c \
libs/vkd3d/state.c \
libs/vkd3d/utils.c \
libs/vkd3d/vkd3d.map \
libs/vkd3d/vkd3d_main.c \
libs/vkd3d/vkd3d_private.h \
libs/vkd3d/vkd3d_shaders.h \
libs/vkd3d/vulkan_procs.h \
libs/vkd3d_version.c
libvkd3d_la_LDFLAGS = $(AM_LDFLAGS) -version-info 2:0:1
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
EXTRA_libvkd3d_la_DEPENDENCIES = $(srcdir)/libs/vkd3d/vkd3d.map
endif
libvkd3d_utils_la_SOURCES = \
libs/vkd3d-utils/vkd3d_utils.map \
libs/vkd3d-utils/vkd3d_utils_main.c \
libs/vkd3d-utils/vkd3d_utils_private.h
libvkd3d_utils_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:1:0
libvkd3d_utils_la_LIBADD = libvkd3d-common.la libvkd3d.la
if HAVE_LD_VERSION_SCRIPT
libvkd3d_utils_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d-utils/vkd3d_utils.map
EXTRA_libvkd3d_utils_la_DEPENDENCIES = $(srcdir)/libs/vkd3d-utils/vkd3d_utils.map
endif
EXTRA_DIST = LICENSE
pkgconfigdir = $(libdir)/pkgconfig
pkginclude_HEADERS = $(vkd3d_public_headers)
nodist_pkgconfig_DATA = libvkd3d.pc libvkd3d-shader.pc libvkd3d-utils.pc
CLEANFILES = libvkd3d.pc libvkd3d-shader.pc libvkd3d-utils.pc
EXTRA_DIST += \
libs/vkd3d/libvkd3d.pc.in \
libs/vkd3d-shader/libvkd3d-shader.pc.in \
libs/vkd3d-utils/libvkd3d-utils.pc.in
noinst_PROGRAMS = vkd3d-compiler
vkd3d_compiler_SOURCES = programs/vkd3d-compiler/main.c
vkd3d_compiler_LDADD = libvkd3d-shader.la
LDADD = libvkd3d.la libvkd3d-utils.la
AM_DEFAULT_SOURCE_EXT = .c
if BUILD_TESTS
check_PROGRAMS = $(vkd3d_tests) $(vkd3d_cross_tests)
TESTS = $(vkd3d_tests) $(vkd3d_cross_tests)
tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @VULKAN_LIBS@
tests_d3d12_invalid_usage_LDADD = $(LDADD) @VULKAN_LIBS@
tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la
endif
if BUILD_DEMOS
DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @XCB_LIBS@ @VULKAN_LIBS@
DEMOS_CFLAGS = $(AM_CFLAGS) @XCB_CFLAGS@
noinst_PROGRAMS += $(vkd3d_demos)
demos_gears_CFLAGS = $(DEMOS_CFLAGS)
demos_gears_LDADD = $(DEMOS_LDADD) -lm
demos_triangle_CFLAGS = $(DEMOS_CFLAGS)
demos_triangle_LDADD = $(DEMOS_LDADD)
endif
EXTRA_DIST += $(vkd3d_test_headers) $(vkd3d_demos_headers)
VKD3D_V_WIDL = $(vkd3d_v_widl_@AM_V@)
vkd3d_v_widl_ = $(vkd3d_v_widl_@AM_DEFAULT_V@)
vkd3d_v_widl_0 = @echo " WIDL " $@;
vkd3d_v_widl_1 =
EXTRA_DIST += $(widl_headers) $(widl_headers:.h=.idl)
$(widl_headers): %.h: %.idl
if HAVE_WIDL
$(VKD3D_V_WIDL)$(WIDL) -h -o $@ $<
else
@echo "widl is required to generate $@"
endif
EXTRA_DIST += $(vkd3d_demos_shaders)
libvkd3d-utils.pc: $(srcdir)/libs/vkd3d-utils/libvkd3d-utils.pc.in Makefile
$(AM_V_GEN)$(SED) -e 's![@]prefix[@]!$(prefix)!g' \
-e 's![@]exec_prefix[@]!$(exec_prefix)!g' \
-e 's![@]includedir[@]!$(includedir)!g' \
-e 's![@]libdir[@]!$(libdir)!g' \
-e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \
$< > $@
libvkd3d-shader.pc: $(srcdir)/libs/vkd3d-shader/libvkd3d-shader.pc.in Makefile
$(AM_V_GEN)$(SED) -e 's![@]prefix[@]!$(prefix)!g' \
-e 's![@]exec_prefix[@]!$(exec_prefix)!g' \
-e 's![@]includedir[@]!$(includedir)!g' \
-e 's![@]libdir[@]!$(libdir)!g' \
-e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \
$< > $@
libvkd3d.pc: $(srcdir)/libs/vkd3d/libvkd3d.pc.in Makefile
$(AM_V_GEN)$(SED) -e 's![@]prefix[@]!$(prefix)!g' \
-e 's![@]exec_prefix[@]!$(exec_prefix)!g' \
-e 's![@]includedir[@]!$(includedir)!g' \
-e 's![@]libdir[@]!$(libdir)!g' \
-e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \
$< > $@
libs/vkd3d_version.c: dummy-vkd3d-version
$(AM_V_GEN)version=`(GIT_DIR=$(top_srcdir)/.git git describe HEAD 2>/dev/null || echo "vkd3d-$(PACKAGE_VERSION)") | $(SED) -n -e '$$s/\(.*\)/const char vkd3d_build[] = "\1";/p'` && (echo $$version | cmp -s - $@) || echo $$version >$@ || ($(RM) $@ && exit 1)
.SILENT: libs/vkd3d_version.c
CLEANFILES += libs/vkd3d_version.c
.PHONY: dummy-vkd3d-version
dummy-vkd3d-version:
## Cross-compile tests
cross_implibs = crosslibs/d3d12
CROSS_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include
CROSS_CFLAGS = -g -O2 -Wall -municode ${CROSS_CPPFLAGS}
EXTRA_DIST += $(cross_implibs:=.cross32.def) $(cross_implibs:=.cross64.def)
if HAVE_CROSSTARGET32
CROSS32_CC = @CROSSCC32@
CROSS32_DLLTOOL = @CROSSTARGET32@-dlltool
CROSS32_IMPLIBS = $(cross_implibs:=.cross32.a)
CROSS32_EXEFILES = $(vkd3d_cross_tests:=.cross32.exe) $(vkd3d_demos:=.cross32.exe)
CROSS32_FILES = $(CROSS32_IMPLIBS) $(CROSS32_EXEFILES)
CLEANFILES += $(CROSS32_FILES)
crosstest32: $(CROSS32_FILES)
-include tests/$(DEPDIR)/*.cross32.Po
-include demos/$(DEPDIR)/*.cross32.Po
$(CROSS32_IMPLIBS): %.cross32.a: %.cross32.def
@${MKDIR_P} crosslibs
$(AM_V_GEN)$(CROSS32_DLLTOOL) -k -m i386 --as-flags=-32 -d $< -l $@
$(CROSS32_EXEFILES): %.cross32.exe: %.c $(CROSS32_IMPLIBS) $(widl_headers)
$(AM_V_CCLD)depbase=`echo $@ | $(SED) 's![^/]*$$!$(DEPDIR)/&!;s!\.exe$$!!'`; \
$(CROSS32_CC) $(CROSS_CFLAGS) -MT $@ -MD -MP -MF $$depbase.Tpo -o $@ $< $(CROSS32_IMPLIBS) -ldxgi -lgdi32 && \
$(am__mv) $$depbase.Tpo $$depbase.Po
else
crosstest32:
endif
if HAVE_CROSSTARGET64
CROSS64_CC = @CROSSCC64@
CROSS64_DLLTOOL = @CROSSTARGET64@-dlltool
CROSS64_IMPLIBS = $(cross_implibs:=.cross64.a)
CROSS64_EXEFILES = $(vkd3d_cross_tests:=.cross64.exe) $(vkd3d_demos:=.cross64.exe)
CROSS64_FILES = $(CROSS64_IMPLIBS) $(CROSS64_EXEFILES)
CLEANFILES += $(CROSS64_FILES)
crosstest64: $(CROSS64_FILES)
-include tests/$(DEPDIR)/*.cross64.Po
-include demos/$(DEPDIR)/*.cross64.Po
$(CROSS64_IMPLIBS): %.cross64.a: %.cross64.def
@${MKDIR_P} crosslibs
$(AM_V_GEN)$(CROSS64_DLLTOOL) -k -m i386:x86-64 --as-flags=-64 -d $< -l $@
$(CROSS64_EXEFILES): %.cross64.exe: %.c $(CROSS64_IMPLIBS) $(widl_headers)
$(AM_V_CCLD)depbase=`echo $@ | sed 's![^/]*$$!$(DEPDIR)/&!;s!\.exe$$!!'`; \
$(CROSS64_CC) $(CROSS_CFLAGS) -MT $@ -MD -MP -MF $$depbase.Tpo -o $@ $< $(CROSS64_IMPLIBS) -ldxgi -lgdi32 && \
$(am__mv) $$depbase.Tpo $$depbase.Po
else
crosstest64:
endif
.PHONY: crosstest crosstest32 crosstest64
crosstest: crosstest32 crosstest64

76
README
View File

@ -1,76 +0,0 @@
=============================
The vkd3d 3D Graphics Library
=============================
Vkd3d is a 3D graphics library built on top of Vulkan. It has an API very
similar, but not identical, to Direct3D 12.
==============
Building vkd3d
==============
Vkd3d depends on SPIRV-Headers and Vulkan-Headers (>= 1.1.113).
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
you are building from git, then they will be generated at build-time using
widl. By default, vkd3d will use the widl found in `PATH'. If widl is not
available or is not recent (>= 3.20), then you can build Wine with `make
tools/widl' to avoid building all of Wine. You can then point vkd3d's
configure at that widl binary with `WIDL="/path/to/widl"'.
For release builds, you may want to define NDEBUG. If you do not need debug log
messages, you may also consider VKD3D_NO_TRACE_MESSAGES and
VKD3D_NO_DEBUG_MESSAGES. For example, you can pass `CPPFLAGS="-DNDEBUG
-DVKD3D_NO_TRACE_MESSAGES"' to configure.
===========
Using vkd3d
===========
Vkd3d can be used by projects that target Direct3D 12 as a drop-in replacement
at build-time with some modest source modifications.
If vkd3d is available when building Wine, then Wine will use it to support
Direct3D 12 applications.
=====================
Environment variables
=====================
Most of the environment variables used by vkd3d are for debugging purposes. The
environment variables are not considered a part of API and might be changed or
removed in the future versions of vkd3d.
Some of debug variables are lists of elements. Elements must be separated by
commas or semicolons.
* VKD3D_CONFIG - a list of options that change the behavior of libvkd3d.
* vk_debug - enables Vulkan debug extensions.
* VKD3D_DEBUG - controls the debug level for log messages produced by
libvkd3d. Accepts the following values: none, err, fixme, warn, trace.
* VKD3D_VULKAN_DEVICE - a zero-based device index. Use to force the selected
Vulkan device.
* VKD3D_DISABLE_EXTENSIONS - a list of Vulkan extensions that libvkd3d should
not use even if available.
* VKD3D_SHADER_DEBUG - controls the debug level for log messages produced by
libvkd3d-shader. See VKD3D_DEBUG for accepted values.
* VKD3D_SHADER_DUMP_PATH - path where shader bytecode is dumped.
* VKD3D_TEST_DEBUG - enables additional debug messages in tests. Set to 0, 1
or 2.
* VKD3D_TEST_FILTER - a filter string. Only the tests whose names matches the
filter string will be run, e.g. VKD3D_TEST_FILTER=clear_render_target.
Useful for debugging or developing new tests.
* VKD3D_TEST_PLATFORM - can be set to "wine", "windows" or "other". The test
platform controls the behavior of todo(), todo_if(), bug_if() and broken()
conditions in tests.
* VKD3D_TEST_BUG - set to 0 to disable bug_if() conditions in tests.

447
README.md Normal file
View File

@ -0,0 +1,447 @@
# VKD3D-Proton
VKD3D-Proton is a fork of VKD3D, which aims to implement the full Direct3D 12 API on top of Vulkan.
The project serves as the development effort for Direct3D 12 support in [Proton](https://github.com/ValveSoftware/Proton).
## Upstream
The original project is available at [WineHQ](https://source.winehq.org/git/vkd3d.git/).
## Priorities
Performance and game compatibility are important targets, at the expense of compatibility with older drivers and systems.
Modern Vulkan extensions and features are aggressively made use of to improve game performance and compatibility.
It is recommended to use the very latest drivers you can get your hands on for the best experience.
Backwards compatibility with the vkd3d standalone API is not a goal of this project.
## Drivers
There are some hard requirements on drivers to be able to implement D3D12 in a reasonably performant way.
- Vulkan 1.1
- `VK_EXT_descriptor_indexing` with at least 1000000 UpdateAfterBind descriptors for all types except UniformBuffer.
Essentially all features in `VkPhysicalDeviceDescriptorIndexingFeatures` must be supported.
- `VK_KHR_timeline_semaphore`
- `VK_KHR_sampler_mirror_clamp_to_edge`
- `VK_EXT_robustness2`
- `VK_KHR_separate_depth_stencil_layouts`
- `VK_KHR_bind_memory2`
- `VK_KHR_copy_commands2`
- `VK_KHR_dynamic_rendering`
- `VK_EXT_extended_dynamic_state`
- `VK_EXT_extended_dynamic_state2`
Some notable extensions that **should** be supported for optimal or correct behavior.
These extensions will likely become mandatory later.
- `VK_KHR_buffer_device_address`
- `VK_EXT_image_view_min_lod`
`VK_VALVE_mutable_descriptor_type` is also highly recommended, but not mandatory.
### AMD (RADV)
For AMD, RADV is the recommended driver and the one that sees most testing on AMD GPUs.
The minimum requirement at the moment is Mesa 22.0 since it supports `VK_KHR_dynamic_rendering`.
NOTE: For older Mesa versions, use the v2.6 release.
### NVIDIA
The [Vulkan beta drivers](https://developer.nvidia.com/vulkan-driver) generally contain the latest
driver fixes that we identify while getting games to work.
The latest drivers (stable, beta or Vulkan beta tracks) are always preferred.
If you're having problems, always try the latest drivers.
### Intel
We have not done any testing against Intel iGPUs yet.
------
## Cloning the repo
To clone the repo you should run:
```
git clone --recursive https://github.com/HansKristian-Work/vkd3d-proton
```
in order to pull in all the submodules which are needed for building.
## Building VKD3D-Proton
### Requirements:
- [wine](https://www.winehq.org/) (for `widl`) [for native builds]
- On Windows this may be substituted for [Strawberry Perl](http://strawberryperl.com/) as it ships `widl` and is easy to find and install -- although this dependency may be eliminated in the future.
- [Meson](http://mesonbuild.com/) build system (at least version 0.49)
- [glslang](https://github.com/KhronosGroup/glslang) compiler
- [Mingw-w64](http://mingw-w64.org/) compiler, headers and tools (at least version 7.0) [for cross-builds for d3d12.dll which are default]
### Building:
#### The simple way
Inside the VKD3D-Proton directory, run:
```
./package-release.sh master /your/target/directory --no-package
```
This will create a folder `vkd3d-master` in `/your/target/directory`, which contains both 32-bit and 64-bit versions of VKD3D-Proton, which can be set up in the same way as the release versions as noted above.
If you want to build natively (ie. for `libvkd3d-proton.so`), pass `--native` to the build script. This option will make it build using your system's compilers.
In order to preserve the build directories for development, pass `--dev-build` to the script. This option implies `--no-package`. After making changes to the source code, you can then do the following to rebuild VKD3D-Proton:
```
# change to build.86 for 32-bit
ninja -C /your/target/directory/build.64 install
```
#### Compiling manually (cross for d3d12.dll, default)
```
# 64-bit build.
meson --cross-file build-win64.txt --buildtype release --prefix /your/vkd3d-proton/directory build.64
ninja -C build.64 install
# 32-bit build
meson --cross-file build-win32.txt --buildtype release --prefix /your/vkd3d-proton/directory build.86
ninja -C build.86 install
```
#### Compiling manually (native)
```
# 64-bit build.
meson --buildtype release --prefix /your/vkd3d-proton/directory build.64
ninja -C build.64 install
# 32-bit build
CC="gcc -m32" CXX="g++ -m32" \
PKG_CONFIG_PATH="/usr/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig" \
meson --buildtype release --prefix /your/vkd3d-proton/directory build.86
ninja -C build.86 install
```
## Using VKD3D-Proton
The intended way to use VKD3D-Proton is as a native Win32 d3d12.dll.
This serves as a drop-in replacement for D3D12, and can be used in Wine (Proton or vanilla flavors), or on Windows.
VKD3D-Proton does not supply the necessary DXGI component.
VKD3D-Proton can be used with either DXVK's DXGI implementation, or
Wine's DXGI implementation.
VKD3D-Proton implements its own IDXGISwapChain when built as a native d3d12.dll.
### A note on using VKD3D-Proton on Windows
Native Windows use is mostly relevant for developer testing purposes.
Do not expect games running on Windows 7 or 8.1 to magically make use of VKD3D-Proton,
as many games will only even attempt to load d3d12.dll if they are running on Windows 10.
### Native Linux build
A native Linux binary can be built, but it is not intended to be compatible with upstream Wine.
A native option is mostly relevant for development purposes.
## Environment variables
Most of the environment variables used by VKD3D-Proton are for debugging purposes. The
environment variables are not considered a part of API and might be changed or
removed in the future versions of VKD3D-Proton.
Some of debug variables are lists of elements. Elements must be separated by
commas or semicolons.
- `VKD3D_CONFIG` - a list of options that change the behavior of vkd3d-proton.
- `vk_debug` - enables Vulkan debug extensions and loads validation layer.
- `skip_application_workarounds` - Skips all application workarounds.
For debugging purposes.
- `dxr` - Enables DXR support if supported by device.
- `dxr11` - Enables DXR tier 1.1 support if supported by device.
- `force_static_cbv` - Unsafe speed hack on NVIDIA. May or may not give a significant performance uplift.
- `single_queue` - Do not use asynchronous compute or transfer queues.
- `no_upload_hvv` - Blocks any attempt to use host-visible VRAM (large/resizable BAR) for the UPLOAD heap.
May free up vital VRAM in certain critical situations, at cost of lower GPU performance.
A fraction of VRAM is reserved for resizable BAR allocations either way,
so it should not be a real issue even on lower VRAM cards.
- `force_host_cached` - Forces all host visible allocations to be CACHED, which greatly accelerates captures.
- `no_invariant_position` - Avoids workarounds for invariant position. The workaround is enabled by default.
- `VKD3D_DEBUG` - controls the debug level for log messages produced by
vkd3d-proton. Accepts the following values: none, err, info, fixme, warn, trace.
- `VKD3D_SHADER_DEBUG` - controls the debug level for log messages produced by
the shader compilers. See `VKD3D_DEBUG` for accepted values.
- `VKD3D_LOG_FILE` - If set, redirects `VKD3D_DEBUG` logging output to a file instead.
- `VKD3D_VULKAN_DEVICE` - a zero-based device index. Use to force the selected
Vulkan device.
- `VKD3D_FILTER_DEVICE_NAME` - skips devices that don't include this substring.
- `VKD3D_DISABLE_EXTENSIONS` - a list of Vulkan extensions that vkd3d-proton should
not use even if available.
- `VKD3D_TEST_DEBUG` - enables additional debug messages in tests. Set to 0, 1
or 2.
- `VKD3D_TEST_FILTER` - a filter string. Only the tests whose names matches the
filter string will be run, e.g. `VKD3D_TEST_FILTER=clear_render_target`.
Useful for debugging or developing new tests.
- `VKD3D_TEST_EXCLUDE` - excludes tests of which the name is included in the string,
e.g. `VKD3D_TEST_EXCLUDE=test_root_signature_priority,test_conservative_rasterization_dxil`.
- `VKD3D_TEST_PLATFORM` - can be set to "wine", "windows" or "other". The test
platform controls the behavior of todo(), todo_if(), bug_if() and broken()
conditions in tests.
- `VKD3D_TEST_BUG` - set to 0 to disable bug_if() conditions in tests.
- `VKD3D_PROFILE_PATH` - If profiling is enabled in the build, a profiling block is
emitted to `${VKD3D_PROFILE_PATH}.${pid}`.
## Shader cache
By default, vkd3d-proton manages its own driver cache.
This cache is intended to cache DXBC/DXIL -> SPIR-V conversion.
This reduces stutter (when pipelines are created last minute and app relies on hot driver cache)
and load times (when applications do the right thing of loading PSOs up front).
Behavior is designed to be close to DXVK state cache.
#### Default behavior
`vkd3d-proton.cache` (and `vkd3d-proton.cache.write`) are placed in the current working directory.
Generally, this is the game install folder when running in Steam.
#### Custom directory
`VKD3D_SHADER_CACHE_PATH=/path/to/directory` overrides the directory where `vkd3d-proton.cache` is placed.
#### Disable cache
`VKD3D_SHADER_CACHE_PATH=0` disables the internal cache, and any caching would have to be explicitly managed
by application.
### Behavior of ID3D12PipelineLibrary
When explicit shader cache is used, the need for application managed pipeline libraries is greatly diminished,
and the cache applications interact with is a dummy cache.
If the vkd3d-proton shader cache is disabled, ID3D12PipelineLibrary stores everything relevant for a full cache,
i.e. SPIR-V and PSO driver cache blob.
`VKD3D_CONFIG=pipeline_library_app_cache` is an alternative to `VKD3D_SHADER_CACHE_PATH=0` and can be
automatically enabled based on app-profiles if relevant in the future if applications manage the caches better
than vkd3d-proton can do automagically.
## CPU profiling (development)
Pass `-Denable_profiling=true` to Meson to enable a profiled build. With a profiled build, use `VKD3D_PROFILE_PATH` environment variable.
The profiling dumps out a binary blob which can be analyzed with `programs/vkd3d-profile.py`.
The profile is a trivial system which records number of iterations and total ticks (ns) spent.
It is easy to instrument parts of code you are working on optimizing.
## Advanced shader debugging
These features are only meant to be used by vkd3d-proton developers. For any builtin RenderDoc related functionality
pass `-Denable_renderdoc=true` to Meson.
- `VKD3D_SHADER_DUMP_PATH` - path where shader bytecode is dumped.
Bytecode is dumped in format of `$hash.{spv,dxbc,dxil}`.
- `VKD3D_SHADER_OVERRIDE` - path to where overridden shaders can be found.
If application is creating a pipeline with `$hash` and `$VKD3D_SHADER_OVERRIDE/$hash.spv` exists,
that SPIR-V file will be used instead.
- `VKD3D_AUTO_CAPTURE_SHADER` - If this is set to a shader hash, and the RenderDoc layer is enabled,
vkd3d-proton will automatically make a capture when a specific shader is encountered.
- `VKD3D_AUTO_CAPTURE_COUNTS` - A comma-separated list of indices. This can be used to control which queue submissions to capture.
E.g., use `VKD3D_AUTO_CAPTURE_COUNTS=0,4,10` to capture the 0th (first submission), 4th and 10th submissions which are candidates for capturing.
If `VKD3D_AUTO_CAPTURE_COUNTS` is `-1`, the entire app runtime can be turned into one big capture.
This is only intended to be used when capturing something like the test suite,
or tiny applications with a finite runtime to make it easier to debug cross submission work.
If only `VKD3D_AUTO_CAPTURE_COUNTS` is set, any queue submission is considered for capturing.
If only `VKD3D_AUTO_CAPTURE_SHADER` is set, `VKD3D_AUTO_CAPTURE_COUNTS` is considered to be equal to `"0"`, i.e. a capture is only
made on first encounter with the target shader.
If both are set, the capture counter is only incremented and considered when a submission contains the use of the target shader.
### Breadcrumbs debugging
For debugging GPU hangs, it's useful to know where crashes happen.
If the build has trace enabled (non-release builds), breadcrumbs support is also enabled.
`VKD3D_CONFIG=breadcrumbs` will instrument command lists with `VK_AMD_buffer_marker` or `VK_NV_device_checkpoints`.
On GPU device lost or timeout, crash dumps are written to the log.
For best results on RADV, use `RADV_DEBUG=syncshaders`. The logs will print a digested form of the command lists
which were executing at the time, and attempt to narrow down the possible range of commands which could
have caused a crash.
### Shader logging
It is possible to log the output of replaced shaders, essentially a custom shader printf. To enable this feature, `VK_KHR_buffer_device_address` must be supported.
First, use `VKD3D_SHADER_DEBUG_RING_SIZE_LOG2=28` for example to set up a 256 MiB ring buffer in host memory.
Since this buffer is allocated in host memory, feel free to make it as large as you want, as it does not consume VRAM.
A worker thread will read the data as it comes in and log it. There is potential here to emit more structured information later.
The main reason this is implemented instead of the validation layer printf system is run-time performance,
and avoids any possible accidental hiding of bugs by introducing validation layers which add locking, etc.
Using `debugPrintEXT` is also possible if that fits better with your debugging scenario.
With this shader replacement scheme, we're able to add shader logging as unintrusive as possible.
```
# Inside folder full of override shaders, build everything with:
make -C /path/to/include/shader-debug M=$PWD
```
The shader can then include `#include "debug_channel.h"` and use various functions below.
```
void DEBUG_CHANNEL_INIT(uvec3 ID);
```
is used somewhere in your replaced shader. This should be initialized with `gl_GlobalInvocationID` or similar.
This ID will show up in the log. For each subgroup which calls `DEBUG_CHANNEL_INIT`, an instance counter is generated.
This allows you to correlate several messages which all originate from the same instance counter, which is logged alongside the ID.
An invocation can be uniquely identified with the instance + `DEBUG_CHANNEL_INIT` id.
`DEBUG_CHANNEL_INIT` can be called from non-uniform control flow, as it does not use `barrier()` or similar constructs.
It can also be used in vertex and fragment shaders for this reason.
```
void DEBUG_CHANNEL_MSG();
void DEBUG_CHANNEL_MSG(uint v0);
void DEBUG_CHANNEL_MSG(uint v0, uint v1, ...); // Up to 4 components, can be expanded as needed up to 16.
void DEBUG_CHANNEL_MSG(int v0);
void DEBUG_CHANNEL_MSG(int v0, int v1, ...); // Up to 4 components, ...
void DEBUG_CHANNEL_MSG(float v0);
void DEBUG_CHANNEL_MSG(float v0, float v1, ...); // Up to 4 components, ...
```
These functions log, formatting is `#%x` for uint, `%d` for int and `%f` for float type.
## Descriptor debugging
If `-Denable_descriptor_qa=true` is enabled in build, you can set the `VKD3D_DESCRIPTOR_QA_LOG` env-var to a file.
All descriptor updates and copies are logged so that it's possible to correlate descriptors with
GPU crash dumps. `enable_descriptor_qa` is not enabled by default,
since it adds some flat overhead in an extremely hot code path.
### GPU-assisted debugging
If `VKD3D_CONFIG=descriptor_qa_checks` is set with a build which enables `-Denable_descriptor_qa=true`,
all shaders will be instrumented to check for invalid access. In the log, you will see this to
make sure the feature is enabled.
```
932:info:vkd3d_descriptor_debug_init_once: Enabling descriptor QA checks!
```
The main motivation is the tight integration and high performance.
GPU-assisted debugging can be run at well over playable speeds.
#### Descriptor heap index out of bounds
```
============
Fault type: HEAP_OUT_OF_RANGE
Fault type: MISMATCH_DESCRIPTOR_TYPE
CBV_SRV_UAV heap cookie: 1800
Shader hash and instruction: edbaf1b5ed344467 (1)
Accessed resource/view cookie: 0
Shader desired descriptor type: 8 (STORAGE_BUFFER)
Found descriptor type in heap: 0 (NONE)
Failed heap index: 1024000
==========
```
The instruction `(1)`, is reported as well,
and a disassembly of the shader in question can be used to pinpoint exactly where
things are going wrong.
Dump all shaders with `VKD3D_SHADER_DUMP_PATH=/my/folder`,
and run `spirv-cross -V /my/folder/edbaf1b5ed344467.spv`.
(NOTE: clear out the folder before dumping, existing files are not overwritten).
The faulting instruction can be identified by looking at last argument, e.g.:
```
uint fixup_index = descriptor_qa_check(heap_index, descriptor_type, 1u /* instruction ID */);
```
#### Mismatch descriptor type
```
============
Fault type: MISMATCH_DESCRIPTOR_TYPE
CBV_SRV_UAV heap cookie: 1800 // Refer to VKD3D_DESCRIPTOR_QA_LOG
Shader hash and instruction: edbaf1b5ed344467 (1)
Accessed resource/view cookie: 1802 // Refer to VKD3D_DESCRIPTOR_QA_LOG
Shader desired descriptor type: 8 (STORAGE_BUFFER)
Found descriptor type in heap: 1 (SAMPLED_IMAGE)
Failed heap index: 1025
==========
```
#### Accessing destroyed resource
```
============
Fault type: DESTROYED_RESOURCE
CBV_SRV_UAV heap cookie: 1800
Shader hash and instruction: edbaf1b5ed344467 (2)
Accessed resource/view cookie: 1806
Shader desired descriptor type: 1 (SAMPLED_IMAGE)
Found descriptor type in heap: 1 (SAMPLED_IMAGE)
Failed heap index: 1029
==========
```
### Debugging descriptor crashes with RADV dumps (hardcore ultra nightmare mode)
For when you're absolutely desperate, there is a way to debug GPU hangs.
First, install [umr](https://gitlab.freedesktop.org/tomstdenis/umr) and make the binary setsuid.
`ACO_DEBUG=force-waitcnt RADV_DEBUG=hang VKD3D_DESCRIPTOR_QA_LOG=/somewhere/desc.txt %command%`
It is possible to use `RADV_DEBUG=hang,umr` as well, but from within Wine, there are weird things
happening where UMR dumps do not always succeed.
Instead, it is possible to invoke umr manually from an SSH shell when the GPU hangs.
```
#!/bin/bash
mkdir -p "$HOME/umr-dump"
# For Navi, older GPUs might have different rings. See RADV source.
umr -R gfx_0.0.0 > "$HOME/umr-dump/ring.txt" 2>&1
umr -O halt_waves -wa gfx_0.0.0 > "$HOME/umr-dump/halt-waves-1.txt" 2>&1
umr -O bits,halt_waves -wa gfx_0.0.0 > "$HOME/umr-dump/halt-waves-2.txt" 2>&1
```
A folder is placed in `~/radv_dumps*` by RADV, and the UMR script will place wave dumps in `~/umr-dump`.
First, we can study the wave dumps to see where things crash, e.g.:
```
pgm[6@0x800120e26c00 + 0x584 ] = 0xf0001108 image_load v47, v[4:5], s[48:55] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm
pgm[6@0x800120e26c00 + 0x588 ] = 0x000c2f04 ;;
pgm[6@0x800120e26c00 + 0x58c ] = 0xbf8c3f70 s_waitcnt vmcnt(0)
* pgm[6@0x800120e26c00 + 0x590 ] = 0x930118c0 s_mul_i32 s1, 64, s24
pgm[6@0x800120e26c00 + 0x594 ] = 0xf40c0c09 s_load_dwordx8 s[48:55], s[18:19], s1
pgm[6@0x800120e26c00 + 0x598 ] = 0x02000000 ;;
```
excp: 256 is a memory error (at least on 5700xt).
```
TRAPSTS[50000100]:
excp: 256 | illegal_inst: 0 | buffer_oob: 0 | excp_cycle: 0 |
excp_wave64hi: 0 | xnack_error: 1 | dp_rate: 2 | excp_group_mask: 0 |
```
We can inspect all VGPRs and all SGPRs, here for the image descriptor.
```
[ 48.. 51] = { 0130a000, c0500080, 810dc1df, 93b00204 }
[ 52.. 55] = { 00000000, 00400000, 002b0000, 800130c8 }
```
Decode the VA and study `bo_history.log`. There is a script in RADV which lets you query history for a VA.
This lets us verify that the VA in question was freed at some point.
At point of writing, there is no easy way to decode raw descriptor blobs, but when you're desperate enough you can do it by hand :|
In `pipeline.log` we have the full SPIR-V (with OpSource reference to the source DXIL/DXBC)
and disassembly of the crashed pipeline. Here we can study the code to figure out which descriptor was read.
```
// s7 is the descriptor heap index, s1 is the offset (64 bytes per image descriptor),
// s[18:19] is the descriptor heap.
s_mul_i32 s1, 64, s7 ; 930107c0
s_load_dwordx8 s[48:55], s[18:19], s1 ; f40c0c09 02000000
s_waitcnt lgkmcnt(0) ; bf8cc07f
image_load v47, v[4:5], s[48:55] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm ; f0001108 000c2f04
```
```
[ 4.. 7] = { 03200020, ffff8000, 0000002b, 00000103 }
```
Which is descriptor index #259. Based on this, we can inspect the descriptor QA log and verify that the application
did indeed do something invalid, which caused the GPU hang.

View File

@ -1,4 +0,0 @@
#!/bin/sh
set -e
autoreconf -ifv
rm -rf autom4te.cache

9
bin/.gitignore vendored
View File

@ -1,9 +0,0 @@
ar-lib
compile
config.guess
config.sub
depcomp
install-sh
ltmain.sh
missing
test-driver

19
build-win32.txt Normal file
View File

@ -0,0 +1,19 @@
[binaries]
c = 'i686-w64-mingw32-gcc'
cpp = 'i686-w64-mingw32-g++'
ar = 'i686-w64-mingw32-ar'
strip = 'i686-w64-mingw32-strip'
widl = 'i686-w64-mingw32-widl'
[properties]
c_args=['-msse', '-msse2']
cpp_args=['-msse', '-msse2']
c_link_args = ['-static', '-static-libgcc']
cpp_link_args = ['-static', '-static-libgcc', '-static-libstdc++']
needs_exe_wrapper = true
[host_machine]
system = 'windows'
cpu_family = 'x86'
cpu = 'x86'
endian = 'little'

17
build-win64.txt Normal file
View File

@ -0,0 +1,17 @@
[binaries]
c = 'x86_64-w64-mingw32-gcc'
cpp = 'x86_64-w64-mingw32-g++'
ar = 'x86_64-w64-mingw32-ar'
strip = 'x86_64-w64-mingw32-strip'
widl = 'x86_64-w64-mingw32-widl'
[properties]
c_link_args = ['-static', '-static-libgcc']
cpp_link_args = ['-static', '-static-libgcc', '-static-libstdc++']
needs_exe_wrapper = true
[host_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

View File

@ -1,154 +0,0 @@
AC_PREREQ([2.69])
AC_INIT([vkd3d],[1.1])
AC_CONFIG_AUX_DIR([bin])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS(include/config.h)
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])
AC_ARG_WITH([xcb], AS_HELP_STRING([--with-xcb], [Build with XCB library (default: test)]))
AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools],
[Build with SPIRV-Tools library (default: disabled)]))
AC_ARG_ENABLE([demos],
AS_HELP_STRING([--enable-demos], [Build demo programs (default: disabled)]),,
[enable_demos=no])
AC_ARG_ENABLE([tests],
AS_HELP_STRING([--enable-tests], [Build tests (default: enabled)]),,
[enable_tests=yes])
AC_USE_SYSTEM_EXTENSIONS
dnl Check for progs
AM_PROG_AR
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_SED
AC_PROG_MKDIR_P
VKD3D_PROG_WIDL(3, 20)
AS_IF([test "x$WIDL" = "xno"], [AC_MSG_WARN([widl is required to build header files.])])
AM_INIT_AUTOMAKE([1.11 foreign silent-rules subdir-objects no-dist-gzip dist-xz -Wall -Werror])
AM_MAINTAINER_MODE([enable])
AM_SILENT_RULES([yes])
LT_PREREQ([2.4.2])
LT_INIT([win32-dll])
gl_LD_VERSION_SCRIPT
dnl Check compiler specific flags
AC_SUBST([VKD3D_CFLAGS])
AS_IF([test "x${GCC}" = "xyes"],
[VKD3D_CFLAGS="-Wall -pipe"
VKD3D_CHECK_CFLAGS([-std=c99])
VKD3D_CHECK_CFLAGS([-Wdeclaration-after-statement])
VKD3D_CHECK_CFLAGS([-Wimplicit-fallthrough])
VKD3D_CHECK_CFLAGS([-Wmissing-prototypes])
VKD3D_CHECK_CFLAGS([-Wunused-but-set-parameter])
VKD3D_CHECK_CFLAGS([-Wvla])
VKD3D_CHECK_CFLAGS([-Wpointer-arith])
VKD3D_CHECK_CFLAGS([-Wl,--no-undefined])])
dnl Check for cross compilers
VKD3D_CHECK_MINGW32_PROG([CROSSCC32], [CROSSTARGET32], [no])
VKD3D_CHECK_MINGW64_PROG([CROSSCC64], [CROSSTARGET64], [no])
dnl Check for headers
AC_CHECK_HEADERS([dlfcn.h pthread.h \
vulkan/vulkan.h \
vulkan/spirv.h vulkan/GLSL.std.450.h \
spirv/unified1/spirv.h spirv/unified1/GLSL.std.450.h])
AS_IF([test "x$ac_cv_header_pthread_h" != "xyes"], [AC_MSG_ERROR([pthread.h not found.])])
AS_IF([test "x$ac_cv_header_vulkan_vulkan_h" != "xyes"], [AC_MSG_ERROR([vulkan.h not found.])])
AS_IF([test "x$ac_cv_header_spirv_unified1_spirv_h" != "xyes" \
-a "x$ac_cv_header_vulkan_spirv_h" != "xyes"],
[AC_MSG_ERROR([spirv.h not found.])])
AS_IF([test "x$ac_cv_header_spirv_unified1_GLSL_std_450_h" != "xyes" \
-a "x$ac_cv_header_vulkan_GLSL_std_450_h" != "xyes"],
[AC_MSG_ERROR([GLSL.std.450.h not found.])])
VKD3D_CHECK_VULKAN_HEADER_VERSION([113], [AC_MSG_ERROR([Vulkan headers are too old, 1.1.113 is required.])])
AC_CHECK_DECL([SpvCapabilityDemoteToHelperInvocationEXT],, [AC_MSG_ERROR([SPIR-V headers are too old.])], [
#ifdef HAVE_SPIRV_UNIFIED1_SPIRV_H
# include "spirv/unified1/spirv.h"
#else
# include "vulkan/spirv.h"
#endif])
AC_CHECK_DECLS([program_invocation_name],,,[#include <errno.h>])
dnl Check for libraries
m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG], [m4_fatal([pkg-config autoconf macros not found.])])
AC_CHECK_LIB([m], [ceilf])
AC_SUBST([DL_LIBS])
AC_CHECK_LIB([dl], [dlopen],
[DL_LIBS="-ldl"],
[AS_IF([test "$ac_cv_header_dlfnc_h" = "xyes"], [AC_MSG_ERROR([libdl not found.])])])
AC_ARG_VAR([PTHREAD_LIBS], [linker flags for pthreads])
VKD3D_CHECK_PTHREAD
AC_SUBST([VULKAN_LIBS])
VKD3D_CHECK_SONAME([vulkan], [vkGetInstanceProcAddr],
[VULKAN_LIBS="-lvulkan"],
[VKD3D_CHECK_SONAME([MoltenVK], [vkGetInstanceProcAddr],
[VULKAN_LIBS="-lMoltenVK"
AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN],["$ac_cv_lib_soname_MoltenVK"])],
[AC_MSG_ERROR([libvulkan and libMoltenVK not found.])])])
AS_IF([test "x$with_spirv_tools" = "xyes"],
[PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools-shared],
[AC_DEFINE([HAVE_SPIRV_TOOLS], [1], [Define to 1 if you have SPIRV-Tools.])])],
[with_spirv_tools=no])
HAVE_XCB=no
AS_IF([test "x$with_xcb" != "xno"],
[PKG_CHECK_MODULES([XCB], [xcb xcb-keysyms],
[AC_DEFINE([HAVE_XCB], [1], [Define to 1 if you have libxcb.])
HAVE_XCB=yes],
[HAVE_XCB=no])])
dnl Check for functions
VKD3D_CHECK_FUNC([HAVE_BUILTIN_CLZ], [__builtin_clz], [__builtin_clz(0)])
VKD3D_CHECK_FUNC([HAVE_BUILTIN_POPCOUNT], [__builtin_popcount], [__builtin_popcount(0)])
VKD3D_CHECK_FUNC([HAVE_SYNC_ADD_AND_FETCH], [__sync_add_and_fetch], [__sync_add_and_fetch((int *)0, 0)])
VKD3D_CHECK_FUNC([HAVE_SYNC_SUB_AND_FETCH], [__sync_sub_and_fetch], [__sync_sub_and_fetch((int *)0, 0)])
VKD3D_CHECK_PTHREAD_SETNAME_NP
dnl Makefiles
AS_IF([test "x$enable_demos" = "xyes" -a "x$HAVE_XCB" != "xyes"],
[AC_MSG_ERROR([libxcb is required for demos.])])
AM_CONDITIONAL([BUILD_DEMOS], [test "x$enable_demos" = "xyes"])
AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" != "xno"])
AM_CONDITIONAL([HAVE_WIDL], [test "x$WIDL" != "xno"])
AM_CONDITIONAL([HAVE_CROSSTARGET32], [test "x$CROSSTARGET32" != "xno"])
AM_CONDITIONAL([HAVE_CROSSTARGET64], [test "x$CROSSTARGET64" != "xno"])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
dnl Output configuration summary
AS_IF([test "x$CROSSTARGET32" != "xno" -o "x$CROSSTARGET64" != "xno"],
[HAVE_CROSSTEST=yes], [HAVE_CROSSTEST=no])
AS_ECHO(["
Configuration summary for $PACKAGE $VERSION
widl: ${WIDL}
Have XCB: ${HAVE_XCB}
Have SPIRV-Tools: ${with_spirv_tools}
Building demos: ${enable_demos}
Building tests: ${enable_tests}
Building crosstests: ${HAVE_CROSSTEST}"])
AS_IF([test "x$CROSSTARGET32" != "xno"], [AS_ECHO([" Using 32-bit cross compiler: $CROSSCC32"])])
AS_IF([test "x$CROSSTARGET64" != "xno"], [AS_ECHO([" Using 64-bit cross compiler: $CROSSCC64"])])
AS_ECHO([])

View File

@ -1 +0,0 @@
*.a

View File

@ -1,7 +0,0 @@
LIBRARY D3D12.dll
EXPORTS
D3D12CreateDevice@16 @101
D3D12GetDebugInterface@8 @102
D3D12CreateRootSignatureDeserializer@16 @106
D3D12SerializeRootSignature@16 @107

View File

@ -1,7 +0,0 @@
LIBRARY D3D12.dll
EXPORTS
D3D12CreateDevice @101
D3D12GetDebugInterface @102
D3D12CreateRootSignatureDeserializer @106
D3D12SerializeRootSignature @107

View File

@ -16,21 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* Hack for MinGW-w64 headers.
*
* We want to use WIDL C inline wrappers because some methods
* in D3D12 interfaces return aggregate objects. Unfortunately,
* WIDL C inline wrappers are broken when used with MinGW-w64
* headers because FORCEINLINE expands to extern inline
* which leads to the "multiple storage classes in declaration
* specifiers" compiler error.
*/
#ifdef __MINGW32__
#include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# undef __forceinline
# define __forceinline __inline__ __attribute__((__always_inline__,__gnu_inline__))
# endif
#ifdef _WIN32
# include <vkd3d_win32.h>
#endif
#include <vkd3d_windows.h>

View File

@ -17,11 +17,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <vkd3d_dxgi1_4.h>
#include <stdbool.h>
#include <stdio.h>
#define DEMO_WINDOW_CLASS_NAME L"demo_wc"
#define DEMO_WINDOW_CLASS_NAME u"demo_wc"
struct demo
{
@ -200,12 +199,12 @@ static inline bool demo_init(struct demo *demo, void *user_data)
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = LoadIconW(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
wc.hIcon = LoadIconA(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = DEMO_WINDOW_CLASS_NAME;
wc.hIconSm = LoadIconW(NULL, IDI_WINLOGO);
wc.hIconSm = LoadIconA(NULL, IDI_WINLOGO);
if (!RegisterClassExW(&wc))
return false;

View File

@ -20,6 +20,7 @@
#define VK_USE_PLATFORM_XCB_KHR
#include <vkd3d.h>
#include <vkd3d_utils.h>
#include <vkd3d_sonames.h>
#include <xcb/xcb_event.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_keysyms.h>
@ -28,6 +29,24 @@
#include <unistd.h>
#include <fcntl.h>
#include <stdbool.h>
#include <dlfcn.h>
#define SYMBOL(x) static PFN_vk##x x
SYMBOL(CreateXcbSurfaceKHR);
SYMBOL(GetPhysicalDeviceSurfaceSupportKHR);
SYMBOL(GetPhysicalDeviceSurfaceCapabilitiesKHR);
SYMBOL(GetPhysicalDeviceSurfaceFormatsKHR);
SYMBOL(CreateSwapchainKHR);
SYMBOL(CreateFence);
SYMBOL(GetSwapchainImagesKHR);
SYMBOL(AcquireNextImageKHR);
SYMBOL(WaitForFences);
SYMBOL(ResetFences);
SYMBOL(DestroyFence);
SYMBOL(DestroySurfaceKHR);
SYMBOL(QueuePresentKHR);
SYMBOL(DestroySwapchainKHR);
#undef SYMBOL
struct demo
{
@ -43,6 +62,7 @@ struct demo
void *user_data;
void (*idle_func)(struct demo *demo, void *user_data);
};
struct demo_window
@ -70,6 +90,29 @@ struct demo_swapchain
ID3D12Resource *buffers[1];
};
static inline void init_symbols(VkInstance instance)
{
PFN_vkGetInstanceProcAddr gpa;
void *handle = dlopen(SONAME_LIBVULKAN, RTLD_LAZY);
gpa = (PFN_vkGetInstanceProcAddr)dlsym(handle, "vkGetInstanceProcAddr");
#define SYMBOL(x) x = (PFN_vk##x)gpa(instance, "vk" #x)
SYMBOL(CreateXcbSurfaceKHR);
SYMBOL(GetPhysicalDeviceSurfaceSupportKHR);
SYMBOL(GetPhysicalDeviceSurfaceCapabilitiesKHR);
SYMBOL(GetPhysicalDeviceSurfaceFormatsKHR);
SYMBOL(CreateSwapchainKHR);
SYMBOL(CreateFence);
SYMBOL(GetSwapchainImagesKHR);
SYMBOL(AcquireNextImageKHR);
SYMBOL(WaitForFences);
SYMBOL(ResetFences);
SYMBOL(DestroySurfaceKHR);
SYMBOL(DestroyFence);
SYMBOL(QueuePresentKHR);
SYMBOL(DestroySwapchainKHR);
#undef SYMBOL
}
static inline xcb_atom_t demo_get_atom(xcb_connection_t *c, const char *name)
{
xcb_intern_atom_cookie_t cookie;
@ -339,23 +382,25 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
vk_physical_device = vkd3d_get_vk_physical_device(d3d12_device);
vk_device = vkd3d_get_vk_device(d3d12_device);
init_symbols(vk_instance);
surface_desc.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
surface_desc.pNext = NULL;
surface_desc.flags = 0;
surface_desc.connection = window->demo->connection;
surface_desc.window = window->window;
if (vkCreateXcbSurfaceKHR(vk_instance, &surface_desc, NULL, &vk_surface) < 0)
if (CreateXcbSurfaceKHR(vk_instance, &surface_desc, NULL, &vk_surface) < 0)
{
ID3D12Device_Release(d3d12_device);
return NULL;
}
queue_family_index = vkd3d_get_vk_queue_family_index(command_queue);
if (vkGetPhysicalDeviceSurfaceSupportKHR(vk_physical_device,
if (GetPhysicalDeviceSurfaceSupportKHR(vk_physical_device,
queue_family_index, vk_surface, &supported) < 0 || !supported)
goto fail;
if (vkGetPhysicalDeviceSurfaceCapabilitiesKHR(vk_physical_device, vk_surface, &surface_caps) < 0)
if (GetPhysicalDeviceSurfaceCapabilitiesKHR(vk_physical_device, vk_surface, &surface_caps) < 0)
goto fail;
if ((surface_caps.maxImageCount && desc->buffer_count > surface_caps.maxImageCount)
@ -365,11 +410,11 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|| !(surface_caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR))
goto fail;
if (vkGetPhysicalDeviceSurfaceFormatsKHR(vk_physical_device, vk_surface, &format_count, NULL) < 0
if (GetPhysicalDeviceSurfaceFormatsKHR(vk_physical_device, vk_surface, &format_count, NULL) < 0
|| !format_count || !(formats = calloc(format_count, sizeof(*formats))))
goto fail;
if (vkGetPhysicalDeviceSurfaceFormatsKHR(vk_physical_device, vk_surface, &format_count, formats) < 0)
if (GetPhysicalDeviceSurfaceFormatsKHR(vk_physical_device, vk_surface, &format_count, formats) < 0)
{
free(formats);
goto fail;
@ -413,20 +458,20 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
vk_swapchain_desc.presentMode = VK_PRESENT_MODE_FIFO_KHR;
vk_swapchain_desc.clipped = VK_TRUE;
vk_swapchain_desc.oldSwapchain = VK_NULL_HANDLE;
if (vkCreateSwapchainKHR(vk_device, &vk_swapchain_desc, NULL, &vk_swapchain) < 0)
if (CreateSwapchainKHR(vk_device, &vk_swapchain_desc, NULL, &vk_swapchain) < 0)
goto fail;
fence_desc.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fence_desc.pNext = NULL;
fence_desc.flags = 0;
if (vkCreateFence(vk_device, &fence_desc, NULL, &vk_fence) < 0)
if (CreateFence(vk_device, &fence_desc, NULL, &vk_fence) < 0)
goto fail;
if (vkGetSwapchainImagesKHR(vk_device, vk_swapchain, &image_count, NULL) < 0
if (GetSwapchainImagesKHR(vk_device, vk_swapchain, &image_count, NULL) < 0
|| !(vk_images = calloc(image_count, sizeof(*vk_images))))
goto fail;
if (vkGetSwapchainImagesKHR(vk_device, vk_swapchain, &image_count, vk_images) < 0)
if (GetSwapchainImagesKHR(vk_device, vk_swapchain, &image_count, vk_images) < 0)
{
free(vk_images);
goto fail;
@ -443,13 +488,11 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
swapchain->vk_instance = vk_instance;
swapchain->vk_device = vk_device;
vkAcquireNextImageKHR(vk_device, vk_swapchain, UINT64_MAX,
AcquireNextImageKHR(vk_device, vk_swapchain, UINT64_MAX,
VK_NULL_HANDLE, vk_fence, &swapchain->current_buffer);
vkWaitForFences(vk_device, 1, &vk_fence, VK_TRUE, UINT64_MAX);
vkResetFences(vk_device, 1, &vk_fence);
WaitForFences(vk_device, 1, &vk_fence, VK_TRUE, UINT64_MAX);
ResetFences(vk_device, 1, &vk_fence);
resource_create_info.type = VKD3D_STRUCTURE_TYPE_IMAGE_RESOURCE_CREATE_INFO;
resource_create_info.next = NULL;
resource_create_info.desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
resource_create_info.desc.Alignment = 0;
resource_create_info.desc.Width = desc->width;
@ -461,7 +504,7 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
resource_create_info.desc.SampleDesc.Quality = 0;
resource_create_info.desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
resource_create_info.desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
resource_create_info.flags = VKD3D_RESOURCE_INITIAL_STATE_TRANSITION | VKD3D_RESOURCE_PRESENT_STATE_TRANSITION;
resource_create_info.flags = 0;
resource_create_info.present_state = D3D12_RESOURCE_STATE_PRESENT;
for (i = 0; i < image_count; ++i)
{
@ -476,6 +519,8 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
free(vk_images);
goto fail;
}
vkd3d_enqueue_initial_transition(command_queue, swapchain->buffers[i]);
}
swapchain->buffer_count = image_count;
free(vk_images);
@ -487,10 +532,10 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
fail:
if (vk_fence != VK_NULL_HANDLE)
vkDestroyFence(vk_device, vk_fence, NULL);
DestroyFence(vk_device, vk_fence, NULL);
if (vk_swapchain != VK_NULL_HANDLE)
vkDestroySwapchainKHR(vk_device, vk_swapchain, NULL);
vkDestroySurfaceKHR(vk_instance, vk_surface, NULL);
DestroySwapchainKHR(vk_device, vk_swapchain, NULL);
DestroySurfaceKHR(vk_instance, vk_surface, NULL);
ID3D12Device_Release(d3d12_device);
return NULL;
}
@ -525,13 +570,13 @@ static inline void demo_swapchain_present(struct demo_swapchain *swapchain)
present_desc.pResults = NULL;
vk_queue = vkd3d_acquire_vk_queue(swapchain->command_queue);
vkQueuePresentKHR(vk_queue, &present_desc);
QueuePresentKHR(vk_queue, &present_desc);
vkd3d_release_vk_queue(swapchain->command_queue);
vkAcquireNextImageKHR(swapchain->vk_device, swapchain->vk_swapchain, UINT64_MAX,
AcquireNextImageKHR(swapchain->vk_device, swapchain->vk_swapchain, UINT64_MAX,
VK_NULL_HANDLE, swapchain->vk_fence, &swapchain->current_buffer);
vkWaitForFences(swapchain->vk_device, 1, &swapchain->vk_fence, VK_TRUE, UINT64_MAX);
vkResetFences(swapchain->vk_device, 1, &swapchain->vk_fence);
WaitForFences(swapchain->vk_device, 1, &swapchain->vk_fence, VK_TRUE, UINT64_MAX);
ResetFences(swapchain->vk_device, 1, &swapchain->vk_fence);
}
static inline void demo_swapchain_destroy(struct demo_swapchain *swapchain)
@ -543,9 +588,9 @@ static inline void demo_swapchain_destroy(struct demo_swapchain *swapchain)
{
ID3D12Resource_Release(swapchain->buffers[i]);
}
vkDestroyFence(swapchain->vk_device, swapchain->vk_fence, NULL);
vkDestroySwapchainKHR(swapchain->vk_device, swapchain->vk_swapchain, NULL);
vkDestroySurfaceKHR(swapchain->vk_instance, swapchain->vk_surface, NULL);
DestroyFence(swapchain->vk_device, swapchain->vk_fence, NULL);
DestroySwapchainKHR(swapchain->vk_device, swapchain->vk_swapchain, NULL);
DestroySurfaceKHR(swapchain->vk_instance, swapchain->vk_surface, NULL);
free(swapchain);
}

View File

@ -41,10 +41,12 @@
*/
#define INITGUID
#define _GNU_SOURCE
#ifndef _WIN32
#include <sys/time.h>
#endif
#include <assert.h>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include "demo.h"
@ -268,15 +270,32 @@ static void cxg_update_mvp(struct cx_gears *cxg)
memcpy(cxg->cb_data->normal_matrix, world, sizeof(cxg->cb_data->normal_matrix));
}
static double cxg_get_time(void)
{
#ifdef _WIN32
LARGE_INTEGER freq;
LARGE_INTEGER counter;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&counter);
return ((double)counter.QuadPart) / (double)freq.QuadPart;
#else
struct timeval tv;
double t;
gettimeofday(&tv, NULL);
t = tv.tv_sec + tv.tv_usec / 1000000.0;
return t;
#endif
}
static void cxg_render_frame(struct cx_gears *cxg)
{
static double t_prev = -1.0;
struct timeval tv;
double dt, t;
float a;
gettimeofday(&tv, NULL);
t = tv.tv_sec + tv.tv_usec / 1000000.0;
t = cxg_get_time();
if (t_prev < 0.0)
t_prev = t;
dt = t - t_prev;
@ -437,13 +456,8 @@ static void cxg_mesh_create(ID3D12Device *device, float inner_radius, float oute
float r0, r1, r2;
float angle, da;
if (!(vertices = calloc(tooth_count, 12 * sizeof(*vertices))))
return;
if (!(faces = calloc(tooth_count, 20 * sizeof(*faces))))
{
free(vertices);
return;
}
vertices = calloc(tooth_count, 12 * sizeof(*vertices));
faces = calloc(tooth_count, 20 * sizeof(*faces));
r0 = inner_radius;
r1 = outer_radius - tooth_depth / 2.0f;
@ -878,7 +892,11 @@ static int cxg_main(void)
}
#ifdef _WIN32
int wmain(void)
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
#else
int main(void)
#endif

33
demos/meson.build Normal file
View File

@ -0,0 +1,33 @@
demo_vkd3d_deps = [
threads_dep, vkd3d_common_dep
]
if vkd3d_platform != 'windows'
demo_vkd3d_deps += [
lib_m,
lib_xcb,
lib_xcbkeysyms,
vkd3d_dep,
vkd3d_utils_dep,
]
else
demo_vkd3d_deps += [
lib_dxgi,
lib_d3d12
]
endif
executable('gears', 'gears.c',
dependencies : demo_vkd3d_deps,
include_directories : vkd3d_public_includes,
install : true,
gui_app : true,
override_options : [ 'c_std='+vkd3d_c_std ])
executable('triangle', 'triangle.c',
dependencies : demo_vkd3d_deps,
include_directories : vkd3d_public_includes,
install : true,
gui_app : true,
override_options : [ 'c_std='+vkd3d_c_std ])

View File

@ -393,7 +393,11 @@ static int cxt_main(void)
}
#ifdef _WIN32
int wmain(void)
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
#else
int main(void)
#endif

17
include/meson.build Normal file
View File

@ -0,0 +1,17 @@
vkd3d_idl = [
'vkd3d_d3d12.idl',
'vkd3d_d3d12sdklayers.idl',
'vkd3d_d3dcommon.idl',
'vkd3d_dxgi.idl',
'vkd3d_dxgi1_2.idl',
'vkd3d_dxgi1_3.idl',
'vkd3d_dxgi1_4.idl',
'vkd3d_dxgibase.idl',
'vkd3d_dxgiformat.idl',
'vkd3d_dxgitype.idl',
'vkd3d_swapchain_factory.idl',
'vkd3d_command_list_vkd3d_ext.idl',
'vkd3d_device_vkd3d_ext.idl'
]
vkd3d_header_files = idl_generator.process(vkd3d_idl)

255
include/private/hashmap.h Normal file
View File

@ -0,0 +1,255 @@
/*
* Hash map support
*
* Copyright 2020 Philip Rebohle for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_HASHMAP_H
#define __VKD3D_HASHMAP_H
#include <stddef.h>
#include "vkd3d_memory.h"
enum hash_map_entry_flag
{
HASH_MAP_ENTRY_OCCUPIED = (1 << 0),
};
struct hash_map_entry
{
uint32_t hash_value;
uint32_t flags;
};
typedef uint32_t (*pfn_hash_func)(const void* key);
typedef bool (*pfn_hash_compare_func)(const void *key, const struct hash_map_entry *entry);
/* Open-addressing hash table */
struct hash_map
{
pfn_hash_func hash_func;
pfn_hash_compare_func compare_func;
void *entries;
size_t entry_size;
uint32_t entry_count;
uint32_t used_count;
};
static inline struct hash_map_entry *hash_map_get_entry(const struct hash_map *hash_map, uint32_t entry_idx)
{
return void_ptr_offset(hash_map->entries, hash_map->entry_size * entry_idx);
}
static inline uint32_t hash_map_get_entry_idx(const struct hash_map *hash_map, uint32_t hash_value)
{
return hash_value % hash_map->entry_count;
}
static inline uint32_t hash_map_next_entry_idx(const struct hash_map *hash_map, uint32_t entry_idx)
{
uint32_t next_idx = entry_idx + 1;
return next_idx < hash_map->entry_count ? next_idx : 0;
}
static inline uint32_t hash_map_next_size(uint32_t old_size)
{
/* This yields a sequence of primes and numbers with two
* relatively large prime factors for any reasonable hash
* table size */
return old_size ? (old_size * 2 + 5) : 37;
}
static inline bool hash_map_grow(struct hash_map *hash_map)
{
uint32_t i, old_count, new_count;
void *new_entries, *old_entries;
old_count = hash_map->entry_count;
old_entries = hash_map->entries;
new_count = hash_map_next_size(hash_map->entry_count);
if (!(new_entries = vkd3d_calloc(new_count, hash_map->entry_size)))
return false;
hash_map->entry_count = new_count;
hash_map->entries = new_entries;
for (i = 0; i < old_count; i++)
{
/* Relocate existing entries one by one */
struct hash_map_entry *old_entry = void_ptr_offset(old_entries, i * hash_map->entry_size);
if (old_entry->flags & HASH_MAP_ENTRY_OCCUPIED)
{
uint32_t entry_idx = hash_map_get_entry_idx(hash_map, old_entry->hash_value);
struct hash_map_entry *new_entry = hash_map_get_entry(hash_map, entry_idx);
while (new_entry->flags & HASH_MAP_ENTRY_OCCUPIED)
{
entry_idx = hash_map_next_entry_idx(hash_map, entry_idx);
new_entry = hash_map_get_entry(hash_map, entry_idx);
}
memcpy(new_entry, old_entry, hash_map->entry_size);
}
}
vkd3d_free(old_entries);
return true;
}
static inline bool hash_map_should_grow_before_insert(struct hash_map *hash_map)
{
/* Allow a load factor of 0.7 for performance reasons */
return 10 * hash_map->used_count >= 7 * hash_map->entry_count;
}
static inline struct hash_map_entry *hash_map_find(const struct hash_map *hash_map, const void *key)
{
uint32_t hash_value, entry_idx;
if (!hash_map->entries)
return NULL;
hash_value = hash_map->hash_func(key);
entry_idx = hash_map_get_entry_idx(hash_map, hash_value);
/* We never allow the hash table to be completely
* populated, so this is guaranteed to return */
while (true)
{
struct hash_map_entry *entry = hash_map_get_entry(hash_map, entry_idx);
if (!(entry->flags & HASH_MAP_ENTRY_OCCUPIED))
return NULL;
if (entry->hash_value == hash_value && hash_map->compare_func(key, entry))
return entry;
entry_idx = hash_map_next_entry_idx(hash_map, entry_idx);
}
}
static inline struct hash_map_entry *hash_map_insert(struct hash_map *hash_map, const void *key, const struct hash_map_entry *entry)
{
struct hash_map_entry *target = NULL;
uint32_t hash_value, entry_idx;
if (hash_map_should_grow_before_insert(hash_map))
{
if (!hash_map_grow(hash_map))
return NULL;
}
hash_value = hash_map->hash_func(key);
entry_idx = hash_map_get_entry_idx(hash_map, hash_value);
while (!target)
{
struct hash_map_entry *current = hash_map_get_entry(hash_map, entry_idx);
if (!(current->flags & HASH_MAP_ENTRY_OCCUPIED) ||
(current->hash_value == hash_value && hash_map->compare_func(key, current)))
target = current;
else
entry_idx = hash_map_next_entry_idx(hash_map, entry_idx);
}
if (!(target->flags & HASH_MAP_ENTRY_OCCUPIED))
{
hash_map->used_count += 1;
target->flags = HASH_MAP_ENTRY_OCCUPIED;
target->hash_value = hash_value;
memcpy(target + 1, entry + 1, hash_map->entry_size - sizeof(*entry));
}
/* If target is occupied, we already have an entry in the hashmap.
* Return old one, caller is responsible for cleaning up the node we attempted to add. */
return target;
}
static inline void hash_map_init(struct hash_map *hash_map, pfn_hash_func hash_func, pfn_hash_compare_func compare_func, size_t entry_size)
{
hash_map->hash_func = hash_func;
hash_map->compare_func = compare_func;
hash_map->entries = NULL;
hash_map->entry_size = entry_size;
hash_map->entry_count = 0;
hash_map->used_count = 0;
assert(entry_size > sizeof(struct hash_map_entry));
}
static inline void hash_map_clear(struct hash_map *hash_map)
{
vkd3d_free(hash_map->entries);
hash_map->entries = NULL;
hash_map->entry_count = 0;
hash_map->used_count = 0;
}
static inline uint32_t hash_combine(uint32_t old_hash, uint32_t new_hash) {
return old_hash ^ (new_hash + 0x9e3779b9 + (old_hash << 6) + (old_hash >> 2));
}
static inline uint32_t hash_uint64(uint64_t n)
{
return hash_combine((uint32_t)n, (uint32_t)(n >> 32));
}
/* A somewhat stronger hash when we're meant to store the hash (pipeline caches, etc). Based on FNV-1a. */
static inline uint64_t hash_fnv1_init()
{
return 0xcbf29ce484222325ull;
}
static inline uint64_t hash_fnv1_iterate_u8(uint64_t h, uint8_t value)
{
return (h * 0x100000001b3ull) ^ value;
}
static inline uint64_t hash_fnv1_iterate_u32(uint64_t h, uint32_t value)
{
return (h * 0x100000001b3ull) ^ value;
}
static inline uint64_t hash_fnv1_iterate_f32(uint64_t h, float value)
{
union u { float f32; uint32_t u32; } v;
v.f32 = value;
return hash_fnv1_iterate_u32(h, v.u32);
}
static inline uint64_t hash_fnv1_iterate_u64(uint64_t h, uint64_t value)
{
h = hash_fnv1_iterate_u32(h, value & UINT32_MAX);
h = hash_fnv1_iterate_u32(h, value >> 32);
return h;
}
static inline uint64_t hash_fnv1_iterate_string(uint64_t h, const char *str)
{
if (str)
while (*str)
h = hash_fnv1_iterate_u8(h, *str++);
h = hash_fnv1_iterate_u8(h, 0);
return h;
}
#endif /* __VKD3D_HASHMAP_H */

View File

@ -0,0 +1,688 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2019-2020 Baldur Karlsson
*
* 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.
******************************************************************************/
#pragma once
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// Documentation for the API is available at https://renderdoc.org/docs/in_application_api.html
//
#if !defined(RENDERDOC_NO_STDINT)
#include <stdint.h>
#endif
#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
#define RENDERDOC_CC __cdecl
#elif defined(__linux__)
#define RENDERDOC_CC
#elif defined(__APPLE__)
#define RENDERDOC_CC
#else
#error "Unknown platform"
#endif
#ifdef __cplusplus
extern "C" {
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////
// Constants not used directly in below API
// This is a GUID/magic value used for when applications pass a path where shader debug
// information can be found to match up with a stripped shader.
// the define can be used like so: const GUID RENDERDOC_ShaderDebugMagicValue =
// RENDERDOC_ShaderDebugMagicValue_value
#define RENDERDOC_ShaderDebugMagicValue_struct \
{ \
0xeab25520, 0x6670, 0x4865, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
}
// as an alternative when you want a byte array (assuming x86 endianness):
#define RENDERDOC_ShaderDebugMagicValue_bytearray \
{ \
0x20, 0x55, 0xb2, 0xea, 0x70, 0x66, 0x65, 0x48, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
}
// truncated version when only a uint64_t is available (e.g. Vulkan tags):
#define RENDERDOC_ShaderDebugMagicValue_truncated 0x48656670eab25520ULL
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc capture options
//
typedef enum RENDERDOC_CaptureOption {
// Allow the application to enable vsync
//
// Default - enabled
//
// 1 - The application can enable or disable vsync at will
// 0 - vsync is force disabled
eRENDERDOC_Option_AllowVSync = 0,
// Allow the application to enable fullscreen
//
// Default - enabled
//
// 1 - The application can enable or disable fullscreen at will
// 0 - fullscreen is force disabled
eRENDERDOC_Option_AllowFullscreen = 1,
// Record API debugging events and messages
//
// Default - disabled
//
// 1 - Enable built-in API debugging features and records the results into
// the capture, which is matched up with events on replay
// 0 - no API debugging is forcibly enabled
eRENDERDOC_Option_APIValidation = 2,
eRENDERDOC_Option_DebugDeviceMode = 2, // deprecated name of this enum
// Capture CPU callstacks for API events
//
// Default - disabled
//
// 1 - Enables capturing of callstacks
// 0 - no callstacks are captured
eRENDERDOC_Option_CaptureCallstacks = 3,
// When capturing CPU callstacks, only capture them from drawcalls.
// This option does nothing without the above option being enabled
//
// Default - disabled
//
// 1 - Only captures callstacks for drawcall type API events.
// Ignored if CaptureCallstacks is disabled
// 0 - Callstacks, if enabled, are captured for every event.
eRENDERDOC_Option_CaptureCallstacksOnlyDraws = 4,
// Specify a delay in seconds to wait for a debugger to attach, after
// creating or injecting into a process, before continuing to allow it to run.
//
// 0 indicates no delay, and the process will run immediately after injection
//
// Default - 0 seconds
//
eRENDERDOC_Option_DelayForDebugger = 5,
// Verify buffer access. This includes checking the memory returned by a Map() call to
// detect any out-of-bounds modification, as well as initialising buffers with undefined contents
// to a marker value to catch use of uninitialised memory.
//
// NOTE: This option is only valid for OpenGL and D3D11. Explicit APIs such as D3D12 and Vulkan do
// not do the same kind of interception & checking and undefined contents are really undefined.
//
// Default - disabled
//
// 1 - Verify buffer access
// 0 - No verification is performed, and overwriting bounds may cause crashes or corruption in
// RenderDoc.
eRENDERDOC_Option_VerifyBufferAccess = 6,
// The old name for eRENDERDOC_Option_VerifyBufferAccess was eRENDERDOC_Option_VerifyMapWrites.
// This option now controls the filling of uninitialised buffers with 0xdddddddd which was
// previously always enabled
eRENDERDOC_Option_VerifyMapWrites = eRENDERDOC_Option_VerifyBufferAccess,
// Hooks any system API calls that create child processes, and injects
// RenderDoc into them recursively with the same options.
//
// Default - disabled
//
// 1 - Hooks into spawned child processes
// 0 - Child processes are not hooked by RenderDoc
eRENDERDOC_Option_HookIntoChildren = 7,
// By default RenderDoc only includes resources in the final capture necessary
// for that frame, this allows you to override that behaviour.
//
// Default - disabled
//
// 1 - all live resources at the time of capture are included in the capture
// and available for inspection
// 0 - only the resources referenced by the captured frame are included
eRENDERDOC_Option_RefAllResources = 8,
// **NOTE**: As of RenderDoc v1.1 this option has been deprecated. Setting or
// getting it will be ignored, to allow compatibility with older versions.
// In v1.1 the option acts as if it's always enabled.
//
// By default RenderDoc skips saving initial states for resources where the
// previous contents don't appear to be used, assuming that writes before
// reads indicate previous contents aren't used.
//
// Default - disabled
//
// 1 - initial contents at the start of each captured frame are saved, even if
// they are later overwritten or cleared before being used.
// 0 - unless a read is detected, initial contents will not be saved and will
// appear as black or empty data.
eRENDERDOC_Option_SaveAllInitials = 9,
// In APIs that allow for the recording of command lists to be replayed later,
// RenderDoc may choose to not capture command lists before a frame capture is
// triggered, to reduce overheads. This means any command lists recorded once
// and replayed many times will not be available and may cause a failure to
// capture.
//
// NOTE: This is only true for APIs where multithreading is difficult or
// discouraged. Newer APIs like Vulkan and D3D12 will ignore this option
// and always capture all command lists since the API is heavily oriented
// around it and the overheads have been reduced by API design.
//
// 1 - All command lists are captured from the start of the application
// 0 - Command lists are only captured if their recording begins during
// the period when a frame capture is in progress.
eRENDERDOC_Option_CaptureAllCmdLists = 10,
// Mute API debugging output when the API validation mode option is enabled
//
// Default - enabled
//
// 1 - Mute any API debug messages from being displayed or passed through
// 0 - API debugging is displayed as normal
eRENDERDOC_Option_DebugOutputMute = 11,
// Option to allow vendor extensions to be used even when they may be
// incompatible with RenderDoc and cause corrupted replays or crashes.
//
// Default - inactive
//
// No values are documented, this option should only be used when absolutely
// necessary as directed by a RenderDoc developer.
eRENDERDOC_Option_AllowUnsupportedVendorExtensions = 12,
} RENDERDOC_CaptureOption;
// Sets an option that controls how RenderDoc behaves on capture.
//
// Returns 1 if the option and value are valid
// Returns 0 if either is invalid and the option is unchanged
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionU32)(RENDERDOC_CaptureOption opt, uint32_t val);
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionF32)(RENDERDOC_CaptureOption opt, float val);
// Gets the current value of an option as a uint32_t
//
// If the option is invalid, 0xffffffff is returned
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionU32)(RENDERDOC_CaptureOption opt);
// Gets the current value of an option as a float
//
// If the option is invalid, -FLT_MAX is returned
typedef float(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionF32)(RENDERDOC_CaptureOption opt);
typedef enum RENDERDOC_InputButton {
// '0' - '9' matches ASCII values
eRENDERDOC_Key_0 = 0x30,
eRENDERDOC_Key_1 = 0x31,
eRENDERDOC_Key_2 = 0x32,
eRENDERDOC_Key_3 = 0x33,
eRENDERDOC_Key_4 = 0x34,
eRENDERDOC_Key_5 = 0x35,
eRENDERDOC_Key_6 = 0x36,
eRENDERDOC_Key_7 = 0x37,
eRENDERDOC_Key_8 = 0x38,
eRENDERDOC_Key_9 = 0x39,
// 'A' - 'Z' matches ASCII values
eRENDERDOC_Key_A = 0x41,
eRENDERDOC_Key_B = 0x42,
eRENDERDOC_Key_C = 0x43,
eRENDERDOC_Key_D = 0x44,
eRENDERDOC_Key_E = 0x45,
eRENDERDOC_Key_F = 0x46,
eRENDERDOC_Key_G = 0x47,
eRENDERDOC_Key_H = 0x48,
eRENDERDOC_Key_I = 0x49,
eRENDERDOC_Key_J = 0x4A,
eRENDERDOC_Key_K = 0x4B,
eRENDERDOC_Key_L = 0x4C,
eRENDERDOC_Key_M = 0x4D,
eRENDERDOC_Key_N = 0x4E,
eRENDERDOC_Key_O = 0x4F,
eRENDERDOC_Key_P = 0x50,
eRENDERDOC_Key_Q = 0x51,
eRENDERDOC_Key_R = 0x52,
eRENDERDOC_Key_S = 0x53,
eRENDERDOC_Key_T = 0x54,
eRENDERDOC_Key_U = 0x55,
eRENDERDOC_Key_V = 0x56,
eRENDERDOC_Key_W = 0x57,
eRENDERDOC_Key_X = 0x58,
eRENDERDOC_Key_Y = 0x59,
eRENDERDOC_Key_Z = 0x5A,
// leave the rest of the ASCII range free
// in case we want to use it later
eRENDERDOC_Key_NonPrintable = 0x100,
eRENDERDOC_Key_Divide,
eRENDERDOC_Key_Multiply,
eRENDERDOC_Key_Subtract,
eRENDERDOC_Key_Plus,
eRENDERDOC_Key_F1,
eRENDERDOC_Key_F2,
eRENDERDOC_Key_F3,
eRENDERDOC_Key_F4,
eRENDERDOC_Key_F5,
eRENDERDOC_Key_F6,
eRENDERDOC_Key_F7,
eRENDERDOC_Key_F8,
eRENDERDOC_Key_F9,
eRENDERDOC_Key_F10,
eRENDERDOC_Key_F11,
eRENDERDOC_Key_F12,
eRENDERDOC_Key_Home,
eRENDERDOC_Key_End,
eRENDERDOC_Key_Insert,
eRENDERDOC_Key_Delete,
eRENDERDOC_Key_PageUp,
eRENDERDOC_Key_PageDn,
eRENDERDOC_Key_Backspace,
eRENDERDOC_Key_Tab,
eRENDERDOC_Key_PrtScrn,
eRENDERDOC_Key_Pause,
eRENDERDOC_Key_Max,
} RENDERDOC_InputButton;
// Sets which key or keys can be used to toggle focus between multiple windows
//
// If keys is NULL or num is 0, toggle keys will be disabled
typedef void(RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(RENDERDOC_InputButton *keys, int num);
// Sets which key or keys can be used to capture the next frame
//
// If keys is NULL or num is 0, captures keys will be disabled
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(RENDERDOC_InputButton *keys, int num);
typedef enum RENDERDOC_OverlayBits {
// This single bit controls whether the overlay is enabled or disabled globally
eRENDERDOC_Overlay_Enabled = 0x1,
// Show the average framerate over several seconds as well as min/max
eRENDERDOC_Overlay_FrameRate = 0x2,
// Show the current frame number
eRENDERDOC_Overlay_FrameNumber = 0x4,
// Show a list of recent captures, and how many captures have been made
eRENDERDOC_Overlay_CaptureList = 0x8,
// Default values for the overlay mask
eRENDERDOC_Overlay_Default = (eRENDERDOC_Overlay_Enabled | eRENDERDOC_Overlay_FrameRate |
eRENDERDOC_Overlay_FrameNumber | eRENDERDOC_Overlay_CaptureList),
// Enable all bits
eRENDERDOC_Overlay_All = ~0U,
// Disable all bits
eRENDERDOC_Overlay_None = 0,
} RENDERDOC_OverlayBits;
// returns the overlay bits that have been set
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
// sets the overlay bits with an and & or mask
typedef void(RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
// this function will attempt to remove RenderDoc's hooks in the application.
//
// Note: that this can only work correctly if done immediately after
// the module is loaded, before any API work happens. RenderDoc will remove its
// injected hooks and shut down. Behaviour is undefined if this is called
// after any API functions have been called, and there is still no guarantee of
// success.
typedef void(RENDERDOC_CC *pRENDERDOC_RemoveHooks)();
// DEPRECATED: compatibility for code compiled against pre-1.4.1 headers.
typedef pRENDERDOC_RemoveHooks pRENDERDOC_Shutdown;
// This function will unload RenderDoc's crash handler.
//
// If you use your own crash handler and don't want RenderDoc's handler to
// intercede, you can call this function to unload it and any unhandled
// exceptions will pass to the next handler.
typedef void(RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
// Sets the capture file path template
//
// pathtemplate is a UTF-8 string that gives a template for how captures will be named
// and where they will be saved.
//
// Any extension is stripped off the path, and captures are saved in the directory
// specified, and named with the filename and the frame number appended. If the
// directory does not exist it will be created, including any parent directories.
//
// If pathtemplate is NULL, the template will remain unchanged
//
// Example:
//
// SetCaptureFilePathTemplate("my_captures/example");
//
// Capture #1 -> my_captures/example_frame123.rdc
// Capture #2 -> my_captures/example_frame456.rdc
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFilePathTemplate)(const char *pathtemplate);
// returns the current capture path template, see SetCaptureFileTemplate above, as a UTF-8 string
typedef const char *(RENDERDOC_CC *pRENDERDOC_GetCaptureFilePathTemplate)();
// DEPRECATED: compatibility for code compiled against pre-1.1.2 headers.
typedef pRENDERDOC_SetCaptureFilePathTemplate pRENDERDOC_SetLogFilePathTemplate;
typedef pRENDERDOC_GetCaptureFilePathTemplate pRENDERDOC_GetLogFilePathTemplate;
// returns the number of captures that have been made
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
// This function returns the details of a capture, by index. New captures are added
// to the end of the list.
//
// filename will be filled with the absolute path to the capture file, as a UTF-8 string
// pathlength will be written with the length in bytes of the filename string
// timestamp will be written with the time of the capture, in seconds since the Unix epoch
//
// Any of the parameters can be NULL and they'll be skipped.
//
// The function will return 1 if the capture index is valid, or 0 if the index is invalid
// If the index is invalid, the values will be unchanged
//
// Note: when captures are deleted in the UI they will remain in this list, so the
// capture path may not exist anymore.
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *filename,
uint32_t *pathlength, uint64_t *timestamp);
// Sets the comments associated with a capture file. These comments are displayed in the
// UI program when opening.
//
// filePath should be a path to the capture file to add comments to. If set to NULL or ""
// the most recent capture file created made will be used instead.
// comments should be a NULL-terminated UTF-8 string to add as comments.
//
// Any existing comments will be overwritten.
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFileComments)(const char *filePath,
const char *comments);
// returns 1 if the RenderDoc UI is connected to this application, 0 otherwise
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsTargetControlConnected)();
// DEPRECATED: compatibility for code compiled against pre-1.1.1 headers.
// This was renamed to IsTargetControlConnected in API 1.1.1, the old typedef is kept here for
// backwards compatibility with old code, it is castable either way since it's ABI compatible
// as the same function pointer type.
typedef pRENDERDOC_IsTargetControlConnected pRENDERDOC_IsRemoteAccessConnected;
// This function will launch the Replay UI associated with the RenderDoc library injected
// into the running application.
//
// if connectTargetControl is 1, the Replay UI will be launched with a command line parameter
// to connect to this application
// cmdline is the rest of the command line, as a UTF-8 string. E.g. a captures to open
// if cmdline is NULL, the command line will be empty.
//
// returns the PID of the replay UI if successful, 0 if not successful.
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_LaunchReplayUI)(uint32_t connectTargetControl,
const char *cmdline);
// RenderDoc can return a higher version than requested if it's backwards compatible,
// this function returns the actual version returned. If a parameter is NULL, it will be
// ignored and the others will be filled out.
typedef void(RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, int *patch);
//////////////////////////////////////////////////////////////////////////
// Capturing functions
//
// A device pointer is a pointer to the API's root handle.
//
// This would be an ID3D11Device, HGLRC/GLXContext, ID3D12Device, etc
typedef void *RENDERDOC_DevicePointer;
// A window handle is the OS's native window handle
//
// This would be an HWND, GLXDrawable, etc
typedef void *RENDERDOC_WindowHandle;
// A helper macro for Vulkan, where the device handle cannot be used directly.
//
// Passing the VkInstance to this macro will return the RENDERDOC_DevicePointer to use.
//
// Specifically, the value needed is the dispatch table pointer, which sits as the first
// pointer-sized object in the memory pointed to by the VkInstance. Thus we cast to a void** and
// indirect once.
#define RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(inst) (*((void **)(inst)))
// This sets the RenderDoc in-app overlay in the API/window pair as 'active' and it will
// respond to keypresses. Neither parameter can be NULL
typedef void(RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// capture the next frame on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
// capture the next N frames on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerMultiFrameCapture)(uint32_t numFrames);
// When choosing either a device pointer or a window handle to capture, you can pass NULL.
// Passing NULL specifies a 'wildcard' match against anything. This allows you to specify
// any API rendering to a specific window, or a specific API instance rendering to any window,
// or in the simplest case of one window and one API, you can just pass NULL for both.
//
// In either case, if there are two or more possible matching (device,window) pairs it
// is undefined which one will be captured.
//
// Note: for headless rendering you can pass NULL for the window handle and either specify
// a device pointer or leave it NULL as above.
// Immediately starts capturing API calls on the specified device pointer and window handle.
//
// If there is no matching thing to capture (e.g. no supported API has been initialised),
// this will do nothing.
//
// The results are undefined (including crashes) if two captures are started overlapping,
// even on separate devices and/oror windows.
typedef void(RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// Returns whether or not a frame capture is currently ongoing anywhere.
//
// This will return 1 if a capture is ongoing, and 0 if there is no capture running
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)();
// Ends capturing immediately.
//
// This will return 1 if the capture succeeded, and 0 if there was an error capturing.
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// Ends capturing immediately and discard any data stored without saving to disk.
//
// This will return 1 if the capture was discarded, and 0 if there was an error or no capture
// was in progress
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_DiscardFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc API versions
//
// RenderDoc uses semantic versioning (http://semver.org/).
//
// MAJOR version is incremented when incompatible API changes happen.
// MINOR version is incremented when functionality is added in a backwards-compatible manner.
// PATCH version is incremented when backwards-compatible bug fixes happen.
//
// Note that this means the API returned can be higher than the one you might have requested.
// e.g. if you are running against a newer RenderDoc that supports 1.0.1, it will be returned
// instead of 1.0.0. You can check this with the GetAPIVersion entry point
typedef enum RENDERDOC_Version {
eRENDERDOC_API_Version_1_0_0 = 10000, // RENDERDOC_API_1_0_0 = 1 00 00
eRENDERDOC_API_Version_1_0_1 = 10001, // RENDERDOC_API_1_0_1 = 1 00 01
eRENDERDOC_API_Version_1_0_2 = 10002, // RENDERDOC_API_1_0_2 = 1 00 02
eRENDERDOC_API_Version_1_1_0 = 10100, // RENDERDOC_API_1_1_0 = 1 01 00
eRENDERDOC_API_Version_1_1_1 = 10101, // RENDERDOC_API_1_1_1 = 1 01 01
eRENDERDOC_API_Version_1_1_2 = 10102, // RENDERDOC_API_1_1_2 = 1 01 02
eRENDERDOC_API_Version_1_2_0 = 10200, // RENDERDOC_API_1_2_0 = 1 02 00
eRENDERDOC_API_Version_1_3_0 = 10300, // RENDERDOC_API_1_3_0 = 1 03 00
eRENDERDOC_API_Version_1_4_0 = 10400, // RENDERDOC_API_1_4_0 = 1 04 00
eRENDERDOC_API_Version_1_4_1 = 10401, // RENDERDOC_API_1_4_1 = 1 04 01
} RENDERDOC_Version;
// API version changelog:
//
// 1.0.0 - initial release
// 1.0.1 - Bugfix: IsFrameCapturing() was returning false for captures that were triggered
// by keypress or TriggerCapture, instead of Start/EndFrameCapture.
// 1.0.2 - Refactor: Renamed eRENDERDOC_Option_DebugDeviceMode to eRENDERDOC_Option_APIValidation
// 1.1.0 - Add feature: TriggerMultiFrameCapture(). Backwards compatible with 1.0.x since the new
// function pointer is added to the end of the struct, the original layout is identical
// 1.1.1 - Refactor: Renamed remote access to target control (to better disambiguate from remote
// replay/remote server concept in replay UI)
// 1.1.2 - Refactor: Renamed "log file" in function names to just capture, to clarify that these
// are captures and not debug logging files. This is the first API version in the v1.0
// branch.
// 1.2.0 - Added feature: SetCaptureFileComments() to add comments to a capture file that will be
// displayed in the UI program on load.
// 1.3.0 - Added feature: New capture option eRENDERDOC_Option_AllowUnsupportedVendorExtensions
// which allows users to opt-in to allowing unsupported vendor extensions to function.
// Should be used at the user's own risk.
// Refactor: Renamed eRENDERDOC_Option_VerifyMapWrites to
// eRENDERDOC_Option_VerifyBufferAccess, which now also controls initialisation to
// 0xdddddddd of uninitialised buffer contents.
// 1.4.0 - Added feature: DiscardFrameCapture() to discard a frame capture in progress and stop
// capturing without saving anything to disk.
// 1.4.1 - Refactor: Renamed Shutdown to RemoveHooks to better clarify what is happening
typedef struct RENDERDOC_API_1_4_1
{
pRENDERDOC_GetAPIVersion GetAPIVersion;
pRENDERDOC_SetCaptureOptionU32 SetCaptureOptionU32;
pRENDERDOC_SetCaptureOptionF32 SetCaptureOptionF32;
pRENDERDOC_GetCaptureOptionU32 GetCaptureOptionU32;
pRENDERDOC_GetCaptureOptionF32 GetCaptureOptionF32;
pRENDERDOC_SetFocusToggleKeys SetFocusToggleKeys;
pRENDERDOC_SetCaptureKeys SetCaptureKeys;
pRENDERDOC_GetOverlayBits GetOverlayBits;
pRENDERDOC_MaskOverlayBits MaskOverlayBits;
// Shutdown was renamed to RemoveHooks in 1.4.1.
// These unions allow old code to continue compiling without changes
union
{
pRENDERDOC_Shutdown Shutdown;
pRENDERDOC_RemoveHooks RemoveHooks;
};
pRENDERDOC_UnloadCrashHandler UnloadCrashHandler;
// Get/SetLogFilePathTemplate was renamed to Get/SetCaptureFilePathTemplate in 1.1.2.
// These unions allow old code to continue compiling without changes
union
{
// deprecated name
pRENDERDOC_SetLogFilePathTemplate SetLogFilePathTemplate;
// current name
pRENDERDOC_SetCaptureFilePathTemplate SetCaptureFilePathTemplate;
};
union
{
// deprecated name
pRENDERDOC_GetLogFilePathTemplate GetLogFilePathTemplate;
// current name
pRENDERDOC_GetCaptureFilePathTemplate GetCaptureFilePathTemplate;
};
pRENDERDOC_GetNumCaptures GetNumCaptures;
pRENDERDOC_GetCapture GetCapture;
pRENDERDOC_TriggerCapture TriggerCapture;
// IsRemoteAccessConnected was renamed to IsTargetControlConnected in 1.1.1.
// This union allows old code to continue compiling without changes
union
{
// deprecated name
pRENDERDOC_IsRemoteAccessConnected IsRemoteAccessConnected;
// current name
pRENDERDOC_IsTargetControlConnected IsTargetControlConnected;
};
pRENDERDOC_LaunchReplayUI LaunchReplayUI;
pRENDERDOC_SetActiveWindow SetActiveWindow;
pRENDERDOC_StartFrameCapture StartFrameCapture;
pRENDERDOC_IsFrameCapturing IsFrameCapturing;
pRENDERDOC_EndFrameCapture EndFrameCapture;
// new function in 1.1.0
pRENDERDOC_TriggerMultiFrameCapture TriggerMultiFrameCapture;
// new function in 1.2.0
pRENDERDOC_SetCaptureFileComments SetCaptureFileComments;
// new function in 1.4.0
pRENDERDOC_DiscardFrameCapture DiscardFrameCapture;
} RENDERDOC_API_1_4_1;
typedef RENDERDOC_API_1_4_1 RENDERDOC_API_1_0_0;
typedef RENDERDOC_API_1_4_1 RENDERDOC_API_1_0_1;
typedef RENDERDOC_API_1_4_1 RENDERDOC_API_1_0_2;
typedef RENDERDOC_API_1_4_1 RENDERDOC_API_1_1_0;
typedef RENDERDOC_API_1_4_1 RENDERDOC_API_1_1_1;
typedef RENDERDOC_API_1_4_1 RENDERDOC_API_1_1_2;
typedef RENDERDOC_API_1_4_1 RENDERDOC_API_1_2_0;
typedef RENDERDOC_API_1_4_1 RENDERDOC_API_1_3_0;
typedef RENDERDOC_API_1_4_1 RENDERDOC_API_1_4_0;
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc API entry point
//
// This entry point can be obtained via GetProcAddress/dlsym if RenderDoc is available.
//
// The name is the same as the typedef - "RENDERDOC_GetAPI"
//
// This function is not thread safe, and should not be called on multiple threads at once.
// Ideally, call this once as early as possible in your application's startup, before doing
// any API work, since some configuration functionality etc has to be done also before
// initialising any APIs.
//
// Parameters:
// version is a single value from the RENDERDOC_Version above.
//
// outAPIPointers will be filled out with a pointer to the corresponding struct of function
// pointers.
//
// Returns:
// 1 - if the outAPIPointers has been filled with a pointer to the API struct requested
// 0 - if the requested version is not supported or the arguments are invalid.
//
typedef int(RENDERDOC_CC *pRENDERDOC_GetAPI)(RENDERDOC_Version version, void **outAPIPointers);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -0,0 +1,283 @@
/*
* Copyright 2020 Joshua Ashton for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_ATOMIC_H
#define __VKD3D_ATOMIC_H
#include <stdint.h>
#if defined(_MSC_VER)
# include <intrin.h>
typedef enum
{
vkd3d_memory_order_relaxed,
vkd3d_memory_order_consume,
vkd3d_memory_order_acquire,
vkd3d_memory_order_release,
vkd3d_memory_order_acq_rel,
vkd3d_memory_order_seq_cst,
} vkd3d_memory_order;
# define vkd3d_atomic_rw_barrier() _ReadWriteBarrier()
FORCEINLINE void vkd3d_atomic_load_barrier(vkd3d_memory_order order)
{
switch (order)
{
case vkd3d_memory_order_consume:
case vkd3d_memory_order_acquire:
case vkd3d_memory_order_seq_cst:
vkd3d_atomic_rw_barrier();
break;
case vkd3d_memory_order_relaxed:
default:
break;
}
}
/* Redefinitions for invalid memory orders */
#define InterlockedExchangeRelease InterlockedExchange
#define InterlockedExchangeRelease64 InterlockedExchange64
#define vkd3d_atomic_choose_intrinsic(order, result, intrinsic, suffix, ...) \
switch (order) \
{ \
case vkd3d_memory_order_relaxed: result = intrinsic##NoFence##suffix (__VA_ARGS__); break; \
case vkd3d_memory_order_consume: \
case vkd3d_memory_order_acquire: result = intrinsic##Acquire##suffix (__VA_ARGS__); break; \
case vkd3d_memory_order_release: result = intrinsic##Release##suffix (__VA_ARGS__); break; \
case vkd3d_memory_order_acq_rel: \
case vkd3d_memory_order_seq_cst: result = intrinsic##suffix (__VA_ARGS__); break; \
}
FORCEINLINE uint32_t vkd3d_atomic_uint32_load_explicit(uint32_t *target, vkd3d_memory_order order)
{
uint32_t value = *((volatile uint32_t*)target);
vkd3d_atomic_load_barrier(order);
return value;
}
FORCEINLINE void vkd3d_atomic_uint32_store_explicit(uint32_t *target, uint32_t value, vkd3d_memory_order order)
{
switch (order)
{
case vkd3d_memory_order_release: vkd3d_atomic_rw_barrier(); /* fallthrough */
case vkd3d_memory_order_relaxed: *((volatile uint32_t*)target) = value; break;
default:
case vkd3d_memory_order_seq_cst:
(void) InterlockedExchange((LONG*) target, value);
}
}
FORCEINLINE uint32_t vkd3d_atomic_uint32_exchange_explicit(uint32_t *target, uint32_t value, vkd3d_memory_order order)
{
uint32_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedExchange, /* no suffix */,(LONG*)target, value);
return result;
}
FORCEINLINE uint32_t vkd3d_atomic_uint32_increment(uint32_t *target, vkd3d_memory_order order)
{
uint32_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedIncrement, /* no suffix */,(LONG*)target);
return result;
}
FORCEINLINE uint32_t vkd3d_atomic_uint32_decrement(uint32_t *target, vkd3d_memory_order order)
{
uint32_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedDecrement, /* no suffix */,(LONG*)target);
return result;
}
FORCEINLINE uint32_t vkd3d_atomic_uint32_add(uint32_t *target, uint32_t value, vkd3d_memory_order order)
{
uint32_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedAdd, /* no suffix */,(LONG*)target, value);
return result;
}
FORCEINLINE uint32_t vkd3d_atomic_uint32_sub(uint32_t *target, uint32_t value, vkd3d_memory_order order)
{
uint32_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedAdd, /* no suffix */,(LONG*)target, (uint32_t)(-(int32_t)value));
return result;
}
FORCEINLINE uint32_t vkd3d_atomic_uint32_and(uint32_t *target, uint32_t value, vkd3d_memory_order order)
{
uint32_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedAnd, /* no suffix */,(LONG*)target, value);
return result;
}
FORCEINLINE uint32_t vkd3d_atomic_uint32_or(uint32_t *target, uint32_t value, vkd3d_memory_order order)
{
uint32_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedOr, /* no suffix */,(LONG*)target, value);
return result;
}
FORCEINLINE uint32_t vkd3d_atomic_uint32_compare_exchange(uint32_t* target, uint32_t expected, uint32_t desired,
vkd3d_memory_order success_order, vkd3d_memory_order fail_order)
{
uint32_t result;
/* InterlockedCompareExchange has desired (ExChange) first, then expected (Comperand) */
vkd3d_atomic_choose_intrinsic(success_order, result, InterlockedCompareExchange, /* no suffix */, (LONG*)target, desired, expected);
return result;
}
FORCEINLINE uint64_t vkd3d_atomic_uint64_load_explicit(uint64_t *target, vkd3d_memory_order order)
{
uint64_t value = *((volatile uint64_t*)target);
vkd3d_atomic_load_barrier(order);
return value;
}
FORCEINLINE void vkd3d_atomic_uint64_store_explicit(uint64_t *target, uint64_t value, vkd3d_memory_order order)
{
switch (order)
{
case vkd3d_memory_order_release: vkd3d_atomic_rw_barrier(); /* fallthrough */
case vkd3d_memory_order_relaxed: *((volatile uint64_t*)target) = value; break;
default:
case vkd3d_memory_order_seq_cst:
(void) InterlockedExchange64((LONG64*) target, value);
}
}
FORCEINLINE uint64_t vkd3d_atomic_uint64_exchange_explicit(uint64_t *target, uint64_t value, vkd3d_memory_order order)
{
uint64_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedExchange, 64, (LONG64*)target, value);
return result;
}
FORCEINLINE uint64_t vkd3d_atomic_uint64_increment(uint64_t *target, vkd3d_memory_order order)
{
uint64_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedIncrement, 64, (LONG64*)target);
return result;
}
FORCEINLINE uint64_t vkd3d_atomic_uint64_decrement(uint64_t *target, vkd3d_memory_order order)
{
uint64_t result;
vkd3d_atomic_choose_intrinsic(order, result, InterlockedDecrement, 64, (LONG64*)target);
return result;
}
FORCEINLINE uint64_t vkd3d_atomic_uint64_compare_exchange(UINT64* target, uint64_t expected, uint64_t desired,
vkd3d_memory_order success_order, vkd3d_memory_order fail_order)
{
uint64_t result;
/* InterlockedCompareExchange has desired (ExChange) first, then expected (Comperand). Use UINT64 to mark 8-byte alignment. */
vkd3d_atomic_choose_intrinsic(success_order, result, InterlockedCompareExchange, 64, (LONG64*)target, desired, expected);
return result;
}
#elif defined(__GNUC__) || defined(__clang__)
typedef enum
{
vkd3d_memory_order_relaxed = __ATOMIC_RELAXED,
vkd3d_memory_order_consume = __ATOMIC_CONSUME,
vkd3d_memory_order_acquire = __ATOMIC_ACQUIRE,
vkd3d_memory_order_release = __ATOMIC_RELEASE,
vkd3d_memory_order_acq_rel = __ATOMIC_ACQ_REL,
vkd3d_memory_order_seq_cst = __ATOMIC_SEQ_CST,
} vkd3d_memory_order;
# define vkd3d_atomic_generic_load_explicit(target, order) __atomic_load_n(target, order)
# define vkd3d_atomic_generic_store_explicit(target, value, order) __atomic_store_n(target, value, order)
# define vkd3d_atomic_generic_exchange_explicit(target, value, order) __atomic_exchange_n(target, value, order)
# define vkd3d_atomic_generic_increment(target, order) __atomic_add_fetch(target, 1, order)
# define vkd3d_atomic_generic_decrement(target, order) __atomic_sub_fetch(target, 1, order)
# define vkd3d_atomic_generic_add(target, value, order) __atomic_add_fetch(target, value, order)
# define vkd3d_atomic_generic_sub(target, value, order) __atomic_sub_fetch(target, value, order)
# define vkd3d_atomic_generic_and(target, value, order) __atomic_and_fetch(target, value, order)
# define vkd3d_atomic_generic_or(target, value, order) __atomic_or_fetch(target, value, order)
# define vkd3d_atomic_uint32_load_explicit(target, order) vkd3d_atomic_generic_load_explicit(target, order)
# define vkd3d_atomic_uint32_store_explicit(target, value, order) vkd3d_atomic_generic_store_explicit(target, value, order)
# define vkd3d_atomic_uint32_exchange_explicit(target, value, order) vkd3d_atomic_generic_exchange_explicit(target, value, order)
# define vkd3d_atomic_uint32_increment(target, order) vkd3d_atomic_generic_increment(target, order)
# define vkd3d_atomic_uint32_decrement(target, order) vkd3d_atomic_generic_decrement(target, order)
# define vkd3d_atomic_uint32_add(target, value, order) vkd3d_atomic_generic_add(target, value, order)
# define vkd3d_atomic_uint32_sub(target, value, order) vkd3d_atomic_generic_sub(target, value, order)
# define vkd3d_atomic_uint32_and(target, value, order) vkd3d_atomic_generic_and(target, value, order)
# define vkd3d_atomic_uint32_or(target, value, order) vkd3d_atomic_generic_or(target, value, order)
static inline uint32_t vkd3d_atomic_uint32_compare_exchange(uint32_t* target, uint32_t expected, uint32_t desired,
vkd3d_memory_order success_order, vkd3d_memory_order fail_order)
{
/* Expected is written to with the old value in the case that *target != expected */
__atomic_compare_exchange_n(target, &expected, desired, 0, success_order, fail_order);
return expected;
}
# define vkd3d_atomic_uint64_load_explicit(target, order) vkd3d_atomic_generic_load_explicit(target, order)
# define vkd3d_atomic_uint64_store_explicit(target, value, order) vkd3d_atomic_generic_store_explicit(target, value, order)
# define vkd3d_atomic_uint64_exchange_explicit(target, value, order) vkd3d_atomic_generic_exchange_explicit(target, value, order)
# define vkd3d_atomic_uint64_increment(target, order) vkd3d_atomic_generic_increment(target, order)
# define vkd3d_atomic_uint64_decrement(target, order) vkd3d_atomic_generic_decrement(target, order)
static inline uint64_t vkd3d_atomic_uint64_compare_exchange(UINT64* target, uint64_t expected, uint64_t desired,
vkd3d_memory_order success_order, vkd3d_memory_order fail_order)
{
/* Expected is written to with the old value in the case that *target != expected. Use UINT64 to mark 8-byte alignment. */
__atomic_compare_exchange_n(target, &expected, desired, 0, success_order, fail_order);
return expected;
}
# ifndef __MINGW32__
# define InterlockedIncrement(target) vkd3d_atomic_uint32_increment(target, vkd3d_memory_order_seq_cst)
# define InterlockedDecrement(target) vkd3d_atomic_uint32_decrement(target, vkd3d_memory_order_seq_cst)
# define InterlockedCompareExchange(target, desired, expected) vkd3d_atomic_uint32_compare_exchange(target, expected, desired, vkd3d_memory_order_seq_cst, vkd3d_memory_order_acquire)
# define InterlockedIncrement64(target) vkd3d_atomic_uint64_increment(target, vkd3d_memory_order_seq_cst)
# define InterlockedDecrement64(target) vkd3d_atomic_uint64_decrement(target, vkd3d_memory_order_seq_cst)
# define InterlockedCompareExchange64(target, desired, expected) vkd3d_atomic_uint64_compare_exchange(target, expected, desired, vkd3d_memory_order_seq_cst, vkd3d_memory_order_acquire)
# endif
#else
# error "No atomics for this platform"
#endif
#if INTPTR_MAX == INT64_MAX
# define vkd3d_atomic_ptr_load_explicit(target, order) ((void *)vkd3d_atomic_uint64_load_explicit((uint64_t *)target, order))
# define vkd3d_atomic_ptr_store_explicit(target, value, order) (vkd3d_atomic_uint64_store_explicit((uint64_t *)target, (uint64_t)value, order))
# define vkd3d_atomic_ptr_exchange_explicit(target, value, order) ((void *)vkd3d_atomic_uint64_exchange_explicit((uint64_t *)target, (uint64_t)value, order))
# define vkd3d_atomic_ptr_increment(target, order) ((void *)vkd3d_atomic_uint64_increment((uint64_t *)target, order))
# define vkd3d_atomic_ptr_decrement(target, order) ((void *)vkd3d_atomic_uint64_decrement((uint64_t *)target, order))
# define vkd3d_atomic_ptr_compare_exchange(target, expected, desired, success_order, fail_order) \
((void *)vkd3d_atomic_uint64_compare_exchange((UINT64 *)target, (uint64_t)expected, (uint64_t)desired, success_order, fail_order))
#else
# define vkd3d_atomic_ptr_load_explicit(target, order) ((void *)vkd3d_atomic_uint32_load_explicit((uint32_t *)target, order))
# define vkd3d_atomic_ptr_store_explicit(target, value, order) (vkd3d_atomic_uint32_store_explicit((uint32_t *)target, (uint32_t)value, order))
# define vkd3d_atomic_ptr_exchange_explicit(target, value, order) ((void *)vkd3d_atomic_uint32_exchange_explicit((uint32_t *)target, (uint32_t)value, order))
# define vkd3d_atomic_ptr_increment(target, order) ((void *)vkd3d_atomic_uint32_increment((uint32_t *)target, order))
# define vkd3d_atomic_ptr_decrement(target, order) ((void *)vkd3d_atomic_uint32_decrement((uint32_t *)target, order))
# define vkd3d_atomic_ptr_compare_exchange(target, expected, desired, success_order, fail_order) \
((void *)vkd3d_atomic_uint32_compare_exchange((uint32_t *)target, (uint32_t)expected, (uint32_t)desired, success_order, fail_order))
#endif
#endif

View File

@ -19,15 +19,20 @@
#ifndef __VKD3D_COMMON_H
#define __VKD3D_COMMON_H
#include "config.h"
#include "vkd3d_windows.h"
#include "vkd3d_spinlock.h"
#include "vkd3d_profiling.h"
#include <ctype.h>
#include <stdint.h>
#include <limits.h>
#include <stdbool.h>
#include <assert.h>
#ifdef _MSC_VER
#include <intrin.h>
#else
#include <time.h>
#endif
#ifndef ARRAY_SIZE
@ -40,8 +45,15 @@
#define MEMBER_SIZE(t, m) sizeof(((t *)0)->m)
static inline uint64_t align64(uint64_t addr, uint64_t alignment)
{
assert(alignment > 0 && (alignment & (alignment - 1)) == 0);
return (addr + (alignment - 1)) & ~(alignment - 1);
}
static inline size_t align(size_t addr, size_t alignment)
{
assert(alignment > 0 && (alignment & (alignment - 1)) == 0);
return (addr + (alignment - 1)) & ~(alignment - 1);
}
@ -57,7 +69,7 @@ static inline unsigned int vkd3d_popcount(unsigned int v)
{
#ifdef _MSC_VER
return __popcnt(v);
#elif defined(HAVE_BUILTIN_POPCOUNT)
#elif defined(__GNUC__) || defined(__clang__)
return __builtin_popcount(v);
#else
v -= (v >> 1) & 0x55555555;
@ -81,6 +93,87 @@ static inline bool vkd3d_bitmask_is_contiguous(unsigned int mask)
return vkd3d_popcount(mask) == j;
}
/* Returns 64 for mask == 0 */
static inline unsigned int vkd3d_bitmask_tzcnt64(uint64_t mask)
{
#ifdef _MSC_VER
unsigned long result;
#ifdef _WIN64
return _BitScanForward64(&result, mask) ? result : 64;
#else
uint32_t lower, upper;
lower = (uint32_t)mask;
upper = (uint32_t)(mask >> 32);
if (_BitScanForward(&result, lower))
return result;
else if (_BitScanForward(&result, upper))
return result + 32;
else
return 64;
#endif
#elif defined(__GNUC__) || defined(__clang__)
return mask ? __builtin_ctzll(mask) : 64;
#else
#error "No implementation for ctzll."
#endif
}
/* Returns 32 for mask == 0 */
static inline unsigned int vkd3d_bitmask_tzcnt32(uint32_t mask)
{
#ifdef _MSC_VER
unsigned long result;
return _BitScanForward(&result, mask) ? result : 32;
#elif defined(__GNUC__) || defined(__clang__)
return mask ? __builtin_ctz(mask) : 32;
#else
#error "No implementation for ctz."
#endif
}
/* find least significant bit, then remove that bit from mask */
static inline unsigned int vkd3d_bitmask_iter64(uint64_t* mask)
{
uint64_t cur_mask = *mask;
*mask = cur_mask & (cur_mask - 1);
return vkd3d_bitmask_tzcnt64(cur_mask);
}
static inline unsigned int vkd3d_bitmask_iter32(uint32_t *mask)
{
uint32_t cur_mask = *mask;
*mask = cur_mask & (cur_mask - 1);
return vkd3d_bitmask_tzcnt32(cur_mask);
}
struct vkd3d_bitmask_range
{
unsigned int offset;
unsigned int count;
};
static inline struct vkd3d_bitmask_range vkd3d_bitmask_iter32_range(uint32_t *mask)
{
struct vkd3d_bitmask_range range;
uint32_t tmp;
if (*mask == ~0u)
{
range.offset = 0;
range.count = 32;
*mask = 0u;
}
else
{
range.offset = vkd3d_bitmask_tzcnt32(*mask);
tmp = *mask >> range.offset;
range.count = vkd3d_bitmask_tzcnt32(~tmp);
*mask &= ~(((1u << range.count) - 1u) << range.offset);
}
return range;
}
/* Undefined for x == 0. */
static inline unsigned int vkd3d_log2i(unsigned int x)
{
@ -90,7 +183,7 @@ static inline unsigned int vkd3d_log2i(unsigned int x)
unsigned long result;
_BitScanReverse(&result, x);
return (unsigned int)result;
#elif defined(HAVE_BUILTIN_CLZ)
#elif defined(__GNUC__) || defined(__clang__)
return __builtin_clz(x) ^ 0x1f;
#else
static const unsigned int l[] =
@ -119,6 +212,14 @@ static inline unsigned int vkd3d_log2i(unsigned int x)
#endif
}
static inline unsigned int vkd3d_log2i_ceil(unsigned int x)
{
if (x == 1)
return 0;
else
return vkd3d_log2i(x - 1) + 1;
}
static inline int ascii_isupper(int c)
{
return 'A' <= c && c <= 'Z';
@ -142,45 +243,87 @@ static inline int ascii_strcasecmp(const char *a, const char *b)
return c_a - c_b;
}
#ifndef _WIN32
# if HAVE_SYNC_ADD_AND_FETCH
static inline LONG InterlockedIncrement(LONG volatile *x)
static inline bool is_power_of_two(unsigned int x)
{
return __sync_add_and_fetch(x, 1);
return x && !(x & (x -1));
}
# else
# error "InterlockedIncrement() not implemented for this platform"
# endif /* HAVE_SYNC_ADD_AND_FETCH */
# if HAVE_SYNC_SUB_AND_FETCH
static inline LONG InterlockedDecrement(LONG volatile *x)
static inline void vkd3d_parse_version(const char *version, int *major, int *minor, int *patch)
{
return __sync_sub_and_fetch(x, 1);
}
# else
# error "InterlockedDecrement() not implemented for this platform"
# endif
#endif /* _WIN32 */
char *end;
#if HAVE_SYNC_ADD_AND_FETCH
# define atomic_add_fetch(ptr, val) __sync_add_and_fetch(ptr, val)
#elif defined(_MSC_VER)
/* InterlockedAdd returns value after increment, like add_and_fetch. */
# define atomic_add_fetch(ptr, val) InterlockedAdd(ptr, val)
#else
# error "atomic_add_fetch() not implemented for this platform"
#endif /* HAVE_SYNC_ADD_AND_FETCH */
static inline void vkd3d_parse_version(const char *version, int *major, int *minor)
{
*major = atoi(version);
while (isdigit(*version))
++version;
*major = strtol(version, &end, 10);
version = end;
if (*version == '.')
++version;
*minor = strtol(version, &end, 10);
version = end;
if (*version == '.')
++version;
*patch = strtol(version, NULL, 10);
}
*minor = atoi(version);
static inline uint32_t float_bits_to_uint32(float f)
{
uint32_t u;
memcpy(&u, &f, sizeof(u));
return u;
}
static inline size_t vkd3d_wcslen(const WCHAR *wstr)
{
size_t length = 0;
while (true)
{
if (!wstr[length])
return length;
length += 1;
}
}
static inline void *void_ptr_offset(void *ptr, size_t offset)
{
return ((char*)ptr) + offset;
}
#ifdef _MSC_VER
#define VKD3D_THREAD_LOCAL __declspec(thread)
#else
#define VKD3D_THREAD_LOCAL __thread
#endif
static inline uint64_t vkd3d_get_current_time_ns(void)
{
#ifdef _WIN32
LARGE_INTEGER li, lf;
uint64_t whole, part;
QueryPerformanceCounter(&li);
QueryPerformanceFrequency(&lf);
whole = (li.QuadPart / lf.QuadPart) * 1000000000;
part = ((li.QuadPart % lf.QuadPart) * 1000000000) / lf.QuadPart;
return whole + part;
#else
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
return ts.tv_sec * 1000000000ll + ts.tv_nsec;
#endif
}
#ifdef _MSC_VER
#pragma intrinsic(__rdtsc)
#endif
static inline uint64_t vkd3d_get_current_time_ticks(void)
{
#ifdef _MSC_VER
return __rdtsc();
#elif defined(__i386__) || defined(__x86_64__)
return __builtin_ia32_rdtsc();
#else
return vkd3d_get_current_time_ns();
#endif
}
#endif /* __VKD3D_COMMON_H */

View File

@ -26,49 +26,64 @@
#include <stdint.h>
#ifdef VKD3D_NO_TRACE_MESSAGES
#define TRACE(args...) do { } while (0)
#define TRACE(...) do { } while (0)
#define TRACE_ON() (false)
#endif
#ifdef VKD3D_NO_DEBUG_MESSAGES
#define WARN(args...) do { } while (0)
#define FIXME(args...) do { } while (0)
#define WARN(...) do { } while (0)
#define FIXME(...) do { } while (0)
#endif
enum vkd3d_dbg_level
{
VKD3D_DBG_LEVEL_UNKNOWN,
VKD3D_DBG_LEVEL_NONE,
VKD3D_DBG_LEVEL_ERR,
VKD3D_DBG_LEVEL_INFO,
VKD3D_DBG_LEVEL_FIXME,
VKD3D_DBG_LEVEL_WARN,
VKD3D_DBG_LEVEL_TRACE,
};
enum vkd3d_dbg_level vkd3d_dbg_get_level(void) DECLSPEC_HIDDEN;
#ifndef VKD3D_DBG_CHANNEL
#error Must define VKD3D_DBG_CHANNEL to either VKD3D_DBG_CHANNEL_API or SHADER to use vkd3d_debug.h
#endif
void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function,
const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
enum vkd3d_dbg_channel
{
VKD3D_DBG_CHANNEL_API,
VKD3D_DBG_CHANNEL_SHADER,
VKD3D_DBG_CHANNEL_COUNT
};
const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2) DECLSPEC_HIDDEN;
const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args) DECLSPEC_HIDDEN;
const char *debugstr_a(const char *str) DECLSPEC_HIDDEN;
const char *debugstr_w(const WCHAR *wstr, size_t wchar_size) DECLSPEC_HIDDEN;
enum vkd3d_dbg_level vkd3d_dbg_get_level(enum vkd3d_dbg_channel channel);
void vkd3d_dbg_printf(enum vkd3d_dbg_channel channel, enum vkd3d_dbg_level level, const char *function,
const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5);
const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2);
const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args);
const char *debugstr_a(const char *str);
const char *debugstr_w(const WCHAR *wstr);
#define VKD3D_DBG_LOG(level) \
do { \
const enum vkd3d_dbg_channel vkd3d_dbg_channel = VKD3D_DBG_CHANNEL; \
const enum vkd3d_dbg_level vkd3d_dbg_level = VKD3D_DBG_LEVEL_##level; \
VKD3D_DBG_PRINTF
#define VKD3D_DBG_LOG_ONCE(first_time_level, level) \
do { \
static bool vkd3d_dbg_next_time; \
const enum vkd3d_dbg_channel vkd3d_dbg_channel = VKD3D_DBG_CHANNEL; \
const enum vkd3d_dbg_level vkd3d_dbg_level = vkd3d_dbg_next_time \
? VKD3D_DBG_LEVEL_##level : VKD3D_DBG_LEVEL_##first_time_level; \
vkd3d_dbg_next_time = true; \
VKD3D_DBG_PRINTF
#define VKD3D_DBG_PRINTF(...) \
vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0)
vkd3d_dbg_printf(vkd3d_dbg_channel, vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0)
#ifndef TRACE
#define TRACE VKD3D_DBG_LOG(TRACE)
@ -83,15 +98,14 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size) DECLSPEC_HIDDEN;
#endif
#define ERR VKD3D_DBG_LOG(ERR)
#define INFO VKD3D_DBG_LOG(INFO)
#ifndef TRACE_ON
#define TRACE_ON() (vkd3d_dbg_get_level() == VKD3D_DBG_LEVEL_TRACE)
#define TRACE_ON() (vkd3d_dbg_get_level(VKD3D_DBG_CHANNEL) == VKD3D_DBG_LEVEL_TRACE)
#endif
#define FIXME_ONCE VKD3D_DBG_LOG_ONCE(FIXME, WARN)
#define VKD3D_DEBUG_ENV_NAME(name) const char *vkd3d_dbg_env_name = name
static inline const char *debugstr_guid(const GUID *guid)
{
if (!guid)
@ -103,7 +117,7 @@ static inline const char *debugstr_guid(const GUID *guid)
guid->Data4[5], guid->Data4[6], guid->Data4[7]);
}
unsigned int vkd3d_env_var_as_uint(const char *name, unsigned int default_value) DECLSPEC_HIDDEN;
unsigned int vkd3d_env_var_as_uint(const char *name, unsigned int default_value);
struct vkd3d_debug_option
{
@ -111,8 +125,8 @@ struct vkd3d_debug_option
uint64_t flag;
};
bool vkd3d_debug_list_has_member(const char *string, const char *member) DECLSPEC_HIDDEN;
bool vkd3d_debug_list_has_member(const char *string, const char *member);
uint64_t vkd3d_parse_debug_options(const char *string,
const struct vkd3d_debug_option *options, unsigned int option_count) DECLSPEC_HIDDEN;
const struct vkd3d_debug_option *options, unsigned int option_count);
#endif /* __VKD3D_DEBUG_H */

View File

@ -0,0 +1,119 @@
/*
* Copyright 2021 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_DESCRIPTOR_QA_DATA_H
#define __VKD3D_DESCRIPTOR_QA_DATA_H
#include <stdint.h>
/* Data types which are used by shader backends when emitting code. */
enum vkd3d_descriptor_qa_flag_bits
{
VKD3D_DESCRIPTOR_QA_TYPE_NONE_BIT = 0,
VKD3D_DESCRIPTOR_QA_TYPE_SAMPLED_IMAGE_BIT = 1 << 0,
VKD3D_DESCRIPTOR_QA_TYPE_STORAGE_IMAGE_BIT = 1 << 1,
VKD3D_DESCRIPTOR_QA_TYPE_UNIFORM_BUFFER_BIT = 1 << 2,
VKD3D_DESCRIPTOR_QA_TYPE_STORAGE_BUFFER_BIT = 1 << 3,
VKD3D_DESCRIPTOR_QA_TYPE_UNIFORM_TEXEL_BUFFER_BIT = 1 << 4,
VKD3D_DESCRIPTOR_QA_TYPE_STORAGE_TEXEL_BUFFER_BIT = 1 << 5,
VKD3D_DESCRIPTOR_QA_TYPE_RT_ACCELERATION_STRUCTURE_BIT = 1 << 6,
VKD3D_DESCRIPTOR_QA_TYPE_SAMPLER_BIT = 1 << 7,
VKD3D_DESCRIPTOR_QA_TYPE_RAW_VA_BIT = 1 << 8
};
typedef uint32_t vkd3d_descriptor_qa_flags;
struct vkd3d_descriptor_qa_cookie_descriptor
{
uint32_t cookie;
uint32_t descriptor_type;
};
enum vkd3d_descriptor_debug_fault_type
{
VKD3D_DESCRIPTOR_FAULT_TYPE_HEAP_OF_OF_RANGE = 1 << 0,
VKD3D_DESCRIPTOR_FAULT_TYPE_MISMATCH_DESCRIPTOR_TYPE = 1 << 1,
VKD3D_DESCRIPTOR_FAULT_TYPE_DESTROYED_RESOURCE = 1 << 2
};
/* Physical layout of QA buffer. */
struct vkd3d_descriptor_qa_global_buffer_data
{
uint64_t failed_hash;
uint32_t failed_offset;
uint32_t failed_heap;
uint32_t failed_cookie;
uint32_t fault_atomic;
uint32_t failed_instruction;
uint32_t failed_descriptor_type_mask;
uint32_t actual_descriptor_type_mask;
uint32_t fault_type;
uint32_t live_status_table[];
};
/* Physical layout of QA heap buffer. */
struct vkd3d_descriptor_qa_heap_buffer_data
{
uint32_t num_descriptors;
uint32_t heap_index;
struct vkd3d_descriptor_qa_cookie_descriptor desc[];
};
enum vkd3d_descriptor_qa_heap_buffer_data_member
{
VKD3D_DESCRIPTOR_QA_HEAP_MEMBER_NUM_DESCRIPTORS = 0,
VKD3D_DESCRIPTOR_QA_HEAP_MEMBER_HEAP_INDEX,
VKD3D_DESCRIPTOR_QA_HEAP_MEMBER_DESC,
VKD3D_DESCRIPTOR_QA_HEAP_MEMBER_COUNT
};
VKD3D_UNUSED static const char *vkd3d_descriptor_qa_heap_data_names[VKD3D_DESCRIPTOR_QA_HEAP_MEMBER_COUNT] = {
"num_descriptors",
"heap_index",
"desc",
};
enum vkd3d_descriptor_qa_global_buffer_data_member
{
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_FAILED_HASH = 0,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_FAILED_OFFSET,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_FAILED_HEAP,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_FAILED_COOKIE,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_FAULT_ATOMIC,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_FAILED_INSTRUCTION,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_FAILED_DESCRIPTOR_TYPE_MASK,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_ACTUAL_DESCRIPTOR_TYPE_MASK,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_FAULT_TYPE,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_LIVE_STATUS_TABLE,
VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_COUNT
};
VKD3D_UNUSED static const char *vkd3d_descriptor_qa_global_buffer_data_names[VKD3D_DESCRIPTOR_QA_GLOBAL_BUFFER_DATA_MEMBER_COUNT] = {
"failed_hash",
"failed_offset",
"failed_heap",
"failed_cookie",
"fault_atomic",
"failed_instruction",
"failed_descriptor_type_mask",
"actual_descriptor_type_mask",
"fault_type",
"live_status_table",
};
#endif

View File

@ -0,0 +1,42 @@
/*
* Copyright 2022 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_FILE_UTILS_H
#define __VKD3D_FILE_UTILS_H
#include <stddef.h>
#include <stdio.h>
#include <stdbool.h>
struct vkd3d_memory_mapped_file
{
void *mapped;
size_t mapped_size;
};
/* On failure, ensures the struct is cleared to zero.
* A reference to the file is kept through the memory mapping. */
bool vkd3d_file_map_read_only(const char *path, struct vkd3d_memory_mapped_file *file);
/* Clears out file on unmap. */
void vkd3d_file_unmap(struct vkd3d_memory_mapped_file *file);
bool vkd3d_file_rename_overwrite(const char *from_path, const char *to_path);
bool vkd3d_file_rename_no_replace(const char *from_path, const char *to_path);
bool vkd3d_file_delete(const char *path);
FILE *vkd3d_file_open_exclusive_write(const char *path);
#endif

View File

@ -23,6 +23,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include "vkd3d_common.h"
#include "vkd3d_debug.h"
static inline void *vkd3d_malloc(size_t size)
@ -55,6 +56,24 @@ static inline void vkd3d_free(void *ptr)
}
bool vkd3d_array_reserve(void **elements, size_t *capacity,
size_t element_count, size_t element_size) DECLSPEC_HIDDEN;
size_t element_count, size_t element_size);
static inline void *vkd3d_malloc_aligned(size_t size, size_t alignment)
{
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#else
return aligned_alloc(alignment, align(size, alignment));
#endif
}
static inline void vkd3d_free_aligned(void *ptr)
{
#ifdef _WIN32
_aligned_free(ptr);
#else
free(ptr);
#endif
}
#endif /* __VKD3D_MEMORY_H */

View File

@ -0,0 +1,44 @@
/*
* Copyright 2020 Joshua Ashton for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_PLATFORM_H
#define __VKD3D_PLATFORM_H
#include "vkd3d_common.h"
#if defined(_WIN32)
#define VKD3D_PATH_MAX _MAX_PATH
#else
#define VKD3D_PATH_MAX PATH_MAX
#endif
typedef void* vkd3d_module_t;
vkd3d_module_t vkd3d_dlopen(const char *name);
void *vkd3d_dlsym(vkd3d_module_t handle, const char *symbol);
int vkd3d_dlclose(vkd3d_module_t handle);
const char *vkd3d_dlerror(void);
bool vkd3d_get_env_var(const char *name, char *value, size_t value_size);
bool vkd3d_get_program_name(char program_name[VKD3D_PATH_MAX]);
#endif

View File

@ -0,0 +1,64 @@
/*
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_PROFILING_H
#define __VKD3D_PROFILING_H
#include "vkd3d_windows.h"
#include "vkd3d_spinlock.h"
#include "vkd3d_common.h"
#ifdef VKD3D_ENABLE_PROFILING
void vkd3d_init_profiling(void);
bool vkd3d_uses_profiling(void);
unsigned int vkd3d_profiling_register_region(const char *name, spinlock_t *lock, uint32_t *latch);
void vkd3d_profiling_notify_work(unsigned int index, uint64_t start_ticks, uint64_t end_ticks, unsigned int iteration_count);
#define VKD3D_REGION_DECL(name) \
static uint32_t _vkd3d_region_latch_##name; \
static spinlock_t _vkd3d_region_lock_##name; \
uint64_t _vkd3d_region_begin_tick_##name; \
uint64_t _vkd3d_region_end_tick_##name; \
unsigned int _vkd3d_region_index_##name
#define VKD3D_REGION_BEGIN(name) \
do { \
if (!(_vkd3d_region_index_##name = vkd3d_atomic_uint32_load_explicit(&_vkd3d_region_latch_##name, vkd3d_memory_order_acquire))) \
_vkd3d_region_index_##name = vkd3d_profiling_register_region(#name, &_vkd3d_region_lock_##name, &_vkd3d_region_latch_##name); \
_vkd3d_region_begin_tick_##name = vkd3d_get_current_time_ticks(); \
} while(0)
#define VKD3D_REGION_END_ITERATIONS(name, iter) \
do { \
_vkd3d_region_end_tick_##name = vkd3d_get_current_time_ticks(); \
vkd3d_profiling_notify_work(_vkd3d_region_index_##name, _vkd3d_region_begin_tick_##name, _vkd3d_region_end_tick_##name, iter); \
} while(0)
#else
static inline void vkd3d_init_profiling(void)
{
}
#define VKD3D_REGION_DECL(name) ((void)0)
#define VKD3D_REGION_BEGIN(name) ((void)0)
#define VKD3D_REGION_END_ITERATIONS(name, iter) ((void)0)
#endif /* VKD3D_ENABLE_PROFILING */
#define VKD3D_REGION_END(name) VKD3D_REGION_END_ITERATIONS(name, 1)
#endif /* __VKD3D_PROFILING_H */

View File

@ -0,0 +1,59 @@
/*
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_RW_SPINLOCK_H
#define __VKD3D_RW_SPINLOCK_H
#include "vkd3d_spinlock.h"
#define VKD3D_RW_SPINLOCK_WRITE 1u
#define VKD3D_RW_SPINLOCK_READ 2u
#define VKD3D_RW_SPINLOCK_IDLE 0u
static inline void rw_spinlock_acquire_read(spinlock_t *spinlock)
{
uint32_t count = vkd3d_atomic_uint32_add(spinlock, VKD3D_RW_SPINLOCK_READ, vkd3d_memory_order_acquire);
while (count & VKD3D_RW_SPINLOCK_WRITE)
{
vkd3d_pause();
count = vkd3d_atomic_uint32_load_explicit(spinlock, vkd3d_memory_order_acquire);
}
}
static inline void rw_spinlock_release_read(spinlock_t *spinlock)
{
vkd3d_atomic_uint32_sub(spinlock, VKD3D_RW_SPINLOCK_READ, vkd3d_memory_order_release);
}
static inline void rw_spinlock_acquire_write(spinlock_t *spinlock)
{
while (vkd3d_atomic_uint32_load_explicit(spinlock, vkd3d_memory_order_relaxed) != VKD3D_RW_SPINLOCK_IDLE ||
vkd3d_atomic_uint32_compare_exchange(spinlock,
VKD3D_RW_SPINLOCK_IDLE, VKD3D_RW_SPINLOCK_WRITE,
vkd3d_memory_order_acquire, vkd3d_memory_order_relaxed) != VKD3D_RW_SPINLOCK_IDLE)
{
vkd3d_pause();
}
}
static inline void rw_spinlock_release_write(spinlock_t *spinlock)
{
vkd3d_atomic_uint32_and(spinlock, ~VKD3D_RW_SPINLOCK_WRITE, vkd3d_memory_order_release);
}
#endif

View File

@ -0,0 +1,67 @@
/*
* Copyright 2020 Philip Rebohle for Valve Corporation
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_SPINLOCK_H
#define __VKD3D_SPINLOCK_H
#include <stdint.h>
#include <stdbool.h>
#include "vkd3d_atomic.h"
#ifdef __SSE2__
#include <emmintrin.h>
#endif
static inline void vkd3d_pause(void)
{
#ifdef __SSE2__
_mm_pause();
#endif
}
#define vkd3d_spinlock_try_lock(lock) \
(!vkd3d_atomic_uint32_load_explicit(lock, vkd3d_memory_order_relaxed) && \
!vkd3d_atomic_uint32_exchange_explicit(lock, 1u, vkd3d_memory_order_acquire))
#define vkd3d_spinlock_unlock(lock) vkd3d_atomic_uint32_store_explicit(lock, 0u, vkd3d_memory_order_release)
typedef uint32_t spinlock_t;
static inline void spinlock_init(spinlock_t *lock)
{
*lock = 0;
}
static inline bool spinlock_try_acquire(spinlock_t *lock)
{
return vkd3d_spinlock_try_lock(lock);
}
static inline void spinlock_acquire(spinlock_t *lock)
{
while (!spinlock_try_acquire(lock))
vkd3d_pause();
}
static inline void spinlock_release(spinlock_t *lock)
{
vkd3d_spinlock_unlock(lock);
}
#endif

View File

@ -0,0 +1,82 @@
/*
* Copyright 2021 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_STRING_H
#define __VKD3D_STRING_H
#include "vkd3d_common.h"
#include <stddef.h>
/* Various string utilities. */
WCHAR *vkd3d_dup_entry_point(const char *str);
WCHAR *vkd3d_dup_entry_point_n(const char *str, size_t len);
WCHAR *vkd3d_dup_demangled_entry_point(const char *str);
char *vkd3d_dup_demangled_entry_point_ascii(const char *str);
bool vkd3d_export_strequal(const WCHAR *a, const WCHAR *b);
bool vkd3d_export_strequal_mixed(const WCHAR *a, const char *b);
bool vkd3d_export_strequal_substr(const WCHAR *a, size_t n, const WCHAR *b);
char *vkd3d_strdup(const char *str);
char *vkd3d_strdup_n(const char *str, size_t n);
WCHAR *vkd3d_wstrdup(const WCHAR *str);
WCHAR *vkd3d_wstrdup_n(const WCHAR *str, size_t n);
static inline bool vkd3d_string_ends_with_n(const char *str, size_t str_len, const char *ending, size_t ending_len)
{
return str_len >= ending_len && !strncmp(str + (str_len - ending_len), ending, ending_len);
}
static inline bool vkd3d_string_ends_with(const char *str, const char *ending)
{
return vkd3d_string_ends_with_n(str, strlen(str), ending, strlen(ending));
}
enum vkd3d_string_compare_mode
{
VKD3D_STRING_COMPARE_NEVER,
VKD3D_STRING_COMPARE_ALWAYS,
VKD3D_STRING_COMPARE_EXACT,
VKD3D_STRING_COMPARE_STARTS_WITH,
VKD3D_STRING_COMPARE_ENDS_WITH,
VKD3D_STRING_COMPARE_CONTAINS,
};
static inline bool vkd3d_string_compare(enum vkd3d_string_compare_mode mode, const char *string, const char *comparator)
{
switch (mode)
{
default:
case VKD3D_STRING_COMPARE_NEVER:
return false;
case VKD3D_STRING_COMPARE_ALWAYS:
return true;
case VKD3D_STRING_COMPARE_EXACT:
return !strcmp(string, comparator);
case VKD3D_STRING_COMPARE_STARTS_WITH:
return !strncmp(string, comparator, strlen(comparator));
case VKD3D_STRING_COMPARE_ENDS_WITH:
return vkd3d_string_ends_with(string, comparator);
case VKD3D_STRING_COMPARE_CONTAINS:
return strstr(string, comparator) != NULL;
}
}
#endif /* __VKD3D_STRING_H */

View File

@ -20,6 +20,7 @@
#define __VKD3D_TEST_H
#include "vkd3d_common.h"
#include "vkd3d_debug.h"
#include <assert.h>
#include <inttypes.h>
#include <stdarg.h>
@ -28,16 +29,19 @@
#include <stdlib.h>
#include <string.h>
#ifdef VKD3D_TEST_DECLARE_MAIN
static void vkd3d_test_main(int argc, char **argv);
static const char *vkd3d_test_name;
static const char *vkd3d_test_platform = "other";
#endif
extern const char *vkd3d_test_name;
extern const char *vkd3d_test_platform;
static void vkd3d_test_start_todo(bool is_todo);
static int vkd3d_test_loop_todo(void);
static void vkd3d_test_end_todo(void);
#define START_TEST(name) \
static const char *vkd3d_test_name = #name; \
const char *vkd3d_test_name = #name; \
static void vkd3d_test_main(int argc, char **argv)
/*
@ -100,7 +104,7 @@ static void vkd3d_test_end_todo(void);
#define todo todo_if(true)
static struct
struct vkd3d_test_state_context
{
LONG success_count;
LONG failure_count;
@ -119,8 +123,10 @@ static struct
bool bug_enabled;
const char *test_name_filter;
const char *test_exclude_list;
char context[1024];
} vkd3d_test_state;
};
extern struct vkd3d_test_state_context vkd3d_test_state;
static bool
vkd3d_test_platform_is_windows(void)
@ -141,13 +147,17 @@ vkd3d_test_check_assert_that(unsigned int line, bool result, const char *fmt, va
{
InterlockedIncrement(&vkd3d_test_state.success_count);
if (vkd3d_test_state.debug_level > 1)
{
printf("%s:%d%s: Test succeeded.\n", vkd3d_test_name, line, vkd3d_test_state.context);
fflush(stdout);
}
}
else
{
InterlockedIncrement(&vkd3d_test_state.failure_count);
printf("%s:%d%s: Test failed: ", vkd3d_test_name, line, vkd3d_test_state.context);
vprintf(fmt, args);
fflush(stdout);
}
}
@ -177,6 +187,7 @@ vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list arg
else
printf("%s:%d%s: Bug: ", vkd3d_test_name, line, vkd3d_test_state.context);
vprintf(fmt, args);
fflush(stdout);
}
else if (is_todo)
{
@ -191,6 +202,7 @@ vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list arg
printf("%s:%d%s: Todo: ", vkd3d_test_name, line, vkd3d_test_state.context);
}
vprintf(fmt, args);
fflush(stdout);
}
else
{
@ -217,6 +229,7 @@ vkd3d_test_skip(unsigned int line, const char *fmt, ...)
vprintf(fmt, args);
va_end(args);
InterlockedIncrement(&vkd3d_test_state.skip_count);
fflush(stdout);
}
static void VKD3D_PRINTF_FUNC(2, 3) VKD3D_UNUSED
@ -227,6 +240,7 @@ vkd3d_test_trace(unsigned int line, const char *fmt, ...)
printf("%s:%d%s: ", vkd3d_test_name, line, vkd3d_test_state.context);
vprintf(fmt, args);
va_end(args);
fflush(stdout);
}
static void VKD3D_PRINTF_FUNC(1, 2) VKD3D_UNUSED
@ -237,7 +251,7 @@ vkd3d_test_debug(const char *fmt, ...)
int size;
size = snprintf(buffer, sizeof(buffer), "%s: ", vkd3d_test_name);
if (0 < size && size < sizeof(buffer))
if (0 < size && size < (int)sizeof(buffer))
{
va_start(args, fmt);
vsnprintf(buffer + size, sizeof(buffer) - size, fmt, args);
@ -250,20 +264,26 @@ vkd3d_test_debug(const char *fmt, ...)
#endif
if (vkd3d_test_state.debug_level > 0)
{
printf("%s\n", buffer);
fflush(stdout);
}
}
#ifdef VKD3D_TEST_DECLARE_MAIN
int main(int argc, char **argv)
{
const char *exclude_list = getenv("VKD3D_TEST_EXCLUDE");
const char *test_filter = getenv("VKD3D_TEST_FILTER");
const char *debug_level = getenv("VKD3D_TEST_DEBUG");
char *test_platform = getenv("VKD3D_TEST_PLATFORM");
const char *bug = getenv("VKD3D_TEST_BUG");
memset(&vkd3d_test_state, 0, sizeof(vkd3d_test_state));
vkd3d_test_state.debug_level = debug_level ? atoi(debug_level) : 0;
vkd3d_test_state.debug_level = debug_level ? atoi(debug_level) : 1;
vkd3d_test_state.bug_enabled = bug ? atoi(bug) : true;
vkd3d_test_state.test_name_filter = test_filter;
vkd3d_test_state.test_exclude_list = exclude_list;
if (test_platform)
{
@ -276,13 +296,13 @@ int main(int argc, char **argv)
vkd3d_test_main(argc, argv);
printf("%s: %lu tests executed (%lu failures, %lu skipped, %lu todo, %lu bugs).\n",
printf("%s: %lu tests executed (%lu failures, %lu successful todo, %lu skipped, %lu todo, %lu bugs).\n",
vkd3d_test_name,
(unsigned long)(vkd3d_test_state.success_count
+ vkd3d_test_state.failure_count + vkd3d_test_state.todo_count
+ vkd3d_test_state.todo_success_count),
(unsigned long)(vkd3d_test_state.failure_count
+ vkd3d_test_state.todo_success_count),
(unsigned long)vkd3d_test_state.failure_count,
(unsigned long)vkd3d_test_state.todo_success_count,
(unsigned long)vkd3d_test_state.skip_count,
(unsigned long)vkd3d_test_state.todo_count,
(unsigned long)vkd3d_test_state.bug_count);
@ -290,7 +310,8 @@ int main(int argc, char **argv)
if (test_platform)
free(test_platform);
return vkd3d_test_state.failure_count || vkd3d_test_state.todo_success_count;
fflush(stdout);
return vkd3d_test_state.failure_count != 0;
}
#ifdef _WIN32
@ -339,16 +360,27 @@ int wmain(int argc, WCHAR **wargv)
return ret;
}
#endif /* _WIN32 */
#endif /* VKD3D_TEST_DECLARE_MAIN */
typedef void (*vkd3d_test_pfn)(void);
static inline void vkd3d_run_test(const char *name, vkd3d_test_pfn test_pfn)
{
const char *old_test_name;
if (vkd3d_test_state.test_name_filter && !strstr(name, vkd3d_test_state.test_name_filter))
return;
vkd3d_test_debug("%s", name);
if (vkd3d_test_state.test_exclude_list
&& vkd3d_debug_list_has_member(vkd3d_test_state.test_exclude_list, name))
return;
old_test_name = vkd3d_test_name;
vkd3d_test_debug("======== %s begin ========", name);
vkd3d_test_name = name;
test_pfn();
vkd3d_test_name = old_test_name;
vkd3d_test_debug("======== %s end ==========", name);
}
static inline void vkd3d_test_start_todo(bool is_todo)

View File

@ -0,0 +1,351 @@
/*
* Copyright 2019 Hans-Kristian Arntzen for Valve
*
* 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
*/
#ifndef __VKD3D_THREADS_H
#define __VKD3D_THREADS_H
#include "vkd3d_memory.h"
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/* pthread_t is passed by value in some functions,
* which implies we need pthread_t to be a pointer type here. */
struct pthread
{
HANDLE thread;
DWORD id;
void * (*routine)(void *);
void *arg;
};
typedef struct pthread *pthread_t;
/* pthread_mutex_t is not copyable, so embed CS inline. */
typedef struct pthread_mutex
{
SRWLOCK lock;
} pthread_mutex_t;
#define PTHREAD_MUTEX_INITIALIZER {SRWLOCK_INIT}
/* pthread_cond_t is not copyable, so embed CV inline. */
typedef struct pthread_cond
{
CONDITION_VARIABLE cond;
} pthread_cond_t;
typedef pthread_cond_t condvar_reltime_t;
static DWORD WINAPI win32_thread_wrapper_routine(void *arg)
{
pthread_t thread = arg;
thread->routine(thread->arg);
return 0;
}
static inline int pthread_create(pthread_t *out_thread, void *attr, void * (*thread_fun)(void *), void *arg)
{
pthread_t thread = vkd3d_calloc(1, sizeof(*thread));
if (!thread)
return -1;
(void)attr;
thread->routine = thread_fun;
thread->arg = arg;
thread->thread = CreateThread(NULL, 0, win32_thread_wrapper_routine, thread, 0, &thread->id);
if (!thread->thread)
{
vkd3d_free(thread);
return -1;
}
*out_thread = thread;
return 0;
}
static inline int pthread_join(pthread_t thread, void **ret)
{
int success;
(void)ret;
success = WaitForSingleObject(thread->thread, INFINITE) == WAIT_OBJECT_0;
if (success)
{
CloseHandle(thread->thread);
vkd3d_free(thread);
}
return success ? 0 : -1;
}
static inline int pthread_mutex_init(pthread_mutex_t *lock, void *attr)
{
(void)attr;
InitializeSRWLock(&lock->lock);
return 0;
}
static inline int pthread_mutex_lock(pthread_mutex_t *lock)
{
AcquireSRWLockExclusive(&lock->lock);
return 0;
}
static inline int pthread_mutex_unlock(pthread_mutex_t *lock)
{
ReleaseSRWLockExclusive(&lock->lock);
return 0;
}
static inline int pthread_mutex_destroy(pthread_mutex_t *lock)
{
return 0;
}
/* SRWLocks distinguish between write and read unlocks, but pthread interface does not,
* so make a trivial wrapper type instead to avoid any possible API conflicts. */
typedef struct rwlock
{
SRWLOCK rwlock;
} rwlock_t;
static inline int rwlock_init(rwlock_t *lock)
{
InitializeSRWLock(&lock->rwlock);
return 0;
}
static inline int rwlock_lock_write(rwlock_t *lock)
{
AcquireSRWLockExclusive(&lock->rwlock);
return 0;
}
static inline int rwlock_lock_read(rwlock_t *lock)
{
AcquireSRWLockShared(&lock->rwlock);
return 0;
}
static inline int rwlock_unlock_write(rwlock_t *lock)
{
ReleaseSRWLockExclusive(&lock->rwlock);
return 0;
}
static inline int rwlock_unlock_read(rwlock_t *lock)
{
ReleaseSRWLockShared(&lock->rwlock);
return 0;
}
static inline int rwlock_destroy(rwlock_t *lock)
{
return 0;
}
static inline int pthread_cond_init(pthread_cond_t *cond, void *attr)
{
(void)attr;
InitializeConditionVariable(&cond->cond);
return 0;
}
static inline int pthread_cond_destroy(pthread_cond_t *cond)
{
(void)cond;
return 0;
}
static inline int pthread_cond_signal(pthread_cond_t *cond)
{
WakeConditionVariable(&cond->cond);
return 0;
}
static inline int pthread_cond_broadcast(pthread_cond_t *cond)
{
WakeAllConditionVariable(&cond->cond);
return 0;
}
static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *lock)
{
BOOL ret = SleepConditionVariableSRW(&cond->cond, &lock->lock, INFINITE, 0);
return ret ? 0 : -1;
}
static inline int condvar_reltime_init(condvar_reltime_t *cond)
{
return pthread_cond_init(cond, NULL);
}
static inline int condvar_reltime_destroy(condvar_reltime_t *cond)
{
return pthread_cond_destroy(cond);
}
static inline int condvar_reltime_signal(condvar_reltime_t *cond)
{
return pthread_cond_signal(cond);
}
static inline int condvar_reltime_wait_timeout_seconds(condvar_reltime_t *cond, pthread_mutex_t *lock, unsigned int seconds)
{
BOOL ret = SleepConditionVariableSRW(&cond->cond, &lock->lock, seconds * 1000, 0);
if (ret)
return 0;
else if (GetLastError() == ERROR_TIMEOUT)
return 1;
else
return -1;
}
static inline void vkd3d_set_thread_name(const char *name)
{
(void)name;
}
typedef INIT_ONCE pthread_once_t;
#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
static inline BOOL CALLBACK pthread_once_wrapper(PINIT_ONCE once, PVOID parameter, PVOID *context)
{
void (*func)(void) = parameter;
(void)once;
(void)context;
func();
return TRUE;
}
static inline void pthread_once(pthread_once_t *once, void (*func)(void))
{
InitOnceExecuteOnce(once, pthread_once_wrapper, func, NULL);
}
#else
#include <pthread.h>
#include <errno.h>
#include <time.h>
static inline void vkd3d_set_thread_name(const char *name)
{
pthread_setname_np(pthread_self(), name);
}
typedef struct rwlock
{
pthread_rwlock_t rwlock;
} rwlock_t;
static inline int rwlock_init(rwlock_t *lock)
{
return pthread_rwlock_init(&lock->rwlock, NULL);
}
static inline int rwlock_lock_write(rwlock_t *lock)
{
return pthread_rwlock_wrlock(&lock->rwlock);
}
static inline int rwlock_lock_read(rwlock_t *lock)
{
return pthread_rwlock_rdlock(&lock->rwlock);
}
static inline int rwlock_unlock_write(rwlock_t *lock)
{
return pthread_rwlock_unlock(&lock->rwlock);
}
static inline int rwlock_unlock_read(rwlock_t *lock)
{
return pthread_rwlock_unlock(&lock->rwlock);
}
static inline int rwlock_destroy(rwlock_t *lock)
{
return pthread_rwlock_destroy(&lock->rwlock);
}
typedef struct condvar_reltime
{
pthread_cond_t cond;
} condvar_reltime_t;
static inline int condvar_reltime_init(condvar_reltime_t *cond)
{
pthread_condattr_t attr;
int rc;
pthread_condattr_init(&attr);
pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
rc = pthread_cond_init(&cond->cond, &attr);
pthread_condattr_destroy(&attr);
return rc;
}
static inline void condvar_reltime_destroy(condvar_reltime_t *cond)
{
pthread_cond_destroy(&cond->cond);
}
static inline int condvar_reltime_signal(condvar_reltime_t *cond)
{
return pthread_cond_signal(&cond->cond);
}
static inline int condvar_reltime_wait_timeout_seconds(condvar_reltime_t *cond, pthread_mutex_t *lock, unsigned int seconds)
{
struct timespec ts;
int rc;
clock_gettime(CLOCK_MONOTONIC, &ts);
ts.tv_sec += seconds;
/* This is absolute time. */
rc = pthread_cond_timedwait(&cond->cond, lock, &ts);
if (rc == ETIMEDOUT)
return 1;
else if (rc == 0)
return 0;
else
return -1;
}
#define PTHREAD_ONCE_CALLBACK
#endif
#ifdef __linux__
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>
#endif
static inline unsigned int vkd3d_get_current_thread_id(void)
{
#ifdef _WIN32
return GetCurrentThreadId();
#elif defined(__linux__)
return syscall(__NR_gettid);
#else
return 0;
#endif
}
#endif /* __VKD3D_THREADS_H */

View File

@ -21,6 +21,8 @@
#include "vkd3d_common.h"
char *vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t wchar_size) DECLSPEC_HIDDEN;
/* max_elements is 0 if only nul-terminator should be used.
* Otherwise, terminate the string after either a nul-termination byte or max_elements. */
char *vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t max_elements);
#endif /* __VKD3D_UTF8_H */

View File

@ -0,0 +1,6 @@
#ifndef __VULKAN_PRIVATE_EXTENSIONS_H__
#define __VULKAN_PRIVATE_EXTENSIONS_H__
/* Nothing here at the moment. Add hacks here! */
#endif

View File

@ -0,0 +1,71 @@
INCLUDE_DIR := $(CURDIR)
VERT_SOURCES := $(wildcard $(M)/*.vert)
FRAG_SOURCES := $(wildcard $(M)/*.frag)
COMP_SOURCES := $(wildcard $(M)/*.comp)
TESC_SOURCES := $(wildcard $(M)/*.tesc)
TESE_SOURCES := $(wildcard $(M)/*.tese)
GEOM_SOURCES := $(wildcard $(M)/*.geom)
RGEN_SOURCES := $(wildcard $(M)/*.rgen)
RINT_SOURCES := $(wildcard $(M)/*.rint)
RAHIT_SOURCES := $(wildcard $(M)/*.rahit)
RCHIT_SOURCES := $(wildcard $(M)/*.rchit)
RMISS_SOURCES := $(wildcard $(M)/*.rmiss)
RCALL_SOURCES := $(wildcard $(M)/*.rcall)
SPV_OBJECTS := \
$(VERT_SOURCES:.vert=.spv) \
$(FRAG_SOURCES:.frag=.spv) \
$(COMP_SOURCES:.comp=.spv) \
$(TESC_SOURCES:.tesc=.spv) \
$(TESE_SOURCES:.tese=.spv) \
$(GEOM_SOURCES:.geom=.spv) \
$(RGEN_SOURCES:.rgen=.spv) \
$(RINT_SOURCES:.rint=.spv) \
$(RAHIT_SOURCES:.rahit=.spv) \
$(RCHIT_SOURCES:.rchit=.spv) \
$(RMISS_SOURCES:.rmiss=.spv) \
$(RCALL_SOURCES:.rcall=.spv)
%.spv: %.vert
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 $(GLSLC_FLAGS)
%.spv: %.frag
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 -DDEBUG_CHANNEL_HELPER_LANES $(GLSLC_FLAGS)
%.spv: %.comp
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 $(GLSLC_FLAGS)
%.spv: %.geom
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 $(GLSLC_FLAGS)
%.spv: %.tesc
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 $(GLSLC_FLAGS)
%.spv: %.tese
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 $(GLSLC_FLAGS)
%.spv: %.rgen
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 --target-spv=spv1.4 $(GLSLC_FLAGS)
%.spv: %.rint
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 --target-spv=spv1.4 $(GLSLC_FLAGS)
%.spv: %.rahit
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 --target-spv=spv1.4 $(GLSLC_FLAGS)
%.spv: %.rchit
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 --target-spv=spv1.4 $(GLSLC_FLAGS)
%.spv: %.rmiss
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 --target-spv=spv1.4 $(GLSLC_FLAGS)
%.spv: %.rcall
glslc -o $@ $< -I$(INCLUDE_DIR) --target-env=vulkan1.1 --target-spv=spv1.4 $(GLSLC_FLAGS)
all: $(SPV_OBJECTS)
clean:
rm -f $(SPV_OBJECTS)
.PHONY: clean

View File

@ -0,0 +1,338 @@
/*
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef DEBUG_CHANNEL_H_
#define DEBUG_CHANNEL_H_
#extension GL_EXT_buffer_reference : require
#extension GL_ARB_gpu_shader_int64 : require
#extension GL_KHR_shader_subgroup_basic : require
#extension GL_KHR_shader_subgroup_ballot : require
#ifdef DEBUG_CHANNEL_HELPER_LANES
#extension GL_EXT_demote_to_helper_invocation : require
#endif
layout(buffer_reference, std430, buffer_reference_align = 4) coherent buffer ControlBlock
{
uint message_counter;
uint instance_counter;
};
layout(buffer_reference, std430, buffer_reference_align = 4) coherent buffer RingBuffer
{
uint data[];
};
layout(constant_id = 0) const uint64_t DEBUG_SHADER_HASH = 0;
layout(constant_id = 1) const uint64_t DEBUG_SHADER_ATOMIC_BDA = 0;
layout(constant_id = 2) const uint64_t DEBUG_SHADER_RING_BDA = 0;
layout(constant_id = 3) const uint DEBUG_SHADER_RING_SIZE = 0;
const uint DEBUG_SHADER_RING_MASK = DEBUG_SHADER_RING_SIZE - 1;
const bool DEBUG_SHADER_RING_ACTIVE = DEBUG_SHADER_ATOMIC_BDA != 0;
const uint DEBUG_CHANNEL_FMT_HEX = 0;
const uint DEBUG_CHANNEL_FMT_I32 = 1;
const uint DEBUG_CHANNEL_FMT_F32 = 2;
const uint DEBUG_CHANNEL_FMT_HEX_ALL = DEBUG_CHANNEL_FMT_HEX * 0x55555555u;
const uint DEBUG_CHANNEL_FMT_I32_ALL = DEBUG_CHANNEL_FMT_I32 * 0x55555555u;
const uint DEBUG_CHANNEL_FMT_F32_ALL = DEBUG_CHANNEL_FMT_F32 * 0x55555555u;
const uint DEBUG_CHANNEL_WORD_COOKIE = 0xdeadca70u; /* Let host fish for this cookie in device lost scenarios. */
uint DEBUG_CHANNEL_INSTANCE_COUNTER;
uvec3 DEBUG_CHANNEL_ID;
/* Need to make sure the elected subgroup can have side effects. */
#ifdef DEBUG_CHANNEL_HELPER_LANES
bool DEBUG_CHANNEL_ELECT()
{
bool elected = false;
if (!helperInvocationEXT())
elected = subgroupElect();
return elected;
}
#else
bool DEBUG_CHANNEL_ELECT()
{
return subgroupElect();
}
#endif
void DEBUG_CHANNEL_INIT(uvec3 id)
{
if (!DEBUG_SHADER_RING_ACTIVE)
return;
DEBUG_CHANNEL_ID = id;
uint inst;
#ifdef DEBUG_CHANNEL_HELPER_LANES
if (!helperInvocationEXT())
{
/* Elect and broadcast must happen without helper lanes here.
* We must perform the instance increment with side effects,
* and broadcast first must pick the elected lane. */
if (subgroupElect())
inst = atomicAdd(ControlBlock(DEBUG_SHADER_ATOMIC_BDA).instance_counter, 1u);
DEBUG_CHANNEL_INSTANCE_COUNTER = subgroupBroadcastFirst(inst);
}
/* Helper lanes cannot write debug messages, since they cannot have side effects.
* Leave it undefined, and we should ensure SGPR propagation either way ... */
#else
if (DEBUG_CHANNEL_ELECT())
inst = atomicAdd(ControlBlock(DEBUG_SHADER_ATOMIC_BDA).instance_counter, 1u);
DEBUG_CHANNEL_INSTANCE_COUNTER = subgroupBroadcastFirst(inst);
#endif
}
void DEBUG_CHANNEL_INIT_IMPLICIT_INSTANCE(uvec3 id, uint inst)
{
if (!DEBUG_SHADER_RING_ACTIVE)
return;
DEBUG_CHANNEL_ID = id;
DEBUG_CHANNEL_INSTANCE_COUNTER = inst;
}
void DEBUG_CHANNEL_UNLOCK_MESSAGE(RingBuffer buf, uint offset, uint num_words)
{
memoryBarrierBuffer();
/* Make sure this word is made visible last. This way the ring thread can avoid reading bogus messages.
* If the host thread observed a num_word of 0, we know a message was allocated, but we don't necessarily
* have a complete write yet.
* In a device lost scenario, we can try to fish for valid messages. */
buf.data[(offset + 0) & DEBUG_SHADER_RING_MASK] = num_words | DEBUG_CHANNEL_WORD_COOKIE;
memoryBarrierBuffer();
}
void DEBUG_CHANNEL_WRITE_HEADER(RingBuffer buf, uint offset, uint fmt)
{
buf.data[(offset + 1) & DEBUG_SHADER_RING_MASK] = uint(DEBUG_SHADER_HASH);
buf.data[(offset + 2) & DEBUG_SHADER_RING_MASK] = uint(DEBUG_SHADER_HASH >> 32);
buf.data[(offset + 3) & DEBUG_SHADER_RING_MASK] = DEBUG_CHANNEL_INSTANCE_COUNTER;
buf.data[(offset + 4) & DEBUG_SHADER_RING_MASK] = DEBUG_CHANNEL_ID.x;
buf.data[(offset + 5) & DEBUG_SHADER_RING_MASK] = DEBUG_CHANNEL_ID.y;
buf.data[(offset + 6) & DEBUG_SHADER_RING_MASK] = DEBUG_CHANNEL_ID.z;
buf.data[(offset + 7) & DEBUG_SHADER_RING_MASK] = fmt;
}
uint DEBUG_CHANNEL_ALLOCATE(uint words)
{
uint offset = atomicAdd(ControlBlock(DEBUG_SHADER_ATOMIC_BDA).message_counter, words);
return offset;
}
void DEBUG_CHANNEL_MSG_()
{
if (!DEBUG_SHADER_RING_ACTIVE)
return;
uint words = 8;
uint offset = DEBUG_CHANNEL_ALLOCATE(words);
RingBuffer buf = RingBuffer(DEBUG_SHADER_RING_BDA);
DEBUG_CHANNEL_WRITE_HEADER(buf, offset, 0);
DEBUG_CHANNEL_UNLOCK_MESSAGE(buf, offset, words);
}
void DEBUG_CHANNEL_MSG_(uint fmt, uint v0)
{
if (!DEBUG_SHADER_RING_ACTIVE)
return;
RingBuffer buf = RingBuffer(DEBUG_SHADER_RING_BDA);
uint words = 9;
uint offset = DEBUG_CHANNEL_ALLOCATE(words);
DEBUG_CHANNEL_WRITE_HEADER(buf, offset, fmt);
buf.data[(offset + 8) & DEBUG_SHADER_RING_MASK] = v0;
DEBUG_CHANNEL_UNLOCK_MESSAGE(buf, offset, words);
}
void DEBUG_CHANNEL_MSG_(uint fmt, uint v0, uint v1)
{
if (!DEBUG_SHADER_RING_ACTIVE)
return;
RingBuffer buf = RingBuffer(DEBUG_SHADER_RING_BDA);
uint words = 10;
uint offset = DEBUG_CHANNEL_ALLOCATE(words);
DEBUG_CHANNEL_WRITE_HEADER(buf, offset, fmt);
buf.data[(offset + 8) & DEBUG_SHADER_RING_MASK] = v0;
buf.data[(offset + 9) & DEBUG_SHADER_RING_MASK] = v1;
DEBUG_CHANNEL_UNLOCK_MESSAGE(buf, offset, words);
}
void DEBUG_CHANNEL_MSG_(uint fmt, uint v0, uint v1, uint v2)
{
if (!DEBUG_SHADER_RING_ACTIVE)
return;
RingBuffer buf = RingBuffer(DEBUG_SHADER_RING_BDA);
uint words = 11;
uint offset = DEBUG_CHANNEL_ALLOCATE(words);
DEBUG_CHANNEL_WRITE_HEADER(buf, offset, fmt);
buf.data[(offset + 8) & DEBUG_SHADER_RING_MASK] = v0;
buf.data[(offset + 9) & DEBUG_SHADER_RING_MASK] = v1;
buf.data[(offset + 10) & DEBUG_SHADER_RING_MASK] = v2;
DEBUG_CHANNEL_UNLOCK_MESSAGE(buf, offset, words);
}
void DEBUG_CHANNEL_MSG_(uint fmt, uint v0, uint v1, uint v2, uint v3)
{
if (!DEBUG_SHADER_RING_ACTIVE)
return;
RingBuffer buf = RingBuffer(DEBUG_SHADER_RING_BDA);
uint words = 12;
uint offset = DEBUG_CHANNEL_ALLOCATE(words);
DEBUG_CHANNEL_WRITE_HEADER(buf, offset, fmt);
buf.data[(offset + 8) & DEBUG_SHADER_RING_MASK] = v0;
buf.data[(offset + 9) & DEBUG_SHADER_RING_MASK] = v1;
buf.data[(offset + 10) & DEBUG_SHADER_RING_MASK] = v2;
buf.data[(offset + 11) & DEBUG_SHADER_RING_MASK] = v3;
DEBUG_CHANNEL_UNLOCK_MESSAGE(buf, offset, words);
}
void DEBUG_CHANNEL_MSG()
{
DEBUG_CHANNEL_MSG_();
}
void DEBUG_CHANNEL_MSG(uint v0)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_HEX_ALL, v0);
}
void DEBUG_CHANNEL_MSG(uint v0, uint v1)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_HEX_ALL, v0, v1);
}
void DEBUG_CHANNEL_MSG(uint v0, uint v1, uint v2)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_HEX_ALL, v0, v1, v2);
}
void DEBUG_CHANNEL_MSG(uint v0, uint v1, uint v2, uint v3)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_HEX_ALL, v0, v1, v2, v3);
}
void DEBUG_CHANNEL_MSG(int v0)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_I32_ALL, v0);
}
void DEBUG_CHANNEL_MSG(int v0, int v1)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_I32_ALL, v0, v1);
}
void DEBUG_CHANNEL_MSG(int v0, int v1, int v2)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_I32_ALL, v0, v1, v2);
}
void DEBUG_CHANNEL_MSG(int v0, int v1, int v2, int v3)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_I32_ALL, v0, v1, v2, v3);
}
void DEBUG_CHANNEL_MSG(float v0)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_F32_ALL, floatBitsToUint(v0));
}
void DEBUG_CHANNEL_MSG(float v0, float v1)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_F32_ALL, floatBitsToUint(v0), floatBitsToUint(v1));
}
void DEBUG_CHANNEL_MSG(float v0, float v1, float v2)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_F32_ALL, floatBitsToUint(v0), floatBitsToUint(v1), floatBitsToUint(v2));
}
void DEBUG_CHANNEL_MSG(float v0, float v1, float v2, float v3)
{
DEBUG_CHANNEL_MSG_(DEBUG_CHANNEL_FMT_F32_ALL, floatBitsToUint(v0), floatBitsToUint(v1), floatBitsToUint(v2), floatBitsToUint(v3));
}
void DEBUG_CHANNEL_MSG_UNIFORM(uint v0)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0);
}
void DEBUG_CHANNEL_MSG_UNIFORM(uint v0, uint v1)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0, v1);
}
void DEBUG_CHANNEL_MSG_UNIFORM(uint v0, uint v1, uint v2)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0, v1, v2);
}
void DEBUG_CHANNEL_MSG_UNIFORM(uint v0, uint v1, uint v2, uint v3)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0, v1, v2, v3);
}
void DEBUG_CHANNEL_MSG_UNIFORM(int v0)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0);
}
void DEBUG_CHANNEL_MSG_UNIFORM(int v0, int v1)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0, v1);
}
void DEBUG_CHANNEL_MSG_UNIFORM(int v0, int v1, int v2)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0, v1, v2);
}
void DEBUG_CHANNEL_MSG_UNIFORM(int v0, int v1, int v2, int v3)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0, v1, v2, v3);
}
void DEBUG_CHANNEL_MSG_UNIFORM(float v0)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0);
}
void DEBUG_CHANNEL_MSG_UNIFORM(float v0, float v1)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0, v1);
}
void DEBUG_CHANNEL_MSG_UNIFORM(float v0, float v1, float v2)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0, v1, v2);
}
void DEBUG_CHANNEL_MSG_UNIFORM(float v0, float v1, float v2, float v3)
{
if (DEBUG_CHANNEL_ELECT())
DEBUG_CHANNEL_MSG(v0, v1, v2, v3);
}
#endif

View File

@ -27,29 +27,71 @@
#endif /* VKD3D_NO_WIN32_TYPES */
#ifndef VKD3D_NO_VULKAN_H
# ifdef _WIN32
# define VK_USE_PLATFORM_WIN32_KHR
# endif
# include <vulkan/vulkan.h>
# include "private/vulkan_private_extensions.h"
#endif /* VKD3D_NO_VULKAN_H */
#define VKD3D_MIN_API_VERSION VK_API_VERSION_1_1
#define VKD3D_MAX_API_VERSION VK_API_VERSION_1_1
#if defined(__GNUC__)
# define DECLSPEC_VISIBLE __attribute__((visibility("default")))
#else
# define DECLSPEC_VISIBLE
#endif
#if defined(_WIN32) && !defined(VKD3D_BUILD_STANDALONE_D3D12)
# ifdef VKD3D_EXPORTS
# define VKD3D_EXPORT __declspec(dllexport)
# else
# define VKD3D_EXPORT __declspec(dllimport)
# endif
#elif defined(__GNUC__)
# define VKD3D_EXPORT DECLSPEC_VISIBLE
#else
# define VKD3D_EXPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
enum vkd3d_structure_type
{
/* 1.0 */
VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
VKD3D_STRUCTURE_TYPE_IMAGE_RESOURCE_CREATE_INFO,
/* 1.1 */
VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO,
/* 1.2 */
VKD3D_STRUCTURE_TYPE_OPTIONAL_DEVICE_EXTENSIONS_INFO,
VKD3D_STRUCTURE_TYPE_APPLICATION_INFO,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_STRUCTURE_TYPE),
};
#define VKD3D_CONFIG_FLAG_VULKAN_DEBUG (1ull << 0)
#define VKD3D_CONFIG_FLAG_SKIP_APPLICATION_WORKAROUNDS (1ull << 1)
#define VKD3D_CONFIG_FLAG_DEBUG_UTILS (1ull << 2)
#define VKD3D_CONFIG_FLAG_FORCE_STATIC_CBV (1ull << 3)
#define VKD3D_CONFIG_FLAG_DXR (1ull << 4)
#define VKD3D_CONFIG_FLAG_SINGLE_QUEUE (1ull << 5)
#define VKD3D_CONFIG_FLAG_DESCRIPTOR_QA_CHECKS (1ull << 6)
#define VKD3D_CONFIG_FLAG_FORCE_RTV_EXCLUSIVE_QUEUE (1ull << 7)
#define VKD3D_CONFIG_FLAG_FORCE_DSV_EXCLUSIVE_QUEUE (1ull << 8)
#define VKD3D_CONFIG_FLAG_FORCE_MINIMUM_SUBGROUP_SIZE (1ull << 9)
#define VKD3D_CONFIG_FLAG_NO_UPLOAD_HVV (1ull << 10)
#define VKD3D_CONFIG_FLAG_LOG_MEMORY_BUDGET (1ull << 11)
#define VKD3D_CONFIG_FLAG_IGNORE_RTV_HOST_VISIBLE (1ull << 12)
#define VKD3D_CONFIG_FLAG_FORCE_HOST_CACHED (1ull << 13)
#define VKD3D_CONFIG_FLAG_DXR11 (1ull << 14)
#define VKD3D_CONFIG_FLAG_FORCE_NO_INVARIANT_POSITION (1ull << 15)
#define VKD3D_CONFIG_FLAG_GLOBAL_PIPELINE_CACHE (1ull << 16)
#define VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_NO_SERIALIZE_SPIRV (1ull << 17)
#define VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_SANITIZE_SPIRV (1ull << 18)
#define VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_LOG (1ull << 19)
#define VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_IGNORE_SPIRV (1ull << 20)
#define VKD3D_CONFIG_FLAG_MUTABLE_SINGLE_SET (1ull << 21)
#define VKD3D_CONFIG_FLAG_MEMORY_ALLOCATOR_SKIP_CLEAR (1ull << 22)
#define VKD3D_CONFIG_FLAG_RECYCLE_COMMAND_POOLS (1ull << 23)
#define VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_IGNORE_MISMATCH_DRIVER (1ull << 24)
#define VKD3D_CONFIG_FLAG_BREADCRUMBS (1ull << 25)
#define VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_APP_CACHE_ONLY (1ull << 26)
#define VKD3D_CONFIG_FLAG_SHADER_CACHE_SYNC (1ull << 27)
#define VKD3D_CONFIG_FLAG_FORCE_RAW_VA_CBV (1ull << 28)
#define VKD3D_CONFIG_FLAG_ZERO_MEMORY_WORKAROUNDS_COMMITTED_BUFFER_UAV (1ull << 29)
#define VKD3D_CONFIG_FLAG_ALLOW_SBT_COLLECTION (1ull << 30)
#define VKD3D_CONFIG_FLAG_FORCE_NATIVE_FP16 (1ull << 31)
#define VKD3D_CONFIG_FLAG_USE_HOST_IMPORT_FALLBACK (1ull << 32)
typedef HRESULT (*PFN_vkd3d_signal_event)(HANDLE event);
@ -62,49 +104,22 @@ struct vkd3d_instance;
struct vkd3d_instance_create_info
{
enum vkd3d_structure_type type;
const void *next;
PFN_vkd3d_signal_event pfn_signal_event;
PFN_vkd3d_create_thread pfn_create_thread;
PFN_vkd3d_join_thread pfn_join_thread;
size_t wchar_size;
/* If set to NULL, libvkd3d loads libvulkan. */
PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr;
const char * const *instance_extensions;
uint32_t instance_extension_count;
};
/* Extends vkd3d_instance_create_info. Available since 1.1. */
struct vkd3d_optional_instance_extensions_info
{
enum vkd3d_structure_type type;
const void *next;
const char * const *extensions;
uint32_t extension_count;
};
/* Extends vkd3d_instance_create_info. Available since 1.2. */
struct vkd3d_application_info
{
enum vkd3d_structure_type type;
const void *next;
const char *application_name;
uint32_t application_version;
const char *engine_name; /* "vkd3d" if NULL */
uint32_t engine_version; /* vkd3d version if engine_name is NULL */
const char * const *optional_instance_extensions;
uint32_t optional_instance_extension_count;
};
struct vkd3d_device_create_info
{
enum vkd3d_structure_type type;
const void *next;
D3D_FEATURE_LEVEL minimum_feature_level;
struct vkd3d_instance *instance;
@ -115,29 +130,15 @@ struct vkd3d_device_create_info
const char * const *device_extensions;
uint32_t device_extension_count;
const char * const *optional_device_extensions;
uint32_t optional_device_extension_count;
IUnknown *parent;
LUID adapter_luid;
};
/* Extends vkd3d_device_create_info. Available since 1.2. */
struct vkd3d_optional_device_extensions_info
{
enum vkd3d_structure_type type;
const void *next;
const char * const *extensions;
uint32_t extension_count;
};
/* vkd3d_image_resource_create_info flags */
#define VKD3D_RESOURCE_INITIAL_STATE_TRANSITION 0x00000001
#define VKD3D_RESOURCE_PRESENT_STATE_TRANSITION 0x00000002
struct vkd3d_image_resource_create_info
{
enum vkd3d_structure_type type;
const void *next;
VkImage vk_image;
D3D12_RESOURCE_DESC desc;
unsigned int flags;
@ -146,42 +147,43 @@ struct vkd3d_image_resource_create_info
#ifndef VKD3D_NO_PROTOTYPES
HRESULT vkd3d_create_instance(const struct vkd3d_instance_create_info *create_info,
VKD3D_EXPORT HRESULT vkd3d_create_instance(const struct vkd3d_instance_create_info *create_info,
struct vkd3d_instance **instance);
ULONG vkd3d_instance_decref(struct vkd3d_instance *instance);
VkInstance vkd3d_instance_get_vk_instance(struct vkd3d_instance *instance);
ULONG vkd3d_instance_incref(struct vkd3d_instance *instance);
VKD3D_EXPORT ULONG vkd3d_instance_decref(struct vkd3d_instance *instance);
VKD3D_EXPORT VkInstance vkd3d_instance_get_vk_instance(struct vkd3d_instance *instance);
VKD3D_EXPORT ULONG vkd3d_instance_incref(struct vkd3d_instance *instance);
HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info,
VKD3D_EXPORT HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info,
REFIID iid, void **device);
IUnknown *vkd3d_get_device_parent(ID3D12Device *device);
VkDevice vkd3d_get_vk_device(ID3D12Device *device);
VkPhysicalDevice vkd3d_get_vk_physical_device(ID3D12Device *device);
struct vkd3d_instance *vkd3d_instance_from_device(ID3D12Device *device);
VKD3D_EXPORT IUnknown *vkd3d_get_device_parent(ID3D12Device *device);
VKD3D_EXPORT VkDevice vkd3d_get_vk_device(ID3D12Device *device);
VKD3D_EXPORT VkPhysicalDevice vkd3d_get_vk_physical_device(ID3D12Device *device);
VKD3D_EXPORT struct vkd3d_instance *vkd3d_instance_from_device(ID3D12Device *device);
uint32_t vkd3d_get_vk_queue_family_index(ID3D12CommandQueue *queue);
VkQueue vkd3d_acquire_vk_queue(ID3D12CommandQueue *queue);
void vkd3d_release_vk_queue(ID3D12CommandQueue *queue);
VKD3D_EXPORT uint32_t vkd3d_get_vk_queue_family_index(ID3D12CommandQueue *queue);
VKD3D_EXPORT VkQueue vkd3d_acquire_vk_queue(ID3D12CommandQueue *queue);
VKD3D_EXPORT void vkd3d_release_vk_queue(ID3D12CommandQueue *queue);
VKD3D_EXPORT void vkd3d_enqueue_initial_transition(ID3D12CommandQueue *queue, ID3D12Resource *resource);
HRESULT vkd3d_create_image_resource(ID3D12Device *device,
VKD3D_EXPORT HRESULT vkd3d_create_image_resource(ID3D12Device *device,
const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource);
ULONG vkd3d_resource_decref(ID3D12Resource *resource);
ULONG vkd3d_resource_incref(ID3D12Resource *resource);
VKD3D_EXPORT ULONG vkd3d_resource_decref(ID3D12Resource *resource);
VKD3D_EXPORT ULONG vkd3d_resource_incref(ID3D12Resource *resource);
HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc,
VKD3D_EXPORT HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc,
D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob);
HRESULT vkd3d_create_root_signature_deserializer(const void *data, SIZE_T data_size,
VKD3D_EXPORT HRESULT vkd3d_create_root_signature_deserializer(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer);
VkFormat vkd3d_get_vk_format(DXGI_FORMAT format);
VKD3D_EXPORT VkFormat vkd3d_get_vk_format(DXGI_FORMAT format);
/* 1.1 */
DXGI_FORMAT vkd3d_get_dxgi_format(VkFormat format);
VKD3D_EXPORT DXGI_FORMAT vkd3d_get_dxgi_format(VkFormat format);
/* 1.2 */
HRESULT vkd3d_serialize_versioned_root_signature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
VKD3D_EXPORT HRESULT vkd3d_serialize_versioned_root_signature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
ID3DBlob **blob, ID3DBlob **error_blob);
HRESULT vkd3d_create_versioned_root_signature_deserializer(const void *data, SIZE_T data_size,
VKD3D_EXPORT HRESULT vkd3d_create_versioned_root_signature_deserializer(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer);
#endif /* VKD3D_NO_PROTOTYPES */

View File

@ -0,0 +1,32 @@
/*
* * Copyright 2021 NVIDIA Corporation
*
* 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
*/
import "vkd3d_d3d12.idl";
import "vkd3d_vk_includes.h";
[
uuid(77a86b09-2bea-4801-b89a-37648e104af1),
object,
local,
pointer_default(unique)
]
interface ID3D12GraphicsCommandListExt : IUnknown
{
HRESULT GetVulkanHandle(VkCommandBuffer *pVkCommandBuffer);
HRESULT LaunchCubinShader(D3D12_CUBIN_DATA_HANDLE *handle, UINT32 block_x, UINT32 block_y, UINT32 block_z, const void *params, UINT32 param_size);
}

File diff suppressed because it is too large Load Diff

View File

@ -77,6 +77,7 @@ typedef enum D3D_FEATURE_LEVEL
D3D_FEATURE_LEVEL_11_1 = 0xb100,
D3D_FEATURE_LEVEL_12_0 = 0xc000,
D3D_FEATURE_LEVEL_12_1 = 0xc100,
D3D_FEATURE_LEVEL_12_2 = 0xc200,
} D3D_FEATURE_LEVEL;
[
@ -93,3 +94,7 @@ interface ID3D10Blob : IUnknown
typedef ID3D10Blob ID3DBlob;
cpp_quote("#define IID_ID3DBlob IID_ID3D10Blob")
cpp_quote("DEFINE_GUID(WKPDID_D3DDebugObjectName,0x429b8c22,0x9188,0x4b0c,0x87,0x42,0xac,0xb0,0xbf,0x85,0xc2,0x00);")
cpp_quote("DEFINE_GUID(WKPDID_D3DDebugObjectNameW,0x4cca5fd8,0x921f,0x42c8,0x85,0x66,0x70,0xca,0xf2,0xa9,0xb7,0x41);")
cpp_quote("DEFINE_GUID(WKPDID_CommentStringW,0xd0149dc0,0x90e8,0x4ec8,0x81,0x44,0xe9,0x00,0xad,0x26,0x6b,0xb2);")

View File

@ -0,0 +1,37 @@
/*
* * Copyright 2021 NVIDIA Corporation
*
* 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
*/
import "vkd3d_d3d12.idl";
import "vkd3d_vk_includes.h";
[
uuid(11ea7a1a-0f6a-49bf-b612-3e30f8e201dd),
object,
local,
pointer_default(unique)
]
interface ID3D12DeviceExt : IUnknown
{
HRESULT GetVulkanHandles(VkInstance *vk_instance, VkPhysicalDevice *vk_physical_device, VkDevice *vk_device);
BOOL GetExtensionSupport(D3D12_VK_EXTENSION extension);
HRESULT CreateCubinComputeShaderWithName(const void *cubin_data, UINT32 cubin_size, UINT32 block_x, UINT32 block_y, UINT32 block_z, const char *shader_name, D3D12_CUBIN_DATA_HANDLE **handle);
HRESULT DestroyCubinComputeShader(D3D12_CUBIN_DATA_HANDLE *handle);
HRESULT GetCudaTextureObject(D3D12_CPU_DESCRIPTOR_HANDLE srv_handle, D3D12_CPU_DESCRIPTOR_HANDLE sampler_handle, UINT32 *cuda_texture_handle);
HRESULT GetCudaSurfaceObject(D3D12_CPU_DESCRIPTOR_HANDLE uav_handle, UINT32 *cuda_surface_handle);
HRESULT CaptureUAVInfo(D3D12_UAV_INFO *uav_info);
}

View File

@ -135,5 +135,12 @@ typedef enum DXGI_FORMAT
DXGI_FORMAT_A8P8 = 0x72,
DXGI_FORMAT_B4G4R4A4_UNORM = 0x73,
DXGI_FORMAT_P208 = 0x82,
DXGI_FORMAT_V208 = 0x83,
DXGI_FORMAT_V408 = 0x84,
DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE = 0xbd,
DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE = 0xbe,
DXGI_FORMAT_FORCE_UINT = 0xffffffff,
} DXGI_FORMAT;

View File

@ -21,24 +21,16 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <hashmap.h>
#include <vkd3d_types.h>
#include <vkd3d_d3d12.h>
#include <vkd3d.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
enum vkd3d_shader_structure_type
{
/* 1.2 */
VKD3D_SHADER_STRUCTURE_TYPE_SHADER_INTERFACE_INFO,
VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS,
VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO,
VKD3D_SHADER_STRUCTURE_TYPE_TRANSFORM_FEEDBACK_INFO,
VKD3D_SHADER_STRUCTURE_TYPE_DOMAIN_SHADER_COMPILE_ARGUMENTS,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STRUCTURE_TYPE),
};
enum vkd3d_shader_compiler_option
{
VKD3D_SHADER_STRIP_DEBUG = 0x00000001,
@ -60,12 +52,34 @@ enum vkd3d_shader_visibility
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_VISIBILITY),
};
typedef uint64_t vkd3d_shader_hash_t;
enum vkd3d_shader_meta_flags
{
VKD3D_SHADER_META_FLAG_REPLACED = 1 << 0,
VKD3D_SHADER_META_FLAG_USES_SUBGROUP_SIZE = 1 << 1,
VKD3D_SHADER_META_FLAG_USES_NATIVE_16BIT_OPERATIONS = 1 << 2,
};
struct vkd3d_shader_meta
{
vkd3d_shader_hash_t hash;
unsigned int cs_workgroup_size[3]; /* Only contains valid data if uses_subgroup_size is true. */
unsigned int patch_vertex_count; /* Relevant for HS. May be 0, in which case the patch vertex count is not known. */
unsigned int cs_required_wave_size; /* If non-zero, force a specific CS subgroup size. */
uint32_t flags; /* vkd3d_shader_meta_flags */
};
STATIC_ASSERT(sizeof(struct vkd3d_shader_meta) == 32);
struct vkd3d_shader_code
{
const void *code;
size_t size;
struct vkd3d_shader_meta meta;
};
vkd3d_shader_hash_t vkd3d_shader_hash(const struct vkd3d_shader_code *shader);
enum vkd3d_shader_descriptor_type
{
VKD3D_SHADER_DESCRIPTOR_TYPE_UNKNOWN,
@ -85,8 +99,12 @@ struct vkd3d_shader_descriptor_binding
enum vkd3d_shader_binding_flag
{
VKD3D_SHADER_BINDING_FLAG_BUFFER = 0x00000001,
VKD3D_SHADER_BINDING_FLAG_IMAGE = 0x00000002,
VKD3D_SHADER_BINDING_FLAG_BUFFER = 0x00000001,
VKD3D_SHADER_BINDING_FLAG_IMAGE = 0x00000002,
VKD3D_SHADER_BINDING_FLAG_AUX_BUFFER = 0x00000004,
VKD3D_SHADER_BINDING_FLAG_BINDLESS = 0x00000008,
VKD3D_SHADER_BINDING_FLAG_RAW_VA = 0x00000010,
VKD3D_SHADER_BINDING_FLAG_RAW_SSBO = 0x00000020,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_BINDING_FLAG),
};
@ -115,7 +133,7 @@ struct vkd3d_shader_parameter_immediate_constant
union
{
uint32_t u32;
} u;
};
};
struct vkd3d_shader_parameter_specialization_constant
@ -132,13 +150,19 @@ struct vkd3d_shader_parameter
{
struct vkd3d_shader_parameter_immediate_constant immediate_constant;
struct vkd3d_shader_parameter_specialization_constant specialization_constant;
} u;
};
};
#define VKD3D_SHADER_DESCRIPTOR_RANGE_UNBOUNDED (~0u)
struct vkd3d_shader_resource_binding
{
enum vkd3d_shader_descriptor_type type;
unsigned int register_space;
unsigned int register_index;
unsigned int register_count;
unsigned int descriptor_table;
unsigned int descriptor_offset;
enum vkd3d_shader_visibility shader_visibility;
unsigned int flags; /* vkd3d_shader_binding_flags */
@ -147,27 +171,9 @@ struct vkd3d_shader_resource_binding
#define VKD3D_DUMMY_SAMPLER_INDEX ~0u
struct vkd3d_shader_combined_resource_sampler
{
unsigned int resource_index;
unsigned int sampler_index;
enum vkd3d_shader_visibility shader_visibility;
unsigned int flags; /* vkd3d_shader_binding_flags */
struct vkd3d_shader_descriptor_binding binding;
};
struct vkd3d_shader_uav_counter_binding
{
unsigned int register_index; /* u# */
enum vkd3d_shader_visibility shader_visibility;
struct vkd3d_shader_descriptor_binding binding;
unsigned int offset;
};
struct vkd3d_shader_push_constant_buffer
{
unsigned int register_space;
unsigned int register_index;
enum vkd3d_shader_visibility shader_visibility;
@ -175,22 +181,89 @@ struct vkd3d_shader_push_constant_buffer
unsigned int size; /* in bytes */
};
struct vkd3d_shader_descriptor_table_buffer
{
unsigned int offset; /* in bytes */
unsigned int count; /* number of tables */
};
enum vkd3d_shader_interface_flag
{
VKD3D_SHADER_INTERFACE_PUSH_CONSTANTS_AS_UNIFORM_BUFFER = 0x00000001u,
VKD3D_SHADER_INTERFACE_BINDLESS_CBV_AS_STORAGE_BUFFER = 0x00000002u,
VKD3D_SHADER_INTERFACE_SSBO_OFFSET_BUFFER = 0x00000004u,
VKD3D_SHADER_INTERFACE_TYPED_OFFSET_BUFFER = 0x00000008u,
VKD3D_SHADER_INTERFACE_DESCRIPTOR_QA_BUFFER = 0x00000010u
};
struct vkd3d_shader_interface_info
{
enum vkd3d_shader_structure_type type;
const void *next;
unsigned int flags; /* vkd3d_shader_interface_flags */
unsigned int min_ssbo_alignment;
struct vkd3d_shader_descriptor_table_buffer descriptor_tables;
const struct vkd3d_shader_resource_binding *bindings;
unsigned int binding_count;
const struct vkd3d_shader_push_constant_buffer *push_constant_buffers;
unsigned int push_constant_buffer_count;
const struct vkd3d_shader_combined_resource_sampler *combined_samplers;
unsigned int combined_sampler_count;
/* Ignored unless VKD3D_SHADER_INTERFACE_PUSH_CONSTANTS_AS_UNIFORM_BUFFER is set */
const struct vkd3d_shader_descriptor_binding *push_constant_ubo_binding;
/* Ignored unless VKD3D_SHADER_INTERFACE_SSBO_OFFSET_BUFFER or TYPED_OFFSET_BUFFER is set */
const struct vkd3d_shader_descriptor_binding *offset_buffer_binding;
const struct vkd3d_shader_uav_counter_binding *uav_counters;
unsigned int uav_counter_count;
#ifdef VKD3D_ENABLE_DESCRIPTOR_QA
/* Ignored unless VKD3D_SHADER_INTERFACE_DESCRIPTOR_QA_BUFFER is set. */
const struct vkd3d_shader_descriptor_binding *descriptor_qa_global_binding;
/* Ignored unless VKD3D_SHADER_INTERFACE_DESCRIPTOR_QA_BUFFER is set. */
const struct vkd3d_shader_descriptor_binding *descriptor_qa_heap_binding;
#endif
VkShaderStageFlagBits stage;
const struct vkd3d_shader_transform_feedback_info *xfb_info;
};
struct vkd3d_shader_descriptor_table
{
uint32_t table_index;
uint32_t binding_count;
struct vkd3d_shader_resource_binding *first_binding;
};
struct vkd3d_shader_root_constant
{
uint32_t constant_index;
uint32_t constant_count;
};
struct vkd3d_shader_root_descriptor
{
struct vkd3d_shader_resource_binding *binding;
uint32_t raw_va_root_descriptor_index;
};
struct vkd3d_shader_root_parameter
{
D3D12_ROOT_PARAMETER_TYPE parameter_type;
union
{
struct vkd3d_shader_root_constant constant;
struct vkd3d_shader_root_descriptor descriptor;
struct vkd3d_shader_descriptor_table descriptor_table;
};
};
struct vkd3d_shader_interface_local_info
{
const struct vkd3d_shader_root_parameter *local_root_parameters;
unsigned int local_root_parameter_count;
const struct vkd3d_shader_push_constant_buffer *shader_record_constant_buffers;
unsigned int shader_record_buffer_count;
const struct vkd3d_shader_resource_binding *bindings;
unsigned int binding_count;
uint32_t descriptor_size;
};
struct vkd3d_shader_transform_feedback_element
@ -203,12 +276,8 @@ struct vkd3d_shader_transform_feedback_element
uint8_t output_slot;
};
/* Extends vkd3d_shader_interface_info. */
struct vkd3d_shader_transform_feedback_info
{
enum vkd3d_shader_structure_type type;
const void *next;
const struct vkd3d_shader_transform_feedback_element *elements;
unsigned int element_count;
const unsigned int *buffer_strides;
@ -218,7 +287,6 @@ struct vkd3d_shader_transform_feedback_info
enum vkd3d_shader_target
{
VKD3D_SHADER_TARGET_NONE,
VKD3D_SHADER_TARGET_SPIRV_OPENGL_4_5,
VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0, /* default target */
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TARGET),
@ -229,13 +297,63 @@ enum vkd3d_shader_target_extension
VKD3D_SHADER_TARGET_EXTENSION_NONE,
VKD3D_SHADER_TARGET_EXTENSION_SPV_EXT_DEMOTE_TO_HELPER_INVOCATION,
VKD3D_SHADER_TARGET_EXTENSION_READ_STORAGE_IMAGE_WITHOUT_FORMAT,
VKD3D_SHADER_TARGET_EXTENSION_SPV_KHR_INTEGER_DOT_PRODUCT,
VKD3D_SHADER_TARGET_EXTENSION_RAY_TRACING_PRIMITIVE_CULLING,
VKD3D_SHADER_TARGET_EXTENSION_SCALAR_BLOCK_LAYOUT,
/* When using scalar block layout with a vec3 array on a byte address buffer,
* there is diverging behavior across hardware.
* On AMD, robustness is checked per component, which means we can implement ByteAddressBuffer
* without further hackery. On NVIDIA, robustness does not seem to work this way, so it's either
* all in range, or all out of range. We can implement structured buffer vectorization of vec3,
* but not byte address buffer. */
VKD3D_SHADER_TARGET_EXTENSION_ASSUME_PER_COMPONENT_SSBO_ROBUSTNESS,
VKD3D_SHADER_TARGET_EXTENSION_BARYCENTRIC_KHR,
VKD3D_SHADER_TARGET_EXTENSION_MIN_PRECISION_IS_NATIVE_16BIT,
VKD3D_SHADER_TARGET_EXTENSION_COUNT,
};
enum vkd3d_shader_quirk
{
/* If sample or sample_b is used in control flow, force LOD 0.0 (which game should expect anyway).
* Works around specific, questionable shaders which rely on this to give sensible results,
* since LOD can become garbage on certain implementations, and even on native drivers
* the result is implementation defined.
* Outside of making this edge case well-defined in Vulkan or hacking driver compilers,
* this is the pragmatic solution.
* Hoisting gradients is not possible in all cases,
* and would not be worth it until it's a widespread problem. */
VKD3D_SHADER_QUIRK_FORCE_EXPLICIT_LOD_IN_CONTROL_FLOW = (1 << 0),
/* After every write to group shared memory, force a memory barrier.
* This works around buggy games which forget to use barrier(). */
VKD3D_SHADER_QUIRK_FORCE_TGSM_BARRIERS = (1 << 1),
/* For Position builtins in Output storage class, emit Invariant decoration.
* Normally, games have to emit Precise math for position, but if they forget ... */
VKD3D_SHADER_QUIRK_INVARIANT_POSITION = (1 << 2),
};
struct vkd3d_shader_quirk_hash
{
vkd3d_shader_hash_t shader_hash;
uint32_t quirks;
};
struct vkd3d_shader_quirk_info
{
const struct vkd3d_shader_quirk_hash *hashes;
unsigned int num_hashes;
uint32_t default_quirks;
/* Quirks which are ORed in with the other masks (including default_quirks).
* Used mostly for additional overrides from VKD3D_CONFIG. */
uint32_t global_quirks;
};
struct vkd3d_shader_compile_arguments
{
enum vkd3d_shader_structure_type type;
const void *next;
enum vkd3d_shader_target target;
unsigned int target_extension_count;
@ -247,6 +365,8 @@ struct vkd3d_shader_compile_arguments
bool dual_source_blending;
const unsigned int *output_swizzles;
unsigned int output_swizzle_count;
const struct vkd3d_shader_quirk_info *quirks;
};
enum vkd3d_tessellator_output_primitive
@ -265,16 +385,6 @@ enum vkd3d_tessellator_partitioning
VKD3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4,
};
/* Extends vkd3d_shader_compile_arguments. */
struct vkd3d_shader_domain_shader_compile_arguments
{
enum vkd3d_shader_structure_type type;
const void *next;
enum vkd3d_tessellator_output_primitive output_primitive;
enum vkd3d_tessellator_output_primitive partitioning;
};
/* root signature 1.0 */
enum vkd3d_filter
{
@ -426,7 +536,7 @@ struct vkd3d_root_parameter
struct vkd3d_root_descriptor_table descriptor_table;
struct vkd3d_root_constants constants;
struct vkd3d_root_descriptor descriptor;
} u;
};
enum vkd3d_shader_visibility shader_visibility;
};
@ -469,6 +579,7 @@ enum vkd3d_descriptor_range_flags
VKD3D_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE = 0x2,
VKD3D_DESCRIPTOR_RANGE_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4,
VKD3D_DESCRIPTOR_RANGE_FLAG_DATA_STATIC = 0x8,
VKD3D_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS = 0x10000
};
struct vkd3d_descriptor_range1
@ -502,7 +613,7 @@ struct vkd3d_root_parameter1
struct vkd3d_root_descriptor_table1 descriptor_table;
struct vkd3d_root_constants constants;
struct vkd3d_root_descriptor1 descriptor;
} u;
};
enum vkd3d_shader_visibility shader_visibility;
};
@ -530,21 +641,27 @@ struct vkd3d_versioned_root_signature_desc
{
struct vkd3d_root_signature_desc v_1_0;
struct vkd3d_root_signature_desc1 v_1_1;
} u;
};
};
/* FIXME: Add support for 64 UAV bind slots. */
#define VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS 8
enum vkd3d_shader_uav_flag
{
VKD3D_SHADER_UAV_FLAG_READ_ACCESS = 0x00000001,
VKD3D_SHADER_UAV_FLAG_ATOMIC_COUNTER = 0x00000002,
VKD3D_SHADER_UAV_FLAG_ATOMIC_ACCESS = 0x00000004,
};
struct vkd3d_shader_scan_info
{
enum vkd3d_shader_structure_type type;
void *next;
unsigned int uav_read_mask; /* VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS */
unsigned int uav_counter_mask; /* VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS */
unsigned int sampler_comparison_mode_mask; /* 16 */
struct hash_map register_map;
bool use_vocp;
bool early_fragment_tests;
bool has_side_effects;
bool needs_late_zs;
bool discards;
bool has_uav_counter;
unsigned int patch_vertex_count;
};
enum vkd3d_component_type
@ -554,6 +671,7 @@ enum vkd3d_component_type
VKD3D_TYPE_INT = 2,
VKD3D_TYPE_FLOAT = 3,
VKD3D_TYPE_BOOL,
VKD3D_TYPE_DOUBLE,
VKD3D_TYPE_COUNT,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_COMPONENT_TYPE),
@ -636,7 +754,11 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);
int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
struct vkd3d_versioned_root_signature_desc *root_signature);
struct vkd3d_versioned_root_signature_desc *root_signature,
vkd3d_shader_hash_t *compatibility_hash);
int vkd3d_shader_parse_root_signature_raw(const char *data, unsigned int data_size,
struct vkd3d_versioned_root_signature_desc *desc,
vkd3d_shader_hash_t *compatibility_hash);
void vkd3d_shader_free_root_signature(struct vkd3d_versioned_root_signature_desc *root_signature);
/* FIXME: Add support for returning error messages (ID3DBlob). */
@ -651,11 +773,89 @@ int vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc,
int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
struct vkd3d_shader_signature *signature);
int vkd3d_shader_parse_output_signature(const struct vkd3d_shader_code *dxbc,
struct vkd3d_shader_signature *signature);
struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
const struct vkd3d_shader_signature *signature, const char *semantic_name,
unsigned int semantic_index, unsigned int stream_index);
void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature);
/* For DXR, use special purpose entry points since there's a lot of special purpose reflection required. */
struct vkd3d_shader_library_entry_point
{
unsigned int identifier;
VkShaderStageFlagBits stage;
WCHAR *mangled_entry_point;
WCHAR *plain_entry_point;
char *real_entry_point;
};
enum vkd3d_shader_subobject_kind
{
/* Matches DXIL for simplicity. */
VKD3D_SHADER_SUBOBJECT_KIND_STATE_OBJECT_CONFIG = 0,
VKD3D_SHADER_SUBOBJECT_KIND_GLOBAL_ROOT_SIGNATURE = 1,
VKD3D_SHADER_SUBOBJECT_KIND_LOCAL_ROOT_SIGNATURE = 2,
VKD3D_SHADER_SUBOBJECT_KIND_SUBOBJECT_TO_EXPORTS_ASSOCIATION = 8,
VKD3D_SHADER_SUBOBJECT_KIND_RAYTRACING_SHADER_CONFIG = 9,
VKD3D_SHADER_SUBOBJECT_KIND_RAYTRACING_PIPELINE_CONFIG = 10,
VKD3D_SHADER_SUBOBJECT_KIND_HIT_GROUP = 11,
VKD3D_SHADER_SUBOBJECT_KIND_RAYTRACING_PIPELINE_CONFIG1 = 12,
};
struct vkd3d_shader_library_subobject
{
enum vkd3d_shader_subobject_kind kind;
unsigned int dxil_identifier;
/* All const pointers here point directly to the DXBC blob,
* so they do not need to be freed.
* Fortunately for us, the C strings are zero-terminated in the blob itself. */
/* In the blob, ASCII is used as identifier, where API uses wide strings, sigh ... */
const char *name;
union
{
D3D12_RAYTRACING_PIPELINE_CONFIG1 pipeline_config;
D3D12_RAYTRACING_SHADER_CONFIG shader_config;
D3D12_STATE_OBJECT_CONFIG object_config;
/* Duped strings because API wants wide strings for no good reason. */
D3D12_HIT_GROUP_DESC hit_group;
D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION association;
struct
{
const void *data;
size_t size;
} payload;
} data;
};
int vkd3d_shader_dxil_append_library_entry_points_and_subobjects(
const D3D12_DXIL_LIBRARY_DESC *library_desc,
unsigned int identifier,
struct vkd3d_shader_library_entry_point **entry_points,
size_t *entry_point_size, size_t *entry_point_count,
struct vkd3d_shader_library_subobject **subobjects,
size_t *subobjects_size, size_t *subobjects_count);
void vkd3d_shader_dxil_free_library_entry_points(struct vkd3d_shader_library_entry_point *entry_points, size_t count);
void vkd3d_shader_dxil_free_library_subobjects(struct vkd3d_shader_library_subobject *subobjects, size_t count);
int vkd3d_shader_compile_dxil_export(const struct vkd3d_shader_code *dxil,
const char *export,
struct vkd3d_shader_code *spirv,
const struct vkd3d_shader_interface_info *shader_interface_info,
const struct vkd3d_shader_interface_local_info *shader_interface_local_info,
const struct vkd3d_shader_compile_arguments *compiler_args);
uint32_t vkd3d_shader_compile_arguments_select_quirks(
const struct vkd3d_shader_compile_arguments *args, vkd3d_shader_hash_t hash);
uint64_t vkd3d_shader_get_revision(void);
#endif /* VKD3D_SHADER_NO_PROTOTYPES */
/*
@ -668,7 +868,8 @@ typedef int (*PFN_vkd3d_shader_compile_dxbc)(const struct vkd3d_shader_code *dxb
typedef void (*PFN_vkd3d_shader_free_shader_code)(struct vkd3d_shader_code *code);
typedef int (*PFN_vkd3d_shader_parse_root_signature)(const struct vkd3d_shader_code *dxbc,
struct vkd3d_versioned_root_signature_desc *root_signature);
struct vkd3d_versioned_root_signature_desc *root_signature,
vkd3d_shader_hash_t *compatibility_hash);
typedef void (*PFN_vkd3d_shader_free_root_signature)(struct vkd3d_versioned_root_signature_desc *root_signature);
typedef int (*PFN_vkd3d_shader_serialize_root_signature)(

35
include/vkd3d_sonames.h Normal file
View File

@ -0,0 +1,35 @@
/*
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_SONAMES_H
#define __VKD3D_SONAMES_H
/* These sonames are defined by the loader ABI. */
#if defined(_WIN32)
#define SONAME_LIBVULKAN "vulkan-1.dll"
#elif defined(__linux__)
#define SONAME_LIBVULKAN "libvulkan.so.1"
#elif defined(__APPLE__)
#define SONAME_LIBVULKAN "libvulkan.1.dylib"
#else
#error "Unrecognized platform."
#endif
#endif

View File

@ -0,0 +1,39 @@
/*
* Copyright 2020 Joshua Ashton for Valve Software
*
* 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
*
*/
import "vkd3d_windows.h";
import "vkd3d_dxgibase.idl";
import "vkd3d_dxgi1_2.idl";
[
object,
local,
uuid(53cb4ff0-c25a-4164-a891-0e83db0a7aac)
]
interface IWineDXGISwapChainFactory : IUnknown
{
HRESULT CreateSwapChainForHwnd(
[in] IDXGIFactory *pFactory,
[in] HWND hWnd,
[in] const DXGI_SWAP_CHAIN_DESC1 *pDesc,
[in] const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *pFullscreenDesc,
[in] IDXGIOutput *pRestrictToOutput,
[out] IDXGISwapChain1 **ppSwapChain
);
}

View File

@ -30,22 +30,42 @@ extern "C" {
#define VKD3D_WAIT_FAILED (~0u)
#define VKD3D_INFINITE (~0u)
/* 1.0 */
HANDLE vkd3d_create_event(void);
HRESULT vkd3d_signal_event(HANDLE event);
unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds);
void vkd3d_destroy_event(HANDLE event);
#ifdef _WIN32
# ifdef _MSC_VER
# define VKD3D_UTILS_EXPORT
# else
/* We need to specify the __declspec(dllexport) attribute
* on MinGW because otherwise the stdcall aliases/fixups
* don't get exported.
*/
# ifdef VKD3D_UTILS_EXPORTS
# define VKD3D_UTILS_EXPORT __declspec(dllexport)
# else
# define VKD3D_UTILS_EXPORT __declspec(dllimport)
# endif
# endif
#elif defined(__GNUC__)
# define VKD3D_UTILS_EXPORT DECLSPEC_VISIBLE
#else
# define VKD3D_UTILS_EXPORT
#endif
HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter, D3D_FEATURE_LEVEL feature_level, REFIID iid, void **device);
HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T data_size, REFIID iid, void **deserializer);
HRESULT WINAPI D3D12GetDebugInterface(REFIID iid, void **debug);
HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *desc,
/* 1.0 */
VKD3D_UTILS_EXPORT HANDLE vkd3d_create_event(void);
VKD3D_UTILS_EXPORT HRESULT vkd3d_signal_event(HANDLE event);
VKD3D_UTILS_EXPORT unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds);
VKD3D_UTILS_EXPORT void vkd3d_destroy_event(HANDLE event);
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter, D3D_FEATURE_LEVEL feature_level, REFIID iid, void **device);
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T data_size, REFIID iid, void **deserializer);
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12GetDebugInterface(REFIID iid, void **debug);
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *desc,
D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob);
/* 1.2 */
HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer(const void *data,
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer(const void *data,
SIZE_T data_size, REFIID iid, void **deserializer);
HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
ID3DBlob **blob, ID3DBlob **error_blob);
#ifdef __cplusplus

View File

@ -0,0 +1,58 @@
/*
* * Copyright 2021 NVIDIA Corporation
*
* 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
*/
#ifndef __VKD3D_VK_INCLUDES_H
#define __VKD3D_VK_INCLUDES_H
#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
typedef struct VkCuFunctionNVX_T *VkCuFunctionNVX;
typedef struct VkCuModuleNVX_T *VkCuModuleNVX;
#else
typedef UINT64 VkCuFunctionNVX;
typedef UINT64 VkCuModuleNVX;
#endif
typedef struct VkPhysicalDevice_T *VkPhysicalDevice;
typedef struct VkCommandBuffer_T *VkCommandBuffer;
typedef struct VkInstance_T *VkInstance;
typedef struct VkDevice_T *VkDevice;
typedef enum D3D12_VK_EXTENSION
{
D3D12_VK_NVX_BINARY_IMPORT = 0x1,
D3D12_VK_NVX_IMAGE_VIEW_HANDLE = 0x2
} D3D12_VK_EXTENSION;
typedef struct D3D12_CUBIN_DATA_HANDLE
{
VkCuFunctionNVX vkCuFunction;
VkCuModuleNVX vkCuModule;
UINT32 blockX;
UINT32 blockY;
UINT32 blockZ;
} D3D12_CUBIN_DATA_HANDLE;
typedef struct D3D12_UAV_INFO
{
UINT32 version;
UINT32 surfaceHandle;
UINT64 gpuVAStart;
UINT64 gpuVASize;
} D3D12_UAV_INFO;
#endif // __VKD3D_VK_INCLUDES_H

86
include/vkd3d_win32.h Normal file
View File

@ -0,0 +1,86 @@
/*
* Copyright 2020 Joshua Ashton for Valve Software
*
* 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
*
*/
#ifndef __VKD3D_WIN32_H
#define __VKD3D_WIN32_H
/* Hack for MinGW-w64 headers.
*
* We want to use WIDL C inline wrappers because some methods
* in D3D12 interfaces return aggregate objects. Unfortunately,
* WIDL C inline wrappers are broken when used with MinGW-w64
* headers because FORCEINLINE expands to extern inline
* which leads to the "multiple storage classes in declaration
* specifiers" compiler error.
*
* This hack will define static to be meaningless when these
* headers are included, which are the only things declared
* static.
*/
#ifdef __MINGW32__
# define static
#endif
#define INITGUID
#define COBJMACROS
#define WIDL_C_INLINE_WRAPPERS
#include <vkd3d_windows.h>
/* Vulkan headers include static const declarations. Enable static keyword for
* them.
*/
#ifdef __MINGW32__
# undef static
#endif
#define VK_USE_PLATFORM_WIN32_KHR
#include <vulkan/vulkan.h>
#include "private/vulkan_private_extensions.h"
#ifdef __MINGW32__
# define static
#endif
#include <dxgi1_6.h>
/* We already included regular DXGI...
* let's not redefine everything under a new header
*/
#define __vkd3d_dxgibase_h__
#define __vkd3d_dxgi_h__
#define __vkd3d_dxgi1_2_h__
#define __vkd3d_dxgi1_3_h__
#define __vkd3d_dxgi1_4_h__
#include <vkd3d_swapchain_factory.h>
#include <vkd3d_command_list_vkd3d_ext.h>
#include <vkd3d_device_vkd3d_ext.h>
#include <vkd3d_d3d12.h>
#include <vkd3d_d3d12sdklayers.h>
/* End of MinGW hack. All Windows headers have been included */
#ifdef __MINGW32__
# undef static
#endif
#define VKD3D_NO_WIN32_TYPES
#define VKD3D_NO_VULKAN_H
#include <vkd3d.h>
#endif

View File

@ -22,21 +22,12 @@
/* Nameless unions */
#ifndef __C89_NAMELESS
# ifdef NONAMELESSUNION
# define __C89_NAMELESS
# define __C89_NAMELESSUNIONNAME u
# else
# define __C89_NAMELESS
# define __C89_NAMELESSUNIONNAME
# endif /* NONAMELESSUNION */
#endif /* __C89_NAMELESS */
#if !defined(_WIN32) || defined(__WIDL__)
# if !defined(__WIDL__) && !defined(VKD3D_WIN32_WCHAR)
# include <wchar.h>
# endif
# ifdef __GNUC__
# define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
# endif
@ -86,18 +77,20 @@ typedef unsigned long UINT64;
typedef long long DECLSPEC_ALIGN(8) INT64;
typedef unsigned long long DECLSPEC_ALIGN(8) UINT64;
# endif
typedef INT64 LONG64;
typedef long LONG_PTR;
typedef unsigned long ULONG_PTR;
typedef ULONG_PTR SIZE_T;
# ifdef VKD3D_WIN32_WCHAR
typedef unsigned short WCHAR;
# else
typedef wchar_t WCHAR;
# endif /* VKD3D_WIN32_WCHAR */
typedef void *HANDLE;
typedef const WCHAR* LPCWSTR;
#define _fseeki64(a, b, c) fseeko64(a, b, c)
#define _ftelli64(a) ftello64(a)
/* GUID */
# ifdef __WIDL__
typedef struct
@ -122,18 +115,18 @@ typedef GUID IID;
# ifdef INITGUID
# ifndef __cplusplus
# define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
const GUID name DECLSPEC_HIDDEN; \
const GUID name; \
const GUID name = \
{ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 }}
# else
# define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
EXTERN_C const GUID name DECLSPEC_HIDDEN; \
EXTERN_C const GUID name; \
EXTERN_C const GUID name = \
{ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 }}
# endif
# else
# define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
EXTERN_C const GUID name DECLSPEC_HIDDEN;
EXTERN_C const GUID name;
# endif /* INITGUID */
/* __uuidof emulation */
@ -166,7 +159,6 @@ extern "C++"
typedef struct SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
#endif /* !defined(_WIN32) || defined(__WIDL__) */
#ifndef _WIN32
# include <stddef.h>
# include <stdlib.h>
@ -233,18 +225,6 @@ typedef struct SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
#endif /* _WIN32 */
/* Define DECLSPEC_HIDDEN */
#ifndef DECLSPEC_HIDDEN
# if defined(__MINGW32__)
# define DECLSPEC_HIDDEN
# elif defined(__GNUC__)
# define DECLSPEC_HIDDEN __attribute__((visibility("hidden")))
# else
# define DECLSPEC_HIDDEN
# endif
#endif /* DECLSPEC_HIDDEN */
/* Define min() & max() macros */
#ifndef NOMINMAX
# ifndef min

11
libs/d3d12/d3d12.def Normal file
View File

@ -0,0 +1,11 @@
LIBRARY d3d12.dll
EXPORTS
D3D12CreateDevice @101
D3D12GetDebugInterface @102
D3D12CreateRootSignatureDeserializer
D3D12CreateVersionedRootSignatureDeserializer
D3D12EnableExperimentalFeatures
D3D12SerializeRootSignature
D3D12SerializeVersionedRootSignature

364
libs/d3d12/main.c Normal file
View File

@ -0,0 +1,364 @@
/*
* Copyright 2018 Józef Kucia for CodeWeavers
* Copyright 2020 Joshua Ashton for Valve Software
*
* 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
*
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#define VK_NO_PROTOTYPES
#include "vkd3d_win32.h"
#include "vkd3d_atomic.h"
#include "vkd3d_debug.h"
#include "vkd3d_threads.h"
/* We need to specify the __declspec(dllexport) attribute
* on MinGW because otherwise the stdcall aliases/fixups
* don't get exported.
*/
#if defined(_MSC_VER)
#define DLLEXPORT
#else
#define DLLEXPORT __declspec(dllexport)
#endif
static pthread_once_t library_once = PTHREAD_ONCE_INIT;
static HMODULE vulkan_module = NULL;
static void load_vulkan_once(void)
{
if (!vulkan_module)
vulkan_module = LoadLibraryA("vulkan-1.dll");
}
static PFN_vkGetInstanceProcAddr load_vulkan(void)
{
pthread_once(&library_once, load_vulkan_once);
if (vulkan_module)
return (void *)GetProcAddress(vulkan_module, "vkGetInstanceProcAddr");
else
return NULL;
}
HRESULT WINAPI DLLEXPORT D3D12GetDebugInterface(REFIID iid, void **debug)
{
TRACE("iid %s, debug %p.\n", debugstr_guid(iid), debug);
WARN("Returning DXGI_ERROR_SDK_COMPONENT_MISSING.\n");
return DXGI_ERROR_SDK_COMPONENT_MISSING;
}
HRESULT WINAPI DLLEXPORT D3D12EnableExperimentalFeatures(UINT feature_count,
const IID *iids, void *configurations, UINT *configurations_sizes)
{
FIXME("feature_count %u, iids %p, configurations %p, configurations_sizes %p stub!\n",
feature_count, iids, configurations, configurations_sizes);
return E_NOINTERFACE;
}
static HRESULT d3d12_signal_event(HANDLE event)
{
return SetEvent(event) ? S_OK : E_FAIL;
}
struct d3d12_thread_data
{
PFN_vkd3d_thread main_pfn;
void *data;
};
static DWORD WINAPI d3d12_thread_main(void *data)
{
struct d3d12_thread_data *thread_data = data;
thread_data->main_pfn(thread_data->data);
free(thread_data);
return 0;
}
static void *d3d12_create_thread(PFN_vkd3d_thread main_pfn, void *data)
{
struct d3d12_thread_data *thread_data;
HANDLE thread;
if (!(thread_data = malloc(sizeof(*thread_data))))
{
ERR("Failed to allocate thread data.\n");
return NULL;
}
thread_data->main_pfn = main_pfn;
thread_data->data = data;
if (!(thread = CreateThread(NULL, 0, d3d12_thread_main, thread_data, 0, NULL)))
free(thread_data);
return thread;
}
static HRESULT d3d12_join_thread(void *handle)
{
HANDLE thread = handle;
DWORD ret;
if ((ret = WaitForSingleObject(thread, INFINITE)) != WAIT_OBJECT_0)
{
ERR("Failed to wait for thread, ret %#x.\n", ret);
}
CloseHandle(thread);
return ret == WAIT_OBJECT_0 ? S_OK : E_FAIL;
}
static HRESULT d3d12_get_adapter(IDXGIAdapter **dxgi_adapter, IUnknown *adapter)
{
IDXGIFactory4 *factory = NULL;
HRESULT hr;
if (!adapter)
{
if (FAILED(hr = CreateDXGIFactory1(&IID_IDXGIFactory4, (void **)&factory)))
{
WARN("Failed to create DXGI factory, hr %#x.\n", hr);
goto done;
}
if (FAILED(hr = IDXGIFactory4_EnumAdapters(factory, 0, dxgi_adapter)))
{
WARN("Failed to enumerate primary adapter, hr %#x.\n", hr);
goto done;
}
}
else
{
if (FAILED(hr = IUnknown_QueryInterface(adapter, &IID_IDXGIAdapter, (void **)dxgi_adapter)))
{
WARN("Invalid adapter %p, hr %#x.\n", adapter, hr);
goto done;
}
}
done:
if (factory)
IDXGIFactory4_Release(factory);
return hr;
}
static VkPhysicalDevice d3d12_find_physical_device(struct vkd3d_instance *instance,
PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr, struct DXGI_ADAPTER_DESC *adapter_desc)
{
PFN_vkGetPhysicalDeviceProperties2 pfn_vkGetPhysicalDeviceProperties2;
PFN_vkGetPhysicalDeviceProperties pfn_vkGetPhysicalDeviceProperties;
PFN_vkEnumeratePhysicalDevices pfn_vkEnumeratePhysicalDevices;
VkPhysicalDevice vk_physical_device = VK_NULL_HANDLE;
VkPhysicalDeviceIDProperties id_properties;
VkPhysicalDeviceProperties2 properties2;
VkPhysicalDevice *vk_physical_devices;
VkInstance vk_instance;
unsigned int i;
uint32_t count;
VkResult vr;
vk_instance = vkd3d_instance_get_vk_instance(instance);
pfn_vkEnumeratePhysicalDevices = (void *)pfn_vkGetInstanceProcAddr(vk_instance, "vkEnumeratePhysicalDevices");
pfn_vkGetPhysicalDeviceProperties = (void *)pfn_vkGetInstanceProcAddr(vk_instance, "vkGetPhysicalDeviceProperties");
pfn_vkGetPhysicalDeviceProperties2 = (void *)pfn_vkGetInstanceProcAddr(vk_instance, "vkGetPhysicalDeviceProperties2");
if ((vr = pfn_vkEnumeratePhysicalDevices(vk_instance, &count, NULL)) < 0)
{
WARN("Failed to get device count, vr %d.\n", vr);
return VK_NULL_HANDLE;
}
if (!count)
{
WARN("No physical device available.\n");
return VK_NULL_HANDLE;
}
if (!(vk_physical_devices = calloc(count, sizeof(*vk_physical_devices))))
return VK_NULL_HANDLE;
if ((vr = pfn_vkEnumeratePhysicalDevices(vk_instance, &count, vk_physical_devices)) < 0)
goto done;
TRACE("Matching adapters by LUIDs.\n");
for (i = 0; i < count; ++i)
{
pfn_vkGetPhysicalDeviceProperties(vk_physical_devices[i], &properties2.properties);
/* Skip over physical devices below our minimum API version */
if (properties2.properties.apiVersion < VKD3D_MIN_API_VERSION)
{
WARN("Skipped adapter %s as it is below our minimum API version.", properties2.properties.deviceName);
continue;
}
id_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES;
id_properties.pNext = NULL;
properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
properties2.pNext = &id_properties;
pfn_vkGetPhysicalDeviceProperties2(vk_physical_devices[i], &properties2);
if (id_properties.deviceLUIDValid && !memcmp(id_properties.deviceLUID, &adapter_desc->AdapterLuid, VK_LUID_SIZE))
{
vk_physical_device = vk_physical_devices[i];
break;
}
}
if (!vk_physical_device)
{
TRACE("Matching adapters by PCI IDs.\n");
for (i = 0; i < count; ++i)
{
pfn_vkGetPhysicalDeviceProperties(vk_physical_devices[i], &properties2.properties);
if (properties2.properties.deviceID == adapter_desc->DeviceId &&
properties2.properties.vendorID == adapter_desc->VendorId)
{
vk_physical_device = vk_physical_devices[i];
break;
}
}
}
if (!vk_physical_device)
{
FIXME("Could not find Vulkan physical device for DXGI adapter.\n");
WARN("Using first available physical device...\n");
vk_physical_device = vk_physical_devices[0];
}
done:
free(vk_physical_devices);
return vk_physical_device;
}
HRESULT WINAPI DLLEXPORT D3D12CreateDevice(IUnknown *adapter, D3D_FEATURE_LEVEL minimum_feature_level,
REFIID iid, void **device)
{
struct vkd3d_instance_create_info instance_create_info;
PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr;
struct vkd3d_device_create_info device_create_info;
struct DXGI_ADAPTER_DESC adapter_desc;
struct vkd3d_instance *instance;
IDXGIAdapter *dxgi_adapter;
HRESULT hr;
static const char * const instance_extensions[] =
{
VK_KHR_SURFACE_EXTENSION_NAME,
VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
};
static const char * const device_extensions[] =
{
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
};
TRACE("adapter %p, minimum_feature_level %#x, iid %s, device %p.\n",
adapter, minimum_feature_level, debugstr_guid(iid), device);
if (!(pfn_vkGetInstanceProcAddr = load_vulkan()))
{
ERR("Failed to load Vulkan library.\n");
return E_FAIL;
}
if (FAILED(hr = d3d12_get_adapter(&dxgi_adapter, adapter)))
return hr;
if (FAILED(hr = IDXGIAdapter_GetDesc(dxgi_adapter, &adapter_desc)))
{
WARN("Failed to get adapter desc, hr %#x.\n", hr);
goto done;
}
instance_create_info.pfn_signal_event = d3d12_signal_event;
instance_create_info.pfn_create_thread = d3d12_create_thread;
instance_create_info.pfn_join_thread = d3d12_join_thread;
instance_create_info.pfn_vkGetInstanceProcAddr = pfn_vkGetInstanceProcAddr;
instance_create_info.instance_extensions = instance_extensions;
instance_create_info.instance_extension_count = ARRAYSIZE(instance_extensions);
instance_create_info.optional_instance_extensions = NULL;
instance_create_info.optional_instance_extension_count = 0;
if (FAILED(hr = vkd3d_create_instance(&instance_create_info, &instance)))
{
WARN("Failed to create vkd3d instance, hr %#x.\n", hr);
goto done;
}
device_create_info.minimum_feature_level = minimum_feature_level;
device_create_info.instance = instance;
device_create_info.instance_create_info = NULL;
device_create_info.vk_physical_device = d3d12_find_physical_device(instance, pfn_vkGetInstanceProcAddr, &adapter_desc);
device_create_info.device_extensions = device_extensions;
device_create_info.device_extension_count = ARRAYSIZE(device_extensions);
device_create_info.optional_device_extensions = NULL;
device_create_info.optional_device_extension_count = 0;
device_create_info.parent = (IUnknown *)dxgi_adapter;
memcpy(&device_create_info.adapter_luid, &adapter_desc.AdapterLuid, VK_LUID_SIZE);
hr = vkd3d_create_device(&device_create_info, iid, device);
vkd3d_instance_decref(instance);
done:
IDXGIAdapter_Release(dxgi_adapter);
return hr;
}
HRESULT WINAPI DLLEXPORT D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer)
{
TRACE("data %p, data_size %lu, iid %s, deserializer %p.\n",
data, data_size, debugstr_guid(iid), deserializer);
return vkd3d_create_root_signature_deserializer(data, data_size, iid, deserializer);
}
HRESULT WINAPI DLLEXPORT D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *root_signature_desc,
D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob)
{
TRACE("root_signature_desc %p, version %#x, blob %p, error_blob %p.\n",
root_signature_desc, version, blob, error_blob);
return vkd3d_serialize_root_signature(root_signature_desc, version, blob, error_blob);
}
HRESULT WINAPI DLLEXPORT D3D12CreateVersionedRootSignatureDeserializer(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer)
{
TRACE("data %p, data_size %lu, iid %s, deserializer %p.\n",
data, data_size, debugstr_guid(iid), deserializer);
return vkd3d_create_versioned_root_signature_deserializer(data, data_size, iid, deserializer);
}
HRESULT WINAPI DLLEXPORT D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
ID3DBlob **blob, ID3DBlob **error_blob)
{
TRACE("desc %p, blob %p, error_blob %p.\n", desc, blob, error_blob);
return vkd3d_serialize_versioned_root_signature(desc, blob, error_blob);
}

16
libs/d3d12/meson.build Normal file
View File

@ -0,0 +1,16 @@
d3d12_src = [
'main.c'
]
d3d12_lib = shared_library('d3d12', d3d12_src,
name_prefix : '', # libd3d12.dll -> d3d12.dll
dependencies : [ vkd3d_dep, lib_dxgi ],
include_directories : vkd3d_private_includes,
install : true,
objects : not vkd3d_is_msvc ? 'd3d12.def' : [],
vs_module_defs : 'd3d12.def',
override_options : [ 'c_std='+vkd3d_c_std ])
d3d12_dep = declare_dependency(
link_with : d3d12_lib,
include_directories : vkd3d_public_includes)

7
libs/meson.build Normal file
View File

@ -0,0 +1,7 @@
subdir('vkd3d-common')
subdir('vkd3d-shader')
subdir('vkd3d')
subdir('vkd3d-utils')
if enable_d3d12
subdir('d3d12')
endif

View File

@ -16,7 +16,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_COUNT
#include "vkd3d_debug.h"
#include "vkd3d_threads.h"
#include "vkd3d_platform.h"
#include <assert.h>
#include <ctype.h>
@ -27,60 +31,103 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#define VKD3D_DEBUG_BUFFER_COUNT 64
#define VKD3D_DEBUG_BUFFER_SIZE 512
extern const char *vkd3d_dbg_env_name DECLSPEC_HIDDEN;
static const char *debug_level_names[] =
{
/* VKD3D_DBG_LEVEL_NONE */ "none",
/* VKD3D_DBG_LEVEL_ERR */ "err",
/* VKD3D_DBG_LEVEL_FIXME */ "fixme",
/* VKD3D_DBG_LEVEL_WARN */ "warn",
/* VKD3D_DBG_LEVEL_TRACE */ "trace",
/* VKD3D_DBG_LEVEL_UNKNOWN */ NULL,
/* VKD3D_DBG_LEVEL_NONE */ "none",
/* VKD3D_DBG_LEVEL_ERR */ "err",
/* VKD3D_DBG_LEVEL_INFO */ "info",
/* VKD3D_DBG_LEVEL_FIXME */ "fixme",
/* VKD3D_DBG_LEVEL_WARN */ "warn",
/* VKD3D_DBG_LEVEL_TRACE */ "trace",
};
enum vkd3d_dbg_level vkd3d_dbg_get_level(void)
static const char *env_for_channel[] =
{
static unsigned int level = ~0u;
const char *vkd3d_debug;
unsigned int i;
/* VKD3D_DBG_CHANNEL_API */ "VKD3D_DEBUG",
/* VKD3D_DBG_CHANNEL_SHADER */ "VKD3D_SHADER_DEBUG",
};
if (level != ~0u)
return level;
static unsigned int vkd3d_dbg_level[VKD3D_DBG_CHANNEL_COUNT];
static spinlock_t vkd3d_dbg_initialized;
static pthread_once_t vkd3d_dbg_once = PTHREAD_ONCE_INIT;
static FILE *vkd3d_log_file;
if (!(vkd3d_debug = getenv(vkd3d_dbg_env_name)))
vkd3d_debug = "";
static void vkd3d_dbg_init_once(void)
{
char vkd3d_debug[VKD3D_PATH_MAX];
unsigned int channel, i;
for (i = 0; i < ARRAY_SIZE(debug_level_names); ++i)
for (channel = 0; channel < VKD3D_DBG_CHANNEL_COUNT; channel++)
{
if (!strcmp(debug_level_names[i], vkd3d_debug))
if (!vkd3d_get_env_var(env_for_channel[channel], vkd3d_debug, sizeof(vkd3d_debug)))
strncpy(vkd3d_debug, "", VKD3D_PATH_MAX);
for (i = 1; i < ARRAY_SIZE(debug_level_names); ++i)
if (!strcmp(debug_level_names[i], vkd3d_debug))
vkd3d_dbg_level[channel] = i;
/* Default debug level. */
if (vkd3d_dbg_level[channel] == VKD3D_DBG_LEVEL_UNKNOWN)
vkd3d_dbg_level[channel] = VKD3D_DBG_LEVEL_FIXME;
}
if (vkd3d_get_env_var("VKD3D_LOG_FILE", vkd3d_debug, sizeof(vkd3d_debug)))
{
vkd3d_log_file = fopen(vkd3d_debug, "w");
if (!vkd3d_log_file)
{
level = i;
return level;
fprintf(stderr, "Failed to open log file: %s!\n", vkd3d_debug);
fflush(stderr);
}
}
/* Default debug level. */
level = VKD3D_DBG_LEVEL_FIXME;
return level;
vkd3d_atomic_uint32_store_explicit(&vkd3d_dbg_initialized, 1, vkd3d_memory_order_release);
}
void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...)
static inline void vkd3d_dbg_init(void)
{
/* Early out since we're going to be spamming calls to vkd3d_dbg_init() for every trace call. */
if (!vkd3d_atomic_uint32_load_explicit(&vkd3d_dbg_initialized, vkd3d_memory_order_acquire))
pthread_once(&vkd3d_dbg_once, vkd3d_dbg_init_once);
}
enum vkd3d_dbg_level vkd3d_dbg_get_level(enum vkd3d_dbg_channel channel)
{
vkd3d_dbg_init();
if (channel >= VKD3D_DBG_CHANNEL_COUNT)
return VKD3D_DBG_LEVEL_FIXME;
assert(vkd3d_dbg_level[channel] != VKD3D_DBG_LEVEL_UNKNOWN);
return vkd3d_dbg_level[channel];
}
void vkd3d_dbg_printf(enum vkd3d_dbg_channel channel, enum vkd3d_dbg_level level, const char *function, const char *fmt, ...)
{
static spinlock_t spin;
unsigned int tid;
FILE *log_file;
va_list args;
if (vkd3d_dbg_get_level() < level)
if (vkd3d_dbg_get_level(channel) < level)
return;
log_file = vkd3d_log_file ? vkd3d_log_file : stderr;
assert(level < ARRAY_SIZE(debug_level_names));
fprintf(stderr, "%s:%s: ", debug_level_names[level], function);
tid = vkd3d_get_current_thread_id();
va_start(args, fmt);
vfprintf(stderr, fmt, args);
spinlock_acquire(&spin);
fprintf(log_file, "%04x:%s:%s: ", tid, debug_level_names[level], function);
vfprintf(log_file, fmt, args);
spinlock_release(&spin);
va_end(args);
fflush(log_file);
}
static char *get_buffer(void)
@ -174,10 +221,10 @@ const char *debugstr_a(const char *str)
return buffer;
}
static const char *debugstr_w16(const uint16_t *wstr)
const char *debugstr_w(const WCHAR *wstr)
{
char *buffer, *ptr;
uint16_t c;
WCHAR c;
if (!wstr)
return "(null)";
@ -234,80 +281,13 @@ static const char *debugstr_w16(const uint16_t *wstr)
return buffer;
}
static const char *debugstr_w32(const uint32_t *wstr)
{
char *buffer, *ptr;
uint32_t c;
if (!wstr)
return "(null)";
ptr = buffer = get_buffer();
*ptr++ = '"';
while ((c = *wstr++) && ptr <= buffer + VKD3D_DEBUG_BUFFER_SIZE - 10)
{
int escape_char;
switch (c)
{
case '"':
case '\\':
case '\n':
case '\r':
case '\t':
escape_char = c;
break;
default:
escape_char = 0;
break;
}
if (escape_char)
{
*ptr++ = '\\';
*ptr++ = escape_char;
continue;
}
if (isprint(c))
{
*ptr++ = c;
}
else
{
*ptr++ = '\\';
sprintf(ptr, "%04x", c);
ptr += 4;
}
}
*ptr++ = '"';
if (c)
{
*ptr++ = '.';
*ptr++ = '.';
*ptr++ = '.';
}
*ptr = '\0';
return buffer;
}
const char *debugstr_w(const WCHAR *wstr, size_t wchar_size)
{
if (wchar_size == 2)
return debugstr_w16((const uint16_t *)wstr);
return debugstr_w32((const uint32_t *)wstr);
}
unsigned int vkd3d_env_var_as_uint(const char *name, unsigned int default_value)
{
const char *value = getenv(name);
char value[VKD3D_PATH_MAX];
unsigned long r;
char *end_ptr;
if (value)
if (vkd3d_get_env_var(name, value, sizeof(value)) && strlen(value) > 0)
{
errno = 0;
r = strtoul(value, &end_ptr, 0);

View File

@ -0,0 +1,188 @@
/*
* Copyright 2022 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_file_utils.h"
#include "vkd3d_debug.h"
/* For disk cache. */
#ifdef _WIN32
#include <windows.h>
#include <io.h>
#else
#include <unistd.h>
#include <sys/mman.h>
#include <errno.h>
#endif
#include <fcntl.h>
#include <sys/stat.h>
#include <stdio.h>
bool vkd3d_file_rename_overwrite(const char *from_path, const char *to_path)
{
#ifdef _WIN32
DWORD code = ERROR_SUCCESS;
if (!MoveFileA(from_path, to_path))
{
code = GetLastError();
if (code == ERROR_ALREADY_EXISTS)
{
code = ERROR_SUCCESS;
if (!ReplaceFileA(to_path, from_path, NULL, 0, NULL, NULL))
code = GetLastError();
}
}
return code == ERROR_SUCCESS;
#else
return rename(from_path, to_path) == 0;
#endif
}
bool vkd3d_file_rename_no_replace(const char *from_path, const char *to_path)
{
#ifdef _WIN32
DWORD code = ERROR_SUCCESS;
if (!MoveFileA(from_path, to_path))
code = GetLastError();
return code == ERROR_SUCCESS;
#else
return renameat2(AT_FDCWD, from_path, AT_FDCWD, to_path, RENAME_NOREPLACE) == 0;
#endif
}
bool vkd3d_file_delete(const char *path)
{
#ifdef _WIN32
DWORD code = ERROR_SUCCESS;
if (!DeleteFileA(path))
code = GetLastError();
return code == ERROR_SUCCESS;
#else
return unlink(path) == 0;
#endif
}
FILE *vkd3d_file_open_exclusive_write(const char *path)
{
#ifdef _WIN32
/* From Fossilize. AFAIK, there is no direct way to make this work with FILE interface, so have to roundtrip
* through jank POSIX layer.
* wbx kinda works, but Wine warns about it, despite it working anyways.
* Older MSVC runtimes do not support wbx. */
FILE *file = NULL;
int fd;
fd = _open(path, _O_BINARY | _O_WRONLY | _O_CREAT | _O_EXCL | _O_TRUNC | _O_SEQUENTIAL,
_S_IWRITE | _S_IREAD);
if (fd >= 0)
{
file = _fdopen(fd, "wb");
/* _fdopen takes ownership. */
if (!file)
_close(fd);
}
return file;
#else
return fopen(path, "wbx");
#endif
}
void vkd3d_file_unmap(struct vkd3d_memory_mapped_file *file)
{
if (file->mapped)
{
#ifdef _WIN32
UnmapViewOfFile(file->mapped);
#else
munmap(file->mapped, file->mapped_size);
#endif
}
memset(file, 0, sizeof(*file));
}
bool vkd3d_file_map_read_only(const char *path, struct vkd3d_memory_mapped_file *file)
{
#ifdef _WIN32
DWORD size_hi, size_lo;
HANDLE file_mapping;
HANDLE handle;
#else
struct stat stat_buf;
int fd;
#endif
file->mapped = NULL;
file->mapped_size = 0;
#ifdef _WIN32
handle = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
INVALID_HANDLE_VALUE);
if (handle == INVALID_HANDLE_VALUE)
goto out;
size_lo = GetFileSize(handle, &size_hi);
file->mapped_size = size_lo | (((uint64_t)size_hi) << 32);
file_mapping = CreateFileMappingA(handle, NULL, PAGE_READONLY, 0, 0, NULL);
if (file_mapping == INVALID_HANDLE_VALUE)
goto out;
file->mapped = MapViewOfFile(file_mapping, FILE_MAP_READ, 0, 0, file->mapped_size);
CloseHandle(file_mapping);
file_mapping = INVALID_HANDLE_VALUE;
if (!file->mapped)
{
ERR("Failed to MapViewOfFile for %s.\n", path);
goto out;
}
out:
if (handle != INVALID_HANDLE_VALUE)
CloseHandle(handle);
#else
fd = open(path, O_RDONLY);
if (fd < 0)
goto out;
if (fstat(fd, &stat_buf) < 0)
{
ERR("Failed to fstat pipeline cache.\n");
goto out;
}
/* Map private to make sure we get CoW behavior in case someone clobbers
* the cache while in flight. We need to read data directly out of the cache. */
file->mapped = mmap(NULL, stat_buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (file->mapped != MAP_FAILED)
file->mapped_size = stat_buf.st_size;
else
goto out;
out:
if (fd >= 0)
close(fd);
#endif
if (!file->mapped)
file->mapped_size = 0;
return file->mapped != NULL;
}

View File

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_memory.h"
bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)

View File

@ -0,0 +1,17 @@
vkd3d_common_src = [
'debug.c',
'memory.c',
'utf8.c',
'profiling.c',
'string.c',
'file_utils.c',
'platform.c',
]
vkd3d_common_lib = static_library('vkd3d_common', vkd3d_common_src, vkd3d_header_files,
include_directories : vkd3d_private_includes,
override_options : [ 'c_std='+vkd3d_c_std ])
vkd3d_common_dep = declare_dependency(
link_with : vkd3d_common_lib,
include_directories : [ vkd3d_public_includes, vkd3d_common_lib.private_dir_include() ])

View File

@ -0,0 +1,198 @@
/*
* Copyright 2020 Joshua Ashton for Valve Corporation
*
* 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_platform.h"
#include <assert.h>
#include <stdio.h>
#if defined(__linux__)
# include <dlfcn.h>
# include <errno.h>
vkd3d_module_t vkd3d_dlopen(const char *name)
{
return dlopen(name, RTLD_NOW);
}
void *vkd3d_dlsym(vkd3d_module_t handle, const char *symbol)
{
return dlsym(handle, symbol);
}
int vkd3d_dlclose(vkd3d_module_t handle)
{
return dlclose(handle);
}
const char *vkd3d_dlerror(void)
{
return dlerror();
}
bool vkd3d_get_program_name(char program_name[VKD3D_PATH_MAX])
{
char *name, *p, *real_path = NULL;
if ((name = strrchr(program_invocation_name, '/')))
{
real_path = realpath("/proc/self/exe", NULL);
/* Try to strip command line arguments. */
if (real_path && (p = strrchr(real_path, '/'))
&& !strncmp(real_path, program_invocation_name, strlen(real_path)))
{
name = p;
}
++name;
}
else if ((name = strrchr(program_invocation_name, '\\')))
{
++name;
}
else
{
name = program_invocation_name;
}
strncpy(program_name, name, VKD3D_PATH_MAX);
program_name[VKD3D_PATH_MAX - 1] = '\0';
free(real_path);
return true;
}
#elif defined(_WIN32)
# include <windows.h>
vkd3d_module_t vkd3d_dlopen(const char *name)
{
return LoadLibraryA(name);
}
void *vkd3d_dlsym(vkd3d_module_t handle, const char *symbol)
{
return GetProcAddress(handle, symbol);
}
int vkd3d_dlclose(vkd3d_module_t handle)
{
FreeLibrary(handle);
return 0;
}
const char *vkd3d_dlerror(void)
{
return "Not implemented for this platform.";
}
bool vkd3d_get_program_name(char program_name[VKD3D_PATH_MAX])
{
char *name;
char exe_path[VKD3D_PATH_MAX];
GetModuleFileNameA(NULL, exe_path, VKD3D_PATH_MAX);
if ((name = strrchr(exe_path, '/')))
{
++name;
}
else if ((name = strrchr(exe_path, '\\')))
{
++name;
}
else
{
name = exe_path;
}
strncpy(program_name, name, VKD3D_PATH_MAX);
return true;
}
#else
vkd3d_module_t vkd3d_dlopen(const char *name)
{
FIXME("Not implemented for this platform.\n");
return NULL;
}
void *vkd3d_dlsym(vkd3d_module_t handle, const char *symbol)
{
return NULL;
}
int vkd3d_dlclose(vkd3d_module_t handle)
{
return 0;
}
const char *vkd3d_dlerror(void)
{
return "Not implemented for this platform.";
}
bool vkd3d_get_program_name(char program_name[VKD3D_PATH_MAX])
{
*program_name = '\0';
return false;
}
#endif
#if defined(_WIN32)
bool vkd3d_get_env_var(const char *name, char *value, size_t value_size)
{
DWORD len;
assert(value);
assert(value_size > 0);
len = GetEnvironmentVariableA(name, value, value_size);
if (len > 0 && len <= value_size)
{
return true;
}
value[0] = '\0';
return false;
}
#else
bool vkd3d_get_env_var(const char *name, char *value, size_t value_size)
{
const char *env_value;
assert(value);
assert(value_size > 0);
if ((env_value = getenv(name)))
{
snprintf(value, value_size, "%s", env_value);
return true;
}
value[0] = '\0';
return false;
}
#endif

View File

@ -0,0 +1,198 @@
/*
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifdef VKD3D_ENABLE_PROFILING
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_profiling.h"
#include "vkd3d_platform.h"
#include "vkd3d_threads.h"
#include "vkd3d_debug.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#endif
static pthread_once_t profiling_block_once = PTHREAD_ONCE_INIT;
static unsigned int profiling_region_count;
static spinlock_t profiling_lock;
struct vkd3d_profiling_block
{
uint64_t ticks_total;
uint64_t iteration_total;
char name[64 - 2 * sizeof(uint64_t)];
};
static struct vkd3d_profiling_block *mapped_blocks;
#define VKD3D_MAX_PROFILING_REGIONS 256
static spinlock_t region_locks[VKD3D_MAX_PROFILING_REGIONS];
#ifdef _WIN32
static void vkd3d_init_profiling_path(const char *path)
{
HANDLE profiling_fd;
HANDLE file_view;
char path_pid[_MAX_PATH];
snprintf(path_pid, sizeof(path_pid), "%s.%u", path, GetCurrentProcessId());
profiling_fd = CreateFileA(path_pid, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, INVALID_HANDLE_VALUE);
if (profiling_fd == INVALID_HANDLE_VALUE)
{
ERR("Failed to open profiling FD.\n");
return;
}
file_view = CreateFileMappingA(profiling_fd, NULL, PAGE_READWRITE, 0,
VKD3D_MAX_PROFILING_REGIONS * sizeof(*mapped_blocks), NULL);
if (file_view == INVALID_HANDLE_VALUE)
{
ERR("Failed to create profiling file view.\n");
CloseHandle(profiling_fd);
return;
}
mapped_blocks = MapViewOfFile(file_view, FILE_MAP_ALL_ACCESS, 0, 0,
VKD3D_MAX_PROFILING_REGIONS * sizeof(*mapped_blocks));
if (!mapped_blocks)
ERR("Failed to map view of file.\n");
CloseHandle(file_view);
CloseHandle(profiling_fd);
}
#else
static void vkd3d_init_profiling_path(const char *path)
{
int profiling_fd;
char path_pid[PATH_MAX];
snprintf(path_pid, sizeof(path_pid), "%s.%u", path, getpid());
profiling_fd = open(path_pid, O_RDWR | O_CREAT, 0644);
if (profiling_fd >= 0)
{
if (ftruncate(profiling_fd, VKD3D_MAX_PROFILING_REGIONS * sizeof(*mapped_blocks)) < 0)
{
ERR("Failed to resize profiling FD.\n");
close(profiling_fd);
return;
}
mapped_blocks = mmap(NULL, VKD3D_MAX_PROFILING_REGIONS * sizeof(*mapped_blocks),
PROT_READ | PROT_WRITE, MAP_SHARED, profiling_fd, 0);
if (!mapped_blocks)
{
ERR("Failed to map block.\n");
close(profiling_fd);
return;
}
memset(mapped_blocks, 0, VKD3D_MAX_PROFILING_REGIONS * sizeof(*mapped_blocks));
close(profiling_fd);
}
else
{
ERR("Failed to open profiling FD.\n");
}
}
#endif
static void vkd3d_init_profiling_once(void)
{
char path[VKD3D_PATH_MAX];
vkd3d_get_env_var("VKD3D_PROFILE_PATH", path, sizeof(path));
if (strlen(path) > 0)
vkd3d_init_profiling_path(path);
}
void vkd3d_init_profiling(void)
{
pthread_once(&profiling_block_once, vkd3d_init_profiling_once);
}
bool vkd3d_uses_profiling(void)
{
return mapped_blocks != NULL;
}
unsigned int vkd3d_profiling_register_region(const char *name, spinlock_t *lock, uint32_t *latch)
{
unsigned int index;
if (!mapped_blocks)
return 0;
spinlock_acquire(lock);
if (*latch == 0)
{
spinlock_acquire(&profiling_lock);
/* Begin at 1, 0 is reserved as a sentinel. */
index = ++profiling_region_count;
if (index <= VKD3D_MAX_PROFILING_REGIONS)
{
strncpy(mapped_blocks[index - 1].name, name, sizeof(mapped_blocks[index - 1].name) - 1);
/* Important to store with release semantics after we've initialized the block. */
vkd3d_atomic_uint32_store_explicit(latch, index, vkd3d_memory_order_release);
}
else
{
ERR("Too many profiling regions!\n");
index = 0;
}
spinlock_release(&profiling_lock);
}
else
index = *latch;
spinlock_release(lock);
return index;
}
void vkd3d_profiling_notify_work(unsigned int index,
uint64_t start_ticks, uint64_t end_ticks,
unsigned int iteration_count)
{
struct vkd3d_profiling_block *block;
spinlock_t *lock;
if (index == 0 || index > VKD3D_MAX_PROFILING_REGIONS || !mapped_blocks)
return;
index--;
lock = &region_locks[index];
block = &mapped_blocks[index];
spinlock_acquire(lock);
block->iteration_total += iteration_count;
block->ticks_total += end_ticks - start_ticks;
spinlock_release(lock);
}
#endif /* VKD3D_ENABLE_PROFILING */

176
libs/vkd3d-common/string.c Normal file
View File

@ -0,0 +1,176 @@
/*
* Copyright 2021 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_string.h"
#include "vkd3d_memory.h"
STATIC_ASSERT(sizeof(WCHAR) == sizeof(uint16_t));
char *vkd3d_strdup(const char *str)
{
/* strdup() is actually not standard. */
char *duped;
size_t len;
len = strlen(str) + 1;
duped = vkd3d_malloc(len);
if (duped)
memcpy(duped, str, len);
return duped;
}
char *vkd3d_strdup_n(const char *str, size_t n)
{
char *duped;
size_t len;
len = strnlen(str, n);
duped = vkd3d_malloc(len + 1);
if (duped)
{
memcpy(duped, str, len);
duped[len] = '\0';
}
return duped;
}
WCHAR *vkd3d_wstrdup(const WCHAR *str)
{
WCHAR *duped;
size_t len;
len = vkd3d_wcslen(str) + 1;
duped = vkd3d_malloc(len * sizeof(WCHAR));
if (duped)
memcpy(duped, str, len * sizeof(WCHAR));
return duped;
}
bool vkd3d_export_strequal(const WCHAR *a, const WCHAR *b)
{
if (!a || !b)
return false;
while (*a != '\0' && *b != '\0')
{
if (*a != *b)
return false;
a++;
b++;
}
return *a == *b;
}
bool vkd3d_export_strequal_mixed(const WCHAR *a, const char *b)
{
if (!a || !b)
return false;
while (*a != '\0' && *b != '\0')
{
if (*a != *b)
return false;
a++;
b++;
}
return *a == *b;
}
bool vkd3d_export_strequal_substr(const WCHAR *a, size_t expected_n, const WCHAR *b)
{
size_t n = 0;
if (!a || !b)
return false;
while (*a != '\0' && *b != '\0' && n < expected_n)
{
if (*a != *b)
return false;
a++;
b++;
n++;
}
return n == expected_n && *b == '\0';
}
WCHAR *vkd3d_dup_entry_point(const char *str)
{
return vkd3d_dup_entry_point_n(str, strlen(str));
}
WCHAR *vkd3d_dup_entry_point_n(const char *str, size_t len)
{
WCHAR *duped;
size_t i;
duped = vkd3d_malloc((len + 1) * sizeof(WCHAR));
if (!duped)
return NULL;
for (i = 0; i < len; i++)
duped[i] = (unsigned char)str[i];
duped[len] = 0;
return duped;
}
static bool is_valid_identifier_character(char v)
{
return (v >= 'a' && v <= 'z') || (v >= 'A' && v <= 'Z') || v == '_' || (v >= '0' && v <= '9');
}
static const char *vkd3d_manged_entry_point_scan(const char *entry, const char **out_end_entry)
{
const char *end_entry;
while (*entry != '\0' && !is_valid_identifier_character(*entry))
entry++;
end_entry = entry;
while (*end_entry != '\0' && is_valid_identifier_character(*end_entry))
end_entry++;
if (entry == end_entry)
return NULL;
*out_end_entry = end_entry;
return entry;
}
WCHAR *vkd3d_dup_demangled_entry_point(const char *entry)
{
const char *end_entry;
if (!(entry = vkd3d_manged_entry_point_scan(entry, &end_entry)))
return NULL;
return vkd3d_dup_entry_point_n(entry, end_entry - entry);
}
char *vkd3d_dup_demangled_entry_point_ascii(const char *entry)
{
const char *end_entry;
if (!(entry = vkd3d_manged_entry_point_scan(entry, &end_entry)))
return NULL;
return vkd3d_strdup_n(entry, end_entry - entry);
}

View File

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_memory.h"
#include "vkd3d_utf8.h"
@ -82,9 +84,9 @@ static void vkd3d_utf8_append(char **dst, uint32_t c)
*dst += 4;
}
static uint32_t vkd3d_utf16_read(const uint16_t **src)
static uint32_t vkd3d_utf16_read(const WCHAR **src)
{
const uint16_t *s = *src;
const WCHAR *s = *src;
if (s[0] < 0xd800 || s[0] > 0xdfff) /* Not a surrogate pair. */
{
@ -103,14 +105,20 @@ static uint32_t vkd3d_utf16_read(const uint16_t **src)
return 0x10000 + ((s[0] & 0x3ff) << 10) + (s[1] & 0x3ff);
}
static char *vkd3d_strdup_w16_utf8(const uint16_t *wstr)
static inline bool vkd3d_string_should_loop_u16(ptrdiff_t max_elements, const WCHAR* src, const WCHAR* wstr)
{
const uint16_t *src = wstr;
ptrdiff_t cursor_pos = src - wstr;
return (!max_elements || cursor_pos < max_elements) && *src;
}
char *vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t max_elements)
{
const WCHAR *src = wstr;
size_t dst_size = 0;
char *dst, *utf8;
uint32_t c;
while (*src)
while (vkd3d_string_should_loop_u16(max_elements, src, wstr))
{
if (!(c = vkd3d_utf16_read(&src)))
continue;
@ -123,42 +131,13 @@ static char *vkd3d_strdup_w16_utf8(const uint16_t *wstr)
utf8 = dst;
src = wstr;
while (*src)
while (vkd3d_string_should_loop_u16(max_elements, src, wstr))
{
if (!(c = vkd3d_utf16_read(&src)))
continue;
vkd3d_utf8_append(&utf8, c);
}
*utf8 = 0;
*utf8 = '\0';
return dst;
}
static char *vkd3d_strdup_w32_utf8(const uint32_t *wstr)
{
const uint32_t *src = wstr;
size_t dst_size = 0;
char *dst, *utf8;
while (*src)
dst_size += vkd3d_utf8_len(*src++);
++dst_size;
if (!(dst = vkd3d_malloc(dst_size)))
return NULL;
utf8 = dst;
src = wstr;
while (*src)
vkd3d_utf8_append(&utf8, *src++);
*utf8 = 0;
return dst;
}
char *vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t wchar_size)
{
if (wchar_size == 2)
return vkd3d_strdup_w16_utf8((const uint16_t *)wstr);
return vkd3d_strdup_w32_utf8((const uint32_t *)wstr);
}

View File

@ -33,6 +33,8 @@
* will fill a supplied 16-byte array with the digest.
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_SHADER
#include "vkd3d_shader_private.h"
#define DXBC_CHECKSUM_BLOCK_SIZE 64

File diff suppressed because it is too large Load Diff

1640
libs/vkd3d-shader/dxil.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +0,0 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: vkd3d-shader
Description: The vkd3d Shader Translation Library
Version: @PACKAGE_VERSION@
Cflags: -I${includedir}/vkd3d
Libs: -L${libdir} -lvkd3d-shader

View File

@ -0,0 +1,18 @@
vkd3d_shader_src = [
'checksum.c',
'dxil.c',
'dxbc.c',
'spirv.c',
'trace.c',
'vkd3d_shader_main.c',
]
vkd3d_shader_lib = static_library('vkd3d-shader', vkd3d_shader_src,
dependencies : [ vkd3d_common_dep, dxil_spirv_dep ],
include_directories : vkd3d_private_includes,
override_options : [ 'c_std='+vkd3d_c_std ])
vkd3d_shader_dep = declare_dependency(
link_with : vkd3d_shader_lib,
dependencies : vkd3d_common_dep,
include_directories : vkd3d_public_includes)

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_SHADER
#include "vkd3d_shader_private.h"
#include <stdio.h>
@ -36,7 +38,6 @@ struct vkd3d_string_buffer
static const char * const shader_opcode_names[] =
{
/* VKD3DSIH_ABS */ "abs",
/* VKD3DSIH_ADD */ "add",
/* VKD3DSIH_AND */ "and",
/* VKD3DSIH_ATOMIC_AND */ "atomic_and",
@ -58,12 +59,9 @@ static const char * const shader_opcode_names[] =
/* VKD3DSIH_CALL */ "call",
/* VKD3DSIH_CALLNZ */ "callnz",
/* VKD3DSIH_CASE */ "case",
/* VKD3DSIH_CMP */ "cmp",
/* VKD3DSIH_CND */ "cnd",
/* VKD3DSIH_CONTINUE */ "continue",
/* VKD3DSIH_CONTINUEP */ "continuec",
/* VKD3DSIH_COUNTBITS */ "countbits",
/* VKD3DSIH_CRS */ "crs",
/* VKD3DSIH_CUT */ "cut",
/* VKD3DSIH_CUT_STREAM */ "cut_stream",
/* VKD3DSIH_DCL */ "dcl",
@ -106,16 +104,11 @@ static const char * const shader_opcode_names[] =
/* VKD3DSIH_DCL_UAV_STRUCTURED */ "dcl_uav_structured",
/* VKD3DSIH_DCL_UAV_TYPED */ "dcl_uav_typed",
/* VKD3DSIH_DCL_VERTICES_OUT */ "dcl_maxOutputVertexCount",
/* VKD3DSIH_DEF */ "def",
/* VKD3DSIH_DEFAULT */ "default",
/* VKD3DSIH_DEFB */ "defb",
/* VKD3DSIH_DEFI */ "defi",
/* VKD3DSIH_DIV */ "div",
/* VKD3DSIH_DP2 */ "dp2",
/* VKD3DSIH_DP2ADD */ "dp2add",
/* VKD3DSIH_DP3 */ "dp3",
/* VKD3DSIH_DP4 */ "dp4",
/* VKD3DSIH_DST */ "dst",
/* VKD3DSIH_DSX */ "dsx",
/* VKD3DSIH_DSX_COARSE */ "deriv_rtx_coarse",
/* VKD3DSIH_DSX_FINE */ "deriv_rtx_fine",
@ -124,16 +117,17 @@ static const char * const shader_opcode_names[] =
/* VKD3DSIH_DSY_FINE */ "deriv_rty_fine",
/* VKD3DSIH_ELSE */ "else",
/* VKD3DSIH_EMIT */ "emit",
/* VKD3DSIH_EMIT_THEN_CUT */ "emit_then_cut",
/* VKD3DSIH_EMIT_STREAM */ "emit_stream",
/* VKD3DSIH_EMIT_THEN_CUT_STREAM */ "emit_then_cut_stream",
/* VKD3DSIH_ENDIF */ "endif",
/* VKD3DSIH_ENDLOOP */ "endloop",
/* VKD3DSIH_ENDREP */ "endrep",
/* VKD3DSIH_ENDSWITCH */ "endswitch",
/* VKD3DSIH_EQ */ "eq",
/* VKD3DSIH_EVAL_CENTROID */ "eval_centroid",
/* VKD3DSIH_EVAL_SAMPLE_INDEX */ "eval_sample_index",
/* VKD3DSIH_EVAL_SNAPPED */ "eval_snapped",
/* VKD3DSIH_EXP */ "exp",
/* VKD3DSIH_EXPP */ "expp",
/* VKD3DSIH_F16TOF32 */ "f16tof32",
/* VKD3DSIH_F32TOF16 */ "f32tof16",
/* VKD3DSIH_FCALL */ "fcall",
@ -186,34 +180,23 @@ static const char * const shader_opcode_names[] =
/* VKD3DSIH_LD_RAW */ "ld_raw",
/* VKD3DSIH_LD_STRUCTURED */ "ld_structured",
/* VKD3DSIH_LD_UAV_TYPED */ "ld_uav_typed",
/* VKD3DSIH_LIT */ "lit",
/* VKD3DSIH_LOD */ "lod",
/* VKD3DSIH_LOG */ "log",
/* VKD3DSIH_LOGP */ "logp",
/* VKD3DSIH_LOOP */ "loop",
/* VKD3DSIH_LRP */ "lrp",
/* VKD3DSIH_LT */ "lt",
/* VKD3DSIH_M3x2 */ "m3x2",
/* VKD3DSIH_M3x3 */ "m3x3",
/* VKD3DSIH_M3x4 */ "m3x4",
/* VKD3DSIH_M4x3 */ "m4x3",
/* VKD3DSIH_M4x4 */ "m4x4",
/* VKD3DSIH_MAD */ "mad",
/* VKD3DSIH_MAX */ "max",
/* VKD3DSIH_MIN */ "min",
/* VKD3DSIH_MOV */ "mov",
/* VKD3DSIH_MOVA */ "mova",
/* VKD3DSIH_MOVC */ "movc",
/* VKD3DSIH_MUL */ "mul",
/* VKD3DSIH_NE */ "ne",
/* VKD3DSIH_NOP */ "nop",
/* VKD3DSIH_NOT */ "not",
/* VKD3DSIH_NRM */ "nrm",
/* VKD3DSIH_OR */ "or",
/* VKD3DSIH_PHASE */ "phase",
/* VKD3DSIH_POW */ "pow",
/* VKD3DSIH_RCP */ "rcp",
/* VKD3DSIH_REP */ "rep",
/* VKD3DSIH_RESINFO */ "resinfo",
/* VKD3DSIH_RET */ "ret",
/* VKD3DSIH_RETP */ "retp",
@ -230,7 +213,6 @@ static const char * const shader_opcode_names[] =
/* VKD3DSIH_SAMPLE_INFO */ "sample_info",
/* VKD3DSIH_SAMPLE_LOD */ "sample_l",
/* VKD3DSIH_SAMPLE_POS */ "sample_pos",
/* VKD3DSIH_SETP */ "setp",
/* VKD3DSIH_SGE */ "sge",
/* VKD3DSIH_SGN */ "sgn",
/* VKD3DSIH_SINCOS */ "sincos",
@ -243,28 +225,7 @@ static const char * const shader_opcode_names[] =
/* VKD3DSIH_SWAPC */ "swapc",
/* VKD3DSIH_SWITCH */ "switch",
/* VKD3DSIH_SYNC */ "sync",
/* VKD3DSIH_TEX */ "texld",
/* VKD3DSIH_TEXBEM */ "texbem",
/* VKD3DSIH_TEXBEML */ "texbeml",
/* VKD3DSIH_TEXCOORD */ "texcrd",
/* VKD3DSIH_TEXDEPTH */ "texdepth",
/* VKD3DSIH_TEXDP3 */ "texdp3",
/* VKD3DSIH_TEXDP3TEX */ "texdp3tex",
/* VKD3DSIH_TEXKILL */ "texkill",
/* VKD3DSIH_TEXLDD */ "texldd",
/* VKD3DSIH_TEXLDL */ "texldl",
/* VKD3DSIH_TEXM3x2DEPTH */ "texm3x2depth",
/* VKD3DSIH_TEXM3x2PAD */ "texm3x2pad",
/* VKD3DSIH_TEXM3x2TEX */ "texm3x2tex",
/* VKD3DSIH_TEXM3x3 */ "texm3x3",
/* VKD3DSIH_TEXM3x3DIFF */ "texm3x3diff",
/* VKD3DSIH_TEXM3x3PAD */ "texm3x3pad",
/* VKD3DSIH_TEXM3x3SPEC */ "texm3x3spec",
/* VKD3DSIH_TEXM3x3TEX */ "texm3x3tex",
/* VKD3DSIH_TEXM3x3VSPEC */ "texm3x3vspec",
/* VKD3DSIH_TEXREG2AR */ "texreg2ar",
/* VKD3DSIH_TEXREG2GB */ "texreg2gb",
/* VKD3DSIH_TEXREG2RGB */ "texreg2rgb",
/* VKD3DSIH_DISCARD */ "discard",
/* VKD3DSIH_UBFE */ "ubfe",
/* VKD3DSIH_UDIV */ "udiv",
/* VKD3DSIH_UGE */ "uge",
@ -272,6 +233,7 @@ static const char * const shader_opcode_names[] =
/* VKD3DSIH_UMAX */ "umax",
/* VKD3DSIH_UMIN */ "umin",
/* VKD3DSIH_UMUL */ "umul",
/* VKD3DSIH_UMAD */ "umad",
/* VKD3DSIH_USHR */ "ushr",
/* VKD3DSIH_UTOF */ "utof",
/* VKD3DSIH_XOR */ "xor",
@ -381,22 +343,6 @@ static int shader_addline(struct vkd3d_string_buffer *buffer, const char *format
}
}
/* Convert floating point offset relative to a register file to an absolute
* offset for float constants. */
static unsigned int shader_get_float_offset(enum vkd3d_shader_register_type register_type, UINT register_idx)
{
switch (register_type)
{
case VKD3DSPR_CONST: return register_idx;
case VKD3DSPR_CONST2: return 2048 + register_idx;
case VKD3DSPR_CONST3: return 4096 + register_idx;
case VKD3DSPR_CONST4: return 6144 + register_idx;
default:
FIXME("Unsupported register type: %u.\n", register_type);
return register_idx;
}
}
static void shader_dump_global_flags(struct vkd3d_string_buffer *buffer, DWORD global_flags)
{
unsigned int i;
@ -412,6 +358,8 @@ static void shader_dump_global_flags(struct vkd3d_string_buffer *buffer, DWORD g
{VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL, "forceEarlyDepthStencil"},
{VKD3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS, "enableRawAndStructuredBuffers"},
{VKD3DSGF_ENABLE_MINIMUM_PRECISION, "enableMinimumPrecision"},
{VKD3DSGF_ENABLE_DOUBLE_PRECISION_FLOAT_OPS, "enableDoublePrecisionFloatOps"},
{VKD3DSGF_ENABLE_11_1_DOUBLE_EXTENSIONS, "enable11_1DoubleExtensions"},
};
for (i = 0; i < ARRAY_SIZE(global_flag_info); ++i)
@ -590,7 +538,7 @@ static void shader_dump_decl_usage(struct vkd3d_string_buffer *buffer,
break;
}
}
else if (semantic->reg.reg.type == VKD3DSPR_RESOURCE || semantic->reg.reg.type == VKD3DSPR_UAV)
else // if (semantic->reg.reg.type == VKD3DSPR_RESOURCE || semantic->reg.reg.type == VKD3DSPR_UAV)
{
if (semantic->reg.reg.type == VKD3DSPR_RESOURCE)
shader_addline(buffer, "_resource_");
@ -671,80 +619,6 @@ static void shader_dump_decl_usage(struct vkd3d_string_buffer *buffer,
break;
}
}
else
{
/* Pixel shaders 3.0 don't have usage semantics. */
if (shader_version->major < 3 && shader_version->type == VKD3D_SHADER_TYPE_PIXEL)
return;
else
shader_addline(buffer, "_");
switch (semantic->usage)
{
case VKD3D_DECL_USAGE_POSITION:
shader_addline(buffer, "position%u", semantic->usage_idx);
break;
case VKD3D_DECL_USAGE_BLEND_INDICES:
shader_addline(buffer, "blend");
break;
case VKD3D_DECL_USAGE_BLEND_WEIGHT:
shader_addline(buffer, "weight");
break;
case VKD3D_DECL_USAGE_NORMAL:
shader_addline(buffer, "normal%u", semantic->usage_idx);
break;
case VKD3D_DECL_USAGE_PSIZE:
shader_addline(buffer, "psize");
break;
case VKD3D_DECL_USAGE_COLOR:
if (!semantic->usage_idx)
shader_addline(buffer, "color");
else
shader_addline(buffer, "specular%u", (semantic->usage_idx - 1));
break;
case VKD3D_DECL_USAGE_TEXCOORD:
shader_addline(buffer, "texture%u", semantic->usage_idx);
break;
case VKD3D_DECL_USAGE_TANGENT:
shader_addline(buffer, "tangent");
break;
case VKD3D_DECL_USAGE_BINORMAL:
shader_addline(buffer, "binormal");
break;
case VKD3D_DECL_USAGE_TESS_FACTOR:
shader_addline(buffer, "tessfactor");
break;
case VKD3D_DECL_USAGE_POSITIONT:
shader_addline(buffer, "positionT%u", semantic->usage_idx);
break;
case VKD3D_DECL_USAGE_FOG:
shader_addline(buffer, "fog");
break;
case VKD3D_DECL_USAGE_DEPTH:
shader_addline(buffer, "depth");
break;
case VKD3D_DECL_USAGE_SAMPLE:
shader_addline(buffer, "sample");
break;
default:
shader_addline(buffer, "<unknown_semantic(%#x)>", semantic->usage);
FIXME("Unrecognised semantic usage %#x.\n", semantic->usage);
}
}
}
static void shader_dump_src_param(struct vkd3d_string_buffer *buffer,
@ -753,8 +627,6 @@ static void shader_dump_src_param(struct vkd3d_string_buffer *buffer,
static void shader_dump_register(struct vkd3d_string_buffer *buffer,
const struct vkd3d_shader_register *reg, const struct vkd3d_shader_version *shader_version)
{
static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
static const char * const misctype_reg_names[] = {"vPos", "vFace"};
unsigned int offset = reg->idx[0].offset;
switch (reg->type)
@ -767,22 +639,6 @@ static void shader_dump_register(struct vkd3d_string_buffer *buffer,
shader_addline(buffer, "v");
break;
case VKD3DSPR_CONST:
case VKD3DSPR_CONST2:
case VKD3DSPR_CONST3:
case VKD3DSPR_CONST4:
shader_addline(buffer, "c");
offset = shader_get_float_offset(reg->type, offset);
break;
case VKD3DSPR_TEXTURE: /* vs: case VKD3DSPR_ADDR */
shader_addline(buffer, "%c", shader_version->type == VKD3D_SHADER_TYPE_PIXEL ? 't' : 'a');
break;
case VKD3DSPR_RASTOUT:
shader_addline(buffer, "%s", rastout_reg_names[offset]);
break;
case VKD3DSPR_COLOROUT:
shader_addline(buffer, "oC");
break;
@ -799,59 +655,22 @@ static void shader_dump_register(struct vkd3d_string_buffer *buffer,
shader_addline(buffer, "oDepthLE");
break;
case VKD3DSPR_ATTROUT:
shader_addline(buffer, "oD");
break;
case VKD3DSPR_TEXCRDOUT:
/* Vertex shaders >= 3.0 use general purpose output registers
* (VKD3DSPR_OUTPUT), which can include an address token. */
if (shader_version->major >= 3)
shader_addline(buffer, "o");
else
shader_addline(buffer, "oT");
break;
case VKD3DSPR_CONSTINT:
shader_addline(buffer, "i");
break;
case VKD3DSPR_CONSTBOOL:
shader_addline(buffer, "b");
break;
case VKD3DSPR_LABEL:
shader_addline(buffer, "l");
break;
case VKD3DSPR_LOOP:
shader_addline(buffer, "aL");
case VKD3DSPR_OUTPUT:
shader_addline(buffer, "o");
break;
case VKD3DSPR_SAMPLER:
shader_addline(buffer, "s");
break;
case VKD3DSPR_MISCTYPE:
if (offset > 1)
{
FIXME("Unhandled misctype register %u.\n", offset);
shader_addline(buffer, "<unhandled misctype %#x>", offset);
}
else
{
shader_addline(buffer, "%s", misctype_reg_names[offset]);
}
break;
case VKD3DSPR_PREDICATE:
shader_addline(buffer, "p");
break;
case VKD3DSPR_IMMCONST:
shader_addline(buffer, "l");
break;
case VKD3DSPR_IMMCONST64:
shader_addline(buffer, "d");
break;
case VKD3DSPR_CONSTBUFFER:
shader_addline(buffer, "cb");
break;
@ -970,15 +789,15 @@ static void shader_dump_register(struct vkd3d_string_buffer *buffer,
switch (reg->data_type)
{
case VKD3D_DATA_FLOAT:
shader_addline(buffer, "%.8e", reg->u.immconst_float[0]);
shader_addline(buffer, "%.8e", reg->immconst_float[0]);
break;
case VKD3D_DATA_INT:
shader_addline(buffer, "%d", reg->u.immconst_uint[0]);
shader_addline(buffer, "%d", reg->immconst_uint[0]);
break;
case VKD3D_DATA_RESOURCE:
case VKD3D_DATA_SAMPLER:
case VKD3D_DATA_UINT:
shader_addline(buffer, "%u", reg->u.immconst_uint[0]);
shader_addline(buffer, "%u", reg->immconst_uint[0]);
break;
default:
shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
@ -991,20 +810,20 @@ static void shader_dump_register(struct vkd3d_string_buffer *buffer,
{
case VKD3D_DATA_FLOAT:
shader_addline(buffer, "%.8e, %.8e, %.8e, %.8e",
reg->u.immconst_float[0], reg->u.immconst_float[1],
reg->u.immconst_float[2], reg->u.immconst_float[3]);
reg->immconst_float[0], reg->immconst_float[1],
reg->immconst_float[2], reg->immconst_float[3]);
break;
case VKD3D_DATA_INT:
shader_addline(buffer, "%d, %d, %d, %d",
reg->u.immconst_uint[0], reg->u.immconst_uint[1],
reg->u.immconst_uint[2], reg->u.immconst_uint[3]);
reg->immconst_uint[0], reg->immconst_uint[1],
reg->immconst_uint[2], reg->immconst_uint[3]);
break;
case VKD3D_DATA_RESOURCE:
case VKD3D_DATA_SAMPLER:
case VKD3D_DATA_UINT:
shader_addline(buffer, "%u, %u, %u, %u",
reg->u.immconst_uint[0], reg->u.immconst_uint[1],
reg->u.immconst_uint[2], reg->u.immconst_uint[3]);
reg->immconst_uint[0], reg->immconst_uint[1],
reg->immconst_uint[2], reg->immconst_uint[3]);
break;
default:
shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
@ -1018,9 +837,43 @@ static void shader_dump_register(struct vkd3d_string_buffer *buffer,
}
shader_addline(buffer, ")");
}
else if (reg->type != VKD3DSPR_RASTOUT
&& reg->type != VKD3DSPR_MISCTYPE
&& reg->type != VKD3DSPR_NULL)
else if (reg->type == VKD3DSPR_IMMCONST64)
{
shader_addline(buffer, "(");
switch (reg->immconst_type)
{
case VKD3D_IMMCONST_SCALAR:
switch (reg->data_type)
{
case VKD3D_DATA_DOUBLE:
shader_addline(buffer, "%f", reg->immconst_double[0]);
break;
default:
shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
break;
}
break;
case VKD3D_IMMCONST_DVEC2:
switch (reg->data_type)
{
case VKD3D_DATA_DOUBLE:
shader_addline(buffer, "%f, %f",
reg->immconst_double[0], reg->immconst_double[1]);
break;
default:
shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
break;
}
break;
default:
shader_addline(buffer, "<unhandled immconst_type %#x>", reg->immconst_type);
break;
}
shader_addline(buffer, ")");
}
else if (reg->type != VKD3DSPR_NULL)
{
if (offset != ~0u)
{
@ -1056,7 +909,7 @@ static void shader_dump_register(struct vkd3d_string_buffer *buffer,
}
if (reg->type == VKD3DSPR_FUNCTIONPOINTER)
shader_addline(buffer, "[%u]", reg->u.fp_body_idx);
shader_addline(buffer, "[%u]", reg->fp_body_idx);
}
}
@ -1089,16 +942,8 @@ static void shader_dump_src_param(struct vkd3d_string_buffer *buffer,
enum vkd3d_shader_src_modifier src_modifier = param->modifiers;
DWORD swizzle = param->swizzle;
if (src_modifier == VKD3DSPSM_NEG
|| src_modifier == VKD3DSPSM_BIASNEG
|| src_modifier == VKD3DSPSM_SIGNNEG
|| src_modifier == VKD3DSPSM_X2NEG
|| src_modifier == VKD3DSPSM_ABSNEG)
if (src_modifier == VKD3DSPSM_NEG || src_modifier == VKD3DSPSM_ABSNEG)
shader_addline(buffer, "-");
else if (src_modifier == VKD3DSPSM_COMP)
shader_addline(buffer, "1-");
else if (src_modifier == VKD3DSPSM_NOT)
shader_addline(buffer, "!");
if (src_modifier == VKD3DSPSM_ABS || src_modifier == VKD3DSPSM_ABSNEG)
shader_addline(buffer, "abs(");
@ -1109,16 +954,6 @@ static void shader_dump_src_param(struct vkd3d_string_buffer *buffer,
{
case VKD3DSPSM_NONE: break;
case VKD3DSPSM_NEG: break;
case VKD3DSPSM_NOT: break;
case VKD3DSPSM_BIAS: shader_addline(buffer, "_bias"); break;
case VKD3DSPSM_BIASNEG: shader_addline(buffer, "_bias"); break;
case VKD3DSPSM_SIGN: shader_addline(buffer, "_bx2"); break;
case VKD3DSPSM_SIGNNEG: shader_addline(buffer, "_bx2"); break;
case VKD3DSPSM_COMP: break;
case VKD3DSPSM_X2: shader_addline(buffer, "_x2"); break;
case VKD3DSPSM_X2NEG: shader_addline(buffer, "_x2"); break;
case VKD3DSPSM_DZ: shader_addline(buffer, "_dz"); break;
case VKD3DSPSM_DW: shader_addline(buffer, "_dw"); break;
case VKD3DSPSM_ABSNEG: shader_addline(buffer, ")"); break;
case VKD3DSPSM_ABS: shader_addline(buffer, ")"); break;
default: shader_addline(buffer, "_unknown_modifier(%#x)", src_modifier);
@ -1151,23 +986,9 @@ static void shader_dump_ins_modifiers(struct vkd3d_string_buffer *buffer,
{
DWORD mmask = dst->modifiers;
switch (dst->shift)
{
case 0: break;
case 13: shader_addline(buffer, "_d8"); break;
case 14: shader_addline(buffer, "_d4"); break;
case 15: shader_addline(buffer, "_d2"); break;
case 1: shader_addline(buffer, "_x2"); break;
case 2: shader_addline(buffer, "_x4"); break;
case 3: shader_addline(buffer, "_x8"); break;
default: shader_addline(buffer, "_unhandled_shift(%d)", dst->shift); break;
}
if (mmask & VKD3DSPDM_SATURATE) shader_addline(buffer, "_sat");
if (mmask & VKD3DSPDM_PARTIALPRECISION) shader_addline(buffer, "_pp");
if (mmask & VKD3DSPDM_MSAMPCENTROID) shader_addline(buffer, "_centroid");
mmask &= ~(VKD3DSPDM_SATURATE | VKD3DSPDM_PARTIALPRECISION | VKD3DSPDM_MSAMPCENTROID);
mmask &= ~(VKD3DSPDM_SATURATE);
if (mmask) FIXME("Unrecognised modifier %#x.\n", mmask);
}
@ -1287,7 +1108,7 @@ static void shader_dump_instruction_flags(struct vkd3d_string_buffer *buffer,
case VKD3DSIH_CONTINUEP:
case VKD3DSIH_IF:
case VKD3DSIH_RETP:
case VKD3DSIH_TEXKILL:
case VKD3DSIH_DISCARD:
switch (ins->flags)
{
case VKD3D_SHADER_CONDITIONAL_OP_NZ: shader_addline(buffer, "_nz"); break;
@ -1333,11 +1154,6 @@ static void shader_dump_instruction_flags(struct vkd3d_string_buffer *buffer,
shader_dump_sync_flags(buffer, ins->flags);
break;
case VKD3DSIH_TEX:
if (shader_version->major >= 2 && (ins->flags & VKD3DSI_TEXLD_PROJECT))
shader_addline(buffer, "p");
break;
default:
shader_dump_precise_flags(buffer, ins->flags);
break;
@ -1550,24 +1366,6 @@ static void shader_dump_instruction(struct vkd3d_string_buffer *buffer,
shader_dump_register_space(buffer, ins->declaration.structured_resource.register_space, shader_version);
break;
case VKD3DSIH_DEF:
shader_addline(buffer, "def c%u = %.8e, %.8e, %.8e, %.8e",
shader_get_float_offset(ins->dst[0].reg.type, ins->dst[0].reg.idx[0].offset),
ins->src[0].reg.u.immconst_float[0], ins->src[0].reg.u.immconst_float[1],
ins->src[0].reg.u.immconst_float[2], ins->src[0].reg.u.immconst_float[3]);
break;
case VKD3DSIH_DEFI:
shader_addline(buffer, "defi i%u = %d, %d, %d, %d", ins->dst[0].reg.idx[0].offset,
ins->src[0].reg.u.immconst_uint[0], ins->src[0].reg.u.immconst_uint[1],
ins->src[0].reg.u.immconst_uint[2], ins->src[0].reg.u.immconst_uint[3]);
break;
case VKD3DSIH_DEFB:
shader_addline(buffer, "defb b%u = %s",
ins->dst[0].reg.idx[0].offset, ins->src[0].reg.u.immconst_uint[0] ? "true" : "false");
break;
default:
if (ins->predicate)
{

View File

@ -1,16 +0,0 @@
VKD3D_1_0
{
global:
vkd3d_shader_compile_dxbc;
vkd3d_shader_convert_root_signature;
vkd3d_shader_find_signature_element;
vkd3d_shader_free_root_signature;
vkd3d_shader_free_shader_code;
vkd3d_shader_free_shader_signature;
vkd3d_shader_parse_input_signature;
vkd3d_shader_parse_root_signature;
vkd3d_shader_scan_dxbc;
vkd3d_shader_serialize_root_signature;
local: *;
};

View File

@ -16,53 +16,160 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_SHADER
#include "vkd3d_shader_private.h"
#include "vkd3d_platform.h"
#include <stdio.h>
#include <inttypes.h>
VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG");
STATIC_ASSERT(MEMBER_SIZE(struct vkd3d_shader_scan_info, uav_counter_mask) * CHAR_BIT >= VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS);
STATIC_ASSERT(MEMBER_SIZE(struct vkd3d_shader_scan_info, uav_read_mask) * CHAR_BIT >= VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS);
static void vkd3d_shader_dump_blob(const char *path, const char *prefix, const void *data, size_t size)
static void vkd3d_shader_dump_blob(const char *path, vkd3d_shader_hash_t hash, const void *data, size_t size, const char *ext)
{
static int shader_id = 0;
char filename[1024];
unsigned int id;
FILE *f;
id = InterlockedIncrement(&shader_id) - 1;
snprintf(filename, ARRAY_SIZE(filename), "%s/%016"PRIx64".%s", path, hash, ext);
snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%s-%u.dxbc", path, prefix, id);
if ((f = fopen(filename, "wb")))
INFO("Dumping blob to %s.\n", filename);
/* Exclusive open to avoid multiple threads spamming out the same shader module, and avoids race condition. */
if ((f = fopen(filename, "wbx")))
{
if (fwrite(data, 1, size, f) != size)
ERR("Failed to write shader to %s.\n", filename);
if (fclose(f))
ERR("Failed to close stream %s.\n", filename);
}
else
{
ERR("Failed to open %s for dumping shader.\n", filename);
}
}
static void vkd3d_shader_dump_shader(enum vkd3d_shader_type type, const struct vkd3d_shader_code *shader)
static bool vkd3d_shader_replace_path(const char *filename, vkd3d_shader_hash_t hash, const void **data, size_t *size)
{
void *buffer = NULL;
FILE *f = NULL;
size_t len;
if ((f = fopen(filename, "rb")))
{
if (fseek(f, 0, SEEK_END) < 0)
goto err;
len = ftell(f);
if (len < 16)
goto err;
rewind(f);
buffer = vkd3d_malloc(len);
if (!buffer)
goto err;
if (fread(buffer, 1, len, f) != len)
goto err;
}
else
goto err;
*data = buffer;
*size = len;
INFO("Overriding shader hash %016"PRIx64" with alternative SPIR-V module from %s!\n", hash, filename);
fclose(f);
return true;
err:
if (f)
fclose(f);
vkd3d_free(buffer);
return false;
}
bool vkd3d_shader_replace(vkd3d_shader_hash_t hash, const void **data, size_t *size)
{
static bool enabled = true;
const char *path;
char path[VKD3D_PATH_MAX];
char filename[1024];
if (!enabled)
return false;
if (!vkd3d_get_env_var("VKD3D_SHADER_OVERRIDE", path, sizeof(path)))
{
enabled = false;
return false;
}
snprintf(filename, ARRAY_SIZE(filename), "%s/%016"PRIx64".spv", path, hash);
return vkd3d_shader_replace_path(filename, hash, data, size);
}
bool vkd3d_shader_replace_export(vkd3d_shader_hash_t hash, const void **data, size_t *size, const char *export)
{
static bool enabled = true;
char path[VKD3D_PATH_MAX];
char filename[1024];
if (!enabled)
return false;
if (!vkd3d_get_env_var("VKD3D_SHADER_OVERRIDE", path, sizeof(path)))
{
enabled = false;
return false;
}
snprintf(filename, ARRAY_SIZE(filename), "%s/%016"PRIx64".lib.%s.spv", path, hash, export);
return vkd3d_shader_replace_path(filename, hash, data, size);
}
void vkd3d_shader_dump_shader(vkd3d_shader_hash_t hash, const struct vkd3d_shader_code *shader, const char *ext)
{
static bool enabled = true;
char path[VKD3D_PATH_MAX];
if (!enabled)
return;
if (!(path = getenv("VKD3D_SHADER_DUMP_PATH")))
if (!vkd3d_get_env_var("VKD3D_SHADER_DUMP_PATH", path, sizeof(path)))
{
enabled = false;
return;
}
vkd3d_shader_dump_blob(path, shader_get_type_prefix(type), shader->code, shader->size);
vkd3d_shader_dump_blob(path, hash, shader->code, shader->size, ext);
}
void vkd3d_shader_dump_spirv_shader(vkd3d_shader_hash_t hash, const struct vkd3d_shader_code *shader)
{
static bool enabled = true;
char path[VKD3D_PATH_MAX];
if (!enabled)
return;
if (!vkd3d_get_env_var("VKD3D_SHADER_DUMP_PATH", path, sizeof(path)))
{
enabled = false;
return;
}
vkd3d_shader_dump_blob(path, hash, shader->code, shader->size, "spv");
}
void vkd3d_shader_dump_spirv_shader_export(vkd3d_shader_hash_t hash, const struct vkd3d_shader_code *shader,
const char *export)
{
static bool enabled = true;
char path[VKD3D_PATH_MAX];
char tag[1024];
if (!enabled)
return;
if (!vkd3d_get_env_var("VKD3D_SHADER_DUMP_PATH", path, sizeof(path)))
{
enabled = false;
return;
}
snprintf(tag, sizeof(tag), "lib.%s.spv", export);
vkd3d_shader_dump_blob(path, hash, shader->code, shader->size, tag);
}
struct vkd3d_shader_parser
@ -108,15 +215,8 @@ static int vkd3d_shader_validate_compile_args(const struct vkd3d_shader_compile_
if (!compile_args)
return VKD3D_OK;
if (compile_args->type != VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS)
{
WARN("Invalid structure type %#x.\n", compile_args->type);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
switch (compile_args->target)
{
case VKD3D_SHADER_TARGET_SPIRV_OPENGL_4_5:
case VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0:
break;
default:
@ -127,6 +227,100 @@ static int vkd3d_shader_validate_compile_args(const struct vkd3d_shader_compile_
return VKD3D_OK;
}
struct vkd3d_shader_scan_key
{
enum vkd3d_shader_register_type register_type;
unsigned int register_id;
};
struct vkd3d_shader_scan_entry
{
struct hash_map_entry entry;
struct vkd3d_shader_scan_key key;
unsigned int flags;
};
static uint32_t vkd3d_shader_scan_entry_hash(const void *key)
{
const struct vkd3d_shader_scan_key *k = key;
return hash_combine(k->register_type, k->register_id);
}
static bool vkd3d_shader_scan_entry_compare(const void *key, const struct hash_map_entry *entry)
{
const struct vkd3d_shader_scan_entry *e = (const struct vkd3d_shader_scan_entry*) entry;
const struct vkd3d_shader_scan_key *k = key;
return e->key.register_type == k->register_type && e->key.register_id == k->register_id;
}
unsigned int vkd3d_shader_scan_get_register_flags(const struct vkd3d_shader_scan_info *scan_info,
enum vkd3d_shader_register_type type, unsigned int id)
{
struct vkd3d_shader_scan_key key;
struct hash_map_entry *e;
key.register_type = type;
key.register_id = id;
e = hash_map_find(&scan_info->register_map, &key);
return e ? e->flags : 0u;
}
static void vkd3d_shader_scan_set_register_flags(struct vkd3d_shader_scan_info *scan_info,
enum vkd3d_shader_register_type type, unsigned int id, unsigned int flags)
{
struct vkd3d_shader_scan_entry entry;
struct vkd3d_shader_scan_key key;
struct hash_map_entry *e;
key.register_type = type;
key.register_id = id;
if ((e = hash_map_find(&scan_info->register_map, &key)))
e->flags |= flags;
else
{
entry.key = key;
entry.flags = flags;
hash_map_insert(&scan_info->register_map, &key, &entry.entry);
}
}
static void vkd3d_shader_scan_init(struct vkd3d_shader_scan_info *scan_info)
{
memset(scan_info, 0, sizeof(*scan_info));
hash_map_init(&scan_info->register_map, &vkd3d_shader_scan_entry_hash,
&vkd3d_shader_scan_entry_compare, sizeof(struct vkd3d_shader_scan_entry));
}
static void vkd3d_shader_scan_destroy(struct vkd3d_shader_scan_info *scan_info)
{
hash_map_clear(&scan_info->register_map);
}
static int vkd3d_shader_validate_shader_type(enum vkd3d_shader_type type, VkShaderStageFlagBits stages)
{
static const VkShaderStageFlagBits table[VKD3D_SHADER_TYPE_COUNT] = {
VK_SHADER_STAGE_FRAGMENT_BIT,
VK_SHADER_STAGE_VERTEX_BIT,
VK_SHADER_STAGE_GEOMETRY_BIT,
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
VK_SHADER_STAGE_COMPUTE_BIT,
};
if (type >= VKD3D_SHADER_TYPE_COUNT)
return VKD3D_ERROR_INVALID_ARGUMENT;
if (table[type] != stages)
{
ERR("Expected VkShaderStage #%x, but got VkShaderStage #%x.\n", stages, table[type]);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
return 0;
}
int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
struct vkd3d_shader_code *spirv, unsigned int compiler_options,
const struct vkd3d_shader_interface_info *shader_interface_info,
@ -136,37 +330,67 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
struct vkd3d_dxbc_compiler *spirv_compiler;
struct vkd3d_shader_scan_info scan_info;
struct vkd3d_shader_parser parser;
vkd3d_shader_hash_t hash;
int ret;
TRACE("dxbc {%p, %zu}, spirv %p, compiler_options %#x, shader_interface_info %p, compile_args %p.\n",
dxbc->code, dxbc->size, spirv, compiler_options, shader_interface_info, compile_args);
if (shader_interface_info && shader_interface_info->type != VKD3D_SHADER_STRUCTURE_TYPE_SHADER_INTERFACE_INFO)
{
WARN("Invalid structure type %#x.\n", shader_interface_info->type);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
if ((ret = vkd3d_shader_validate_compile_args(compile_args)) < 0)
return ret;
scan_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO;
scan_info.next = NULL;
/* DXIL is handled externally through dxil-spirv. */
if (shader_is_dxil(dxbc->code, dxbc->size))
{
return vkd3d_shader_compile_dxil(dxbc, spirv, shader_interface_info, compile_args);
}
memset(&spirv->meta, 0, sizeof(spirv->meta));
hash = vkd3d_shader_hash(dxbc);
spirv->meta.hash = hash;
if (vkd3d_shader_replace(hash, &spirv->code, &spirv->size))
{
spirv->meta.flags |= VKD3D_SHADER_META_FLAG_REPLACED;
return VKD3D_OK;
}
vkd3d_shader_scan_init(&scan_info);
if ((ret = vkd3d_shader_scan_dxbc(dxbc, &scan_info)) < 0)
{
vkd3d_shader_scan_destroy(&scan_info);
return ret;
}
spirv->meta.patch_vertex_count = scan_info.patch_vertex_count;
if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0)
{
vkd3d_shader_scan_destroy(&scan_info);
return ret;
}
vkd3d_shader_dump_shader(parser.shader_version.type, dxbc);
if (shader_interface_info)
{
if ((ret = vkd3d_shader_validate_shader_type(parser.shader_version.type, shader_interface_info->stage)) < 0)
{
vkd3d_shader_scan_destroy(&scan_info);
return ret;
}
}
vkd3d_shader_dump_shader(hash, dxbc, "dxbc");
if (TRACE_ON())
vkd3d_shader_trace(parser.data);
if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser.shader_version,
&parser.shader_desc, compiler_options, shader_interface_info, compile_args, &scan_info)))
&parser.shader_desc, compiler_options, shader_interface_info, compile_args, &scan_info,
spirv->meta.hash)))
{
ERR("Failed to create DXBC compiler.\n");
vkd3d_shader_scan_destroy(&scan_info);
vkd3d_shader_parser_destroy(&parser);
return VKD3D_ERROR;
}
@ -179,6 +403,7 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
{
WARN("Encountered unrecognized or invalid instruction.\n");
vkd3d_dxbc_compiler_destroy(spirv_compiler);
vkd3d_shader_scan_destroy(&scan_info);
vkd3d_shader_parser_destroy(&parser);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
@ -190,7 +415,11 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
if (ret >= 0)
ret = vkd3d_dxbc_compiler_generate_spirv(spirv_compiler, spirv);
if (ret == 0)
vkd3d_shader_dump_spirv_shader(hash, spirv);
vkd3d_dxbc_compiler_destroy(spirv_compiler);
vkd3d_shader_scan_destroy(&scan_info);
vkd3d_shader_parser_destroy(&parser);
return ret;
}
@ -200,16 +429,41 @@ static bool vkd3d_shader_instruction_is_uav_read(const struct vkd3d_shader_instr
enum VKD3D_SHADER_INSTRUCTION_HANDLER handler_idx = instruction->handler_idx;
return (VKD3DSIH_ATOMIC_AND <= handler_idx && handler_idx <= VKD3DSIH_ATOMIC_XOR)
|| (VKD3DSIH_IMM_ATOMIC_ALLOC <= handler_idx && handler_idx <= VKD3DSIH_IMM_ATOMIC_XOR)
|| handler_idx == VKD3DSIH_LD_UAV_TYPED
|| (handler_idx == VKD3DSIH_LD_RAW && instruction->src[1].reg.type == VKD3DSPR_UAV)
|| (handler_idx == VKD3DSIH_LD_STRUCTURED && instruction->src[2].reg.type == VKD3DSPR_UAV);
|| handler_idx == VKD3DSIH_LD_UAV_TYPED || handler_idx == VKD3DSIH_LD_UAV_TYPED_FEEDBACK
|| ((handler_idx == VKD3DSIH_LD_RAW || handler_idx == VKD3DSIH_LD_RAW_FEEDBACK) && instruction->src[1].reg.type == VKD3DSPR_UAV)
|| ((handler_idx == VKD3DSIH_LD_STRUCTURED || handler_idx == VKD3DSIH_LD_STRUCTURED_FEEDBACK) && instruction->src[2].reg.type == VKD3DSPR_UAV);
}
static bool vkd3d_shader_instruction_is_uav_write(const struct vkd3d_shader_instruction *instruction)
{
enum VKD3D_SHADER_INSTRUCTION_HANDLER handler_idx = instruction->handler_idx;
return (VKD3DSIH_ATOMIC_AND <= handler_idx && handler_idx <= VKD3DSIH_ATOMIC_XOR)
|| (VKD3DSIH_IMM_ATOMIC_ALLOC <= handler_idx && handler_idx <= VKD3DSIH_IMM_ATOMIC_XOR)
|| handler_idx == VKD3DSIH_STORE_UAV_TYPED
|| handler_idx == VKD3DSIH_STORE_RAW
|| handler_idx == VKD3DSIH_STORE_STRUCTURED;
}
static bool vkd3d_shader_instruction_is_uav_atomic(const struct vkd3d_shader_instruction *instruction)
{
enum VKD3D_SHADER_INSTRUCTION_HANDLER handler_idx = instruction->handler_idx;
return ((VKD3DSIH_ATOMIC_AND <= handler_idx && handler_idx <= VKD3DSIH_ATOMIC_XOR) ||
(VKD3DSIH_IMM_ATOMIC_AND <= handler_idx && handler_idx <= VKD3DSIH_IMM_ATOMIC_XOR)) &&
handler_idx != VKD3DSIH_IMM_ATOMIC_CONSUME;
}
static void vkd3d_shader_scan_record_uav_read(struct vkd3d_shader_scan_info *scan_info,
const struct vkd3d_shader_register *reg)
{
assert(reg->idx[0].offset < VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS);
scan_info->uav_read_mask |= 1u << reg->idx[0].offset;
vkd3d_shader_scan_set_register_flags(scan_info, VKD3DSPR_UAV,
reg->idx[0].offset, VKD3D_SHADER_UAV_FLAG_READ_ACCESS);
}
static void vkd3d_shader_scan_record_uav_atomic(struct vkd3d_shader_scan_info *scan_info,
const struct vkd3d_shader_register *reg)
{
vkd3d_shader_scan_set_register_flags(scan_info, VKD3DSPR_UAV,
reg->idx[0].offset, VKD3D_SHADER_UAV_FLAG_ATOMIC_ACCESS);
}
static bool vkd3d_shader_instruction_is_uav_counter(const struct vkd3d_shader_instruction *instruction)
@ -222,8 +476,10 @@ static bool vkd3d_shader_instruction_is_uav_counter(const struct vkd3d_shader_in
static void vkd3d_shader_scan_record_uav_counter(struct vkd3d_shader_scan_info *scan_info,
const struct vkd3d_shader_register *reg)
{
assert(reg->idx[0].offset < VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS);
scan_info->uav_counter_mask |= 1u << reg->idx[0].offset;
scan_info->has_side_effects = true;
scan_info->has_uav_counter = true;
vkd3d_shader_scan_set_register_flags(scan_info, VKD3DSPR_UAV,
reg->idx[0].offset, VKD3D_SHADER_UAV_FLAG_ATOMIC_COUNTER);
}
static void vkd3d_shader_scan_input_declaration(struct vkd3d_shader_scan_info *scan_info,
@ -235,14 +491,21 @@ static void vkd3d_shader_scan_input_declaration(struct vkd3d_shader_scan_info *s
scan_info->use_vocp = true;
}
static void vkd3d_shader_scan_sampler_declaration(struct vkd3d_shader_scan_info *scan_info,
static void vkd3d_shader_scan_output_declaration(struct vkd3d_shader_scan_info *scan_info,
const struct vkd3d_shader_instruction *instruction)
{
unsigned int sampler_index = instruction->declaration.dst.reg.idx[0].offset;
if (instruction->flags & VKD3DSI_SAMPLER_COMPARISON_MODE)
switch (instruction->declaration.dst.reg.type)
{
assert(sampler_index < CHAR_BIT * sizeof(scan_info->sampler_comparison_mode_mask));
scan_info->sampler_comparison_mode_mask |= 1u << sampler_index;
case VKD3DSPR_DEPTHOUT:
case VKD3DSPR_DEPTHOUTLE:
case VKD3DSPR_DEPTHOUTGE:
case VKD3DSPR_STENCILREFOUT:
case VKD3DSPR_SAMPLEMASK:
scan_info->needs_late_zs = true;
break;
default:
break;
}
}
@ -250,14 +513,25 @@ static void vkd3d_shader_scan_instruction(struct vkd3d_shader_scan_info *scan_in
const struct vkd3d_shader_instruction *instruction)
{
unsigned int i;
bool is_atomic;
switch (instruction->handler_idx)
{
case VKD3DSIH_DCL_INPUT:
vkd3d_shader_scan_input_declaration(scan_info, instruction);
break;
case VKD3DSIH_DCL_SAMPLER:
vkd3d_shader_scan_sampler_declaration(scan_info, instruction);
case VKD3DSIH_DCL_OUTPUT:
vkd3d_shader_scan_output_declaration(scan_info, instruction);
break;
case VKD3DSIH_DISCARD:
scan_info->discards = true;
break;
case VKD3DSIH_DCL_GLOBAL_FLAGS:
if (instruction->flags & VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL)
scan_info->early_fragment_tests = true;
break;
case VKD3DSIH_DCL_INPUT_CONTROL_POINT_COUNT:
scan_info->patch_vertex_count = instruction->declaration.count;
break;
default:
break;
@ -265,18 +539,31 @@ static void vkd3d_shader_scan_instruction(struct vkd3d_shader_scan_info *scan_in
if (vkd3d_shader_instruction_is_uav_read(instruction))
{
is_atomic = vkd3d_shader_instruction_is_uav_atomic(instruction);
for (i = 0; i < instruction->dst_count; ++i)
{
if (instruction->dst[i].reg.type == VKD3DSPR_UAV)
{
vkd3d_shader_scan_record_uav_read(scan_info, &instruction->dst[i].reg);
if (is_atomic)
vkd3d_shader_scan_record_uav_atomic(scan_info, &instruction->dst[i].reg);
}
}
for (i = 0; i < instruction->src_count; ++i)
{
if (instruction->src[i].reg.type == VKD3DSPR_UAV)
{
vkd3d_shader_scan_record_uav_read(scan_info, &instruction->src[i].reg);
if (is_atomic)
vkd3d_shader_scan_record_uav_atomic(scan_info, &instruction->src[i].reg);
}
}
}
if (vkd3d_shader_instruction_is_uav_write(instruction))
scan_info->has_side_effects = true;
if (vkd3d_shader_instruction_is_uav_counter(instruction))
vkd3d_shader_scan_record_uav_counter(scan_info, &instruction->src[0].reg);
}
@ -290,33 +577,33 @@ int vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc,
TRACE("dxbc {%p, %zu}, scan_info %p.\n", dxbc->code, dxbc->size, scan_info);
if (scan_info->type != VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO)
if (shader_is_dxil(dxbc->code, dxbc->size))
{
WARN("Invalid structure type %#x.\n", scan_info->type);
return VKD3D_ERROR_INVALID_ARGUMENT;
/* There is nothing interesting to scan. DXIL does this internally. */
return VKD3D_OK;
}
if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0)
return ret;
memset(scan_info, 0, sizeof(*scan_info));
while (!shader_sm4_is_end(parser.data, &parser.ptr))
else
{
shader_sm4_read_instruction(parser.data, &parser.ptr, &instruction);
if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0)
return ret;
if (instruction.handler_idx == VKD3DSIH_INVALID)
while (!shader_sm4_is_end(parser.data, &parser.ptr))
{
WARN("Encountered unrecognized or invalid instruction.\n");
vkd3d_shader_parser_destroy(&parser);
return VKD3D_ERROR_INVALID_ARGUMENT;
shader_sm4_read_instruction(parser.data, &parser.ptr, &instruction);
if (instruction.handler_idx == VKD3DSIH_INVALID)
{
WARN("Encountered unrecognized or invalid instruction.\n");
vkd3d_shader_parser_destroy(&parser);
return VKD3D_ERROR_INVALID_ARGUMENT;
}
vkd3d_shader_scan_instruction(scan_info, &instruction);
}
vkd3d_shader_scan_instruction(scan_info, &instruction);
vkd3d_shader_parser_destroy(&parser);
return VKD3D_OK;
}
vkd3d_shader_parser_destroy(&parser);
return VKD3D_OK;
}
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *shader_code)
@ -336,7 +623,7 @@ static void vkd3d_shader_free_root_signature_v_1_0(struct vkd3d_root_signature_d
const struct vkd3d_root_parameter *parameter = &root_signature->parameters[i];
if (parameter->parameter_type == VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
vkd3d_free((void *)parameter->u.descriptor_table.descriptor_ranges);
vkd3d_free((void *)parameter->descriptor_table.descriptor_ranges);
}
vkd3d_free((void *)root_signature->parameters);
vkd3d_free((void *)root_signature->static_samplers);
@ -353,7 +640,7 @@ static void vkd3d_shader_free_root_signature_v_1_1(struct vkd3d_root_signature_d
const struct vkd3d_root_parameter1 *parameter = &root_signature->parameters[i];
if (parameter->parameter_type == VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
vkd3d_free((void *)parameter->u.descriptor_table.descriptor_ranges);
vkd3d_free((void *)parameter->descriptor_table.descriptor_ranges);
}
vkd3d_free((void *)root_signature->parameters);
vkd3d_free((void *)root_signature->static_samplers);
@ -365,11 +652,11 @@ void vkd3d_shader_free_root_signature(struct vkd3d_versioned_root_signature_desc
{
if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0)
{
vkd3d_shader_free_root_signature_v_1_0(&desc->u.v_1_0);
vkd3d_shader_free_root_signature_v_1_0(&desc->v_1_0);
}
else if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_1)
{
vkd3d_shader_free_root_signature_v_1_1(&desc->u.v_1_1);
vkd3d_shader_free_root_signature_v_1_1(&desc->v_1_1);
}
else if (desc->version)
{
@ -388,6 +675,14 @@ int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
return shader_parse_input_signature(dxbc->code, dxbc->size, signature);
}
int vkd3d_shader_parse_output_signature(const struct vkd3d_shader_code *dxbc,
struct vkd3d_shader_signature *signature)
{
TRACE("dxbc {%p, %zu}, signature %p.\n", dxbc->code, dxbc->size, signature);
return shader_parse_output_signature(dxbc->code, dxbc->size, signature);
}
struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
const struct vkd3d_shader_signature *signature, const char *semantic_name,
unsigned int semantic_index, unsigned int stream_index)
@ -417,3 +712,39 @@ void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature
vkd3d_free(signature->elements);
signature->elements = NULL;
}
vkd3d_shader_hash_t vkd3d_shader_hash(const struct vkd3d_shader_code *shader)
{
vkd3d_shader_hash_t h = hash_fnv1_init();
const uint8_t *code = shader->code;
size_t i, n;
for (i = 0, n = shader->size; i < n; i++)
h = hash_fnv1_iterate_u8(h, code[i]);
return h;
}
uint32_t vkd3d_shader_compile_arguments_select_quirks(
const struct vkd3d_shader_compile_arguments *compile_args, vkd3d_shader_hash_t shader_hash)
{
unsigned int i;
if (compile_args && compile_args->quirks)
{
for (i = 0; i < compile_args->quirks->num_hashes; i++)
if (compile_args->quirks->hashes[i].shader_hash == shader_hash)
return compile_args->quirks->hashes[i].quirks | compile_args->quirks->global_quirks;
return compile_args->quirks->default_quirks | compile_args->quirks->global_quirks;
}
else
return 0;
}
uint64_t vkd3d_shader_get_revision(void)
{
/* This is meant to be bumped every time a change is made to the shader compiler.
* Might get nuked later ...
* It's not immediately useful for invalidating pipeline caches, since that would mostly be covered
* by vkd3d-proton Git hash. */
return 1;
}

View File

@ -45,7 +45,6 @@
#ifndef __VKD3D_SHADER_PRIVATE_H
#define __VKD3D_SHADER_PRIVATE_H
#define NONAMELESSUNION
#include "vkd3d_common.h"
#include "vkd3d_memory.h"
#include "vkd3d_shader.h"
@ -59,9 +58,12 @@
#define VKD3D_VEC4_SIZE 4
#define VKD3D_DVEC2_SIZE 2
#define VKD3D_DOUBLE_DWORD_SIZE 2
#define VKD3D_DVEC2_DWORD_SIZE (VKD3D_DOUBLE_DWORD_SIZE * VKD3D_DVEC2_SIZE)
enum VKD3D_SHADER_INSTRUCTION_HANDLER
{
VKD3DSIH_ABS,
VKD3DSIH_ADD,
VKD3DSIH_AND,
VKD3DSIH_ATOMIC_AND,
@ -83,12 +85,10 @@ enum VKD3D_SHADER_INSTRUCTION_HANDLER
VKD3DSIH_CALL,
VKD3DSIH_CALLNZ,
VKD3DSIH_CASE,
VKD3DSIH_CMP,
VKD3DSIH_CND,
VKD3DSIH_CHECK_ACCESS_FULLY_MAPPED,
VKD3DSIH_CONTINUE,
VKD3DSIH_CONTINUEP,
VKD3DSIH_COUNTBITS,
VKD3DSIH_CRS,
VKD3DSIH_CUT,
VKD3DSIH_CUT_STREAM,
VKD3DSIH_DCL,
@ -131,16 +131,11 @@ enum VKD3D_SHADER_INSTRUCTION_HANDLER
VKD3DSIH_DCL_UAV_STRUCTURED,
VKD3DSIH_DCL_UAV_TYPED,
VKD3DSIH_DCL_VERTICES_OUT,
VKD3DSIH_DEF,
VKD3DSIH_DEFAULT,
VKD3DSIH_DEFB,
VKD3DSIH_DEFI,
VKD3DSIH_DIV,
VKD3DSIH_DP2,
VKD3DSIH_DP2ADD,
VKD3DSIH_DP3,
VKD3DSIH_DP4,
VKD3DSIH_DST,
VKD3DSIH_DSX,
VKD3DSIH_DSX_COARSE,
VKD3DSIH_DSX_FINE,
@ -149,16 +144,17 @@ enum VKD3D_SHADER_INSTRUCTION_HANDLER
VKD3DSIH_DSY_FINE,
VKD3DSIH_ELSE,
VKD3DSIH_EMIT,
VKD3DSIH_EMIT_THEN_CUT,
VKD3DSIH_EMIT_STREAM,
VKD3DSIH_EMIT_THEN_CUT_STREAM,
VKD3DSIH_ENDIF,
VKD3DSIH_ENDLOOP,
VKD3DSIH_ENDREP,
VKD3DSIH_ENDSWITCH,
VKD3DSIH_EQ,
VKD3DSIH_EVAL_CENTROID,
VKD3DSIH_EVAL_SAMPLE_INDEX,
VKD3DSIH_EVAL_SNAPPED,
VKD3DSIH_EXP,
VKD3DSIH_EXPP,
VKD3DSIH_F16TOF32,
VKD3DSIH_F32TOF16,
VKD3DSIH_FCALL,
@ -170,8 +166,12 @@ enum VKD3D_SHADER_INSTRUCTION_HANDLER
VKD3DSIH_FTOU,
VKD3DSIH_GATHER4,
VKD3DSIH_GATHER4_C,
VKD3DSIH_GATHER4_C_FEEDBACK,
VKD3DSIH_GATHER4_FEEDBACK,
VKD3DSIH_GATHER4_PO,
VKD3DSIH_GATHER4_PO_C,
VKD3DSIH_GATHER4_PO_C_FEEDBACK,
VKD3DSIH_GATHER4_PO_FEEDBACK,
VKD3DSIH_GE,
VKD3DSIH_HS_CONTROL_POINT_PHASE,
VKD3DSIH_HS_DECLS,
@ -207,38 +207,32 @@ enum VKD3D_SHADER_INSTRUCTION_HANDLER
VKD3DSIH_ITOF,
VKD3DSIH_LABEL,
VKD3DSIH_LD,
VKD3DSIH_LD_FEEDBACK,
VKD3DSIH_LD2DMS,
VKD3DSIH_LD2DMS_FEEDBACK,
VKD3DSIH_LD_RAW,
VKD3DSIH_LD_RAW_FEEDBACK,
VKD3DSIH_LD_STRUCTURED,
VKD3DSIH_LD_STRUCTURED_FEEDBACK,
VKD3DSIH_LD_UAV_TYPED,
VKD3DSIH_LIT,
VKD3DSIH_LD_UAV_TYPED_FEEDBACK,
VKD3DSIH_LOD,
VKD3DSIH_LOG,
VKD3DSIH_LOGP,
VKD3DSIH_LOOP,
VKD3DSIH_LRP,
VKD3DSIH_LT,
VKD3DSIH_M3x2,
VKD3DSIH_M3x3,
VKD3DSIH_M3x4,
VKD3DSIH_M4x3,
VKD3DSIH_M4x4,
VKD3DSIH_MAD,
VKD3DSIH_MAX,
VKD3DSIH_MIN,
VKD3DSIH_MOV,
VKD3DSIH_MOVA,
VKD3DSIH_MOVC,
VKD3DSIH_MUL,
VKD3DSIH_NE,
VKD3DSIH_NOP,
VKD3DSIH_NOT,
VKD3DSIH_NRM,
VKD3DSIH_OR,
VKD3DSIH_PHASE,
VKD3DSIH_POW,
VKD3DSIH_RCP,
VKD3DSIH_REP,
VKD3DSIH_RESINFO,
VKD3DSIH_RET,
VKD3DSIH_RETP,
@ -249,13 +243,18 @@ enum VKD3D_SHADER_INSTRUCTION_HANDLER
VKD3DSIH_RSQ,
VKD3DSIH_SAMPLE,
VKD3DSIH_SAMPLE_B,
VKD3DSIH_SAMPLE_B_FEEDBACK,
VKD3DSIH_SAMPLE_C,
VKD3DSIH_SAMPLE_C_FEEDBACK,
VKD3DSIH_SAMPLE_C_LZ,
VKD3DSIH_SAMPLE_C_LZ_FEEDBACK,
VKD3DSIH_SAMPLE_FEEDBACK,
VKD3DSIH_SAMPLE_GRAD,
VKD3DSIH_SAMPLE_GRAD_FEEDBACK,
VKD3DSIH_SAMPLE_INFO,
VKD3DSIH_SAMPLE_LOD,
VKD3DSIH_SAMPLE_LOD_FEEDBACK,
VKD3DSIH_SAMPLE_POS,
VKD3DSIH_SETP,
VKD3DSIH_SGE,
VKD3DSIH_SGN,
VKD3DSIH_SINCOS,
@ -268,28 +267,7 @@ enum VKD3D_SHADER_INSTRUCTION_HANDLER
VKD3DSIH_SWAPC,
VKD3DSIH_SWITCH,
VKD3DSIH_SYNC,
VKD3DSIH_TEX,
VKD3DSIH_TEXBEM,
VKD3DSIH_TEXBEML,
VKD3DSIH_TEXCOORD,
VKD3DSIH_TEXDEPTH,
VKD3DSIH_TEXDP3,
VKD3DSIH_TEXDP3TEX,
VKD3DSIH_TEXKILL,
VKD3DSIH_TEXLDD,
VKD3DSIH_TEXLDL,
VKD3DSIH_TEXM3x2DEPTH,
VKD3DSIH_TEXM3x2PAD,
VKD3DSIH_TEXM3x2TEX,
VKD3DSIH_TEXM3x3,
VKD3DSIH_TEXM3x3DIFF,
VKD3DSIH_TEXM3x3PAD,
VKD3DSIH_TEXM3x3SPEC,
VKD3DSIH_TEXM3x3TEX,
VKD3DSIH_TEXM3x3VSPEC,
VKD3DSIH_TEXREG2AR,
VKD3DSIH_TEXREG2GB,
VKD3DSIH_TEXREG2RGB,
VKD3DSIH_DISCARD,
VKD3DSIH_UBFE,
VKD3DSIH_UDIV,
VKD3DSIH_UGE,
@ -297,38 +275,44 @@ enum VKD3D_SHADER_INSTRUCTION_HANDLER
VKD3DSIH_UMAX,
VKD3DSIH_UMIN,
VKD3DSIH_UMUL,
VKD3DSIH_UMAD,
VKD3DSIH_USHR,
VKD3DSIH_UTOF,
VKD3DSIH_XOR,
VKD3DSIH_DADD,
VKD3DSIH_DMAX,
VKD3DSIH_DMIN,
VKD3DSIH_DMUL,
VKD3DSIH_DEQ,
VKD3DSIH_DGE,
VKD3DSIH_DLT,
VKD3DSIH_DNE,
VKD3DSIH_DMOV,
VKD3DSIH_DMOVC,
VKD3DSIH_DTOF,
VKD3DSIH_FTOD,
VKD3DSIH_DDIV,
VKD3DSIH_DFMA,
VKD3DSIH_DRCP,
VKD3DSIH_DTOI,
VKD3DSIH_DTOU,
VKD3DSIH_ITOD,
VKD3DSIH_UTOD,
VKD3DSIH_INVALID,
};
enum vkd3d_shader_register_type
{
VKD3DSPR_TEMP = 0,
VKD3DSPR_INPUT = 1,
VKD3DSPR_CONST = 2,
VKD3DSPR_ADDR = 3,
VKD3DSPR_TEXTURE = 3,
VKD3DSPR_RASTOUT = 4,
VKD3DSPR_ATTROUT = 5,
VKD3DSPR_TEXCRDOUT = 6,
VKD3DSPR_OUTPUT = 6,
VKD3DSPR_CONSTINT = 7,
VKD3DSPR_COLOROUT = 8,
VKD3DSPR_DEPTHOUT = 9,
VKD3DSPR_SAMPLER = 10,
VKD3DSPR_CONST2 = 11,
VKD3DSPR_CONST3 = 12,
VKD3DSPR_CONST4 = 13,
VKD3DSPR_CONSTBOOL = 14,
VKD3DSPR_LOOP = 15,
VKD3DSPR_TEMPFLOAT16 = 16,
VKD3DSPR_MISCTYPE = 17,
VKD3DSPR_LABEL = 18,
VKD3DSPR_PREDICATE = 19,
VKD3DSPR_TEMP,
VKD3DSPR_INPUT,
VKD3DSPR_OUTPUT,
VKD3DSPR_COLOROUT,
VKD3DSPR_DEPTHOUT,
VKD3DSPR_SAMPLER,
VKD3DSPR_IMMCONST,
VKD3DSPR_IMMCONST64,
VKD3DSPR_CONSTBUFFER,
VKD3DSPR_IMMCONSTBUFFER,
VKD3DSPR_PRIMID,
@ -357,6 +341,8 @@ enum vkd3d_shader_register_type
VKD3DSPR_DEPTHOUTGE,
VKD3DSPR_DEPTHOUTLE,
VKD3DSPR_RASTERIZER,
VKD3DSPR_STENCILREFOUT,
VKD3DSPR_INNERCOVERAGE,
VKD3DSPR_INVALID = ~0u,
};
@ -387,30 +373,28 @@ enum vkd3d_data_type
VKD3D_DATA_UNORM,
VKD3D_DATA_SNORM,
VKD3D_DATA_OPAQUE,
VKD3D_DATA_DOUBLE,
};
enum vkd3d_immconst_type
{
VKD3D_IMMCONST_SCALAR,
VKD3D_IMMCONST_VEC4,
VKD3D_IMMCONST_DVEC2 = VKD3D_IMMCONST_VEC4,
};
enum vkd3d_shader_register_modifier
{
VKD3DSPRM_NONE = 0,
VKD3DSPRM_NONUNIFORM = 1,
};
enum vkd3d_shader_src_modifier
{
VKD3DSPSM_NONE = 0,
VKD3DSPSM_NEG = 1,
VKD3DSPSM_BIAS = 2,
VKD3DSPSM_BIASNEG = 3,
VKD3DSPSM_SIGN = 4,
VKD3DSPSM_SIGNNEG = 5,
VKD3DSPSM_COMP = 6,
VKD3DSPSM_X2 = 7,
VKD3DSPSM_X2NEG = 8,
VKD3DSPSM_DZ = 9,
VKD3DSPSM_DW = 10,
VKD3DSPSM_ABS = 11,
VKD3DSPSM_ABSNEG = 12,
VKD3DSPSM_NOT = 13,
VKD3DSPSM_ABS = 2,
VKD3DSPSM_ABSNEG = 3
};
#define VKD3DSP_WRITEMASK_0 0x1u /* .x r */
@ -422,9 +406,7 @@ enum vkd3d_shader_src_modifier
enum vkd3d_shader_dst_modifier
{
VKD3DSPDM_NONE = 0,
VKD3DSPDM_SATURATE = 1,
VKD3DSPDM_PARTIALPRECISION = 2,
VKD3DSPDM_MSAMPCENTROID = 4,
VKD3DSPDM_SATURATE = 1
};
enum vkd3d_shader_interpolation_mode
@ -442,9 +424,11 @@ enum vkd3d_shader_interpolation_mode
enum vkd3d_shader_global_flags
{
VKD3DSGF_REFACTORING_ALLOWED = 0x01,
VKD3DSGF_ENABLE_DOUBLE_PRECISION_FLOAT_OPS = 0x02,
VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x04,
VKD3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x08,
VKD3DSGF_ENABLE_MINIMUM_PRECISION = 0x20
VKD3DSGF_ENABLE_MINIMUM_PRECISION = 0x20,
VKD3DSGF_ENABLE_11_1_DOUBLE_EXTENSIONS = 0x40,
};
enum vkd3d_shader_sync_flags
@ -467,7 +451,6 @@ enum vkd3d_tessellator_domain
};
#define VKD3DSI_NONE 0x0
#define VKD3DSI_TEXLD_PROJECT 0x1
#define VKD3DSI_INDEXED_DYNAMIC 0x4
#define VKD3DSI_RESINFO_RCP_FLOAT 0x1
#define VKD3DSI_RESINFO_UINT 0x2
@ -498,8 +481,6 @@ enum vkd3d_shader_conditional_op
VKD3D_SHADER_CONDITIONAL_OP_Z = 1
};
#define VKD3D_SM1_VS 0xfffeu
#define VKD3D_SM1_PS 0xffffu
#define VKD3D_SM4_PS 0x0000u
#define VKD3D_SM4_VS 0x0001u
#define VKD3D_SM4_GS 0x0002u
@ -507,10 +488,6 @@ enum vkd3d_shader_conditional_op
#define VKD3D_SM5_DS 0x0004u
#define VKD3D_SM5_CS 0x0005u
/* Shader version tokens, and shader end tokens */
#define VKD3DPS_VERSION(major, minor) ((VKD3D_SM1_PS << 16) | ((major) << 8) | (minor))
#define VKD3DVS_VERSION(major, minor) ((VKD3D_SM1_VS << 16) | ((major) << 8) | (minor))
#define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
#define MAX_REG_OUTPUT 32
@ -537,7 +514,7 @@ struct vkd3d_shader_version
struct vkd3d_shader_immediate_constant_buffer
{
unsigned int vec4_count;
DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
uint32_t data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
};
struct vkd3d_shader_indexable_temp
@ -557,15 +534,18 @@ struct vkd3d_shader_register_index
struct vkd3d_shader_register
{
enum vkd3d_shader_register_type type;
enum vkd3d_shader_register_modifier modifier;
enum vkd3d_data_type data_type;
struct vkd3d_shader_register_index idx[3];
enum vkd3d_immconst_type immconst_type;
union
{
DWORD immconst_uint[VKD3D_VEC4_SIZE];
uint32_t immconst_uint[VKD3D_VEC4_SIZE];
float immconst_float[VKD3D_VEC4_SIZE];
double immconst_double[VKD3D_DVEC2_SIZE];
uint64_t immconst_uint64[VKD3D_DVEC2_SIZE];
unsigned fp_body_idx;
} u;
};
};
struct vkd3d_shader_dst_param
@ -573,7 +553,6 @@ struct vkd3d_shader_dst_param
struct vkd3d_shader_register reg;
DWORD write_mask;
DWORD modifiers;
DWORD shift;
};
struct vkd3d_shader_src_param
@ -589,32 +568,13 @@ struct vkd3d_shader_index_range
unsigned int register_count;
};
enum vkd3d_decl_usage
{
VKD3D_DECL_USAGE_POSITION = 0,
VKD3D_DECL_USAGE_BLEND_WEIGHT = 1,
VKD3D_DECL_USAGE_BLEND_INDICES = 2,
VKD3D_DECL_USAGE_NORMAL = 3,
VKD3D_DECL_USAGE_PSIZE = 4,
VKD3D_DECL_USAGE_TEXCOORD = 5,
VKD3D_DECL_USAGE_TANGENT = 6,
VKD3D_DECL_USAGE_BINORMAL = 7,
VKD3D_DECL_USAGE_TESS_FACTOR = 8,
VKD3D_DECL_USAGE_POSITIONT = 9,
VKD3D_DECL_USAGE_COLOR = 10,
VKD3D_DECL_USAGE_FOG = 11,
VKD3D_DECL_USAGE_DEPTH = 12,
VKD3D_DECL_USAGE_SAMPLE = 13
};
struct vkd3d_shader_semantic
{
enum vkd3d_decl_usage usage;
unsigned int usage_idx;
enum vkd3d_shader_resource_type resource_type;
enum vkd3d_data_type resource_data_type;
struct vkd3d_shader_dst_param reg;
unsigned int register_space;
unsigned int register_index;
};
enum vkd3d_shader_input_sysval_semantic
@ -662,6 +622,7 @@ struct vkd3d_shader_register_semantic
struct vkd3d_shader_sampler
{
struct vkd3d_shader_src_param src;
unsigned int register_index;
unsigned int register_space;
};
@ -669,6 +630,7 @@ struct vkd3d_shader_constant_buffer
{
struct vkd3d_shader_src_param src;
unsigned int size;
unsigned int register_index;
unsigned int register_space;
};
@ -676,12 +638,14 @@ struct vkd3d_shader_structured_resource
{
struct vkd3d_shader_dst_param reg;
unsigned int byte_stride;
unsigned int register_index;
unsigned int register_space;
};
struct vkd3d_shader_raw_resource
{
struct vkd3d_shader_dst_param dst;
unsigned int register_index;
unsigned int register_space;
};
@ -797,25 +761,28 @@ static inline bool vkd3d_shader_register_is_output(const struct vkd3d_shader_reg
return reg->type == VKD3DSPR_OUTPUT || reg->type == VKD3DSPR_COLOROUT;
}
void vkd3d_shader_trace(void *data) DECLSPEC_HIDDEN;
void vkd3d_shader_trace(void *data);
const char *shader_get_type_prefix(enum vkd3d_shader_type type) DECLSPEC_HIDDEN;
const char *shader_get_type_prefix(enum vkd3d_shader_type type);
void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
const struct vkd3d_shader_signature *output_signature) DECLSPEC_HIDDEN;
void shader_sm4_free(void *data) DECLSPEC_HIDDEN;
const struct vkd3d_shader_signature *output_signature);
void shader_sm4_free(void *data);
void shader_sm4_read_header(void *data, const DWORD **ptr,
struct vkd3d_shader_version *shader_version) DECLSPEC_HIDDEN;
struct vkd3d_shader_version *shader_version);
void shader_sm4_read_instruction(void *data, const DWORD **ptr,
struct vkd3d_shader_instruction *ins) DECLSPEC_HIDDEN;
bool shader_sm4_is_end(void *data, const DWORD **ptr) DECLSPEC_HIDDEN;
struct vkd3d_shader_instruction *ins);
bool shader_sm4_is_end(void *data, const DWORD **ptr);
int shader_extract_from_dxbc(const void *dxbc, size_t dxbc_length,
struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
void free_shader_desc(struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
struct vkd3d_shader_desc *desc);
bool shader_is_dxil(const void *dxbc, size_t dxbc_length);
void free_shader_desc(struct vkd3d_shader_desc *desc);
int shader_parse_input_signature(const void *dxbc, size_t dxbc_length,
struct vkd3d_shader_signature *signature) DECLSPEC_HIDDEN;
struct vkd3d_shader_signature *signature);
int shader_parse_output_signature(const void *dxbc, size_t dxbc_length,
struct vkd3d_shader_signature *signature);
struct vkd3d_dxbc_compiler;
@ -823,14 +790,22 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader
const struct vkd3d_shader_desc *shader_desc, uint32_t compiler_options,
const struct vkd3d_shader_interface_info *shader_interface_info,
const struct vkd3d_shader_compile_arguments *compile_args,
const struct vkd3d_shader_scan_info *scan_info) DECLSPEC_HIDDEN;
const struct vkd3d_shader_scan_info *scan_info,
vkd3d_shader_hash_t shader_hash);
int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction) DECLSPEC_HIDDEN;
const struct vkd3d_shader_instruction *instruction);
int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
struct vkd3d_shader_code *spirv) DECLSPEC_HIDDEN;
void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler) DECLSPEC_HIDDEN;
struct vkd3d_shader_code *spirv);
void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler);
void vkd3d_compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4]) DECLSPEC_HIDDEN;
void vkd3d_compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4]);
void vkd3d_shader_dump_spirv_shader(vkd3d_shader_hash_t hash, const struct vkd3d_shader_code *shader);
void vkd3d_shader_dump_spirv_shader_export(vkd3d_shader_hash_t hash, const struct vkd3d_shader_code *shader,
const char *export);
void vkd3d_shader_dump_shader(vkd3d_shader_hash_t hash, const struct vkd3d_shader_code *shader, const char *ext);
bool vkd3d_shader_replace(vkd3d_shader_hash_t hash, const void **data, size_t *size);
bool vkd3d_shader_replace_export(vkd3d_shader_hash_t hash, const void **data, size_t *size, const char *export);
static inline enum vkd3d_component_type vkd3d_component_type_from_data_type(
enum vkd3d_data_type data_type)
@ -845,6 +820,8 @@ static inline enum vkd3d_component_type vkd3d_component_type_from_data_type(
return VKD3D_TYPE_UINT;
case VKD3D_DATA_INT:
return VKD3D_TYPE_INT;
case VKD3D_DATA_DOUBLE:
return VKD3D_TYPE_DOUBLE;
default:
FIXME("Unhandled data type %#x.\n", data_type);
return VKD3D_TYPE_UINT;
@ -862,6 +839,8 @@ static inline enum vkd3d_data_type vkd3d_data_type_from_component_type(
return VKD3D_DATA_UINT;
case VKD3D_TYPE_INT:
return VKD3D_DATA_INT;
case VKD3D_TYPE_DOUBLE:
return VKD3D_DATA_DOUBLE;
default:
FIXME("Unhandled component type %#x.\n", component_type);
return VKD3D_DATA_FLOAT;
@ -890,6 +869,16 @@ static inline unsigned int vkd3d_write_mask_component_count(DWORD write_mask)
return count;
}
static inline unsigned int vkd3d_write_mask_component_count_typed(DWORD write_mask,
enum vkd3d_component_type type)
{
unsigned int component_count = vkd3d_write_mask_component_count(write_mask);
if (type == VKD3D_TYPE_DOUBLE)
component_count /= 2;
assert(component_count != 0);
return component_count;
}
static inline unsigned int vkd3d_write_mask_from_component_count(unsigned int component_count)
{
assert(component_count <= VKD3D_VEC4_SIZE);
@ -921,4 +910,13 @@ static inline unsigned int vkd3d_compact_swizzle(unsigned int swizzle, unsigned
#define VKD3D_DXBC_MAX_SOURCE_COUNT 6
#define VKD3D_DXBC_HEADER_SIZE (8 * sizeof(uint32_t))
unsigned int vkd3d_shader_scan_get_register_flags(const struct vkd3d_shader_scan_info *scan_info,
enum vkd3d_shader_register_type type, unsigned int id);
/* DXIL support */
int vkd3d_shader_compile_dxil(const struct vkd3d_shader_code *dxbc,
struct vkd3d_shader_code *spirv,
const struct vkd3d_shader_interface_info *shader_interface_info,
const struct vkd3d_shader_compile_arguments *compiler_args);
#endif /* __VKD3D_SHADER_PRIVATE_H */

View File

@ -1,10 +0,0 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: vkd3d-utils
Description: The vkd3d 3D Graphics Utility Library
Version: @PACKAGE_VERSION@
Cflags: -I${includedir}/vkd3d
Libs: -L${libdir} -lvkd3d-utils

View File

@ -0,0 +1,19 @@
vkd3d_utils_src = [
'vkd3d_utils_main.c',
]
vkd3d_utils_lib = shared_library('vkd3d-proton-utils', vkd3d_utils_src,
dependencies : vkd3d_dep,
include_directories : vkd3d_private_includes,
install : true,
objects : not vkd3d_is_msvc and vkd3d_platform == 'windows'
? 'vkd3d-proton-utils.def'
: [],
vs_module_defs : 'vkd3d-proton-utils.def',
version : '3.0.0',
c_args : '-DVKD3D_UTILS_EXPORTS',
override_options : [ 'c_std='+vkd3d_c_std ])
vkd3d_utils_dep = declare_dependency(
link_with : vkd3d_utils_lib,
include_directories : vkd3d_public_includes)

View File

@ -0,0 +1,16 @@
LIBRARY vkd3d-proton-utils-3.dll
EXPORTS
D3D12CreateDevice @101
D3D12GetDebugInterface @102
D3D12CreateRootSignatureDeserializer
D3D12CreateVersionedRootSignatureDeserializer
D3D12EnableExperimentalFeatures
D3D12SerializeRootSignature
D3D12SerializeVersionedRootSignature
vkd3d_create_event
vkd3d_wait_event
vkd3d_signal_event
vkd3d_destroy_event

View File

@ -1,16 +0,0 @@
VKD3D_1_0
{
global:
D3D12CreateDevice;
D3D12CreateRootSignatureDeserializer;
D3D12CreateVersionedRootSignatureDeserializer;
D3D12GetDebugInterface;
D3D12SerializeRootSignature;
D3D12SerializeVersionedRootSignature;
vkd3d_create_event;
vkd3d_destroy_event;
vkd3d_signal_event;
vkd3d_wait_event;
local: *;
};

View File

@ -16,21 +16,21 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_common.h"
#include "vkd3d_utils_private.h"
VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
HRESULT WINAPI D3D12GetDebugInterface(REFIID iid, void **debug)
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12GetDebugInterface(REFIID iid, void **debug)
{
FIXME("iid %s, debug %p stub!\n", debugstr_guid(iid), debug);
return E_NOTIMPL;
}
HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter,
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter,
D3D_FEATURE_LEVEL minimum_feature_level, REFIID iid, void **device)
{
struct vkd3d_optional_instance_extensions_info optional_extensions_info;
struct vkd3d_instance_create_info instance_create_info;
struct vkd3d_device_create_info device_create_info;
@ -54,22 +54,14 @@ HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter,
if (adapter)
FIXME("Ignoring adapter %p.\n", adapter);
memset(&optional_extensions_info, 0, sizeof(optional_extensions_info));
optional_extensions_info.type = VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO;
optional_extensions_info.extensions = optional_instance_extensions;
optional_extensions_info.extension_count = ARRAY_SIZE(optional_instance_extensions);
memset(&instance_create_info, 0, sizeof(instance_create_info));
instance_create_info.type = VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instance_create_info.next = &optional_extensions_info;
instance_create_info.pfn_signal_event = vkd3d_signal_event;
instance_create_info.wchar_size = sizeof(WCHAR);
instance_create_info.instance_extensions = instance_extensions;
instance_create_info.instance_extension_count = ARRAY_SIZE(instance_extensions);
instance_create_info.optional_instance_extensions = optional_instance_extensions;
instance_create_info.optional_instance_extension_count = ARRAY_SIZE(optional_instance_extensions);
memset(&device_create_info, 0, sizeof(device_create_info));
device_create_info.type = VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
device_create_info.next = NULL;
device_create_info.minimum_feature_level = minimum_feature_level;
device_create_info.instance_create_info = &instance_create_info;
device_create_info.device_extensions = device_extensions;
@ -78,7 +70,7 @@ HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter,
return vkd3d_create_device(&device_create_info, iid, device);
}
HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T data_size,
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer)
{
TRACE("data %p, data_size %lu, iid %s, deserializer %p.\n",
@ -87,7 +79,7 @@ HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T dat
return vkd3d_create_root_signature_deserializer(data, data_size, iid, deserializer);
}
HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer(const void *data, SIZE_T data_size,
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer(const void *data, SIZE_T data_size,
REFIID iid,void **deserializer)
{
TRACE("data %p, data_size %lu, iid %s, deserializer %p.\n",
@ -96,7 +88,16 @@ HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer(const void *data, S
return vkd3d_create_versioned_root_signature_deserializer(data, data_size, iid, deserializer);
}
HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *desc,
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12EnableExperimentalFeatures(UINT feature_count,
const IID *iids, void *configurations, UINT *configurations_sizes)
{
FIXME("feature_count %u, iids %p, configurations %p, configurations_sizes %p stub!\n",
feature_count, iids, configurations, configurations_sizes);
return E_NOINTERFACE;
}
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *desc,
D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob)
{
TRACE("desc %p, version %#x, blob %p, error_blob %p.\n", desc, version, blob, error_blob);
@ -104,7 +105,7 @@ HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *desc
return vkd3d_serialize_root_signature(desc, version, blob, error_blob);
}
HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
VKD3D_UTILS_EXPORT HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
ID3DBlob **blob, ID3DBlob **error_blob)
{
TRACE("desc %p, blob %p, error_blob %p.\n", desc, blob, error_blob);
@ -113,7 +114,7 @@ HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_S
}
/* Events */
HANDLE vkd3d_create_event(void)
VKD3D_UTILS_EXPORT HANDLE vkd3d_create_event(void)
{
struct vkd3d_event *event;
int rc;
@ -144,7 +145,7 @@ HANDLE vkd3d_create_event(void)
return event;
}
unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds)
VKD3D_UTILS_EXPORT unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds)
{
struct vkd3d_event *impl = event;
int rc;
@ -187,7 +188,7 @@ unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds)
return VKD3D_WAIT_FAILED;
}
HRESULT vkd3d_signal_event(HANDLE event)
VKD3D_UTILS_EXPORT HRESULT vkd3d_signal_event(HANDLE event)
{
struct vkd3d_event *impl = event;
int rc;
@ -206,7 +207,7 @@ HRESULT vkd3d_signal_event(HANDLE event)
return S_OK;
}
void vkd3d_destroy_event(HANDLE event)
VKD3D_UTILS_EXPORT void vkd3d_destroy_event(HANDLE event)
{
struct vkd3d_event *impl = event;
int rc;

View File

@ -20,10 +20,9 @@
#define __VKD3D_UTILS_PRIVATE_H
#define COBJMACROS
#define NONAMELESSUNION
#define VK_NO_PROTOTYPES
#include <pthread.h>
#include "vkd3d_threads.h"
#include <vkd3d.h>
#include "vkd3d_memory.h"

View File

@ -0,0 +1,498 @@
/*
* Copyright 2021 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_private.h"
#define RT_TRACE TRACE
void vkd3d_acceleration_structure_build_info_cleanup(
struct vkd3d_acceleration_structure_build_info *info)
{
if (info->primitive_counts != info->primitive_counts_stack)
vkd3d_free(info->primitive_counts);
if (info->geometries != info->geometries_stack)
vkd3d_free(info->geometries);
if (info->build_range_ptrs != info->build_range_ptr_stack)
vkd3d_free((void *)info->build_range_ptrs);
if (info->build_ranges != info->build_range_stack)
vkd3d_free(info->build_ranges);
}
static VkBuildAccelerationStructureFlagsKHR d3d12_build_flags_to_vk(
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS flags)
{
VkBuildAccelerationStructureFlagsKHR vk_flags = 0;
if (flags & D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_COMPACTION)
vk_flags |= VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_KHR;
if (flags & D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_UPDATE)
vk_flags |= VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR;
if (flags & D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_MINIMIZE_MEMORY)
vk_flags |= VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_KHR;
if (flags & D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_BUILD)
vk_flags |= VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR;
if (flags & D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_TRACE)
vk_flags |= VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR;
return vk_flags;
}
static VkGeometryFlagsKHR d3d12_geometry_flags_to_vk(D3D12_RAYTRACING_GEOMETRY_FLAGS flags)
{
VkGeometryFlagsKHR vk_flags = 0;
if (flags & D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE)
vk_flags |= VK_GEOMETRY_OPAQUE_BIT_KHR;
if (flags & D3D12_RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION)
vk_flags |= VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR;
return vk_flags;
}
bool vkd3d_acceleration_structure_convert_inputs(const struct d3d12_device *device,
struct vkd3d_acceleration_structure_build_info *info,
const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *desc)
{
VkAccelerationStructureGeometryTrianglesDataKHR *triangles;
VkAccelerationStructureBuildGeometryInfoKHR *build_info;
VkAccelerationStructureGeometryAabbsDataKHR *aabbs;
const D3D12_RAYTRACING_GEOMETRY_DESC *geom_desc;
bool have_triangles, have_aabbs;
unsigned int i;
RT_TRACE("Converting inputs.\n");
RT_TRACE("=====================\n");
build_info = &info->build_info;
memset(build_info, 0, sizeof(*build_info));
build_info->sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
if (desc->Type == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL)
{
build_info->type = VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR;
RT_TRACE("Top level build.\n");
}
else
{
build_info->type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR;
RT_TRACE("Bottom level build.\n");
}
build_info->flags = d3d12_build_flags_to_vk(desc->Flags);
if (desc->Flags & D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE)
{
RT_TRACE("BUILD_FLAG_PERFORM_UPDATE.\n");
build_info->mode = VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR;
}
else
build_info->mode = VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR;
info->geometries = info->geometries_stack;
info->primitive_counts = info->primitive_counts_stack;
info->build_ranges = info->build_range_stack;
info->build_range_ptrs = info->build_range_ptr_stack;
if (desc->Type == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL)
{
memset(info->geometries, 0, sizeof(*info->geometries));
info->geometries[0].sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR;
info->geometries[0].geometryType = VK_GEOMETRY_TYPE_INSTANCES_KHR;
info->geometries[0].geometry.instances.sType =
VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR;
info->geometries[0].geometry.instances.arrayOfPointers =
desc->DescsLayout == D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS ? VK_TRUE : VK_FALSE;
info->geometries[0].geometry.instances.data.deviceAddress = desc->InstanceDescs;
info->primitive_counts = info->primitive_counts_stack;
info->primitive_counts[0] = desc->NumDescs;
build_info->geometryCount = 1;
RT_TRACE(" ArrayOfPointers: %u.\n",
desc->DescsLayout == D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS ? 1 : 0);
RT_TRACE(" NumDescs: %u.\n", info->primitive_counts[0]);
}
else
{
have_triangles = false;
have_aabbs = false;
if (desc->NumDescs <= VKD3D_BUILD_INFO_STACK_COUNT)
{
memset(info->geometries, 0, sizeof(*info->geometries) * desc->NumDescs);
memset(info->primitive_counts, 0, sizeof(*info->primitive_counts) * desc->NumDescs);
}
else
{
info->geometries = vkd3d_calloc(desc->NumDescs, sizeof(*info->geometries));
info->primitive_counts = vkd3d_calloc(desc->NumDescs, sizeof(*info->primitive_counts));
info->build_ranges = vkd3d_malloc(desc->NumDescs * sizeof(*info->build_ranges));
info->build_range_ptrs = vkd3d_malloc(desc->NumDescs * sizeof(*info->build_range_ptrs));
}
build_info->geometryCount = desc->NumDescs;
for (i = 0; i < desc->NumDescs; i++)
{
info->geometries[i].sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR;
RT_TRACE(" Geom %u:\n", i);
if (desc->DescsLayout == D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS)
{
geom_desc = desc->ppGeometryDescs[i];
RT_TRACE(" ArrayOfPointers\n");
}
else
{
geom_desc = &desc->pGeometryDescs[i];
RT_TRACE(" PointerToArray\n");
}
info->geometries[i].flags = d3d12_geometry_flags_to_vk(geom_desc->Flags);
RT_TRACE(" Flags = #%x\n", geom_desc->Flags);
switch (geom_desc->Type)
{
case D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES:
/* Runtime validates this. */
if (have_aabbs)
{
ERR("Cannot mix and match geometry types in a BLAS.\n");
return false;
}
have_triangles = true;
info->geometries[i].geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR;
triangles = &info->geometries[i].geometry.triangles;
triangles->sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
triangles->indexData.deviceAddress = geom_desc->Triangles.IndexBuffer;
if (geom_desc->Triangles.IndexFormat != DXGI_FORMAT_UNKNOWN)
{
if (!geom_desc->Triangles.IndexBuffer)
WARN("Application is using IndexBuffer = 0 and IndexFormat != UNKNOWN. Likely application bug.\n");
triangles->indexType =
geom_desc->Triangles.IndexFormat == DXGI_FORMAT_R16_UINT ?
VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32;
info->primitive_counts[i] = geom_desc->Triangles.IndexCount / 3;
RT_TRACE(" Indexed : Index count = %u (%u bits)\n",
geom_desc->Triangles.IndexCount,
triangles->indexType == VK_INDEX_TYPE_UINT16 ? 16 : 32);
RT_TRACE(" Vertex count: %u\n", geom_desc->Triangles.VertexCount);
RT_TRACE(" IBO VA: %"PRIx64".\n", geom_desc->Triangles.IndexBuffer);
}
else
{
info->primitive_counts[i] = geom_desc->Triangles.VertexCount / 3;
triangles->indexType = VK_INDEX_TYPE_NONE_KHR;
RT_TRACE(" Triangle list : Vertex count: %u\n", geom_desc->Triangles.VertexCount);
}
triangles->maxVertex = max(1, geom_desc->Triangles.VertexCount) - 1;
triangles->vertexStride = geom_desc->Triangles.VertexBuffer.StrideInBytes;
triangles->vertexFormat = vkd3d_internal_get_vk_format(device, geom_desc->Triangles.VertexFormat);
triangles->vertexData.deviceAddress = geom_desc->Triangles.VertexBuffer.StartAddress;
triangles->transformData.deviceAddress = geom_desc->Triangles.Transform3x4;
RT_TRACE(" Transform3x4: %s\n", geom_desc->Triangles.Transform3x4 ? "on" : "off");
RT_TRACE(" Vertex format: %s\n", debug_dxgi_format(geom_desc->Triangles.VertexFormat));
RT_TRACE(" VBO VA: %"PRIx64"\n", geom_desc->Triangles.VertexBuffer.StartAddress);
RT_TRACE(" Vertex stride: %"PRIu64" bytes\n", geom_desc->Triangles.VertexBuffer.StrideInBytes);
break;
case D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS:
/* Runtime validates this. */
if (have_triangles)
{
ERR("Cannot mix and match geometry types in a BLAS.\n");
return false;
}
have_aabbs = true;
info->geometries[i].geometryType = VK_GEOMETRY_TYPE_AABBS_KHR;
aabbs = &info->geometries[i].geometry.aabbs;
aabbs->sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR;
aabbs->stride = geom_desc->AABBs.AABBs.StrideInBytes;
aabbs->data.deviceAddress = geom_desc->AABBs.AABBs.StartAddress;
info->primitive_counts[i] = geom_desc->AABBs.AABBCount;
RT_TRACE(" AABB stride: %"PRIu64" bytes\n", geom_desc->AABBs.AABBs.StrideInBytes);
break;
default:
FIXME("Unsupported geometry type %u.\n", geom_desc->Type);
return false;
}
RT_TRACE(" Primitive count %u.\n", info->primitive_counts[i]);
}
}
for (i = 0; i < build_info->geometryCount; i++)
{
info->build_range_ptrs[i] = &info->build_ranges[i];
info->build_ranges[i].primitiveCount = info->primitive_counts[i];
info->build_ranges[i].firstVertex = 0;
info->build_ranges[i].primitiveOffset = 0;
info->build_ranges[i].transformOffset = 0;
}
build_info->pGeometries = info->geometries;
RT_TRACE("=====================\n");
return true;
}
static void vkd3d_acceleration_structure_end_barrier(struct d3d12_command_list *list)
{
/* We resolve the query in TRANSFER, but DXR expects UNORDERED_ACCESS. */
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
VkMemoryBarrier barrier;
barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
barrier.pNext = NULL;
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
barrier.dstAccessMask = 0;
VK_CALL(vkCmdPipelineBarrier(list->vk_command_buffer,
VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0,
1, &barrier, 0, NULL, 0, NULL));
}
static void vkd3d_acceleration_structure_write_postbuild_info(
struct d3d12_command_list *list,
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *desc,
VkDeviceSize desc_offset,
VkAccelerationStructureKHR vk_acceleration_structure)
{
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
const struct vkd3d_unique_resource *resource;
VkQueryPool vk_query_pool;
VkQueryType vk_query_type;
uint32_t vk_query_index;
VkDeviceSize stride;
uint32_t type_index;
VkBuffer vk_buffer;
uint32_t offset;
resource = vkd3d_va_map_deref(&list->device->memory_allocator.va_map, desc->DestBuffer);
if (!resource)
{
ERR("Invalid resource.\n");
return;
}
vk_buffer = resource->vk_buffer;
offset = desc->DestBuffer - resource->va;
offset += desc_offset;
if (desc->InfoType == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE)
{
vk_query_type = VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR;
type_index = VKD3D_QUERY_TYPE_INDEX_RT_COMPACTED_SIZE;
stride = sizeof(uint64_t);
}
else if (desc->InfoType == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE &&
list->device->device_info.ray_tracing_maintenance1_features.rayTracingMaintenance1)
{
vk_query_type = VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR;
type_index = VKD3D_QUERY_TYPE_INDEX_RT_CURRENT_SIZE;
stride = sizeof(uint64_t);
}
else if (desc->InfoType == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION)
{
vk_query_type = VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR;
type_index = VKD3D_QUERY_TYPE_INDEX_RT_SERIALIZE_SIZE;
stride = sizeof(uint64_t);
}
else
{
FIXME("Unsupported InfoType %u.\n", desc->InfoType);
/* TODO: CURRENT_SIZE is something we cannot query in Vulkan, so
* we'll need to keep around a buffer to handle this.
* For now, just clear to 0. */
VK_CALL(vkCmdFillBuffer(list->vk_command_buffer, vk_buffer, offset,
sizeof(uint64_t), 0));
return;
}
if (!d3d12_command_allocator_allocate_query_from_type_index(list->allocator,
type_index, &vk_query_pool, &vk_query_index))
{
ERR("Failed to allocate query.\n");
return;
}
d3d12_command_list_reset_query(list, vk_query_pool, vk_query_index);
VK_CALL(vkCmdWriteAccelerationStructuresPropertiesKHR(list->vk_command_buffer,
1, &vk_acceleration_structure, vk_query_type, vk_query_pool, vk_query_index));
VK_CALL(vkCmdCopyQueryPoolResults(list->vk_command_buffer,
vk_query_pool, vk_query_index, 1,
vk_buffer, offset, stride,
VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT));
if (desc->InfoType == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION)
{
if (list->device->device_info.ray_tracing_maintenance1_features.rayTracingMaintenance1)
{
type_index = VKD3D_QUERY_TYPE_INDEX_RT_SERIALIZE_SIZE_BOTTOM_LEVEL_POINTERS;
if (!d3d12_command_allocator_allocate_query_from_type_index(list->allocator,
type_index, &vk_query_pool, &vk_query_index))
{
ERR("Failed to allocate query.\n");
return;
}
d3d12_command_list_reset_query(list, vk_query_pool, vk_query_index);
VK_CALL(vkCmdWriteAccelerationStructuresPropertiesKHR(list->vk_command_buffer,
1, &vk_acceleration_structure, vk_query_type, vk_query_pool, vk_query_index));
VK_CALL(vkCmdCopyQueryPoolResults(list->vk_command_buffer,
vk_query_pool, vk_query_index, 1,
vk_buffer, offset + sizeof(uint64_t), stride,
VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT));
}
else
{
FIXME("NumBottomLevelPointers will always return 0.\n");
VK_CALL(vkCmdFillBuffer(list->vk_command_buffer, vk_buffer, offset + sizeof(uint64_t),
sizeof(uint64_t), 0));
}
}
}
void vkd3d_acceleration_structure_emit_postbuild_info(
struct d3d12_command_list *list,
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *desc,
uint32_t count,
const D3D12_GPU_VIRTUAL_ADDRESS *addresses)
{
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
VkAccelerationStructureKHR vk_acceleration_structure;
VkMemoryBarrier barrier;
VkDeviceSize stride;
uint32_t i;
barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
barrier.pNext = NULL;
barrier.srcAccessMask = 0;
barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
/* We resolve the query in TRANSFER, but DXR expects UNORDERED_ACCESS. */
VK_CALL(vkCmdPipelineBarrier(list->vk_command_buffer,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
1, &barrier, 0, NULL, 0, NULL));
stride = desc->InfoType == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION ?
2 * sizeof(uint64_t) : sizeof(uint64_t);
for (i = 0; i < count; i++)
{
vk_acceleration_structure = vkd3d_va_map_place_acceleration_structure(
&list->device->memory_allocator.va_map, list->device, addresses[i]);
if (vk_acceleration_structure)
vkd3d_acceleration_structure_write_postbuild_info(list, desc, i * stride, vk_acceleration_structure);
else
ERR("Failed to query acceleration structure for VA 0x%"PRIx64".\n", addresses[i]);
}
vkd3d_acceleration_structure_end_barrier(list);
}
void vkd3d_acceleration_structure_emit_immediate_postbuild_info(
struct d3d12_command_list *list, uint32_t count,
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *desc,
VkAccelerationStructureKHR vk_acceleration_structure)
{
/* In D3D12 we are supposed to be able to emit without an explicit barrier,
* but we need to emit them for Vulkan. */
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
VkMemoryBarrier barrier;
uint32_t i;
barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
barrier.pNext = NULL;
barrier.srcAccessMask = VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR;
/* The query accesses STRUCTURE_READ_BIT in BUILD_BIT stage. */
barrier.dstAccessMask = VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR | VK_ACCESS_TRANSFER_WRITE_BIT;
/* Writing to the result buffer is supposed to happen in UNORDERED_ACCESS on DXR for
* some bizarre reason, so we have to satisfy a transfer barrier.
* Have to basically do a full stall to make this work ... */
VK_CALL(vkCmdPipelineBarrier(list->vk_command_buffer,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR | VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
1, &barrier, 0, NULL, 0, NULL));
/* Could optimize a bit by batching more aggressively, but no idea if it's going to help in practice. */
for (i = 0; i < count; i++)
vkd3d_acceleration_structure_write_postbuild_info(list, &desc[i], 0, vk_acceleration_structure);
vkd3d_acceleration_structure_end_barrier(list);
}
static bool convert_copy_mode(
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE mode,
VkCopyAccelerationStructureModeKHR *vk_mode)
{
switch (mode)
{
case D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_CLONE:
*vk_mode = VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR;
return true;
case D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_COMPACT:
*vk_mode = VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR;
return true;
default:
FIXME("Unsupported RTAS copy mode #%x.\n", mode);
return false;
}
}
void vkd3d_acceleration_structure_copy(
struct d3d12_command_list *list,
D3D12_GPU_VIRTUAL_ADDRESS dst, D3D12_GPU_VIRTUAL_ADDRESS src,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE mode)
{
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
VkAccelerationStructureKHR dst_as, src_as;
VkCopyAccelerationStructureInfoKHR info;
dst_as = vkd3d_va_map_place_acceleration_structure(&list->device->memory_allocator.va_map, list->device, dst);
if (dst_as == VK_NULL_HANDLE)
{
ERR("Invalid dst address #%"PRIx64" for RTAS copy.\n", dst);
return;
}
src_as = vkd3d_va_map_place_acceleration_structure(&list->device->memory_allocator.va_map, list->device, src);
if (src_as == VK_NULL_HANDLE)
{
ERR("Invalid src address #%"PRIx64" for RTAS copy.\n", src);
return;
}
info.sType = VK_STRUCTURE_TYPE_COPY_ACCELERATION_STRUCTURE_INFO_KHR;
info.pNext = NULL;
info.dst = dst_as;
info.src = src_as;
if (convert_copy_mode(mode, &info.mode))
VK_CALL(vkCmdCopyAccelerationStructureKHR(list->vk_command_buffer, &info));
}

655
libs/vkd3d/breadcrumbs.c Normal file
View File

@ -0,0 +1,655 @@
/*
* Copyright 2022 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_private.h"
#include "vkd3d_debug.h"
#include "vkd3d_common.h"
#include <assert.h>
#include <stdio.h>
/* Just allocate everything up front. This only consumes host memory anyways. */
#define MAX_COMMAND_LISTS (32 * 1024)
/* Questionable on 32-bit, but we don't really care. */
#define NV_ENCODE_CHECKPOINT(context, counter) ((void*) ((uintptr_t)(context) + (uintptr_t)MAX_COMMAND_LISTS * (counter)))
#define NV_CHECKPOINT_CONTEXT(ptr) ((uint32_t)((uintptr_t)(ptr) % MAX_COMMAND_LISTS))
#define NV_CHECKPOINT_COUNTER(ptr) ((uint32_t)((uintptr_t)(ptr) / MAX_COMMAND_LISTS))
static const char *vkd3d_breadcrumb_command_type_to_str(enum vkd3d_breadcrumb_command_type type)
{
switch (type)
{
case VKD3D_BREADCRUMB_COMMAND_SET_TOP_MARKER:
return "top_marker";
case VKD3D_BREADCRUMB_COMMAND_SET_BOTTOM_MARKER:
return "bottom_marker";
case VKD3D_BREADCRUMB_COMMAND_SET_SHADER_HASH:
return "set_shader_hash";
case VKD3D_BREADCRUMB_COMMAND_DRAW:
return "draw";
case VKD3D_BREADCRUMB_COMMAND_DRAW_INDEXED:
return "draw_indexed";
case VKD3D_BREADCRUMB_COMMAND_DISPATCH:
return "dispatch";
case VKD3D_BREADCRUMB_COMMAND_EXECUTE_INDIRECT:
return "execute_indirect";
case VKD3D_BREADCRUMB_COMMAND_EXECUTE_INDIRECT_TEMPLATE:
return "execute_indirect_template";
case VKD3D_BREADCRUMB_COMMAND_COPY:
return "copy";
case VKD3D_BREADCRUMB_COMMAND_RESOLVE:
return "resolve";
case VKD3D_BREADCRUMB_COMMAND_WBI:
return "wbi";
case VKD3D_BREADCRUMB_COMMAND_RESOLVE_QUERY:
return "resolve_query";
case VKD3D_BREADCRUMB_COMMAND_GATHER_VIRTUAL_QUERY:
return "gather_virtual_query";
case VKD3D_BREADCRUMB_COMMAND_BUILD_RTAS:
return "build_rtas";
case VKD3D_BREADCRUMB_COMMAND_COPY_RTAS:
return "copy_rtas";
case VKD3D_BREADCRUMB_COMMAND_EMIT_RTAS_POSTBUILD:
return "emit_rtas_postbuild";
case VKD3D_BREADCRUMB_COMMAND_TRACE_RAYS:
return "trace_rays";
case VKD3D_BREADCRUMB_COMMAND_BARRIER:
return "barrier";
case VKD3D_BREADCRUMB_COMMAND_AUX32:
return "aux32";
case VKD3D_BREADCRUMB_COMMAND_AUX64:
return "aux64";
case VKD3D_BREADCRUMB_COMMAND_VBO:
return "vbo";
case VKD3D_BREADCRUMB_COMMAND_IBO:
return "ibo";
case VKD3D_BREADCRUMB_COMMAND_ROOT_DESC:
return "root_desc";
case VKD3D_BREADCRUMB_COMMAND_ROOT_CONST:
return "root_const";
case VKD3D_BREADCRUMB_COMMAND_TAG:
return "tag";
default:
return "?";
}
}
HRESULT vkd3d_breadcrumb_tracer_init(struct vkd3d_breadcrumb_tracer *tracer, struct d3d12_device *device)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
D3D12_HEAP_PROPERTIES heap_properties;
D3D12_RESOURCE_DESC1 resource_desc;
VkMemoryPropertyFlags memory_props;
HRESULT hr;
int rc;
memset(tracer, 0, sizeof(*tracer));
if ((rc = pthread_mutex_init(&tracer->lock, NULL)))
return hresult_from_errno(rc);
if (device->vk_info.AMD_buffer_marker)
{
INFO("Enabling AMD_buffer_marker breadcrumbs.\n");
memset(&resource_desc, 0, sizeof(resource_desc));
resource_desc.Width = MAX_COMMAND_LISTS * sizeof(struct vkd3d_breadcrumb_counter);
resource_desc.Height = 1;
resource_desc.DepthOrArraySize = 1;
resource_desc.MipLevels = 1;
resource_desc.Format = DXGI_FORMAT_UNKNOWN;
resource_desc.SampleDesc.Count = 1;
resource_desc.SampleDesc.Quality = 0;
resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
if (FAILED(hr = vkd3d_create_buffer(device, &heap_properties, D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS,
&resource_desc, &tracer->host_buffer)))
{
goto err;
}
memory_props = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
/* If device faults in the middle of execution we will never get the chance to flush device caches.
* Make sure that breadcrumbs are always written directly out.
* This is the primary usecase for the device coherent/uncached extension after all ...
* Don't make this a hard requirement since buffer markers might be implicitly coherent on some
* implementations (Turnip?). */
if (device->device_info.device_coherent_memory_features_amd.deviceCoherentMemory)
{
memory_props |= VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD |
VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD;
}
if (FAILED(hr = vkd3d_allocate_buffer_memory(device, tracer->host_buffer,
memory_props, &tracer->host_buffer_memory)))
{
goto err;
}
if (VK_CALL(vkMapMemory(device->vk_device, tracer->host_buffer_memory.vk_memory,
0, VK_WHOLE_SIZE,
0, (void**)&tracer->mapped)) != VK_SUCCESS)
{
hr = E_OUTOFMEMORY;
goto err;
}
memset(tracer->mapped, 0, sizeof(*tracer->mapped) * MAX_COMMAND_LISTS);
}
else if (device->vk_info.NV_device_diagnostic_checkpoints)
{
INFO("Enabling NV_device_diagnostics_checkpoints breadcrumbs.\n");
}
else
{
ERR("Breadcrumbs require support for either AMD_buffer_marker or NV_device_diagnostics_checkpoints.\n");
hr = E_FAIL;
goto err;
}
tracer->trace_contexts = vkd3d_calloc(MAX_COMMAND_LISTS, sizeof(*tracer->trace_contexts));
tracer->trace_context_index = 0;
return S_OK;
err:
vkd3d_breadcrumb_tracer_cleanup(tracer, device);
return hr;
}
void vkd3d_breadcrumb_tracer_cleanup(struct vkd3d_breadcrumb_tracer *tracer, struct d3d12_device *device)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
if (device->vk_info.AMD_buffer_marker)
{
VK_CALL(vkDestroyBuffer(device->vk_device, tracer->host_buffer, NULL));
vkd3d_free_device_memory(device, &tracer->host_buffer_memory);
}
vkd3d_free(tracer->trace_contexts);
pthread_mutex_destroy(&tracer->lock);
}
unsigned int vkd3d_breadcrumb_tracer_allocate_command_list(struct vkd3d_breadcrumb_tracer *tracer,
struct d3d12_command_list *list, struct d3d12_command_allocator *allocator)
{
unsigned int index = UINT32_MAX;
unsigned int iteration_count;
int rc;
if ((rc = pthread_mutex_lock(&tracer->lock)))
{
ERR("Failed to lock mutex, rc %d.\n", rc);
return UINT32_MAX;
}
/* Since this is a ring, this is extremely likely to succeed on first attempt. */
for (iteration_count = 0; iteration_count < MAX_COMMAND_LISTS; iteration_count++)
{
tracer->trace_context_index = (tracer->trace_context_index + 1) % MAX_COMMAND_LISTS;
if (!tracer->trace_contexts[tracer->trace_context_index].locked)
{
tracer->trace_contexts[tracer->trace_context_index].locked = 1;
index = tracer->trace_context_index;
break;
}
}
pthread_mutex_unlock(&tracer->lock);
if (index == UINT32_MAX)
{
ERR("Failed to allocate new index for command list.\n");
return index;
}
TRACE("Allocating breadcrumb context %u for list %p.\n", index, list);
list->breadcrumb_context_index = index;
/* Need to clear this on a fresh allocation rather than release, since we can end up releasing a command list
* before we observe the device lost. */
tracer->trace_contexts[index].command_count = 0;
tracer->trace_contexts[index].counter = 0;
if (list->device->vk_info.AMD_buffer_marker)
memset(&tracer->mapped[index], 0, sizeof(tracer->mapped[index]));
vkd3d_array_reserve((void**)&allocator->breadcrumb_context_indices, &allocator->breadcrumb_context_index_size,
allocator->breadcrumb_context_index_count + 1,
sizeof(*allocator->breadcrumb_context_indices));
allocator->breadcrumb_context_indices[allocator->breadcrumb_context_index_count++] = index;
return index;
}
/* Command allocator keeps a list of allocated breadcrumb command lists. */
void vkd3d_breadcrumb_tracer_release_command_lists(struct vkd3d_breadcrumb_tracer *tracer,
const unsigned int *indices, size_t indices_count)
{
unsigned int index;
size_t i;
int rc;
if (!indices_count)
return;
if ((rc = pthread_mutex_lock(&tracer->lock)))
{
ERR("Failed to lock mutex, rc %d.\n", rc);
return;
}
for (i = 0; i < indices_count; i++)
{
index = indices[i];
if (index != UINT32_MAX)
tracer->trace_contexts[index].locked = 0;
TRACE("Releasing breadcrumb context %u.\n", index);
}
pthread_mutex_unlock(&tracer->lock);
}
static void vkd3d_breadcrumb_tracer_report_command_list(
const struct vkd3d_breadcrumb_command_list_trace_context *context,
uint32_t begin_marker,
uint32_t end_marker)
{
const struct vkd3d_breadcrumb_command *cmd;
bool observed_begin_cmd = false;
bool observed_end_cmd = false;
unsigned int i;
if (end_marker == 0)
{
ERR(" ===== Potential crash region BEGIN (make sure RADV_DEBUG=syncshaders is used for maximum accuracy) =====\n");
observed_begin_cmd = true;
}
/* We can assume that possible culprit commands lie between the end_marker
* and top_marker. */
for (i = 0; i < context->command_count; i++)
{
cmd = &context->commands[i];
/* If there is a command which sets TOP_OF_PIPE, but we haven't observed the marker yet,
* the command processor hasn't gotten there yet (most likely ...), so that should be the
* natural end-point. */
if (!observed_end_cmd &&
cmd->type == VKD3D_BREADCRUMB_COMMAND_SET_TOP_MARKER &&
cmd->count > begin_marker)
{
observed_end_cmd = true;
ERR(" ===== Potential crash region END =====\n");
}
if (cmd->type == VKD3D_BREADCRUMB_COMMAND_AUX32)
{
ERR(" Set arg: %u (#%x)\n", cmd->word_32bit, cmd->word_32bit);
}
else if (cmd->type == VKD3D_BREADCRUMB_COMMAND_AUX64)
{
ERR(" Set arg: %"PRIu64" (#%"PRIx64")\n", cmd->word_64bit, cmd->word_64bit);
}
else if (cmd->type == VKD3D_BREADCRUMB_COMMAND_TAG)
{
ERR(" Tag: %s\n", cmd->tag);
}
else
{
ERR(" Command: %s\n", vkd3d_breadcrumb_command_type_to_str(cmd->type));
switch (cmd->type)
{
case VKD3D_BREADCRUMB_COMMAND_SET_TOP_MARKER:
case VKD3D_BREADCRUMB_COMMAND_SET_BOTTOM_MARKER:
ERR(" marker: %u\n", cmd->count);
break;
case VKD3D_BREADCRUMB_COMMAND_SET_SHADER_HASH:
ERR(" hash: %016"PRIx64", stage: %x\n", cmd->shader.hash, cmd->shader.stage);
break;
default:
break;
}
}
/* We have proved we observed this command is complete.
* Some command after this signal is at fault. */
if (!observed_begin_cmd &&
cmd->type == VKD3D_BREADCRUMB_COMMAND_SET_BOTTOM_MARKER &&
cmd->count == end_marker)
{
observed_begin_cmd = true;
ERR(" ===== Potential crash region BEGIN (make sure RADV_DEBUG=syncshaders is used for maximum accuracy) =====\n");
}
}
}
static void vkd3d_breadcrumb_tracer_report_command_list_amd(struct vkd3d_breadcrumb_tracer *tracer,
unsigned int context_index)
{
const struct vkd3d_breadcrumb_command_list_trace_context *context;
uint32_t begin_marker;
uint32_t end_marker;
context = &tracer->trace_contexts[context_index];
/* Unused, cannot be the cause. */
if (context->counter == 0)
return;
begin_marker = tracer->mapped[context_index].begin_marker;
end_marker = tracer->mapped[context_index].end_marker;
/* Never executed, cannot be the cause. */
if (begin_marker == 0 && end_marker == 0)
return;
/* Successfully retired, cannot be the cause. */
if (begin_marker == UINT32_MAX && end_marker == UINT32_MAX)
return;
/* Edge case if we re-submitted a command list,
* but it ends up crashing before we hit any BOTTOM_OF_PIPE
* marker. Normalize the inputs such that end_marker <= begin_marker. */
if (begin_marker > 0 && end_marker == UINT32_MAX)
end_marker = 0;
ERR("Found pending command list context %u in executable state, TOP_OF_PIPE marker %u, BOTTOM_OF_PIPE marker %u.\n",
context_index, begin_marker, end_marker);
vkd3d_breadcrumb_tracer_report_command_list(context, begin_marker, end_marker);
ERR("Done analyzing command list.\n");
}
static void vkd3d_breadcrumb_tracer_report_queue_nv(struct vkd3d_breadcrumb_tracer *tracer,
struct d3d12_device *device,
VkQueue vk_queue)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
uint32_t begin_marker, end_marker;
uint32_t checkpoint_context_index;
VkCheckpointDataNV *checkpoints;
uint32_t checkpoint_marker;
uint32_t checkpoint_count;
uint32_t context_index;
uint32_t i;
VK_CALL(vkGetQueueCheckpointDataNV(vk_queue, &checkpoint_count, NULL));
if (checkpoint_count == 0)
return;
checkpoints = vkd3d_calloc(checkpoint_count, sizeof(VkCheckpointDataNV));
for (i = 0; i < checkpoint_count; i++)
checkpoints[i].sType = VK_STRUCTURE_TYPE_CHECKPOINT_DATA_NV;
VK_CALL(vkGetQueueCheckpointDataNV(vk_queue, &checkpoint_count, checkpoints));
context_index = UINT32_MAX;
begin_marker = 0;
end_marker = 0;
for (i = 0; i < checkpoint_count; i++)
{
checkpoint_context_index = NV_CHECKPOINT_CONTEXT(checkpoints[i].pCheckpointMarker);
checkpoint_marker = NV_CHECKPOINT_COUNTER(checkpoints[i].pCheckpointMarker);
if (context_index != checkpoint_context_index && context_index != UINT32_MAX)
{
FIXME("Markers have different contexts. Execution is likely split across multiple command buffers?\n");
context_index = UINT32_MAX;
break;
}
context_index = checkpoint_context_index;
if (checkpoints[i].stage == VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT && checkpoint_marker > begin_marker)
{
/* We want to find the latest TOP_OF_PIPE_BIT. Then we prove that command processor got to that point. */
begin_marker = checkpoint_marker;
}
else if (checkpoints[i].stage == VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT && checkpoint_marker > end_marker)
{
/* We want to find the latest BOTTOM_OF_PIPE_BIT. Then we prove that we got that far. */
end_marker = checkpoint_marker;
}
else if (checkpoints[i].stage != VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT &&
checkpoints[i].stage != VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT)
{
FIXME("Unexpected checkpoint pipeline stage. #%x\n", checkpoints[i].stage);
context_index = UINT32_MAX;
break;
}
}
if (context_index != UINT32_MAX && begin_marker != 0 && end_marker != 0 && end_marker != UINT32_MAX)
{
ERR("Found pending command list context %u in executable state, TOP_OF_PIPE marker %u, BOTTOM_OF_PIPE marker %u.\n",
context_index, begin_marker, end_marker);
vkd3d_breadcrumb_tracer_report_command_list(&tracer->trace_contexts[context_index], begin_marker, end_marker);
ERR("Done analyzing command list.\n");
}
vkd3d_free(checkpoints);
}
void vkd3d_breadcrumb_tracer_report_device_lost(struct vkd3d_breadcrumb_tracer *tracer,
struct d3d12_device *device)
{
struct vkd3d_queue_family_info *queue_family_info;
VkQueue vk_queue;
unsigned int i;
ERR("Device lost observed, analyzing breadcrumbs ...\n");
if (device->vk_info.AMD_buffer_marker)
{
/* AMD path, buffer marker. */
for (i = 0; i < MAX_COMMAND_LISTS; i++)
vkd3d_breadcrumb_tracer_report_command_list_amd(tracer, i);
}
else if (device->vk_info.NV_device_diagnostic_checkpoints)
{
/* vkGetQueueCheckpointDataNV does not require us to synchronize access to the queue. */
queue_family_info = d3d12_device_get_vkd3d_queue_family(device, D3D12_COMMAND_LIST_TYPE_DIRECT);
for (i = 0; i < queue_family_info->queue_count; i++)
{
vk_queue = queue_family_info->queues[i]->vk_queue;
vkd3d_breadcrumb_tracer_report_queue_nv(tracer, device, vk_queue);
}
queue_family_info = d3d12_device_get_vkd3d_queue_family(device, D3D12_COMMAND_LIST_TYPE_COMPUTE);
for (i = 0; i < queue_family_info->queue_count; i++)
{
vk_queue = queue_family_info->queues[i]->vk_queue;
vkd3d_breadcrumb_tracer_report_queue_nv(tracer, device, vk_queue);
}
queue_family_info = d3d12_device_get_vkd3d_queue_family(device, D3D12_COMMAND_LIST_TYPE_COPY);
for (i = 0; i < queue_family_info->queue_count; i++)
{
vk_queue = queue_family_info->queues[i]->vk_queue;
vkd3d_breadcrumb_tracer_report_queue_nv(tracer, device, vk_queue);
}
}
ERR("Done analyzing breadcrumbs ...\n");
}
void vkd3d_breadcrumb_tracer_begin_command_list(struct d3d12_command_list *list)
{
struct vkd3d_breadcrumb_tracer *breadcrumb_tracer = &list->device->breadcrumb_tracer;
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
struct vkd3d_breadcrumb_command_list_trace_context *trace;
unsigned int context = list->breadcrumb_context_index;
struct vkd3d_breadcrumb_command cmd;
if (context == UINT32_MAX)
return;
trace = &breadcrumb_tracer->trace_contexts[context];
trace->counter++;
cmd.count = trace->counter;
cmd.type = VKD3D_BREADCRUMB_COMMAND_SET_TOP_MARKER;
vkd3d_breadcrumb_tracer_add_command(list, &cmd);
if (list->device->vk_info.AMD_buffer_marker)
{
VK_CALL(vkCmdWriteBufferMarkerAMD(list->vk_command_buffer,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
breadcrumb_tracer->host_buffer,
context * sizeof(struct vkd3d_breadcrumb_counter) +
offsetof(struct vkd3d_breadcrumb_counter, begin_marker),
trace->counter));
}
else if (list->device->vk_info.NV_device_diagnostic_checkpoints)
{
/* A checkpoint is implicitly a top and bottom marker. */
cmd.count = trace->counter;
cmd.type = VKD3D_BREADCRUMB_COMMAND_SET_BOTTOM_MARKER;
vkd3d_breadcrumb_tracer_add_command(list, &cmd);
VK_CALL(vkCmdSetCheckpointNV(list->vk_command_buffer, NV_ENCODE_CHECKPOINT(context, trace->counter)));
}
}
void vkd3d_breadcrumb_tracer_add_command(struct d3d12_command_list *list,
const struct vkd3d_breadcrumb_command *command)
{
struct vkd3d_breadcrumb_tracer *breadcrumb_tracer = &list->device->breadcrumb_tracer;
struct vkd3d_breadcrumb_command_list_trace_context *trace;
unsigned int context = list->breadcrumb_context_index;
if (context == UINT32_MAX)
return;
trace = &breadcrumb_tracer->trace_contexts[context];
TRACE("Adding command (%s) to context %u.\n",
vkd3d_breadcrumb_command_type_to_str(command->type), context);
vkd3d_array_reserve((void**)&trace->commands, &trace->command_size,
trace->command_count + 1, sizeof(*trace->commands));
trace->commands[trace->command_count++] = *command;
}
void vkd3d_breadcrumb_tracer_signal(struct d3d12_command_list *list)
{
struct vkd3d_breadcrumb_tracer *breadcrumb_tracer = &list->device->breadcrumb_tracer;
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
struct vkd3d_breadcrumb_command_list_trace_context *trace;
unsigned int context = list->breadcrumb_context_index;
struct vkd3d_breadcrumb_command cmd;
if (context == UINT32_MAX)
return;
trace = &breadcrumb_tracer->trace_contexts[context];
if (list->device->vk_info.AMD_buffer_marker)
{
cmd.type = VKD3D_BREADCRUMB_COMMAND_SET_BOTTOM_MARKER;
cmd.count = trace->counter;
vkd3d_breadcrumb_tracer_add_command(list, &cmd);
TRACE("Breadcrumb signal bottom-of-pipe context %u -> %u\n", context, cmd.count);
VK_CALL(vkCmdWriteBufferMarkerAMD(list->vk_command_buffer,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
breadcrumb_tracer->host_buffer,
context * sizeof(struct vkd3d_breadcrumb_counter) +
offsetof(struct vkd3d_breadcrumb_counter, end_marker),
trace->counter));
trace->counter++;
cmd.type = VKD3D_BREADCRUMB_COMMAND_SET_TOP_MARKER;
cmd.count = trace->counter;
vkd3d_breadcrumb_tracer_add_command(list, &cmd);
TRACE("Breadcrumb signal top-of-pipe context %u -> %u\n", context, cmd.count);
VK_CALL(vkCmdWriteBufferMarkerAMD(list->vk_command_buffer,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
breadcrumb_tracer->host_buffer,
context * sizeof(struct vkd3d_breadcrumb_counter) +
offsetof(struct vkd3d_breadcrumb_counter, begin_marker),
trace->counter));
}
else if (list->device->vk_info.NV_device_diagnostic_checkpoints)
{
trace->counter++;
cmd.type = VKD3D_BREADCRUMB_COMMAND_SET_TOP_MARKER;
cmd.count = trace->counter;
vkd3d_breadcrumb_tracer_add_command(list, &cmd);
TRACE("Breadcrumb signal top-of-pipe context %u -> %u\n", context, cmd.count);
cmd.type = VKD3D_BREADCRUMB_COMMAND_SET_BOTTOM_MARKER;
cmd.count = trace->counter;
vkd3d_breadcrumb_tracer_add_command(list, &cmd);
TRACE("Breadcrumb signal bottom-of-pipe context %u -> %u\n", context, cmd.count);
VK_CALL(vkCmdSetCheckpointNV(list->vk_command_buffer, NV_ENCODE_CHECKPOINT(context, trace->counter)));
}
}
void vkd3d_breadcrumb_tracer_end_command_list(struct d3d12_command_list *list)
{
struct vkd3d_breadcrumb_tracer *breadcrumb_tracer = &list->device->breadcrumb_tracer;
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
struct vkd3d_breadcrumb_command_list_trace_context *trace;
unsigned int context = list->breadcrumb_context_index;
struct vkd3d_breadcrumb_command cmd;
if (context == UINT32_MAX)
return;
trace = &breadcrumb_tracer->trace_contexts[context];
trace->counter = UINT32_MAX;
if (list->device->vk_info.AMD_buffer_marker)
{
VK_CALL(vkCmdWriteBufferMarkerAMD(list->vk_command_buffer,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
breadcrumb_tracer->host_buffer,
context * sizeof(struct vkd3d_breadcrumb_counter) +
offsetof(struct vkd3d_breadcrumb_counter, begin_marker),
trace->counter));
VK_CALL(vkCmdWriteBufferMarkerAMD(list->vk_command_buffer,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
breadcrumb_tracer->host_buffer,
context * sizeof(struct vkd3d_breadcrumb_counter) +
offsetof(struct vkd3d_breadcrumb_counter, end_marker),
trace->counter));
}
else if (list->device->vk_info.NV_device_diagnostic_checkpoints)
{
VK_CALL(vkCmdSetCheckpointNV(list->vk_command_buffer, NV_ENCODE_CHECKPOINT(context, trace->counter)));
}
cmd.count = trace->counter;
cmd.type = VKD3D_BREADCRUMB_COMMAND_SET_TOP_MARKER;
vkd3d_breadcrumb_tracer_add_command(list, &cmd);
cmd.type = VKD3D_BREADCRUMB_COMMAND_SET_BOTTOM_MARKER;
vkd3d_breadcrumb_tracer_add_command(list, &cmd);
}

1787
libs/vkd3d/bundle.c Normal file

File diff suppressed because it is too large Load Diff

3268
libs/vkd3d/cache.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,562 @@
/*
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_COMMAND_LIST_PROFILED
#define __VKD3D_COMMAND_LIST_PROFILED
#define COMMAND_LIST_PROFILED_CALL(name, ...) \
VKD3D_REGION_DECL(name); \
VKD3D_REGION_BEGIN(name); \
d3d12_command_list_##name(__VA_ARGS__); \
VKD3D_REGION_END(name)
static void STDMETHODCALLTYPE d3d12_command_list_DrawInstanced_profiled(d3d12_command_list_iface *iface,
UINT vertex_count_per_instance, UINT instance_count, UINT start_vertex_location,
UINT start_instance_location)
{
COMMAND_LIST_PROFILED_CALL(DrawInstanced, iface, vertex_count_per_instance,
instance_count, start_vertex_location, start_instance_location);
}
static void STDMETHODCALLTYPE d3d12_command_list_DrawIndexedInstanced_profiled(d3d12_command_list_iface *iface,
UINT index_count_per_instance, UINT instance_count, UINT start_vertex_location,
INT base_vertex_location, UINT start_instance_location)
{
COMMAND_LIST_PROFILED_CALL(DrawIndexedInstanced, iface, index_count_per_instance, instance_count,
start_vertex_location, base_vertex_location, start_instance_location);
}
static void STDMETHODCALLTYPE d3d12_command_list_Dispatch_profiled(d3d12_command_list_iface *iface,
UINT x, UINT y, UINT z)
{
COMMAND_LIST_PROFILED_CALL(Dispatch, iface, x, y, z);
}
static void STDMETHODCALLTYPE d3d12_command_list_CopyBufferRegion_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *dst, UINT64 dst_offset, ID3D12Resource *src, UINT64 src_offset, UINT64 byte_count)
{
COMMAND_LIST_PROFILED_CALL(CopyBufferRegion, iface, dst, dst_offset, src, src_offset, byte_count);
}
static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion_profiled(d3d12_command_list_iface *iface,
const D3D12_TEXTURE_COPY_LOCATION *dst, UINT dst_x, UINT dst_y, UINT dst_z,
const D3D12_TEXTURE_COPY_LOCATION *src, const D3D12_BOX *src_box)
{
COMMAND_LIST_PROFILED_CALL(CopyTextureRegion, iface, dst, dst_x, dst_y, dst_z, src, src_box);
}
static void STDMETHODCALLTYPE d3d12_command_list_CopyResource_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *dst, ID3D12Resource *src)
{
COMMAND_LIST_PROFILED_CALL(CopyResource, iface, dst, src);
}
static void STDMETHODCALLTYPE d3d12_command_list_CopyTiles_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *tiled_resource, const D3D12_TILED_RESOURCE_COORDINATE *region_coord,
const D3D12_TILE_REGION_SIZE *region_size, ID3D12Resource *buffer, UINT64 buffer_offset,
D3D12_TILE_COPY_FLAGS flags)
{
COMMAND_LIST_PROFILED_CALL(CopyTiles, iface, tiled_resource, region_coord, region_size, buffer, buffer_offset, flags);
}
static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresource_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *dst, UINT dst_sub_resource_idx,
ID3D12Resource *src, UINT src_sub_resource_idx, DXGI_FORMAT format)
{
COMMAND_LIST_PROFILED_CALL(ResolveSubresource, iface, dst, dst_sub_resource_idx, src, src_sub_resource_idx, format);
}
static void STDMETHODCALLTYPE d3d12_command_list_IASetPrimitiveTopology_profiled(d3d12_command_list_iface *iface,
D3D12_PRIMITIVE_TOPOLOGY topology)
{
COMMAND_LIST_PROFILED_CALL(IASetPrimitiveTopology, iface, topology);
}
static void STDMETHODCALLTYPE d3d12_command_list_RSSetViewports_profiled(d3d12_command_list_iface *iface,
UINT viewport_count, const D3D12_VIEWPORT *viewports)
{
COMMAND_LIST_PROFILED_CALL(RSSetViewports, iface, viewport_count, viewports);
}
static void STDMETHODCALLTYPE d3d12_command_list_RSSetScissorRects_profiled(d3d12_command_list_iface *iface,
UINT rect_count, const D3D12_RECT *rects)
{
COMMAND_LIST_PROFILED_CALL(RSSetScissorRects, iface, rect_count, rects);
}
static void STDMETHODCALLTYPE d3d12_command_list_OMSetBlendFactor_profiled(d3d12_command_list_iface *iface,
const FLOAT blend_factor[4])
{
COMMAND_LIST_PROFILED_CALL(OMSetBlendFactor, iface, blend_factor);
}
static void STDMETHODCALLTYPE d3d12_command_list_OMSetStencilRef_profiled(d3d12_command_list_iface *iface,
UINT stencil_ref)
{
COMMAND_LIST_PROFILED_CALL(OMSetStencilRef, iface, stencil_ref);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetPipelineState_profiled(d3d12_command_list_iface *iface,
ID3D12PipelineState *pipeline_state)
{
COMMAND_LIST_PROFILED_CALL(SetPipelineState, iface, pipeline_state);
}
static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier_profiled(d3d12_command_list_iface *iface,
UINT barrier_count, const D3D12_RESOURCE_BARRIER *barriers)
{
COMMAND_LIST_PROFILED_CALL(ResourceBarrier, iface, barrier_count, barriers);
}
static void STDMETHODCALLTYPE d3d12_command_list_ExecuteBundle_profiled(d3d12_command_list_iface *iface,
ID3D12GraphicsCommandList *command_list)
{
COMMAND_LIST_PROFILED_CALL(ExecuteBundle, iface, command_list);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetDescriptorHeaps_profiled(d3d12_command_list_iface *iface,
UINT heap_count, ID3D12DescriptorHeap *const *heaps)
{
COMMAND_LIST_PROFILED_CALL(SetDescriptorHeaps, iface, heap_count, heaps);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootSignature_profiled(d3d12_command_list_iface *iface,
ID3D12RootSignature *root_signature)
{
COMMAND_LIST_PROFILED_CALL(SetComputeRootSignature, iface, root_signature);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootSignature_profiled(d3d12_command_list_iface *iface,
ID3D12RootSignature *root_signature)
{
COMMAND_LIST_PROFILED_CALL(SetGraphicsRootSignature, iface, root_signature);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootDescriptorTable_profiled(d3d12_command_list_iface *iface,
UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
{
COMMAND_LIST_PROFILED_CALL(SetComputeRootDescriptorTable, iface, root_parameter_index, base_descriptor);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootDescriptorTable_profiled(d3d12_command_list_iface *iface,
UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
{
COMMAND_LIST_PROFILED_CALL(SetGraphicsRootDescriptorTable, iface, root_parameter_index, base_descriptor);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRoot32BitConstant_profiled(d3d12_command_list_iface *iface,
UINT root_parameter_index, UINT data, UINT dst_offset)
{
COMMAND_LIST_PROFILED_CALL(SetComputeRoot32BitConstant, iface, root_parameter_index, data, dst_offset);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRoot32BitConstant_profiled(d3d12_command_list_iface *iface,
UINT root_parameter_index, UINT data, UINT dst_offset)
{
COMMAND_LIST_PROFILED_CALL(SetGraphicsRoot32BitConstant, iface, root_parameter_index, data, dst_offset);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRoot32BitConstants_profiled(d3d12_command_list_iface *iface,
UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset)
{
COMMAND_LIST_PROFILED_CALL(SetComputeRoot32BitConstants, iface, root_parameter_index, constant_count, data, dst_offset);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRoot32BitConstants_profiled(d3d12_command_list_iface *iface,
UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset)
{
COMMAND_LIST_PROFILED_CALL(SetGraphicsRoot32BitConstants, iface, root_parameter_index, constant_count, data, dst_offset);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootConstantBufferView_profiled(
d3d12_command_list_iface *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
{
COMMAND_LIST_PROFILED_CALL(SetComputeRootConstantBufferView, iface, root_parameter_index, address);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootConstantBufferView_profiled(
d3d12_command_list_iface *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
{
COMMAND_LIST_PROFILED_CALL(SetGraphicsRootConstantBufferView, iface, root_parameter_index, address);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootShaderResourceView_profiled(
d3d12_command_list_iface *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
{
COMMAND_LIST_PROFILED_CALL(SetComputeRootShaderResourceView, iface, root_parameter_index, address);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootShaderResourceView_profiled(
d3d12_command_list_iface *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
{
COMMAND_LIST_PROFILED_CALL(SetGraphicsRootShaderResourceView, iface, root_parameter_index, address);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootUnorderedAccessView_profiled(
d3d12_command_list_iface *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
{
COMMAND_LIST_PROFILED_CALL(SetComputeRootUnorderedAccessView, iface, root_parameter_index, address);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootUnorderedAccessView_profiled(
d3d12_command_list_iface *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
{
COMMAND_LIST_PROFILED_CALL(SetGraphicsRootUnorderedAccessView, iface, root_parameter_index, address);
}
static void STDMETHODCALLTYPE d3d12_command_list_IASetIndexBuffer_profiled(d3d12_command_list_iface *iface,
const D3D12_INDEX_BUFFER_VIEW *view)
{
COMMAND_LIST_PROFILED_CALL(IASetIndexBuffer, iface, view);
}
static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers_profiled(d3d12_command_list_iface *iface,
UINT start_slot, UINT view_count, const D3D12_VERTEX_BUFFER_VIEW *views)
{
COMMAND_LIST_PROFILED_CALL(IASetVertexBuffers, iface, start_slot, view_count, views);
}
static void STDMETHODCALLTYPE d3d12_command_list_SOSetTargets_profiled(d3d12_command_list_iface *iface,
UINT start_slot, UINT view_count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW *views)
{
COMMAND_LIST_PROFILED_CALL(SOSetTargets, iface, start_slot, view_count, views);
}
static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets_profiled(d3d12_command_list_iface *iface,
UINT render_target_descriptor_count, const D3D12_CPU_DESCRIPTOR_HANDLE *render_target_descriptors,
BOOL single_descriptor_handle, const D3D12_CPU_DESCRIPTOR_HANDLE *depth_stencil_descriptor)
{
COMMAND_LIST_PROFILED_CALL(OMSetRenderTargets, iface, render_target_descriptor_count, render_target_descriptors,
single_descriptor_handle, depth_stencil_descriptor);
}
static void STDMETHODCALLTYPE d3d12_command_list_ClearDepthStencilView_profiled(d3d12_command_list_iface *iface,
D3D12_CPU_DESCRIPTOR_HANDLE dsv, D3D12_CLEAR_FLAGS flags, float depth, UINT8 stencil,
UINT rect_count, const D3D12_RECT *rects)
{
COMMAND_LIST_PROFILED_CALL(ClearDepthStencilView, iface, dsv, flags, depth, stencil, rect_count, rects);
}
static void STDMETHODCALLTYPE d3d12_command_list_ClearRenderTargetView_profiled(d3d12_command_list_iface *iface,
D3D12_CPU_DESCRIPTOR_HANDLE rtv, const FLOAT color[4], UINT rect_count, const D3D12_RECT *rects)
{
COMMAND_LIST_PROFILED_CALL(ClearRenderTargetView, iface, rtv, color, rect_count, rects);
}
static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint_profiled(d3d12_command_list_iface *iface,
D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource,
const UINT values[4], UINT rect_count, const D3D12_RECT *rects)
{
COMMAND_LIST_PROFILED_CALL(ClearUnorderedAccessViewUint, iface, gpu_handle, cpu_handle, resource, values, rect_count, rects);
}
static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewFloat_profiled(d3d12_command_list_iface *iface,
D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource,
const float values[4], UINT rect_count, const D3D12_RECT *rects)
{
COMMAND_LIST_PROFILED_CALL(ClearUnorderedAccessViewFloat, iface, gpu_handle, cpu_handle, resource, values, rect_count, rects);
}
static void STDMETHODCALLTYPE d3d12_command_list_DiscardResource_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *resource, const D3D12_DISCARD_REGION *region)
{
COMMAND_LIST_PROFILED_CALL(DiscardResource, iface, resource, region);
}
static void STDMETHODCALLTYPE d3d12_command_list_BeginQuery_profiled(d3d12_command_list_iface *iface,
ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index)
{
COMMAND_LIST_PROFILED_CALL(BeginQuery, iface, heap, type, index);
}
static void STDMETHODCALLTYPE d3d12_command_list_EndQuery_profiled(d3d12_command_list_iface *iface,
ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index)
{
COMMAND_LIST_PROFILED_CALL(EndQuery, iface, heap, type, index);
}
static void STDMETHODCALLTYPE d3d12_command_list_ResolveQueryData_profiled(d3d12_command_list_iface *iface,
ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT start_index, UINT query_count,
ID3D12Resource *dst_buffer, UINT64 aligned_dst_buffer_offset)
{
COMMAND_LIST_PROFILED_CALL(ResolveQueryData, iface, heap, type, start_index, query_count, dst_buffer, aligned_dst_buffer_offset);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetPredication_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *buffer, UINT64 aligned_buffer_offset, D3D12_PREDICATION_OP operation)
{
COMMAND_LIST_PROFILED_CALL(SetPredication, iface, buffer, aligned_buffer_offset, operation);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetMarker_profiled(d3d12_command_list_iface *iface,
UINT metadata, const void *data, UINT size)
{
COMMAND_LIST_PROFILED_CALL(SetMarker, iface, metadata, data, size);
}
static void STDMETHODCALLTYPE d3d12_command_list_BeginEvent_profiled(d3d12_command_list_iface *iface,
UINT metadata, const void *data, UINT size)
{
COMMAND_LIST_PROFILED_CALL(BeginEvent, iface, metadata, data, size);
}
static void STDMETHODCALLTYPE d3d12_command_list_EndEvent_profiled(d3d12_command_list_iface *iface)
{
COMMAND_LIST_PROFILED_CALL(EndEvent, iface);
}
static void STDMETHODCALLTYPE d3d12_command_list_ExecuteIndirect_profiled(d3d12_command_list_iface *iface,
ID3D12CommandSignature *command_signature, UINT max_command_count, ID3D12Resource *arg_buffer,
UINT64 arg_buffer_offset, ID3D12Resource *count_buffer, UINT64 count_buffer_offset)
{
COMMAND_LIST_PROFILED_CALL(ExecuteIndirect, iface, command_signature, max_command_count, arg_buffer, arg_buffer_offset, count_buffer, count_buffer_offset);
}
static void STDMETHODCALLTYPE d3d12_command_list_AtomicCopyBufferUINT_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *dst_buffer, UINT64 dst_offset,
ID3D12Resource *src_buffer, UINT64 src_offset,
UINT dependent_resource_count, ID3D12Resource * const *dependent_resources,
const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges)
{
COMMAND_LIST_PROFILED_CALL(AtomicCopyBufferUINT, iface, dst_buffer, dst_offset, src_buffer, src_offset,
dependent_resource_count, dependent_resources, dependent_sub_resource_ranges);
}
static void STDMETHODCALLTYPE d3d12_command_list_AtomicCopyBufferUINT64_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *dst_buffer, UINT64 dst_offset,
ID3D12Resource *src_buffer, UINT64 src_offset,
UINT dependent_resource_count, ID3D12Resource * const *dependent_resources,
const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges)
{
COMMAND_LIST_PROFILED_CALL(AtomicCopyBufferUINT64, iface, dst_buffer, dst_offset,
src_buffer, src_offset,
dependent_resource_count, dependent_resources,
dependent_sub_resource_ranges);
}
static void STDMETHODCALLTYPE d3d12_command_list_OMSetDepthBounds_profiled(d3d12_command_list_iface *iface,
FLOAT min, FLOAT max)
{
COMMAND_LIST_PROFILED_CALL(OMSetDepthBounds, iface, min, max);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetSamplePositions_profiled(d3d12_command_list_iface *iface,
UINT sample_count, UINT pixel_count, D3D12_SAMPLE_POSITION *sample_positions)
{
COMMAND_LIST_PROFILED_CALL(SetSamplePositions, iface, sample_count, pixel_count, sample_positions);
}
static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresourceRegion_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *dst_resource, UINT dst_sub_resource_idx, UINT dst_x, UINT dst_y,
ID3D12Resource *src_resource, UINT src_sub_resource_idx,
D3D12_RECT *src_rect, DXGI_FORMAT format, D3D12_RESOLVE_MODE mode)
{
COMMAND_LIST_PROFILED_CALL(ResolveSubresourceRegion, iface, dst_resource, dst_sub_resource_idx,
dst_x, dst_y, src_resource, src_sub_resource_idx,
src_rect, format, mode);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetViewInstanceMask_profiled(d3d12_command_list_iface *iface, UINT mask)
{
COMMAND_LIST_PROFILED_CALL(SetViewInstanceMask, iface, mask);
}
static void STDMETHODCALLTYPE d3d12_command_list_WriteBufferImmediate_profiled(d3d12_command_list_iface *iface,
UINT count, const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *parameters,
const D3D12_WRITEBUFFERIMMEDIATE_MODE *modes)
{
COMMAND_LIST_PROFILED_CALL(WriteBufferImmediate, iface, count, parameters, modes);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetProtectedResourceSession_profiled(d3d12_command_list_iface *iface,
ID3D12ProtectedResourceSession *protected_session)
{
COMMAND_LIST_PROFILED_CALL(SetProtectedResourceSession, iface, protected_session);
}
static void STDMETHODCALLTYPE d3d12_command_list_BeginRenderPass_profiled(d3d12_command_list_iface *iface,
UINT rt_count, const D3D12_RENDER_PASS_RENDER_TARGET_DESC *render_targets,
const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *depth_stencil, D3D12_RENDER_PASS_FLAGS flags)
{
COMMAND_LIST_PROFILED_CALL(BeginRenderPass, iface, rt_count, render_targets, depth_stencil, flags);
}
static void STDMETHODCALLTYPE d3d12_command_list_EndRenderPass_profiled(d3d12_command_list_iface *iface)
{
COMMAND_LIST_PROFILED_CALL(EndRenderPass, iface);
}
static void STDMETHODCALLTYPE d3d12_command_list_InitializeMetaCommand_profiled(d3d12_command_list_iface *iface,
ID3D12MetaCommand *meta_command, const void *parameter_data, SIZE_T parameter_size)
{
COMMAND_LIST_PROFILED_CALL(InitializeMetaCommand, iface, meta_command, parameter_data, parameter_size);
}
static void STDMETHODCALLTYPE d3d12_command_list_ExecuteMetaCommand_profiled(d3d12_command_list_iface *iface,
ID3D12MetaCommand *meta_command, const void *parameter_data, SIZE_T parameter_size)
{
COMMAND_LIST_PROFILED_CALL(ExecuteMetaCommand, iface, meta_command, parameter_data, parameter_size);
}
static void STDMETHODCALLTYPE d3d12_command_list_BuildRaytracingAccelerationStructure_profiled(d3d12_command_list_iface *iface,
const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *desc, UINT num_postbuild_info_descs,
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *postbuild_info_descs)
{
COMMAND_LIST_PROFILED_CALL(BuildRaytracingAccelerationStructure, iface, desc, num_postbuild_info_descs,
postbuild_info_descs);
}
static void STDMETHODCALLTYPE d3d12_command_list_EmitRaytracingAccelerationStructurePostbuildInfo_profiled(d3d12_command_list_iface *iface,
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *desc, UINT num_acceleration_structures,
const D3D12_GPU_VIRTUAL_ADDRESS *src_data)
{
COMMAND_LIST_PROFILED_CALL(EmitRaytracingAccelerationStructurePostbuildInfo, iface, desc, num_acceleration_structures, src_data);
}
static void STDMETHODCALLTYPE d3d12_command_list_CopyRaytracingAccelerationStructure_profiled(d3d12_command_list_iface *iface,
D3D12_GPU_VIRTUAL_ADDRESS dst_data, D3D12_GPU_VIRTUAL_ADDRESS src_data,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE mode)
{
COMMAND_LIST_PROFILED_CALL(CopyRaytracingAccelerationStructure, iface, dst_data, src_data, mode);
}
static void STDMETHODCALLTYPE d3d12_command_list_SetPipelineState1_profiled(d3d12_command_list_iface *iface,
ID3D12StateObject *state_object)
{
COMMAND_LIST_PROFILED_CALL(SetPipelineState1, iface, state_object);
}
static void STDMETHODCALLTYPE d3d12_command_list_DispatchRays_profiled(d3d12_command_list_iface *iface,
const D3D12_DISPATCH_RAYS_DESC *desc)
{
COMMAND_LIST_PROFILED_CALL(DispatchRays, iface, desc);
}
static void STDMETHODCALLTYPE d3d12_command_list_RSSetShadingRate_profiled(d3d12_command_list_iface *iface,
D3D12_SHADING_RATE base, const D3D12_SHADING_RATE_COMBINER *combiners)
{
COMMAND_LIST_PROFILED_CALL(RSSetShadingRate, iface, base, combiners);
}
static void STDMETHODCALLTYPE d3d12_command_list_RSSetShadingRateImage_profiled(d3d12_command_list_iface *iface,
ID3D12Resource *image)
{
COMMAND_LIST_PROFILED_CALL(RSSetShadingRateImage, iface, image);
}
static void STDMETHODCALLTYPE d3d12_command_list_DispatchMesh_profiled(d3d12_command_list_iface *iface, UINT x, UINT y, UINT z)
{
COMMAND_LIST_PROFILED_CALL(DispatchMesh, iface, x, y, z);
}
static CONST_VTBL struct ID3D12GraphicsCommandList6Vtbl d3d12_command_list_vtbl_profiled =
{
/* IUnknown methods */
d3d12_command_list_QueryInterface,
d3d12_command_list_AddRef,
d3d12_command_list_Release,
/* ID3D12Object methods */
d3d12_command_list_GetPrivateData,
d3d12_command_list_SetPrivateData,
d3d12_command_list_SetPrivateDataInterface,
(void *)d3d12_object_SetName,
/* ID3D12DeviceChild methods */
d3d12_command_list_GetDevice,
/* ID3D12CommandList methods */
d3d12_command_list_GetType,
/* ID3D12GraphicsCommandList methods */
d3d12_command_list_Close,
d3d12_command_list_Reset,
d3d12_command_list_ClearState,
d3d12_command_list_DrawInstanced_profiled,
d3d12_command_list_DrawIndexedInstanced_profiled,
d3d12_command_list_Dispatch_profiled,
d3d12_command_list_CopyBufferRegion_profiled,
d3d12_command_list_CopyTextureRegion_profiled,
d3d12_command_list_CopyResource_profiled,
d3d12_command_list_CopyTiles_profiled,
d3d12_command_list_ResolveSubresource_profiled,
d3d12_command_list_IASetPrimitiveTopology_profiled,
d3d12_command_list_RSSetViewports_profiled,
d3d12_command_list_RSSetScissorRects_profiled,
d3d12_command_list_OMSetBlendFactor_profiled,
d3d12_command_list_OMSetStencilRef_profiled,
d3d12_command_list_SetPipelineState_profiled,
d3d12_command_list_ResourceBarrier_profiled,
d3d12_command_list_ExecuteBundle_profiled,
d3d12_command_list_SetDescriptorHeaps_profiled,
d3d12_command_list_SetComputeRootSignature_profiled,
d3d12_command_list_SetGraphicsRootSignature_profiled,
d3d12_command_list_SetComputeRootDescriptorTable_profiled,
d3d12_command_list_SetGraphicsRootDescriptorTable_profiled,
d3d12_command_list_SetComputeRoot32BitConstant_profiled,
d3d12_command_list_SetGraphicsRoot32BitConstant_profiled,
d3d12_command_list_SetComputeRoot32BitConstants_profiled,
d3d12_command_list_SetGraphicsRoot32BitConstants_profiled,
d3d12_command_list_SetComputeRootConstantBufferView_profiled,
d3d12_command_list_SetGraphicsRootConstantBufferView_profiled,
d3d12_command_list_SetComputeRootShaderResourceView_profiled,
d3d12_command_list_SetGraphicsRootShaderResourceView_profiled,
d3d12_command_list_SetComputeRootUnorderedAccessView_profiled,
d3d12_command_list_SetGraphicsRootUnorderedAccessView_profiled,
d3d12_command_list_IASetIndexBuffer_profiled,
d3d12_command_list_IASetVertexBuffers_profiled,
d3d12_command_list_SOSetTargets_profiled,
d3d12_command_list_OMSetRenderTargets_profiled,
d3d12_command_list_ClearDepthStencilView_profiled,
d3d12_command_list_ClearRenderTargetView_profiled,
d3d12_command_list_ClearUnorderedAccessViewUint_profiled,
d3d12_command_list_ClearUnorderedAccessViewFloat_profiled,
d3d12_command_list_DiscardResource_profiled,
d3d12_command_list_BeginQuery_profiled,
d3d12_command_list_EndQuery_profiled,
d3d12_command_list_ResolveQueryData_profiled,
d3d12_command_list_SetPredication_profiled,
d3d12_command_list_SetMarker_profiled,
d3d12_command_list_BeginEvent_profiled,
d3d12_command_list_EndEvent_profiled,
d3d12_command_list_ExecuteIndirect_profiled,
/* ID3D12GraphicsCommandList1 methods */
d3d12_command_list_AtomicCopyBufferUINT_profiled,
d3d12_command_list_AtomicCopyBufferUINT64_profiled,
d3d12_command_list_OMSetDepthBounds_profiled,
d3d12_command_list_SetSamplePositions_profiled,
d3d12_command_list_ResolveSubresourceRegion_profiled,
d3d12_command_list_SetViewInstanceMask_profiled,
/* ID3D12GraphicsCommandList2 methods */
d3d12_command_list_WriteBufferImmediate_profiled,
/* ID3D12GraphicsCommandList3 methods */
d3d12_command_list_SetProtectedResourceSession_profiled,
/* ID3D12GraphicsCommandList4 methods */
d3d12_command_list_BeginRenderPass_profiled,
d3d12_command_list_EndRenderPass_profiled,
d3d12_command_list_InitializeMetaCommand_profiled,
d3d12_command_list_ExecuteMetaCommand_profiled,
d3d12_command_list_BuildRaytracingAccelerationStructure_profiled,
d3d12_command_list_EmitRaytracingAccelerationStructurePostbuildInfo_profiled,
d3d12_command_list_CopyRaytracingAccelerationStructure_profiled,
d3d12_command_list_SetPipelineState1_profiled,
d3d12_command_list_DispatchRays_profiled,
/* ID3D12GraphicsCommandList5 methods */
d3d12_command_list_RSSetShadingRate_profiled,
d3d12_command_list_RSSetShadingRateImage_profiled,
/* ID3D12GraphicsCommandList6 methods */
d3d12_command_list_DispatchMesh_profiled,
};
#endif

View File

@ -0,0 +1,116 @@
/*
* * Copyright 2021 NVIDIA Corporation
*
* 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
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_private.h"
static inline struct d3d12_command_list *d3d12_command_list_from_ID3D12GraphicsCommandListExt(ID3D12GraphicsCommandListExt *iface)
{
return CONTAINING_RECORD(iface, struct d3d12_command_list, ID3D12GraphicsCommandListExt_iface);
}
extern ULONG STDMETHODCALLTYPE d3d12_command_list_AddRef(d3d12_command_list_iface *iface);
ULONG STDMETHODCALLTYPE d3d12_command_list_vkd3d_ext_AddRef(ID3D12GraphicsCommandListExt *iface)
{
struct d3d12_command_list *command_list = d3d12_command_list_from_ID3D12GraphicsCommandListExt(iface);
return d3d12_command_list_AddRef(&command_list->ID3D12GraphicsCommandList_iface);
}
extern ULONG STDMETHODCALLTYPE d3d12_command_list_Release(d3d12_command_list_iface *iface);
static ULONG STDMETHODCALLTYPE d3d12_command_list_vkd3d_ext_Release(ID3D12GraphicsCommandListExt *iface)
{
struct d3d12_command_list *command_list = d3d12_command_list_from_ID3D12GraphicsCommandListExt(iface);
return d3d12_command_list_Release(&command_list->ID3D12GraphicsCommandList_iface);
}
extern HRESULT STDMETHODCALLTYPE d3d12_command_list_QueryInterface(d3d12_command_list_iface *iface,
REFIID iid, void **object);
static HRESULT STDMETHODCALLTYPE d3d12_command_list_vkd3d_ext_QueryInterface(ID3D12GraphicsCommandListExt *iface,
REFIID iid, void **out)
{
struct d3d12_command_list *command_list = d3d12_command_list_from_ID3D12GraphicsCommandListExt(iface);
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
return d3d12_command_list_QueryInterface(&command_list->ID3D12GraphicsCommandList_iface, iid, out);
}
static HRESULT STDMETHODCALLTYPE d3d12_command_list_vkd3d_ext_GetVulkanHandle(ID3D12GraphicsCommandListExt *iface,
VkCommandBuffer *pVkCommandBuffer)
{
struct d3d12_command_list *command_list = d3d12_command_list_from_ID3D12GraphicsCommandListExt(iface);
TRACE("iface %p, pVkCommandBuffer %p.\n", iface, pVkCommandBuffer);
if (!pVkCommandBuffer)
return E_INVALIDARG;
*pVkCommandBuffer = command_list->vk_command_buffer;
return S_OK;
}
#define CU_LAUNCH_PARAM_BUFFER_POINTER (const void*)0x01
#define CU_LAUNCH_PARAM_BUFFER_SIZE (const void*)0x02
#define CU_LAUNCH_PARAM_END (const void*)0x00
static HRESULT STDMETHODCALLTYPE d3d12_command_list_vkd3d_ext_LaunchCubinShader(ID3D12GraphicsCommandListExt *iface, D3D12_CUBIN_DATA_HANDLE *handle, UINT32 block_x, UINT32 block_y, UINT32 block_z, const void *params, UINT32 param_size)
{
VkCuLaunchInfoNVX launchInfo = { VK_STRUCTURE_TYPE_CU_LAUNCH_INFO_NVX };
const struct vkd3d_vk_device_procs *vk_procs;
const void *config[] = {
CU_LAUNCH_PARAM_BUFFER_POINTER, params,
CU_LAUNCH_PARAM_BUFFER_SIZE, &param_size,
CU_LAUNCH_PARAM_END
};
struct d3d12_command_list *command_list = d3d12_command_list_from_ID3D12GraphicsCommandListExt(iface);
TRACE("iface %p, handle %p, block_x %u, block_y %u, block_z %u, params %p, param_size %u \n", iface, handle, block_x, block_y, block_z, params, param_size);
if (!handle || !block_x || !block_y || !block_z || !params || !param_size)
return E_INVALIDARG;
launchInfo.function = handle->vkCuFunction;
launchInfo.gridDimX = block_x;
launchInfo.gridDimY = block_y;
launchInfo.gridDimZ = block_z;
launchInfo.blockDimX = handle->blockX;
launchInfo.blockDimY = handle->blockY;
launchInfo.blockDimZ = handle->blockZ;
launchInfo.sharedMemBytes = 0;
launchInfo.paramCount = 0;
launchInfo.pParams = NULL;
launchInfo.extraCount = 1;
launchInfo.pExtras = config;
vk_procs = &command_list->device->vk_procs;
VK_CALL(vkCmdCuLaunchKernelNVX(command_list->vk_command_buffer, &launchInfo));
return S_OK;
}
CONST_VTBL struct ID3D12GraphicsCommandListExtVtbl d3d12_command_list_vkd3d_ext_vtbl =
{
/* IUnknown methods */
d3d12_command_list_vkd3d_ext_QueryInterface,
d3d12_command_list_vkd3d_ext_AddRef,
d3d12_command_list_vkd3d_ext_Release,
/* ID3D12GraphicsCommandListExt methods */
d3d12_command_list_vkd3d_ext_GetVulkanHandle,
d3d12_command_list_vkd3d_ext_LaunchCubinShader
};

531
libs/vkd3d/debug_ring.c Normal file
View File

@ -0,0 +1,531 @@
/*
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_private.h"
#include "vkd3d_debug.h"
#include "vkd3d_common.h"
#include "vkd3d_platform.h"
#include <stdio.h>
void vkd3d_shader_debug_ring_init_spec_constant(struct d3d12_device *device,
struct vkd3d_shader_debug_ring_spec_info *info, vkd3d_shader_hash_t hash)
{
info->spec_info.pData = &info->constants;
info->spec_info.dataSize = sizeof(info->constants);
info->spec_info.pMapEntries = info->map_entries;
info->spec_info.mapEntryCount = 4;
info->constants.hash = hash;
info->constants.host_bda = device->debug_ring.ring_device_address;
info->constants.atomic_bda = device->debug_ring.atomic_device_address;
info->constants.ring_words = device->debug_ring.ring_size / sizeof(uint32_t);
info->map_entries[0].constantID = 0;
info->map_entries[0].offset = offsetof(struct vkd3d_shader_debug_ring_spec_constants, hash);
info->map_entries[0].size = sizeof(uint64_t);
info->map_entries[1].constantID = 1;
info->map_entries[1].offset = offsetof(struct vkd3d_shader_debug_ring_spec_constants, atomic_bda);
info->map_entries[1].size = sizeof(uint64_t);
info->map_entries[2].constantID = 2;
info->map_entries[2].offset = offsetof(struct vkd3d_shader_debug_ring_spec_constants, host_bda);
info->map_entries[2].size = sizeof(uint64_t);
info->map_entries[3].constantID = 3;
info->map_entries[3].offset = offsetof(struct vkd3d_shader_debug_ring_spec_constants, ring_words);
info->map_entries[3].size = sizeof(uint32_t);
}
#define READ_RING_WORD(off) ring->mapped_ring[(off) & ((ring->ring_size / sizeof(uint32_t)) - 1)]
#define READ_RING_WORD_ACQUIRE(off) \
vkd3d_atomic_uint32_load_explicit(&ring->mapped_ring[(off) & ((ring->ring_size / sizeof(uint32_t)) - 1)], \
vkd3d_memory_order_acquire)
#define DEBUG_CHANNEL_WORD_COOKIE 0xdeadca70u
#define DEBUG_CHANNEL_WORD_MASK 0xfffffff0u
static const char *vkd3d_patch_command_token_str(enum vkd3d_patch_command_token token)
{
switch (token)
{
case VKD3D_PATCH_COMMAND_TOKEN_COPY_CONST_U32: return "RootConst";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_IBO_VA_LO: return "IBO VA LO";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_IBO_VA_HI: return "IBO VA HI";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_IBO_SIZE: return "IBO Size";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_INDEX_FORMAT: return "IBO Type";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_VBO_VA_LO: return "VBO VA LO";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_VBO_VA_HI: return "VBO VA HI";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_VBO_SIZE: return "VBO Size";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_VBO_STRIDE: return "VBO Stride";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_ROOT_VA_LO: return "ROOT VA LO";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_ROOT_VA_HI: return "ROOT VA HI";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_VERTEX_COUNT: return "Vertex Count";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_INDEX_COUNT: return "Index Count";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_INSTANCE_COUNT: return "Instance Count";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_FIRST_INDEX: return "First Index";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_FIRST_VERTEX: return "First Vertex";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_FIRST_INSTANCE: return "First Instance";
case VKD3D_PATCH_COMMAND_TOKEN_COPY_VERTEX_OFFSET: return "Vertex Offset";
default: return "???";
}
}
static bool vkd3d_patch_command_token_is_hex(enum vkd3d_patch_command_token token)
{
switch (token)
{
case VKD3D_PATCH_COMMAND_TOKEN_COPY_IBO_VA_LO:
case VKD3D_PATCH_COMMAND_TOKEN_COPY_IBO_VA_HI:
case VKD3D_PATCH_COMMAND_TOKEN_COPY_VBO_VA_LO:
case VKD3D_PATCH_COMMAND_TOKEN_COPY_VBO_VA_HI:
case VKD3D_PATCH_COMMAND_TOKEN_COPY_ROOT_VA_LO:
case VKD3D_PATCH_COMMAND_TOKEN_COPY_ROOT_VA_HI:
return true;
default:
return false;
}
}
static bool vkd3d_shader_debug_ring_print_message(struct vkd3d_shader_debug_ring *ring,
uint32_t word_offset, uint32_t message_word_count)
{
uint32_t i, debug_instance, debug_thread_id[3], fmt;
char message_buffer[4096];
uint64_t shader_hash;
size_t len, avail;
if (message_word_count < 8)
{
ERR("Message word count %u is invalid.\n", message_word_count);
return false;
}
shader_hash = (uint64_t)READ_RING_WORD(word_offset + 1) | ((uint64_t)READ_RING_WORD(word_offset + 2) << 32);
debug_instance = READ_RING_WORD(word_offset + 3);
for (i = 0; i < 3; i++)
debug_thread_id[i] = READ_RING_WORD(word_offset + 4 + i);
fmt = READ_RING_WORD(word_offset + 7);
word_offset += 8;
message_word_count -= 8;
if (shader_hash == 0)
{
/* We got this from our internal debug shaders. Pretty-print.
* Make sure the log is sortable for easier debug.
* TODO: Might consider a callback system that listeners from different subsystems can listen to and print their own messages,
* but that is overengineering at this time ... */
snprintf(message_buffer, sizeof(message_buffer), "ExecuteIndirect: GlobalCommandIndex %010u, Debug tag %010u, DrawID %04u (ThreadID %04u): ",
debug_instance, debug_thread_id[0], debug_thread_id[1], debug_thread_id[2]);
if (message_word_count == 2)
{
len = strlen(message_buffer);
avail = sizeof(message_buffer) - len;
snprintf(message_buffer + len, avail, "DrawCount %u, MaxDrawCount %u",
READ_RING_WORD(word_offset + 0),
READ_RING_WORD(word_offset + 1));
}
else if (message_word_count == 4)
{
union { uint32_t u32; float f32; int32_t s32; } value;
enum vkd3d_patch_command_token token;
uint32_t dst_offset;
uint32_t src_offset;
len = strlen(message_buffer);
avail = sizeof(message_buffer) - len;
token = READ_RING_WORD(word_offset + 0);
dst_offset = READ_RING_WORD(word_offset + 1);
src_offset = READ_RING_WORD(word_offset + 2);
value.u32 = READ_RING_WORD(word_offset + 3);
if (vkd3d_patch_command_token_is_hex(token))
{
snprintf(message_buffer + len, avail, "%s <- #%08x",
vkd3d_patch_command_token_str(token), value.u32);
}
else if (token == VKD3D_PATCH_COMMAND_TOKEN_COPY_CONST_U32)
{
snprintf(message_buffer + len, avail, "%s <- {hex #%08x, s32 %d, f32 %f}",
vkd3d_patch_command_token_str(token), value.u32, value.s32, value.f32);
}
else
{
snprintf(message_buffer + len, avail, "%s <- %d",
vkd3d_patch_command_token_str(token), value.s32);
}
len = strlen(message_buffer);
avail = sizeof(message_buffer) - len;
snprintf(message_buffer + len, avail, " (dst offset %u, src offset %u)", dst_offset, src_offset);
}
}
else
{
snprintf(message_buffer, sizeof(message_buffer), "Shader: %"PRIx64": Instance %010u, ID (%u, %u, %u):",
shader_hash, debug_instance,
debug_thread_id[0], debug_thread_id[1], debug_thread_id[2]);
for (i = 0; i < message_word_count; i++)
{
union
{
float f32;
uint32_t u32;
int32_t i32;
} u;
const char *delim;
u.u32 = READ_RING_WORD(word_offset + i);
len = strlen(message_buffer);
if (len + 1 >= sizeof(message_buffer))
break;
avail = sizeof(message_buffer) - len;
delim = i == 0 ? " " : ", ";
#define VKD3D_DEBUG_CHANNEL_FMT_HEX 0u
#define VKD3D_DEBUG_CHANNEL_FMT_I32 1u
#define VKD3D_DEBUG_CHANNEL_FMT_F32 2u
switch ((fmt >> (2u * i)) & 3u)
{
case VKD3D_DEBUG_CHANNEL_FMT_HEX:
snprintf(message_buffer + len, avail, "%s#%x", delim, u.u32);
break;
case VKD3D_DEBUG_CHANNEL_FMT_I32:
snprintf(message_buffer + len, avail, "%s%d", delim, u.i32);
break;
case VKD3D_DEBUG_CHANNEL_FMT_F32:
snprintf(message_buffer + len, avail, "%s%f", delim, u.f32);
break;
default:
snprintf(message_buffer + len, avail, "%s????", delim);
break;
}
}
}
INFO("%s\n", message_buffer);
return true;
}
void *vkd3d_shader_debug_ring_thread_main(void *arg)
{
uint32_t last_counter, new_counter, count, i, cookie_word_count;
volatile const uint32_t *ring_counter; /* Atomic updated by the GPU. */
struct vkd3d_shader_debug_ring *ring;
struct d3d12_device *device = arg;
bool is_active = true;
uint32_t *ring_base;
uint32_t word_count;
size_t ring_mask;
ring = &device->debug_ring;
ring_mask = (ring->ring_size / sizeof(uint32_t)) - 1;
ring_counter = ring->mapped_control_block;
ring_base = ring->mapped_ring;
last_counter = 0;
vkd3d_set_thread_name("debug-ring");
while (is_active)
{
pthread_mutex_lock(&ring->ring_lock);
if (ring->active)
pthread_cond_wait(&ring->ring_cond, &ring->ring_lock);
is_active = ring->active;
pthread_mutex_unlock(&ring->ring_lock);
new_counter = *ring_counter;
if (last_counter != new_counter)
{
count = (new_counter - last_counter) & ring_mask;
/* Assume that each iteration can safely use 1/4th of the buffer to avoid WAR hazards. */
if (count > (ring->ring_size / 16))
{
ERR("Debug ring is probably too small (%u new words this iteration), increase size to avoid risk of dropping messages.\n",
count);
}
for (i = 0; i < count; )
{
/* The debug ring shader has "release" semantics for the word count write,
* so just make sure the reads don't get reordered here. */
cookie_word_count = READ_RING_WORD_ACQUIRE(last_counter + i);
word_count = cookie_word_count & ~DEBUG_CHANNEL_WORD_MASK;
if (cookie_word_count == 0)
{
ERR("Message was allocated, but write did not complete. last_counter = %u, rewrite new_counter = %u -> %u\n",
last_counter, new_counter, last_counter + i);
/* Rewind the counter, and try again later. */
new_counter = last_counter + i;
break;
}
/* If something is written here, it must be a cookie. */
if ((cookie_word_count & DEBUG_CHANNEL_WORD_MASK) != DEBUG_CHANNEL_WORD_COOKIE)
{
ERR("Invalid message work cookie detected, 0x%x.\n", cookie_word_count);
break;
}
if (i + word_count > count)
{
ERR("Message word count %u is out of bounds (i = %u, count = %u).\n",
word_count, i, count);
break;
}
if (!vkd3d_shader_debug_ring_print_message(ring, last_counter + i, word_count))
break;
i += word_count;
}
}
/* Make sure to clear out any messages we read so that when the ring gets around to
* this point again, we can detect unwritten memory.
* This relies on having a ring that is large enough, but in practice, if we just make the ring
* large enough, there is nothing to worry about. */
while (last_counter != new_counter)
{
ring_base[last_counter & ring_mask] = 0;
last_counter++;
}
}
if (ring->device_lost)
{
INFO("Device lost detected, attempting to fish for clues.\n");
new_counter = *ring_counter;
if (last_counter != new_counter)
{
count = (new_counter - last_counter) & ring_mask;
for (i = 0; i < count; )
{
cookie_word_count = READ_RING_WORD_ACQUIRE(last_counter + i);
word_count = cookie_word_count & ~DEBUG_CHANNEL_WORD_MASK;
/* This is considered a message if it has the marker and a word count that is in-range. */
if ((cookie_word_count & DEBUG_CHANNEL_WORD_MASK) == DEBUG_CHANNEL_WORD_COOKIE &&
i + word_count <= count &&
vkd3d_shader_debug_ring_print_message(ring, last_counter + i, word_count))
{
i += word_count;
}
else
{
/* Keep going. */
i++;
}
}
}
INFO("Done fishing for clues ...\n");
}
return NULL;
}
HRESULT vkd3d_shader_debug_ring_init(struct vkd3d_shader_debug_ring *ring,
struct d3d12_device *device)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
D3D12_HEAP_PROPERTIES heap_properties;
D3D12_RESOURCE_DESC1 resource_desc;
VkMemoryPropertyFlags memory_props;
char env[VKD3D_PATH_MAX];
memset(ring, 0, sizeof(*ring));
if (!vkd3d_get_env_var("VKD3D_SHADER_DEBUG_RING_SIZE_LOG2", env, sizeof(env)))
return S_OK;
ring->active = true;
ring->ring_size = (size_t)1 << strtoul(env, NULL, 0);
ring->control_block_size = 4096;
INFO("Enabling shader debug ring of size: %zu.\n", ring->ring_size);
if (!device->device_info.buffer_device_address_features.bufferDeviceAddress)
{
ERR("Buffer device address must be supported to use VKD3D_SHADER_DEBUG_RING feature.\n");
return E_INVALIDARG;
}
memset(&heap_properties, 0, sizeof(heap_properties));
heap_properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK;
heap_properties.Type = D3D12_HEAP_TYPE_CUSTOM;
heap_properties.MemoryPoolPreference = D3D12_MEMORY_POOL_L0;
memset(&resource_desc, 0, sizeof(resource_desc));
resource_desc.Width = ring->ring_size;
resource_desc.Height = 1;
resource_desc.DepthOrArraySize = 1;
resource_desc.MipLevels = 1;
resource_desc.Format = DXGI_FORMAT_UNKNOWN;
resource_desc.SampleDesc.Count = 1;
resource_desc.SampleDesc.Quality = 0;
resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
resource_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
if (FAILED(vkd3d_create_buffer(device, &heap_properties, D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS,
&resource_desc, &ring->host_buffer)))
goto err_free_buffers;
memory_props = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_CACHED_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
/* If we're doing breadcrumb debugging, we also need to be able to read debug ring messages
* from a crash, so we cannot rely on being able to copy the device payload back to host.
* Use PCI-e BAR + UNCACHED + DEVICE_COHERENT if we must. */
if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_BREADCRUMBS)
{
INFO("Using debug ring with breadcrumbs, opting in to device uncached payload buffer.\n");
/* We use coherent in the debug_channel.h header, but not necessarily guaranteed to be coherent with
* host reads, so make extra sure. */
if (device->device_info.device_coherent_memory_features_amd.deviceCoherentMemory)
{
memory_props |= VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD | VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD;
INFO("Enabling uncached device memory for debug ring.\n");
}
}
if (FAILED(vkd3d_allocate_buffer_memory(device, ring->host_buffer,
memory_props, &ring->host_buffer_memory)))
goto err_free_buffers;
resource_desc.Width = ring->control_block_size;
memset(&heap_properties, 0, sizeof(heap_properties));
heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT;
if (FAILED(vkd3d_create_buffer(device, &heap_properties, D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS,
&resource_desc, &ring->device_atomic_buffer)))
goto err_free_buffers;
memory_props = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_BREADCRUMBS)
{
/* Expect crashes since we won't have time to flush caches.
* We use coherent in the debug_channel.h header, but not necessarily guaranteed to be coherent with
* host reads, so make extra sure. */
if (device->device_info.device_coherent_memory_features_amd.deviceCoherentMemory)
memory_props |= VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD | VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD;
}
if (FAILED(vkd3d_allocate_buffer_memory(device, ring->device_atomic_buffer,
memory_props, &ring->device_atomic_buffer_memory)))
goto err_free_buffers;
if (VK_CALL(vkMapMemory(device->vk_device, ring->host_buffer_memory.vk_memory,
0, VK_WHOLE_SIZE, 0, (void**)&ring->mapped_ring)) != VK_SUCCESS)
goto err_free_buffers;
if (VK_CALL(vkMapMemory(device->vk_device, ring->device_atomic_buffer_memory.vk_memory,
0, VK_WHOLE_SIZE, 0, (void**)&ring->mapped_control_block)) != VK_SUCCESS)
goto err_free_buffers;
ring->ring_device_address = vkd3d_get_buffer_device_address(device, ring->host_buffer);
ring->atomic_device_address = vkd3d_get_buffer_device_address(device, ring->device_atomic_buffer);
memset(ring->mapped_control_block, 0, ring->control_block_size);
memset(ring->mapped_ring, 0, ring->ring_size);
if (pthread_mutex_init(&ring->ring_lock, NULL) != 0)
goto err_free_buffers;
if (pthread_cond_init(&ring->ring_cond, NULL) != 0)
goto err_destroy_mutex;
if (pthread_create(&ring->ring_thread, NULL, vkd3d_shader_debug_ring_thread_main, device) != 0)
{
ERR("Failed to create ring thread.\n");
goto err_destroy_cond;
}
return S_OK;
err_destroy_mutex:
pthread_mutex_destroy(&ring->ring_lock);
err_destroy_cond:
pthread_cond_destroy(&ring->ring_cond);
err_free_buffers:
VK_CALL(vkDestroyBuffer(device->vk_device, ring->host_buffer, NULL));
VK_CALL(vkDestroyBuffer(device->vk_device, ring->device_atomic_buffer, NULL));
vkd3d_free_device_memory(device, &ring->host_buffer_memory);
vkd3d_free_device_memory(device, &ring->device_atomic_buffer_memory);
memset(ring, 0, sizeof(*ring));
return E_OUTOFMEMORY;
}
void vkd3d_shader_debug_ring_cleanup(struct vkd3d_shader_debug_ring *ring,
struct d3d12_device *device)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
if (!ring->active)
return;
pthread_mutex_lock(&ring->ring_lock);
ring->active = false;
pthread_cond_signal(&ring->ring_cond);
pthread_mutex_unlock(&ring->ring_lock);
pthread_join(ring->ring_thread, NULL);
pthread_mutex_destroy(&ring->ring_lock);
pthread_cond_destroy(&ring->ring_cond);
VK_CALL(vkDestroyBuffer(device->vk_device, ring->host_buffer, NULL));
VK_CALL(vkDestroyBuffer(device->vk_device, ring->device_atomic_buffer, NULL));
vkd3d_free_device_memory(device, &ring->host_buffer_memory);
vkd3d_free_device_memory(device, &ring->device_atomic_buffer_memory);
}
static pthread_mutex_t debug_ring_teardown_lock = PTHREAD_MUTEX_INITIALIZER;
void vkd3d_shader_debug_ring_kick(struct vkd3d_shader_debug_ring *ring, struct d3d12_device *device, bool device_lost)
{
if (device_lost)
{
/* Need a global lock here since multiple threads can observe device lost at the same time. */
pthread_mutex_lock(&debug_ring_teardown_lock);
{
ring->device_lost = true;
/* We're going to die or hang after this most likely, so make sure we get to see all messages the
* GPU had to write. Just cleanup now. */
vkd3d_shader_debug_ring_cleanup(ring, device);
}
pthread_mutex_unlock(&debug_ring_teardown_lock);
}
else
{
pthread_cond_signal(&ring->ring_cond);
}
}

View File

@ -0,0 +1,530 @@
/*
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_descriptor_debug.h"
#include "vkd3d_threads.h"
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
static pthread_once_t debug_once = PTHREAD_ONCE_INIT;
static pthread_mutex_t debug_lock = PTHREAD_MUTEX_INITIALIZER;
static bool descriptor_debug_active_qa_checks;
static bool descriptor_debug_active_log;
static FILE *descriptor_debug_file;
struct vkd3d_descriptor_qa_global_info
{
struct vkd3d_descriptor_qa_global_buffer_data *data;
VkDescriptorBufferInfo descriptor;
VkBuffer vk_buffer;
struct vkd3d_device_memory_allocation device_allocation;
unsigned int num_cookies;
pthread_t ring_thread;
pthread_mutex_t ring_lock;
pthread_cond_t ring_cond;
bool active;
};
static const char *debug_descriptor_type(vkd3d_descriptor_qa_flags type_flags)
{
bool has_raw_va = !!(type_flags & VKD3D_DESCRIPTOR_QA_TYPE_RAW_VA_BIT);
switch (type_flags & ~VKD3D_DESCRIPTOR_QA_TYPE_RAW_VA_BIT)
{
case VKD3D_DESCRIPTOR_QA_TYPE_SAMPLER_BIT: return "SAMPLER";
case VKD3D_DESCRIPTOR_QA_TYPE_SAMPLED_IMAGE_BIT: return "SAMPLED_IMAGE";
case VKD3D_DESCRIPTOR_QA_TYPE_STORAGE_IMAGE_BIT: return "STORAGE_IMAGE";
case VKD3D_DESCRIPTOR_QA_TYPE_UNIFORM_BUFFER_BIT: return "UNIFORM_BUFFER";
case VKD3D_DESCRIPTOR_QA_TYPE_STORAGE_BUFFER_BIT: return "STORAGE_BUFFER";
case VKD3D_DESCRIPTOR_QA_TYPE_UNIFORM_TEXEL_BUFFER_BIT: return "UNIFORM_TEXEL_BUFFER";
case VKD3D_DESCRIPTOR_QA_TYPE_STORAGE_TEXEL_BUFFER_BIT: return "STORAGE_TEXEL_BUFFER";
case VKD3D_DESCRIPTOR_QA_TYPE_STORAGE_TEXEL_BUFFER_BIT | VKD3D_DESCRIPTOR_QA_TYPE_STORAGE_BUFFER_BIT:
return has_raw_va ? "STORAGE_TEXEL_BUFFER / STORAGE_BUFFER (w/ counter)" : "STORAGE_TEXEL_BUFFER / STORAGE_BUFFER";
case VKD3D_DESCRIPTOR_QA_TYPE_UNIFORM_TEXEL_BUFFER_BIT | VKD3D_DESCRIPTOR_QA_TYPE_STORAGE_BUFFER_BIT:
return has_raw_va ? "UNIFORM_TEXEL_BUFFER / STORAGE_BUFFER (w/ counter)" : "UNIFORM_TEXEL_BUFFER / STORAGE_BUFFER";
case VKD3D_DESCRIPTOR_QA_TYPE_RT_ACCELERATION_STRUCTURE_BIT:
return "RTAS";
case 0:
return "NONE";
default: return "?";
}
}
static void vkd3d_descriptor_debug_init_once(void)
{
char env[VKD3D_PATH_MAX];
vkd3d_get_env_var("VKD3D_DESCRIPTOR_QA_LOG", env, sizeof(env));
if (strlen(env) > 0)
{
INFO("Enabling VKD3D_DESCRIPTOR_QA_LOG\n");
descriptor_debug_file = fopen(env, "w");
if (!descriptor_debug_file)
ERR("Failed to open file: %s.\n", env);
else
descriptor_debug_active_log = true;
}
if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_DESCRIPTOR_QA_CHECKS)
{
INFO("Enabling descriptor QA checks!\n");
descriptor_debug_active_qa_checks = true;
}
}
void vkd3d_descriptor_debug_init(void)
{
pthread_once(&debug_once, vkd3d_descriptor_debug_init_once);
}
bool vkd3d_descriptor_debug_active_log(void)
{
return descriptor_debug_active_log;
}
bool vkd3d_descriptor_debug_active_qa_checks(void)
{
return descriptor_debug_active_qa_checks;
}
VkDeviceSize vkd3d_descriptor_debug_heap_info_size(unsigned int num_descriptors)
{
return offsetof(struct vkd3d_descriptor_qa_heap_buffer_data, desc) + num_descriptors *
sizeof(struct vkd3d_descriptor_qa_cookie_descriptor);
}
static void vkd3d_descriptor_debug_set_live_status_bit(
struct vkd3d_descriptor_qa_global_info *global_info, uint64_t cookie)
{
if (!global_info || !global_info->active || !global_info->data)
return;
if (cookie < global_info->num_cookies)
{
vkd3d_atomic_uint32_or(&global_info->data->live_status_table[cookie / 32],
1u << (cookie & 31), vkd3d_memory_order_relaxed);
}
else
INFO("Cookie index %"PRIu64" is out of range, cannot be tracked.\n", cookie);
}
static void vkd3d_descriptor_debug_unset_live_status_bit(
struct vkd3d_descriptor_qa_global_info *global_info, uint64_t cookie)
{
if (!global_info || !global_info->active || !global_info->data)
return;
if (cookie < global_info->num_cookies)
{
vkd3d_atomic_uint32_and(&global_info->data->live_status_table[cookie / 32],
~(1u << (cookie & 31)), vkd3d_memory_order_relaxed);
}
}
static void vkd3d_descriptor_debug_qa_check_report_fault(
struct vkd3d_descriptor_qa_global_info *global_info);
static void *vkd3d_descriptor_debug_qa_check_entry(void *userdata)
{
struct vkd3d_descriptor_qa_global_info *global_info = userdata;
bool active = true;
while (active)
{
/* Don't spin endlessly, this thread is kicked after a successful fence wait. */
pthread_mutex_lock(&global_info->ring_lock);
if (global_info->active)
pthread_cond_wait(&global_info->ring_cond, &global_info->ring_lock);
active = global_info->active;
pthread_mutex_unlock(&global_info->ring_lock);
if (global_info->data->fault_type != 0)
{
vkd3d_descriptor_debug_qa_check_report_fault(global_info);
ERR("Num failed checks: %u\n", global_info->data->fault_atomic);
/* Reset the latch so we can get more reports. */
vkd3d_atomic_uint32_store_explicit(&global_info->data->fault_type, 0, vkd3d_memory_order_relaxed);
vkd3d_atomic_uint32_store_explicit(&global_info->data->fault_atomic, 0, vkd3d_memory_order_release);
}
}
return NULL;
}
void vkd3d_descriptor_debug_kick_qa_check(struct vkd3d_descriptor_qa_global_info *global_info)
{
if (global_info && global_info->active)
pthread_cond_signal(&global_info->ring_cond);
}
const VkDescriptorBufferInfo *vkd3d_descriptor_debug_get_global_info_descriptor(
struct vkd3d_descriptor_qa_global_info *global_info)
{
if (global_info)
return &global_info->descriptor;
else
return NULL;
}
HRESULT vkd3d_descriptor_debug_alloc_global_info(
struct vkd3d_descriptor_qa_global_info **out_global_info, unsigned int num_cookies,
struct d3d12_device *device)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
struct vkd3d_descriptor_qa_global_info *global_info;
D3D12_RESOURCE_DESC1 buffer_desc;
D3D12_HEAP_PROPERTIES heap_info;
D3D12_HEAP_FLAGS heap_flags;
VkResult vr;
HRESULT hr;
global_info = vkd3d_calloc(1, sizeof(*global_info));
if (!global_info)
return E_OUTOFMEMORY;
memset(&buffer_desc, 0, sizeof(buffer_desc));
buffer_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
buffer_desc.Width = sizeof(uint32_t) * ((num_cookies + 31) / 32) +
offsetof(struct vkd3d_descriptor_qa_global_buffer_data, live_status_table);
buffer_desc.Height = 1;
buffer_desc.DepthOrArraySize = 1;
buffer_desc.MipLevels = 1;
buffer_desc.SampleDesc.Count = 1;
buffer_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
buffer_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
/* host-visible device memory */
memset(&heap_info, 0, sizeof(heap_info));
heap_info.Type = D3D12_HEAP_TYPE_UPLOAD;
heap_flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS;
if (FAILED(hr = vkd3d_create_buffer(device, &heap_info, heap_flags, &buffer_desc, &global_info->vk_buffer)))
{
vkd3d_descriptor_debug_free_global_info(global_info, device);
return hr;
}
if (FAILED(hr = vkd3d_allocate_buffer_memory(device, global_info->vk_buffer,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
&global_info->device_allocation)))
{
vkd3d_descriptor_debug_free_global_info(global_info, device);
return hr;
}
if ((vr = VK_CALL(vkMapMemory(device->vk_device, global_info->device_allocation.vk_memory,
0, VK_WHOLE_SIZE, 0, (void**)&global_info->data))))
{
ERR("Failed to map buffer, vr %d.\n", vr);
vkd3d_descriptor_debug_free_global_info(global_info, device);
return hresult_from_vk_result(vr);
}
memset(global_info->data, 0, buffer_desc.Width);
/* The NULL descriptor has cookie 0, and is always considered live. */
global_info->data->live_status_table[0] = 1u << 0;
global_info->descriptor.buffer = global_info->vk_buffer;
global_info->descriptor.offset = 0;
global_info->descriptor.range = buffer_desc.Width;
global_info->num_cookies = num_cookies;
pthread_mutex_init(&global_info->ring_lock, NULL);
pthread_cond_init(&global_info->ring_cond, NULL);
global_info->active = true;
if (pthread_create(&global_info->ring_thread, NULL, vkd3d_descriptor_debug_qa_check_entry, global_info) != 0)
{
vkd3d_descriptor_debug_free_global_info(global_info, device);
return E_OUTOFMEMORY;
}
*out_global_info = global_info;
return S_OK;
}
void vkd3d_descriptor_debug_free_global_info(
struct vkd3d_descriptor_qa_global_info *global_info,
struct d3d12_device *device)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
if (!global_info)
return;
if (global_info->active)
{
pthread_mutex_lock(&global_info->ring_lock);
global_info->active = false;
pthread_cond_signal(&global_info->ring_cond);
pthread_mutex_unlock(&global_info->ring_lock);
pthread_join(global_info->ring_thread, NULL);
pthread_mutex_destroy(&global_info->ring_lock);
pthread_cond_destroy(&global_info->ring_cond);
}
vkd3d_free_device_memory(device, &global_info->device_allocation);
VK_CALL(vkDestroyBuffer(device->vk_device, global_info->vk_buffer, NULL));
vkd3d_free(global_info);
}
#define DECL_BUFFER() \
char buffer[4096]; \
char *ptr; \
ptr = buffer; \
*ptr = '\0'
#define FLUSH_BUFFER() do { \
pthread_mutex_lock(&debug_lock); \
fprintf(descriptor_debug_file, "%s\n", buffer); \
pthread_mutex_unlock(&debug_lock); \
fflush(descriptor_debug_file); \
} while (0)
#define APPEND_SNPRINTF(...) do { ptr += strlen(ptr); snprintf(ptr, (buffer + ARRAY_SIZE(buffer)) - ptr, __VA_ARGS__); } while(0)
static void vkd3d_descriptor_debug_qa_check_report_fault(
struct vkd3d_descriptor_qa_global_info *global_info)
{
DECL_BUFFER();
if (global_info->data->fault_type & VKD3D_DESCRIPTOR_FAULT_TYPE_HEAP_OF_OF_RANGE)
APPEND_SNPRINTF("Fault type: HEAP_OUT_OF_RANGE\n");
if (global_info->data->fault_type & VKD3D_DESCRIPTOR_FAULT_TYPE_MISMATCH_DESCRIPTOR_TYPE)
APPEND_SNPRINTF("Fault type: MISMATCH_DESCRIPTOR_TYPE\n");
if (global_info->data->fault_type & VKD3D_DESCRIPTOR_FAULT_TYPE_DESTROYED_RESOURCE)
APPEND_SNPRINTF("Fault type: DESTROYED_RESOURCE\n");
APPEND_SNPRINTF("CBV_SRV_UAV heap cookie: %u\n", global_info->data->failed_heap);
APPEND_SNPRINTF("Shader hash and instruction: %"PRIx64" (%u)\n",
global_info->data->failed_hash, global_info->data->failed_instruction);
APPEND_SNPRINTF("Accessed resource/view cookie: %u\n", global_info->data->failed_cookie);
APPEND_SNPRINTF("Shader desired descriptor type: %u (%s)\n",
global_info->data->failed_descriptor_type_mask,
debug_descriptor_type(global_info->data->failed_descriptor_type_mask));
APPEND_SNPRINTF("Found descriptor type in heap: %u (%s)\n",
global_info->data->actual_descriptor_type_mask,
debug_descriptor_type(global_info->data->actual_descriptor_type_mask));
APPEND_SNPRINTF("Failed heap index: %u\n", global_info->data->failed_offset);
ERR("\n============\n%s==========\n", buffer);
if (!vkd3d_descriptor_debug_active_log())
return;
FLUSH_BUFFER();
}
void vkd3d_descriptor_debug_register_heap(
struct vkd3d_descriptor_qa_heap_buffer_data *heap, uint64_t cookie,
const D3D12_DESCRIPTOR_HEAP_DESC *desc)
{
DECL_BUFFER();
if (heap)
{
heap->num_descriptors = desc->NumDescriptors;
heap->heap_index = cookie <= UINT32_MAX ? (uint32_t)cookie : 0u;
memset(heap->desc, 0, desc->NumDescriptors * sizeof(*heap->desc));
}
if (!vkd3d_descriptor_debug_active_log())
return;
APPEND_SNPRINTF("REGISTER HEAP %"PRIu64" || COUNT = %u", cookie, desc->NumDescriptors);
if (desc->Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE)
APPEND_SNPRINTF(" || SHADER");
switch (desc->Type)
{
case D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV:
APPEND_SNPRINTF(" || CBV_SRV_UAV");
break;
case D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER:
APPEND_SNPRINTF(" || SAMPLER");
break;
case D3D12_DESCRIPTOR_HEAP_TYPE_RTV:
APPEND_SNPRINTF(" || RTV");
break;
case D3D12_DESCRIPTOR_HEAP_TYPE_DSV:
APPEND_SNPRINTF(" || DSV");
break;
default:
APPEND_SNPRINTF(" || ?");
break;
}
FLUSH_BUFFER();
}
void vkd3d_descriptor_debug_unregister_heap(uint64_t cookie)
{
DECL_BUFFER();
if (!vkd3d_descriptor_debug_active_log())
return;
APPEND_SNPRINTF("DESTROY HEAP %"PRIu64, cookie);
FLUSH_BUFFER();
}
void vkd3d_descriptor_debug_register_resource_cookie(struct vkd3d_descriptor_qa_global_info *global_info,
uint64_t cookie, const D3D12_RESOURCE_DESC1 *desc)
{
const char *fmt;
DECL_BUFFER();
vkd3d_descriptor_debug_set_live_status_bit(global_info, cookie);
if (!vkd3d_descriptor_debug_active_log())
return;
APPEND_SNPRINTF("RESOURCE CREATE #%"PRIu64" || ", cookie);
fmt = debug_dxgi_format(desc->Format);
switch (desc->Dimension)
{
case D3D12_RESOURCE_DIMENSION_BUFFER:
APPEND_SNPRINTF("Buffer");
APPEND_SNPRINTF(" || Size = 0x%"PRIx64" bytes", desc->Width);
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE1D:
APPEND_SNPRINTF("Tex1D");
APPEND_SNPRINTF(" || Format = %s || Levels = %u || Layers = %u || Width = %"PRIu64,
fmt, desc->MipLevels, desc->DepthOrArraySize, desc->Width);
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE2D:
APPEND_SNPRINTF("Tex2D");
APPEND_SNPRINTF(" || Format = %s || Levels = %u || Layers = %u || Width = %"PRIu64" || Height = %u",
fmt, desc->MipLevels, desc->DepthOrArraySize, desc->Width, desc->Height);
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE3D:
APPEND_SNPRINTF("Tex3D");
APPEND_SNPRINTF(" || Format = %s || Levels = %u || Width = %"PRIu64" || Height = %u || Depth = %u",
fmt, desc->MipLevels, desc->Width, desc->Height, desc->DepthOrArraySize);
break;
default:
APPEND_SNPRINTF("Unknown dimension");
break;
}
if (desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)
APPEND_SNPRINTF(" || UAV");
if (desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET)
APPEND_SNPRINTF(" || RTV");
if (desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL)
APPEND_SNPRINTF(" || DSV");
FLUSH_BUFFER();
}
void vkd3d_descriptor_debug_register_allocation_cookie(
struct vkd3d_descriptor_qa_global_info *global_info,
uint64_t cookie, const struct vkd3d_allocate_memory_info *info)
{
D3D12_RESOURCE_DESC1 desc;
memset(&desc, 0, sizeof(desc));
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
desc.Width = info->memory_requirements.size;
vkd3d_descriptor_debug_register_resource_cookie(global_info, cookie, &desc);
}
void vkd3d_descriptor_debug_register_view_cookie(
struct vkd3d_descriptor_qa_global_info *global_info,
uint64_t cookie, uint64_t resource_cookie)
{
DECL_BUFFER();
vkd3d_descriptor_debug_set_live_status_bit(global_info, cookie);
if (!vkd3d_descriptor_debug_active_log())
return;
APPEND_SNPRINTF("VIEW CREATE #%"PRIu64" <- RESOURCE #%"PRIu64, cookie, resource_cookie);
FLUSH_BUFFER();
}
void vkd3d_descriptor_debug_unregister_cookie(
struct vkd3d_descriptor_qa_global_info *global_info,
uint64_t cookie)
{
DECL_BUFFER();
/* Don't unset the null descriptor by mistake. */
if (cookie != 0)
vkd3d_descriptor_debug_unset_live_status_bit(global_info, cookie);
if (!vkd3d_descriptor_debug_active_log())
return;
APPEND_SNPRINTF("COOKIE DESTROY #%"PRIu64, cookie);
FLUSH_BUFFER();
}
void vkd3d_descriptor_debug_write_descriptor(struct vkd3d_descriptor_qa_heap_buffer_data *heap, uint64_t heap_cookie,
uint32_t offset, vkd3d_descriptor_qa_flags type_flags, uint64_t cookie)
{
DECL_BUFFER();
if (heap && offset < heap->num_descriptors)
{
/* Should never overflow here except if game is literally spamming allocations every frame and we
* wait around for hours/days.
* This case will trigger warnings either way. */
heap->desc[offset].cookie = cookie <= UINT32_MAX ? (uint32_t)cookie : 0u;
heap->desc[offset].descriptor_type = type_flags;
}
if (!vkd3d_descriptor_debug_active_log())
return;
APPEND_SNPRINTF("WRITE HEAP %"PRIu64" || OFFSET = %u || TYPE = %s || COOKIE = #%"PRIu64,
heap_cookie, offset, debug_descriptor_type(type_flags), cookie);
FLUSH_BUFFER();
}
void vkd3d_descriptor_debug_copy_descriptor(
struct vkd3d_descriptor_qa_heap_buffer_data *dst_heap, uint64_t dst_heap_cookie, uint32_t dst_offset,
struct vkd3d_descriptor_qa_heap_buffer_data *src_heap, uint64_t src_heap_cookie, uint32_t src_offset,
uint64_t cookie)
{
DECL_BUFFER();
if (dst_heap && src_heap && dst_offset < dst_heap->num_descriptors && src_offset < src_heap->num_descriptors)
dst_heap->desc[dst_offset] = src_heap->desc[src_offset];
if (!vkd3d_descriptor_debug_active_log())
return;
APPEND_SNPRINTF("COPY DST HEAP %"PRIu64" || DST OFFSET = %u || COOKIE = #%"PRIu64" || SRC HEAP %"PRIu64" || SRC OFFSET = %u",
dst_heap_cookie, dst_offset, cookie, src_heap_cookie, src_offset);
FLUSH_BUFFER();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,334 @@
/*
* Copyright 2020 Hans-Kristian Arntzen for Valve Corporation
*
* 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
*/
#ifndef __VKD3D_DEVICE_PROFILED_H
#define __VKD3D_DEVICE_PROFILED_H
/* Only profile device commands which we know are somewhat performance sensitive. */
#define DEVICE_PROFILED_CALL_HRESULT(name, ...) \
HRESULT hr; \
VKD3D_REGION_DECL(name); \
VKD3D_REGION_BEGIN(name); \
hr = d3d12_device_##name(__VA_ARGS__); \
VKD3D_REGION_END(name); \
return hr
#define DEVICE_PROFILED_CALL(name, ...) \
VKD3D_REGION_DECL(name); \
VKD3D_REGION_BEGIN(name); \
d3d12_device_##name(__VA_ARGS__); \
VKD3D_REGION_END(name)
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateGraphicsPipelineState_profiled(d3d12_device_iface *iface,
const D3D12_GRAPHICS_PIPELINE_STATE_DESC *desc, REFIID riid, void **pipeline_state)
{
DEVICE_PROFILED_CALL_HRESULT(CreateGraphicsPipelineState, iface, desc, riid, pipeline_state);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateComputePipelineState_profiled(d3d12_device_iface *iface,
const D3D12_COMPUTE_PIPELINE_STATE_DESC *desc, REFIID riid, void **pipeline_state)
{
DEVICE_PROFILED_CALL_HRESULT(CreateComputePipelineState, iface, desc, riid, pipeline_state);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateDescriptorHeap_profiled(d3d12_device_iface *iface,
const D3D12_DESCRIPTOR_HEAP_DESC *desc, REFIID riid, void **descriptor_heap)
{
DEVICE_PROFILED_CALL_HRESULT(CreateDescriptorHeap, iface, desc, riid, descriptor_heap);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateRootSignature_profiled(d3d12_device_iface *iface,
UINT node_mask, const void *bytecode, SIZE_T bytecode_length,
REFIID riid, void **root_signature)
{
DEVICE_PROFILED_CALL_HRESULT(CreateRootSignature, iface, node_mask, bytecode, bytecode_length,
riid, root_signature);
}
static void STDMETHODCALLTYPE d3d12_device_CreateConstantBufferView_profiled(d3d12_device_iface *iface,
const D3D12_CONSTANT_BUFFER_VIEW_DESC *desc, D3D12_CPU_DESCRIPTOR_HANDLE descriptor)
{
DEVICE_PROFILED_CALL(CreateConstantBufferView, iface, desc, descriptor);
}
static void STDMETHODCALLTYPE d3d12_device_CreateShaderResourceView_profiled(d3d12_device_iface *iface,
ID3D12Resource *resource, const D3D12_SHADER_RESOURCE_VIEW_DESC *desc,
D3D12_CPU_DESCRIPTOR_HANDLE descriptor)
{
DEVICE_PROFILED_CALL(CreateShaderResourceView, iface, resource, desc, descriptor);
}
static void STDMETHODCALLTYPE d3d12_device_CreateUnorderedAccessView_profiled(d3d12_device_iface *iface,
ID3D12Resource *resource, ID3D12Resource *counter_resource,
const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc, D3D12_CPU_DESCRIPTOR_HANDLE descriptor)
{
DEVICE_PROFILED_CALL(CreateUnorderedAccessView, iface, resource, counter_resource, desc, descriptor);
}
static void STDMETHODCALLTYPE d3d12_device_CreateRenderTargetView_profiled(d3d12_device_iface *iface,
ID3D12Resource *resource, const D3D12_RENDER_TARGET_VIEW_DESC *desc,
D3D12_CPU_DESCRIPTOR_HANDLE descriptor)
{
DEVICE_PROFILED_CALL(CreateRenderTargetView, iface, resource, desc, descriptor);
}
static void STDMETHODCALLTYPE d3d12_device_CreateDepthStencilView_profiled(d3d12_device_iface *iface,
ID3D12Resource *resource, const D3D12_DEPTH_STENCIL_VIEW_DESC *desc,
D3D12_CPU_DESCRIPTOR_HANDLE descriptor)
{
DEVICE_PROFILED_CALL(CreateDepthStencilView, iface, resource, desc, descriptor);
}
static void STDMETHODCALLTYPE d3d12_device_CreateSampler_profiled(d3d12_device_iface *iface,
const D3D12_SAMPLER_DESC *desc, D3D12_CPU_DESCRIPTOR_HANDLE descriptor)
{
DEVICE_PROFILED_CALL(CreateSampler, iface, desc, descriptor);
}
static void STDMETHODCALLTYPE d3d12_device_CopyDescriptors_profiled(d3d12_device_iface *iface,
UINT dst_descriptor_range_count, const D3D12_CPU_DESCRIPTOR_HANDLE *dst_descriptor_range_offsets,
const UINT *dst_descriptor_range_sizes,
UINT src_descriptor_range_count, const D3D12_CPU_DESCRIPTOR_HANDLE *src_descriptor_range_offsets,
const UINT *src_descriptor_range_sizes,
D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heap_type)
{
VKD3D_REGION_DECL(CopyDescriptors);
unsigned int total_descriptors, total_descriptors_src, total_descriptors_dst, i;
if (src_descriptor_range_sizes)
{
for (i = 0, total_descriptors_src = 0; i < src_descriptor_range_count; i++)
total_descriptors_src += src_descriptor_range_sizes[i];
}
else
total_descriptors_src = src_descriptor_range_count;
if (dst_descriptor_range_sizes)
{
for (i = 0, total_descriptors_dst = 0; i < dst_descriptor_range_count; i++)
total_descriptors_dst += dst_descriptor_range_sizes[i];
}
else
total_descriptors_dst = dst_descriptor_range_count;
VKD3D_REGION_BEGIN(CopyDescriptors);
d3d12_device_CopyDescriptors(iface,
dst_descriptor_range_count, dst_descriptor_range_offsets,
dst_descriptor_range_sizes,
src_descriptor_range_count, src_descriptor_range_offsets,
src_descriptor_range_sizes,
descriptor_heap_type);
total_descriptors = total_descriptors_src < total_descriptors_dst ? total_descriptors_src : total_descriptors_dst;
VKD3D_REGION_END_ITERATIONS(CopyDescriptors, total_descriptors);
}
static void STDMETHODCALLTYPE d3d12_device_CopyDescriptorsSimple_profiled(d3d12_device_iface *iface,
UINT descriptor_count, const D3D12_CPU_DESCRIPTOR_HANDLE dst_descriptor_range_offset,
const D3D12_CPU_DESCRIPTOR_HANDLE src_descriptor_range_offset,
D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heap_type)
{
VKD3D_REGION_DECL(CopyDescriptorsSimple);
VKD3D_REGION_BEGIN(CopyDescriptorsSimple);
d3d12_device_CopyDescriptorsSimple(iface, descriptor_count, dst_descriptor_range_offset,
src_descriptor_range_offset, descriptor_heap_type);
VKD3D_REGION_END_ITERATIONS(CopyDescriptorsSimple, descriptor_count);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource_profiled(d3d12_device_iface *iface,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource)
{
DEVICE_PROFILED_CALL_HRESULT(CreateCommittedResource, iface, heap_properties, heap_flags,
desc, initial_state,
optimized_clear_value, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource1_profiled(d3d12_device_iface *iface,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
const D3D12_CLEAR_VALUE *optimized_clear_value,
ID3D12ProtectedResourceSession *protected_session,
REFIID iid, void **resource)
{
DEVICE_PROFILED_CALL_HRESULT(CreateCommittedResource1, iface, heap_properties, heap_flags,
desc, initial_state,
optimized_clear_value, protected_session, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap1_profiled(d3d12_device_iface *iface,
const D3D12_HEAP_DESC *desc, ID3D12ProtectedResourceSession *protected_session,
REFIID iid, void **heap)
{
DEVICE_PROFILED_CALL_HRESULT(CreateHeap1, iface, desc, protected_session, iid, heap);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap_profiled(d3d12_device_iface *iface,
const D3D12_HEAP_DESC *desc, REFIID iid, void **heap)
{
DEVICE_PROFILED_CALL_HRESULT(CreateHeap, iface, desc, iid, heap);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource_profiled(d3d12_device_iface *iface,
ID3D12Heap *heap, UINT64 heap_offset,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource)
{
DEVICE_PROFILED_CALL_HRESULT(CreatePlacedResource, iface, heap, heap_offset,
desc, initial_state, optimized_clear_value, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource1_profiled(d3d12_device_iface *iface,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value,
ID3D12ProtectedResourceSession *protected_session, REFIID iid, void **resource)
{
DEVICE_PROFILED_CALL_HRESULT(CreateReservedResource1, iface, desc, initial_state, optimized_clear_value, protected_session, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource_profiled(d3d12_device_iface *iface,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource)
{
DEVICE_PROFILED_CALL_HRESULT(CreateReservedResource, iface, desc, initial_state, optimized_clear_value, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePipelineState_profiled(d3d12_device_iface *iface,
const D3D12_PIPELINE_STATE_STREAM_DESC *desc, REFIID riid, void **pipeline_state)
{
DEVICE_PROFILED_CALL_HRESULT(CreatePipelineState, iface, desc, riid, pipeline_state);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource2_profiled(d3d12_device_iface *iface,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc,
D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value,
ID3D12ProtectedResourceSession *protected_session, REFIID iid, void **resource)
{
DEVICE_PROFILED_CALL_HRESULT(CreateCommittedResource2, iface, heap_properties, heap_flags,
desc, initial_state, optimized_clear_value, protected_session, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource1_profiled(d3d12_device_iface *iface,
ID3D12Heap *heap, UINT64 heap_offset, const D3D12_RESOURCE_DESC1 *desc,
D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value,
REFIID iid, void **resource)
{
DEVICE_PROFILED_CALL_HRESULT(CreatePlacedResource1, iface, heap, heap_offset,
desc, initial_state, optimized_clear_value, iid, resource);
}
static void STDMETHODCALLTYPE d3d12_device_CreateSamplerFeedbackUnorderedAccessView_profiled(d3d12_device_iface *iface,
ID3D12Resource *target_resource, ID3D12Resource *feedback_resource, D3D12_CPU_DESCRIPTOR_HANDLE descriptor)
{
DEVICE_PROFILED_CALL(CreateSamplerFeedbackUnorderedAccessView, iface, target_resource, feedback_resource, descriptor);
}
CONST_VTBL struct ID3D12Device9Vtbl d3d12_device_vtbl_profiled =
{
/* IUnknown methods */
d3d12_device_QueryInterface,
d3d12_device_AddRef,
d3d12_device_Release,
/* ID3D12Object methods */
d3d12_device_GetPrivateData,
d3d12_device_SetPrivateData,
d3d12_device_SetPrivateDataInterface,
(void *)d3d12_object_SetName,
/* ID3D12Device methods */
d3d12_device_GetNodeCount,
d3d12_device_CreateCommandQueue,
d3d12_device_CreateCommandAllocator,
d3d12_device_CreateGraphicsPipelineState_profiled,
d3d12_device_CreateComputePipelineState_profiled,
d3d12_device_CreateCommandList,
d3d12_device_CheckFeatureSupport,
d3d12_device_CreateDescriptorHeap_profiled,
d3d12_device_GetDescriptorHandleIncrementSize,
d3d12_device_CreateRootSignature_profiled,
d3d12_device_CreateConstantBufferView_profiled,
d3d12_device_CreateShaderResourceView_profiled,
d3d12_device_CreateUnorderedAccessView_profiled,
d3d12_device_CreateRenderTargetView_profiled,
d3d12_device_CreateDepthStencilView_profiled,
d3d12_device_CreateSampler_profiled,
d3d12_device_CopyDescriptors_profiled,
d3d12_device_CopyDescriptorsSimple_profiled,
d3d12_device_GetResourceAllocationInfo,
d3d12_device_GetCustomHeapProperties,
d3d12_device_CreateCommittedResource_profiled,
d3d12_device_CreateHeap_profiled,
d3d12_device_CreatePlacedResource_profiled,
d3d12_device_CreateReservedResource_profiled,
d3d12_device_CreateSharedHandle,
d3d12_device_OpenSharedHandle,
d3d12_device_OpenSharedHandleByName,
d3d12_device_MakeResident,
d3d12_device_Evict,
d3d12_device_CreateFence,
d3d12_device_GetDeviceRemovedReason,
d3d12_device_GetCopyableFootprints,
d3d12_device_CreateQueryHeap,
d3d12_device_SetStablePowerState,
d3d12_device_CreateCommandSignature,
d3d12_device_GetResourceTiling,
d3d12_device_GetAdapterLuid,
/* ID3D12Device1 methods */
d3d12_device_CreatePipelineLibrary,
d3d12_device_SetEventOnMultipleFenceCompletion,
d3d12_device_SetResidencyPriority,
/* ID3D12Device2 methods */
d3d12_device_CreatePipelineState_profiled,
/* ID3D12Device3 methods */
d3d12_device_OpenExistingHeapFromAddress,
d3d12_device_OpenExistingHeapFromFileMapping,
d3d12_device_EnqueueMakeResident,
/* ID3D12Device4 methods */
d3d12_device_CreateCommandList1,
d3d12_device_CreateProtectedResourceSession,
d3d12_device_CreateCommittedResource1_profiled,
d3d12_device_CreateHeap1_profiled,
d3d12_device_CreateReservedResource1_profiled,
d3d12_device_GetResourceAllocationInfo1,
/* ID3D12Device5 methods */
d3d12_device_CreateLifetimeTracker,
d3d12_device_RemoveDevice,
d3d12_device_EnumerateMetaCommands,
d3d12_device_EnumerateMetaCommandParameters,
d3d12_device_CreateMetaCommand,
d3d12_device_CreateStateObject,
d3d12_device_GetRaytracingAccelerationStructurePrebuildInfo,
d3d12_device_CheckDriverMatchingIdentifier,
/* ID3D12Device6 methods */
d3d12_device_SetBackgroundProcessingMode,
/* ID3D12Device7 methods */
d3d12_device_AddToStateObject,
d3d12_device_CreateProtectedResourceSession1,
/* ID3D12Device8 methods */
d3d12_device_GetResourceAllocationInfo2,
d3d12_device_CreateCommittedResource2_profiled,
d3d12_device_CreatePlacedResource1_profiled,
d3d12_device_CreateSamplerFeedbackUnorderedAccessView_profiled,
d3d12_device_GetCopyableFootprints1,
/* ID3D12Device9 methods */
d3d12_device_CreateShaderCacheSession,
d3d12_device_ShaderCacheControl,
d3d12_device_CreateCommandQueue1,
};
#endif

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