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
|
|
|
|
2024-05-10 08:57:55 +03:00
|
|
|
#include "common/intel_debug_identifier.h"
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
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,
|
vulkan/wsi/wayland: Correctly map 24bpp format types
VK_FORMAT_{R8G8B8,B8G8R8}_{UNORM,SRGB} describe a 3-component, 8bpc,
24bpp, format. This is mapped to that type for Android, and implemented
as such by panvk. radv maps these to 4-component/32bpp formats, but only
support these formats for buffers rather than images. The outlier is
ANV, which relies on the 24->32bpp mapping to happen.
The Wayland WSI was mapping this to the 32bpp R8G8B8A8/B8G8R8A8 formats
instead. This would cause a failure to import the dmabuf into the
compositor on panvk, as it would send a buffer which was too small. (Or,
if it did import: garbage.)
Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39552>
2026-01-27 12:08:59 +00:00
|
|
|
&(struct wsi_device_options){
|
|
|
|
|
.sw_device = false,
|
|
|
|
|
.emulate_24as32 = true,
|
|
|
|
|
});
|
2017-11-13 16:44:07 -08:00
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return result;
|
|
|
|
|
|
2020-12-10 22:46:59 +02:00
|
|
|
struct wsi_device *wsi_device = &physical_device->wsi_device;
|
|
|
|
|
wsi_device->supports_modifiers = true;
|
|
|
|
|
/* Only allow protected content on display */
|
|
|
|
|
for (uint32_t i = 0; i < ARRAY_SIZE(wsi_device->supports_protected); i++) {
|
|
|
|
|
wsi_device->supports_protected[i] =
|
|
|
|
|
physical_device->has_protected_contexts &&
|
|
|
|
|
i == VK_ICD_WSI_PLATFORM_DISPLAY;
|
|
|
|
|
}
|
2017-11-13 16:44:07 -08:00
|
|
|
|
2020-12-10 22:46:59 +02:00
|
|
|
physical_device->vk.wsi_device = wsi_device;
|
2021-10-06 11:21:55 -05:00
|
|
|
|
2020-12-10 22:46:59 +02:00
|
|
|
wsi_device_setup_syncobj_fd(wsi_device, physical_device->local_fd);
|
2021-10-14 14:45:19 +03:00
|
|
|
|
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++;
|
|
|
|
|
}
|
2015-09-01 18:59:06 -07:00
|
|
|
|
2023-04-04 00:21:18 +03:00
|
|
|
if (u_trace_should_process(&device->ds.trace_context))
|
|
|
|
|
anv_queue_trace(queue, NULL, true /* frame */, false /* begin */);
|
|
|
|
|
|
2021-10-20 09:44:02 -05:00
|
|
|
result = wsi_common_queue_present(&device->physical->wsi_device,
|
2025-08-18 11:04:24 -04:00
|
|
|
&queue->vk, pPresentInfo);
|
2019-08-28 13:22:30 +03:00
|
|
|
|
2023-04-04 00:21:18 +03:00
|
|
|
if (u_trace_should_process(&device->ds.trace_context))
|
|
|
|
|
anv_queue_trace(queue, NULL, true /* frame */, true /* begin */);
|
|
|
|
|
|
2019-08-28 13:22:30 +03:00
|
|
|
return result;
|
2015-09-01 18:59:06 -07:00
|
|
|
}
|