mirror of
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer.git
synced 2025-12-20 03:20:09 +01:00
* Enables new warnings (which are made errors by -Werror)
* Wshadow warns when a variable shadows another * Wconversion warns on implicit int conversions * Fixes warnings generated by them Signed-off-by: Alex Bates <alex.bates@arm.com>
This commit is contained in:
parent
80b43daffa
commit
ee3f6c5ab9
23 changed files with 116 additions and 110 deletions
|
|
@ -35,13 +35,15 @@ endif()
|
||||||
|
|
||||||
string(APPEND CMAKE_CXX_FLAGS
|
string(APPEND CMAKE_CXX_FLAGS
|
||||||
" -Wall -Werror -Wextra"
|
" -Wall -Werror -Wextra"
|
||||||
|
" -Wshadow -Wconversion"
|
||||||
" -Wdouble-promotion -Wnon-virtual-dtor -Wdelete-non-virtual-dtor"
|
" -Wdouble-promotion -Wnon-virtual-dtor -Wdelete-non-virtual-dtor"
|
||||||
" -Wcast-qual -Werror=return-type -Wmissing-format-attribute"
|
" -Wcast-qual -Wmissing-format-attribute"
|
||||||
" -pthread -fPIC"
|
" -pthread -fPIC"
|
||||||
)
|
)
|
||||||
|
|
||||||
string(APPEND CMAKE_C_FLAGS
|
string(APPEND CMAKE_C_FLAGS
|
||||||
" -Wall -Werror -Wextra"
|
" -Wall -Werror -Wextra"
|
||||||
|
" -Wshadow -Wconversion"
|
||||||
" -Wstrict-prototypes"
|
" -Wstrict-prototypes"
|
||||||
" -fPIC"
|
" -fPIC"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ VKAPI_ATTR VkResult create_instance(const VkInstanceCreateInfo *pCreateInfo, con
|
||||||
|
|
||||||
TRY_LOG_CALL(extensions.get_extension_strings(modified_enabled_extensions));
|
TRY_LOG_CALL(extensions.get_extension_strings(modified_enabled_extensions));
|
||||||
modified_info.ppEnabledExtensionNames = modified_enabled_extensions.data();
|
modified_info.ppEnabledExtensionNames = modified_enabled_extensions.data();
|
||||||
modified_info.enabledExtensionCount = modified_enabled_extensions.size();
|
modified_info.enabledExtensionCount = static_cast<uint32_t>(modified_enabled_extensions.size());
|
||||||
|
|
||||||
/* Advance the link info for the next element on the chain. */
|
/* Advance the link info for the next element on the chain. */
|
||||||
layer_link_info->u.pLayerInfo = layer_link_info->u.pLayerInfo->pNext;
|
layer_link_info->u.pLayerInfo = layer_link_info->u.pLayerInfo->pNext;
|
||||||
|
|
@ -291,7 +291,7 @@ VKAPI_ATTR VkResult create_device(VkPhysicalDevice physicalDevice, const VkDevic
|
||||||
TRY_LOG_CALL(enabled_extensions.get_extension_strings(modified_enabled_extensions));
|
TRY_LOG_CALL(enabled_extensions.get_extension_strings(modified_enabled_extensions));
|
||||||
|
|
||||||
modified_info.ppEnabledExtensionNames = modified_enabled_extensions.data();
|
modified_info.ppEnabledExtensionNames = modified_enabled_extensions.data();
|
||||||
modified_info.enabledExtensionCount = modified_enabled_extensions.size();
|
modified_info.enabledExtensionCount = static_cast<uint32_t>(modified_enabled_extensions.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool should_layer_handle_frame_boundary_events = false;
|
bool should_layer_handle_frame_boundary_events = false;
|
||||||
|
|
|
||||||
|
|
@ -179,12 +179,12 @@ PFN_vkVoidFunction device_dispatch_table::get_user_enabled_entrypoint(VkDevice d
|
||||||
}
|
}
|
||||||
|
|
||||||
instance_private_data::instance_private_data(instance_dispatch_table table, PFN_vkSetInstanceLoaderData set_loader_data,
|
instance_private_data::instance_private_data(instance_dispatch_table table, PFN_vkSetInstanceLoaderData set_loader_data,
|
||||||
util::wsi_platform_set enabled_layer_platforms, const uint32_t api_version,
|
util::wsi_platform_set layer_platforms,
|
||||||
const util::allocator &alloc)
|
const uint32_t instance_api_version, const util::allocator &alloc)
|
||||||
: disp{ std::move(table) }
|
: disp{ std::move(table) }
|
||||||
, api_version{ api_version }
|
, api_version{ instance_api_version }
|
||||||
, SetInstanceLoaderData{ set_loader_data }
|
, SetInstanceLoaderData{ set_loader_data }
|
||||||
, enabled_layer_platforms{ enabled_layer_platforms }
|
, enabled_layer_platforms{ layer_platforms }
|
||||||
, allocator{ alloc }
|
, allocator{ alloc }
|
||||||
, surfaces{ alloc }
|
, surfaces{ alloc }
|
||||||
, enabled_extensions{ allocator }
|
, enabled_extensions{ allocator }
|
||||||
|
|
@ -205,11 +205,11 @@ static inline void *get_key(dispatchable_type dispatchable_object)
|
||||||
|
|
||||||
VkResult instance_private_data::associate(VkInstance instance, instance_dispatch_table table,
|
VkResult instance_private_data::associate(VkInstance instance, instance_dispatch_table table,
|
||||||
PFN_vkSetInstanceLoaderData set_loader_data,
|
PFN_vkSetInstanceLoaderData set_loader_data,
|
||||||
util::wsi_platform_set enabled_layer_platforms, const uint32_t api_version,
|
util::wsi_platform_set enabled_layer_platforms,
|
||||||
const util::allocator &allocator)
|
const uint32_t instance_api_version, const util::allocator &allocator)
|
||||||
{
|
{
|
||||||
auto instance_data = allocator.make_unique<instance_private_data>(std::move(table), set_loader_data,
|
auto instance_data = allocator.make_unique<instance_private_data>(
|
||||||
enabled_layer_platforms, api_version, allocator);
|
std::move(table), set_loader_data, enabled_layer_platforms, instance_api_version, allocator);
|
||||||
|
|
||||||
if (instance_data == nullptr)
|
if (instance_data == nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -423,7 +423,7 @@ wsi_layer_vkBindImageMemory2(VkDevice device, uint32_t bindInfoCount,
|
||||||
if (bind_sc_info == nullptr || bind_sc_info->swapchain == VK_NULL_HANDLE ||
|
if (bind_sc_info == nullptr || bind_sc_info->swapchain == VK_NULL_HANDLE ||
|
||||||
!device_data.layer_owns_swapchain(bind_sc_info->swapchain))
|
!device_data.layer_owns_swapchain(bind_sc_info->swapchain))
|
||||||
{
|
{
|
||||||
result = device_data.disp.BindImageMemory2KHR(device, 1, &pBindInfos[i]);
|
result = device_data.disp.BindImageMemory2KHR(device, 1u, &pBindInfos[i]);
|
||||||
error_message = "Failed to bind image memory";
|
error_message = "Failed to bind image memory";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -201,11 +201,11 @@ T *allocator::create(size_t num_objects, arg_types &&...args) const noexcept
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
custom_allocator<T> allocator(*this);
|
custom_allocator<T> object_allocator(*this);
|
||||||
T *ptr;
|
T *ptr;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ptr = allocator.allocate(num_objects);
|
ptr = object_allocator.allocate(num_objects);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
|
@ -232,7 +232,7 @@ T *allocator::create(size_t num_objects, arg_types &&...args) const noexcept
|
||||||
objects_constructed--;
|
objects_constructed--;
|
||||||
ptr[objects_constructed].~T();
|
ptr[objects_constructed].~T();
|
||||||
}
|
}
|
||||||
allocator.deallocate(ptr, num_objects);
|
object_allocator.deallocate(ptr, num_objects);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|
@ -247,12 +247,12 @@ void allocator::destroy(size_t num_objects, T *objects) const noexcept
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
custom_allocator<T> allocator(*this);
|
custom_allocator<T> object_allocator(*this);
|
||||||
for (size_t i = 0; i < num_objects; i++)
|
for (size_t i = 0; i < num_objects; i++)
|
||||||
{
|
{
|
||||||
objects[i].~T();
|
objects[i].~T();
|
||||||
}
|
}
|
||||||
allocator.deallocate(objects, num_objects);
|
object_allocator.deallocate(objects, num_objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2024 Arm Limited.
|
* Copyright (c) 2024-2025 Arm Limited.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
|
@ -85,7 +85,7 @@ static int allocate(int fd, uint64_t size)
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
assert(heap_data.fd > 0);
|
assert(heap_data.fd > 0);
|
||||||
return heap_data.fd;
|
return (int)heap_data.fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dma_allocate(const wsialloc_allocator *allocator, const wsialloc_allocate_info *info, uint64_t size)
|
static int dma_allocate(const wsialloc_allocator *allocator, const wsialloc_allocate_info *info, uint64_t size)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ static uint64_t round_size_up_to_align(uint64_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
static wsialloc_error calculate_format_properties(const wsialloc_format_descriptor *descriptor,
|
static wsialloc_error calculate_format_properties(const wsialloc_format_descriptor *descriptor,
|
||||||
const wsialloc_allocate_info *info, int *strides, int *offsets,
|
const wsialloc_allocate_info *info, int *strides, uint32_t *offsets,
|
||||||
uint64_t *total_size)
|
uint64_t *total_size)
|
||||||
{
|
{
|
||||||
assert(descriptor != NULL);
|
assert(descriptor != NULL);
|
||||||
|
|
@ -76,11 +76,11 @@ static wsialloc_error calculate_format_properties(const wsialloc_format_descript
|
||||||
assert(plane_bytes_per_pixel * 8 == bits_per_pixel[plane]);
|
assert(plane_bytes_per_pixel * 8 == bits_per_pixel[plane]);
|
||||||
|
|
||||||
/* With large enough width, this can overflow as strides are signed. In practice, this shouldn't happen */
|
/* With large enough width, this can overflow as strides are signed. In practice, this shouldn't happen */
|
||||||
strides[plane] = round_size_up_to_align(info->width * plane_bytes_per_pixel);
|
strides[plane] = (int)round_size_up_to_align((uint64_t)info->width * plane_bytes_per_pixel);
|
||||||
|
|
||||||
offsets[plane] = size;
|
offsets[plane] = (uint32_t)size;
|
||||||
|
|
||||||
size += strides[plane] * info->height;
|
size += (uint64_t)strides[plane] * info->height;
|
||||||
}
|
}
|
||||||
*total_size = size;
|
*total_size = size;
|
||||||
return WSIALLOC_ERROR_NONE;
|
return WSIALLOC_ERROR_NONE;
|
||||||
|
|
@ -138,7 +138,7 @@ wsialloc_error wsiallocp_alloc(wsialloc_allocator *allocator, wsiallocp_alloc_ca
|
||||||
}
|
}
|
||||||
|
|
||||||
int local_strides[WSIALLOC_MAX_PLANES];
|
int local_strides[WSIALLOC_MAX_PLANES];
|
||||||
int local_offsets[WSIALLOC_MAX_PLANES];
|
uint32_t local_offsets[WSIALLOC_MAX_PLANES];
|
||||||
wsialloc_error err = WSIALLOC_ERROR_NONE;
|
wsialloc_error err = WSIALLOC_ERROR_NONE;
|
||||||
wsialloc_format_descriptor selected_format_desc = {};
|
wsialloc_format_descriptor selected_format_desc = {};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ static int find_compatible_crtc(int fd, drm_resources_owner &resources, drm_conn
|
||||||
|
|
||||||
/* Make the assumption that only one connector will be in use at a time so there is no
|
/* Make the assumption that only one connector will be in use at a time so there is no
|
||||||
* need to check that any other connectors are being driven by this CRTC. */
|
* need to check that any other connectors are being driven by this CRTC. */
|
||||||
return resources->crtcs[j];
|
return static_cast<int>(resources->crtcs[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,7 +183,8 @@ static bool fill_supported_formats_with_modifiers(uint32_t primary_plane_index,
|
||||||
if (!strcmp(property->name, "IN_FORMATS"))
|
if (!strcmp(property->name, "IN_FORMATS"))
|
||||||
{
|
{
|
||||||
drmModeFormatModifierIterator iter{};
|
drmModeFormatModifierIterator iter{};
|
||||||
drm_property_blob_owner blob{ drmModeGetPropertyBlob(drm_fd.get(), object_properties->prop_values[i]) };
|
drm_property_blob_owner blob{ drmModeGetPropertyBlob(
|
||||||
|
drm_fd.get(), static_cast<uint32_t>(object_properties->prop_values[i])) };
|
||||||
if (blob == nullptr)
|
if (blob == nullptr)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -403,8 +404,8 @@ const util::vector<util::drm::drm_format_pair> *drm_display::get_supported_forma
|
||||||
bool drm_display::is_format_supported(const util::drm::drm_format_pair &format) const
|
bool drm_display::is_format_supported(const util::drm::drm_format_pair &format) const
|
||||||
{
|
{
|
||||||
auto supported_format =
|
auto supported_format =
|
||||||
std::find_if(m_supported_formats->begin(), m_supported_formats->end(), [format](const auto &supported_format) {
|
std::find_if(m_supported_formats->begin(), m_supported_formats->end(), [format](const auto &candidate) {
|
||||||
return format.fourcc == supported_format.fourcc && format.modifier == supported_format.modifier;
|
return format.fourcc == candidate.fourcc && format.modifier == candidate.modifier;
|
||||||
});
|
});
|
||||||
|
|
||||||
return supported_format != m_supported_formats->end();
|
return supported_format != m_supported_formats->end();
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
|
||||||
assert(pCreateInfo->pNext == NULL);
|
assert(pCreateInfo->pNext == NULL);
|
||||||
assert(pCreateInfo->flags == 0);
|
assert(pCreateInfo->flags == 0);
|
||||||
|
|
||||||
drm_display *dpy = reinterpret_cast<drm_display *>(display);
|
auto *dpy = reinterpret_cast<drm_display *>(display);
|
||||||
|
|
||||||
const VkDisplayModeParametersKHR *params = &pCreateInfo->parameters;
|
const VkDisplayModeParametersKHR *params = &pCreateInfo->parameters;
|
||||||
|
|
||||||
|
|
@ -224,9 +224,10 @@ CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
|
||||||
return VK_ERROR_INITIALIZATION_FAILED;
|
return VK_ERROR_INITIALIZATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *mode = std::find_if(dpy->get_display_modes_begin(), dpy->get_display_modes_end(), [params](auto &mode) {
|
auto *mode = std::find_if(dpy->get_display_modes_begin(), dpy->get_display_modes_end(), [params](auto &candidate) {
|
||||||
return mode.get_width() == params->visibleRegion.width && mode.get_height() == params->visibleRegion.height &&
|
return candidate.get_width() == params->visibleRegion.width &&
|
||||||
mode.get_refresh_rate() == params->refreshRate;
|
candidate.get_height() == params->visibleRegion.height &&
|
||||||
|
candidate.get_refresh_rate() == params->refreshRate;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mode != dpy->get_display_modes_end())
|
if (mode != dpy->get_display_modes_end())
|
||||||
|
|
@ -246,7 +247,7 @@ CreateDisplayPlaneSurfaceKHR(VkInstance instance, const VkDisplaySurfaceCreateIn
|
||||||
auto &instance_data = layer::instance_private_data::get(instance);
|
auto &instance_data = layer::instance_private_data::get(instance);
|
||||||
util::allocator allocator{ instance_data.get_allocator(), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT, pAllocator };
|
util::allocator allocator{ instance_data.get_allocator(), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT, pAllocator };
|
||||||
|
|
||||||
drm_display_mode *display_mode = reinterpret_cast<drm_display_mode *>(pCreateInfo->displayMode);
|
auto *display_mode = reinterpret_cast<drm_display_mode *>(pCreateInfo->displayMode);
|
||||||
|
|
||||||
VkResult res = instance_data.disp.CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
|
VkResult res = instance_data.disp.CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
|
||||||
if (res == VK_SUCCESS)
|
if (res == VK_SUCCESS)
|
||||||
|
|
@ -276,11 +277,11 @@ GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR displa
|
||||||
assert(display != VK_NULL_HANDLE);
|
assert(display != VK_NULL_HANDLE);
|
||||||
assert(pPropertyCount != nullptr);
|
assert(pPropertyCount != nullptr);
|
||||||
|
|
||||||
drm_display *dpy = reinterpret_cast<drm_display *>(display);
|
auto *dpy = reinterpret_cast<drm_display *>(display);
|
||||||
assert(dpy != nullptr);
|
assert(dpy != nullptr);
|
||||||
|
|
||||||
drm_display_mode *modes{ dpy->get_display_modes_begin() };
|
drm_display_mode *modes{ dpy->get_display_modes_begin() };
|
||||||
size_t num_modes{ dpy->get_num_display_modes() };
|
auto num_modes = static_cast<uint32_t>(dpy->get_num_display_modes());
|
||||||
|
|
||||||
if (pProperties == nullptr)
|
if (pProperties == nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -288,12 +289,12 @@ GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR displa
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t nr_properties = std::min(*pPropertyCount, static_cast<uint32_t>(num_modes));
|
uint32_t nr_properties = std::min(*pPropertyCount, num_modes);
|
||||||
*pPropertyCount = 0;
|
*pPropertyCount = 0;
|
||||||
std::for_each(modes, modes + nr_properties, [&pProperties, &pPropertyCount](auto &mode) {
|
std::for_each(modes, modes + nr_properties, [&pProperties, &pPropertyCount](auto &mode) {
|
||||||
VkDisplayModePropertiesKHR properties = {};
|
VkDisplayModePropertiesKHR properties = {};
|
||||||
|
|
||||||
VkDisplayModeKHR display_mode = reinterpret_cast<VkDisplayModeKHR>(&mode);
|
auto display_mode = reinterpret_cast<VkDisplayModeKHR>(&mode);
|
||||||
properties.displayMode = display_mode;
|
properties.displayMode = display_mode;
|
||||||
|
|
||||||
VkDisplayModeParametersKHR parameters{};
|
VkDisplayModeParametersKHR parameters{};
|
||||||
|
|
@ -305,7 +306,7 @@ GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR displa
|
||||||
*pPropertyCount += 1;
|
*pPropertyCount += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (*pPropertyCount < static_cast<uint32_t>(num_modes))
|
if (*pPropertyCount < num_modes)
|
||||||
{
|
{
|
||||||
return VK_INCOMPLETE;
|
return VK_INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +324,7 @@ GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR
|
||||||
assert(mode != VK_NULL_HANDLE);
|
assert(mode != VK_NULL_HANDLE);
|
||||||
assert(pCapabilities != nullptr);
|
assert(pCapabilities != nullptr);
|
||||||
|
|
||||||
drm_display_mode *display_mode = reinterpret_cast<drm_display_mode *>(mode);
|
auto *display_mode = reinterpret_cast<drm_display_mode *>(mode);
|
||||||
assert(display_mode != nullptr);
|
assert(display_mode != nullptr);
|
||||||
|
|
||||||
auto &display = drm_display::get_display();
|
auto &display = drm_display::get_display();
|
||||||
|
|
@ -337,10 +338,11 @@ GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR
|
||||||
* images. Therefore plane index must be 0. */
|
* images. Therefore plane index must be 0. */
|
||||||
assert(planeIndex == 0);
|
assert(planeIndex == 0);
|
||||||
|
|
||||||
auto valid_mode =
|
auto valid_mode = std::find_if(display->get_display_modes_begin(), display->get_display_modes_end(),
|
||||||
std::find_if(display->get_display_modes_begin(), display->get_display_modes_end(), [&display_mode](auto &mode) {
|
[&display_mode](auto &candidate) {
|
||||||
return (display_mode->get_width() == mode.get_width()) && (display_mode->get_height() == mode.get_height()) &&
|
return (display_mode->get_width() == candidate.get_width()) &&
|
||||||
(display_mode->get_refresh_rate() == mode.get_refresh_rate());
|
(display_mode->get_height() == candidate.get_height()) &&
|
||||||
|
(display_mode->get_refresh_rate() == candidate.get_refresh_rate());
|
||||||
});
|
});
|
||||||
|
|
||||||
assert(valid_mode != display->get_display_modes_end());
|
assert(valid_mode != display->get_display_modes_end());
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_drm_fd;
|
int m_drm_fd;
|
||||||
uint32_t m_fb_id;
|
uint32_t m_fb_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -236,7 +236,7 @@ VkResult swapchain::create_framebuffer(image_backing_memory_external &image_exte
|
||||||
for (uint32_t plane = 0; plane < ext_memory.get_num_planes(); plane++)
|
for (uint32_t plane = 0; plane < ext_memory.get_num_planes(); plane++)
|
||||||
{
|
{
|
||||||
assert(ext_memory.get_strides()[plane] > 0);
|
assert(ext_memory.get_strides()[plane] > 0);
|
||||||
strides[plane] = ext_memory.get_strides()[plane];
|
strides[plane] = static_cast<uint32_t>(ext_memory.get_strides()[plane]);
|
||||||
modifiers[plane] = allocated_format.modifier;
|
modifiers[plane] = allocated_format.modifier;
|
||||||
if (drmPrimeFDToHandle(display->get_drm_fd(), buffer_fds[plane], &buffer_handles[plane]) != 0)
|
if (drmPrimeFDToHandle(display->get_drm_fd(), buffer_fds[plane], &buffer_handles[plane]) != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -332,8 +332,8 @@ void swapchain::present_image(const pending_present_request &pending_present)
|
||||||
drmModeModeInfo modeInfo = m_display_mode->get_drm_mode();
|
drmModeModeInfo modeInfo = m_display_mode->get_drm_mode();
|
||||||
|
|
||||||
uint32_t connector_id = display->get_connector_id();
|
uint32_t connector_id = display->get_connector_id();
|
||||||
drm_res = drmModeSetCrtc(display->get_drm_fd(), display->get_crtc_id(), image_data->get_fb_id(), 0, 0,
|
drm_res = drmModeSetCrtc(display->get_drm_fd(), static_cast<uint32_t>(display->get_crtc_id()),
|
||||||
&connector_id, 1, &modeInfo);
|
image_data->get_fb_id(), 0, 0, &connector_id, 1, &modeInfo);
|
||||||
|
|
||||||
if (drm_res != 0)
|
if (drm_res != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -348,8 +348,8 @@ void swapchain::present_image(const pending_present_request &pending_present)
|
||||||
|
|
||||||
bool page_flip_complete = false;
|
bool page_flip_complete = false;
|
||||||
|
|
||||||
drm_res = drmModePageFlip(display->get_drm_fd(), display->get_crtc_id(), image_data->get_fb_id(),
|
drm_res = drmModePageFlip(display->get_drm_fd(), static_cast<uint32_t>(display->get_crtc_id()),
|
||||||
DRM_MODE_PAGE_FLIP_EVENT, (void *)&page_flip_complete);
|
image_data->get_fb_id(), DRM_MODE_PAGE_FLIP_EVENT, (void *)&page_flip_complete);
|
||||||
|
|
||||||
if (drm_res != 0)
|
if (drm_res != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -398,7 +398,7 @@ void swapchain::present_image(const pending_present_request &pending_present)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find currently presented image */
|
/* Find currently presented image */
|
||||||
uint32_t presented_index = m_swapchain_images.size();
|
auto presented_index = static_cast<uint32_t>(m_swapchain_images.size());
|
||||||
if (!m_first_present)
|
if (!m_first_present)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < m_swapchain_images.size(); ++i)
|
for (uint32_t i = 0; i < m_swapchain_images.size(); ++i)
|
||||||
|
|
@ -426,8 +426,6 @@ void swapchain::present_image(const pending_present_request &pending_present)
|
||||||
{
|
{
|
||||||
unpresent_image(presented_index);
|
unpresent_image(presented_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::variant<VkResult, util::unique_ptr<vulkan_image_handle_creator>> swapchain::create_image_creator(
|
std::variant<VkResult, util::unique_ptr<vulkan_image_handle_creator>> swapchain::create_image_creator(
|
||||||
|
|
|
||||||
|
|
@ -390,7 +390,8 @@ VkResult wsi_ext_present_timing::get_past_presentation_results(
|
||||||
|
|
||||||
for (uint64_t i = 0; (i - removed_entries) < m_queue.size(); ++i)
|
for (uint64_t i = 0; (i - removed_entries) < m_queue.size(); ++i)
|
||||||
{
|
{
|
||||||
auto slot = m_queue.begin() + (i - removed_entries);
|
const auto slot_offset = static_cast<decltype(m_queue)::difference_type>(i - removed_entries);
|
||||||
|
auto slot = m_queue.begin() + slot_offset;
|
||||||
|
|
||||||
if (!slot->has_completed_stages(allow_partial))
|
if (!slot->has_completed_stages(allow_partial))
|
||||||
{
|
{
|
||||||
|
|
@ -419,7 +420,7 @@ VkResult wsi_ext_present_timing::get_past_presentation_results(
|
||||||
incomplete = true;
|
incomplete = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
past_present_timing_properties->presentationTimingCount = timing_count;
|
past_present_timing_properties->presentationTimingCount = static_cast<uint32_t>(timing_count);
|
||||||
return incomplete ? VK_INCOMPLETE : VK_SUCCESS;
|
return incomplete ? VK_INCOMPLETE : VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -334,8 +334,8 @@ public:
|
||||||
{
|
{
|
||||||
if (m_command_pool != VK_NULL_HANDLE)
|
if (m_command_pool != VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
m_device.disp.FreeCommandBuffers(m_device.device, m_command_pool, m_command_buffer.size(),
|
m_device.disp.FreeCommandBuffers(m_device.device, m_command_pool,
|
||||||
m_command_buffer.data());
|
static_cast<uint32_t>(m_command_buffer.size()), m_command_buffer.data());
|
||||||
|
|
||||||
m_device.disp.DestroyCommandPool(m_device.device, m_command_pool, m_allocator.get_original_callbacks());
|
m_device.disp.DestroyCommandPool(m_device.device, m_command_pool, m_allocator.get_original_callbacks());
|
||||||
m_command_pool = VK_NULL_HANDLE;
|
m_command_pool = VK_NULL_HANDLE;
|
||||||
|
|
@ -377,7 +377,7 @@ public:
|
||||||
TRY_LOG_CALL(
|
TRY_LOG_CALL(
|
||||||
m_device.disp.AllocateCommandBuffers(m_device.device, &command_buffer_info, m_command_buffer.data()));
|
m_device.disp.AllocateCommandBuffers(m_device.device, &command_buffer_info, m_command_buffer.data()));
|
||||||
VkCommandBufferBeginInfo begin_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, 0, nullptr };
|
VkCommandBufferBeginInfo begin_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, 0, nullptr };
|
||||||
for (size_t image_index = 0; image_index < num_images; image_index++)
|
for (uint32_t image_index = 0; image_index < num_images; image_index++)
|
||||||
{
|
{
|
||||||
TRY_LOG_CALL(m_device.disp.BeginCommandBuffer(m_command_buffer[image_index], &begin_info));
|
TRY_LOG_CALL(m_device.disp.BeginCommandBuffer(m_command_buffer[image_index], &begin_info));
|
||||||
m_device.disp.CmdResetQueryPool(m_command_buffer[image_index], m_query_pool, image_index, 1);
|
m_device.disp.CmdResetQueryPool(m_command_buffer[image_index], m_query_pool, image_index, 1);
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,8 @@ VkResult external_memory::bind_swapchain_image_memory(const VkImage &image)
|
||||||
bind_img_mem_infos[plane].memoryOffset = m_offsets[plane];
|
bind_img_mem_infos[plane].memoryOffset = m_offsets[plane];
|
||||||
}
|
}
|
||||||
|
|
||||||
return device_data.disp.BindImageMemory2KHR(m_device, bind_img_mem_infos.size(), bind_img_mem_infos.data());
|
return device_data.disp.BindImageMemory2KHR(m_device, static_cast<uint32_t>(bind_img_mem_infos.size()),
|
||||||
|
bind_img_mem_infos.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
return device_data.disp.BindImageMemory(m_device, image, m_memories[0], m_offsets[0]);
|
return device_data.disp.BindImageMemory(m_device, image, m_memories[0], m_offsets[0]);
|
||||||
|
|
|
||||||
|
|
@ -72,18 +72,18 @@ VkResult image_backing_memory_device::allocate_and_bind(VkImage image)
|
||||||
VkMemoryAllocateInfo mem_info = {};
|
VkMemoryAllocateInfo mem_info = {};
|
||||||
mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||||
mem_info.allocationSize = memory_requirements.size;
|
mem_info.allocationSize = memory_requirements.size;
|
||||||
mem_info.memoryTypeIndex = mem_type_idx;
|
mem_info.memoryTypeIndex = static_cast<uint32_t>(mem_type_idx);
|
||||||
|
|
||||||
TRY(disp_table.AllocateMemory(m_device_data.device, &mem_info, m_allocator.get_original_callbacks(),
|
TRY(disp_table.AllocateMemory(m_device_data.device, &mem_info, m_allocator.get_original_callbacks(),
|
||||||
&m_device_memory));
|
&m_device_memory));
|
||||||
TRY(disp_table.BindImageMemory(m_device_data.device, image, m_device_memory, 0));
|
TRY(disp_table.BindImageMemory(m_device_data.device, image, m_device_memory, 0ull));
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult image_backing_memory_device::bind(const VkBindImageMemoryInfo *bind_image_mem_info)
|
VkResult image_backing_memory_device::bind(const VkBindImageMemoryInfo *bind_image_mem_info)
|
||||||
{
|
{
|
||||||
return m_device_data.disp.BindImageMemory(m_device_data.device, bind_image_mem_info->image, m_device_memory, 0);
|
return m_device_data.disp.BindImageMemory(m_device_data.device, bind_image_mem_info->image, m_device_memory, 0ull);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t image_backing_memory_device::get_modifier() const
|
uint64_t image_backing_memory_device::get_modifier() const
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,9 @@ VkResult surface_properties_formats_helper(It begin, It end, uint32_t *surface_f
|
||||||
{
|
{
|
||||||
assert(surface_formats_count != nullptr);
|
assert(surface_formats_count != nullptr);
|
||||||
|
|
||||||
const uint32_t supported_formats_count = std::distance(begin, end);
|
const auto distance = std::distance(begin, end);
|
||||||
|
assert(distance >= 0);
|
||||||
|
const auto supported_formats_count = static_cast<uint32_t>(distance);
|
||||||
if (surface_formats == nullptr && extended_surface_formats == nullptr)
|
if (surface_formats == nullptr && extended_surface_formats == nullptr)
|
||||||
{
|
{
|
||||||
*surface_formats_count = supported_formats_count;
|
*surface_formats_count = supported_formats_count;
|
||||||
|
|
@ -307,17 +309,20 @@ VkResult get_surface_present_modes_common(uint32_t *present_mode_count, VkPresen
|
||||||
|
|
||||||
assert(present_mode_count != nullptr);
|
assert(present_mode_count != nullptr);
|
||||||
|
|
||||||
|
assert(modes.size() <= UINT32_MAX);
|
||||||
|
const auto modes_count = static_cast<uint32_t>(modes.size());
|
||||||
|
|
||||||
if (nullptr == present_modes)
|
if (nullptr == present_modes)
|
||||||
{
|
{
|
||||||
*present_mode_count = modes.size();
|
*present_mode_count = modes_count;
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modes.size() > *present_mode_count)
|
if (modes_count > *present_mode_count)
|
||||||
{
|
{
|
||||||
res = VK_INCOMPLETE;
|
res = VK_INCOMPLETE;
|
||||||
}
|
}
|
||||||
*present_mode_count = std::min(*present_mode_count, static_cast<uint32_t>(modes.size()));
|
*present_mode_count = std::min(*present_mode_count, modes_count);
|
||||||
for (uint32_t i = 0; i < *present_mode_count; ++i)
|
for (uint32_t i = 0; i < *present_mode_count; ++i)
|
||||||
{
|
{
|
||||||
present_modes[i] = modes[i];
|
present_modes[i] = modes[i];
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,8 @@ VkResult swapchain_base::init(VkDevice device, const VkSwapchainCreateInfoKHR *s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VkResult result = m_free_image_semaphore.init(m_swapchain_images.size()); result != VK_SUCCESS)
|
if (VkResult result = m_free_image_semaphore.init(static_cast<uint32_t>(m_swapchain_images.size()));
|
||||||
|
result != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
assert(result == VK_ERROR_OUT_OF_HOST_MEMORY);
|
assert(result == VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -299,7 +300,7 @@ VkResult swapchain_base::init(VkDevice device, const VkSwapchainCreateInfoKHR *s
|
||||||
* Vulkan spec, vkGetDeviceQueue2 should be used to get queues
|
* Vulkan spec, vkGetDeviceQueue2 should be used to get queues
|
||||||
* that were created with non zero flags parameters.
|
* that were created with non zero flags parameters.
|
||||||
*/
|
*/
|
||||||
m_device_data.disp.GetDeviceQueue(m_device, 0, 0, &m_queue);
|
m_device_data.disp.GetDeviceQueue(m_device, 0u, 0u, &m_queue);
|
||||||
TRY_LOG_CALL(m_device_data.SetDeviceLoaderData(m_device, m_queue));
|
TRY_LOG_CALL(m_device_data.SetDeviceLoaderData(m_device, m_queue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,24 +417,24 @@ VkResult swapchain_base::acquire_next_image(uint64_t timeout, VkSemaphore semaph
|
||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t i;
|
size_t image_index_candidate = 0;
|
||||||
for (i = 0; i < m_swapchain_images.size(); ++i)
|
for (; image_index_candidate < m_swapchain_images.size(); ++image_index_candidate)
|
||||||
{
|
{
|
||||||
if (m_swapchain_images[i].get_status() == swapchain_image::UNALLOCATED)
|
if (m_swapchain_images[image_index_candidate].get_status() == swapchain_image::UNALLOCATED)
|
||||||
{
|
{
|
||||||
TRY_LOG_CALL(allocate_and_bind_swapchain_image(m_swapchain_images[i]));
|
TRY_LOG_CALL(allocate_and_bind_swapchain_image(m_swapchain_images[image_index_candidate]));
|
||||||
m_swapchain_images[i].set_status(swapchain_image::FREE);
|
m_swapchain_images[image_index_candidate].set_status(swapchain_image::FREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_swapchain_images[i].get_status() == swapchain_image::FREE)
|
if (m_swapchain_images[image_index_candidate].get_status() == swapchain_image::FREE)
|
||||||
{
|
{
|
||||||
m_swapchain_images[i].set_status(swapchain_image::ACQUIRED);
|
m_swapchain_images[image_index_candidate].set_status(swapchain_image::ACQUIRED);
|
||||||
*image_index = i;
|
*image_index = static_cast<uint32_t>(image_index_candidate);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(i < m_swapchain_images.size());
|
assert(image_index_candidate < m_swapchain_images.size());
|
||||||
|
|
||||||
image_status_lock.unlock();
|
image_status_lock.unlock();
|
||||||
|
|
||||||
|
|
@ -490,7 +491,7 @@ VkResult swapchain_base::get_swapchain_images(uint32_t *swapchain_image_count, V
|
||||||
if (swapchain_images == nullptr)
|
if (swapchain_images == nullptr)
|
||||||
{
|
{
|
||||||
/* Return the number of swapchain images. */
|
/* Return the number of swapchain images. */
|
||||||
*swapchain_image_count = m_swapchain_images.size();
|
*swapchain_image_count = static_cast<uint32_t>(m_swapchain_images.size());
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -508,7 +509,7 @@ VkResult swapchain_base::get_swapchain_images(uint32_t *swapchain_image_count, V
|
||||||
|
|
||||||
current_image++;
|
current_image++;
|
||||||
|
|
||||||
if (current_image == m_swapchain_images.size())
|
if (current_image == static_cast<uint32_t>(m_swapchain_images.size()))
|
||||||
{
|
{
|
||||||
*swapchain_image_count = current_image;
|
*swapchain_image_count = current_image;
|
||||||
|
|
||||||
|
|
@ -660,11 +661,11 @@ VkResult swapchain_base::queue_present(VkQueue queue, const VkPresentInfoKHR *pr
|
||||||
{
|
{
|
||||||
VkSemaphore present_fence_wait_sem =
|
VkSemaphore present_fence_wait_sem =
|
||||||
m_swapchain_images[submit_info.pending_present.image_index].get_present_fence_wait_semaphore();
|
m_swapchain_images[submit_info.pending_present.image_index].get_present_fence_wait_semaphore();
|
||||||
const queue_submit_semaphores wait_semaphores = { &present_fence_wait_sem, 1, nullptr, 0 };
|
const queue_submit_semaphores present_fence_semaphores = { &present_fence_wait_sem, 1, nullptr, 0 };
|
||||||
/*
|
/*
|
||||||
* Here we chain wait_semaphores with present_fence through present_fence_wait.
|
* Here we chain present_fence_semaphores with present_fence through present_fence_wait.
|
||||||
*/
|
*/
|
||||||
TRY(sync_queue_submit(m_device_data, queue, submit_info.present_fence, wait_semaphores));
|
TRY(sync_queue_submit(m_device_data, queue, submit_info.present_fence, present_fence_semaphores));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VULKAN_WSI_LAYER_EXPERIMENTAL
|
#if VULKAN_WSI_LAYER_EXPERIMENTAL
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ VkResult fence_sync::wait_payload(uint64_t timeout)
|
||||||
VkResult res = VK_SUCCESS;
|
VkResult res = VK_SUCCESS;
|
||||||
if (has_payload && !payload_finished)
|
if (has_payload && !payload_finished)
|
||||||
{
|
{
|
||||||
res = dev->disp.WaitForFences(dev->device, 1, &fence, VK_TRUE, timeout);
|
res = dev->disp.WaitForFences(dev->device, 1u, &fence, VK_TRUE, timeout);
|
||||||
if (res == VK_SUCCESS)
|
if (res == VK_SUCCESS)
|
||||||
{
|
{
|
||||||
payload_finished = true;
|
payload_finished = true;
|
||||||
|
|
@ -112,7 +112,7 @@ VkResult fence_sync::wait_payload(uint64_t timeout)
|
||||||
|
|
||||||
VkResult fence_sync::set_payload(VkQueue queue, const queue_submit_semaphores &semaphores, const void *submission_pnext)
|
VkResult fence_sync::set_payload(VkQueue queue, const queue_submit_semaphores &semaphores, const void *submission_pnext)
|
||||||
{
|
{
|
||||||
VkResult result = dev->disp.ResetFences(dev->device, 1, &fence);
|
VkResult result = dev->disp.ResetFences(dev->device, 1u, &fence);
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -233,7 +233,7 @@ VkResult sync_queue_submit(const layer::device_private_data &device, VkQueue que
|
||||||
semaphores.signal_semaphores_count,
|
semaphores.signal_semaphores_count,
|
||||||
semaphores.signal_semaphores };
|
semaphores.signal_semaphores };
|
||||||
|
|
||||||
TRY(device.disp.QueueSubmit(queue, 1, &submit_info, fence));
|
TRY(device.disp.QueueSubmit(queue, 1u, &submit_info, fence));
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,7 +257,7 @@ VkResult sync_queue_submit(const layer::device_private_data &device, VkQueue que
|
||||||
pipeline_stage_flags_vector.data(), command_buffer_data.m_command_buffer_count,
|
pipeline_stage_flags_vector.data(), command_buffer_data.m_command_buffer_count,
|
||||||
command_buffer_data.m_command_buffers, semaphores.signal_semaphores_count,
|
command_buffer_data.m_command_buffers, semaphores.signal_semaphores_count,
|
||||||
semaphores.signal_semaphores };
|
semaphores.signal_semaphores };
|
||||||
TRY(device.disp.QueueSubmit(queue, 1, &submit_info, fence));
|
TRY(device.disp.QueueSubmit(queue, 1u, &submit_info, fence));
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
} /* namespace wsi */
|
} /* namespace wsi */
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ uint64_t wsi_ext_present_id_wayland::get_present_id_from_image_index(uint32_t im
|
||||||
}
|
}
|
||||||
|
|
||||||
auto feedback = m_pending_presents.find(
|
auto feedback = m_pending_presents.find(
|
||||||
[image_index](const presentation_feedback &feedback) { return feedback.get_image_index() == image_index; });
|
[image_index](const presentation_feedback &candidate) { return candidate.get_image_index() == image_index; });
|
||||||
|
|
||||||
return feedback != nullptr ? feedback->get_present_id() : 0;
|
return feedback != nullptr ? feedback->get_present_id() : 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,11 @@ VkResult wsi_ext_present_wait_wayland::wait_for_update(uint64_t present_id, uint
|
||||||
int delay_in_ms = 0;
|
int delay_in_ms = 0;
|
||||||
if (timeout_in_ns != UINT64_MAX)
|
if (timeout_in_ns != UINT64_MAX)
|
||||||
{
|
{
|
||||||
uint64_t min_delay_in_ns = std::min(static_cast<uint64_t>(5000000ULL /* 5ms */), timeout_in_ns);
|
const uint64_t min_delay_in_ns = std::min(static_cast<uint64_t>(5000000ULL /* 5ms */), timeout_in_ns);
|
||||||
timeout_in_ns -= min_delay_in_ns;
|
const uint64_t min_delay_in_ms = min_delay_in_ns / 1000000ULL;
|
||||||
|
|
||||||
delay_in_ms = std::min(static_cast<unsigned long long>(INT_MAX), min_delay_in_ns / 1000ULL / 1000UL);
|
timeout_in_ns -= min_delay_in_ns;
|
||||||
|
delay_in_ms = static_cast<int>(std::min<uint64_t>(min_delay_in_ms, static_cast<uint64_t>(INT_MAX)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,6 @@ private:
|
||||||
*/
|
*/
|
||||||
VkResult wait_for_update(uint64_t present_id, uint64_t timeout_in_ns) override;
|
VkResult wait_for_update(uint64_t present_id, uint64_t timeout_in_ns) override;
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
/**
|
||||||
* @brief Wayland display object.
|
* @brief Wayland display object.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -341,8 +341,9 @@ wayland_owner<wl_buffer> swapchain::create_wl_buffer(image_backing_memory_extern
|
||||||
|
|
||||||
/* create a wl_buffer using the dma_buf protocol */
|
/* create a wl_buffer using the dma_buf protocol */
|
||||||
zwp_linux_buffer_params_v1 *params = zwp_linux_dmabuf_v1_create_params(m_wsi_surface->get_dmabuf_interface());
|
zwp_linux_buffer_params_v1 *params = zwp_linux_dmabuf_v1_create_params(m_wsi_surface->get_dmabuf_interface());
|
||||||
uint32_t modifier_hi = image_external_memory.get_image_create_info().selected_format.modifier >> 32;
|
const uint64_t modifier = image_external_memory.get_image_create_info().selected_format.modifier;
|
||||||
uint32_t modifier_low = image_external_memory.get_image_create_info().selected_format.modifier & 0xFFFFFFFF;
|
const auto modifier_hi = static_cast<uint32_t>(modifier >> 32);
|
||||||
|
const auto modifier_low = static_cast<uint32_t>(modifier & 0xFFFFFFFF);
|
||||||
for (uint32_t plane = 0; plane < ext_memory.get_num_planes(); plane++)
|
for (uint32_t plane = 0; plane < ext_memory.get_num_planes(); plane++)
|
||||||
{
|
{
|
||||||
zwp_linux_buffer_params_v1_add(params, ext_memory.get_buffer_fds()[plane], plane, ext_memory.get_offsets()[plane],
|
zwp_linux_buffer_params_v1_add(params, ext_memory.get_buffer_fds()[plane], plane, ext_memory.get_offsets()[plane],
|
||||||
|
|
@ -516,15 +517,9 @@ bool swapchain::free_image_found()
|
||||||
VkResult swapchain::get_free_buffer(uint64_t *timeout)
|
VkResult swapchain::get_free_buffer(uint64_t *timeout)
|
||||||
{
|
{
|
||||||
int ms_timeout, res;
|
int ms_timeout, res;
|
||||||
|
const uint64_t timeout_ns = *timeout;
|
||||||
if (*timeout >= INT_MAX * 1000llu * 1000llu)
|
const uint64_t timeout_ms = timeout_ns / 1000000ULL;
|
||||||
{
|
ms_timeout = timeout_ms > static_cast<uint64_t>(INT_MAX) ? INT_MAX : static_cast<int>(timeout_ms);
|
||||||
ms_timeout = INT_MAX;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ms_timeout = *timeout / 1000llu / 1000llu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The current dispatch_queue implementation will return if any
|
/* The current dispatch_queue implementation will return if any
|
||||||
* events are returned, even if no events are dispatched to the buffer
|
* events are returned, even if no events are dispatched to the buffer
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ static std::unique_ptr<T, std::function<void(T *)>> make_proxy_with_queue(T *obj
|
||||||
wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(proxy), queue);
|
wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(proxy), queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto delete_proxy = [](T *proxy) { wl_proxy_wrapper_destroy(reinterpret_cast<wl_proxy *>(proxy)); };
|
auto delete_proxy = [](T *wrapped_proxy) { wl_proxy_wrapper_destroy(reinterpret_cast<wl_proxy *>(wrapped_proxy)); };
|
||||||
|
|
||||||
return std::unique_ptr<T, std::function<void(T *)>>(proxy, delete_proxy);
|
return std::unique_ptr<T, std::function<void(T *)>>(proxy, delete_proxy);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,13 @@ wp_presentation_feedback_presented(void *data, struct wp_presentation_feedback *
|
||||||
if (feedback_obj->ext_present_timing() != nullptr)
|
if (feedback_obj->ext_present_timing() != nullptr)
|
||||||
{
|
{
|
||||||
uint64_t timestamp_seconds = (static_cast<uint64_t>(tv_sec_hi) << 32) | tv_sec_lo;
|
uint64_t timestamp_seconds = (static_cast<uint64_t>(tv_sec_hi) << 32) | tv_sec_lo;
|
||||||
double timestamp_limit = static_cast<double>(UINT64_MAX - tv_nsec) / 1e9;
|
const uint64_t seconds_limit = (UINT64_MAX - static_cast<uint64_t>(tv_nsec)) / 1000000000ULL;
|
||||||
if (static_cast<double>(timestamp_seconds) > timestamp_limit)
|
if (timestamp_seconds > seconds_limit)
|
||||||
{
|
{
|
||||||
WSI_LOG_ERROR("timestamp_seconds overflow, capping to safe maximum");
|
WSI_LOG_ERROR("timestamp_seconds overflow, capping to safe maximum");
|
||||||
timestamp_seconds = static_cast<uint64_t>(std::floor(timestamp_limit));
|
timestamp_seconds = seconds_limit;
|
||||||
}
|
}
|
||||||
uint64_t timestamp_ns = static_cast<uint64_t>(timestamp_seconds * 1e9) + tv_nsec;
|
const uint64_t timestamp_ns = (timestamp_seconds * 1000000000ULL) + static_cast<uint64_t>(tv_nsec);
|
||||||
feedback_obj->ext_present_timing()->mark_delivered(feedback_obj->get_image_index(), timestamp_ns);
|
feedback_obj->ext_present_timing()->mark_delivered(feedback_obj->get_image_index(), timestamp_ns);
|
||||||
}
|
}
|
||||||
else if (feedback_obj->ext_present_id() != nullptr)
|
else if (feedback_obj->ext_present_id() != nullptr)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue