Commit Graph

746 Commits

Author SHA1 Message Date
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 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
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 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
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 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 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 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 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
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 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 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 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 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 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 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
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
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
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 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 9185edb42a vkd3d: Implement ID3D12GraphicsCommandList6.
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
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 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 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
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 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 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 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
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 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
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
David McCloskey a19619ccbf vkd3d: Fixing compile errors on Windows. 2021-09-18 21:40:30 +01: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 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 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 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
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 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 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
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
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
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
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 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 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 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 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
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 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 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
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 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
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
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 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
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 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
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 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 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 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 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
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 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