Commit Graph

332 Commits

Author SHA1 Message Date
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 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
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 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
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 9fb624a429 vkd3d: Implement RSSetShadingRateImage
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
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
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
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 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 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 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 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 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 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
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
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
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 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 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
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 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
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 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
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 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 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
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
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 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
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 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 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 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
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
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 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 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
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
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 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