From 5bc7555744e720130ef8c09ecd5eb199e8a25ea5 Mon Sep 17 00:00:00 2001 From: PancakeTAS Date: Mon, 15 Dec 2025 14:05:39 +0100 Subject: [PATCH] refactor(cleanup): remove cast function --- lsfg-vk-layer/src/entrypoint.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lsfg-vk-layer/src/entrypoint.cpp b/lsfg-vk-layer/src/entrypoint.cpp index 3f1cef4..225041d 100644 --- a/lsfg-vk-layer/src/entrypoint.cpp +++ b/lsfg-vk-layer/src/entrypoint.cpp @@ -16,12 +16,6 @@ using namespace lsfgvk; namespace { - /// reinterpret cast helper with const_cast - template - T vcast(U ptr) { - return reinterpret_cast(const_cast(ptr)); // NOLINT - } - /// helper function to add required extensions std::vector add_extensions(const char* const* existingExtensions, size_t count, const std::vector& requiredExtensions) { @@ -67,10 +61,10 @@ namespace { } // apply layer chaining - auto* layerInfo = vcast(info->pNext); + auto* layerInfo = reinterpret_cast(const_cast(info->pNext)); while (layerInfo && (layerInfo->sType != VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO || layerInfo->function != VK_LAYER_LINK_INFO)) { - layerInfo = vcast(layerInfo->pNext); + layerInfo = reinterpret_cast(const_cast(layerInfo->pNext)); } if (!layerInfo) { std::cerr << "lsfg-vk: no layer info found in pNext chain, " @@ -141,10 +135,10 @@ namespace { const VkAllocationCallbacks* alloc, VkDevice* device) { // apply layer chaining - auto* layerInfo = vcast(info->pNext); + auto* layerInfo = reinterpret_cast(const_cast(info->pNext)); while (layerInfo && (layerInfo->sType != VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO || layerInfo->function != VK_LAYER_LINK_INFO)) { - layerInfo = vcast(layerInfo->pNext); + layerInfo = reinterpret_cast(const_cast(layerInfo->pNext)); } if (!layerInfo) { std::cerr << "lsfg-vk: no layer info found in pNext chain, " @@ -169,10 +163,10 @@ namespace { layerInfo->u.pLayerInfo = linkInfo->pNext; // advance for next layer // fetch device loader functions - layerInfo = vcast(info->pNext); + layerInfo = reinterpret_cast(const_cast(info->pNext)); while (layerInfo && (layerInfo->sType != VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO || layerInfo->function != VK_LOADER_DATA_CALLBACK)) { - layerInfo = vcast(layerInfo->pNext); + layerInfo = reinterpret_cast(const_cast(layerInfo->pNext)); } if (!layerInfo) { std::cerr << "lsfg-vk: no layer loader data found in pNext chain.\n";