2015-09-01 17:00:10 -07: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-05 19:34:51 -08:00
|
|
|
#include "anv_measure.h"
|
2016-10-14 05:42:29 +01:00
|
|
|
#include "wsi_common.h"
|
2021-10-20 09:44:02 -05: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-15 18:50:44 -08:00
|
|
|
static PFN_vkVoidFunction
|
|
|
|
|
anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
|
|
|
|
|
{
|
2021-01-23 04:57:21 -06:00
|
|
|
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
|
|
|
|
|
return vk_instance_get_proc_addr_unchecked(&pdevice->instance->vk, pName);
|
2017-11-15 18:50:44 -08:00
|
|
|
}
|
|
|
|
|
|
2023-02-09 06:36:59 +10:00
|
|
|
static VkQueue
|
|
|
|
|
anv_wsi_get_prime_blit_queue(VkDevice _device)
|
|
|
|
|
{
|
|
|
|
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
|
|
|
|
|
|
|
|
|
vk_foreach_queue(_queue, &device->vk) {
|
|
|
|
|
struct anv_queue *queue = (struct anv_queue *)_queue;
|
|
|
|
|
if (queue->family->queueFlags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT))
|
|
|
|
|
return vk_queue_to_handle(_queue);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-04 11:14:45 -07:00
|
|
|
VkResult
|
2016-05-15 22:21:24 -07:00
|
|
|
anv_init_wsi(struct anv_physical_device *physical_device)
|
2015-09-04 11:14:45 -07:00
|
|
|
{
|
2017-11-13 16:44:07 -08: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 04:57:21 -06:00
|
|
|
&physical_device->instance->vk.alloc,
|
2019-04-17 01:30:49 +02:00
|
|
|
physical_device->master_fd,
|
2020-06-19 16:37:51 +10:00
|
|
|
&physical_device->instance->dri_options,
|
2023-02-21 08:40:23 -05:00
|
|
|
&(struct wsi_device_options){.sw_device = false});
|
2017-11-13 16:44:07 -08:00
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
physical_device->wsi_device.supports_modifiers = true;
|
2021-12-15 11:52:44 +02:00
|
|
|
physical_device->wsi_device.signal_semaphore_with_memory = true;
|
|
|
|
|
physical_device->wsi_device.signal_fence_with_memory = true;
|
2023-02-09 06:36:59 +10:00
|
|
|
physical_device->wsi_device.get_blit_queue = anv_wsi_get_prime_blit_queue;
|
2017-11-13 16:44:07 -08:00
|
|
|
|
2021-10-06 11:21:55 -05:00
|
|
|
physical_device->vk.wsi_device = &physical_device->wsi_device;
|
|
|
|
|
|
2021-10-14 14:45:19 +03:00
|
|
|
wsi_device_setup_syncobj_fd(&physical_device->wsi_device,
|
|
|
|
|
physical_device->local_fd);
|
|
|
|
|
|
2017-11-13 16:44:07 -08:00
|
|
|
return VK_SUCCESS;
|
2015-09-04 11:14:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2016-05-15 22:21:24 -07:00
|
|
|
anv_finish_wsi(struct anv_physical_device *physical_device)
|
2015-09-04 11:14:45 -07:00
|
|
|
{
|
2021-10-06 11:21:55 -05:00
|
|
|
physical_device->vk.wsi_device = NULL;
|
2017-11-16 12:49:27 -08:00
|
|
|
wsi_device_finish(&physical_device->wsi_device,
|
2021-01-23 04:57:21 -06:00
|
|
|
&physical_device->instance->vk.alloc);
|
2015-09-04 11:14:45 -07:00
|
|
|
}
|
|
|
|
|
|
2022-02-11 19:28:08 +02: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-02 16:28:36 -08:00
|
|
|
VkResult anv_QueuePresentKHR(
|
2015-09-01 18:59:06 -07:00
|
|
|
VkQueue _queue,
|
2015-12-02 16:28:36 -08:00
|
|
|
const VkPresentInfoKHR* pPresentInfo)
|
2015-09-01 18:59:06 -07:00
|
|
|
{
|
|
|
|
|
ANV_FROM_HANDLE(anv_queue, queue, _queue);
|
2020-03-05 01:15:57 +02:00
|
|
|
struct anv_device *device = queue->device;
|
2021-10-20 09:44:02 -05:00
|
|
|
VkResult result;
|
2020-03-05 01:15:57 +02:00
|
|
|
|
|
|
|
|
if (device->debug_frame_desc) {
|
|
|
|
|
device->debug_frame_desc->frame_id++;
|
2022-11-22 07:26:58 -08:00
|
|
|
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
|
2022-04-06 22:56:00 +03:00
|
|
|
if (device->physical->memory.need_clflush) {
|
2021-04-07 13:22:19 -07:00
|
|
|
intel_clflush_range(device->debug_frame_desc,
|
2020-03-05 01:15:57 +02:00
|
|
|
sizeof(*device->debug_frame_desc));
|
|
|
|
|
}
|
2022-11-22 07:26:58 -08:00
|
|
|
#endif
|
2020-03-05 01:15:57 +02:00
|
|
|
}
|
2015-09-01 18:59:06 -07:00
|
|
|
|
2021-10-20 09:44:02 -05:00
|
|
|
result = vk_queue_wait_before_present(&queue->vk, pPresentInfo);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return result;
|
2019-08-28 13:22:30 +03:00
|
|
|
|
2021-10-20 09:44:02 -05:00
|
|
|
result = wsi_common_queue_present(&device->physical->wsi_device,
|
|
|
|
|
anv_device_to_handle(queue->device),
|
|
|
|
|
_queue, 0,
|
|
|
|
|
pPresentInfo);
|
2019-08-28 13:22:30 +03:00
|
|
|
|
|
|
|
|
return result;
|
2015-09-01 18:59:06 -07:00
|
|
|
}
|