radv: Delete lots of sync code.
This make things all fall back to the common synchronization functions which will switch things to the new submission path and to use vk_fence and vk_semaphore. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> radv: Use common AcquireNextImage2KHR. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> radv: Use common functions for Metro Exodus layer. Needs to be squashed with the big "switch the world" deletion patch but kept it separate for review. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13974>
This commit is contained in:
parent
967fc415fc
commit
91fe0b5629
|
@ -22,17 +22,16 @@
|
|||
*/
|
||||
|
||||
#include "radv_private.h"
|
||||
#include "vk_common_entrypoints.h"
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
metro_exodus_GetSemaphoreCounterValue(VkDevice _device, VkSemaphore _semaphore, uint64_t *pValue)
|
||||
{
|
||||
RADV_FROM_HANDLE(radv_semaphore, semaphore, _semaphore);
|
||||
|
||||
/* See https://gitlab.freedesktop.org/mesa/mesa/-/issues/5119. */
|
||||
if (semaphore == NULL) {
|
||||
if (_semaphore == VK_NULL_HANDLE) {
|
||||
fprintf(stderr, "RADV: Ignoring vkGetSemaphoreCounterValue() with NULL semaphore (game bug)!\n");
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
return radv_GetSemaphoreCounterValue(_device, _semaphore, pValue);
|
||||
return vk_common_GetSemaphoreCounterValue(_device, _semaphore, pValue);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "util/os_file.h"
|
||||
|
||||
#include "radv_private.h"
|
||||
#include "vk_common_entrypoints.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
|
@ -426,7 +427,7 @@ radv_AcquireImageANDROID(VkDevice device_h, VkImage image_h, int nativeFenceFd,
|
|||
.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
|
||||
.fd = semaphore_fd,
|
||||
};
|
||||
result = radv_ImportSemaphoreFdKHR(device_h, &info);
|
||||
result = vk_common_ImportSemaphoreFdKHR(device_h, &info);
|
||||
if (result == VK_SUCCESS)
|
||||
semaphore_fd = -1; /* RADV took ownership */
|
||||
}
|
||||
|
@ -439,7 +440,7 @@ radv_AcquireImageANDROID(VkDevice device_h, VkImage image_h, int nativeFenceFd,
|
|||
.handleType = VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT,
|
||||
.fd = fence_fd,
|
||||
};
|
||||
result = radv_ImportFenceFdKHR(device_h, &info);
|
||||
result = vk_common_ImportFenceFdKHR(device_h, &info);
|
||||
if (result == VK_SUCCESS)
|
||||
fence_fd = -1; /* RADV took ownership */
|
||||
}
|
||||
|
@ -471,13 +472,13 @@ radv_QueueSignalReleaseImageANDROID(VkQueue _queue, uint32_t waitSemaphoreCount,
|
|||
for (uint32_t i = 0; i < waitSemaphoreCount; ++i) {
|
||||
int tmp_fd;
|
||||
result =
|
||||
radv_GetSemaphoreFdKHR(radv_device_to_handle(queue->device),
|
||||
&(VkSemaphoreGetFdInfoKHR){
|
||||
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR,
|
||||
.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
|
||||
.semaphore = pWaitSemaphores[i],
|
||||
},
|
||||
&tmp_fd);
|
||||
vk_common_GetSemaphoreFdKHR(radv_device_to_handle(queue->device),
|
||||
&(VkSemaphoreGetFdInfoKHR){
|
||||
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR,
|
||||
.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
|
||||
.semaphore = pWaitSemaphores[i],
|
||||
},
|
||||
&tmp_fd);
|
||||
if (result != VK_SUCCESS) {
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -722,17 +722,6 @@ struct radv_queue {
|
|||
struct radeon_cmdbuf *initial_preamble_cs;
|
||||
struct radeon_cmdbuf *initial_full_flush_preamble_cs;
|
||||
struct radeon_cmdbuf *continue_preamble_cs;
|
||||
|
||||
struct list_head pending_submissions;
|
||||
mtx_t pending_mutex;
|
||||
|
||||
mtx_t thread_mutex;
|
||||
struct u_cnd_monotonic thread_cond;
|
||||
struct radv_deferred_queue_submission *thread_submission;
|
||||
thrd_t submission_thread;
|
||||
bool thread_exit;
|
||||
bool thread_running;
|
||||
bool cond_created;
|
||||
};
|
||||
|
||||
#define RADV_BORDER_COLOR_COUNT 4096
|
||||
|
@ -2554,71 +2543,6 @@ struct radv_query_pool {
|
|||
uint32_t pipeline_stats_mask;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
RADV_SEMAPHORE_NONE,
|
||||
RADV_SEMAPHORE_SYNCOBJ,
|
||||
RADV_SEMAPHORE_TIMELINE_SYNCOBJ,
|
||||
RADV_SEMAPHORE_TIMELINE,
|
||||
} radv_semaphore_kind;
|
||||
|
||||
struct radv_deferred_queue_submission;
|
||||
|
||||
struct radv_timeline_waiter {
|
||||
struct list_head list;
|
||||
struct radv_deferred_queue_submission *submission;
|
||||
uint64_t value;
|
||||
};
|
||||
|
||||
struct radv_timeline_point {
|
||||
struct list_head list;
|
||||
|
||||
uint64_t value;
|
||||
uint32_t syncobj;
|
||||
|
||||
/* Separate from the list to accomodate CPU wait being async, as well
|
||||
* as prevent point deletion during submission. */
|
||||
unsigned wait_count;
|
||||
};
|
||||
|
||||
struct radv_timeline {
|
||||
mtx_t mutex;
|
||||
|
||||
uint64_t highest_signaled;
|
||||
uint64_t highest_submitted;
|
||||
|
||||
struct list_head points;
|
||||
|
||||
/* Keep free points on hand so we do not have to recreate syncobjs all
|
||||
* the time. */
|
||||
struct list_head free_points;
|
||||
|
||||
/* Submissions that are deferred waiting for a specific value to be
|
||||
* submitted. */
|
||||
struct list_head waiters;
|
||||
};
|
||||
|
||||
struct radv_timeline_syncobj {
|
||||
/* Keep syncobj first, so common-code can just handle this as
|
||||
* non-timeline syncobj. */
|
||||
uint32_t syncobj;
|
||||
uint64_t max_point; /* max submitted point. */
|
||||
};
|
||||
|
||||
struct radv_semaphore_part {
|
||||
radv_semaphore_kind kind;
|
||||
union {
|
||||
uint32_t syncobj;
|
||||
struct radv_timeline timeline;
|
||||
struct radv_timeline_syncobj timeline_syncobj;
|
||||
};
|
||||
};
|
||||
|
||||
struct radv_semaphore {
|
||||
struct vk_object_base base;
|
||||
struct radv_semaphore_part permanent;
|
||||
struct radv_semaphore_part temporary;
|
||||
};
|
||||
|
||||
bool radv_queue_internal_submit(struct radv_queue *queue, struct radeon_cmdbuf *cs);
|
||||
|
||||
void radv_set_descriptor_set(struct radv_cmd_buffer *cmd_buffer, VkPipelineBindPoint bind_point,
|
||||
|
@ -2647,24 +2571,6 @@ uint32_t radv_init_dcc(struct radv_cmd_buffer *cmd_buffer, struct radv_image *im
|
|||
uint32_t radv_init_fmask(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image,
|
||||
const VkImageSubresourceRange *range);
|
||||
|
||||
typedef enum {
|
||||
RADV_FENCE_NONE,
|
||||
RADV_FENCE_SYNCOBJ,
|
||||
} radv_fence_kind;
|
||||
|
||||
struct radv_fence_part {
|
||||
radv_fence_kind kind;
|
||||
|
||||
/* DRM syncobj handle for syncobj-based fences. */
|
||||
uint32_t syncobj;
|
||||
};
|
||||
|
||||
struct radv_fence {
|
||||
struct vk_object_base base;
|
||||
struct radv_fence_part permanent;
|
||||
struct radv_fence_part temporary;
|
||||
};
|
||||
|
||||
/* radv_nir_to_llvm.c */
|
||||
struct radv_shader_args;
|
||||
struct radv_nir_compiler_options;
|
||||
|
@ -2974,7 +2880,6 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_update_template, base,
|
|||
VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_device_memory, base, VkDeviceMemory,
|
||||
VK_OBJECT_TYPE_DEVICE_MEMORY)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_fence, base, VkFence, VK_OBJECT_TYPE_FENCE)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_event, base, VkEvent, VK_OBJECT_TYPE_EVENT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_framebuffer, base, VkFramebuffer,
|
||||
VK_OBJECT_TYPE_FRAMEBUFFER)
|
||||
|
@ -2996,8 +2901,6 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(radv_sampler, base, VkSampler,
|
|||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_sampler_ycbcr_conversion, base,
|
||||
VkSamplerYcbcrConversion,
|
||||
VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_semaphore, base, VkSemaphore,
|
||||
VK_OBJECT_TYPE_SEMAPHORE)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -172,20 +172,6 @@ struct radeon_winsys_bo {
|
|||
bool use_global_list;
|
||||
enum radeon_bo_domain initial_domain;
|
||||
};
|
||||
struct radv_winsys_sem_counts {
|
||||
uint32_t syncobj_count;
|
||||
uint32_t syncobj_reset_count; /* for wait only, whether to reset the syncobj */
|
||||
uint32_t timeline_syncobj_count;
|
||||
uint32_t *syncobj;
|
||||
uint64_t *points;
|
||||
};
|
||||
|
||||
struct radv_winsys_sem_info {
|
||||
bool cs_emit_signal;
|
||||
bool cs_emit_wait;
|
||||
struct radv_winsys_sem_counts wait;
|
||||
struct radv_winsys_sem_counts signal;
|
||||
};
|
||||
|
||||
struct radv_winsys_bo_list {
|
||||
struct radeon_winsys_bo **bos;
|
||||
|
@ -276,12 +262,6 @@ struct radeon_winsys {
|
|||
|
||||
void (*cs_grow)(struct radeon_cmdbuf *cs, size_t min_size);
|
||||
|
||||
VkResult (*cs_submit)(struct radeon_winsys_ctx *ctx, enum ring_type ring_type, int queue_index,
|
||||
struct radeon_cmdbuf **cs_array, unsigned cs_count,
|
||||
struct radeon_cmdbuf *initial_preamble_cs,
|
||||
struct radeon_cmdbuf *continue_preamble_cs,
|
||||
struct radv_winsys_sem_info *sem_info, bool can_patch);
|
||||
|
||||
VkResult (*cs_submit2)(struct radeon_winsys_ctx *ctx, enum ring_type ring_type, int queue_index,
|
||||
struct radeon_cmdbuf **cs_array, unsigned cs_count,
|
||||
struct radeon_cmdbuf *initial_preamble_cs,
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "util/macros.h"
|
||||
#include "radv_meta.h"
|
||||
#include "radv_private.h"
|
||||
#include "vk_fence.h"
|
||||
#include "vk_semaphore.h"
|
||||
#include "vk_util.h"
|
||||
#include "wsi_common.h"
|
||||
|
||||
|
@ -59,6 +61,8 @@ radv_init_wsi(struct radv_physical_device *physical_device)
|
|||
|
||||
physical_device->wsi_device.supports_modifiers = physical_device->rad_info.chip_class >= GFX9;
|
||||
physical_device->wsi_device.set_memory_ownership = radv_wsi_set_memory_ownership;
|
||||
physical_device->wsi_device.signal_semaphore_with_memory = true;
|
||||
physical_device->wsi_device.signal_fence_with_memory = true;
|
||||
|
||||
wsi_device_setup_syncobj_fd(&physical_device->wsi_device, physical_device->local_fd);
|
||||
|
||||
|
@ -74,46 +78,6 @@ radv_finish_wsi(struct radv_physical_device *physical_device)
|
|||
wsi_device_finish(&physical_device->wsi_device, &physical_device->instance->vk.alloc);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
radv_AcquireNextImage2KHR(VkDevice _device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
|
||||
uint32_t *pImageIndex)
|
||||
{
|
||||
RADV_FROM_HANDLE(radv_device, device, _device);
|
||||
struct radv_physical_device *pdevice = device->physical_device;
|
||||
RADV_FROM_HANDLE(radv_fence, fence, pAcquireInfo->fence);
|
||||
RADV_FROM_HANDLE(radv_semaphore, semaphore, pAcquireInfo->semaphore);
|
||||
|
||||
VkResult result =
|
||||
wsi_common_acquire_next_image2(&pdevice->wsi_device, _device, pAcquireInfo, pImageIndex);
|
||||
|
||||
if (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR) {
|
||||
if (fence) {
|
||||
struct radv_fence_part *part =
|
||||
fence->temporary.kind != RADV_FENCE_NONE ? &fence->temporary : &fence->permanent;
|
||||
|
||||
device->ws->signal_syncobj(device->ws, part->syncobj, 0);
|
||||
}
|
||||
if (semaphore) {
|
||||
struct radv_semaphore_part *part = semaphore->temporary.kind != RADV_SEMAPHORE_NONE
|
||||
? &semaphore->temporary
|
||||
: &semaphore->permanent;
|
||||
|
||||
switch (part->kind) {
|
||||
case RADV_SEMAPHORE_NONE:
|
||||
/* Do not need to do anything. */
|
||||
break;
|
||||
case RADV_SEMAPHORE_TIMELINE:
|
||||
case RADV_SEMAPHORE_TIMELINE_SYNCOBJ:
|
||||
unreachable("WSI only allows binary semaphores.");
|
||||
case RADV_SEMAPHORE_SYNCOBJ:
|
||||
device->ws->signal_syncobj(device->ws, part->syncobj, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
radv_QueuePresentKHR(VkQueue _queue, const VkPresentInfoKHR *pPresentInfo)
|
||||
{
|
||||
|
|
|
@ -83,6 +83,21 @@ struct radv_amdgpu_cs {
|
|||
unsigned num_old_cs_buffers;
|
||||
};
|
||||
|
||||
struct radv_winsys_sem_counts {
|
||||
uint32_t syncobj_count;
|
||||
uint32_t syncobj_reset_count; /* for wait only, whether to reset the syncobj */
|
||||
uint32_t timeline_syncobj_count;
|
||||
uint32_t *syncobj;
|
||||
uint64_t *points;
|
||||
};
|
||||
|
||||
struct radv_winsys_sem_info {
|
||||
bool cs_emit_signal;
|
||||
bool cs_emit_wait;
|
||||
struct radv_winsys_sem_counts wait;
|
||||
struct radv_winsys_sem_counts signal;
|
||||
};
|
||||
|
||||
static uint32_t radv_amdgpu_ctx_queue_syncobj(struct radv_amdgpu_ctx *ctx, unsigned ip,
|
||||
unsigned ring);
|
||||
|
||||
|
@ -1992,7 +2007,6 @@ radv_amdgpu_cs_init_functions(struct radv_amdgpu_winsys *ws)
|
|||
ws->base.cs_reset = radv_amdgpu_cs_reset;
|
||||
ws->base.cs_add_buffer = radv_amdgpu_cs_add_buffer;
|
||||
ws->base.cs_execute_secondary = radv_amdgpu_cs_execute_secondary;
|
||||
ws->base.cs_submit = radv_amdgpu_winsys_cs_submit;
|
||||
ws->base.cs_submit2 = radv_amdgpu_winsys_cs_submit2;
|
||||
ws->base.cs_dump = radv_amdgpu_winsys_cs_dump;
|
||||
ws->base.create_syncobj = radv_amdgpu_create_syncobj;
|
||||
|
|
Loading…
Reference in New Issue