mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
anv,wsi: simplify WSI synchronization
Rather than using 2 vfuncs, use one since we've unified the synchronization framework in the runtime with a single vk_sync object. v2 (Jason Ekstrand): - create_sync_for_memory is now in vk_device Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14237>
This commit is contained in:
parent
9ae1e621e5
commit
b00086d393
3 changed files with 33 additions and 60 deletions
|
|
@ -36,47 +36,6 @@ anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
|
|||
return vk_instance_get_proc_addr_unchecked(&pdevice->instance->vk, pName);
|
||||
}
|
||||
|
||||
static void
|
||||
anv_wsi_signal_semaphore_for_memory(VkDevice _device,
|
||||
VkSemaphore _semaphore,
|
||||
VkDeviceMemory _memory)
|
||||
{
|
||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
VK_FROM_HANDLE(vk_semaphore, semaphore, _semaphore);
|
||||
ANV_FROM_HANDLE(anv_device_memory, memory, _memory);
|
||||
ASSERTED VkResult result;
|
||||
|
||||
/* Put a BO semaphore with the image BO in the temporary. For BO binary
|
||||
* semaphores, we always set EXEC_OBJECT_WRITE so this creates a WaR
|
||||
* hazard with the display engine's read to ensure that no one writes to
|
||||
* the image before the read is complete.
|
||||
*/
|
||||
vk_semaphore_reset_temporary(&device->vk, semaphore);
|
||||
|
||||
result = anv_sync_create_for_bo(device, memory->bo, &semaphore->temporary);
|
||||
assert(result == VK_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
anv_wsi_signal_fence_for_memory(VkDevice _device,
|
||||
VkFence _fence,
|
||||
VkDeviceMemory _memory)
|
||||
{
|
||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
VK_FROM_HANDLE(vk_fence, fence, _fence);
|
||||
ANV_FROM_HANDLE(anv_device_memory, memory, _memory);
|
||||
ASSERTED VkResult result;
|
||||
|
||||
/* Put a BO fence with the image BO in the temporary. For BO fences, we
|
||||
* always just wait until the BO isn't busy and reads from the BO should
|
||||
* count as busy.
|
||||
*/
|
||||
vk_fence_reset_temporary(&device->vk, fence);
|
||||
|
||||
result = anv_sync_create_for_bo(device, memory->bo, &fence->temporary);
|
||||
assert(result == VK_SUCCESS);
|
||||
}
|
||||
|
||||
VkResult
|
||||
anv_init_wsi(struct anv_physical_device *physical_device)
|
||||
{
|
||||
|
|
@ -93,10 +52,8 @@ anv_init_wsi(struct anv_physical_device *physical_device)
|
|||
return result;
|
||||
|
||||
physical_device->wsi_device.supports_modifiers = true;
|
||||
physical_device->wsi_device.signal_semaphore_for_memory =
|
||||
anv_wsi_signal_semaphore_for_memory;
|
||||
physical_device->wsi_device.signal_fence_for_memory =
|
||||
anv_wsi_signal_fence_for_memory;
|
||||
physical_device->wsi_device.signal_semaphore_with_memory = true;
|
||||
physical_device->wsi_device.signal_fence_with_memory = true;
|
||||
|
||||
physical_device->vk.wsi_device = &physical_device->wsi_device;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,11 @@
|
|||
#include "util/os_file.h"
|
||||
#include "util/xmlconfig.h"
|
||||
#include "vk_device.h"
|
||||
#include "vk_fence.h"
|
||||
#include "vk_instance.h"
|
||||
#include "vk_physical_device.h"
|
||||
#include "vk_queue.h"
|
||||
#include "vk_semaphore.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
#include <time.h>
|
||||
|
|
@ -620,11 +622,12 @@ wsi_AcquireNextImageKHR(VkDevice _device,
|
|||
|
||||
VkResult
|
||||
wsi_common_acquire_next_image2(const struct wsi_device *wsi,
|
||||
VkDevice device,
|
||||
VkDevice _device,
|
||||
const VkAcquireNextImageInfoKHR *pAcquireInfo,
|
||||
uint32_t *pImageIndex)
|
||||
{
|
||||
VK_FROM_HANDLE(wsi_swapchain, swapchain, pAcquireInfo->swapchain);
|
||||
VK_FROM_HANDLE(vk_device, device, _device);
|
||||
|
||||
VkResult result = swapchain->acquire_next_image(swapchain, pAcquireInfo,
|
||||
pImageIndex);
|
||||
|
|
@ -637,19 +640,33 @@ wsi_common_acquire_next_image2(const struct wsi_device *wsi,
|
|||
}
|
||||
|
||||
if (pAcquireInfo->semaphore != VK_NULL_HANDLE &&
|
||||
wsi->signal_semaphore_for_memory != NULL) {
|
||||
wsi->signal_semaphore_with_memory) {
|
||||
VK_FROM_HANDLE(vk_semaphore, semaphore, pAcquireInfo->semaphore);
|
||||
struct wsi_image *image =
|
||||
swapchain->get_wsi_image(swapchain, *pImageIndex);
|
||||
wsi->signal_semaphore_for_memory(device, pAcquireInfo->semaphore,
|
||||
image->memory);
|
||||
|
||||
vk_semaphore_reset_temporary(device, semaphore);
|
||||
VkResult lresult =
|
||||
device->create_sync_for_memory(device, image->memory,
|
||||
false /* signal_memory */,
|
||||
&semaphore->temporary);
|
||||
if (lresult != VK_SUCCESS)
|
||||
return lresult;
|
||||
}
|
||||
|
||||
if (pAcquireInfo->fence != VK_NULL_HANDLE &&
|
||||
wsi->signal_fence_for_memory != NULL) {
|
||||
wsi->signal_fence_with_memory) {
|
||||
VK_FROM_HANDLE(vk_fence, fence, pAcquireInfo->fence);
|
||||
struct wsi_image *image =
|
||||
swapchain->get_wsi_image(swapchain, *pImageIndex);
|
||||
wsi->signal_fence_for_memory(device, pAcquireInfo->fence,
|
||||
image->memory);
|
||||
|
||||
vk_fence_reset_temporary(device, fence);
|
||||
VkResult lresult =
|
||||
device->create_sync_for_memory(device, image->memory,
|
||||
false /* signal_memory */,
|
||||
&fence->temporary);
|
||||
if (lresult != VK_SUCCESS)
|
||||
return lresult;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -135,19 +135,18 @@ struct wsi_device {
|
|||
|
||||
/* Signals the semaphore such that any wait on the semaphore will wait on
|
||||
* any reads or writes on the give memory object. This is used to
|
||||
* implement the semaphore signal operation in vkAcquireNextImage.
|
||||
* implement the semaphore signal operation in vkAcquireNextImage. This
|
||||
* requires the driver to implement vk_device::create_sync_for_memory.
|
||||
*/
|
||||
void (*signal_semaphore_for_memory)(VkDevice device,
|
||||
VkSemaphore semaphore,
|
||||
VkDeviceMemory memory);
|
||||
bool signal_semaphore_with_memory;
|
||||
|
||||
/* Signals the fence such that any wait on the fence will wait on any reads
|
||||
* or writes on the give memory object. This is used to implement the
|
||||
* semaphore signal operation in vkAcquireNextImage.
|
||||
* semaphore signal operation in vkAcquireNextImage. This requires the
|
||||
* driver to implement vk_device::create_sync_for_memory. The resulting
|
||||
* vk_sync must support CPU waits.
|
||||
*/
|
||||
void (*signal_fence_for_memory)(VkDevice device,
|
||||
VkFence fence,
|
||||
VkDeviceMemory memory);
|
||||
bool signal_fence_with_memory;
|
||||
|
||||
/*
|
||||
* This sets the ownership for a WSI memory object:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue