Commit Graph

313 Commits

Author SHA1 Message Date
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 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
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 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 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 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
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
Conor McCarthy 91555883ac vkd3d: Add stub for ID3D12GraphicsCommandList2::WriteBufferImmediate().
ID3D12GraphicsCommandList2 and WriteBufferImmediate() are used by
Hitman 2, but implementing the function on top of an AMD extension has
no effect on game behaviour. It's commonly used to write debug info.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-12-06 20:11:15 +01:00
Conor McCarthy af60bc03ba vkd3d: Validate texture resource alignments.
Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-27 22:08:31 +01:00
Philip Rebohle 207ca12725 vkd3d: Re-implement d3d12_command_list_ClearUnorderedAccessViewUint().
Addresses the following limitations of the previous implementation:
    - Only R32_{UINT,TYPELESS} were supported for buffers.
    - Clearing an image UAV did not behave correctly for images with non-UINT formats.
    - Due to the use of transfer operations, extra memory barriers were needed.

If necessary, this will create a temporary view with a bit-compatible
UINT format for the resource in order to perform a bit-exact clear.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-25 16:07:04 +01:00
Philip Rebohle 126a789019 vkd3d: Implement d3d12_command_list_ClearUnorderedAccessViewFloat().
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-25 16:06:59 +01:00
Hans-Kristian Arntzen 54d2a15aa6 vkd3d: Use size_t instead of SIZE_T for GPU VA sizes.
This also fixes a format specifier warning in an ERR for the 32-bit Linux
build.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-25 16:06:56 +01:00
Philip Rebohle 1bfacf3727 vkd3d: Store view object type in vkd3d_view.
Currently, vkd3d_view_destroy_descriptor assumes image views
by default, but we need to be able to attach buffer views to
command allocators for UAV clears.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-13 16:40:04 +01:00
Philip Rebohle 4a191a27dc vkd3d: Store view properties in vkd3d_view.
The additional data is needed to implement UAV clears.

Moving this out of d3d12_desc also helps make copying and
traversing descriptor arrays more CPU cache-friendly.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-13 16:39:59 +01:00
Derek Lesho 1d955506a3 vkd3d: Implement d3d12_device_GetCustomHeapProperties().
Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-07 21:07:18 +01:00
Philip Rebohle 8cb42d6971 vkd3d: Keep active bindings after changing root signature.
Shadow of the Tomb Raider does not re-bind all descriptor tables after
setting a new root signature if tessellation is enabled, which causes
some descriptors to be left undefined.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-31 19:24:20 +01:00
Hans-Kristian Arntzen fd4488c3ab vkd3d: Optimise the GPU VA allocator.
The GPU VA allocator was allocating memory in a way where dereferencing
GPU VA required a lock + bsearch() to find the right VA range.

Rather than going this route, we turn the common case into O(1) and
lock-free by creating a slab allocator which allows us to lookup a
pointer directly from a GPU VA with (VA - Base) / PageSize.

The number of allocations in the fast path must be limited since we
cannot trivially grow the allocator while remaining lock-free for
dereferences.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-27 19:15:34 +01:00
Hans-Kristian Arntzen c7916314dc vkd3d: Align allocated GPU address ranges to the requested resource alignment.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-27 19:15:31 +01:00
Henri Verbeet 769dd2b68c vkd3d: Introduce vkd3d_format_get_data_offset().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-18 18:06:10 +02:00
Rémi Bernon 7ec32ebfc5 vkd3d: Introduce vkd3d_format_copy_data().
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-18 18:06:08 +02:00
Henri Verbeet 65417717ac vkd3d: Introduce d3d12_box_is_empty().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-18 18:06:06 +02:00
Conor McCarthy 8e6f5ddd24 vkd3d: Make all descriptor reads and writes atomic.
Shadow of the Tomb Raider overwrites descriptors while they are being
copied in another thread. This patch makes reads and writes atomic for
CBV, SRV, UAV, and sampler descriptors, but not RTV and DSV, for which
copying is not implemented.

Benchmark total frames vs mutex count (the single mutex was locked
only once for copying):

1 mutex:    6480 6489 6503
8 mutexes:  6691 6693 6661
16 mutexes: 6665 6682 6703

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-09-24 17:48:42 +02:00
Conor McCarthy 686eb92252 vkd3d: Use linear tiling for CPU readable textures.
Enables ReadFromSubresource() to succeed in cases where it would have
failed otherwise.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-12 09:31:11 +02:00
Józef Kucia 865fbea532 vkd3d: Remove unused d3d12_root_signature_init_descriptor_pool_size().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-06 17:05:12 +02:00
Józef Kucia 8df3bfc5c2 vkd3d: Prepend pNext chain structures.
Order of structures doesn't matter so we can simply prepend instead of
apending.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-06 17:05:07 +02:00
Józef Kucia 0184917520 vkd3d: Add support for VK_KHR_image_format_list.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-06 17:04:54 +02:00
Józef Kucia 0d851513dc vkd3d: Get rid of dxgi_format_is_typeless().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-07-31 08:31:56 +02:00
Jactry Zeng 9d138ee135 vkd3d: Handle SINT and UINT formats in ClearRenderTargetView().
Signed-off-by: Jactry Zeng <jzeng@codeweavers.com>
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-07-31 08:31:53 +02:00
Józef Kucia d9da1c904e vkd3d: Store vkd3d_format in {dsv,rtv}_desc.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-07-31 08:31:50 +02:00
Józef Kucia 56d260b40e vkd3d: Use vk_append_struct() in more places.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-07-31 08:24:42 +02:00
Józef Kucia ee7d24a213 vkd3d: Add support for VK_EXT_shader_demote_to_helper_invocation.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-07-31 08:24:38 +02:00
Józef Kucia 46ff2c2764 vkd3d: Add support for VK_EXT_texel_buffer_alignment.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-07-05 17:52:13 +02:00
Józef Kucia 69e73a6a8f vkd3d: Implement D3D12_FEATURE_FORMAT_INFO.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-28 08:10:53 +02:00
Józef Kucia dc074af2a0 vkd3d: Make resource mapping thread-safe.
VkDeviceMemory must be externally synchronized.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-21 08:09:21 +02:00
Józef Kucia fb8f0dc5b3 vkd3d: Create private heap objects for committed resources.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-21 08:09:20 +02:00
Józef Kucia dc2ae75461 vkd3d: Return more information from device memory allocation functions.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-21 08:09:18 +02:00
Józef Kucia 110830aca0 vkd3d: Introduce d3d12_resource_is_cpu_accessible() helper.
The condition in d3d12_resource_is_cpu_accessible() is going to be
changed in the following commits.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-21 08:09:16 +02:00
Józef Kucia 1a42564eb9 vkd3d: Use vkd3d_waiting_fence structure in more places.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-18 16:40:43 +02:00
Józef Kucia 3d681737c9 vkd3d: Try to guess application name.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-18 16:40:41 +02:00
Conor McCarthy 901fb7e798 vkd3d: Implement d3d12_command_list_SetPredication().
Predicate arguments which are only non-zero in bit 32 or higher are not
supported. Predicates will not be applied to clear and copy commands because
Vulkan does not support predication of these command classes.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-17 20:53:39 +02:00
Józef Kucia 0baf0302d1 vkd3d: Avoid holding mutex while waiting for fences.
We maintain separate arrays for enqueued fences and fences owned by the
fence worker thread.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-13 20:56:35 +02:00
Józef Kucia 895aaa461b vkd3d: Clarify DSV attachment mask handling.
It isn't immediately obvious what "1u << graphics->rt_count" means.
Use dsv_attachment_mask() helper instead.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-12 22:37:37 +02:00
Józef Kucia 7ecd67aaa0 vkd3d: Factor out vkd3d_join_thread().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-11 23:25:51 +02:00
Józef Kucia bc5e8a9cc2 vkd3d: Factor out vkd3d_create_thread().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-11 23:25:49 +02:00
Józef Kucia 826190fc0e vkd3d: Prefer uint64_t to UINT64.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-11 23:25:44 +02:00
Józef Kucia afe7259242 vkd3d: Introduce helper functions to call ID3D12Device methods.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-10 12:24:40 +02:00
Józef Kucia 71ad883672 vkd3d: Implement d3d12_device_CreateReservedResource().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-05 16:46:34 +02:00
Józef Kucia 991e9b5fad vkd3d: Add partial support for 2D NULL UAV.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-04 17:57:59 +02:00