Skip to content

Commit

Permalink
vkd3d: Add config option to sync ClearUAVs.
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 6, 2024
1 parent 43ca198 commit d15f4c7
Show file tree
Hide file tree
Showing 3 changed files with 30 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 @@ -104,6 +104,7 @@ extern "C" {
#define VKD3D_CONFIG_FLAG_DISABLE_NV_DGCC (1ull << 46)
#define VKD3D_CONFIG_FLAG_MEMORY_ALLOCATOR_SKIP_IMAGE_HEAP_CLEAR (1ull << 47)
#define VKD3D_CONFIG_FLAG_DRIVER_VERSION_SENSITIVE_SHADERS (1ull << 48)
#define VKD3D_CONFIG_FLAG_CLEAR_UAV_SYNC (1ull << 49)

struct vkd3d_instance;

Expand Down
28 changes: 28 additions & 0 deletions libs/vkd3d/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -11578,6 +11578,28 @@ struct vkd3d_clear_uav_info
} u;
};

static void d3d12_command_list_clear_uav_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_queue_shader_stages(list->vk_queue_flags);
vk_barrier.srcAccessMask = VK_ACCESS_2_SHADER_WRITE_BIT;
vk_barrier.dstStageMask = vk_barrier.srcStageMask;
vk_barrier.dstAccessMask = VK_ACCESS_2_SHADER_WRITE_BIT;

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

static void d3d12_command_list_clear_uav(struct d3d12_command_list *list,
struct d3d12_resource *resource, const struct vkd3d_clear_uav_info *args,
const VkClearColorValue *clear_color, UINT rect_count, const D3D12_RECT *rects)
Expand Down Expand Up @@ -11704,6 +11726,9 @@ static void d3d12_command_list_clear_uav(struct d3d12_command_list *list,
VK_CALL(vkCmdPushDescriptorSetKHR(list->cmd.vk_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE,
pipeline.vk_pipeline_layout, 0, 1, &write_set));

if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_CLEAR_UAV_SYNC)
d3d12_command_list_clear_uav_barrier(list);

for (i = 0; i < rect_count || !i; i++)
{
if (rect_count)
Expand Down Expand Up @@ -11743,6 +11768,9 @@ static void d3d12_command_list_clear_uav(struct d3d12_command_list *list,
}

d3d12_command_list_debug_mark_execution(list, VK_PIPELINE_STAGE_2_CLEAR_BIT);
if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_CLEAR_UAV_SYNC)
d3d12_command_list_clear_uav_barrier(list);

d3d12_command_list_debug_mark_end_region(list);
}

Expand Down
1 change: 1 addition & 0 deletions libs/vkd3d/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ static const struct vkd3d_debug_option vkd3d_config_options[] =
{"disable_depth_compression", VKD3D_CONFIG_FLAG_DISABLE_DEPTH_COMPRESSION},
{"disable_color_compression", VKD3D_CONFIG_FLAG_DISABLE_COLOR_COMPRESSION},
{"app_debug_marker_only", VKD3D_CONFIG_FLAG_APP_DEBUG_MARKER_ONLY},
{"clear_uav_sync", VKD3D_CONFIG_FLAG_CLEAR_UAV_SYNC},
};

static void vkd3d_config_flags_init_once(void)
Expand Down

0 comments on commit d15f4c7

Please sign in to comment.