From bc67f3e5927697dbc66dbf64beb093f6d4a3c3e3 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 12 Sep 2024 13:13:01 +0200 Subject: [PATCH 01/47] [Vk] use mPipelineCache for vkCreateComputePipelines() too --- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 71e5906dad..b8fdd1ab78 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -2060,8 +2060,8 @@ namespace Ogre #endif VkPipeline vulkanPso = 0u; - VkResult result = vkCreateComputePipelines( mActiveDevice->mDevice, VK_NULL_HANDLE, 1u, - &computeInfo, 0, &vulkanPso ); + VkResult result = vkCreateComputePipelines( + mActiveDevice->mDevice, mActiveDevice->mPipelineCache, 1u, &computeInfo, 0, &vulkanPso ); checkVkResult( result, "vkCreateComputePipelines" ); #if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM From 4444e823303fb73ab2928a04f7bb1285414fce96 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 12 Sep 2024 20:21:47 +0200 Subject: [PATCH 02/47] [Vk] tessellationShader ... If not enabled, the ... VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO enum values must not be used. VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214 - patchControlPoints must be greater than zero and less than or equal to VkPhysicalDeviceLimits::maxTessellationPatchSize --- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index b8fdd1ab78..9a8702ab56 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -3351,6 +3351,15 @@ namespace Ogre debugLogPso( newPso ); #endif + if( ( newPso->geometryShader && !mActiveDevice->mDeviceFeatures.geometryShader ) || + ( newPso->tesselationHullShader && !mActiveDevice->mDeviceFeatures.tessellationShader ) || + ( newPso->tesselationDomainShader && !mActiveDevice->mDeviceFeatures.tessellationShader ) ) + { + OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, + "Geometry or tesselation shaders are not supported", + "VulkanRenderSystem::_hlmsPipelineStateObjectCreated" ); + } + size_t numShaderStages = 0u; VkPipelineShaderStageCreateInfo shaderStages[NumShaderTypes]; @@ -3476,6 +3485,9 @@ namespace Ogre VkPipelineTessellationStateCreateInfo tessStateCi; makeVkStruct( tessStateCi, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO ); + tessStateCi.patchControlPoints = 1u; + bool useTesselationState = mActiveDevice->mDeviceFeatures.tessellationShader && + ( newPso->tesselationHullShader || newPso->tesselationDomainShader ); VkPipelineViewportStateCreateInfo viewportStateCi; makeVkStruct( viewportStateCi, VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO ); @@ -3625,7 +3637,7 @@ namespace Ogre pipeline.pStages = shaderStages; pipeline.pVertexInputState = &vertexFormatCi; pipeline.pInputAssemblyState = &inputAssemblyCi; - pipeline.pTessellationState = &tessStateCi; + pipeline.pTessellationState = useTesselationState ? &tessStateCi : nullptr; pipeline.pViewportState = &viewportStateCi; pipeline.pRasterizationState = &rasterState; pipeline.pMultisampleState = &mssCi; From 9e3fc3c434ebc0114a769eadc4fc3a4e9e8a47c4 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Fri, 13 Sep 2024 21:36:24 +0200 Subject: [PATCH 03/47] [Vk] Fixed validation errors in vkDebugMarkerSetObjectNameEXT usage --- RenderSystems/Vulkan/src/OgreVulkanProgram.cpp | 4 ++-- RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanProgram.cpp b/RenderSystems/Vulkan/src/OgreVulkanProgram.cpp index 7bc5830207..d3b87bc146 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanProgram.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanProgram.cpp @@ -361,7 +361,7 @@ namespace Ogre checkVkResult( result, "vkCreateShaderModule" ); setObjectName( mDevice->mDevice, (uint64_t)mShaderModule, - VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, mName.c_str() ); + VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT, mName.c_str() ); } if( !mSpirv.empty() && mType == GPT_VERTEX_PROGRAM ) @@ -778,7 +778,7 @@ namespace Ogre checkVkResult( result, "vkCreateShaderModule" ); setObjectName( mDevice->mDevice, (uint64_t)mShaderModule, - VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, mName.c_str() ); + VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT, mName.c_str() ); } if( !mSpirv.empty() && mType == GPT_VERTEX_PROGRAM ) diff --git a/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp b/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp index de0d8a2e84..48976353cf 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp @@ -818,7 +818,7 @@ namespace Ogre #if OGRE_DEBUG_MODE >= OGRE_DEBUG_HIGH const String textureName = getNameStr() + "(View)"; - setObjectName( device->mDevice, (uint64_t)imageView, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + setObjectName( device->mDevice, (uint64_t)imageView, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT, textureName.c_str() ); #endif From 4a30febab02d553e965a149f7afc662679a9af14 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 16 Sep 2024 18:01:20 +0200 Subject: [PATCH 04/47] [Vk] Keep MSAA vulkan texture in predictable state to avoid layout validation errors when resolved texture of VulkanTextureGpuRenderTarget was used as shader resource. Can we skip this barrier if MSAA subtexture is already in required state? --- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 9a8702ab56..987190cb42 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -3292,20 +3292,28 @@ namespace Ogre if( texture->isMultisample() && !texture->hasMsaaExplicitResolves() ) { // Rare case where we render to an implicit resolve without resolving - // (otherwise newLayout = ResolveDest) - // - // Or more common case if we need to copy to/from an MSAA texture + // (otherwise newLayout = ResolveDest), or more common case if we need + // to copy to/from an MSAA texture. We can also try to sample from texture. + // In all these cases keep MSAA texture in predictable layout. // // This cannot catch all use cases, but if you fall into something this // doesn't catch, then you should probably be using explicit resolves - if( itor->newLayout == ResourceLayout::RenderTarget || - itor->newLayout == ResourceLayout::ResolveDest || - itor->newLayout == ResourceLayout::CopySrc || - itor->newLayout == ResourceLayout::CopyDst ) - { - imageBarrier.image = texture->getMsaaFramebufferName(); - mImageBarriers.push_back( imageBarrier ); - } + bool useNewLayoutForMsaa = + itor->newLayout == ResourceLayout::RenderTarget || + itor->newLayout == ResourceLayout::ResolveDest || + itor->newLayout == ResourceLayout::CopySrc || + itor->newLayout == ResourceLayout::CopyDst; + bool useOldLayoutForMsaa = + itor->oldLayout == ResourceLayout::RenderTarget || + itor->oldLayout == ResourceLayout::ResolveDest || + itor->oldLayout == ResourceLayout::CopySrc || + itor->oldLayout == ResourceLayout::CopyDst; + if( !useNewLayoutForMsaa ) + imageBarrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + if( !useOldLayoutForMsaa ) + imageBarrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + imageBarrier.image = texture->getMsaaFramebufferName(); + mImageBarriers.push_back( imageBarrier ); } } else From 56d36e72e992863253cc0f012792cdd94ae54d8c Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 16 Sep 2024 23:33:00 +0200 Subject: [PATCH 05/47] [Vk] fixed SIGSEGV in VulkanDescriptorSetTexture::setHazardousTex() due to the iterators invalidation --- RenderSystems/Vulkan/src/OgreVulkanDescriptorSets.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/RenderSystems/Vulkan/src/OgreVulkanDescriptorSets.cpp b/RenderSystems/Vulkan/src/OgreVulkanDescriptorSets.cpp index 867bdb3e00..130efa69e2 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDescriptorSets.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDescriptorSets.cpp @@ -122,6 +122,7 @@ namespace Ogre if( mLastHazardousTex != hazardousTexIdx ) { const size_t realNumTextures = descSet.mTextures.size(); + mTextures.reserve( 2 * realNumTextures ); mTextures.resize( realNumTextures ); mTextures.appendPOD( mTextures.begin(), mTextures.end() ); mWriteDescSetHazardous.pImageInfo = mTextures.begin() + realNumTextures; From efba9f59222f5d3e135f6c8c6907ec874884b4ea Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Wed, 18 Sep 2024 04:12:38 +0200 Subject: [PATCH 06/47] [Vk] Fixed misaligned const buffers on Android Simulator Medium Phone API 29 with enabled validation layer. Main idea - we need to align offsets rather than pointers if minMemoryMapAlignment < minUniformBufferOffsetAlignment. On that simulator minMemoryMapAlignment = 64, minUniformBufferOffsetAlignment = 256, that is quite strange but technically not forbidden. https://vulkan.gpuinfo.org/displaydevicelimit.php?platform=android&name=minMemoryMapAlignment https://vulkan.gpuinfo.org/displaydevicelimit.php?platform=android&name=minUniformBufferOffsetAlignment "ERROR: [Validation] Code 0 : Validation Error: [ VUID-VkWriteDescriptorSet-descriptorType-00327 ] | MessageID = 0xfdcfe89e | vkUpdateDescriptorSets(): pDescriptorWrites[1].pBufferInfo[0].offset (8913136) must be a multiple of device limit minUniformBufferOffsetAlignment 256 when descriptor type is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER. The Vulkan spec states: If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER or VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, the offset member of each element of pBufferInfo must be a multiple of VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkWriteDescriptorSet-descriptorType-00327)" --- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 987190cb42..9f1a43c791 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -2533,15 +2533,20 @@ namespace Ogre size_t bytesToWrite = shader->getBufferRequiredSize(); if( shader && bytesToWrite > 0 ) { - if( mCurrentAutoParamsBufferSpaceLeft < bytesToWrite ) + OGRE_ASSERT_LOW( + mCurrentAutoParamsBufferSpaceLeft % mVaoManager->getConstBufferAlignment() == 0 ); + + size_t bytesToWriteAligned = + alignToNextMultiple( bytesToWrite, mVaoManager->getConstBufferAlignment() ); + if( mCurrentAutoParamsBufferSpaceLeft < bytesToWriteAligned ) { if( mAutoParamsBufferIdx >= mAutoParamsBuffer.size() ) { // Ask for a coherent buffer to avoid excessive flushing. Note: VaoManager may ignore // this request if the GPU can't provide coherent memory and we must flush anyway. - ConstBufferPacked *constBuffer = - mVaoManager->createConstBuffer( std::max( 512u * 1024u, bytesToWrite ), - BT_DYNAMIC_PERSISTENT_COHERENT, 0, false ); + ConstBufferPacked *constBuffer = mVaoManager->createConstBuffer( + std::max( 512u * 1024u, bytesToWriteAligned ), + BT_DYNAMIC_PERSISTENT_COHERENT, 0, false ); mAutoParamsBuffer.push_back( constBuffer ); } @@ -2550,7 +2555,7 @@ namespace Ogre // This should be near-impossible to trigger because most Const Buffers are <= 64kb // and we reserver 512kb per const buffer. A Low Level Material using a Params buffer // with > 64kb is an edge case we don't care handling. - OGRE_ASSERT_LOW( bytesToWrite <= constBuffer->getTotalSizeBytes() ); + OGRE_ASSERT_LOW( bytesToWriteAligned <= constBuffer->getTotalSizeBytes() ); mCurrentAutoParamsBufferPtr = reinterpret_cast( constBuffer->map( 0, constBuffer->getNumElements() ) ); @@ -2571,18 +2576,8 @@ namespace Ogre constBuffer->bindAsParamBuffer( gptype, bindOffset, bytesToWrite ); - mCurrentAutoParamsBufferPtr += bytesToWrite; - - const uint8 *oldBufferPos = mCurrentAutoParamsBufferPtr; - mCurrentAutoParamsBufferPtr = reinterpret_cast( - alignToNextMultiple( reinterpret_cast( mCurrentAutoParamsBufferPtr ), - mVaoManager->getConstBufferAlignment() ) ); - bytesToWrite += (size_t)( mCurrentAutoParamsBufferPtr - oldBufferPos ); - - // We know that bytesToWrite <= mCurrentAutoParamsBufferSpaceLeft, but that was - // before padding. After padding this may no longer hold true. - mCurrentAutoParamsBufferSpaceLeft -= - std::min( mCurrentAutoParamsBufferSpaceLeft, bytesToWrite ); + mCurrentAutoParamsBufferPtr += bytesToWriteAligned; + mCurrentAutoParamsBufferSpaceLeft -= bytesToWriteAligned; } } //------------------------------------------------------------------------- From 6bbe5828e388b88048bfa1fc875979709cb7176a Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Wed, 18 Sep 2024 17:31:59 +0200 Subject: [PATCH 07/47] Disable blending for autogenerated shadow caster blend blocks. Fixed Vulkan validation layer errors on Google Pixel 7 Pro, that does not supports VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT for PFG_R32_FLOAT aka VK_FORMAT_R32_SFLOAT, that often used for shadow maps. --- OgreMain/src/OgreHlmsDatablock.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/OgreMain/src/OgreHlmsDatablock.cpp b/OgreMain/src/OgreHlmsDatablock.cpp index 3ca7025005..0db77973d0 100644 --- a/OgreMain/src/OgreHlmsDatablock.cpp +++ b/OgreMain/src/OgreHlmsDatablock.cpp @@ -382,13 +382,19 @@ namespace Ogre if( !casterBlock && overrideCasterBlock ) { mIgnoreFlushRenderables = true; - if( mBlendblock[0]->mAlphaToCoverage == HlmsBlendblock::A2cDisabled ) + if( mBlendblock[0]->mAlphaToCoverage == HlmsBlendblock::A2cDisabled && + mBlendblock[0]->mSourceBlendFactor == SBF_ONE && + mBlendblock[0]->mDestBlendFactor == SBF_ZERO && + ( !mBlendblock[0]->mSeparateBlend || + ( mBlendblock[0]->mSourceBlendFactorAlpha == SBF_ONE && + mBlendblock[0]->mDestBlendFactorAlpha == SBF_ZERO ) ) ) setBlendblock( mBlendblock[0], true ); else { - HlmsBlendblock blendblockNoAC = *mBlendblock[0]; - blendblockNoAC.mAlphaToCoverage = HlmsBlendblock::A2cDisabled; - setBlendblock( blendblockNoAC, true ); + HlmsBlendblock casterBlendblock = *mBlendblock[0]; + casterBlendblock.mAlphaToCoverage = HlmsBlendblock::A2cDisabled; + casterBlendblock.setBlendType( SBT_REPLACE ); + setBlendblock( casterBlendblock, true ); } mIgnoreFlushRenderables = false; } @@ -419,13 +425,19 @@ namespace Ogre if( !casterBlock && overrideCasterBlock ) { mIgnoreFlushRenderables = true; - if( mBlendblock[0]->mAlphaToCoverage == HlmsBlendblock::A2cDisabled ) + if( mBlendblock[0]->mAlphaToCoverage == HlmsBlendblock::A2cDisabled && + mBlendblock[0]->mSourceBlendFactor == SBF_ONE && + mBlendblock[0]->mDestBlendFactor == SBF_ZERO && + ( !mBlendblock[0]->mSeparateBlend || + ( mBlendblock[0]->mSourceBlendFactorAlpha == SBF_ONE && + mBlendblock[0]->mDestBlendFactorAlpha == SBF_ZERO ) ) ) setBlendblock( mBlendblock[0], true ); else { - HlmsBlendblock blendblockNoAC = *mBlendblock[0]; - blendblockNoAC.mAlphaToCoverage = HlmsBlendblock::A2cDisabled; - setBlendblock( blendblockNoAC, true ); + HlmsBlendblock casterBlendblock = *mBlendblock[0]; + casterBlendblock.mAlphaToCoverage = HlmsBlendblock::A2cDisabled; + casterBlendblock.setBlendType( SBT_REPLACE ); + setBlendblock( casterBlendblock, true ); } mIgnoreFlushRenderables = false; } From d8bb8e776d80d3e11aba5bce1b3e9b6bddaf0977 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 19 Sep 2024 00:22:30 +0200 Subject: [PATCH 08/47] [Vk] Fixed validation layer "ERROR: [vulkan] Code 0 : invalid vkGetInstanceProcAddr(0xb400006fc4dd30d0, "vkEnumerateInstanceVersion") call" - vkEnumerateInstanceVersion is "global" API, see vkGetInstanceProcAddr docs --- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 9f1a43c791..768bbe42cd 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -1285,8 +1285,7 @@ namespace Ogre { // vkEnumerateInstanceVersion is available since Vulkan 1.1 PFN_vkEnumerateInstanceVersion enumerateInstanceVersion = - (PFN_vkEnumerateInstanceVersion)vkGetInstanceProcAddr( mVkInstance, - "vkEnumerateInstanceVersion" ); + (PFN_vkEnumerateInstanceVersion)vkGetInstanceProcAddr( 0, "vkEnumerateInstanceVersion" ); if( enumerateInstanceVersion ) { uint32_t apiVersion; From e6408c54367ead77bfb66fb717c8428470dc936a Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 19 Sep 2024 10:15:46 +0200 Subject: [PATCH 09/47] [Vk] typo --- RenderSystems/Vulkan/include/Vao/OgreVulkanVaoManager.h | 6 +++--- RenderSystems/Vulkan/src/OgreVulkanQueue.cpp | 4 ++-- RenderSystems/Vulkan/src/OgreVulkanWindow.cpp | 2 +- RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/RenderSystems/Vulkan/include/Vao/OgreVulkanVaoManager.h b/RenderSystems/Vulkan/include/Vao/OgreVulkanVaoManager.h index ebb9e12f14..2cd744be8e 100644 --- a/RenderSystems/Vulkan/include/Vao/OgreVulkanVaoManager.h +++ b/RenderSystems/Vulkan/include/Vao/OgreVulkanVaoManager.h @@ -538,15 +538,15 @@ namespace Ogre /// Insert into the end of semaphoreArray 'numSemaphores' /// number of semaphores that are safe for use. - void getAvailableSempaphores( VkSemaphoreArray &semaphoreArray, size_t numSemaphores ); - VkSemaphore getAvailableSempaphore(); + void getAvailableSemaphores( VkSemaphoreArray &semaphoreArray, size_t numSemaphores ); + VkSemaphore getAvailableSemaphore(); /// Call this function after you've submitted to the GPU a VkSemaphore that will be waited on. /// i.e. 'semaphore' is part of VkSubmitInfo::pWaitSemaphores or part of /// VkPresentInfoKHR::pWaitSemaphores /// /// After enough frames have passed, this semaphore goes - /// back to a pool for getAvailableSempaphores to use + /// back to a pool for getAvailableSemaphores to use void notifyWaitSemaphoreSubmitted( VkSemaphore semaphore ); void notifyWaitSemaphoresSubmitted( const VkSemaphoreArray &semaphores ); void notifySemaphoreUnused( VkSemaphore semaphore ); diff --git a/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp b/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp index 327bc13047..a9c077f110 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp @@ -1220,8 +1220,8 @@ namespace Ogre // Get some semaphores so that presentation can wait for this job to finish rendering // (one for each window that will be swapped) numWindowsPendingSwap = mWindowsPendingSwap.size(); - mVaoManager->getAvailableSempaphores( mGpuSignalSemaphForCurrCmdBuff, - numWindowsPendingSwap ); + mVaoManager->getAvailableSemaphores( mGpuSignalSemaphForCurrCmdBuff, + numWindowsPendingSwap ); } if( !mGpuSignalSemaphForCurrCmdBuff.empty() ) diff --git a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp index 6a434faa2c..eba56e7213 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp @@ -532,7 +532,7 @@ namespace Ogre VulkanVaoManager *vaoManager = mDevice->mVaoManager; - mSwapchainSemaphore = vaoManager->getAvailableSempaphore(); + mSwapchainSemaphore = vaoManager->getAvailableSemaphore(); uint32 swapchainIdx = 0u; VkResult result = vkAcquireNextImageKHR( mDevice->mDevice, mSwapchain, UINT64_MAX, diff --git a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp index 5ed4ba5644..6758d819f6 100644 --- a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp +++ b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp @@ -2140,7 +2140,7 @@ namespace Ogre ++mFrameCount; } //----------------------------------------------------------------------------------- - void VulkanVaoManager::getAvailableSempaphores( VkSemaphoreArray &semaphoreArray, + void VulkanVaoManager::getAvailableSemaphores( VkSemaphoreArray &semaphoreArray, size_t numSemaphores ) { semaphoreArray.reserve( semaphoreArray.size() + numSemaphores ); @@ -2171,7 +2171,7 @@ namespace Ogre } } //----------------------------------------------------------------------------------- - VkSemaphore VulkanVaoManager::getAvailableSempaphore() + VkSemaphore VulkanVaoManager::getAvailableSemaphore() { VkSemaphore retVal; if( mAvailableSemaphores.empty() ) From 681973dcdcb29a09d67984fc5d60fef6e41ea2b7 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Fri, 20 Sep 2024 18:32:52 +0200 Subject: [PATCH 10/47] OGRE_FALLTHROUGH for MSVC --- OgreMain/include/OgrePrerequisites.h | 2 +- RenderSystems/Direct3D11/src/OgreD3D11Device.cpp | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/OgreMain/include/OgrePrerequisites.h b/OgreMain/include/OgrePrerequisites.h index d858a0fd5d..29fea2e075 100644 --- a/OgreMain/include/OgrePrerequisites.h +++ b/OgreMain/include/OgrePrerequisites.h @@ -82,7 +82,7 @@ namespace Ogre #define OGRE_UNUSED_VAR( x ) ( (void)x ) -#if __cplusplus >= 201703L +#if __cplusplus >= 201703L || defined( _MSVC_LANG ) && _MSVC_LANG >= 201703L # define OGRE_FALLTHROUGH [[fallthrough]] #else # if OGRE_COMPILER == OGRE_COMPILER_CLANG diff --git a/RenderSystems/Direct3D11/src/OgreD3D11Device.cpp b/RenderSystems/Direct3D11/src/OgreD3D11Device.cpp index d824c88c6a..b246b94271 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11Device.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11Device.cpp @@ -224,13 +224,8 @@ namespace Ogre char tmp[64]; sprintf( tmp, "deviceRemovedReason = 0x%08X\n", (unsigned)deviceRemovedReason ); res.append( tmp ); + OGRE_FALLTHROUGH; } - // No 'break', fallthrough to the next switch statement -#if OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG - __attribute__( ( fallthrough ) ); -#elif __cplusplus >= 201703L - [[fallthrough]]; -#endif default: { char tmp[64]; From 081c7634c2446d2a7b04f38f4bbeb97781330d02 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Fri, 20 Sep 2024 19:25:57 +0200 Subject: [PATCH 11/47] compiler warnings --- .../Direct3D11/src/OgreD3D11HLSLProgram.cpp | 4 ++-- .../src/Windowing/WIN32/OgreD3D11WindowWinRT.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp b/RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp index 9151805dfb..828cad4df7 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11HLSLProgram.cpp @@ -848,7 +848,7 @@ namespace Ogre GET_SIZE_OF_NAMES( memberTypeNameSize, mMemberTypeName, Name ); // clang-format off - int sizeOfData = sizeof(uint32) + mMicroCode.size() + size_t sizeOfData = sizeof(uint32) + mMicroCode.size() + sizeof(uint32) // mConstantBufferSize + sizeof(uint32) // mConstantBufferNr + sizeof(uint32) // mNumSlots @@ -973,7 +973,7 @@ namespace Ogre // create microcode GpuProgramManager::Microcode newMicrocode = - GpuProgramManager::getSingleton().createMicrocode( sizeOfData ); + GpuProgramManager::getSingleton().createMicrocode( (uint32)sizeOfData ); # define WRITE_START( curlist, memberType ) \ { \ diff --git a/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowWinRT.cpp b/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowWinRT.cpp index 3fb39a468b..461d9a1dda 100644 --- a/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowWinRT.cpp +++ b/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowWinRT.cpp @@ -86,8 +86,8 @@ namespace Ogre Windows::Foundation::Rect rc = mCoreWindow->Bounds; mLeft = (int)floorf( rc.X * scale + 0.5f ); mTop = (int)floorf( rc.Y * scale + 0.5f ); - mRequestedWidth = rc.Width; - mRequestedHeight = rc.Height; + mRequestedWidth = (int)floorf( rc.Width + 0.5f ); + mRequestedHeight = (int)floorf( rc.Height + 0.5f ); } //----------------------------------------------------------------------------------- D3D11WindowCoreWindow::~D3D11WindowCoreWindow() { destroy(); } @@ -176,8 +176,8 @@ namespace Ogre Windows::Foundation::Rect rc = mCoreWindow->Bounds; mLeft = (int)floorf( rc.X * scale + 0.5f ); mTop = (int)floorf( rc.Y * scale + 0.5f ); - mRequestedWidth = rc.Width; - mRequestedHeight = rc.Height; + mRequestedWidth = (int)floorf( rc.Width + 0.5f ); + mRequestedHeight = (int)floorf( rc.Height + 0.5f ); resizeSwapChainBuffers( 0, 0 ); // pass zero to autodetect size } @@ -245,8 +245,8 @@ namespace Ogre static_cast( mSwapChainPanel->ActualHeight ) ); mCompositionScale = Windows::Foundation::Size( mSwapChainPanel->CompositionScaleX, mSwapChainPanel->CompositionScaleY ); - mRequestedWidth = sz.Width; - mRequestedHeight = sz.Height; + mRequestedWidth = (int)floorf( sz.Width + 0.5f ); + mRequestedHeight = (int)floorf( sz.Height + 0.5f ); } //----------------------------------------------------------------------------------- D3D11WindowSwapChainPanel::~D3D11WindowSwapChainPanel() { destroy(); } @@ -363,8 +363,8 @@ namespace Ogre static_cast( mSwapChainPanel->ActualHeight ) ); mCompositionScale = Windows::Foundation::Size( mSwapChainPanel->CompositionScaleX, mSwapChainPanel->CompositionScaleY ); - mRequestedWidth = sz.Width; - mRequestedHeight = sz.Height; + mRequestedWidth = (int)floorf( sz.Width + 0.5f ); + mRequestedHeight = (int)floorf( sz.Height + 0.5f ); int widthPx = std::max( 1, (int)floorf( mRequestedWidth * mCompositionScale.Width + 0.5f ) ); int heightPx = std::max( 1, (int)floorf( mRequestedHeight * mCompositionScale.Height + 0.5f ) ); From 8b3ddcce580d87894fb3dd6fc09e6c68b4d67297 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Fri, 20 Sep 2024 22:18:20 +0200 Subject: [PATCH 12/47] [Vk] Wrap mCurrentCmdBuffer in accessor --- CMakeLists.txt | 2 +- .../Vulkan/include/OgreVulkanQueue.h | 7 ++- .../src/OgreVulkanAsyncTextureTicket.cpp | 4 +- .../src/OgreVulkanDiscardBufferManager.cpp | 2 +- .../src/OgreVulkanHardwareBufferCommon.cpp | 2 +- RenderSystems/Vulkan/src/OgreVulkanQueue.cpp | 10 ++-- .../src/OgreVulkanRenderPassDescriptor.cpp | 4 +- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 48 ++++++++++--------- .../Vulkan/src/OgreVulkanRootLayout.cpp | 2 +- .../Vulkan/src/OgreVulkanStagingTexture.cpp | 2 +- .../Vulkan/src/OgreVulkanTextureGpu.cpp | 16 +++---- .../src/OgreVulkanTextureGpuManager.cpp | 10 ++-- .../src/Vao/OgreVulkanBufferInterface.cpp | 4 +- .../src/Vao/OgreVulkanStagingBuffer.cpp | 8 ++-- .../Vulkan/src/Vao/OgreVulkanVaoManager.cpp | 2 +- 15 files changed, 65 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dac665e58c..dacb857854 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -559,7 +559,7 @@ set( OGRE_DEBUG_LEVEL_DEBUG 3 CACHE STRING 3 - High. We perform intensive validation without concerns for performance." ) set( OGRE_DEBUG_LEVEL_RELEASE 0 CACHE STRING - "Specify debug level for Release, RelWithDebInfo and MinSizeRel builds. See OGRE_MAX_DEBUG_LEVEL_DEBUG" ) + "Specify debug level for Release, RelWithDebInfo and MinSizeRel builds. See OGRE_DEBUG_LEVEL_DEBUG" ) cmake_dependent_option(OGRE_CONFIG_CONTAINERS_USE_CUSTOM_ALLOCATOR "STL containers in Ogre use the custom allocator" TRUE "" FALSE) if( OGRE_CONFIG_ALLOCATOR EQUAL 0 ) diff --git a/RenderSystems/Vulkan/include/OgreVulkanQueue.h b/RenderSystems/Vulkan/include/OgreVulkanQueue.h index 37b6dad1c1..a7dfa0a45f 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanQueue.h +++ b/RenderSystems/Vulkan/include/OgreVulkanQueue.h @@ -77,7 +77,6 @@ namespace Ogre uint32 mQueueIdx; VkQueue mQueue; - VkCommandBuffer mCurrentCmdBuffer; VulkanDevice *mOwnerDevice; @@ -116,6 +115,7 @@ namespace Ogre FastArray mWindowsPendingSwap; protected: + VkCommandBuffer mCurrentCmdBuffer; FastArray mPendingCmds; VulkanVaoManager *mVaoManager; @@ -220,6 +220,11 @@ namespace Ogre void endCommandBuffer(); public: + VkCommandBuffer getCurrentCmdBuffer() + { + OGRE_ASSERT_LOW( mCurrentCmdBuffer ); + return mCurrentCmdBuffer; + } EncoderState getEncoderState() const { return mEncoderState; } void getGraphicsEncoder(); diff --git a/RenderSystems/Vulkan/src/OgreVulkanAsyncTextureTicket.cpp b/RenderSystems/Vulkan/src/OgreVulkanAsyncTextureTicket.cpp index f19d91eb87..7f23f57e19 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanAsyncTextureTicket.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanAsyncTextureTicket.cpp @@ -132,7 +132,7 @@ namespace Ogre memBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; // GPU must stop using this buffer before we can write into it - vkCmdPipelineBarrier( mQueue->mCurrentCmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, + vkCmdPipelineBarrier( mQueue->getCurrentCmdBuffer(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1u, &memBarrier, 0u, 0, 0u, 0 ); } @@ -168,7 +168,7 @@ namespace Ogre region.imageExtent.height = srcTextureBox.height; region.imageExtent.depth = srcTextureBox.depth; - vkCmdCopyImageToBuffer( mQueue->mCurrentCmdBuffer, srcTextureVk->getFinalTextureName(), + vkCmdCopyImageToBuffer( mQueue->getCurrentCmdBuffer(), srcTextureVk->getFinalTextureName(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, mVboName.mVboName, 1u, ®ion ); if( accurateTracking ) diff --git a/RenderSystems/Vulkan/src/OgreVulkanDiscardBufferManager.cpp b/RenderSystems/Vulkan/src/OgreVulkanDiscardBufferManager.cpp index 78a35c689f..641757cf33 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDiscardBufferManager.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDiscardBufferManager.cpp @@ -96,7 +96,7 @@ namespace Ogre region.srcOffset = ( *itor )->getBlockStart() + oldBuffer.mInternalBufferStart; region.dstOffset = ( *itor )->getBlockStart() + mBuffer.mInternalBufferStart; region.size = ( *itor )->getBlockSize(); - vkCmdCopyBuffer( mDevice->mGraphicsQueue.mCurrentCmdBuffer, oldBuffer.mVboName, + vkCmdCopyBuffer( mDevice->mGraphicsQueue.getCurrentCmdBuffer(), oldBuffer.mVboName, mBuffer.mVboName, 1u, ®ion ); ( *itor )->mLastFrameUsed = currentFrame; } diff --git a/RenderSystems/Vulkan/src/OgreVulkanHardwareBufferCommon.cpp b/RenderSystems/Vulkan/src/OgreVulkanHardwareBufferCommon.cpp index 67bca529cc..1224070574 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanHardwareBufferCommon.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanHardwareBufferCommon.cpp @@ -297,7 +297,7 @@ namespace Ogre region.srcOffset = srcOffset + srcOffsetStart; region.dstOffset = dstOffset + dstOffsetStart; region.size = alignToNextMultiple( length, 4u ); - vkCmdCopyBuffer( mDevice->mGraphicsQueue.mCurrentCmdBuffer, srcBuf, dstBuf, 1u, + vkCmdCopyBuffer( mDevice->mGraphicsQueue.getCurrentCmdBuffer(), srcBuf, dstBuf, 1u, ®ion ); if( this->mDiscardBuffer ) diff --git a/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp b/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp index a9c077f110..1401efce31 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanQueue.cpp @@ -54,8 +54,8 @@ namespace Ogre mFamilyIdx( 0u ), mQueueIdx( 0u ), mQueue( 0 ), - mCurrentCmdBuffer( 0 ), mOwnerDevice( 0 ), + mCurrentCmdBuffer( 0 ), mVaoManager( 0 ), mRenderSystem( 0 ), mCurrentFence( 0 ), @@ -635,7 +635,7 @@ namespace Ogre // Wait until earlier render, compute and transfers are done so we can copy what // they wrote (unless we're only here for a texture transition) - vkCmdPipelineBarrier( mCurrentCmdBuffer, srcStage & mOwnerDevice->mSupportedStages, + vkCmdPipelineBarrier( getCurrentCmdBuffer(), srcStage & mOwnerDevice->mSupportedStages, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, numMemBarriers, &memBarrier, 0u, 0, numImageMemBarriers, &imageMemBarrier ); } @@ -839,7 +839,7 @@ namespace Ogre // Wait until earlier render, compute and transfers are done so we can copy what // they wrote (unless we're only here for a texture transition) - vkCmdPipelineBarrier( mCurrentCmdBuffer, srcStage & mOwnerDevice->mSupportedStages, + vkCmdPipelineBarrier( getCurrentCmdBuffer(), srcStage & mOwnerDevice->mSupportedStages, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, numMemBarriers, &memBarrier, 0u, 0, numImageMemBarriers, &imageMemBarrier ); } @@ -937,7 +937,7 @@ namespace Ogre numMemBarriers = 1u; // GPU must stop using this buffer before we can write into it - vkCmdPipelineBarrier( mCurrentCmdBuffer, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, + vkCmdPipelineBarrier( getCurrentCmdBuffer(), VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, numMemBarriers, &memBarrier, 0u, 0, 0u, 0 ); } @@ -997,7 +997,7 @@ namespace Ogre // Wait until earlier render, compute and transfers are done // Block render, compute and transfers until we're done - vkCmdPipelineBarrier( mCurrentCmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, + vkCmdPipelineBarrier( getCurrentCmdBuffer(), VK_PIPELINE_STAGE_TRANSFER_BIT, dstStage & mOwnerDevice->mSupportedStages, 0, numMemBarriers, &memBarrier, 0u, 0, static_cast( mImageMemBarriers.size() ), mImageMemBarriers.begin() ); diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderPassDescriptor.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderPassDescriptor.cpp index 90df712f15..e1678014b0 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderPassDescriptor.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderPassDescriptor.cpp @@ -904,7 +904,7 @@ namespace Ogre if( mInformationOnly ) return; - VkCommandBuffer cmdBuffer = mQueue->mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mQueue->getCurrentCmdBuffer(); const VulkanFrameBufferDescValue &fboDesc = mSharedFboItor->second; @@ -967,7 +967,7 @@ namespace Ogre if( mQueue->getEncoderState() != VulkanQueue::EncoderGraphicsOpen ) return; - vkCmdEndRenderPass( mQueue->mCurrentCmdBuffer ); + vkCmdEndRenderPass( mQueue->getCurrentCmdBuffer() ); if( isInterruptingRendering ) { diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 768bbe42cd..9e0f038a1e 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -2182,7 +2182,7 @@ namespace Ogre if( mPso ) oldRootLayout = reinterpret_cast( mPso->rsData )->rootLayout; - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); OGRE_ASSERT_LOW( pso->rsData ); VulkanHlmsPso *vulkanPso = reinterpret_cast( pso->rsData ); vkCmdBindPipeline( cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanPso->pso ); @@ -2212,7 +2212,7 @@ namespace Ogre { OGRE_ASSERT_LOW( pso->rsData ); vulkanPso = reinterpret_cast( pso->rsData ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdBindPipeline( cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, vulkanPso->pso ); if( vulkanPso->rootLayout != oldRootLayout ) @@ -2232,7 +2232,7 @@ namespace Ogre { flushRootLayoutCS(); - vkCmdDispatch( mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer, pso.mNumThreadGroups[0], + vkCmdDispatch( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), pso.mNumThreadGroups[0], pso.mNumThreadGroups[1], pso.mNumThreadGroups[2] ); } //------------------------------------------------------------------------- @@ -2258,7 +2258,7 @@ namespace Ogre OGRE_ASSERT_LOW( numVertexBuffers < 15u ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); if( numVertexBuffers > 0u ) { vkCmdBindVertexBuffers( cmdBuffer, 0, static_cast( numVertexBuffers ), @@ -2304,7 +2304,7 @@ namespace Ogre { flushRootLayout(); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdDrawIndexedIndirect( cmdBuffer, mIndirectBuffer, reinterpret_cast( cmd->indirectBufferOffset ), cmd->numDraws, sizeof( CbDrawIndexed ) ); @@ -2314,7 +2314,7 @@ namespace Ogre { flushRootLayout(); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdDrawIndirect( cmdBuffer, mIndirectBuffer, reinterpret_cast( cmd->indirectBufferOffset ), cmd->numDraws, sizeof( CbDrawStrip ) ); @@ -2327,7 +2327,7 @@ namespace Ogre CbDrawIndexed *drawCmd = reinterpret_cast( mSwIndirectBufferPtr + (size_t)cmd->indirectBufferOffset ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); for( uint32 i = cmd->numDraws; i--; ) { @@ -2345,7 +2345,7 @@ namespace Ogre CbDrawStrip *drawCmd = reinterpret_cast( mSwIndirectBufferPtr + (size_t)cmd->indirectBufferOffset ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); for( uint32 i = cmd->numDraws; i--; ) { @@ -2359,7 +2359,7 @@ namespace Ogre { VulkanVaoManager *vaoManager = static_cast( mVaoManager ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); VkBuffer vulkanVertexBuffers[16]; VkDeviceSize offsets[16]; @@ -2420,7 +2420,7 @@ namespace Ogre { flushRootLayout(); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdDrawIndexed( cmdBuffer, cmd->primCount, cmd->instanceCount, cmd->firstVertexIndex, (int32_t)mCurrentVertexBuffer->vertexStart, cmd->baseInstance ); } @@ -2429,7 +2429,7 @@ namespace Ogre { flushRootLayout(); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdDraw( cmdBuffer, cmd->primCount, cmd->instanceCount, cmd->firstVertexIndex, cmd->baseInstance ); } @@ -2443,7 +2443,7 @@ namespace Ogre const size_t numberOfInstances = op.numberOfInstances; - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); // Render to screen! if( op.useIndexes ) @@ -2692,7 +2692,7 @@ namespace Ogre #if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM if( !CmdBeginDebugUtilsLabelEXT ) return; // VK_EXT_debug_utils not available - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); VkDebugUtilsLabelEXT markerInfo; makeVkStruct( markerInfo, VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT ); markerInfo.pLabelName = event.c_str(); @@ -2705,7 +2705,7 @@ namespace Ogre #if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM if( !CmdEndDebugUtilsLabelEXT ) return; // VK_EXT_debug_utils not available - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); CmdEndDebugUtilsLabelEXT( cmdBuffer ); #endif } @@ -2905,11 +2905,11 @@ namespace Ogre mActiveDevice->mGraphicsQueue.getGraphicsEncoder(); VulkanVaoManager *vaoManager = static_cast( mVaoManager ); - vaoManager->bindDrawIdVertexBuffer( mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer ); + vaoManager->bindDrawIdVertexBuffer( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer() ); if( mStencilEnabled ) { - vkCmdSetStencilReference( mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer, + vkCmdSetStencilReference( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), VK_STENCIL_FACE_FRONT_AND_BACK, mStencilRefValue ); } @@ -2943,7 +2943,8 @@ namespace Ogre #endif } - vkCmdSetViewport( mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer, 0u, numViewports, vkVp ); + vkCmdSetViewport( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), 0u, numViewports, + vkVp ); } if( mVpChanged || numViewports > 1u ) @@ -2966,7 +2967,7 @@ namespace Ogre #endif } - vkCmdSetScissor( mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer, 0u, numViewports, + vkCmdSetScissor( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), 0u, numViewports, scissorRect ); } @@ -3340,10 +3341,11 @@ namespace Ogre if( dstStage == 0 ) dstStage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; - vkCmdPipelineBarrier( - mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer, srcStage & mActiveDevice->mSupportedStages, - dstStage & mActiveDevice->mSupportedStages, 0, numMemBarriers, &memBarrier, 0u, 0, - static_cast( mImageBarriers.size() ), mImageBarriers.begin() ); + vkCmdPipelineBarrier( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), + srcStage & mActiveDevice->mSupportedStages, + dstStage & mActiveDevice->mSupportedStages, 0, numMemBarriers, &memBarrier, + 0u, 0, static_cast( mImageBarriers.size() ), + mImageBarriers.begin() ); mImageBarriers.clear(); } //------------------------------------------------------------------------- @@ -3864,7 +3866,7 @@ namespace Ogre if( mActiveDevice->mGraphicsQueue.getEncoderState() == VulkanQueue::EncoderGraphicsOpen ) { - vkCmdSetStencilReference( mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer, + vkCmdSetStencilReference( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), VK_STENCIL_FACE_FRONT_AND_BACK, mStencilRefValue ); } } diff --git a/RenderSystems/Vulkan/src/OgreVulkanRootLayout.cpp b/RenderSystems/Vulkan/src/OgreVulkanRootLayout.cpp index bb68f345d9..162eb433bc 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRootLayout.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRootLayout.cpp @@ -611,7 +611,7 @@ namespace Ogre if( firstDirtySet < mSets.size() ) { vkCmdBindDescriptorSets( - device->mGraphicsQueue.mCurrentCmdBuffer, + device->mGraphicsQueue.getCurrentCmdBuffer(), mCompute ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS, mRootLayout, firstDirtySet, static_cast( mSets.size() ) - firstDirtySet, &descSets[firstDirtySet], 0u, 0 ); diff --git a/RenderSystems/Vulkan/src/OgreVulkanStagingTexture.cpp b/RenderSystems/Vulkan/src/OgreVulkanStagingTexture.cpp index f3050b8763..134e7ed321 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanStagingTexture.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanStagingTexture.cpp @@ -183,7 +183,7 @@ namespace Ogre region.imageExtent.height = srcBox.height; region.imageExtent.depth = srcBox.depth; - vkCmdCopyBufferToImage( device->mGraphicsQueue.mCurrentCmdBuffer, mVboName, + vkCmdCopyBufferToImage( device->mGraphicsQueue.getCurrentCmdBuffer(), mVboName, dstTextureVulkan->getFinalTextureName(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1u, ®ion ); } diff --git a/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp b/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp index 48976353cf..cc4626c7bb 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanTextureGpu.cpp @@ -185,7 +185,7 @@ namespace Ogre imageBarrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; vkCmdPipelineBarrier( - device->mGraphicsQueue.mCurrentCmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + device->mGraphicsQueue.getCurrentCmdBuffer(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0u, 0, 0u, 0, 1u, &imageBarrier ); mCurrLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; @@ -223,7 +223,7 @@ namespace Ogre imageBarrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; imageBarrier.newLayout = mCurrLayout; vkCmdPipelineBarrier( - device->mGraphicsQueue.mCurrentCmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + device->mGraphicsQueue.getCurrentCmdBuffer(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0u, 0, 0u, 0, 1u, &imageBarrier ); } } @@ -525,7 +525,7 @@ namespace Ogre if( dstTexture->isMultisample() && !dstTexture->hasMsaaExplicitResolves() ) dstTextureName = dstTexture->mMsaaFramebufferName; - vkCmdCopyImage( device->mGraphicsQueue.mCurrentCmdBuffer, srcTextureName, mCurrLayout, + vkCmdCopyImage( device->mGraphicsQueue.getCurrentCmdBuffer(), srcTextureName, mCurrLayout, dstTextureName, dstTexture->mCurrLayout, 1u, ®ion ); if( dstTexture->isMultisample() && !dstTexture->hasMsaaExplicitResolves() && @@ -542,7 +542,7 @@ namespace Ogre resolve.extent.height = getInternalHeight(); resolve.extent.depth = getDepth(); - vkCmdResolveImage( device->mGraphicsQueue.mCurrentCmdBuffer, + vkCmdResolveImage( device->mGraphicsQueue.getCurrentCmdBuffer(), dstTexture->mMsaaFramebufferName, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dstTexture->mFinalTextureName, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1u, &resolve ); @@ -602,7 +602,7 @@ namespace Ogre imageBarrier[1].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; imageBarrier[1].srcAccessMask = 0; imageBarrier[1].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - vkCmdPipelineBarrier( device->mGraphicsQueue.mCurrentCmdBuffer, + vkCmdPipelineBarrier( device->mGraphicsQueue.getCurrentCmdBuffer(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0u, 0, 0u, 0, 1u, &imageBarrier[1] ); } @@ -641,7 +641,7 @@ namespace Ogre region.dstOffsets[1].y = static_cast( std::max( internalHeight >> i, 1u ) ); region.dstOffsets[1].z = static_cast( std::max( getDepth() >> i, 1u ) ); - vkCmdBlitImage( device->mGraphicsQueue.mCurrentCmdBuffer, mFinalTextureName, mCurrLayout, + vkCmdBlitImage( device->mGraphicsQueue.getCurrentCmdBuffer(), mFinalTextureName, mCurrLayout, mFinalTextureName, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1u, ®ion, VK_FILTER_LINEAR ); @@ -656,7 +656,7 @@ namespace Ogre // Wait for vkCmdBlitImage on mip i to finish before advancing to mip i+1 // Also transition src mip 'i' to TRANSFER_SRC_OPTIMAL // Also transition src mip 'i+1' to TRANSFER_DST_OPTIMAL - vkCmdPipelineBarrier( device->mGraphicsQueue.mCurrentCmdBuffer, + vkCmdPipelineBarrier( device->mGraphicsQueue.getCurrentCmdBuffer(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0u, 0, 0u, 0, numBarriers, imageBarrier ); } @@ -1008,7 +1008,7 @@ namespace Ogre imageBarrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; imageBarrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; imageBarrier.image = mMsaaFramebufferName; - vkCmdPipelineBarrier( device->mGraphicsQueue.mCurrentCmdBuffer, + vkCmdPipelineBarrier( device->mGraphicsQueue.getCurrentCmdBuffer(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, PixelFormatGpuUtils::isDepth( finalPixelFormat ) ? ( VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | diff --git a/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp b/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp index 8ca4f4acaf..58180a5b99 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp @@ -190,7 +190,7 @@ namespace Ogre ++barrierCount; } - vkCmdPipelineBarrier( device->mGraphicsQueue.mCurrentCmdBuffer, + vkCmdPipelineBarrier( device->mGraphicsQueue.getCurrentCmdBuffer(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0u, 0, 0u, 0, static_cast( barrierCount ), imageMemBarrier ); @@ -229,7 +229,7 @@ namespace Ogre else region.imageExtent.height = 4u; - vkCmdCopyBufferToImage( device->mGraphicsQueue.mCurrentCmdBuffer, stagingBuffVboName, + vkCmdCopyBufferToImage( device->mGraphicsQueue.getCurrentCmdBuffer(), stagingBuffVboName, mBlankTexture[i].vkImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1u, ®ion ); } @@ -250,9 +250,9 @@ namespace Ogre ++barrierCount; } - vkCmdPipelineBarrier( device->mGraphicsQueue.mCurrentCmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, 0, 0u, 0, 0u, 0, - static_cast( barrierCount ), imageMemBarrier ); + vkCmdPipelineBarrier( device->mGraphicsQueue.getCurrentCmdBuffer(), + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, 0, 0u, + 0, 0u, 0, static_cast( barrierCount ), imageMemBarrier ); mBlankTexture[TextureTypes::Unknown] = mBlankTexture[TextureTypes::Type2D]; if( c_bSkipAliasable ) diff --git a/RenderSystems/Vulkan/src/Vao/OgreVulkanBufferInterface.cpp b/RenderSystems/Vulkan/src/Vao/OgreVulkanBufferInterface.cpp index 21f0a82198..a223a7725e 100644 --- a/RenderSystems/Vulkan/src/Vao/OgreVulkanBufferInterface.cpp +++ b/RenderSystems/Vulkan/src/Vao/OgreVulkanBufferInterface.cpp @@ -203,7 +203,7 @@ namespace Ogre region.srcOffset = srcOffsetBytes; region.dstOffset = dstOffsetBytes; region.size = sizeBytes; - vkCmdCopyBuffer( device->mGraphicsQueue.mCurrentCmdBuffer, mVboName, dstBufferVk->getVboName(), - 1u, ®ion ); + vkCmdCopyBuffer( device->mGraphicsQueue.getCurrentCmdBuffer(), mVboName, + dstBufferVk->getVboName(), 1u, ®ion ); } } // namespace Ogre diff --git a/RenderSystems/Vulkan/src/Vao/OgreVulkanStagingBuffer.cpp b/RenderSystems/Vulkan/src/Vao/OgreVulkanStagingBuffer.cpp index a6b9d4ff2c..84c058ec14 100644 --- a/RenderSystems/Vulkan/src/Vao/OgreVulkanStagingBuffer.cpp +++ b/RenderSystems/Vulkan/src/Vao/OgreVulkanStagingBuffer.cpp @@ -221,7 +221,7 @@ namespace Ogre VulkanVaoManager *vaoManager = static_cast( mVaoManager ); VulkanDevice *device = vaoManager->getDevice(); - VkCommandBuffer cmdBuffer = device->mGraphicsQueue.mCurrentCmdBuffer; + VkCommandBuffer cmdBuffer = device->mGraphicsQueue.getCurrentCmdBuffer(); OGRE_ASSERT_MEDIUM( mUnmapTicket != std::numeric_limits::max() && "VulkanStagingBuffer already unmapped!" ); @@ -313,7 +313,7 @@ namespace Ogre OGRE_ASSERT_HIGH( !Workarounds::mPowerVRAlignment || ( region.dstOffset % Workarounds::mPowerVRAlignment ) == 0u ); #endif - vkCmdCopyBuffer( device->mGraphicsQueue.mCurrentCmdBuffer, bufferInterface->getVboName(), + vkCmdCopyBuffer( device->mGraphicsQueue.getCurrentCmdBuffer(), bufferInterface->getVboName(), mVboName, 1u, ®ion ); return freeRegionOffset; @@ -354,7 +354,7 @@ namespace Ogre OGRE_ASSERT_HIGH( !Workarounds::mPowerVRAlignment || ( region.dstOffset % Workarounds::mPowerVRAlignment ) == 0u ); #endif - vkCmdCopyBuffer( device->mGraphicsQueue.mCurrentCmdBuffer, mVboName, dstBuffer, 1u, ®ion ); + vkCmdCopyBuffer( device->mGraphicsQueue.getCurrentCmdBuffer(), mVboName, dstBuffer, 1u, ®ion ); if( mUploadOnly ) { @@ -417,7 +417,7 @@ namespace Ogre OGRE_ASSERT_HIGH( !Workarounds::mPowerVRAlignment || ( region.dstOffset % Workarounds::mPowerVRAlignment ) == 0u ); #endif - vkCmdCopyBuffer( device->mGraphicsQueue.mCurrentCmdBuffer, srcBuffer, mVboName, 1u, ®ion ); + vkCmdCopyBuffer( device->mGraphicsQueue.getCurrentCmdBuffer(), srcBuffer, mVboName, 1u, ®ion ); return freeRegionOffset + extraOffset; } diff --git a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp index 6758d819f6..d10472aa80 100644 --- a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp +++ b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp @@ -525,7 +525,7 @@ namespace Ogre VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT /*| VK_ACCESS_HOST_READ_BIT | VK_ACCESS_HOST_WRITE_BIT*/; - vkCmdPipelineBarrier( mDevice->mGraphicsQueue.mCurrentCmdBuffer, + vkCmdPipelineBarrier( mDevice->mGraphicsQueue.getCurrentCmdBuffer(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 1u, &memBarrier, 0u, 0, 0u, 0 ); } From 7bfc2ccdde969fe97214956c7cdc5e91c0bb8502 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Fri, 20 Sep 2024 23:37:12 +0200 Subject: [PATCH 13/47] hide calculation of the variables used only in assert under #if !defined( NDEBUG ) --- OgreMain/include/OgreDescriptorSetSampler.h | 2 +- OgreMain/src/Animation/OgreSkeletonAnimManager.cpp | 2 +- OgreMain/src/OgreDescriptorSetTexture.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OgreMain/include/OgreDescriptorSetSampler.h b/OgreMain/include/OgreDescriptorSetSampler.h index 7e6a270be1..e2037ee661 100644 --- a/OgreMain/include/OgreDescriptorSetSampler.h +++ b/OgreMain/include/OgreDescriptorSetSampler.h @@ -108,7 +108,7 @@ namespace Ogre void checkValidity() const { -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE && !defined( NDEBUG ) size_t totalSamplersUsed = 0u; for( size_t i = 0; i < NumShaderTypes; ++i ) diff --git a/OgreMain/src/Animation/OgreSkeletonAnimManager.cpp b/OgreMain/src/Animation/OgreSkeletonAnimManager.cpp index ba8f882da0..127e261b4e 100644 --- a/OgreMain/src/Animation/OgreSkeletonAnimManager.cpp +++ b/OgreMain/src/Animation/OgreSkeletonAnimManager.cpp @@ -112,7 +112,7 @@ namespace Ogre skeletonsArray.insert( it, newInstance ); -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE && !defined( NDEBUG ) { // Check all depth levels respect the same ordering FastArray::const_iterator itSkel = skeletonsArray.begin(); diff --git a/OgreMain/src/OgreDescriptorSetTexture.cpp b/OgreMain/src/OgreDescriptorSetTexture.cpp index 6e64fccbf5..c83750cb94 100644 --- a/OgreMain/src/OgreDescriptorSetTexture.cpp +++ b/OgreMain/src/OgreDescriptorSetTexture.cpp @@ -39,7 +39,7 @@ namespace Ogre { void DescriptorSetTexture::checkValidity() const { -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE && !defined( NDEBUG ) size_t totalTexturesUsed = 0u; for( size_t i = 0; i < NumShaderTypes; ++i ) @@ -72,7 +72,7 @@ namespace Ogre "This DescriptorSetTexture2 doesn't use any texture/buffer! " "Perhaps incorrectly setup?" ); -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE && !defined( NDEBUG ) size_t totalTexturesUsed = 0u; for( size_t i = 0; i < NumShaderTypes; ++i ) From e45cc818cfe25aaad17e7c20902349a6d81a5dcc Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Sat, 21 Sep 2024 00:27:13 +0200 Subject: [PATCH 14/47] fixed build in OGRE_DEBUG_LOW mode --- OgreMain/include/Animation/OgreBone.h | 4 ++-- OgreMain/include/Animation/OgreBone.inl | 2 +- OgreMain/include/OgreSceneNode.h | 2 +- OgreMain/src/Animation/OgreBone.cpp | 22 +++++++++++----------- OgreMain/src/Animation/OgreTagPoint.cpp | 6 +++--- OgreMain/src/OgreSceneNode.cpp | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/OgreMain/include/Animation/OgreBone.h b/OgreMain/include/Animation/OgreBone.h index 2c8d21c08d..eb425c245c 100644 --- a/OgreMain/include/Animation/OgreBone.h +++ b/OgreMain/include/Animation/OgreBone.h @@ -68,7 +68,7 @@ namespace Ogre ArrayMatrixAf4x3 const *RESTRICT_ALIAS mReverseBind; BoneTransform mTransform; -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM mutable bool mCachedTransformOutOfDate; Node *mDebugParentNode; bool mInitialized; @@ -281,7 +281,7 @@ namespace Ogre */ FORCEINLINE const SimpleMatrixAf4x3 &_getLocalSpaceTransform() const { -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM assert( !mCachedTransformOutOfDate ); #endif return mTransform.mDerivedTransform[mTransform.mIndex]; diff --git a/OgreMain/include/Animation/OgreBone.inl b/OgreMain/include/Animation/OgreBone.inl index d42773e00d..2410db65a7 100644 --- a/OgreMain/include/Animation/OgreBone.inl +++ b/OgreMain/include/Animation/OgreBone.inl @@ -26,7 +26,7 @@ THE SOFTWARE. ----------------------------------------------------------------------------- */ -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM #define CACHED_TRANSFORM_OUT_OF_DATE() this->setCachedTransformOutOfDate() #else #define CACHED_TRANSFORM_OUT_OF_DATE() ((void)0) diff --git a/OgreMain/include/OgreSceneNode.h b/OgreMain/include/OgreSceneNode.h index 9af91c12bf..90b460364e 100644 --- a/OgreMain/include/OgreSceneNode.h +++ b/OgreMain/include/OgreSceneNode.h @@ -319,7 +319,7 @@ namespace Ogre NodeMemoryManager *getDefaultNodeMemoryManager( SceneMemoryMgrTypes sceneType ) override; -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM void _setCachedTransformOutOfDate() override; #endif }; diff --git a/OgreMain/src/Animation/OgreBone.cpp b/OgreMain/src/Animation/OgreBone.cpp index 4545a6fddc..01f9d375f9 100644 --- a/OgreMain/src/Animation/OgreBone.cpp +++ b/OgreMain/src/Animation/OgreBone.cpp @@ -36,7 +36,7 @@ THE SOFTWARE. #include "OgreLogManager.h" #include "OgreNode.h" -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM # define CACHED_TRANSFORM_OUT_OF_DATE() this->setCachedTransformOutOfDate() #else # define CACHED_TRANSFORM_OUT_OF_DATE() ( (void)0 ) @@ -49,7 +49,7 @@ namespace Ogre IdObject( 0 ), mReverseBind( 0 ), mTransform( BoneTransform() ), -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM mCachedTransformOutOfDate( true ), mDebugParentNode( 0 ), mInitialized( false ), @@ -65,7 +65,7 @@ namespace Ogre //----------------------------------------------------------------------- Bone::~Bone() { -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM assert( !mInitialized && "Must call _deinitialize() before destructor!" ); #endif } @@ -73,7 +73,7 @@ namespace Ogre void Bone::_initialize( IdType id, BoneMemoryManager *boneMemoryManager, Bone *parent, ArrayMatrixAf4x3 const *RESTRICT_ALIAS reverseBind ) { -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM assert( !mInitialized ); mInitialized = true; #endif @@ -130,14 +130,14 @@ namespace Ogre mReverseBind = 0; mBoneMemoryManager = 0; -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM mInitialized = false; #endif } //----------------------------------------------------------------------- void Bone::setCachedTransformOutOfDate() const { -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM mCachedTransformOutOfDate = true; BoneVec::const_iterator itor = mChildren.begin(); @@ -213,7 +213,7 @@ namespace Ogre //----------------------------------------------------------------------- void Bone::_setNodeParent( Node *nodeParent ) { -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM mDebugParentNode = nodeParent; #endif if( nodeParent ) @@ -251,7 +251,7 @@ namespace Ogre //----------------------------------------------------------------------- Matrix4 Bone::_getDerivedTransform() const { -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM assert( !mCachedTransformOutOfDate ); #endif OGRE_ALIGNED_DECL( Matrix4, localSpaceBone, OGRE_SIMD_ALIGNMENT ); @@ -312,7 +312,7 @@ namespace Ogre /* mat.storeToAoS( mTransform.mDerivedTransform ); -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM for( size_t j=0; j= OGRE_DEBUG_MEDIUM for( size_t j = 0; j < ARRAY_PACKED_REALS; ++j ) { if( t.mOwner[j] ) @@ -403,7 +403,7 @@ namespace Ogre } } //----------------------------------------------------------------------- -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM void Bone::_setCachedTransformOutOfDate() { mCachedTransformOutOfDate = true; } #endif } // namespace Ogre diff --git a/OgreMain/src/Animation/OgreTagPoint.cpp b/OgreMain/src/Animation/OgreTagPoint.cpp index f32abd0b4d..dff6f83034 100644 --- a/OgreMain/src/Animation/OgreTagPoint.cpp +++ b/OgreMain/src/Animation/OgreTagPoint.cpp @@ -99,7 +99,7 @@ namespace Ogre //----------------------------------------------------------------------- Matrix3 TagPoint::_getDerivedOrientationMatrix() const { -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM assert( !mCachedTransformOutOfDate ); #endif Matrix3 retVal; @@ -165,7 +165,7 @@ namespace Ogre finalMat.decomposition( *t.mDerivedPosition, *t.mDerivedScale, *t.mDerivedOrientation ); -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM for( size_t j = 0; j < ARRAY_PACKED_REALS; ++j ) { if( t.mOwner[j] ) @@ -212,7 +212,7 @@ namespace Ogre finalMat.decomposition( *t.mDerivedPosition, *t.mDerivedScale, *t.mDerivedOrientation ); -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM for( size_t j = 0; j < ARRAY_PACKED_REALS; ++j ) { if( t.mOwner[j] ) diff --git a/OgreMain/src/OgreSceneNode.cpp b/OgreMain/src/OgreSceneNode.cpp index 516a11966a..14b5e028c3 100644 --- a/OgreMain/src/OgreSceneNode.cpp +++ b/OgreMain/src/OgreSceneNode.cpp @@ -505,7 +505,7 @@ namespace Ogre return &mCreator->_getNodeMemoryManager( sceneType ); } //----------------------------------------------------------------------- -#if OGRE_DEBUG_MODE +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM void SceneNode::_setCachedTransformOutOfDate() { Node::_setCachedTransformOutOfDate(); From f72b0cacc67da5ce04d8fa45e6ea4067ee01153a Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Sat, 21 Sep 2024 01:07:30 +0200 Subject: [PATCH 15/47] do not compare OGRE_DEBUG_MODE with 1, it can be 0..3 --- OgreMain/include/OgreFileSystemLayer.h | 2 +- OgreMain/src/WIN32/OgreConfigDialog.cpp | 2 +- OgreMain/src/WIN32/OgreErrorDialog.cpp | 2 +- .../GL3Plus/src/windowing/win32/OgreWin32GLSupport.cpp | 2 +- RenderSystems/GL3Plus/src/windowing/win32/OgreWin32Window.cpp | 2 +- .../Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/OgreMain/include/OgreFileSystemLayer.h b/OgreMain/include/OgreFileSystemLayer.h index 02e9cb711e..ee9cd868ff 100644 --- a/OgreMain/include/OgreFileSystemLayer.h +++ b/OgreMain/include/OgreFileSystemLayer.h @@ -73,7 +73,7 @@ namespace Ogre */ const Ogre::String getConfigFilePath( Ogre::String filename ) const { -#if OGRE_DEBUG_MODE == 1 && \ +#if OGRE_DEBUG_MODE && \ ( OGRE_PLATFORM != OGRE_PLATFORM_APPLE && OGRE_PLATFORM != OGRE_PLATFORM_APPLE_IOS ) // add OGRE_BUILD_SUFFIX (default: "_d") to config file names Ogre::String::size_type pos = filename.rfind( '.' ); diff --git a/OgreMain/src/WIN32/OgreConfigDialog.cpp b/OgreMain/src/WIN32/OgreConfigDialog.cpp index ccf1f5cf60..b12e301c08 100644 --- a/OgreMain/src/WIN32/OgreConfigDialog.cpp +++ b/OgreMain/src/WIN32/OgreConfigDialog.cpp @@ -47,7 +47,7 @@ namespace Ogre # ifdef OGRE_STATIC_LIB mHInstance = GetModuleHandle( NULL ); # else -# if OGRE_DEBUG_MODE == 1 +# if OGRE_DEBUG_MODE mHInstance = GetModuleHandle( "OgreMain_d.dll" ); # else mHInstance = GetModuleHandle( "OgreMain.dll" ); diff --git a/OgreMain/src/WIN32/OgreErrorDialog.cpp b/OgreMain/src/WIN32/OgreErrorDialog.cpp index f58a52c9b5..ca26ee7b14 100644 --- a/OgreMain/src/WIN32/OgreErrorDialog.cpp +++ b/OgreMain/src/WIN32/OgreErrorDialog.cpp @@ -44,7 +44,7 @@ namespace Ogre # ifdef OGRE_STATIC_LIB mHInstance = GetModuleHandle( NULL ); # else -# if OGRE_DEBUG_MODE == 1 +# if OGRE_DEBUG_MODE mHInstance = GetModuleHandle( "OgreMain_d.dll" ); # else mHInstance = GetModuleHandle( "OgreMain.dll" ); diff --git a/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32GLSupport.cpp b/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32GLSupport.cpp index 48b22d9d5c..4b5900616e 100644 --- a/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32GLSupport.cpp +++ b/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32GLSupport.cpp @@ -503,7 +503,7 @@ namespace Ogre # ifdef OGRE_STATIC_LIB hinst = GetModuleHandle( NULL ); # else -# if OGRE_DEBUG_MODE == 1 +# if OGRE_DEBUG_MODE hinst = GetModuleHandle( "RenderSystem_GL3Plus_d.dll" ); # else hinst = GetModuleHandle( "RenderSystem_GL3Plus.dll" ); diff --git a/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32Window.cpp b/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32Window.cpp index 4db87daf02..7f17e91e42 100644 --- a/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32Window.cpp +++ b/RenderSystems/GL3Plus/src/windowing/win32/OgreWin32Window.cpp @@ -404,7 +404,7 @@ namespace Ogre # ifdef OGRE_STATIC_LIB hInstance = GetModuleHandle( NULL ); # else -# if OGRE_DEBUG_MODE == 1 +# if OGRE_DEBUG_MODE hInstance = GetModuleHandle( "RenderSystem_GL3Plus_d.dll" ); # else hInstance = GetModuleHandle( "RenderSystem_GL3Plus.dll" ); diff --git a/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp b/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp index 5f24bfd996..71b70db41a 100644 --- a/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp +++ b/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp @@ -369,7 +369,7 @@ namespace Ogre # ifdef OGRE_STATIC_LIB hInstance = GetModuleHandle( NULL ); # else -# if OGRE_DEBUG_MODE == 1 +# if OGRE_DEBUG_MODE hInstance = GetModuleHandle( "RenderSystem_Vulkan_d.dll" ); # else hInstance = GetModuleHandle( "RenderSystem_Vulkan.dll" ); From 0aceb99cde796c1beb6dec9e5f141b5ef4c62131 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Sat, 21 Sep 2024 01:23:56 +0200 Subject: [PATCH 16/47] use OGRE_STATIC_ASSERT for single argument checks --- OgreMain/include/OgreAssert.h | 8 +++----- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/OgreMain/include/OgreAssert.h b/OgreMain/include/OgreAssert.h index 2aede1c8cb..bfd7655d5b 100644 --- a/OgreMain/include/OgreAssert.h +++ b/OgreMain/include/OgreAssert.h @@ -126,12 +126,10 @@ namespace Ogre # define OGRE_VERIFY_MSG( cond, msg, ... ) ( (void)0 ) #endif -#if __cplusplus >= 201103L +#if __cplusplus >= 201703L || defined( _MSVC_LANG ) && _MSVC_LANG >= 201703L +# define OGRE_STATIC_ASSERT( x ) static_assert( x ) +#else // C++11 # define OGRE_STATIC_ASSERT( x ) static_assert( x, # x ) -#else -# define OGRE_STATIC_ASSERT( x ) \ - typedef char OgreStaticAssert[( x ) ? 1 : -1]; \ - OGRE_UNUSED( OgreStaticAssert ); #endif #endif diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 9e0f038a1e..e0580907d3 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -528,7 +528,7 @@ namespace Ogre //------------------------------------------------------------------------- void VulkanRenderSystem::savePipelineCache( DataStreamPtr stream ) const { - static_assert( sizeof( PipelineCachePrefixHeader ) == 48 ); + OGRE_STATIC_ASSERT( sizeof( PipelineCachePrefixHeader ) == 48 ); if( mActiveDevice->mPipelineCache ) { size_t size{}; @@ -559,7 +559,7 @@ namespace Ogre hdr.driverVersion = mActiveDevice->mDeviceProperties.driverVersion; hdr.driverABI = sizeof( void * ); memcpy( hdr.uuid, mActiveDevice->mDeviceProperties.pipelineCacheUUID, VK_UUID_SIZE ); - static_assert( VK_UUID_SIZE == 16 ); + OGRE_STATIC_ASSERT( VK_UUID_SIZE == 16 ); uint64 hashResult[2] = {}; OGRE_HASH128_FUNC( buf.data(), (int)buf.size(), IdString::Seed, hashResult ); From 1270639dbf8b77844bf186e45c023933cf63e601 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sat, 21 Sep 2024 19:07:59 -0300 Subject: [PATCH 17/47] Replace use of assert() for OGRE_ASSERT_MEDIUM --- OgreMain/include/Animation/OgreBone.h | 4 +--- OgreMain/include/OgreNode.h | 4 +--- OgreMain/src/Animation/OgreBone.cpp | 4 +--- OgreMain/src/Animation/OgreTagPoint.cpp | 4 +--- OgreMain/src/OgreNode.cpp | 2 +- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/OgreMain/include/Animation/OgreBone.h b/OgreMain/include/Animation/OgreBone.h index eb425c245c..b9ba876665 100644 --- a/OgreMain/include/Animation/OgreBone.h +++ b/OgreMain/include/Animation/OgreBone.h @@ -281,9 +281,7 @@ namespace Ogre */ FORCEINLINE const SimpleMatrixAf4x3 &_getLocalSpaceTransform() const { -#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM - assert( !mCachedTransformOutOfDate ); -#endif + OGRE_ASSERT_MEDIUM( !mCachedTransformOutOfDate ); return mTransform.mDerivedTransform[mTransform.mIndex]; } diff --git a/OgreMain/include/OgreNode.h b/OgreMain/include/OgreNode.h index d7fbb61191..72a911c529 100644 --- a/OgreMain/include/OgreNode.h +++ b/OgreMain/include/OgreNode.h @@ -677,9 +677,7 @@ namespace Ogre */ virtual_l2 FORCEINLINE const Matrix4 &_getFullTransform() const { -#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM - assert( !mCachedTransformOutOfDate ); -#endif + OGRE_ASSERT_MEDIUM( !mCachedTransformOutOfDate ); return mTransform.mDerivedTransform[mTransform.mIndex]; } diff --git a/OgreMain/src/Animation/OgreBone.cpp b/OgreMain/src/Animation/OgreBone.cpp index 01f9d375f9..36e97b6886 100644 --- a/OgreMain/src/Animation/OgreBone.cpp +++ b/OgreMain/src/Animation/OgreBone.cpp @@ -251,9 +251,7 @@ namespace Ogre //----------------------------------------------------------------------- Matrix4 Bone::_getDerivedTransform() const { -#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM - assert( !mCachedTransformOutOfDate ); -#endif + OGRE_ASSERT_MEDIUM( !mCachedTransformOutOfDate ); OGRE_ALIGNED_DECL( Matrix4, localSpaceBone, OGRE_SIMD_ALIGNMENT ); OGRE_ALIGNED_DECL( Matrix4, parentNodeTransform, OGRE_SIMD_ALIGNMENT ); diff --git a/OgreMain/src/Animation/OgreTagPoint.cpp b/OgreMain/src/Animation/OgreTagPoint.cpp index dff6f83034..8c31673fc6 100644 --- a/OgreMain/src/Animation/OgreTagPoint.cpp +++ b/OgreMain/src/Animation/OgreTagPoint.cpp @@ -99,9 +99,7 @@ namespace Ogre //----------------------------------------------------------------------- Matrix3 TagPoint::_getDerivedOrientationMatrix() const { -#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM - assert( !mCachedTransformOutOfDate ); -#endif + OGRE_ASSERT_MEDIUM( !mCachedTransformOutOfDate ); Matrix3 retVal; mTransform.mDerivedTransform[mTransform.mIndex].extract3x3Matrix( retVal ); return retVal; diff --git a/OgreMain/src/OgreNode.cpp b/OgreMain/src/OgreNode.cpp index c86b89caae..de1b522462 100644 --- a/OgreMain/src/OgreNode.cpp +++ b/OgreMain/src/OgreNode.cpp @@ -255,7 +255,7 @@ namespace Ogre //----------------------------------------------------------------------- /*const Matrix4& Node::_getFullTransform() const { - assert( !mCachedTransformOutOfDate ); + OGRE_ASSERT_MEDIUM( !mCachedTransformOutOfDate ); return mTransform.mDerivedTransform[mTransform.mIndex]; }*/ //----------------------------------------------------------------------- From 8474986bb61b7e42df5e310c323d172784582d7a Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sat, 21 Sep 2024 19:12:35 -0300 Subject: [PATCH 18/47] Replace use of assert() for OGRE_ASSERT_MEDIUM --- OgreMain/include/OgreDescriptorSetSampler.h | 13 +++++----- .../src/Animation/OgreSkeletonAnimManager.cpp | 4 +-- OgreMain/src/OgreDescriptorSetTexture.cpp | 26 ++++++++++--------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/OgreMain/include/OgreDescriptorSetSampler.h b/OgreMain/include/OgreDescriptorSetSampler.h index e2037ee661..5d6edff03f 100644 --- a/OgreMain/include/OgreDescriptorSetSampler.h +++ b/OgreMain/include/OgreDescriptorSetSampler.h @@ -108,17 +108,18 @@ namespace Ogre void checkValidity() const { -#if OGRE_DEBUG_MODE && !defined( NDEBUG ) +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM size_t totalSamplersUsed = 0u; for( size_t i = 0; i < NumShaderTypes; ++i ) totalSamplersUsed += mShaderTypeSamplerCount[i]; - assert( totalSamplersUsed > 0 && - "This DescriptorSetSampler doesn't use any sampler! Perhaps incorrectly setup?" ); - assert( totalSamplersUsed == mSamplers.size() && - "This DescriptorSetSampler doesn't use as many samplers as it " - "claims to have, or uses more than it has provided" ); + OGRE_ASSERT_MEDIUM( + totalSamplersUsed > 0 && + "This DescriptorSetSampler doesn't use any sampler! Perhaps incorrectly setup?" ); + OGRE_ASSERT_MEDIUM( totalSamplersUsed == mSamplers.size() && + "This DescriptorSetSampler doesn't use as many samplers as it " + "claims to have, or uses more than it has provided" ); #endif } }; diff --git a/OgreMain/src/Animation/OgreSkeletonAnimManager.cpp b/OgreMain/src/Animation/OgreSkeletonAnimManager.cpp index 127e261b4e..41045ca11d 100644 --- a/OgreMain/src/Animation/OgreSkeletonAnimManager.cpp +++ b/OgreMain/src/Animation/OgreSkeletonAnimManager.cpp @@ -112,7 +112,7 @@ namespace Ogre skeletonsArray.insert( it, newInstance ); -#if OGRE_DEBUG_MODE && !defined( NDEBUG ) +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_HIGH { // Check all depth levels respect the same ordering FastArray::const_iterator itSkel = skeletonsArray.begin(); @@ -128,7 +128,7 @@ namespace Ogre { Bone **owner1 = transf1[i].mOwner + transf1[i].mIndex; Bone **owner2 = transf2[i].mOwner + transf2[i].mIndex; - assert( owner1 < owner2 ); + OGRE_ASSERT_HIGH( owner1 < owner2 ); } ++itSkel2; diff --git a/OgreMain/src/OgreDescriptorSetTexture.cpp b/OgreMain/src/OgreDescriptorSetTexture.cpp index c83750cb94..8c8f503785 100644 --- a/OgreMain/src/OgreDescriptorSetTexture.cpp +++ b/OgreMain/src/OgreDescriptorSetTexture.cpp @@ -39,17 +39,18 @@ namespace Ogre { void DescriptorSetTexture::checkValidity() const { -#if OGRE_DEBUG_MODE && !defined( NDEBUG ) +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM size_t totalTexturesUsed = 0u; for( size_t i = 0; i < NumShaderTypes; ++i ) totalTexturesUsed += mShaderTypeTexCount[i]; - assert( totalTexturesUsed > 0 && - "This DescriptorSetTexture doesn't use any texture! Perhaps incorrectly setup?" ); - assert( totalTexturesUsed == mTextures.size() && - "This DescriptorSetTexture doesn't use as many textures as it " - "claims to have, or uses more than it has provided" ); + OGRE_ASSERT_MEDIUM( + totalTexturesUsed > 0 && + "This DescriptorSetTexture doesn't use any texture! Perhaps incorrectly setup?" ); + OGRE_ASSERT_MEDIUM( totalTexturesUsed == mTextures.size() && + "This DescriptorSetTexture doesn't use as many textures as it " + "claims to have, or uses more than it has provided" ); #endif } //----------------------------------------------------------------------------------- @@ -72,17 +73,18 @@ namespace Ogre "This DescriptorSetTexture2 doesn't use any texture/buffer! " "Perhaps incorrectly setup?" ); -#if OGRE_DEBUG_MODE && !defined( NDEBUG ) +#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM size_t totalTexturesUsed = 0u; for( size_t i = 0; i < NumShaderTypes; ++i ) totalTexturesUsed += mShaderTypeTexCount[i]; - assert( totalTexturesUsed > 0 && - "This DescriptorSetTexture doesn't use any texture! Perhaps incorrectly setup?" ); - assert( totalTexturesUsed == mTextures.size() && - "This DescriptorSetTexture doesn't use as many textures as it " - "claims to have, or uses more than it has provided" ); + OGRE_ASSERT_MEDIUM( + totalTexturesUsed > 0 && + "This DescriptorSetTexture doesn't use any texture! Perhaps incorrectly setup?" ); + OGRE_ASSERT_MEDIUM( totalTexturesUsed == mTextures.size() && + "This DescriptorSetTexture doesn't use as many textures as it " + "claims to have, or uses more than it has provided" ); #endif FastArray::const_iterator itor = mTextures.begin(); From 01a3c80da5242b7a494913075f33dc2e88220d7c Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sat, 21 Sep 2024 19:14:22 -0300 Subject: [PATCH 19/47] Document that OGRE_DEBUG_LOW is not allowed to break the ABI --- OgreMain/include/OgrePlatform.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OgreMain/include/OgrePlatform.h b/OgreMain/include/OgrePlatform.h index 2f52343545..f9f7a12e46 100644 --- a/OgreMain/include/OgrePlatform.h +++ b/OgreMain/include/OgrePlatform.h @@ -331,9 +331,12 @@ THE SOFTWARE. // No checks done at all #define OGRE_DEBUG_NONE 0 // We perform basic assert checks and other non-performance intensive checks +// This setting must NOT break the ABI. i.e. a binary compiled with OGRE_DEBUG_LOW +// must be ABI compatible with a binary compiled without it. #define OGRE_DEBUG_LOW 1 // We alter classes to add some debug variables for a bit more thorough checking // and also perform checks that may cause some performance hit +// This setting or higher is allowed to break the ABI. #define OGRE_DEBUG_MEDIUM 2 // We perform intensive validation without concerns for performance #define OGRE_DEBUG_HIGH 3 From bf9399504330888e23ca34b508d45139dad3a659 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 23 Sep 2024 18:06:39 +0200 Subject: [PATCH 20/47] [Vk] Don't ask for VK_EXT_DEBUG_UTILS_EXTENSION_NAME if support was not declared. Fixed validation error on Samsung A33. --- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index e0580907d3..35d7d285b0 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -1294,7 +1294,8 @@ namespace Ogre { // Loader version < 1.1.114 is blacklisted as it will just crash. // See https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/258 - bAllow_VK_EXT_debug_utils = true; + bAllow_VK_EXT_debug_utils = + VulkanDevice::hasInstanceExtension( VK_EXT_DEBUG_UTILS_EXTENSION_NAME ); } } } From 425e2222a0b77068ea2fa674e5ce9d5dffef7428 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 23 Sep 2024 22:24:59 +0200 Subject: [PATCH 21/47] [Vk] use LML_CRITICAL for errors detected by validation layer --- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 35d7d285b0..514ac6159a 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -142,7 +142,8 @@ namespace Ogre sprintf(message, "INFORMATION: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg); } - LogManager::getSingleton().logMessage( message ); + LogManager::getSingleton().logMessage( message, + msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT ? LML_CRITICAL : LML_NORMAL ); free(message); From 2300f52346b3c4c90da98c7269fe4608613cd205 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Mon, 23 Sep 2024 20:38:13 -0300 Subject: [PATCH 22/47] [Metal] Fix Instanced Stereo on iOS / macOS Fixes #464 --- Samples/Media/Hlms/Pbs/Metal/VertexShader_vs.metal | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Samples/Media/Hlms/Pbs/Metal/VertexShader_vs.metal b/Samples/Media/Hlms/Pbs/Metal/VertexShader_vs.metal index 3287162643..418efcda80 100644 --- a/Samples/Media/Hlms/Pbs/Metal/VertexShader_vs.metal +++ b/Samples/Media/Hlms/Pbs/Metal/VertexShader_vs.metal @@ -37,6 +37,9 @@ struct PS_INPUT @insertpiece( VStoPS_block ) float4 gl_Position [[position]]; + @property( hlms_instanced_stereo ) + uint gl_ViewportIndex [[viewport_array_index]]; + @end @property( hlms_pso_clip_distances ) float gl_ClipDistance [[clip_distance]] [@value( hlms_pso_clip_distances )]; @end From 2727b6278b8b7ddb29936a7cd3199aa249890e78 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Wed, 25 Sep 2024 02:30:28 +0200 Subject: [PATCH 23/47] [Vk] Fixed Validation Error: [ VUID-VkPresentInfoKHR-pImageIndices-01430 ] vkQueuePresentKHR(): pPresentInfo->pSwapchains[0] images passed to present must be in layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR but is in VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL. --- OgreMain/include/Compositor/OgreCompositorWorkspace.h | 2 +- OgreMain/src/Compositor/OgreCompositorWorkspace.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/OgreMain/include/Compositor/OgreCompositorWorkspace.h b/OgreMain/include/Compositor/OgreCompositorWorkspace.h index cb990a0c43..ac60f53f87 100644 --- a/OgreMain/include/Compositor/OgreCompositorWorkspace.h +++ b/OgreMain/include/Compositor/OgreCompositorWorkspace.h @@ -159,7 +159,7 @@ namespace Ogre /// Only valid workspaces can update without crashing bool isValid() const { return mValid; } - void setEnabled( bool bEnabled ) { mEnabled = bEnabled; } + void setEnabled( bool bEnabled ); bool getEnabled() const { return mEnabled; } /** When building with OGRE_PROFILING enabled, setting this option to true diff --git a/OgreMain/src/Compositor/OgreCompositorWorkspace.cpp b/OgreMain/src/Compositor/OgreCompositorWorkspace.cpp index 208818a291..5e0131b240 100644 --- a/OgreMain/src/Compositor/OgreCompositorWorkspace.cpp +++ b/OgreMain/src/Compositor/OgreCompositorWorkspace.cpp @@ -737,6 +737,15 @@ namespace Ogre return finalTarget; } //----------------------------------------------------------------------------------- + void CompositorWorkspace::setEnabled( bool bEnabled ) + { + if( mEnabled != bEnabled ) + { + mEnabled = bEnabled; + _notifyBarriersDirty(); + } + } + //----------------------------------------------------------------------------------- void CompositorWorkspace::_notifyBarriersDirty() { getCompositorManager()->_notifyBarriersDirty(); } //----------------------------------------------------------------------------------- CompositorManager2 *CompositorWorkspace::getCompositorManager() From 1287dbb6030429f5045616301c77f47e6927758b Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Fri, 27 Sep 2024 18:00:35 +0200 Subject: [PATCH 24/47] [Vk] Recreate VulkanWindowSwapChainBased MSAA surface after setOrientationMode(). Fixed validation error "pCreateInfo->pAttachments[0] mip level 0 has height (814) smaller than the corresponding framebuffer height (2340)." --- RenderSystems/Vulkan/src/OgreVulkanWindow.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp index eba56e7213..3875b0e53a 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp @@ -296,15 +296,6 @@ namespace Ogre Math::Clamp( getHeight(), surfaceCaps.minImageExtent.height, surfaceCaps.maxImageExtent.height ) ); - // We need to retransition the main texture now to create MSAA surfaces (if any). - // We need to do it now, because doing it later will overwrite the VkImage handles with NULL. - // - // mTexture is supposed to always be at Resident once it transitions there, - // so maintain that guarantee. - if( mTexture->getResidencyStatus() != GpuResidency::OnStorage ) - mTexture->_transitionTo( GpuResidency::OnStorage, (uint8 *)0 ); - mTexture->_transitionTo( GpuResidency::Resident, (uint8 *)0 ); - VkBool32 supported; result = vkGetPhysicalDeviceSurfaceSupportKHR( mDevice->mPhysicalDevice, mDevice->mGraphicsQueue.mFamilyIdx, mSurfaceKHR, &supported ); @@ -496,6 +487,12 @@ namespace Ogre mSwapchainImages.begin() ); checkVkResult( result, "vkGetSwapchainImagesKHR" ); + // We need to retransition the main texture now to re-create MSAA surfaces (if any). + // We need to do it now, because doing it later will overwrite the VkImage handles with NULL. + if( mTexture->getResidencyStatus() != GpuResidency::OnStorage ) + mTexture->_transitionTo( GpuResidency::OnStorage, (uint8 *)0 ); + mTexture->_transitionTo( GpuResidency::Resident, (uint8 *)0 ); + acquireNextSwapchain(); if( mDepthBuffer ) From e8b3856887266948bca6b1776862c7e88f139842 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Tue, 1 Oct 2024 21:14:33 +0200 Subject: [PATCH 25/47] [Vk] pass Vulkan windows through validateSampleDescription, fixed "Validation Error: [ VUID-VkImageCreateInfo-samples-02258 ] | MessageID = 0x5fccc613 | vkCreateImage(): pCreateInfo->samples (VK_SAMPLE_COUNT_2_BIT) is not supported by format VK_FORMAT_R8G8B8A8_SRGB" --- OgreMain/include/OgreRenderSystem.h | 9 +- OgreMain/src/OgreRenderSystem.cpp | 3 +- OgreMain/src/OgreTextureGpu.cpp | 6 +- .../include/OgreD3D11RenderSystem.h | 4 +- .../Direct3D11/src/OgreD3D11RenderSystem.cpp | 4 +- .../Direct3D11/src/OgreD3D11Window.cpp | 6 +- .../Windowing/WIN32/OgreD3D11WindowHwnd.cpp | 6 +- .../Windowing/WIN32/OgreD3D11WindowWinRT.cpp | 8 +- .../Metal/include/OgreMetalRenderSystem.h | 4 +- .../Metal/src/OgreMetalRenderSystem.mm | 3 +- RenderSystems/Metal/src/OgreMetalWindow.mm | 4 +- .../Vulkan/include/OgreVulkanRenderSystem.h | 4 +- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 101 ++++++------------ RenderSystems/Vulkan/src/OgreVulkanWindow.cpp | 8 +- .../Android/OgreVulkanAndroidWindow.cpp | 8 +- .../src/Windowing/X11/OgreVulkanXcbWindow.cpp | 8 +- .../Windowing/win32/OgreVulkanWin32Window.cpp | 10 +- 17 files changed, 77 insertions(+), 119 deletions(-) diff --git a/OgreMain/include/OgreRenderSystem.h b/OgreMain/include/OgreRenderSystem.h index 6fcede06fb..4b28c06cf3 100644 --- a/OgreMain/include/OgreRenderSystem.h +++ b/OgreMain/include/OgreRenderSystem.h @@ -316,16 +316,15 @@ namespace Ogre See TextureFlags::TextureFlags. Relevant flags are: NotTexture + RenderToTexture Uav - @param depthTextureFlags - Only used if format is a colour pixel format. - Same as textureFlags, but for associated depth buffer if format. + RenderWindowSpecific @return Supported sample description for requested FSAA mode, with graceful downgrading. */ virtual SampleDescription validateSampleDescription( const SampleDescription &sampleDesc, - PixelFormatGpu format, uint32 textureFlags, - uint32 depthTextureFlags ); + PixelFormatGpu format, + uint32 textureFlags ); /** Creates a new rendering window. @remarks diff --git a/OgreMain/src/OgreRenderSystem.cpp b/OgreMain/src/OgreRenderSystem.cpp index 2070405789..6546210561 100644 --- a/OgreMain/src/OgreRenderSystem.cpp +++ b/OgreMain/src/OgreRenderSystem.cpp @@ -811,8 +811,7 @@ namespace Ogre //----------------------------------------------------------------------- SampleDescription RenderSystem::validateSampleDescription( const SampleDescription &sampleDesc, PixelFormatGpu format, - uint32 textureFlags, - uint32 depthTextureFlags ) + uint32 textureFlags ) { SampleDescription retVal( sampleDesc.getMaxSamples(), sampleDesc.getMsaaPattern() ); return retVal; diff --git a/OgreMain/src/OgreTextureGpu.cpp b/OgreMain/src/OgreTextureGpu.cpp index 53f5a3efc8..5f7fefc72c 100644 --- a/OgreMain/src/OgreTextureGpu.cpp +++ b/OgreMain/src/OgreTextureGpu.cpp @@ -450,13 +450,9 @@ namespace Ogre uint32 msaaTextureFlags = TextureFlags::NotTexture; if( hasMsaaExplicitResolves() ) msaaTextureFlags = mTextureFlags; - uint32 depthFormatTextureFlags = 0u; - if( !getPreferDepthTexture() ) - depthFormatTextureFlags = TextureFlags::NotTexture; mSampleDescription = mTextureManager->getRenderSystem()->validateSampleDescription( - mRequestedSampleDescription, mPixelFormat, msaaTextureFlags, - depthFormatTextureFlags ); + mRequestedSampleDescription, mPixelFormat, msaaTextureFlags ); } if( !( mSampleDescription == mRequestedSampleDescription ) ) notifyAllListenersTextureChanged( TextureGpuListener::FsaaSettingAlteredByApi, 0 ); diff --git a/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h b/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h index 9d396ed525..38efc81ccc 100644 --- a/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h +++ b/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h @@ -334,8 +334,8 @@ namespace Ogre void postExtraThreadsStarted() override; SampleDescription validateSampleDescription( const SampleDescription &sampleDesc, - PixelFormatGpu format, uint32 textureFlags, - uint32 depthTextureFlags ) override; + PixelFormatGpu format, + uint32 textureFlags ) override; /// @copydoc RenderSystem::getDisplayMonitorCount unsigned int getDisplayMonitorCount() const override; diff --git a/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp b/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp index cd9d02695a..26805ad7d3 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp @@ -3707,11 +3707,9 @@ namespace Ogre //--------------------------------------------------------------------- SampleDescription D3D11RenderSystem::validateSampleDescription( const SampleDescription &sampleDesc, PixelFormatGpu format, - uint32 textureFlags, - uint32 depthTextureFlags ) + uint32 textureFlags ) { OGRE_UNUSED_VAR( textureFlags ); - OGRE_UNUSED_VAR( depthTextureFlags ); SampleDescription res; DXGI_FORMAT dxgiFormat = D3D11Mappings::get( format ); diff --git a/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp b/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp index dd42e0ed86..e3576aa073 100644 --- a/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp +++ b/RenderSystems/Direct3D11/src/OgreD3D11Window.cpp @@ -336,9 +336,9 @@ namespace Ogre if( mUseFlipMode ) { // swapchain is not multisampled in flip sequential mode, so we reuse it - // D3D11 doesn't care about texture flags, so we leave them as 0. - mSampleDescription = mRenderSystem->validateSampleDescription( mRequestedSampleDescription, - _getRenderFormat(), 0u, 0u ); + mSampleDescription = mRenderSystem->validateSampleDescription( + mRequestedSampleDescription, _getRenderFormat(), + TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific ); } else { diff --git a/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowHwnd.cpp b/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowHwnd.cpp index 8bf6cdcf5f..bdc7289d99 100644 --- a/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowHwnd.cpp +++ b/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowHwnd.cpp @@ -158,9 +158,9 @@ namespace Ogre //----------------------------------------------------------------------------------- HRESULT D3D11WindowHwnd::_createSwapChainImpl() { - // D3D11 doesn't care about texture flags, so we leave them as 0. - mSampleDescription = mRenderSystem->validateSampleDescription( mRequestedSampleDescription, - _getRenderFormat(), 0u, 0u ); + mSampleDescription = mRenderSystem->validateSampleDescription( + mRequestedSampleDescription, _getRenderFormat(), + TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific ); HRESULT hr; // Create swap chain diff --git a/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowWinRT.cpp b/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowWinRT.cpp index 461d9a1dda..fff013f7c8 100644 --- a/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowWinRT.cpp +++ b/RenderSystems/Direct3D11/src/Windowing/WIN32/OgreD3D11WindowWinRT.cpp @@ -118,8 +118,8 @@ namespace Ogre { # if !__OGRE_WINRT_PHONE mSampleDescription = mRenderSystem->validateSampleDescription( - mRequestedSampleDescription, _getRenderFormat(), TextureFlags::NotTexture, - TextureFlags::NotTexture ); + mRequestedSampleDescription, _getRenderFormat(), + TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific ); # endif DXGI_SWAP_CHAIN_DESC1 desc = {}; desc.Width = 0; // Use automatic sizing. @@ -276,8 +276,8 @@ namespace Ogre { # if !__OGRE_WINRT_PHONE mSampleDescription = mRenderSystem->validateSampleDescription( - mRequestedSampleDescription, _getRenderFormat(), TextureFlags::NotTexture, - TextureFlags::NotTexture ); + mRequestedSampleDescription, _getRenderFormat(), + TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific ); # endif int widthPx = std::max( 1, (int)floorf( mRequestedWidth * mCompositionScale.Width + 0.5f ) ); diff --git a/RenderSystems/Metal/include/OgreMetalRenderSystem.h b/RenderSystems/Metal/include/OgreMetalRenderSystem.h index c56747ef02..f027e395de 100644 --- a/RenderSystems/Metal/include/OgreMetalRenderSystem.h +++ b/RenderSystems/Metal/include/OgreMetalRenderSystem.h @@ -297,8 +297,8 @@ namespace Ogre unsigned int getDisplayMonitorCount() const override { return 1; } SampleDescription validateSampleDescription( const SampleDescription &sampleDesc, - PixelFormatGpu format, uint32 textureFlags, - uint32 depthTextureFlags ) override; + PixelFormatGpu format, + uint32 textureFlags ) override; const PixelFormatToShaderType *getPixelFormatToShaderType() const override; diff --git a/RenderSystems/Metal/src/OgreMetalRenderSystem.mm b/RenderSystems/Metal/src/OgreMetalRenderSystem.mm index afe8274a30..65df397c37 100644 --- a/RenderSystems/Metal/src/OgreMetalRenderSystem.mm +++ b/RenderSystems/Metal/src/OgreMetalRenderSystem.mm @@ -240,8 +240,7 @@ of this software and associated documentation files (the "Software"), to deal //------------------------------------------------------------------------- SampleDescription MetalRenderSystem::validateSampleDescription( const SampleDescription &sampleDesc, PixelFormatGpu format, - uint32 textureFlags, - uint32 depthTextureFlags ) + uint32 textureFlags ) { uint8 samples = sampleDesc.getMaxSamples(); if( @available( iOS 9.0, * ) ) diff --git a/RenderSystems/Metal/src/OgreMetalWindow.mm b/RenderSystems/Metal/src/OgreMetalWindow.mm index 6da96af60c..cfe29f57aa 100644 --- a/RenderSystems/Metal/src/OgreMetalWindow.mm +++ b/RenderSystems/Metal/src/OgreMetalWindow.mm @@ -510,8 +510,8 @@ static void SetupMetalWindowListeners( Ogre::MetalWindow *metalWindow, NSWindow // We create our MSAA buffer and it is not accessible, thus NotTexture. // Same for our depth buffer. mSampleDescription = textureManager->getRenderSystem()->validateSampleDescription( - mRequestedSampleDescription, mTexture->getPixelFormat(), TextureFlags::NotTexture, - TextureFlags::NotTexture ); + mRequestedSampleDescription, mTexture->getPixelFormat(), + TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific ); mTexture->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); if( mDepthBuffer ) mDepthBuffer->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); diff --git a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h index efad4ebefd..a9379f17c9 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h +++ b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h @@ -406,8 +406,8 @@ namespace Ogre void _descriptorSetUavDestroyed( DescriptorSetUav *set ) override; SampleDescription validateSampleDescription( const SampleDescription &sampleDesc, - PixelFormatGpu format, uint32 textureFlags, - uint32 depthTextureFlags ) override; + PixelFormatGpu format, + uint32 textureFlags ) override; VulkanDevice *getVulkanDevice() const { return mDevice; } void _notifyDeviceStalled(); diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 514ac6159a..38b8aff68c 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -3877,8 +3877,7 @@ namespace Ogre inline bool isPowerOf2( uint32 x ) { return ( x & ( x - 1u ) ) == 0u; } SampleDescription VulkanRenderSystem::validateSampleDescription( const SampleDescription &sampleDesc, PixelFormatGpu format, - uint32 textureFlags, - uint32 depthTextureFlags ) + uint32 textureFlags ) { if( !mDevice ) { @@ -3898,90 +3897,52 @@ namespace Ogre // TODO: Support VK_AMD_mixed_attachment_samples & VK_NV_framebuffer_mixed_samples. return validateSampleDescription( SampleDescription( sampleDesc.getMaxSamples(), sampleDesc.getMsaaPattern() ), format, - textureFlags, depthTextureFlags ); + textureFlags ); } else { // MSAA. - VkSampleCountFlags supportedSampleCounts = 0u; + VkSampleCountFlags supportedSampleCounts = (VK_SAMPLE_COUNT_64_BIT << 1) - 1; - if( PixelFormatGpuUtils::isDepth( format ) ) - { - // Not an if-else typo: storageImageSampleCounts is AND'ed against *DepthSampleCounts. - if( textureFlags & TextureFlags::Uav ) - supportedSampleCounts = deviceLimits.storageImageSampleCounts; - - if( textureFlags & TextureFlags::NotTexture ) - supportedSampleCounts = deviceLimits.framebufferDepthSampleCounts; - else - supportedSampleCounts = deviceLimits.sampledImageDepthSampleCounts; - - if( PixelFormatGpuUtils::isStencil( format ) ) - { - // Not a typo: storageImageSampleCounts is AND'ed against *StencilSampleCounts. - if( textureFlags & TextureFlags::Uav ) - supportedSampleCounts &= deviceLimits.storageImageSampleCounts; - - if( textureFlags & TextureFlags::NotTexture ) - supportedSampleCounts &= deviceLimits.framebufferStencilSampleCounts; - else - supportedSampleCounts &= deviceLimits.sampledImageStencilSampleCounts; - } - } - else if( PixelFormatGpuUtils::isStencil( format ) ) - { - // Not an if-else typo: storageImageSampleCounts is AND'ed against *StencilSampleCounts. - if( textureFlags & TextureFlags::Uav ) - supportedSampleCounts = deviceLimits.storageImageSampleCounts; - - if( textureFlags & TextureFlags::NotTexture ) - supportedSampleCounts = deviceLimits.framebufferStencilSampleCounts; - else - supportedSampleCounts = deviceLimits.sampledImageStencilSampleCounts; - } - else if( format == PFG_NULL ) + if( format == PFG_NULL ) { // PFG_NULL is always NotTexture and can't be Uav, // let's just return to the user what they intended to ask. supportedSampleCounts = deviceLimits.framebufferNoAttachmentsSampleCounts; } - else if( PixelFormatGpuUtils::isInteger( format ) ) - { - // TODO: Query Vulkan 1.2 / extensions to get framebufferIntegerColorSampleCounts. - // supportedSampleCounts = deviceLimits.framebufferIntegerColorSampleCounts; - supportedSampleCounts = VK_SAMPLE_COUNT_1_BIT; - } + else if( textureFlags & TextureFlags::Uav ) + supportedSampleCounts &= deviceLimits.storageImageSampleCounts; else { - if( textureFlags & TextureFlags::Uav ) - supportedSampleCounts = deviceLimits.storageImageSampleCounts; - else if( textureFlags & TextureFlags::NotTexture ) - supportedSampleCounts = deviceLimits.framebufferColorSampleCounts; - else - supportedSampleCounts = deviceLimits.sampledImageColorSampleCounts; + bool isDepth = PixelFormatGpuUtils::isDepth( format ); + bool isStencil = PixelFormatGpuUtils::isStencil( format ); + bool isInteger = PixelFormatGpuUtils::isInteger( format ); - if( PixelFormatGpuUtils::isDepth( format ) ) + if( textureFlags & ( TextureFlags::NotTexture | TextureFlags::RenderToTexture | + TextureFlags::RenderWindowSpecific ) ) { - // Not an if-else typo: storageImage... is AND'ed against *DepthSampleCounts. - if( depthTextureFlags & TextureFlags::Uav ) - supportedSampleCounts &= deviceLimits.storageImageSampleCounts; - - if( depthTextureFlags & TextureFlags::NotTexture ) + // frame buffer + if( !isDepth && !isStencil && !isInteger ) + supportedSampleCounts &= deviceLimits.framebufferColorSampleCounts; + if( isDepth || ( textureFlags & TextureFlags::RenderWindowSpecific ) ) supportedSampleCounts &= deviceLimits.framebufferDepthSampleCounts; - else - supportedSampleCounts &= deviceLimits.sampledImageDepthSampleCounts; + if( isStencil || ( textureFlags & TextureFlags::RenderWindowSpecific ) ) + supportedSampleCounts &= deviceLimits.framebufferStencilSampleCounts; + if( isInteger ) // TODO: Query Vulkan 1.2 / extensions to get framebufferIntegerColorSampleCounts. + supportedSampleCounts &= VK_SAMPLE_COUNT_1_BIT; + } - if( PixelFormatGpuUtils::isStencil( format ) ) - { - // Not a typo: storageImageSampleCounts is AND'ed against *StencilSampleCounts. - if( depthTextureFlags & TextureFlags::Uav ) - supportedSampleCounts &= deviceLimits.storageImageSampleCounts; - - if( depthTextureFlags & TextureFlags::NotTexture ) - supportedSampleCounts &= deviceLimits.framebufferStencilSampleCounts; - else - supportedSampleCounts &= deviceLimits.sampledImageStencilSampleCounts; - } + if( 0 == ( textureFlags & TextureFlags::NotTexture ) ) + { + // sampled image + if( !isDepth && !isStencil && !isInteger ) + supportedSampleCounts &= deviceLimits.sampledImageColorSampleCounts; + if( isDepth || ( textureFlags & TextureFlags::RenderWindowSpecific ) ) + supportedSampleCounts &= deviceLimits.sampledImageDepthSampleCounts; + if( isStencil || ( textureFlags & TextureFlags::RenderWindowSpecific ) ) + supportedSampleCounts &= deviceLimits.sampledImageStencilSampleCounts; + if( isInteger ) + supportedSampleCounts &= deviceLimits.sampledImageIntegerSampleCounts; } } diff --git a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp index 3875b0e53a..3b1bceab49 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp @@ -157,10 +157,12 @@ namespace Ogre mStencilBuffer = mDepthBuffer; } - mTexture->setSampleDescription( mRequestedSampleDescription ); + mSampleDescription = mDevice->mRenderSystem->validateSampleDescription( + mRequestedSampleDescription, mTexture->getPixelFormat(), + TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific ); + mTexture->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); if( mDepthBuffer ) - mDepthBuffer->setSampleDescription( mRequestedSampleDescription ); - mSampleDescription = mRequestedSampleDescription; + mDepthBuffer->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); if( mDepthBuffer ) { diff --git a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp index bc1b6032ec..07d4101d34 100644 --- a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp +++ b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp @@ -418,10 +418,12 @@ namespace Ogre mStencilBuffer = mDepthBuffer; } - mTexture->setSampleDescription( mRequestedSampleDescription ); + mSampleDescription = mDevice->mRenderSystem->validateSampleDescription( + mRequestedSampleDescription, mTexture->getPixelFormat(), + TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific ); + mTexture->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); if( mDepthBuffer ) - mDepthBuffer->setSampleDescription( mRequestedSampleDescription ); - mSampleDescription = mRequestedSampleDescription; + mDepthBuffer->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); if( mDepthBuffer ) { diff --git a/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp b/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp index db4f507a3e..7f6e08a56f 100644 --- a/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp +++ b/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp @@ -237,10 +237,12 @@ namespace Ogre mStencilBuffer = mDepthBuffer; } - mTexture->setSampleDescription( mRequestedSampleDescription ); + mSampleDescription = mDevice->mRenderSystem->validateSampleDescription( + mRequestedSampleDescription, mTexture->getPixelFormat(), + TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific ); + mTexture->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); if( mDepthBuffer ) - mDepthBuffer->setSampleDescription( mRequestedSampleDescription ); - mSampleDescription = mRequestedSampleDescription; + mDepthBuffer->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); if( mDepthBuffer ) { diff --git a/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp b/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp index 71b70db41a..6c7206c6e5 100644 --- a/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp +++ b/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp @@ -552,10 +552,12 @@ namespace Ogre mStencilBuffer = mDepthBuffer; } - mTexture->setSampleDescription( mRequestedSampleDescription ); + mSampleDescription = mDevice->mRenderSystem->validateSampleDescription( + mRequestedSampleDescription, mTexture->getPixelFormat(), + TextureFlags::NotTexture | TextureFlags::RenderWindowSpecific ); + mTexture->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); if( mDepthBuffer ) - mDepthBuffer->setSampleDescription( mRequestedSampleDescription ); - mSampleDescription = mRequestedSampleDescription; + mDepthBuffer->_setSampleDescription( mRequestedSampleDescription, mSampleDescription ); if( mDepthBuffer ) { @@ -567,8 +569,6 @@ namespace Ogre mTexture->_setDepthBufferDefaults( DepthBuffer::POOL_NO_DEPTH, false, PFG_NULL ); } - mSampleDescription = mRequestedSampleDescription; - createSwapchain(); setHidden( mHidden ); From 4ab51f15c7d6b03b1597edfdc65898a18320ec36 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Tue, 1 Oct 2024 21:53:57 -0300 Subject: [PATCH 26/47] Small cosmetic changes Const correctness Add braces for readability Clang format comment --- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 38b8aff68c..2a85abb1ca 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -3902,7 +3902,7 @@ namespace Ogre else { // MSAA. - VkSampleCountFlags supportedSampleCounts = (VK_SAMPLE_COUNT_64_BIT << 1) - 1; + VkSampleCountFlags supportedSampleCounts = ( VK_SAMPLE_COUNT_64_BIT << 1 ) - 1; if( format == PFG_NULL ) { @@ -3911,12 +3911,14 @@ namespace Ogre supportedSampleCounts = deviceLimits.framebufferNoAttachmentsSampleCounts; } else if( textureFlags & TextureFlags::Uav ) + { supportedSampleCounts &= deviceLimits.storageImageSampleCounts; + } else { - bool isDepth = PixelFormatGpuUtils::isDepth( format ); - bool isStencil = PixelFormatGpuUtils::isStencil( format ); - bool isInteger = PixelFormatGpuUtils::isInteger( format ); + const bool isDepth = PixelFormatGpuUtils::isDepth( format ); + const bool isStencil = PixelFormatGpuUtils::isStencil( format ); + const bool isInteger = PixelFormatGpuUtils::isInteger( format ); if( textureFlags & ( TextureFlags::NotTexture | TextureFlags::RenderToTexture | TextureFlags::RenderWindowSpecific ) ) @@ -3928,8 +3930,12 @@ namespace Ogre supportedSampleCounts &= deviceLimits.framebufferDepthSampleCounts; if( isStencil || ( textureFlags & TextureFlags::RenderWindowSpecific ) ) supportedSampleCounts &= deviceLimits.framebufferStencilSampleCounts; - if( isInteger ) // TODO: Query Vulkan 1.2 / extensions to get framebufferIntegerColorSampleCounts. + if( isInteger ) + { + // TODO: Query Vulkan 1.2 / extensions to get + // framebufferIntegerColorSampleCounts. supportedSampleCounts &= VK_SAMPLE_COUNT_1_BIT; + } } if( 0 == ( textureFlags & TextureFlags::NotTexture ) ) From a3fcd63542ba119569cd51d6305c9c58b098666b Mon Sep 17 00:00:00 2001 From: "Dmytro Yunchyk(aka DimA)" Date: Wed, 2 Oct 2024 18:02:26 +0200 Subject: [PATCH 27/47] [Vk] assert to catch mSharedFboItor pointing to nothing --- RenderSystems/Vulkan/src/OgreVulkanRenderPassDescriptor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderPassDescriptor.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderPassDescriptor.cpp index e1678014b0..d8139010fc 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderPassDescriptor.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderPassDescriptor.cpp @@ -906,6 +906,7 @@ namespace Ogre VkCommandBuffer cmdBuffer = mQueue->getCurrentCmdBuffer(); + OGRE_ASSERT_LOW( mSharedFboItor != mRenderSystem->_getFrameBufferDescMap().end() ); const VulkanFrameBufferDescValue &fboDesc = mSharedFboItor->second; size_t fboIdx = 0u; From 7255629b6495aa3add9f4ae3cfc1f46909e5d02e Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Tue, 8 Oct 2024 21:27:53 +0200 Subject: [PATCH 28/47] [Vk] Avoid swapchain recreation in windowMovedOrResized() when window is moved but not resized. Swapchains suboptimal due to the mismatching colorspace or orientation are still rebuilt. --- .../Windowing/Android/OgreVulkanAndroidWindow.cpp | 8 +++++--- .../Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp | 12 +++++++++--- .../src/Windowing/win32/OgreVulkanWin32Window.cpp | 3 +++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp index 07d4101d34..ca16434dec 100644 --- a/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp +++ b/RenderSystems/Vulkan/src/Windowing/Android/OgreVulkanAndroidWindow.cpp @@ -241,6 +241,11 @@ namespace Ogre if( mClosed || !mNativeWindow ) return; + const uint32 newWidth = static_cast( ANativeWindow_getWidth( mNativeWindow ) ); + const uint32 newHeight = static_cast( ANativeWindow_getHeight( mNativeWindow ) ); + if( newWidth == getWidth() && newHeight == getHeight() && !mRebuildingSwapchain ) + return; + mDevice->stall(); #ifdef OGRE_VULKAN_USE_SWAPPY @@ -285,9 +290,6 @@ namespace Ogre mStencilBuffer->_transitionTo( GpuResidency::OnStorage, (uint8 *)0 ); } - const uint32 newWidth = static_cast( ANativeWindow_getWidth( mNativeWindow ) ); - const uint32 newHeight = static_cast( ANativeWindow_getHeight( mNativeWindow ) ); - setFinalResolution( newWidth, newHeight ); createSwapchain(); diff --git a/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp b/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp index 7f6e08a56f..7400a37722 100644 --- a/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp +++ b/RenderSystems/Vulkan/src/Windowing/X11/OgreVulkanXcbWindow.cpp @@ -517,6 +517,14 @@ namespace Ogre mTop = geom->y; } + auto newWidth = geom->width; + auto newHeight = geom->height; + + free( geom ); + + if( newWidth == getWidth() && newHeight == getHeight() && !mRebuildingSwapchain ) + return; + mDevice->stall(); destroySwapchain(); @@ -527,11 +535,9 @@ namespace Ogre if( mStencilBuffer && mStencilBuffer != mDepthBuffer ) mStencilBuffer->_transitionTo( GpuResidency::OnStorage, (uint8 *)0 ); - setFinalResolution( geom->width, geom->height ); + setFinalResolution( newWidth, newHeight ); createSwapchain(); - - free( geom ); } //------------------------------------------------------------------------- void VulkanXcbWindow::_setVisible( bool visible ) { mVisible = visible; } diff --git a/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp b/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp index 6c7206c6e5..351d0009d6 100644 --- a/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp +++ b/RenderSystems/Vulkan/src/Windowing/win32/OgreVulkanWin32Window.cpp @@ -727,6 +727,9 @@ namespace Ogre updateWindowRect(); + if( mRequestedWidth == getWidth() && mRequestedHeight == getHeight() && !mRebuildingSwapchain ) + return; + mDevice->stall(); destroySwapchain(); From 886cdfe5d12b00003aa2c1e8074f2a82c8592715 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Tue, 8 Oct 2024 21:47:59 +0200 Subject: [PATCH 29/47] [Ogre] We want to halt using macro + builtin rather than inline function, to generate debug information with assertion line number rather than halting machinery line number. Better stack symbolication in Google Play Console, that otherwise shows outer function name + original source line number of the then inlined body of the trap_instruction(), making several OGRE_ASSERTs indistinguishable --- OgreMain/include/OgreAssert.h | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/OgreMain/include/OgreAssert.h b/OgreMain/include/OgreAssert.h index bfd7655d5b..8c9934209d 100644 --- a/OgreMain/include/OgreAssert.h +++ b/OgreMain/include/OgreAssert.h @@ -34,7 +34,6 @@ #define _OgreAssert_H_ #include "OgrePrerequisites.h" -#include "debugbreak/debugbreak.h" namespace Ogre { @@ -57,7 +56,46 @@ namespace Ogre } // namespace Assert } // namespace Ogre -#define OGRE_HALT() debug_break() +// We want to halt using macro + builtin rather than inline function, to generate debug information +// with assertion line number rather than halting machinery line number. Inspired by +// https://github.com/nemequ/portable-snippets/blob/master/debug-trap/debug-trap.h +// https://github.com/scottt/debugbreak/blob/master/debugbreak.h +#if defined( __has_builtin ) +# if __has_builtin( __builtin_debugtrap ) +# define OGRE_HALT() __builtin_debugtrap() +# elif __has_builtin( __debugbreak ) +# define OGRE_HALT() __debugbreak() +# endif +#endif +#if !defined( OGRE_HALT ) +# if defined( _MSC_VER ) || defined( __INTEL_COMPILER ) +# define OGRE_HALT() __debugbreak() +# elif defined( __DMC__ ) && defined( _M_IX86 ) +# define OGRE_HALT() __asm int 3h +# elif defined( __i386__ ) || defined( __x86_64__ ) +# define OGRE_HALT() __asm__ __volatile__( "int3" ) +# elif defined( __thumb__ ) +# define OGRE_HALT() __asm__ __volatile__( ".inst 0xde01" ) +# elif defined( __aarch64__ ) +# define OGRE_HALT() __asm__ __volatile__( ".inst 0xd4200000" ) +# elif defined( __arm__ ) +# define OGRE_HALT() __asm__ __volatile__( ".inst 0xe7f001f0" ) +# elif defined( __alpha__ ) && !defined( __osf__ ) +# define OGRE_HALT() __asm__ __volatile__( "bpt" ) +# elif defined( __powerpc__ ) +# define OGRE_HALT() __asm__ __volatile__( ".4byte 0x7d821008" ) +# elif defined( __riscv ) +# define OGRE_HALT() __asm__ __volatile__( ".4byte 0x00100073" ) +# else +# include +# if defined( SIGTRAP ) +# define OGRE_HALT() raise( SIGTRAP ) +# else +# define OGRE_HALT() raise( SIGABRT ) +# endif +# endif +#endif + #define OGRE_UNUSED( x ) \ do \ { \ From 4a713b8d83638c505685892677e9df1d764043e6 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Wed, 9 Oct 2024 18:26:13 +0200 Subject: [PATCH 30/47] Reduce shaders variability, avoiding writing to shader code lines like *** target_envprobe_map 1460524074 --- Components/Hlms/Pbs/src/OgreHlmsPbs.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp b/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp index 5c262cbf02..930591bc02 100644 --- a/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp +++ b/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp @@ -1146,9 +1146,16 @@ namespace Ogre if( getProperty( tid, HlmsBaseProp::Pose ) > 0 ) setProperty( tid, HlmsBaseProp::VertexId, 1 ); - const int32 envProbeMapVal = getProperty( tid, PbsProperty::EnvProbeMap ); - const bool canUseManualProbe = - envProbeMapVal && envProbeMapVal != getProperty( tid, PbsProperty::TargetEnvprobeMap ); + const int32 envProbeMap = getProperty( tid, PbsProperty::EnvProbeMap ); + const int32 targetEnvProbeMap = getProperty( tid, PbsProperty::TargetEnvprobeMap ); + const bool canUseManualProbe = envProbeMap && envProbeMap != targetEnvProbeMap; + + // Reduce shaders variability, reset EnvProbeMap and TargetEnvprobeMap to 1 or 0 + // preserving outcome of predicate 'envprobe_map && envprobe_map != target_envprobe_map' + if( envProbeMap ) + setProperty( tid, PbsProperty::EnvProbeMap, 1 ); + setProperty( tid, PbsProperty::TargetEnvprobeMap, envProbeMap == targetEnvProbeMap ); + if( canUseManualProbe || getProperty( tid, PbsProperty::ParallaxCorrectCubemaps ) ) { setProperty( tid, PbsProperty::UseEnvProbeMap, 1 ); @@ -1368,8 +1375,6 @@ namespace Ogre } } - const int32 envProbeMap = getProperty( tid, PbsProperty::EnvProbeMap ); - const int32 targetEnvProbeMap = getProperty( tid, PbsProperty::TargetEnvprobeMap ); if( ( envProbeMap && envProbeMap != targetEnvProbeMap ) || parallaxCorrectCubemaps ) { if( !envProbeMap || envProbeMap == targetEnvProbeMap ) From 7127253eace345761c3b66697081611b7eebbf05 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 10 Oct 2024 13:50:27 +0200 Subject: [PATCH 31/47] [Vk] write size of loaded or saved pipeline cache to log --- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 2a85abb1ca..2fef706a8b 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -516,11 +516,18 @@ namespace Ogre result = vkCreatePipelineCache( mActiveDevice->mDevice, &pipelineCacheCreateInfo, nullptr, &pipelineCache ); if( VK_SUCCESS == result && pipelineCache != 0 ) + { std::swap( mActiveDevice->mPipelineCache, pipelineCache ); + LogManager::getSingleton().logMessage( "[Vulkan] Pipeline cache loaded, " + + StringConverter::toString( buf.size() ) + + " bytes." ); + } else + { LogManager::getSingleton().logMessage( "[Vulkan] Pipeline cache loading failed. VkResult = " + vkResultToString( result ) ); + } if( pipelineCache != 0 ) vkDestroyPipelineCache( mActiveDevice->mDevice, pipelineCache, nullptr ); } @@ -567,7 +574,9 @@ namespace Ogre hdr.dataHash = hashResult[0]; stream->write( buf.data(), buf.size() ); - LogManager::getSingleton().logMessage( "[Vulkan] Pipeline cache saved." ); + LogManager::getSingleton().logMessage( "[Vulkan] Pipeline cache saved, " + + StringConverter::toString( buf.size() ) + + " bytes." ); } } if( result != VK_SUCCESS ) From ade72b91faf4e419ee001f8b00d600936fd767b2 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Mon, 14 Oct 2024 19:13:15 -0300 Subject: [PATCH 32/47] Fix hasMinVersion() Two drivers having the same minor but different release value must be considered different when looking for workarounds and bugs. --- OgreMain/include/OgreRenderSystemCapabilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OgreMain/include/OgreRenderSystemCapabilities.h b/OgreMain/include/OgreRenderSystemCapabilities.h index 740a41a698..95b13e7b93 100644 --- a/OgreMain/include/OgreRenderSystemCapabilities.h +++ b/OgreMain/include/OgreRenderSystemCapabilities.h @@ -331,7 +331,7 @@ namespace Ogre bool hasMinVersion( int minMajor, int minMinor, int minRel ) const { - return major > minMajor || ( major == minMajor && minor >= minMinor ) || + return major > minMajor || ( major == minMajor && minor > minMinor ) || ( major == minMajor && minor == minMinor && release >= minRel ); } }; From c125d4179320d9aac98056f29cb484f0f1fbbd38 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Tue, 15 Oct 2024 19:23:40 -0300 Subject: [PATCH 33/47] Default OGRE_USE_NEW_PROJECT_NAME = ON for 4.0 As per documentation, OGRE_USE_NEW_PROJECT_NAME defaults to off in 3.0 and defaults to on in 4.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dacb857854..9828a8056d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ endif () # OgreAddTargets and OgreConfigTargets make use of OGRE_NEXT and OGRE_NEXT_PREFIX option(OGRE_USE_NEW_PROJECT_NAME "Libraries containing Ogre name will be called OgreNext, e.g. 'OgreNext.dll' instead of 'Ogre.dll'" - FALSE) + TRUE) if( OGRE_USE_NEW_PROJECT_NAME ) set( OGRE_NEXT "OgreNext" ) From 99a76aee87b6dc8394a47205cf8c7cae51a4bc50 Mon Sep 17 00:00:00 2001 From: "Dmytro Yunchyk(aka DimA)" Date: Mon, 21 Oct 2024 15:56:38 +0300 Subject: [PATCH 34/47] fixed shader cache entry creation in HlmsLowLevel::createShaderCacheEntry() when getProperty( kNoTid, HlmsBaseProp::ShadowCaster )!=casterPass --- OgreMain/src/OgreHlms.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OgreMain/src/OgreHlms.cpp b/OgreMain/src/OgreHlms.cpp index 347cc47560..cfc208d4e6 100644 --- a/OgreMain/src/OgreHlms.cpp +++ b/OgreMain/src/OgreHlms.cpp @@ -3660,8 +3660,13 @@ namespace Ogre // Low level is a special case because it doesn't (yet?) support parallel compilation if( !parallelQueue || mType == HLMS_LOW_LEVEL ) { + bool saveShadowCasterProp = getProperty( kNoTid, HlmsBaseProp::ShadowCaster ); + if( saveShadowCasterProp != casterPass ) + setProperty( kNoTid, HlmsBaseProp::ShadowCaster, casterPass ); lastReturnedValue = createShaderCacheEntry( hash[0], passCache, finalHash, queuedRenderable, nullptr, kNoTid ); + if( saveShadowCasterProp != casterPass ) + setProperty( kNoTid, HlmsBaseProp::ShadowCaster, saveShadowCasterProp ); } else { From 12eef284d51f3e727aef2840ad4e4bf5c1d981a7 Mon Sep 17 00:00:00 2001 From: "Dmytro Yunchyk(aka DimA)" Date: Tue, 22 Oct 2024 11:36:37 +0300 Subject: [PATCH 35/47] better fix for HlmsLowLevel::createShaderCacheEntry() - get casterPass from passCache rather then from ThreadDataVec --- OgreMain/src/OgreHlms.cpp | 5 ----- OgreMain/src/OgreHlmsLowLevel.cpp | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/OgreMain/src/OgreHlms.cpp b/OgreMain/src/OgreHlms.cpp index cfc208d4e6..347cc47560 100644 --- a/OgreMain/src/OgreHlms.cpp +++ b/OgreMain/src/OgreHlms.cpp @@ -3660,13 +3660,8 @@ namespace Ogre // Low level is a special case because it doesn't (yet?) support parallel compilation if( !parallelQueue || mType == HLMS_LOW_LEVEL ) { - bool saveShadowCasterProp = getProperty( kNoTid, HlmsBaseProp::ShadowCaster ); - if( saveShadowCasterProp != casterPass ) - setProperty( kNoTid, HlmsBaseProp::ShadowCaster, casterPass ); lastReturnedValue = createShaderCacheEntry( hash[0], passCache, finalHash, queuedRenderable, nullptr, kNoTid ); - if( saveShadowCasterProp != casterPass ) - setProperty( kNoTid, HlmsBaseProp::ShadowCaster, saveShadowCasterProp ); } else { diff --git a/OgreMain/src/OgreHlmsLowLevel.cpp b/OgreMain/src/OgreHlmsLowLevel.cpp index d3403b08d7..fe6d976e31 100644 --- a/OgreMain/src/OgreHlmsLowLevel.cpp +++ b/OgreMain/src/OgreHlmsLowLevel.cpp @@ -98,7 +98,7 @@ namespace Ogre if( pass->hasFragmentProgram() ) pso.pixelShader = pass->getFragmentProgram(); - bool casterPass = getProperty( tid, HlmsBaseProp::ShadowCaster ) != 0; + bool casterPass = getProperty( passCache.setProperties, HlmsBaseProp::ShadowCaster ) != 0; const HlmsDatablock *datablock = queuedRenderable.renderable->getDatablock(); pso.macroblock = datablock->getMacroblock( casterPass ); From 563249dac15896577d2c9af7539c895a6c1f80a3 Mon Sep 17 00:00:00 2001 From: Esther Dalhuisen Date: Tue, 29 Oct 2024 14:57:18 +0100 Subject: [PATCH 36/47] Fix include path error when compiling Ogre as a subproject --- Components/SceneFormat/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Components/SceneFormat/CMakeLists.txt b/Components/SceneFormat/CMakeLists.txt index 9a220ff667..49ba326216 100644 --- a/Components/SceneFormat/CMakeLists.txt +++ b/Components/SceneFormat/CMakeLists.txt @@ -21,7 +21,7 @@ file( include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -include_directories(${CMAKE_SOURCE_DIR}/Components/Hlms/Common/include) +include_directories(${OGRE_SOURCE_DIR}/Components/Hlms/Common/include) ogre_add_component_include_dir(Hlms/Pbs) add_definitions( -DOgreSceneFormat_EXPORTS ) From c545473fa509bcc39ef80f025baea62eeab783d7 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 4 Nov 2024 11:41:22 +0100 Subject: [PATCH 37/47] fixed log message --- RenderSystems/Vulkan/src/OgreVulkanDiscardBufferManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanDiscardBufferManager.cpp b/RenderSystems/Vulkan/src/OgreVulkanDiscardBufferManager.cpp index 641757cf33..cf0b106968 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDiscardBufferManager.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDiscardBufferManager.cpp @@ -110,7 +110,7 @@ namespace Ogre } LogManager::getSingleton().logMessage( - "PERFORMANCE WARNING: MetalDiscardBufferManager::growToFit must stall." + "PERFORMANCE WARNING: VulkanDiscardBufferManager::growToFit must stall." "Consider increasing the default discard capacity to at least " + StringConverter::toString( newCapacity ) + " bytes" ); From 52e7d95a0c83d0ed726e31bc9f99ba603aa11d05 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 4 Nov 2024 20:52:26 +0100 Subject: [PATCH 38/47] [Vk] always set RSC_32BIT_INDEX, even if range is limited to 2^24-1 --- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 2fef706a8b..605ca7d590 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -808,6 +808,9 @@ namespace Ogre rsc->setCapability( RSC_CUBEMAPPING ); rsc->setCapability( RSC_TEXTURE_COMPRESSION ); rsc->setCapability( RSC_VBO ); + // VK_INDEX_TYPE_UINT32 is always supported with range at least 2^24-1 + // and even 2^32-1 if mActiveDevice->mDeviceFeatures.fullDrawIndexUint32 + rsc->setCapability( RSC_32BIT_INDEX ); rsc->setCapability( RSC_TWO_SIDED_STENCIL ); rsc->setCapability( RSC_STENCIL_WRAP ); if( mActiveDevice->mDeviceFeatures.shaderClipDistance ) From 4e4f3ab6c4165702c157b169133c587c65464979 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 4 Nov 2024 22:52:24 +0100 Subject: [PATCH 39/47] [Vk] Skip zero size heaps in addMemoryType() as in https://vulkan.gpuinfo.org/displayreport.php?id=34174#memory --- RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp index d10472aa80..d2c372f81e 100644 --- a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp +++ b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp @@ -705,6 +705,11 @@ namespace Ogre const VkPhysicalDeviceMemoryProperties &memProperties, const uint32 memoryTypeIdx ) { + // Skip zero size heaps, as in https://vulkan.gpuinfo.org/displayreport.php?id=34174#memory + // on Vulkan Compatibility Pack for Arm64 Windows over Parallels Display Adapter (WDDM) + if( memProperties.memoryHeaps[memProperties.memoryTypes[memoryTypeIdx].heapIndex].size == 0 ) + return; + FastArray::iterator itor = mBestVkMemoryTypeIndex[vboFlag].begin(); FastArray::iterator endt = mBestVkMemoryTypeIndex[vboFlag].end(); From 523f02b3f371db2b093be4b6e8f2e0c48701399f Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Wed, 6 Nov 2024 17:22:34 +0100 Subject: [PATCH 40/47] .gitignore Dependencies folder itself, not only content of it --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 40543d2b96..fd5c2ccb95 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ syntax: glob *.rule *.sdf .DS_Store -Dependencies/* +Dependencies iOSDependencies build/* SDK/OSX/sdk_contents @@ -28,4 +28,4 @@ AndroidBuild/ AndroidDependencies/ Build/ EmscriptenDependencies -EmscriptenBuild \ No newline at end of file +EmscriptenBuild From 24bd4cea5253c8f176f40d46245f93f34c9565a6 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 7 Nov 2024 00:05:06 +0100 Subject: [PATCH 41/47] cleanup --- RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h index a9379f17c9..2ac9c4fa48 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h +++ b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h @@ -148,8 +148,6 @@ namespace Ogre /// Creates a dummy VkRenderPass for use in PSO creation VkRenderPass getVkRenderPass( HlmsPassPso passPso, uint8 &outMrtCount ); - void bindDescriptorSet() const; - void flushRootLayout(); void flushRootLayoutCS(); @@ -161,7 +159,6 @@ namespace Ogre const String &getName() const override; const String &getFriendlyName() const override; - void refreshConfig(); void initConfigOptions(); ConfigOptionMap &getConfigOptions() override; void setConfigOption( const String &name, const String &value ) override; @@ -274,14 +271,9 @@ namespace Ogre void _dispatch( const HlmsComputePso &pso ) override; void _setVertexArrayObject( const VertexArrayObject *vao ) override; - void flushDescriptorState( - VkPipelineBindPoint pipeline_bind_point, const VulkanConstBufferPacked &constBuffer, - const size_t bindOffset, const size_t bytesToWrite, - const unordered_map::type &shaderBindings ); void _render( const CbDrawCallIndexed *cmd ) override; void _render( const CbDrawCallStrip *cmd ) override; - void bindDescriptorSet( VulkanVaoManager *&vaoManager ); void _renderEmulated( const CbDrawCallIndexed *cmd ) override; void _renderEmulated( const CbDrawCallStrip *cmd ) override; From 52d0b40427527c87f46896f792ec5d9507b13abd Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 7 Nov 2024 00:38:33 +0100 Subject: [PATCH 42/47] [Vk] merge VulkanRenderSystem::mDevice and mActiveDevice --- .../Vulkan/include/OgreVulkanRenderSystem.h | 2 - .../Vulkan/src/OgreVulkanRenderSystem.cpp | 182 +++++++++--------- 2 files changed, 88 insertions(+), 96 deletions(-) diff --git a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h index 2ac9c4fa48..0f4a7d2ce9 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h +++ b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h @@ -91,8 +91,6 @@ namespace Ogre v1::VertexData *mCurrentVertexBuffer; VkPrimitiveTopology mCurrentPrimType; - VulkanDevice *mActiveDevice; - VulkanDevice *mDevice; VulkanCache *mCache; diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 605ca7d590..a8f83e3ca7 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -179,7 +179,6 @@ namespace Ogre mAutoParamsBufferIdx( 0 ), mCurrentAutoParamsBufferPtr( 0 ), mCurrentAutoParamsBufferSpaceLeft( 0 ), - mActiveDevice( 0 ), mDevice( 0 ), mCache( 0 ), mPso( 0 ), @@ -347,13 +346,13 @@ namespace Ogre if( mDummySampler ) { - vkDestroySampler( mActiveDevice->mDevice, mDummySampler, 0 ); + vkDestroySampler( mDevice->mDevice, mDummySampler, 0 ); mDummySampler = 0; } if( mDummyTextureView ) { - vkDestroyImageView( mActiveDevice->mDevice, mDummyTextureView, 0 ); + vkDestroyImageView( mDevice->mDevice, mDummyTextureView, 0 ); mDummyTextureView = 0; } @@ -487,12 +486,11 @@ namespace Ogre auto &hdr = *(PipelineCachePrefixHeader *)buf.data(); if( hdr.magic == ( 'V' | ( 'K' << 8 ) | ( 'P' << 16 ) | ( 'C' << 24 ) ) && hdr.dataSize == buf.size() - sizeof( PipelineCachePrefixHeader ) && - hdr.vendorID == mActiveDevice->mDeviceProperties.vendorID && - hdr.deviceID == mActiveDevice->mDeviceProperties.deviceID && - hdr.driverVersion == mActiveDevice->mDeviceProperties.driverVersion && + hdr.vendorID == mDevice->mDeviceProperties.vendorID && + hdr.deviceID == mDevice->mDeviceProperties.deviceID && + hdr.driverVersion == mDevice->mDeviceProperties.driverVersion && hdr.driverABI == sizeof( void * ) && - 0 == memcmp( hdr.uuid, mActiveDevice->mDeviceProperties.pipelineCacheUUID, - VK_UUID_SIZE ) ) + 0 == memcmp( hdr.uuid, mDevice->mDeviceProperties.pipelineCacheUUID, VK_UUID_SIZE ) ) { auto dataHash = hdr.dataHash; hdr.dataHash = 0; @@ -513,11 +511,11 @@ namespace Ogre pipelineCacheCreateInfo.pInitialData = buf.data() + sizeof( PipelineCachePrefixHeader ); VkPipelineCache pipelineCache{}; - result = vkCreatePipelineCache( mActiveDevice->mDevice, &pipelineCacheCreateInfo, + result = vkCreatePipelineCache( mDevice->mDevice, &pipelineCacheCreateInfo, nullptr, &pipelineCache ); if( VK_SUCCESS == result && pipelineCache != 0 ) { - std::swap( mActiveDevice->mPipelineCache, pipelineCache ); + std::swap( mDevice->mPipelineCache, pipelineCache ); LogManager::getSingleton().logMessage( "[Vulkan] Pipeline cache loaded, " + StringConverter::toString( buf.size() ) + " bytes." ); @@ -529,7 +527,7 @@ namespace Ogre vkResultToString( result ) ); } if( pipelineCache != 0 ) - vkDestroyPipelineCache( mActiveDevice->mDevice, pipelineCache, nullptr ); + vkDestroyPipelineCache( mDevice->mDevice, pipelineCache, nullptr ); } } } @@ -537,19 +535,18 @@ namespace Ogre void VulkanRenderSystem::savePipelineCache( DataStreamPtr stream ) const { OGRE_STATIC_ASSERT( sizeof( PipelineCachePrefixHeader ) == 48 ); - if( mActiveDevice->mPipelineCache ) + if( mDevice->mPipelineCache ) { size_t size{}; - VkResult result = vkGetPipelineCacheData( mActiveDevice->mDevice, - mActiveDevice->mPipelineCache, &size, nullptr ); + VkResult result = vkGetPipelineCacheData( mDevice->mDevice, mDevice->mPipelineCache, &size, + nullptr ); if( result == VK_SUCCESS && size > 0 && size <= 0x7FFFFFFF ) { std::vector buf; // PipelineCachePrefixHeader + payload do { buf.resize( sizeof( PipelineCachePrefixHeader ) + size ); - result = vkGetPipelineCacheData( mActiveDevice->mDevice, - mActiveDevice->mPipelineCache, &size, + result = vkGetPipelineCacheData( mDevice->mDevice, mDevice->mPipelineCache, &size, buf.data() + sizeof( PipelineCachePrefixHeader ) ); } while( result == VK_INCOMPLETE ); @@ -562,11 +559,11 @@ namespace Ogre hdr.magic = 'V' | ( 'K' << 8 ) | ( 'P' << 16 ) | ( 'C' << 24 ); hdr.dataSize = (uint32_t)size; hdr.dataHash = 0; - hdr.vendorID = mActiveDevice->mDeviceProperties.vendorID; - hdr.deviceID = mActiveDevice->mDeviceProperties.deviceID; - hdr.driverVersion = mActiveDevice->mDeviceProperties.driverVersion; + hdr.vendorID = mDevice->mDeviceProperties.vendorID; + hdr.deviceID = mDevice->mDeviceProperties.deviceID; + hdr.driverVersion = mDevice->mDeviceProperties.driverVersion; hdr.driverABI = sizeof( void * ); - memcpy( hdr.uuid, mActiveDevice->mDeviceProperties.pipelineCacheUUID, VK_UUID_SIZE ); + memcpy( hdr.uuid, mDevice->mDeviceProperties.pipelineCacheUUID, VK_UUID_SIZE ); OGRE_STATIC_ASSERT( VK_UUID_SIZE == 16 ); uint64 hashResult[2] = {}; @@ -650,10 +647,10 @@ namespace Ogre // We would like to save the device properties for the device capabilities limits. // These limits are needed for buffers' binding alignments. VkPhysicalDeviceProperties *vkProperties = - const_cast( &mActiveDevice->mDeviceProperties ); - vkGetPhysicalDeviceProperties( mActiveDevice->mPhysicalDevice, vkProperties ); + const_cast( &mDevice->mDeviceProperties ); + vkGetPhysicalDeviceProperties( mDevice->mPhysicalDevice, vkProperties ); - VkPhysicalDeviceProperties &properties = mActiveDevice->mDeviceProperties; + VkPhysicalDeviceProperties &properties = mDevice->mDeviceProperties; LogManager::getSingleton().logMessage( "[Vulkan] API Version: " + @@ -720,10 +717,10 @@ namespace Ogre rsc->setDriverVersion( driverVersion ); } - if( mActiveDevice->mDeviceFeatures.imageCubeArray ) + if( mDevice->mDeviceFeatures.imageCubeArray ) rsc->setCapability( RSC_TEXTURE_CUBE_MAP_ARRAY ); - if( mActiveDevice->hasDeviceExtension( VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME ) ) + if( mDevice->hasDeviceExtension( VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME ) ) rsc->setCapability( RSC_VP_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER ); rsc->setCapability( RSC_SHADER_RELAXED_FLOAT ); @@ -734,7 +731,7 @@ namespace Ogre rsc->setCapability( RSC_SHADER_FLOAT16 ); } - if( mActiveDevice->mDeviceFeatures.depthClamp ) + if( mDevice->mDeviceFeatures.depthClamp ) rsc->setCapability( RSC_DEPTH_CLAMP ); { @@ -777,7 +774,7 @@ namespace Ogre rsc->setMaxThreadsPerThreadgroupAxis( deviceLimits.maxComputeWorkGroupSize ); rsc->setMaxThreadsPerThreadgroup( deviceLimits.maxComputeWorkGroupInvocations ); - if( mActiveDevice->mDeviceFeatures.samplerAnisotropy && deviceLimits.maxSamplerAnisotropy > 1u ) + if( mDevice->mDeviceFeatures.samplerAnisotropy && deviceLimits.maxSamplerAnisotropy > 1u ) { rsc->setCapability( RSC_ANISOTROPY ); rsc->setMaxSupportedAnisotropy( deviceLimits.maxSamplerAnisotropy ); @@ -809,11 +806,11 @@ namespace Ogre rsc->setCapability( RSC_TEXTURE_COMPRESSION ); rsc->setCapability( RSC_VBO ); // VK_INDEX_TYPE_UINT32 is always supported with range at least 2^24-1 - // and even 2^32-1 if mActiveDevice->mDeviceFeatures.fullDrawIndexUint32 + // and even 2^32-1 if mDevice->mDeviceFeatures.fullDrawIndexUint32 rsc->setCapability( RSC_32BIT_INDEX ); rsc->setCapability( RSC_TWO_SIDED_STENCIL ); rsc->setCapability( RSC_STENCIL_WRAP ); - if( mActiveDevice->mDeviceFeatures.shaderClipDistance ) + if( mDevice->mDeviceFeatures.shaderClipDistance ) rsc->setCapability( RSC_USER_CLIP_PLANES ); rsc->setCapability( RSC_VERTEX_FORMAT_UBYTE4 ); rsc->setCapability( RSC_INFINITE_FAR_PLANE ); @@ -1422,7 +1419,6 @@ namespace Ogre mDevice = new VulkanDevice( mVkInstance, mVulkanSupport->getSelectedDeviceIdx(), this ); else mDevice = new VulkanDevice( mVkInstance, *externalDevice, this ); - mActiveDevice = mDevice; mNativeShadingLanguageVersion = 450; @@ -1536,8 +1532,8 @@ namespace Ogre mVaoManager = vaoManager; mHardwareBufferManager = OGRE_NEW v1::VulkanHardwareBufferManager( mDevice, mVaoManager ); - mActiveDevice->mVaoManager = vaoManager; - mActiveDevice->initQueues(); + mDevice->mVaoManager = vaoManager; + mDevice->initQueues(); vaoManager->initDrawIdVertexBuffer(); FastArray depthFormatCandidates( 5u ); @@ -1602,21 +1598,20 @@ namespace Ogre imageViewCi.subresourceRange.layerCount = 1u; VkResult result = - vkCreateImageView( mActiveDevice->mDevice, &imageViewCi, 0, &mDummyTextureView ); + vkCreateImageView( mDevice->mDevice, &imageViewCi, 0, &mDummyTextureView ); checkVkResult( result, "vkCreateImageView" ); } { VkSamplerCreateInfo samplerDescriptor; makeVkStruct( samplerDescriptor, VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO ); - float maxAllowedAnisotropy = - mActiveDevice->mDeviceProperties.limits.maxSamplerAnisotropy; + float maxAllowedAnisotropy = mDevice->mDeviceProperties.limits.maxSamplerAnisotropy; samplerDescriptor.maxAnisotropy = maxAllowedAnisotropy; samplerDescriptor.anisotropyEnable = VK_FALSE; samplerDescriptor.minLod = -std::numeric_limits::max(); samplerDescriptor.maxLod = std::numeric_limits::max(); VkResult result = - vkCreateSampler( mActiveDevice->mDevice, &samplerDescriptor, 0, &mDummySampler ); + vkCreateSampler( mDevice->mDevice, &samplerDescriptor, 0, &mDummySampler ); checkVkResult( result, "vkCreateSampler" ); } @@ -1633,7 +1628,7 @@ namespace Ogre mInitialized = true; } - win->_setDevice( mActiveDevice ); + win->_setDevice( mDevice ); win->_initialize( mTextureGpuManager, miscParams ); return win; @@ -2047,7 +2042,7 @@ namespace Ogre RenderPassDescriptor *VulkanRenderSystem::createRenderPassDescriptor() { VulkanRenderPassDescriptor *retVal = - OGRE_NEW VulkanRenderPassDescriptor( &mActiveDevice->mGraphicsQueue, this ); + OGRE_NEW VulkanRenderPassDescriptor( &mDevice->mGraphicsQueue, this ); mRenderPassDescs.insert( retVal ); return retVal; } @@ -2073,8 +2068,8 @@ namespace Ogre #endif VkPipeline vulkanPso = 0u; - VkResult result = vkCreateComputePipelines( - mActiveDevice->mDevice, mActiveDevice->mPipelineCache, 1u, &computeInfo, 0, &vulkanPso ); + VkResult result = vkCreateComputePipelines( mDevice->mDevice, mDevice->mPipelineCache, 1u, + &computeInfo, 0, &vulkanPso ); checkVkResult( result, "vkCreateComputePipelines" ); #if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM @@ -2109,7 +2104,7 @@ namespace Ogre OGRE_ASSERT_LOW( pso->rsData ); VulkanHlmsPso *vulkanPso = static_cast( pso->rsData ); - delayed_vkDestroyPipeline( mVaoManager, mActiveDevice->mDevice, vulkanPso->pso, 0 ); + delayed_vkDestroyPipeline( mVaoManager, mDevice->mDevice, vulkanPso->pso, 0 ); delete vulkanPso; pso->rsData = 0; } @@ -2146,7 +2141,7 @@ namespace Ogre { RenderSystem::_endFrameOnce(); endRenderPassDescriptor( false ); - mActiveDevice->commitAndNextCommandBuffer( SubmissionType::EndFrameAndSwap ); + mDevice->commitAndNextCommandBuffer( SubmissionType::EndFrameAndSwap ); } //------------------------------------------------------------------------- void VulkanRenderSystem::_setHlmsSamplerblock( uint8 texUnit, const HlmsSamplerblock *samplerblock ) @@ -2181,7 +2176,7 @@ namespace Ogre //------------------------------------------------------------------------- void VulkanRenderSystem::_setPipelineStateObject( const HlmsPso *pso ) { - if( pso && mActiveDevice->mGraphicsQueue.getEncoderState() != VulkanQueue::EncoderGraphicsOpen ) + if( pso && mDevice->mGraphicsQueue.getEncoderState() != VulkanQueue::EncoderGraphicsOpen ) { OGRE_ASSERT_LOW( mInterruptedRenderCommandEncoder && @@ -2196,7 +2191,7 @@ namespace Ogre if( mPso ) oldRootLayout = reinterpret_cast( mPso->rsData )->rootLayout; - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); OGRE_ASSERT_LOW( pso->rsData ); VulkanHlmsPso *vulkanPso = reinterpret_cast( pso->rsData ); vkCmdBindPipeline( cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanPso->pso ); @@ -2212,7 +2207,7 @@ namespace Ogre //------------------------------------------------------------------------- void VulkanRenderSystem::_setComputePso( const HlmsComputePso *pso ) { - mActiveDevice->mGraphicsQueue.getComputeEncoder(); + mDevice->mGraphicsQueue.getComputeEncoder(); if( mComputePso != pso ) { @@ -2226,7 +2221,7 @@ namespace Ogre { OGRE_ASSERT_LOW( pso->rsData ); vulkanPso = reinterpret_cast( pso->rsData ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdBindPipeline( cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, vulkanPso->pso ); if( vulkanPso->rootLayout != oldRootLayout ) @@ -2246,7 +2241,7 @@ namespace Ogre { flushRootLayoutCS(); - vkCmdDispatch( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), pso.mNumThreadGroups[0], + vkCmdDispatch( mDevice->mGraphicsQueue.getCurrentCmdBuffer(), pso.mNumThreadGroups[0], pso.mNumThreadGroups[1], pso.mNumThreadGroups[2] ); } //------------------------------------------------------------------------- @@ -2272,7 +2267,7 @@ namespace Ogre OGRE_ASSERT_LOW( numVertexBuffers < 15u ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); if( numVertexBuffers > 0u ) { vkCmdBindVertexBuffers( cmdBuffer, 0, static_cast( numVertexBuffers ), @@ -2318,7 +2313,7 @@ namespace Ogre { flushRootLayout(); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdDrawIndexedIndirect( cmdBuffer, mIndirectBuffer, reinterpret_cast( cmd->indirectBufferOffset ), cmd->numDraws, sizeof( CbDrawIndexed ) ); @@ -2328,7 +2323,7 @@ namespace Ogre { flushRootLayout(); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdDrawIndirect( cmdBuffer, mIndirectBuffer, reinterpret_cast( cmd->indirectBufferOffset ), cmd->numDraws, sizeof( CbDrawStrip ) ); @@ -2341,7 +2336,7 @@ namespace Ogre CbDrawIndexed *drawCmd = reinterpret_cast( mSwIndirectBufferPtr + (size_t)cmd->indirectBufferOffset ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); for( uint32 i = cmd->numDraws; i--; ) { @@ -2359,7 +2354,7 @@ namespace Ogre CbDrawStrip *drawCmd = reinterpret_cast( mSwIndirectBufferPtr + (size_t)cmd->indirectBufferOffset ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); for( uint32 i = cmd->numDraws; i--; ) { @@ -2373,7 +2368,7 @@ namespace Ogre { VulkanVaoManager *vaoManager = static_cast( mVaoManager ); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); VkBuffer vulkanVertexBuffers[16]; VkDeviceSize offsets[16]; @@ -2434,7 +2429,7 @@ namespace Ogre { flushRootLayout(); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdDrawIndexed( cmdBuffer, cmd->primCount, cmd->instanceCount, cmd->firstVertexIndex, (int32_t)mCurrentVertexBuffer->vertexStart, cmd->baseInstance ); } @@ -2443,7 +2438,7 @@ namespace Ogre { flushRootLayout(); - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); vkCmdDraw( cmdBuffer, cmd->primCount, cmd->instanceCount, cmd->firstVertexIndex, cmd->baseInstance ); } @@ -2457,7 +2452,7 @@ namespace Ogre const size_t numberOfInstances = op.numberOfInstances; - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); // Render to screen! if( op.useIndexes ) @@ -2692,7 +2687,7 @@ namespace Ogre //------------------------------------------------------------------------- void VulkanRenderSystem::flushCommands() { - mActiveDevice->commitAndNextCommandBuffer( SubmissionType::FlushOnly ); + mDevice->commitAndNextCommandBuffer( SubmissionType::FlushOnly ); } //------------------------------------------------------------------------- void VulkanRenderSystem::beginProfileEvent( const String &eventName ) {} @@ -2706,7 +2701,7 @@ namespace Ogre #if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM if( !CmdBeginDebugUtilsLabelEXT ) return; // VK_EXT_debug_utils not available - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); VkDebugUtilsLabelEXT markerInfo; makeVkStruct( markerInfo, VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT ); markerInfo.pLabelName = event.c_str(); @@ -2719,7 +2714,7 @@ namespace Ogre #if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM if( !CmdEndDebugUtilsLabelEXT ) return; // VK_EXT_debug_utils not available - VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(); + VkCommandBuffer cmdBuffer = mDevice->mGraphicsQueue.getCurrentCmdBuffer(); CmdEndDebugUtilsLabelEXT( cmdBuffer ); #endif } @@ -2735,7 +2730,7 @@ namespace Ogre void VulkanRenderSystem::endGpuDebuggerFrameCapture( Window *window, const bool bDiscard ) { if( mRenderDocApi && !bDiscard ) - mActiveDevice->commitAndNextCommandBuffer( SubmissionType::FlushOnly ); + mDevice->commitAndNextCommandBuffer( SubmissionType::FlushOnly ); RenderSystem::endGpuDebuggerFrameCapture( window, bDiscard ); } //------------------------------------------------------------------------- @@ -2781,18 +2776,18 @@ namespace Ogre void VulkanRenderSystem::initialiseFromRenderSystemCapabilities( RenderSystemCapabilities *caps, Window *primary ) { - mShaderManager = OGRE_NEW VulkanGpuProgramManager( mActiveDevice ); - mVulkanProgramFactory0 = OGRE_NEW VulkanProgramFactory( mActiveDevice, "glslvk", true ); - mVulkanProgramFactory1 = OGRE_NEW VulkanProgramFactory( mActiveDevice, "glsl", false ); - mVulkanProgramFactory2 = OGRE_NEW VulkanProgramFactory( mActiveDevice, "hlslvk", false ); - mVulkanProgramFactory3 = OGRE_NEW VulkanProgramFactory( mActiveDevice, "hlsl", false ); + mShaderManager = OGRE_NEW VulkanGpuProgramManager( mDevice ); + mVulkanProgramFactory0 = OGRE_NEW VulkanProgramFactory( mDevice, "glslvk", true ); + mVulkanProgramFactory1 = OGRE_NEW VulkanProgramFactory( mDevice, "glsl", false ); + mVulkanProgramFactory2 = OGRE_NEW VulkanProgramFactory( mDevice, "hlslvk", false ); + mVulkanProgramFactory3 = OGRE_NEW VulkanProgramFactory( mDevice, "hlsl", false ); HighLevelGpuProgramManager::getSingleton().addFactory( mVulkanProgramFactory0 ); // HighLevelGpuProgramManager::getSingleton().addFactory( mVulkanProgramFactory1 ); HighLevelGpuProgramManager::getSingleton().addFactory( mVulkanProgramFactory2 ); // HighLevelGpuProgramManager::getSingleton().addFactory( mVulkanProgramFactory3 ); - mCache = OGRE_NEW VulkanCache( mActiveDevice ); + mCache = OGRE_NEW VulkanCache( mDevice ); Log *defaultLog = LogManager::getSingleton().getDefaultLog(); if( defaultLog ) @@ -2818,7 +2813,7 @@ namespace Ogre // If we get a validation layer here; then the error was generated by the // Pass that last called beginRenderPassDescriptor (i.e. not this one) endRenderPassDescriptor( false ); - mActiveDevice->commitAndNextCommandBuffer( SubmissionType::FlushOnly ); + mDevice->commitAndNextCommandBuffer( SubmissionType::FlushOnly ); } const int oldWidth = mCurrentRenderViewport[0].getActualWidth(); @@ -2901,11 +2896,11 @@ namespace Ogre mInterruptedRenderCommandEncoder = false; const bool wasGraphicsOpen = - mActiveDevice->mGraphicsQueue.getEncoderState() != VulkanQueue::EncoderGraphicsOpen; + mDevice->mGraphicsQueue.getEncoderState() != VulkanQueue::EncoderGraphicsOpen; if( mEntriesToFlush ) { - mActiveDevice->mGraphicsQueue.endAllEncoders( false ); + mDevice->mGraphicsQueue.endAllEncoders( false ); VulkanRenderPassDescriptor *newPassDesc = static_cast( mCurrentRenderPassDescriptor ); @@ -2916,14 +2911,14 @@ namespace Ogre // This is a new command buffer / encoder. State needs to be set again if( mEntriesToFlush || !wasGraphicsOpen ) { - mActiveDevice->mGraphicsQueue.getGraphicsEncoder(); + mDevice->mGraphicsQueue.getGraphicsEncoder(); VulkanVaoManager *vaoManager = static_cast( mVaoManager ); - vaoManager->bindDrawIdVertexBuffer( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer() ); + vaoManager->bindDrawIdVertexBuffer( mDevice->mGraphicsQueue.getCurrentCmdBuffer() ); if( mStencilEnabled ) { - vkCmdSetStencilReference( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), + vkCmdSetStencilReference( mDevice->mGraphicsQueue.getCurrentCmdBuffer(), VK_STENCIL_FACE_FRONT_AND_BACK, mStencilRefValue ); } @@ -2957,7 +2952,7 @@ namespace Ogre #endif } - vkCmdSetViewport( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), 0u, numViewports, + vkCmdSetViewport( mDevice->mGraphicsQueue.getCurrentCmdBuffer(), 0u, numViewports, vkVp ); } @@ -2981,7 +2976,7 @@ namespace Ogre #endif } - vkCmdSetScissor( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), 0u, numViewports, + vkCmdSetScissor( mDevice->mGraphicsQueue.getCurrentCmdBuffer(), 0u, numViewports, scissorRect ); } @@ -3220,7 +3215,7 @@ namespace Ogre return retVal; } //------------------------------------------------------------------------- - void VulkanRenderSystem::endCopyEncoder() { mActiveDevice->mGraphicsQueue.endCopyEncoder(); } + void VulkanRenderSystem::endCopyEncoder() { mDevice->mGraphicsQueue.endCopyEncoder(); } //------------------------------------------------------------------------- void VulkanRenderSystem::executeResourceTransition( const ResourceTransitionArray &rstCollection ) { @@ -3228,7 +3223,7 @@ namespace Ogre return; // Needs to be done now, as it may change layouts of textures we're about to change - mActiveDevice->mGraphicsQueue.endAllEncoders(); + mDevice->mGraphicsQueue.endAllEncoders(); VkPipelineStageFlags srcStage = 0u; VkPipelineStageFlags dstStage = 0u; @@ -3355,9 +3350,9 @@ namespace Ogre if( dstStage == 0 ) dstStage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; - vkCmdPipelineBarrier( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), - srcStage & mActiveDevice->mSupportedStages, - dstStage & mActiveDevice->mSupportedStages, 0, numMemBarriers, &memBarrier, + vkCmdPipelineBarrier( mDevice->mGraphicsQueue.getCurrentCmdBuffer(), + srcStage & mDevice->mSupportedStages, + dstStage & mDevice->mSupportedStages, 0, numMemBarriers, &memBarrier, 0u, 0, static_cast( mImageBarriers.size() ), mImageBarriers.begin() ); mImageBarriers.clear(); @@ -3369,9 +3364,9 @@ namespace Ogre debugLogPso( newPso ); #endif - if( ( newPso->geometryShader && !mActiveDevice->mDeviceFeatures.geometryShader ) || - ( newPso->tesselationHullShader && !mActiveDevice->mDeviceFeatures.tessellationShader ) || - ( newPso->tesselationDomainShader && !mActiveDevice->mDeviceFeatures.tessellationShader ) ) + if( ( newPso->geometryShader && !mDevice->mDeviceFeatures.geometryShader ) || + ( newPso->tesselationHullShader && !mDevice->mDeviceFeatures.tessellationShader ) || + ( newPso->tesselationDomainShader && !mDevice->mDeviceFeatures.tessellationShader ) ) { OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "Geometry or tesselation shaders are not supported", @@ -3504,7 +3499,7 @@ namespace Ogre VkPipelineTessellationStateCreateInfo tessStateCi; makeVkStruct( tessStateCi, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO ); tessStateCi.patchControlPoints = 1u; - bool useTesselationState = mActiveDevice->mDeviceFeatures.tessellationShader && + bool useTesselationState = mDevice->mDeviceFeatures.tessellationShader && ( newPso->tesselationHullShader || newPso->tesselationDomainShader ); VkPipelineViewportStateCreateInfo viewportStateCi; @@ -3669,8 +3664,8 @@ namespace Ogre #endif VkPipeline vulkanPso = 0; - VkResult result = vkCreateGraphicsPipelines( - mActiveDevice->mDevice, mActiveDevice->mPipelineCache, 1u, &pipeline, 0, &vulkanPso ); + VkResult result = vkCreateGraphicsPipelines( mDevice->mDevice, mDevice->mPipelineCache, 1u, + &pipeline, 0, &vulkanPso ); checkVkResult( result, "vkCreateGraphicsPipelines" ); #if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM @@ -3711,7 +3706,7 @@ namespace Ogre OGRE_ASSERT_LOW( pso->rsData ); VulkanHlmsPso *vulkanPso = static_cast( pso->rsData ); - delayed_vkDestroyPipeline( mVaoManager, mActiveDevice->mDevice, vulkanPso->pso, 0 ); + delayed_vkDestroyPipeline( mVaoManager, mDevice->mDevice, vulkanPso->pso, 0 ); delete vulkanPso; pso->rsData = 0; } @@ -3752,12 +3747,12 @@ namespace Ogre samplerDescriptor.magFilter = VulkanMappings::get( newBlock->mMagFilter ); samplerDescriptor.mipmapMode = VulkanMappings::getMipFilter( newBlock->mMipFilter ); samplerDescriptor.mipLodBias = newBlock->mMipLodBias; - float maxAllowedAnisotropy = mActiveDevice->mDeviceProperties.limits.maxSamplerAnisotropy; + float maxAllowedAnisotropy = mDevice->mDeviceProperties.limits.maxSamplerAnisotropy; samplerDescriptor.maxAnisotropy = newBlock->mMaxAnisotropy > maxAllowedAnisotropy ? maxAllowedAnisotropy : newBlock->mMaxAnisotropy; samplerDescriptor.anisotropyEnable = - ( mActiveDevice->mDeviceFeatures.samplerAnisotropy == VK_TRUE ) && + ( mDevice->mDeviceFeatures.samplerAnisotropy == VK_TRUE ) && ( samplerDescriptor.maxAnisotropy > 1.0f ? VK_TRUE : VK_FALSE ); samplerDescriptor.addressModeU = VulkanMappings::get( newBlock->mU ); samplerDescriptor.addressModeV = VulkanMappings::get( newBlock->mV ); @@ -3773,8 +3768,7 @@ namespace Ogre } VkSampler textureSampler; - VkResult result = - vkCreateSampler( mActiveDevice->mDevice, &samplerDescriptor, 0, &textureSampler ); + VkResult result = vkCreateSampler( mDevice->mDevice, &samplerDescriptor, 0, &textureSampler ); checkVkResult( result, "vkCreateSampler" ); #if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 @@ -3793,7 +3787,7 @@ namespace Ogre VkSampler textureSampler = *static_cast( block->mRsData ); delete(uint64 *)block->mRsData; #endif - delayed_vkDestroySampler( mVaoManager, mActiveDevice->mDevice, textureSampler, 0 ); + delayed_vkDestroySampler( mVaoManager, mDevice->mDevice, textureSampler, 0 ); } //------------------------------------------------------------------------- void VulkanRenderSystem::_descriptorSetTextureCreated( DescriptorSetTexture *newSet ) @@ -3822,7 +3816,7 @@ namespace Ogre OGRE_ASSERT_LOW( set->mRsData ); VulkanDescriptorSetTexture2 *vulkanSet = static_cast( set->mRsData ); - vulkanSet->destroy( mVaoManager, mActiveDevice->mDevice, *set ); + vulkanSet->destroy( mVaoManager, mDevice->mDevice, *set ); delete vulkanSet; set->mRsData = 0; } @@ -3878,9 +3872,9 @@ namespace Ogre { mStencilRefValue = refValue; - if( mActiveDevice->mGraphicsQueue.getEncoderState() == VulkanQueue::EncoderGraphicsOpen ) + if( mDevice->mGraphicsQueue.getEncoderState() == VulkanQueue::EncoderGraphicsOpen ) { - vkCmdSetStencilReference( mActiveDevice->mGraphicsQueue.getCurrentCmdBuffer(), + vkCmdSetStencilReference( mDevice->mGraphicsQueue.getCurrentCmdBuffer(), VK_STENCIL_FACE_FRONT_AND_BACK, mStencilRefValue ); } } From 5f7eb178e7a75a337eb1bdc08eb4c79e6b2b3523 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 7 Nov 2024 02:16:31 +0100 Subject: [PATCH 43/47] [Vk] cache physical devices list in VulkanRenderSystem --- .../Vulkan/include/OgreVulkanRenderSystem.h | 2 ++ RenderSystems/Vulkan/src/OgreVulkanDevice.cpp | 17 ++-------- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 31 +++++++++++++++++++ .../Vulkan/src/OgreVulkanSupport.cpp | 23 ++------------ 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h index 0f4a7d2ce9..858f55d317 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h +++ b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h @@ -74,6 +74,7 @@ namespace Ogre VulkanProgramFactory *mVulkanProgramFactory3; VkInstance mVkInstance; + FastArray mVkPhysicalDeviceList; VulkanSupport *mVulkanSupport; std::map mAvailableVulkanSupports; @@ -199,6 +200,7 @@ namespace Ogre void sharedVkInitialization(); VkInstance getVkInstance() const { return mVkInstance; } + const FastArray &getVkPhysicalDevices( bool refreshList = false ); Window *_initialise( bool autoCreateWindow, const String &windowTitle = "OGRE Render Window" ) override; diff --git a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp index 0df0992e21..a8da83c096 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp @@ -401,15 +401,8 @@ namespace Ogre { VkResult result = VK_SUCCESS; - uint32 numDevices = 0u; - result = vkEnumeratePhysicalDevices( mInstance, &numDevices, NULL ); - checkVkResult( result, "vkEnumeratePhysicalDevices" ); - - if( numDevices == 0u ) - { - OGRE_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR, "No Vulkan devices found.", - "VulkanDevice::createPhysicalDevice" ); - } + const FastArray& devices = mRenderSystem->getVkPhysicalDevices(); + uint numDevices = devices.size(); const String numDevicesStr = StringConverter::toString( numDevices ); String deviceIdsStr = StringConverter::toString( deviceIdx ); @@ -427,11 +420,7 @@ namespace Ogre LogManager::getSingleton().logMessage( "[Vulkan] Selecting device " + deviceIdsStr ); - FastArray pd; - pd.resize( numDevices ); - result = vkEnumeratePhysicalDevices( mInstance, &numDevices, pd.begin() ); - checkVkResult( result, "vkEnumeratePhysicalDevices" ); - mPhysicalDevice = pd[deviceIdx]; + mPhysicalDevice = devices[deviceIdx]; vkGetPhysicalDeviceMemoryProperties( mPhysicalDevice, &mDeviceMemoryProperties ); diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index a8f83e3ca7..7defc4561c 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -1321,6 +1321,37 @@ namespace Ogre #endif } //------------------------------------------------------------------------- + const FastArray& VulkanRenderSystem::getVkPhysicalDevices( bool refreshList ) + { + if( refreshList || mVkPhysicalDeviceList.empty() ) + { + mVkPhysicalDeviceList.clear(); + + VkResult result = VK_SUCCESS; + do + { + uint32 numDevices = 0u; + result = vkEnumeratePhysicalDevices( mVkInstance, &numDevices, NULL ); + checkVkResult( result, "vkEnumeratePhysicalDevices" ); + + if( numDevices == 0u ) + { + OGRE_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR, "No Vulkan devices found.", + "VulkanRenderSystem::getVkPhysicalDevices" ); + } + + mVkPhysicalDeviceList.resize( numDevices ); + result = vkEnumeratePhysicalDevices( mVkInstance, &numDevices, + mVkPhysicalDeviceList.begin() ); + mVkPhysicalDeviceList.resize( numDevices ); + if( result != VK_INCOMPLETE ) + checkVkResult( result, "vkEnumeratePhysicalDevices" ); + + } while( result == VK_INCOMPLETE ); + } + return mVkPhysicalDeviceList; + } + //------------------------------------------------------------------------- Window *VulkanRenderSystem::_initialise( bool autoCreateWindow, const String &windowTitle ) { Window *autoWindow = 0; diff --git a/RenderSystems/Vulkan/src/OgreVulkanSupport.cpp b/RenderSystems/Vulkan/src/OgreVulkanSupport.cpp index 166c43c183..94072dd311 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanSupport.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanSupport.cpp @@ -38,20 +38,8 @@ namespace Ogre { mDevices.clear(); - VkInstance instance = renderSystem->getVkInstance(); - - VkResult result = VK_SUCCESS; - - uint32 numDevices = 0u; - result = vkEnumeratePhysicalDevices( instance, &numDevices, NULL ); - checkVkResult( result, "vkEnumeratePhysicalDevices" ); - - if( numDevices == 0u ) - { - OGRE_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR, "No Vulkan devices found.", - "VulkanSupport::enumerateDevices" ); - return; - } + const FastArray &devices = renderSystem->getVkPhysicalDevices(); + uint numDevices = devices.size(); char tmpBuffer[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE + 32]; LwString logStr( LwString::FromEmptyPointer( tmpBuffer, sizeof( tmpBuffer ) ) ); @@ -60,18 +48,13 @@ namespace Ogre logStr.a( "[Vulkan] Found ", numDevices, " devices" ); LogManager::getSingleton().logMessage( logStr.c_str() ); - FastArray pd; - pd.resize( numDevices ); - result = vkEnumeratePhysicalDevices( instance, &numDevices, pd.begin() ); - checkVkResult( result, "vkEnumeratePhysicalDevices" ); - LogManager::getSingleton().logMessage( "[Vulkan] Found devices:" ); mDevices.reserve( numDevices ); for( uint32 i = 0u; i < numDevices; ++i ) { VkPhysicalDeviceProperties deviceProps; - vkGetPhysicalDeviceProperties( pd[i], &deviceProps ); + vkGetPhysicalDeviceProperties( devices[i], &deviceProps ); logStr.clear(); logStr.a( deviceProps.deviceName, " #", i ); From aca39b789cbb7470a5b4aa570290c80352f338b4 Mon Sep 17 00:00:00 2001 From: "Dmytro Yunchyk(aka DimA)" Date: Thu, 7 Nov 2024 03:49:33 +0100 Subject: [PATCH 44/47] fixed HLMS shaders to support PrecisionMidf16 --- Samples/Media/Hlms/Common/Any/Cubemap_piece_all.any | 4 ++-- .../Pbs/Any/ForwardPlus_DecalsCubemaps_piece_ps.any | 2 +- .../Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any | 12 ++++++------ .../Hlms/Unlit/Any/800.PixelShader_piece_ps.any | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Samples/Media/Hlms/Common/Any/Cubemap_piece_all.any b/Samples/Media/Hlms/Common/Any/Cubemap_piece_all.any index 3cd2def5cb..c83d200d6f 100644 --- a/Samples/Media/Hlms/Common/Any/Cubemap_piece_all.any +++ b/Samples/Media/Hlms/Common/Any/Cubemap_piece_all.any @@ -61,7 +61,7 @@ INLINE midf4 localCorrect( midf3 reflDir, midf3 posLS, CubemapProbe probe ) \return Position in local space. */ -@property( syntax == metal )inline @end float3 toProbeLocalSpace( float3 pos, CubemapProbe probe ) +@property( syntax == metal )inline @end midf3 toProbeLocalSpace( float3 pos, CubemapProbe probe ) { float3 probeShapeCenterVS = float3( probe.row0_centerX.w, probe.row1_centerY.w, @@ -78,7 +78,7 @@ INLINE midf4 localCorrect( midf3 reflDir, midf3 posLS, CubemapProbe probe ) posLS = posLS * viewSpaceToProbeLocal; @end - return posLS; + return midf3_c( posLS ); } /// Returns true if position (in local space) is inside the probe. False otherwise diff --git a/Samples/Media/Hlms/Pbs/Any/ForwardPlus_DecalsCubemaps_piece_ps.any b/Samples/Media/Hlms/Pbs/Any/ForwardPlus_DecalsCubemaps_piece_ps.any index 194503bda2..92e7977d4f 100644 --- a/Samples/Media/Hlms/Pbs/Any/ForwardPlus_DecalsCubemaps_piece_ps.any +++ b/Samples/Media/Hlms/Pbs/Any/ForwardPlus_DecalsCubemaps_piece_ps.any @@ -169,7 +169,7 @@ float4 probeInnerRange = readOnlyFetch( f3dLightList, int(idx + 6u) ).xyzw; float4 probeOuterRange = readOnlyFetch( f3dLightList, int(idx + 7u) ).xyzw; - midf3 posInProbSpace = midf3_c( toProbeLocalSpace( inPs.pos, probe ) ); + midf3 posInProbSpace = toProbeLocalSpace( inPs.pos, probe ); midf probeFade = getProbeFade( posInProbSpace, probe ); if( probeFade > _h( 0 ) ) diff --git a/Samples/Media/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any b/Samples/Media/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any index 152b2bd6eb..48247f1af0 100644 --- a/Samples/Media/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any +++ b/Samples/Media/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any @@ -367,9 +367,9 @@ @property( two_sided_lighting ) @property( hlms_forwardplus_flipY ) - @piece( two_sided_flip_normal )* (gl_FrontFacing ? -1.0 : 1.0)@end + @piece( two_sided_flip_normal )* (gl_FrontFacing ? _h(-1.0) : _h(1.0))@end @else - @piece( two_sided_flip_normal )* (gl_FrontFacing ? 1.0 : -1.0)@end + @piece( two_sided_flip_normal )* (gl_FrontFacing ? _h(1.0) : _h(-1.0))@end @end @end @piece( LoadGeomNormalData ) @@ -665,7 +665,7 @@ @end @piece( CubemapManualPcc ) - midf3 posInProbSpace = midf3_c( toProbeLocalSpace( inPs.pos, @insertpiece( pccProbeSource ) ) ); + midf3 posInProbSpace = toProbeLocalSpace( inPs.pos, @insertpiece( pccProbeSource ) ); midf probeFade = getProbeFade( posInProbSpace, @insertpiece( pccProbeSource ) ); @property( vct_num_probes ) if( probeFade > _h( 0 ) && (pixelData.roughness < _h( 1.0f ) || vctSpecular.w == 0) ) @@ -751,14 +751,14 @@ @piece( ProcessAlpha ) @property( hlms_alphablend || hlms_alpha_to_coverage || hlms_alpha_hash ) @property( use_texture_alpha ) - float finalAlpha = midf_c( material.F0.w ) * pixelData.diffuse.w; + midf finalAlpha = midf_c( material.F0.w ) * midf_c( pixelData.diffuse.w ); @else - float finalAlpha = midf_c( material.F0.w ); + midf finalAlpha = midf_c( material.F0.w ); @end @property( hlms_alpha_hash ) @property( hlms_alpha_to_coverage ) - finalAlpha = AlphaHashReject( finalAlpha, inPs.uv0.xy ALPHA_HASHING_ARG ); + finalAlpha = midf_c( AlphaHashReject( finalAlpha, inPs.uv0.xy ALPHA_HASHING_ARG ) ); @else if( AlphaHashReject( finalAlpha, inPs.uv0.xy ALPHA_HASHING_ARG ) ) discard; diff --git a/Samples/Media/Hlms/Unlit/Any/800.PixelShader_piece_ps.any b/Samples/Media/Hlms/Unlit/Any/800.PixelShader_piece_ps.any index 181918bd92..cd10a8eee9 100644 --- a/Samples/Media/Hlms/Unlit/Any/800.PixelShader_piece_ps.any +++ b/Samples/Media/Hlms/Unlit/Any/800.PixelShader_piece_ps.any @@ -126,7 +126,7 @@ outPs_colour0 = diffuseCol; @property( hlms_alpha_hash && hlms_alpha_to_coverage ) - outPs_colour0.w = AlphaHashReject( diffuseCol.w, inPs.uv0.xy ALPHA_HASHING_ARG ); + outPs_colour0.w = midf_c( AlphaHashReject( diffuseCol.w, inPs.uv0.xy ALPHA_HASHING_ARG ) ); @end @end @end From 9a66c048de4346cca9b0a10fa7969a6935f92f23 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 7 Nov 2024 14:31:44 +0100 Subject: [PATCH 45/47] Fixed error MSB3491: Could not write lines to file "Tutorial_Hlms05_CustomizationPerObjArbitraryData.dir\Debug\Tutorial.6235AE06.tlog\Tutorial_Hlms05_CustomizationPerObjArbitraryData.lastbuildstate". Path: Tutorial_Hlms05_CustomizationPerObjArbitraryData.dir\Debug\Tutorial.6235AE06.tlog\Tutorial_Hlms05_CustomizationPerObjArbitraryData.lastbuildstate exceeds the OS max path limit. The fully qualified file name must be less than 260 characters. --- Samples/2.0/CMakeLists.txt | 2 +- ...ustomizationPerObjArbitraryDataGameState.h | 23 ------------------- .../CMakeLists.txt | 8 +++---- ...torial_Hlms05_CustomizationPerObjData.cpp} | 15 ++++++------ ...Tutorial_Hlms05_CustomizationPerObjData.h} | 12 ++++------ ...ms05_CustomizationPerObjDataGameState.cpp} | 10 ++++---- ..._Hlms05_CustomizationPerObjDataGameState.h | 23 +++++++++++++++++++ .../Tutorial_Hlms05_MyHlmsPbs.cpp | 0 .../Tutorial_Hlms05_MyHlmsPbs.h | 0 .../MyCustom_piece_all.any | 0 .../MyCustom_piece_ps.any | 0 .../MyCustom_piece_vs.any | 0 12 files changed, 45 insertions(+), 48 deletions(-) delete mode 100644 Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.h rename Samples/2.0/Tutorials/{Tutorial_Hlms05_CustomizationPerObjArbitraryData => Tutorial_Hlms05_CustomizationPerObjData}/CMakeLists.txt (64%) rename Samples/2.0/Tutorials/{Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryData.cpp => Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjData.cpp} (85%) rename Samples/2.0/Tutorials/{Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryData.h => Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjData.h} (91%) rename Samples/2.0/Tutorials/{Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.cpp => Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjDataGameState.cpp} (94%) create mode 100644 Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjDataGameState.h rename Samples/2.0/Tutorials/{Tutorial_Hlms05_CustomizationPerObjArbitraryData => Tutorial_Hlms05_CustomizationPerObjData}/Tutorial_Hlms05_MyHlmsPbs.cpp (100%) rename Samples/2.0/Tutorials/{Tutorial_Hlms05_CustomizationPerObjArbitraryData => Tutorial_Hlms05_CustomizationPerObjData}/Tutorial_Hlms05_MyHlmsPbs.h (100%) rename Samples/Media/2.0/scripts/materials/{Tutorial_Hlms05_CustomizationPerObjArbitraryData => Tutorial_Hlms05_CustomizationPerObjData}/MyCustom_piece_all.any (100%) rename Samples/Media/2.0/scripts/materials/{Tutorial_Hlms05_CustomizationPerObjArbitraryData => Tutorial_Hlms05_CustomizationPerObjData}/MyCustom_piece_ps.any (100%) rename Samples/Media/2.0/scripts/materials/{Tutorial_Hlms05_CustomizationPerObjArbitraryData => Tutorial_Hlms05_CustomizationPerObjData}/MyCustom_piece_vs.any (100%) diff --git a/Samples/2.0/CMakeLists.txt b/Samples/2.0/CMakeLists.txt index 7402d56f72..d5c2a4f403 100644 --- a/Samples/2.0/CMakeLists.txt +++ b/Samples/2.0/CMakeLists.txt @@ -206,7 +206,7 @@ if( OGRE_BUILD_SAMPLES2 AND NOT OGRE_BUILD_SAMPLES2_SKIP ) add_subdirectory(Tutorials/Tutorial_Hlms02_CustomizationPerObj) add_subdirectory(Tutorials/Tutorial_Hlms03_AlwaysOnTopA) add_subdirectory(Tutorials/Tutorial_Hlms04_AlwaysOnTopB) - add_subdirectory(Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData) + add_subdirectory(Tutorials/Tutorial_Hlms05_CustomizationPerObjData) if( OGRE_BUILD_COMPONENT_SCENE_FORMAT ) add_subdirectory(Tutorials/Tutorial_Memory) endif() diff --git a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.h b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.h deleted file mode 100644 index c57437d441..0000000000 --- a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.h +++ /dev/null @@ -1,23 +0,0 @@ - -#ifndef Demo_Hlms05CustomizationPerObjArbitraryDataGameState_H -#define Demo_Hlms05CustomizationPerObjArbitraryDataGameState_H - -#include "OgrePrerequisites.h" -#include "TutorialGameState.h" - -namespace Demo -{ - class Hlms05CustomizationPerObjArbitraryDataGameState : public TutorialGameState - { - std::vector mChangingItems; - - public: - Hlms05CustomizationPerObjArbitraryDataGameState( const Ogre::String &helpDescription ); - - void createScene01() override; - - void update( float timeSinceLast ) override; - }; -} // namespace Demo - -#endif diff --git a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/CMakeLists.txt b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/CMakeLists.txt similarity index 64% rename from Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/CMakeLists.txt rename to Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/CMakeLists.txt index 2f2d18aa8e..ccfaf35d22 100644 --- a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/CMakeLists.txt +++ b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/CMakeLists.txt @@ -18,8 +18,8 @@ ogre_add_component_include_dir(Hlms/Pbs) add_recursive( ./ SOURCE_FILES ) -ogre_add_executable(Tutorial_Hlms05_CustomizationPerObjArbitraryData WIN32 MACOSX_BUNDLE ${SOURCE_FILES} ${SAMPLE_COMMON_RESOURCES}) +ogre_add_executable(Tutorial_Hlms05_CustomizationPerObjData WIN32 MACOSX_BUNDLE ${SOURCE_FILES} ${SAMPLE_COMMON_RESOURCES}) -target_link_libraries(Tutorial_Hlms05_CustomizationPerObjArbitraryData ${OGRE_LIBRARIES} ${OGRE_SAMPLES_LIBRARIES}) -ogre_config_sample_lib(Tutorial_Hlms05_CustomizationPerObjArbitraryData) -ogre_config_sample_pkg(Tutorial_Hlms05_CustomizationPerObjArbitraryData) +target_link_libraries(Tutorial_Hlms05_CustomizationPerObjData ${OGRE_LIBRARIES} ${OGRE_SAMPLES_LIBRARIES}) +ogre_config_sample_lib(Tutorial_Hlms05_CustomizationPerObjData) +ogre_config_sample_pkg(Tutorial_Hlms05_CustomizationPerObjData) diff --git a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryData.cpp b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjData.cpp similarity index 85% rename from Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryData.cpp rename to Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjData.cpp index 8225efe6cb..9ca830a8f8 100644 --- a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryData.cpp +++ b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjData.cpp @@ -1,7 +1,7 @@ -#include "Tutorial_Hlms05_CustomizationPerObjArbitraryData.h" +#include "Tutorial_Hlms05_CustomizationPerObjData.h" -#include "Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.h" +#include "Tutorial_Hlms05_CustomizationPerObjDataGameState.h" // Declares WinMain / main #include "MainEntryPointHelper.h" @@ -25,9 +25,9 @@ namespace Demo GraphicsSystem **outGraphicsSystem, GameState **outLogicGameState, LogicSystem **outLogicSystem ) { - Hlms05CustomizationPerObjArbitraryDataGameState *gfxGameState = - new Hlms05CustomizationPerObjArbitraryDataGameState( - "Tutorial_Hlms02_CustomizationPerObj showed how to show send a custom colour.\n" + Hlms05CustomizationPerObjDataGameState *gfxGameState = + new Hlms05CustomizationPerObjDataGameState( + "Tutorial_Hlms05_CustomizationPerObjData showed how to show send a custom colour.\n" "However such sample forces all customized objects to share the same colour\n" "(or at most, a limited number of multiple colours).\n" "\n" @@ -53,10 +53,9 @@ namespace Demo "\n" "\n" "This sample depends on the media files:\n" - " * Samples/Media/2.0/materials/Tutorial_Hlms05_CustomizationPerObjArbitraryData\n" ); + " * Samples/Media/2.0/materials/Tutorial_Hlms05_CustomizationPerObjData\n" ); - GraphicsSystem *graphicsSystem = - new Hlms05CustomizationPerObjArbitraryDataGraphicsSystem( gfxGameState ); + GraphicsSystem *graphicsSystem = new Hlms05CustomizationPerObjDataGraphicsSystem( gfxGameState ); gfxGameState->_notifyGraphicsSystem( graphicsSystem ); diff --git a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryData.h b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjData.h similarity index 91% rename from Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryData.h rename to Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjData.h index 21d5ef63cc..b249332b20 100644 --- a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryData.h +++ b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjData.h @@ -1,6 +1,6 @@ -#ifndef Demo_Tutorial_Hlms05_CustomizationPerObjArbitraryData_H -#define Demo_Tutorial_Hlms05_CustomizationPerObjArbitraryData_H +#ifndef Demo_Tutorial_Hlms05_CustomizationPerObjData_H +#define Demo_Tutorial_Hlms05_CustomizationPerObjData_H #include "GraphicsSystem.h" @@ -20,7 +20,7 @@ namespace Demo { - class Hlms05CustomizationPerObjArbitraryDataGraphicsSystem final : public GraphicsSystem + class Hlms05CustomizationPerObjDataGraphicsSystem final : public GraphicsSystem { Ogre::CompositorWorkspace *setupCompositor() override { @@ -110,8 +110,7 @@ namespace Demo // The order in which we push to archivePbsLibraryFolders DOES matter // since script order parsing matters. Ogre::Archive *archiveLibrary = archiveManager.load( - rootHlmsFolder + - "2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjArbitraryData", + rootHlmsFolder + "2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjData", archiveType, true ); archivePbsLibraryFolders.push_back( archiveLibrary ); } @@ -137,8 +136,7 @@ namespace Demo } public: - Hlms05CustomizationPerObjArbitraryDataGraphicsSystem( GameState *gameState ) : - GraphicsSystem( gameState ) + Hlms05CustomizationPerObjDataGraphicsSystem( GameState *gameState ) : GraphicsSystem( gameState ) { } }; diff --git a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.cpp b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjDataGameState.cpp similarity index 94% rename from Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.cpp rename to Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjDataGameState.cpp index 558661835b..3777653699 100644 --- a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.cpp +++ b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjDataGameState.cpp @@ -1,7 +1,7 @@ -#include "Tutorial_Hlms05_CustomizationPerObjArbitraryDataGameState.h" +#include "Tutorial_Hlms05_CustomizationPerObjDataGameState.h" -#include "Tutorial_Hlms05_CustomizationPerObjArbitraryData.h" +#include "Tutorial_Hlms05_CustomizationPerObjData.h" #include "Tutorial_Hlms05_MyHlmsPbs.h" #include "CameraController.h" @@ -23,13 +23,13 @@ using namespace Demo; -Hlms05CustomizationPerObjArbitraryDataGameState::Hlms05CustomizationPerObjArbitraryDataGameState( +Hlms05CustomizationPerObjDataGameState::Hlms05CustomizationPerObjDataGameState( const Ogre::String &helpDescription ) : TutorialGameState( helpDescription ) { } //----------------------------------------------------------------------------- -void Hlms05CustomizationPerObjArbitraryDataGameState::createScene01() +void Hlms05CustomizationPerObjDataGameState::createScene01() { Ogre::SceneManager *sceneManager = mGraphicsSystem->getSceneManager(); @@ -153,7 +153,7 @@ void Hlms05CustomizationPerObjArbitraryDataGameState::createScene01() TutorialGameState::createScene01(); } //----------------------------------------------------------------------------- -void Hlms05CustomizationPerObjArbitraryDataGameState::update( float timeSinceLast ) +void Hlms05CustomizationPerObjDataGameState::update( float timeSinceLast ) { for( Ogre::Item *item : mChangingItems ) { diff --git a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjDataGameState.h b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjDataGameState.h new file mode 100644 index 0000000000..77a219eb8e --- /dev/null +++ b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_CustomizationPerObjDataGameState.h @@ -0,0 +1,23 @@ + +#ifndef Demo_Hlms05CustomizationPerObjDataGameState_H +#define Demo_Hlms05CustomizationPerObjDataGameState_H + +#include "OgrePrerequisites.h" +#include "TutorialGameState.h" + +namespace Demo +{ + class Hlms05CustomizationPerObjDataGameState : public TutorialGameState + { + std::vector mChangingItems; + + public: + Hlms05CustomizationPerObjDataGameState( const Ogre::String &helpDescription ); + + void createScene01() override; + + void update( float timeSinceLast ) override; + }; +} // namespace Demo + +#endif diff --git a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_MyHlmsPbs.cpp b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_MyHlmsPbs.cpp similarity index 100% rename from Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_MyHlmsPbs.cpp rename to Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_MyHlmsPbs.cpp diff --git a/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_MyHlmsPbs.h b/Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_MyHlmsPbs.h similarity index 100% rename from Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/Tutorial_Hlms05_MyHlmsPbs.h rename to Samples/2.0/Tutorials/Tutorial_Hlms05_CustomizationPerObjData/Tutorial_Hlms05_MyHlmsPbs.h diff --git a/Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/MyCustom_piece_all.any b/Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjData/MyCustom_piece_all.any similarity index 100% rename from Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/MyCustom_piece_all.any rename to Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjData/MyCustom_piece_all.any diff --git a/Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/MyCustom_piece_ps.any b/Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjData/MyCustom_piece_ps.any similarity index 100% rename from Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/MyCustom_piece_ps.any rename to Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjData/MyCustom_piece_ps.any diff --git a/Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/MyCustom_piece_vs.any b/Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjData/MyCustom_piece_vs.any similarity index 100% rename from Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjArbitraryData/MyCustom_piece_vs.any rename to Samples/Media/2.0/scripts/materials/Tutorial_Hlms05_CustomizationPerObjData/MyCustom_piece_vs.any From 87326b469d05db6962890993007d3bfddcb2792d Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 7 Nov 2024 18:03:32 +0100 Subject: [PATCH 46/47] [Vk] Identify physical devices by name rather than by index. Assign unique names that are robust to devices addition/removing by adding suffixes only if necessary. --- .../Vulkan/include/OgreVulkanDevice.h | 4 +- .../Vulkan/include/OgreVulkanRenderSystem.h | 11 +++- .../Vulkan/include/OgreVulkanSupport.h | 6 +- RenderSystems/Vulkan/src/OgreVulkanDevice.cpp | 37 ++++------- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 40 +++++++++--- .../Vulkan/src/OgreVulkanSupport.cpp | 64 +++---------------- 6 files changed, 66 insertions(+), 96 deletions(-) diff --git a/RenderSystems/Vulkan/include/OgreVulkanDevice.h b/RenderSystems/Vulkan/include/OgreVulkanDevice.h index f1eeab966e..2e2eab4ddd 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanDevice.h +++ b/RenderSystems/Vulkan/include/OgreVulkanDevice.h @@ -135,7 +135,7 @@ namespace Ogre FastArray &outQueueCiArray ); public: - VulkanDevice( VkInstance instance, uint32 deviceIdx, VulkanRenderSystem *renderSystem ); + VulkanDevice( VkInstance instance, const String &deviceName, VulkanRenderSystem *renderSystem ); VulkanDevice( VkInstance instance, const VulkanExternalDevice &externalDevice, VulkanRenderSystem *renderSystem ); ~VulkanDevice(); @@ -153,7 +153,7 @@ namespace Ogre static void addExternalInstanceExtensions( FastArray &extensions ); protected: - void createPhysicalDevice( uint32 deviceIdx ); + void createPhysicalDevice( const String &deviceName ); public: void createDevice( FastArray &extensions, uint32 maxComputeQueues, diff --git a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h index 858f55d317..fa6a09b6b7 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h +++ b/RenderSystems/Vulkan/include/OgreVulkanRenderSystem.h @@ -51,6 +51,13 @@ namespace Ogre struct VulkanHlmsPso; class VulkanSupport; + struct VulkanPhysicalDevice + { + VkPhysicalDevice physicalDevice; + String title; + }; + typedef std::vector VulkanPhysicalDeviceList; + /** Implementation of Vulkan as a rendering system. */ @@ -74,7 +81,7 @@ namespace Ogre VulkanProgramFactory *mVulkanProgramFactory3; VkInstance mVkInstance; - FastArray mVkPhysicalDeviceList; + VulkanPhysicalDeviceList mVulkanPhysicalDeviceList; VulkanSupport *mVulkanSupport; std::map mAvailableVulkanSupports; @@ -200,7 +207,7 @@ namespace Ogre void sharedVkInitialization(); VkInstance getVkInstance() const { return mVkInstance; } - const FastArray &getVkPhysicalDevices( bool refreshList = false ); + const VulkanPhysicalDeviceList &getVulkanPhysicalDevices( bool refreshList = false ); Window *_initialise( bool autoCreateWindow, const String &windowTitle = "OGRE Render Window" ) override; diff --git a/RenderSystems/Vulkan/include/OgreVulkanSupport.h b/RenderSystems/Vulkan/include/OgreVulkanSupport.h index e43d88ff6d..8e9b4bbfef 100644 --- a/RenderSystems/Vulkan/include/OgreVulkanSupport.h +++ b/RenderSystems/Vulkan/include/OgreVulkanSupport.h @@ -41,12 +41,8 @@ namespace Ogre class _OgreVulkanExport VulkanSupport { - FastArray mDevices; - bool mSupported; - void enumerateDevices( VulkanRenderSystem *renderSystem ); - void initialize( VulkanRenderSystem *renderSystem ); public: @@ -66,7 +62,7 @@ namespace Ogre virtual String validateConfigOptions(); - uint32 getSelectedDeviceIdx() const; + String getSelectedDeviceName() const; ConfigOptionMap &getConfigOptions( VulkanRenderSystem *renderSystem ); diff --git a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp index a8da83c096..939ef019b2 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp @@ -49,7 +49,7 @@ namespace Ogre { static FastArray msInstanceExtensions; - VulkanDevice::VulkanDevice( VkInstance instance, uint32 deviceIdx, + VulkanDevice::VulkanDevice( VkInstance instance, const String &deviceName, VulkanRenderSystem *renderSystem ) : mInstance( instance ), mPhysicalDevice( 0 ), @@ -62,7 +62,7 @@ namespace Ogre mIsExternal( false ) { memset( &mDeviceMemoryProperties, 0, sizeof( mDeviceMemoryProperties ) ); - createPhysicalDevice( deviceIdx ); + createPhysicalDevice( deviceName ); } //------------------------------------------------------------------------- VulkanDevice::VulkanDevice( VkInstance instance, const VulkanExternalDevice &externalDevice, @@ -397,30 +397,21 @@ namespace Ogre std::sort( msInstanceExtensions.begin(), msInstanceExtensions.end() ); } //------------------------------------------------------------------------- - void VulkanDevice::createPhysicalDevice( uint32 deviceIdx ) + void VulkanDevice::createPhysicalDevice( const String &deviceName ) { - VkResult result = VK_SUCCESS; - - const FastArray& devices = mRenderSystem->getVkPhysicalDevices(); - uint numDevices = devices.size(); - - const String numDevicesStr = StringConverter::toString( numDevices ); - String deviceIdsStr = StringConverter::toString( deviceIdx ); - - LogManager::getSingleton().logMessage( "[Vulkan] Found " + numDevicesStr + " devices" ); - - if( deviceIdx >= numDevices ) - { - LogManager::getSingleton().logMessage( "[Vulkan] Requested device index " + deviceIdsStr + - " but there's only " + - StringConverter::toString( numDevices ) + "devices" ); - deviceIdx = 0u; - deviceIdsStr = "0"; - } + const auto& devices = mRenderSystem->getVulkanPhysicalDevices(); + size_t deviceIdx = 0; + for( size_t i = 0; i < devices.size(); ++i ) + if( devices[i].title == deviceName ) + { + deviceIdx = i; + break; + } - LogManager::getSingleton().logMessage( "[Vulkan] Selecting device " + deviceIdsStr ); + LogManager::getSingleton().logMessage( "[Vulkan] Requested \"" + deviceName + "\", selected \"" + + devices[deviceIdx].title + "\"" ); - mPhysicalDevice = devices[deviceIdx]; + mPhysicalDevice = devices[deviceIdx].physicalDevice; vkGetPhysicalDeviceMemoryProperties( mPhysicalDevice, &mDeviceMemoryProperties ); diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 7defc4561c..79b4a47b4f 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -1321,12 +1321,15 @@ namespace Ogre #endif } //------------------------------------------------------------------------- - const FastArray& VulkanRenderSystem::getVkPhysicalDevices( bool refreshList ) + const VulkanPhysicalDeviceList &VulkanRenderSystem::getVulkanPhysicalDevices( bool refreshList ) { - if( refreshList || mVkPhysicalDeviceList.empty() ) + + if( refreshList || mVulkanPhysicalDeviceList.empty() ) { - mVkPhysicalDeviceList.clear(); + LogManager::getSingleton().logMessage( "[Vulkan] Device detection starts" ); + // enumerate + std::vector devices; VkResult result = VK_SUCCESS; do { @@ -1340,16 +1343,35 @@ namespace Ogre "VulkanRenderSystem::getVkPhysicalDevices" ); } - mVkPhysicalDeviceList.resize( numDevices ); - result = vkEnumeratePhysicalDevices( mVkInstance, &numDevices, - mVkPhysicalDeviceList.begin() ); - mVkPhysicalDeviceList.resize( numDevices ); + devices.resize( numDevices ); + result = vkEnumeratePhysicalDevices( mVkInstance, &numDevices, devices.data() ); + devices.resize( numDevices ); if( result != VK_INCOMPLETE ) checkVkResult( result, "vkEnumeratePhysicalDevices" ); } while( result == VK_INCOMPLETE ); + + // assign unique names, allowing reordering/inserting/removing + map::type sameNameCounter; + mVulkanPhysicalDeviceList.clear(); + mVulkanPhysicalDeviceList.reserve(devices.size()); + for (auto device : devices) + { + VkPhysicalDeviceProperties deviceProps; + vkGetPhysicalDeviceProperties( device, &deviceProps ); + + String name( deviceProps.deviceName ); + unsigned sameNameIndex = sameNameCounter[name]++; // inserted entry is zero-initialized + if( sameNameIndex != 0 ) + name += " (" + Ogre::StringConverter::toString( sameNameIndex + 1 ) + ")"; + + LogManager::getSingleton().logMessage( "[Vulkan] \"" + name + "\"" ); + mVulkanPhysicalDeviceList.push_back( { device, name } ); + } + + LogManager::getSingleton().logMessage( "[Vulkan] Device detection ends" ); } - return mVkPhysicalDeviceList; + return mVulkanPhysicalDeviceList; } //------------------------------------------------------------------------- Window *VulkanRenderSystem::_initialise( bool autoCreateWindow, const String &windowTitle ) @@ -1447,7 +1469,7 @@ namespace Ogre initializeVkInstance(); if( !externalDevice ) - mDevice = new VulkanDevice( mVkInstance, mVulkanSupport->getSelectedDeviceIdx(), this ); + mDevice = new VulkanDevice( mVkInstance, mVulkanSupport->getSelectedDeviceName(), this ); else mDevice = new VulkanDevice( mVkInstance, *externalDevice, this ); diff --git a/RenderSystems/Vulkan/src/OgreVulkanSupport.cpp b/RenderSystems/Vulkan/src/OgreVulkanSupport.cpp index 94072dd311..461ad0d657 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanSupport.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanSupport.cpp @@ -34,43 +34,10 @@ Copyright (c) 2000-present Torus Knot Software Ltd namespace Ogre { - void VulkanSupport::enumerateDevices( VulkanRenderSystem *renderSystem ) - { - mDevices.clear(); - - const FastArray &devices = renderSystem->getVkPhysicalDevices(); - uint numDevices = devices.size(); - - char tmpBuffer[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE + 32]; - LwString logStr( LwString::FromEmptyPointer( tmpBuffer, sizeof( tmpBuffer ) ) ); - - logStr.clear(); - logStr.a( "[Vulkan] Found ", numDevices, " devices" ); - LogManager::getSingleton().logMessage( logStr.c_str() ); - - LogManager::getSingleton().logMessage( "[Vulkan] Found devices:" ); - - mDevices.reserve( numDevices ); - for( uint32 i = 0u; i < numDevices; ++i ) - { - VkPhysicalDeviceProperties deviceProps; - vkGetPhysicalDeviceProperties( devices[i], &deviceProps ); - - logStr.clear(); - logStr.a( deviceProps.deviceName, " #", i ); - mDevices.push_back( logStr.c_str() ); - - LogManager::getSingleton().logMessage( logStr.c_str() ); - } - } - //------------------------------------------------------------------------- void VulkanSupport::initialize( VulkanRenderSystem *renderSystem ) { if( !renderSystem->getVkInstance() ) renderSystem->initializeVkInstance(); - - if( mDevices.empty() ) - enumerateDevices( renderSystem ); } //------------------------------------------------------------------------- void VulkanSupport::setSupported() { mSupported = true; } @@ -85,16 +52,11 @@ namespace Ogre ConfigOption optSRGB; optDevices.name = "Device"; - - FastArray::const_iterator itor = mDevices.begin(); - FastArray::const_iterator endt = mDevices.end(); - optDevices.possibleValues.push_back( "(default)" ); - - while( itor != endt ) - optDevices.possibleValues.push_back( *itor++ ); - - optDevices.currentValue = mDevices.front(); + const auto &devices = renderSystem->getVulkanPhysicalDevices(); + for( auto &device : devices ) + optDevices.possibleValues.push_back( device.title ); + optDevices.currentValue = optDevices.possibleValues.front(); optDevices.immutable = false; optInterfaces.name = "Interface"; @@ -169,8 +131,8 @@ namespace Ogre if( it != mOptions.end() ) { const String deviceName = it->second.currentValue; - if( deviceName != "(default)" && - std::find( mDevices.begin(), mDevices.end(), deviceName ) == mDevices.end() ) + if( std::find( it->second.possibleValues.begin(), it->second.possibleValues.end(), + deviceName ) == it->second.possibleValues.end() ) { setConfigOption( "Device", "(default)" ); return "Requested rendering device could not be found, default will be used instead."; @@ -180,21 +142,13 @@ namespace Ogre return BLANKSTRING; } //------------------------------------------------------------------------- - uint32 VulkanSupport::getSelectedDeviceIdx() const + String VulkanSupport::getSelectedDeviceName() const { - uint32 deviceIdx = 0u; - ConfigOptionMap::const_iterator it = mOptions.find( "Device" ); if( it != mOptions.end() ) - { - const String deviceName = it->second.currentValue; - FastArray::const_iterator itDevice = - std::find( mDevices.begin(), mDevices.end(), deviceName ); - if( itDevice != mDevices.end() ) - deviceIdx = uint32( itDevice - mDevices.begin() ); - } + return it->second.currentValue; - return deviceIdx; + return "(default)"; } //------------------------------------------------------------------------- ConfigOptionMap &VulkanSupport::getConfigOptions( VulkanRenderSystem *renderSystem ) From b26240003729f2e82cf4191086945dd2e0108848 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Thu, 7 Nov 2024 18:48:58 +0100 Subject: [PATCH 47/47] [Vk] use logMessage("Vulkan: some message" pattern, as column of spaces after "Vulkan: " helps to visually skip or focus on messages from VK RS, rather than on generic Ogre messages. Also, for consistency with D3D11 RS. --- RenderSystems/Vulkan/src/OgreVulkanDevice.cpp | 21 ++++---- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 49 ++++++++++--------- .../Vulkan/src/Vao/OgreVulkanVaoManager.cpp | 20 ++++---- 3 files changed, 48 insertions(+), 42 deletions(-) diff --git a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp index 939ef019b2..03d002452c 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanDevice.cpp @@ -77,7 +77,8 @@ namespace Ogre mSupportedStages( 0xFFFFFFFF ), mIsExternal( true ) { - LogManager::getSingleton().logMessage( "Creating Vulkan Device from External VkVulkan handle" ); + LogManager::getSingleton().logMessage( + "Vulkan: Creating Vulkan Device from External VkVulkan handle" ); memset( &mDeviceMemoryProperties, 0, sizeof( mDeviceMemoryProperties ) ); @@ -123,7 +124,8 @@ namespace Ogre for( size_t i = 0u; i < numExtensions; ++i ) { const String extensionName = availableExtensions[i].extensionName; - LogManager::getSingleton().logMessage( "Found device extension: " + extensionName ); + LogManager::getSingleton().logMessage( "Vulkan: Found device extension: " + + extensionName ); extensions.insert( extensionName ); } @@ -136,7 +138,7 @@ namespace Ogre if( extensions.find( itor->extensionName ) == extensions.end() ) { LogManager::getSingleton().logMessage( - "[Vulkan][INFO] External Device claims extension " + + "Vulkan: [INFO] External Device claims extension " + String( itor->extensionName ) + " is present but it's not. This is normal. Ignoring." ); itor = efficientVectorRemove( deviceExtensionsCopy, itor ); @@ -152,8 +154,8 @@ namespace Ogre itor = deviceExtensionsCopy.begin(); while( itor != endt ) { - LogManager::getSingleton().logMessage( "Externally requested Device Extension: " + - String( itor->extensionName ) ); + LogManager::getSingleton().logMessage( + "Vulkan: Externally requested Device Extension: " + String( itor->extensionName ) ); mDeviceExtensions.push_back( itor->extensionName ); ++itor; } @@ -362,7 +364,7 @@ namespace Ogre while( itor != endt ) { - LogManager::getSingleton().logMessage( "Requesting Instance Extension: " + + LogManager::getSingleton().logMessage( "Vulkan: Requesting Instance Extension: " + String( *itor ) ); msInstanceExtensions.push_back( *itor ); ++itor; @@ -388,7 +390,7 @@ namespace Ogre while( itor != endt ) { - LogManager::getSingleton().logMessage( "Externally requested Instance Extension: " + + LogManager::getSingleton().logMessage( "Vulkan: Externally requested Instance Extension: " + String( itor->extensionName ) ); msInstanceExtensions.push_back( itor->extensionName ); ++itor; @@ -408,7 +410,7 @@ namespace Ogre break; } - LogManager::getSingleton().logMessage( "[Vulkan] Requested \"" + deviceName + "\", selected \"" + + LogManager::getSingleton().logMessage( "Vulkan: Requested \"" + deviceName + "\", selected \"" + devices[deviceIdx].title + "\"" ); mPhysicalDevice = devices[deviceIdx].physicalDevice; @@ -557,7 +559,8 @@ namespace Ogre while( itor != endt ) { - LogManager::getSingleton().logMessage( "Requesting Extension: " + String( *itor ) ); + LogManager::getSingleton().logMessage( "Vulkan: Requesting Extension: " + + String( *itor ) ); mDeviceExtensions.push_back( *itor ); ++itor; } diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 79b4a47b4f..355f961608 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -501,7 +501,7 @@ namespace Ogre } if( result != VK_SUCCESS ) - LogManager::getSingleton().logMessage( "[Vulkan] Pipeline cache outdated, not loaded." ); + LogManager::getSingleton().logMessage( "Vulkan: Pipeline cache outdated, not loaded." ); else { VkPipelineCacheCreateInfo pipelineCacheCreateInfo; @@ -516,14 +516,14 @@ namespace Ogre if( VK_SUCCESS == result && pipelineCache != 0 ) { std::swap( mDevice->mPipelineCache, pipelineCache ); - LogManager::getSingleton().logMessage( "[Vulkan] Pipeline cache loaded, " + + LogManager::getSingleton().logMessage( "Vulkan: Pipeline cache loaded, " + StringConverter::toString( buf.size() ) + " bytes." ); } else { LogManager::getSingleton().logMessage( - "[Vulkan] Pipeline cache loading failed. VkResult = " + + "Vulkan: Pipeline cache loading failed. VkResult = " + vkResultToString( result ) ); } if( pipelineCache != 0 ) @@ -571,13 +571,13 @@ namespace Ogre hdr.dataHash = hashResult[0]; stream->write( buf.data(), buf.size() ); - LogManager::getSingleton().logMessage( "[Vulkan] Pipeline cache saved, " + + LogManager::getSingleton().logMessage( "Vulkan: Pipeline cache saved, " + StringConverter::toString( buf.size() ) + " bytes." ); } } if( result != VK_SUCCESS ) - LogManager::getSingleton().logMessage( "[Vulkan] Pipeline cache not saved. VkResult = " + + LogManager::getSingleton().logMessage( "Vulkan: Pipeline cache not saved. VkResult = " + vkResultToString( result ) ); } } @@ -598,14 +598,14 @@ namespace Ogre if( !CreateDebugReportCallback ) { LogManager::getSingleton().logMessage( - "[Vulkan] GetProcAddr: Unable to find vkCreateDebugReportCallbackEXT. " + "Vulkan: GetProcAddr: Unable to find vkCreateDebugReportCallbackEXT. " "Debug reporting won't be available" ); return; } if( !DestroyDebugReportCallback ) { LogManager::getSingleton().logMessage( - "[Vulkan] GetProcAddr: Unable to find vkDestroyDebugReportCallbackEXT. " + "Vulkan: GetProcAddr: Unable to find vkDestroyDebugReportCallbackEXT. " "Debug reporting won't be available" ); return; } @@ -653,19 +653,19 @@ namespace Ogre VkPhysicalDeviceProperties &properties = mDevice->mDeviceProperties; LogManager::getSingleton().logMessage( - "[Vulkan] API Version: " + + "Vulkan: API Version: " + StringConverter::toString( VK_VERSION_MAJOR( properties.apiVersion ) ) + "." + StringConverter::toString( VK_VERSION_MINOR( properties.apiVersion ) ) + "." + StringConverter::toString( VK_VERSION_PATCH( properties.apiVersion ) ) + " (" + StringConverter::toString( properties.apiVersion, 0, ' ', std::ios::hex ) + ")" ); LogManager::getSingleton().logMessage( - "[Vulkan] Driver Version (raw): " + + "Vulkan: Driver Version (raw): " + StringConverter::toString( properties.driverVersion, 0, ' ', std::ios::hex ) ); LogManager::getSingleton().logMessage( - "[Vulkan] Vendor ID: " + + "Vulkan: Vendor ID: " + StringConverter::toString( properties.vendorID, 0, ' ', std::ios::hex ) ); LogManager::getSingleton().logMessage( - "[Vulkan] Device ID: " + + "Vulkan: Device ID: " + StringConverter::toString( properties.deviceID, 0, ' ', std::ios::hex ) ); rsc->setDeviceName( properties.deviceName ); @@ -1030,7 +1030,7 @@ namespace Ogre //------------------------------------------------------------------------- void VulkanRenderSystem::initializeExternalVkInstance( VulkanExternalInstance *externalInstance ) { - LogManager::getSingleton().logMessage( "[Vulkan] VkInstance is provided externally" ); + LogManager::getSingleton().logMessage( "Vulkan: VkInstance is provided externally" ); OGRE_ASSERT_LOW( !mVkInstance ); @@ -1053,7 +1053,8 @@ namespace Ogre for( size_t i = 0u; i < numExtensions; ++i ) { const String extensionName = availableExtensions[i].extensionName; - LogManager::getSingleton().logMessage( "Found instance extension: " + extensionName ); + LogManager::getSingleton().logMessage( "Vulkan: Found instance extension: " + + extensionName ); extensions.insert( extensionName ); } @@ -1066,7 +1067,7 @@ namespace Ogre if( extensions.find( itor->extensionName ) == extensions.end() ) { LogManager::getSingleton().logMessage( - "[Vulkan][INFO] External Instance claims extension " + + "Vulkan: [INFO] External Instance claims extension " + String( itor->extensionName ) + " is present but it's not. This is normal. Ignoring." ); itor = efficientVectorRemove( externalInstance->instanceExtensions, itor ); @@ -1111,7 +1112,7 @@ namespace Ogre for( size_t i = 0u; i < numInstanceLayers; ++i ) { const String layerName = instanceLayerProps[i].layerName; - LogManager::getSingleton().logMessage( "Found instance layer: " + layerName ); + LogManager::getSingleton().logMessage( "Vulkan: Found instance layer: " + layerName ); layers.insert( layerName ); } @@ -1123,7 +1124,7 @@ namespace Ogre if( layers.find( itor->layerName ) == layers.end() ) { LogManager::getSingleton().logMessage( - "[Vulkan][INFO] External Instance claims layer " + String( itor->layerName ) + + "Vulkan: [INFO] External Instance claims layer " + String( itor->layerName ) + " is present but it's not. This is normal. Ignoring." ); itor = efficientVectorRemove( externalInstance->instanceLayers, itor ); endt = externalInstance->instanceLayers.end(); @@ -1148,7 +1149,7 @@ namespace Ogre if( mVkInstance ) return; - LogManager::getSingleton().logMessage( "[Vulkan] Initializing VkInstance" ); + LogManager::getSingleton().logMessage( "Vulkan: Initializing VkInstance" ); #ifdef OGRE_VULKAN_WINDOW_NULL mAvailableVulkanSupports["null"]->setSupported(); @@ -1169,7 +1170,8 @@ namespace Ogre for( size_t i = 0u; i < numExtensions; ++i ) { const String extensionName = availableExtensions[i].extensionName; - LogManager::getSingleton().logMessage( "Found instance extension: " + extensionName ); + LogManager::getSingleton().logMessage( "Vulkan: Found instance extension: " + + extensionName ); #ifdef OGRE_VULKAN_WINDOW_WIN32 if( extensionName == VulkanWin32Window::getRequiredExtensionName() ) @@ -1251,7 +1253,7 @@ namespace Ogre for( size_t i = 0u; i < numInstanceLayers; ++i ) { const String layerName = instanceLayerProps[i].layerName; - LogManager::getSingleton().logMessage( "Found instance layer: " + layerName ); + LogManager::getSingleton().logMessage( "Vulkan: Found instance layer: " + layerName ); #if OGRE_DEBUG_MODE >= OGRE_DEBUG_HIGH if( layerName == "VK_LAYER_KHRONOS_validation" ) { @@ -1326,7 +1328,7 @@ namespace Ogre if( refreshList || mVulkanPhysicalDeviceList.empty() ) { - LogManager::getSingleton().logMessage( "[Vulkan] Device detection starts" ); + LogManager::getSingleton().logMessage( "Vulkan: Device detection starts" ); // enumerate std::vector devices; @@ -1365,11 +1367,11 @@ namespace Ogre if( sameNameIndex != 0 ) name += " (" + Ogre::StringConverter::toString( sameNameIndex + 1 ) + ")"; - LogManager::getSingleton().logMessage( "[Vulkan] \"" + name + "\"" ); + LogManager::getSingleton().logMessage( "Vulkan: \"" + name + "\"" ); mVulkanPhysicalDeviceList.push_back( { device, name } ); } - LogManager::getSingleton().logMessage( "[Vulkan] Device detection ends" ); + LogManager::getSingleton().logMessage( "Vulkan: Device detection ends" ); } return mVulkanPhysicalDeviceList; } @@ -1499,7 +1501,8 @@ namespace Ogre for( size_t i = 0u; i < numExtensions; ++i ) { const String extensionName = availableExtensions[i].extensionName; - LogManager::getSingleton().logMessage( "Found device extension: " + extensionName ); + LogManager::getSingleton().logMessage( "Vulkan: Found device extension: " + + extensionName ); if( extensionName == VK_KHR_MAINTENANCE2_EXTENSION_NAME ) { diff --git a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp index d2c372f81e..8a1e81e03f 100644 --- a/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp +++ b/RenderSystems/Vulkan/src/Vao/OgreVulkanVaoManager.cpp @@ -497,7 +497,7 @@ namespace Ogre char tmpBuffer[256]; LwString text( LwString::FromEmptyPointer( tmpBuffer, sizeof( tmpBuffer ) ) ); - text.a( "[Vulkan] Flushing all mDelayedBlocks(", bytesToMegabytes( mDelayedBlocksSize ), + text.a( "Vulkan: Flushing all mDelayedBlocks(", bytesToMegabytes( mDelayedBlocksSize ), " MB) because mDelayedBlocksFlushThreshold(", bytesToMegabytes( mDelayedBlocksFlushThreshold ), " MB) was exceeded. This prevents async operations (e.g. async compute)", @@ -774,9 +774,9 @@ namespace Ogre VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT ); LogManager &logManager = LogManager::getSingleton(); - logManager.logMessage( "Supported memory types for general buffer usage: " + + logManager.logMessage( "Vulkan: Supported memory types for general buffer usage: " + StringConverter::toString( supportedMemoryTypesBuffer ) ); - logManager.logMessage( "Supported memory types for reading: " + + logManager.logMessage( "Vulkan: Supported memory types for reading: " + StringConverter::toString( supportedMemoryTypesRead ) ); const VkPhysicalDeviceMemoryProperties &memProperties = mDevice->mDeviceMemoryProperties; @@ -822,7 +822,7 @@ namespace Ogre { // This is BS. No heap is device-local. Sigh, just pick any and try to get the best score logManager.logMessage( - "VkDevice: No heap found with DEVICE_LOCAL bit set. This should be impossible", + "Vulkan: No heap found with DEVICE_LOCAL bit set. This should be impossible", LML_CRITICAL ); for( uint32 i = 0u; i < numMemoryTypes; ++i ) addMemoryType( CPU_INACCESSIBLE, memProperties, i ); @@ -868,17 +868,17 @@ namespace Ogre } } - logManager.logMessage( "VkDevice will use coherent memory buffers: " + + logManager.logMessage( "Vulkan: VkDevice will use coherent memory buffers: " + StringConverter::toString( mSupportsCoherentMemory ) ); - logManager.logMessage( "VkDevice will use non-coherent memory buffers: " + + logManager.logMessage( "Vulkan: VkDevice will use non-coherent memory buffers: " + StringConverter::toString( mSupportsNonCoherentMemory ) ); - logManager.logMessage( "VkDevice will prefer coherent memory buffers: " + + logManager.logMessage( "Vulkan: VkDevice will prefer coherent memory buffers: " + StringConverter::toString( mPreferCoherentMemory ) ); if( mBestVkMemoryTypeIndex[CPU_READ_WRITE].empty() ) { logManager.logMessage( - "VkDevice: could not find cached host-visible memory. GPU -> CPU transfers could be " + "Vulkan: could not find cached host-visible memory. GPU -> CPU transfers could be " "slow", LML_CRITICAL ); @@ -909,7 +909,7 @@ namespace Ogre if( mDevice->mDeviceProperties.limits.bufferImageGranularity != 1u ) mBestVkMemoryTypeIndex[TEXTURES_OPTIMAL] = mBestVkMemoryTypeIndex[CPU_INACCESSIBLE]; - logManager.logMessage( "VkDevice will use coherent memory for reading: " + + logManager.logMessage( "Vulkan: VkDevice will use coherent memory for reading: " + StringConverter::toString( mReadMemoryIsCoherent ) ); // Fill mMemoryTypesInUse @@ -927,7 +927,7 @@ namespace Ogre } } - logManager.logMessage( "VkDevice read memory is coherent: " + + logManager.logMessage( "Vulkan: VkDevice read memory is coherent: " + StringConverter::toString( mReadMemoryIsCoherent ) ); } //-----------------------------------------------------------------------------------