From 5dc4ebade17e700a9edb50361224b73690fed24f Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 30 Jul 2025 23:25:27 +0200 Subject: [PATCH] Fix Vulkan perf tracing with Tracy on Switch --- Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp | 7 ++----- Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp index 99b3712ae..1a8739acc 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp @@ -111,7 +111,7 @@ GPUContextVulkan::GPUContextVulkan(GPUDeviceVulkan* device, QueueVulkan* queue) #endif #if GPU_ENABLE_TRACY -#if VK_EXT_calibrated_timestamps && VK_EXT_host_query_reset +#if VK_EXT_calibrated_timestamps && VK_EXT_host_query_reset && !PLATFORM_SWITCH // Use calibrated timestamps extension if (vkResetQueryPoolEXT && vkGetCalibratedTimestampsEXT) { @@ -120,7 +120,7 @@ GPUContextVulkan::GPUContextVulkan(GPUDeviceVulkan* device, QueueVulkan* queue) else #endif { - // Use immediate command buffer for Tracy initialization + // Use immediate command buffer for timestamps calibration VkCommandBufferAllocateInfo cmdInfo; RenderToolsVulkan::ZeroStruct(cmdInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO); cmdInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; @@ -1021,9 +1021,7 @@ void GPUContextVulkan::ResetCB() void GPUContextVulkan::BindCB(int32 slot, GPUConstantBuffer* cb) { ASSERT(slot >= 0 && slot < GPU_MAX_CB_BINDED); - const auto cbVulkan = static_cast(cb); - if (_cbHandles[slot] != cbVulkan) { _cbDirtyFlag = true; @@ -1110,7 +1108,6 @@ void GPUContextVulkan::UpdateCB(GPUConstantBuffer* cb, const void* data) const uint32 size = cbVulkan->GetSize(); if (size == 0) return; - const auto cmdBuffer = _cmdBufferManager->GetCmdBuffer(); // Allocate bytes for the buffer const auto allocation = _device->UniformBufferUploader->Allocate(size, 0, this); diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp index 083748aaa..fb7510a2d 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp @@ -52,6 +52,9 @@ bool SupportsDebugUtilsExt = false; #if VK_EXT_debug_utils VkDebugUtilsMessengerEXT Messenger = VK_NULL_HANDLE; #endif +#if PLATFORM_SWITCH +VkInstance SwitchVkInstance = VK_NULL_HANDLE; +#endif bool SupportsDebugCallbackExt = false; VkDebugReportCallbackEXT MsgCallback = VK_NULL_HANDLE; @@ -1241,7 +1244,9 @@ GPUDevice* GPUDeviceVulkan::Create() return nullptr; } -#if !PLATFORM_SWITCH +#if PLATFORM_SWITCH + SwitchVkInstance = Instance; +#else // Setup bindings volkLoadInstance(Instance); #endif