Commit Graph

349 Commits

Author SHA1 Message Date
Philip Rebohle 28bf2eec3e vkd3d: Rework static samplers.
Static samplers are embedded in the root signature, so we can create
a separate descriptor set layout and descriptor set which we only
need to rebind when the root signature itself changes.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 13:11:10 +01:00
Philip Rebohle ae12e22187 vkd3d: Rework root descriptor updates.
Updates the root descriptor set or push descriptor at draw time.
This fixes a potential issue with shader-based clear/copy commands
invalidating previously bound root descriptors.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 12:19:07 +01:00
Philip Rebohle 82bf3e810b vkd3d: Rework root descriptors.
Streamlines descriptor set layout creation for root descriptors.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 12:19:07 +01:00
Philip Rebohle 189bcd39af vkd3d: Store index of root descriptor set in root signature.
This allows us to put root descriptors into a set other than 0.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle 3f125ac919 vkd3d: Temporarily require VK_KHR_push_descriptor.
Allows us to more easily refactor root signature-related code
without having to worry about root descriptors for now.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
Philip Rebohle 0d071c9c37 vkd3d: Rename root signature descriptor set layout members.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-10 11:44:45 +01:00
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 dfa208f909 vkd3d: Remove d3d12_command_list_invalidate_bindings.
The primary purpose of this function was to invalidate UAV
counters upon binding a pipeline. This is no longer an issue
and we don't have any other per-pipeline bindings, so this
function can be dropped.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-03 20:58:46 +01:00
Philip Rebohle f3d89a548a vkd3d: Reintroduce UAV counters.
Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2020-03-02 12:16:30 +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 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 9c64642468 vkd3d: Add SetViewInstanceMask() to the ID3D12GraphicsCommandList1 interface.
This method was missing in version 10.0.15063.0 of the SDK, but is
present in version 10.0.18362.0, without a UUID change. Presumably that
means this was simply an omission in the older header, rather than an
API change in the newer header.

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:10 +01:00
Philip Rebohle a204a681a1 vkd3d: Handle DXGI_FORMAT_R11G11B10_FLOAT in d3d12_command_list_ClearUnorderedAccessViewUint().
There is no bit-compatible UINT format, so we'll use DXGI_FORMAT_R32_UINT.

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:07 +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
Philip Rebohle 72246862af vkd3d: Factor out root parameter invalidation.
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:13 +01:00
Philip Rebohle 79da30adc7 vkd3d: Defer compute pipeline update to Dispatch time.
Needed to support compute-based clear and copy operations.

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:09 +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
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
Rémi Bernon 832f47edd3 vkd3d: Clamp buffer image copy size to subresource dimensions.
This fixes a vulkan validation error.

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-27 19:20:27 +01:00
Conor McCarthy 2155748c41 vkd3d: Add support for multiplanar depth/stencil state transitions.
If separate transitions of the depth and stencil plane occur in the
same array of barriers, they will be consolidated into one Vulkan
layout transition. This can only be supported for combinations of
depth read and depth write states, or identical states.

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-10-27 19:14:38 +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
Hans-Kristian Arntzen a0ebcce398 vkd3d: Do not use RESET_COMMAND_BUFFERS_BIT.
By setting this flag, command pools cannot efficiently pool allocations.
This flag should be set to 0 so only the VkCommandPool may be reset.
This matches D3D12 API.

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-01 19:16:16 +02:00
Hans-Kristian Arntzen 3c86b2341c vkd3d: Do not release resources in vkResetCommandPool.
D3D12 command allocators are intended to recycle memory across resets,
so we should do the same thing in vkd3d.

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-01 19:16:12 +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 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 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 ed8bd8cd59 vkd3d: Implement D3D12_RESOURCE_STATE_PREDICATION resource barriers.
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:41:11 +02:00
Józef Kucia 16c62ded81 vkd3d: End conditional rendering before ending command buffer.
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:41:07 +02:00
Józef Kucia 9939712560 vkd3d: Begin and end conditional rendering outside render passes.
The Vulkan spec says:

  "Conditional rendering must also either begin and end inside the same
  subpass of a render pass instance, or must both begin and end outside
  of a render pass instance (i.e. contain entire render pass instances)."

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:41:04 +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 e912a2c329 vkd3d: Validate resource pointer for transition barriers.
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:33 +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 206fd23afe vkd3d: Avoid busy-waiting in fence worker thread.
This might delay updating a d3d12_fence when a fence enqueued later than
other fences is signaled before them. On the other hand, it
significantly reduces CPU usage. I haven't found a program negatively
impacted by this change so far.

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:38 +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 285a19408f vkd3d: Introduce FIXME_ONCE().
The debug log level is demoted to WARN after the FIXME is printed once.

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:44 +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 28f99600a5 vkd3d: Avoid allocating memory in d3d12_command_list_update_uav_counter_descriptors().
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:42 +02:00
Józef Kucia 6862f34004 vkd3d: Avoid allocating memory in d3d12_command_list_RSSetScissorRects().
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:39 +02:00
Józef Kucia 812878fa87 vkd3d: Emit barriers in ClearUnorderedAccessViewUint().
We use transfer operations instead of unordered access.

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:30 +02:00
Józef Kucia 3abfb840fd vkd3d: Invalidate current pipeline when DSV format is changed.
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:26 +02:00