Commit Graph

504 Commits

Author SHA1 Message Date
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 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
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 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 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
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
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 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 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
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 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 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
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 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 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 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 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
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
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
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 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
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 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 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 3b6a4ab988 vkd3d: Implement ID3D12Device8 and ID3D12Resource2.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2021-11-19 14:57:51 +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
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 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 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 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 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 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 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
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
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 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 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