VKAPI_ATTR VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func)
{
- VkLayerInstanceCreateInfo *chain_info = (VkLayerInstanceCreateInfo *)pCreateInfo->pNext;
+ auto *chain_info = reinterpret_cast<const VkLayerInstanceCreateInfo *>(pCreateInfo->pNext);
while (chain_info &&
!(chain_info->sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO && chain_info->function == func))
{
- chain_info = (VkLayerInstanceCreateInfo *)chain_info->pNext;
+ chain_info = reinterpret_cast<const VkLayerInstanceCreateInfo *>(chain_info->pNext);
}
- return chain_info;
+ return const_cast<VkLayerInstanceCreateInfo *>(chain_info);
}
VKAPI_ATTR VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, VkLayerFunction func)
{
- VkLayerDeviceCreateInfo *chain_info = (VkLayerDeviceCreateInfo *)pCreateInfo->pNext;
+ auto *chain_info = reinterpret_cast<const VkLayerDeviceCreateInfo *>(pCreateInfo->pNext);
while (chain_info &&
!(chain_info->sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO && chain_info->function == func))
{
- chain_info = (VkLayerDeviceCreateInfo *)chain_info->pNext;
+ chain_info = reinterpret_cast<const VkLayerDeviceCreateInfo *>(chain_info->pNext);
}
- return chain_info;
+ return const_cast<VkLayerDeviceCreateInfo *>(chain_info);
}
template <typename T>
auto result = g_instance_data.try_insert(std::make_pair(key, instance_data.get()));
if (result.has_value())
{
- instance_data.release();
+ instance_data.release(); // NOLINT(bugprone-unused-return-value)
return VK_SUCCESS;
}
else
auto result = g_device_data.try_insert(std::make_pair(key, device_data.get()));
if (result.has_value())
{
- device_data.release();
+ device_data.release(); // NOLINT(bugprone-unused-return-value)
return VK_SUCCESS;
}
else
}
assert(swapc != VK_NULL_HANDLE);
- wsi::swapchain_base *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
+ auto *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
wsi::destroy_surface_swapchain(sc, device_data, pAllocator);
}
assert(pSwapchainImageCount != nullptr);
assert(swapc != VK_NULL_HANDLE);
- wsi::swapchain_base *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
+ auto *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
return sc->get_swapchain_images(pSwapchainImageCount, pSwapchainImages);
}
assert(swapc != VK_NULL_HANDLE);
assert(semaphore != VK_NULL_HANDLE || fence != VK_NULL_HANDLE);
assert(pImageIndex != nullptr);
- wsi::swapchain_base *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
+ auto *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
return sc->acquire_next_image(timeout, semaphore, fence, pImageIndex);
}
{
VkSwapchainKHR swapc = pPresentInfo->pSwapchains[i];
- wsi::swapchain_base *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
+ auto *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
assert(sc != nullptr);
VkResult res = sc->queue_present(queue, pPresentInfo, pPresentInfo->pImageIndices[i]);
return device_data.disp.AcquireNextImage2KHR(device, pAcquireInfo, pImageIndex);
}
- wsi::swapchain_base *sc = reinterpret_cast<wsi::swapchain_base *>(pAcquireInfo->swapchain);
+ auto *sc = reinterpret_cast<wsi::swapchain_base *>(pAcquireInfo->swapchain);
return sc->acquire_next_image(pAcquireInfo->timeout, pAcquireInfo->semaphore, pAcquireInfo->fence, pImageIndex);
}
{
auto &device_data = layer::device_private_data::get(device);
- const VkImageSwapchainCreateInfoKHR *image_sc_create_info =
- util::find_extension<VkImageSwapchainCreateInfoKHR>(VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR,
- pCreateInfo->pNext);
+ const auto *image_sc_create_info = util::find_extension<VkImageSwapchainCreateInfoKHR>(
+ VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR, pCreateInfo->pNext);
if (image_sc_create_info == nullptr || !device_data.layer_owns_swapchain(image_sc_create_info->swapchain))
{
for (uint32_t i = 0; i < bindInfoCount; i++)
{
- const VkBindImageMemorySwapchainInfoKHR *bind_sc_info = util::find_extension<VkBindImageMemorySwapchainInfoKHR>(
+ const auto *bind_sc_info = util::find_extension<VkBindImageMemorySwapchainInfoKHR>(
VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR, pBindInfos[i].pNext);
if (bind_sc_info == nullptr || bind_sc_info->swapchain == VK_NULL_HANDLE ||
template <typename T, typename... Args>
util::unique_ptr<T> make_unique(Args &&...args) const noexcept;
- VkAllocationCallbacks m_callbacks;
+ VkAllocationCallbacks m_callbacks{};
VkSystemAllocationScope m_scope;
};
#include "extension_list.hpp"
#include "util/custom_allocator.hpp"
#include <layer/private_data.hpp>
-#include <string.h>
+#include <cstring>
#include <cassert>
namespace util
/*
- * Copyright (c) 2017, 2019 Arm Limited.
+ * Copyright (c) 2017, 2019, 2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
/* only programming error can cause _destroy to fail */
assert(res == 0);
- res = pthread_mutex_init(&m_mutex, NULL);
+ res = pthread_mutex_init(&m_mutex, nullptr);
/* only programming errors can result in failure */
assert(res == 0);
static_cast<long>(timeout % (1000 * 1000 * 1000))
};
- struct timespec now;
+ struct timespec now = {};
res = clock_gettime(CLOCK_MONOTONIC, &now);
assert(res == 0); /* only fails with programming error (EINVAL, EFAULT, EPERM) */
VkResult res = VK_SUCCESS;
/* Construct a list of all formats supported by the driver - for color attachment */
constexpr int max_core_1_0_formats = VK_FORMAT_ASTC_12x12_SRGB_BLOCK + 1;
- VkFormat formats[max_core_1_0_formats];
+ std::array<VkFormat, max_core_1_0_formats> formats{};
uint32_t format_count = 0;
for (int id = 0; id < max_core_1_0_formats; id++)
struct image_data
{
/* Device memory backing the image. */
- VkDeviceMemory memory;
+ VkDeviceMemory memory{};
fence_sync present_fence;
};
swapchain_base::swapchain_base(layer::device_private_data &dev_data, const VkAllocationCallbacks *callbacks)
: m_device_data(dev_data)
, m_page_flip_thread_run(false)
+ , m_is_valid(false)
+ , m_start_present_semaphore()
, m_thread_sem_defined(false)
, m_first_present(true)
- , m_pending_buffer_pool{}
+ , m_pending_buffer_pool()
, m_allocator(dev_data.get_allocator(), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT, callbacks)
, m_swapchain_images(m_allocator)
, m_surface(VK_NULL_HANDLE)
std::unique_lock<std::recursive_mutex> image_status_lock(m_image_status_mutex);
- uint32_t i;
+ size_t i;
for (i = 0; i < m_swapchain_images.size(); ++i)
{
if (m_swapchain_images[i].status == swapchain_image::FREE)
/* Waiting for free images waits for both free and pending. One pending image may be presented and acquired by a
* compositor. The WSI backend may not necessarily know which pending image is presented to change its state. It may
* be impossible to wait for that one presented image. */
- wait = m_swapchain_images.size() - acquired_images - 1;
+ wait = static_cast<int>(m_swapchain_images.size()) - acquired_images - 1;
image_status_lock.unlock();
while (wait > 0)
VkPipelineStageFlags pipeline_stage_flags = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
VkSubmitInfo submit_info = {
- VK_STRUCTURE_TYPE_SUBMIT_INFO, NULL, sem_count, sem_payload, &pipeline_stage_flags, 0, NULL, 0, NULL
+ VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, sem_count, sem_payload, &pipeline_stage_flags, 0, nullptr, 0, nullptr
};
result = dev->disp.QueueSubmit(queue, 1, &submit_info, fence);