Fix warnings in wsi/display/

Change-Id: I8b96fda0203658cdd7e4569d8c4767116842eaac
Signed-off-by: Alex Bates <alex.bates@arm.com>
This commit is contained in:
Alex Bates 2025-12-09 10:24:55 +00:00 committed by Maged Elnaggar
parent 2a8d0e47b2
commit 253a21c7fe
7 changed files with 40 additions and 39 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Arm Limited.
* Copyright (c) 2024-2025 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@ -85,7 +85,7 @@ static int allocate(int fd, uint64_t size)
return -errno;
}
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)

View file

@ -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,
const wsialloc_allocate_info *info, int *strides, int *offsets,
const wsialloc_allocate_info *info, int *strides, uint32_t *offsets,
uint64_t *total_size)
{
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]);
/* 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;
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_offsets[WSIALLOC_MAX_PLANES];
uint32_t local_offsets[WSIALLOC_MAX_PLANES];
wsialloc_error err = WSIALLOC_ERROR_NONE;
wsialloc_format_descriptor selected_format_desc = {};
@ -195,4 +195,4 @@ wsialloc_error wsiallocp_alloc(wsialloc_allocator *allocator, wsiallocp_alloc_ca
result->is_disjoint = false;
return WSIALLOC_ERROR_NONE;
}
}

View file

@ -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
* 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"))
{
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)
{
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
{
auto supported_format =
std::find_if(m_supported_formats->begin(), m_supported_formats->end(), [format](const auto &supported_format) {
return format.fourcc == supported_format.fourcc && format.modifier == supported_format.modifier;
std::find_if(m_supported_formats->begin(), m_supported_formats->end(), [format](const auto &candidate) {
return format.fourcc == candidate.fourcc && format.modifier == candidate.modifier;
});
return supported_format != m_supported_formats->end();

View file

@ -215,7 +215,7 @@ CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
assert(pCreateInfo->pNext == NULL);
assert(pCreateInfo->flags == 0);
drm_display *dpy = reinterpret_cast<drm_display *>(display);
auto *dpy = reinterpret_cast<drm_display *>(display);
const VkDisplayModeParametersKHR *params = &pCreateInfo->parameters;
@ -224,9 +224,10 @@ CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
return VK_ERROR_INITIALIZATION_FAILED;
}
auto *mode = std::find_if(dpy->get_display_modes_begin(), dpy->get_display_modes_end(), [params](auto &mode) {
return mode.get_width() == params->visibleRegion.width && mode.get_height() == params->visibleRegion.height &&
mode.get_refresh_rate() == params->refreshRate;
auto *mode = std::find_if(dpy->get_display_modes_begin(), dpy->get_display_modes_end(), [params](auto &candidate) {
return candidate.get_width() == params->visibleRegion.width &&
candidate.get_height() == params->visibleRegion.height &&
candidate.get_refresh_rate() == params->refreshRate;
});
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);
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);
if (res == VK_SUCCESS)
@ -276,11 +277,11 @@ GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR displa
assert(display != VK_NULL_HANDLE);
assert(pPropertyCount != nullptr);
drm_display *dpy = reinterpret_cast<drm_display *>(display);
auto *dpy = reinterpret_cast<drm_display *>(display);
assert(dpy != nullptr);
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)
{
@ -288,12 +289,12 @@ GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR displa
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;
std::for_each(modes, modes + nr_properties, [&pProperties, &pPropertyCount](auto &mode) {
VkDisplayModePropertiesKHR properties = {};
VkDisplayModeKHR display_mode = reinterpret_cast<VkDisplayModeKHR>(&mode);
auto display_mode = reinterpret_cast<VkDisplayModeKHR>(&mode);
properties.displayMode = display_mode;
VkDisplayModeParametersKHR parameters{};
@ -305,7 +306,7 @@ GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR displa
*pPropertyCount += 1;
});
if (*pPropertyCount < static_cast<uint32_t>(num_modes))
if (*pPropertyCount < num_modes)
{
return VK_INCOMPLETE;
}
@ -323,7 +324,7 @@ GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR
assert(mode != VK_NULL_HANDLE);
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);
auto &display = drm_display::get_display();
@ -337,11 +338,12 @@ GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR
* images. Therefore plane index must be 0. */
assert(planeIndex == 0);
auto valid_mode =
std::find_if(display->get_display_modes_begin(), display->get_display_modes_end(), [&display_mode](auto &mode) {
return (display_mode->get_width() == mode.get_width()) && (display_mode->get_height() == mode.get_height()) &&
(display_mode->get_refresh_rate() == mode.get_refresh_rate());
});
auto valid_mode = std::find_if(display->get_display_modes_begin(), display->get_display_modes_end(),
[&display_mode](auto &candidate) {
return (display_mode->get_width() == candidate.get_width()) &&
(display_mode->get_height() == candidate.get_height()) &&
(display_mode->get_refresh_rate() == candidate.get_refresh_rate());
});
assert(valid_mode != display->get_display_modes_end());
UNUSED(valid_mode);

View file

@ -68,7 +68,7 @@ public:
}
private:
uint32_t m_drm_fd;
int m_drm_fd;
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++)
{
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;
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();
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,
&connector_id, 1, &modeInfo);
drm_res = drmModeSetCrtc(display->get_drm_fd(), static_cast<uint32_t>(display->get_crtc_id()),
image_data->get_fb_id(), 0, 0, &connector_id, 1, &modeInfo);
if (drm_res != 0)
{
@ -348,8 +348,8 @@ void swapchain::present_image(const pending_present_request &pending_present)
bool page_flip_complete = false;
drm_res = drmModePageFlip(display->get_drm_fd(), display->get_crtc_id(), image_data->get_fb_id(),
DRM_MODE_PAGE_FLIP_EVENT, (void *)&page_flip_complete);
drm_res = drmModePageFlip(display->get_drm_fd(), static_cast<uint32_t>(display->get_crtc_id()),
image_data->get_fb_id(), DRM_MODE_PAGE_FLIP_EVENT, (void *)&page_flip_complete);
if (drm_res != 0)
{
@ -398,7 +398,7 @@ void swapchain::present_image(const pending_present_request &pending_present)
}
/* 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)
{
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);
}
return;
}
std::variant<VkResult, util::unique_ptr<vulkan_image_handle_creator>> swapchain::create_image_creator(

View file

@ -369,7 +369,8 @@ VkResult wsi_ext_present_timing::get_past_presentation_results(
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))
{

View file

@ -77,7 +77,6 @@ private:
*/
VkResult wait_for_update(uint64_t present_id, uint64_t timeout_in_ns) override;
private:
/**
* @brief Wayland display object.
*/