From 95d813653964b37f23af370bb0e85196156d7dd0 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 23 Dec 2024 15:38:25 +0100 Subject: [PATCH] [Vk] add missing checkVkResult, but not in destroy() --- .../Compositor/Pass/OgreCompositorPass.cpp | 2 +- .../Vulkan/src/OgreVulkanDescriptorPool.cpp | 3 +- RenderSystems/Vulkan/src/OgreVulkanDevice.cpp | 17 ++++++----- RenderSystems/Vulkan/src/OgreVulkanQueue.cpp | 28 ++++++++++++++----- .../src/OgreVulkanTextureGpuManager.cpp | 3 +- RenderSystems/Vulkan/src/OgreVulkanWindow.cpp | 7 +++-- .../Tutorial_VulkanExternal.cpp | 10 +++++-- 7 files changed, 48 insertions(+), 22 deletions(-) diff --git a/OgreMain/src/Compositor/Pass/OgreCompositorPass.cpp b/OgreMain/src/Compositor/Pass/OgreCompositorPass.cpp index 4f0aeec037c..d0f048ab914 100644 --- a/OgreMain/src/Compositor/Pass/OgreCompositorPass.cpp +++ b/OgreMain/src/Compositor/Pass/OgreCompositorPass.cpp @@ -331,7 +331,7 @@ namespace Ogre { renderPassDesc->entriesModified( RenderPassDescriptor::All ); } - catch( Exception &e ) + catch( Exception & ) { LogManager::getSingleton().logMessage( "The compositor pass '" + mDefinition->mProfilingId + "' from Node: '" + diff --git a/RenderSystems/Vulkan/src/OgreVulkanDescriptorPool.cpp b/RenderSystems/Vulkan/src/OgreVulkanDescriptorPool.cpp index c53720835e6..30fced6b561 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDescriptorPool.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDescriptorPool.cpp @@ -191,7 +191,8 @@ namespace Ogre while( itor != endt ) { - vkResetDescriptorPool( device->mDevice, itor->pool, 0 ); + VkResult result = vkResetDescriptorPool( device->mDevice, itor->pool, 0 ); + checkVkResult( result, "vkResetDescriptorPool" ); itor->size = 0u; ++itor; } diff --git a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp index 547225d3c11..dd9e5a70897 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp @@ -518,7 +518,7 @@ namespace Ogre { if( mDevice ) { - vkDeviceWaitIdle( mDevice ); + vkDeviceWaitIdle( mDevice ); // intentionally ignore result in destroy() mGraphicsQueue.destroy(); destroyQueues( mComputeQueues ); @@ -714,12 +714,15 @@ namespace Ogre // Obtain logical device uint32 numExtensions = 0; - vkEnumerateDeviceExtensionProperties( mPhysicalDevice, 0, &numExtensions, 0 ); + VkResult result = vkEnumerateDeviceExtensionProperties( mPhysicalDevice, 0, &numExtensions, 0 ); + checkVkResult( result, "vkEnumerateDeviceExtensionProperties" ); FastArray availableExtensions; availableExtensions.resize( numExtensions ); - vkEnumerateDeviceExtensionProperties( mPhysicalDevice, 0, &numExtensions, - availableExtensions.begin() ); + result = vkEnumerateDeviceExtensionProperties( mPhysicalDevice, 0, &numExtensions, + availableExtensions.begin() ); + checkVkResult( result, "vkEnumerateDeviceExtensionProperties" ); + if( !externalDevice ) { createDevice( availableExtensions, 0u, 0u ); @@ -776,8 +779,7 @@ namespace Ogre // initial pipeline cache VkPipelineCacheCreateInfo pipelineCacheCreateInfo; makeVkStruct( pipelineCacheCreateInfo, VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO ); - VkResult result = - vkCreatePipelineCache( mDevice, &pipelineCacheCreateInfo, nullptr, &mPipelineCache ); + result = vkCreatePipelineCache( mDevice, &pipelineCacheCreateInfo, nullptr, &mPipelineCache ); checkVkResult( result, "vkCreatePipelineCache" ); // debug utils @@ -1064,7 +1066,8 @@ namespace Ogre commitAndNextCommandBuffer( SubmissionType::FlushOnly ); mRenderSystem->resetAllBindings(); - vkDeviceWaitIdle( mDevice ); + VkResult result = vkDeviceWaitIdle( mDevice ); + checkVkResult( result, "vkDeviceWaitIdle" ); mRenderSystem->_notifyDeviceStalled(); } diff --git a/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp b/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp index 1bc8dcb9723..9cc27b98199 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp @@ -74,7 +74,7 @@ namespace Ogre { if( mDevice ) { - vkDeviceWaitIdle( mDevice ); + vkDeviceWaitIdle( mDevice ); // intentionally ignore result in destroy() mWindowsPendingSwap.clear(); @@ -160,7 +160,11 @@ namespace Ogre // Reset the recycled fences so they can be used again const uint32 numFencesToReset = (uint32)( mAvailableFences.size() - oldNumAvailableFences ); if( numFencesToReset > 0u ) - vkResetFences( mDevice, numFencesToReset, &mAvailableFences[oldNumAvailableFences] ); + { + VkResult result = + vkResetFences( mDevice, numFencesToReset, &mAvailableFences[oldNumAvailableFences] ); + checkVkResult( result, "vkResetFences" ); + } } //------------------------------------------------------------------------- inline VkFence VulkanQueue::getCurrentFence() @@ -192,7 +196,10 @@ namespace Ogre frameData.mCommands.push_back( cmdBuffer ); } else if( frameData.mCurrentCmdIdx == 0u ) - vkResetCommandPool( mDevice, frameData.mCmdPool, 0 ); + { + VkResult result = vkResetCommandPool( mDevice, frameData.mCmdPool, 0 ); + checkVkResult( result, "vkResetCommandPool" ); + } return frameData.mCommands[frameData.mCurrentCmdIdx++]; } @@ -280,7 +287,11 @@ namespace Ogre cmdPoolCreateInfo.queueFamilyIndex = mFamilyIdx; for( size_t i = 0; i < maxNumFrames; ++i ) - vkCreateCommandPool( mDevice, &cmdPoolCreateInfo, 0, &mPerFrameData[i].mCmdPool ); + { + VkResult result = + vkCreateCommandPool( mDevice, &cmdPoolCreateInfo, 0, &mPerFrameData[i].mCmdPool ); + checkVkResult( result, "vkCreateCommandPool" ); + } newCommandBuffer(); } @@ -293,7 +304,8 @@ namespace Ogre VkCommandBufferBeginInfo beginInfo; makeVkStruct( beginInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO ); beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - vkBeginCommandBuffer( mCurrentCmdBuffer, &beginInfo ); + VkResult result = vkBeginCommandBuffer( mCurrentCmdBuffer, &beginInfo ); + checkVkResult( result, "vkBeginCommandBuffer" ); } //------------------------------------------------------------------------- void VulkanQueue::endCommandBuffer() @@ -1117,7 +1129,8 @@ namespace Ogre { if( itor->second.recycleAfterRelease ) { - vkResetFences( mDevice, 1u, &itor->first ); + VkResult result = vkResetFences( mDevice, 1u, &itor->first ); + checkVkResult( result, "vkResetFences" ); mAvailableFences.push_back( itor->first ); } mRefCountedFences.erase( itor ); @@ -1145,7 +1158,8 @@ namespace Ogre if( !fences.empty() ) { const uint32 numFences = static_cast( fences.size() ); - vkWaitForFences( mDevice, numFences, &fences[0], VK_TRUE, UINT64_MAX ); + VkResult result = vkWaitForFences( mDevice, numFences, &fences[0], VK_TRUE, UINT64_MAX ); + checkVkResult( result, "vkWaitForFences" ); recycleFences( fences ); } } diff --git a/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp b/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp index e2bae071676..a202fa5cd7e 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp @@ -294,7 +294,8 @@ namespace Ogre // We will be releasing the staging texture memory immediately. We must flush out manually mDevice->commitAndNextCommandBuffer( SubmissionType::FlushOnly ); - vkDeviceWaitIdle( mDevice->mDevice ); + VkResult result = vkDeviceWaitIdle( mDevice->mDevice ); + checkVkResult( result, "vkDeviceWaitIdle" ); vaoManager->destroyStagingTexture( stagingTex ); delete stagingTex; diff --git a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp index fc9f37924c5..4cce0bd502e 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp @@ -319,12 +319,15 @@ namespace Ogre } uint32 numPresentModes = 0u; - vkGetPhysicalDeviceSurfacePresentModesKHR( mDevice->mPhysicalDevice, mSurfaceKHR, + result = vkGetPhysicalDeviceSurfacePresentModesKHR( mDevice->mPhysicalDevice, mSurfaceKHR, &numPresentModes, 0 ); + checkVkResult( result, "vkGetPhysicalDeviceSurfacePresentModesKHR" ); + FastArray presentModes; presentModes.resize( numPresentModes ); - vkGetPhysicalDeviceSurfacePresentModesKHR( mDevice->mPhysicalDevice, mSurfaceKHR, + result = vkGetPhysicalDeviceSurfacePresentModesKHR( mDevice->mPhysicalDevice, mSurfaceKHR, &numPresentModes, presentModes.begin() ); + checkVkResult( result, "vkGetPhysicalDeviceSurfacePresentModesKHR" ); // targetPresentModes[0] is the target, targetPresentModes[1] is the fallback bool presentModesFound[2] = { false, false }; diff --git a/Samples/2.0/Tutorials/Tutorial_VulkanExternal/Tutorial_VulkanExternal.cpp b/Samples/2.0/Tutorials/Tutorial_VulkanExternal/Tutorial_VulkanExternal.cpp index 1230493ca63..904b8f4ca63 100644 --- a/Samples/2.0/Tutorials/Tutorial_VulkanExternal/Tutorial_VulkanExternal.cpp +++ b/Samples/2.0/Tutorials/Tutorial_VulkanExternal/Tutorial_VulkanExternal.cpp @@ -308,12 +308,16 @@ static void createVulkanDevice( const Ogre::VulkanExternalInstance &externalInst FastArray deviceExtensions; { uint32_t numExtensions = 0; - vkEnumerateDeviceExtensionProperties( outExternalDevice.physicalDevice, 0, &numExtensions, 0 ); + VkResult result = vkEnumerateDeviceExtensionProperties( outExternalDevice.physicalDevice, 0, + &numExtensions, 0 ); + myCheckVkResult( result, "vkCreateInstance" ); FastArray availableExtensions; availableExtensions.resize( numExtensions ); - vkEnumerateDeviceExtensionProperties( outExternalDevice.physicalDevice, 0, &numExtensions, - availableExtensions.begin() ); + result = vkEnumerateDeviceExtensionProperties( outExternalDevice.physicalDevice, 0, + &numExtensions, availableExtensions.begin() ); + myCheckVkResult( result, "vkCreateInstance" ); + for( size_t i = 0u; i < numExtensions; ++i ) { const String extensionName = availableExtensions[i].extensionName;