Commit Graph

595 Commits

Author SHA1 Message Date
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
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 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 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
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
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
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 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 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 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 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 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 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
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 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 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
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 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
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 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 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
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
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 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
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
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 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
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 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 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 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