2015-09-02 01:00:10 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2015 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2016-10-14 05:42:29 +01:00
|
|
|
#include "anv_private.h"
|
2021-01-06 03:34:51 +00:00
|
|
|
#include "anv_measure.h"
|
2016-10-14 05:42:29 +01:00
|
|
|
#include "wsi_common.h"
|
2021-10-20 15:44:02 +01:00
|
|
|
#include "vk_fence.h"
|
|
|
|
#include "vk_queue.h"
|
|
|
|
#include "vk_semaphore.h"
|
2017-06-06 12:31:05 +01:00
|
|
|
#include "vk_util.h"
|
2016-10-14 05:14:45 +01:00
|
|
|
|
2017-11-16 02:50:44 +00:00
|
|
|
static PFN_vkVoidFunction
|
|
|
|
anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
|
|
|
|
{
|
2021-01-23 10:57:21 +00:00
|
|
|
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
|
|
|
|
return vk_instance_get_proc_addr_unchecked(&pdevice->instance->vk, pName);
|
2017-11-16 02:50:44 +00:00
|
|
|
}
|
|
|
|
|
2015-09-04 19:14:45 +01:00
|
|
|
VkResult
|
2016-05-16 06:21:24 +01:00
|
|
|
anv_init_wsi(struct anv_physical_device *physical_device)
|
2015-09-04 19:14:45 +01:00
|
|
|
{
|
2017-11-14 00:44:07 +00:00
|
|
|
VkResult result;
|
|
|
|
|
|
|
|
result = wsi_device_init(&physical_device->wsi_device,
|
|
|
|
anv_physical_device_to_handle(physical_device),
|
|
|
|
anv_wsi_proc_addr,
|
2021-01-23 10:57:21 +00:00
|
|
|
&physical_device->instance->vk.alloc,
|
2019-04-17 00:30:49 +01:00
|
|
|
physical_device->master_fd,
|
2020-06-19 07:37:51 +01:00
|
|
|
&physical_device->instance->dri_options,
|
|
|
|
false);
|
2017-11-14 00:44:07 +00:00
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
physical_device->wsi_device.supports_modifiers = true;
|
2021-12-15 09:52:44 +00:00
|
|
|
physical_device->wsi_device.signal_semaphore_with_memory = true;
|
|
|
|
physical_device->wsi_device.signal_fence_with_memory = true;
|
2017-11-14 00:44:07 +00:00
|
|
|
|
2021-10-06 17:21:55 +01:00
|
|
|
physical_device->vk.wsi_device = &physical_device->wsi_device;
|
|
|
|
|
2021-10-14 12:45:19 +01:00
|
|
|
wsi_device_setup_syncobj_fd(&physical_device->wsi_device,
|
|
|
|
physical_device->local_fd);
|
|
|
|
|
2017-11-14 00:44:07 +00:00
|
|
|
return VK_SUCCESS;
|
2015-09-04 19:14:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-05-16 06:21:24 +01:00
|
|
|
anv_finish_wsi(struct anv_physical_device *physical_device)
|
2015-09-04 19:14:45 +01:00
|
|
|
{
|
2021-10-06 17:21:55 +01:00
|
|
|
physical_device->vk.wsi_device = NULL;
|
2017-11-16 20:49:27 +00:00
|
|
|
wsi_device_finish(&physical_device->wsi_device,
|
2021-01-23 10:57:21 +00:00
|
|
|
&physical_device->instance->vk.alloc);
|
2015-09-04 19:14:45 +01:00
|
|
|
}
|
|
|
|
|
2022-02-11 17:28:08 +00:00
|
|
|
VkResult anv_AcquireNextImage2KHR(
|
|
|
|
VkDevice _device,
|
|
|
|
const VkAcquireNextImageInfoKHR *pAcquireInfo,
|
|
|
|
uint32_t *pImageIndex)
|
|
|
|
{
|
|
|
|
VK_FROM_HANDLE(anv_device, device, _device);
|
|
|
|
|
|
|
|
VkResult result =
|
|
|
|
wsi_common_acquire_next_image2(&device->physical->wsi_device,
|
|
|
|
_device, pAcquireInfo, pImageIndex);
|
|
|
|
if (result == VK_SUCCESS)
|
|
|
|
anv_measure_acquire(device);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-12-03 00:28:36 +00:00
|
|
|
VkResult anv_QueuePresentKHR(
|
2015-09-02 02:59:06 +01:00
|
|
|
VkQueue _queue,
|
2015-12-03 00:28:36 +00:00
|
|
|
const VkPresentInfoKHR* pPresentInfo)
|
2015-09-02 02:59:06 +01:00
|
|
|
{
|
|
|
|
ANV_FROM_HANDLE(anv_queue, queue, _queue);
|
2020-03-04 23:15:57 +00:00
|
|
|
struct anv_device *device = queue->device;
|
2021-10-20 15:44:02 +01:00
|
|
|
VkResult result;
|
2020-03-04 23:15:57 +00:00
|
|
|
|
|
|
|
if (device->debug_frame_desc) {
|
|
|
|
device->debug_frame_desc->frame_id++;
|
|
|
|
if (!device->info.has_llc) {
|
2021-04-07 21:22:19 +01:00
|
|
|
intel_clflush_range(device->debug_frame_desc,
|
2020-03-04 23:15:57 +00:00
|
|
|
sizeof(*device->debug_frame_desc));
|
|
|
|
}
|
|
|
|
}
|
2015-09-02 02:59:06 +01:00
|
|
|
|
2021-10-20 15:44:02 +01:00
|
|
|
result = vk_queue_wait_before_present(&queue->vk, pPresentInfo);
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
return result;
|
2019-08-28 11:22:30 +01:00
|
|
|
|
2021-10-20 15:44:02 +01:00
|
|
|
result = wsi_common_queue_present(&device->physical->wsi_device,
|
|
|
|
anv_device_to_handle(queue->device),
|
|
|
|
_queue, 0,
|
|
|
|
pPresentInfo);
|
2019-08-28 11:22:30 +01:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < pPresentInfo->waitSemaphoreCount; i++) {
|
2021-10-20 15:44:02 +01:00
|
|
|
VK_FROM_HANDLE(vk_semaphore, semaphore, pPresentInfo->pWaitSemaphores[i]);
|
2019-08-28 11:22:30 +01:00
|
|
|
/* From the Vulkan 1.0.53 spec:
|
|
|
|
*
|
|
|
|
* "If the import is temporary, the implementation must restore the
|
|
|
|
* semaphore to its prior permanent state after submitting the next
|
|
|
|
* semaphore wait operation."
|
|
|
|
*/
|
2021-10-20 15:44:02 +01:00
|
|
|
vk_semaphore_reset_temporary(&queue->device->vk, semaphore);
|
2019-08-28 11:22:30 +01:00
|
|
|
}
|
|
|
|
|
2021-11-21 16:23:57 +00:00
|
|
|
u_trace_context_process(&device->ds.trace_context, true);
|
2021-11-18 15:45:57 +00:00
|
|
|
|
2019-08-28 11:22:30 +01:00
|
|
|
return result;
|
2015-09-02 02:59:06 +01:00
|
|
|
}
|