Skip to content

Commit

Permalink
vkd3d: Add config option for copy_buffer_sync.
Browse files Browse the repository at this point in the history
Signed-off-by: Hans-Kristian Arntzen <[email protected]>
  • Loading branch information
HansKristian-Work committed Aug 27, 2024
1 parent 5b2f42d commit 8fc0fa3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/vkd3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ extern "C" {
#define VKD3D_CONFIG_FLAG_SMALL_VRAM_REBAR (1ull << 49)
#define VKD3D_CONFIG_FLAG_NO_STAGGERED_SUBMIT (1ull << 50)
#define VKD3D_CONFIG_FLAG_CLEAR_UAV_SYNC (1ull << 51)
#define VKD3D_CONFIG_FLAG_COPY_BUFFER_SYNC (1ull << 52)

struct vkd3d_instance;

Expand Down
34 changes: 34 additions & 0 deletions libs/vkd3d/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -7451,6 +7451,28 @@ static void STDMETHODCALLTYPE d3d12_command_list_Dispatch(d3d12_command_list_ifa
d3d12_command_list_check_compute_barrier(list);
}

static void d3d12_command_list_full_transfer_barrier(struct d3d12_command_list *list)
{
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
VkMemoryBarrier2 vk_barrier;
VkDependencyInfo dep_info;

memset(&vk_barrier, 0, sizeof(vk_barrier));
memset(&dep_info, 0, sizeof(dep_info));
vk_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2;

dep_info.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO;
dep_info.memoryBarrierCount = 1;
dep_info.pMemoryBarriers = &vk_barrier;
vk_barrier.srcStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT;
vk_barrier.srcAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT;
vk_barrier.dstStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT;
vk_barrier.dstAccessMask = VK_ACCESS_2_MEMORY_WRITE_BIT | VK_ACCESS_2_MEMORY_READ_BIT;

VK_CALL(vkCmdPipelineBarrier2(list->cmd.vk_command_buffer, &dep_info));
d3d12_command_list_debug_mark_barrier(list, &dep_info);
}

static void STDMETHODCALLTYPE d3d12_command_list_CopyBufferRegion(d3d12_command_list_iface *iface,
ID3D12Resource *dst, UINT64 dst_offset, ID3D12Resource *src, UINT64 src_offset, UINT64 byte_count)
{
Expand Down Expand Up @@ -7505,6 +7527,12 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyBufferRegion(d3d12_command_
d3d12_command_list_debug_mark_execution(list, VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT);
VK_CALL(vkCmdCopyBuffer2(list->cmd.vk_command_buffer, &copy_info));

if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_COPY_BUFFER_SYNC)
{
list->tracked_copy_buffer_count = 0;
d3d12_command_list_full_transfer_barrier(list);
}

VKD3D_BREADCRUMB_COMMAND(COPY);
}

Expand Down Expand Up @@ -8418,6 +8446,12 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyResource(d3d12_command_list
!!(dst_resource->flags & VKD3D_RESOURCE_RESERVED));
d3d12_command_list_debug_mark_execution(list, VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT);
VK_CALL(vkCmdCopyBuffer2(list->cmd.vk_command_buffer, &copy_info));

if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_COPY_BUFFER_SYNC)
{
list->tracked_copy_buffer_count = 0;
d3d12_command_list_full_transfer_barrier(list);
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions libs/vkd3d/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ static const struct vkd3d_debug_option vkd3d_config_options[] =
{"small_vram_rebar", VKD3D_CONFIG_FLAG_SMALL_VRAM_REBAR},
{"no_staggered_submit", VKD3D_CONFIG_FLAG_NO_STAGGERED_SUBMIT},
{"clear_uav_sync", VKD3D_CONFIG_FLAG_CLEAR_UAV_SYNC},
{"copy_buffer_sync", VKD3D_CONFIG_FLAG_COPY_BUFFER_SYNC},
};

static void vkd3d_config_flags_init_once(void)
Expand Down

0 comments on commit 8fc0fa3

Please sign in to comment.