diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-12-24 07:20:10 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-12-24 07:20:10 +0000 |
| commit | 72169d31c7f8a8e1f0a011e45b19ea7710eef985 (patch) | |
| tree | 935085a90a27216001289ddfcea2f999ce6b90cc | |
| parent | Fixed CMake warning when processing SPIRV-Tools-shared on Mac (diff) | |
| download | DiligentCore-72169d31c7f8a8e1f0a011e45b19ea7710eef985.tar.gz DiligentCore-72169d31c7f8a8e1f0a011e45b19ea7710eef985.zip | |
Fixed multiple unused variable warnings in clang release build
27 files changed, 684 insertions, 640 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e4fbf3cb..3071951a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,7 +132,7 @@ if(MSVC) # - disable w4189 - local variable is initialized but not referenced # - Enable AVX2 instruction set (/arch:AVX2) # - Disable RTTI (/GR-) - # - Enable whole program optimizaion (/GL) + # - Enable whole program optimization (/GL) # - Enable string pooling (/GF) set(MSVC_ALL_RELEASE_COMPILE_OPTIONS /arch:AVX2 /wd4189 /GR- /GL /GF) #target_compile_options(BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:/arch:AVX2 /wd4189 /Ot") diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp index 0702f7ac..12027427 100644 --- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp +++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp @@ -55,7 +55,7 @@ static uint32_t GetDecorationOffset(const spirv_cross::Compiler& Compiler, VERIFY(Compiler.has_decoration(Res.id, Decoration), "Res \'", Res.name, "\' has no requested decoration"); uint32_t offset = 0; auto declared = Compiler.get_binary_offset_for_decoration(Res.id, Decoration, offset); - VERIFY(declared, "Requested decoration is not declared"); + VERIFY(declared, "Requested decoration is not declared"); (void)declared; return offset; } @@ -396,11 +396,13 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, SamplerInd); if (pNewSepImg->IsValidSepSamplerAssigned()) { +#ifdef DEVELOPMENT const auto& SepSmplr = GetSepSmplr(pNewSepImg->GetAssignedSepSamplerInd()); DEV_CHECK_ERR(SepSmplr.ArraySize == 1 || SepSmplr.ArraySize == pNewSepImg->ArraySize, "Array size (", SepSmplr.ArraySize,") of separate sampler variable '", SepSmplr.Name, "' must be equal to 1 or be the same as the array size (", pNewSepImg->ArraySize, ") of separate image variable '", pNewSepImg->Name, "' it is assigned to"); +#endif } } VERIFY_EXPR(CurrSepImg == GetNumSepImgs()); @@ -522,13 +524,13 @@ void SPIRVShaderResources::Initialize(IMemoryAllocator& Allocator, constexpr Uint32 MaxOffset = std::numeric_limits<OffsetType>::max(); auto AdvanceOffset = [&CurrentOffset, MaxOffset](Uint32 NumResources) { - VERIFY(CurrentOffset <= MaxOffset, "Current offser (", CurrentOffset, ") exceeds max allowed value (", MaxOffset, ")"); + VERIFY(CurrentOffset <= MaxOffset, "Current offser (", CurrentOffset, ") exceeds max allowed value (", MaxOffset, ")"); (void)MaxOffset; auto Offset = static_cast<OffsetType>(CurrentOffset); CurrentOffset += NumResources; return Offset; }; - auto UniformBufferOffset = AdvanceOffset(Counters.NumUBs); UniformBufferOffset; // To suppress warning + auto UniformBufferOffset = AdvanceOffset(Counters.NumUBs); (void)UniformBufferOffset; m_StorageBufferOffset = AdvanceOffset(Counters.NumSBs); m_StorageImageOffset = AdvanceOffset(Counters.NumImgs); m_SampledImageOffset = AdvanceOffset(Counters.NumSmpldImgs); @@ -603,7 +605,7 @@ SPIRVShaderResources::~SPIRVShaderResources() SPIRVShaderResources::ResourceCounters SPIRVShaderResources::CountResources(const SHADER_VARIABLE_TYPE* AllowedVarTypes, Uint32 NumAllowedTypes)const noexcept { - Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes); + Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes); (void)AllowedTypeBits; ResourceCounters Counters; ProcessResources( diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h index 23bd88c9..cd37a9e3 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.h +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h @@ -717,10 +717,12 @@ inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) { VERIFY(pBuffer != nullptr, "Buffer must not be null"); +#ifdef DEVELOPMENT const auto& BuffDesc = ValidatedCast<BufferImplType>(pBuffer)->GetDesc(); DEV_CHECK_ERR(BuffDesc.Usage == USAGE_DEFAULT, "Unable to update buffer '", BuffDesc.Name, "': only USAGE_DEFAULT buffers can be updated with UpdateData()"); DEV_CHECK_ERR(Offset < BuffDesc.uiSizeInBytes, "Unable to update buffer '", BuffDesc.Name, "': offset (", Offset, ") exceeds the buffer size (", BuffDesc.uiSizeInBytes, ")" ); DEV_CHECK_ERR(Size + Offset <= BuffDesc.uiSizeInBytes, "Unable to update buffer '", BuffDesc.Name, "': Update region [", Offset, ",", Size + Offset, ") is out of buffer bounds [0,", BuffDesc.uiSizeInBytes, ")" ); +#endif } template<typename BaseInterface, typename ImplementationTraits> @@ -735,10 +737,12 @@ inline void DeviceContextBase<BaseInterface,ImplementationTraits> :: { VERIFY(pSrcBuffer != nullptr, "Source buffer must not be null"); VERIFY(pDstBuffer != nullptr, "Destination buffer must not be null"); +#ifdef DEVELOPMENT const auto& SrcBufferDesc = ValidatedCast<BufferImplType>(pSrcBuffer)->GetDesc(); const auto& DstBufferDesc = ValidatedCast<BufferImplType>(pDstBuffer)->GetDesc(); DEV_CHECK_ERR( DstOffset + Size <= DstBufferDesc.uiSizeInBytes, "Failed to copy buffer '", SrcBufferDesc.Name, "' to '", DstBufferDesc.Name, "': Destination range [", DstOffset, ",", DstOffset + Size, ") is out of buffer bounds [0,", DstBufferDesc.uiSizeInBytes, ")" ); DEV_CHECK_ERR( SrcOffset + Size <= SrcBufferDesc.uiSizeInBytes, "Failed to copy buffer '", SrcBufferDesc.Name, "' to '", DstBufferDesc.Name, "': Source range [", SrcOffset, ",", SrcOffset + Size, ") is out of buffer bounds [0,", SrcBufferDesc.uiSizeInBytes, ")" ); +#endif } template<typename BaseInterface, typename ImplementationTraits> diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp index 21333984..5c334cc3 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp @@ -320,7 +320,7 @@ void BufferGLImpl::Unmap() // occur only during the periods that a buffer's data store is mapped. If such corruption // has occurred, glUnmapBuffer() returns FALSE, and the contents of the buffer's // data store become undefined. - VERIFY( Result != GL_FALSE, "Failed to unmap buffer. The data may have been corrupted" ); + VERIFY( Result != GL_FALSE, "Failed to unmap buffer. The data may have been corrupted" ); (void)Result; glBindBuffer(m_uiMapTarget, 0); m_uiMapTarget = 0; } @@ -328,18 +328,22 @@ void BufferGLImpl::Unmap() void BufferGLImpl::BufferMemoryBarrier( Uint32 RequiredBarriers, GLContextState &GLContextState ) { #if GL_ARB_shader_image_load_store - const Uint32 BufferBarriers = - GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT | - GL_ELEMENT_ARRAY_BARRIER_BIT | - GL_UNIFORM_BARRIER_BIT | - GL_COMMAND_BARRIER_BIT | - GL_BUFFER_UPDATE_BARRIER_BIT | - GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT | - GL_SHADER_STORAGE_BARRIER_BIT | - GL_TEXTURE_FETCH_BARRIER_BIT; - VERIFY( (RequiredBarriers & BufferBarriers) !=0, "At least one buffer memory barrier flag should be set" ); - VERIFY( (RequiredBarriers & ~BufferBarriers) == 0, "Inappropriate buffer memory barrier flag" ); - + #ifdef _DEBUG + { + constexpr Uint32 BufferBarriers = + GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT | + GL_ELEMENT_ARRAY_BARRIER_BIT | + GL_UNIFORM_BARRIER_BIT | + GL_COMMAND_BARRIER_BIT | + GL_BUFFER_UPDATE_BARRIER_BIT | + GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT | + GL_SHADER_STORAGE_BARRIER_BIT | + GL_TEXTURE_FETCH_BARRIER_BIT; + VERIFY( (RequiredBarriers & BufferBarriers) !=0, "At least one buffer memory barrier flag should be set" ); + VERIFY( (RequiredBarriers & ~BufferBarriers) == 0, "Inappropriate buffer memory barrier flag" ); + } + #endif + GLContextState.EnsureMemoryBarrier( RequiredBarriers, this ); #endif } diff --git a/Graphics/GraphicsEngineOpenGL/src/FBOCache.cpp b/Graphics/GraphicsEngineOpenGL/src/FBOCache.cpp index 238c1025..e92ec105 100644 --- a/Graphics/GraphicsEngineOpenGL/src/FBOCache.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/FBOCache.cpp @@ -189,21 +189,27 @@ const GLObjectWrappers::GLFrameBufferObj& FBOCache::GetFBO( Uint32 NumRenderTarg if( ViewDesc.Format == TEX_FORMAT_D32_FLOAT || ViewDesc.Format == TEX_FORMAT_D16_UNORM ) { - auto GLTexFmt = pTexGL->GetGLTexFormat(); - VERIFY( GLTexFmt == GL_DEPTH_COMPONENT32F || GLTexFmt == GL_DEPTH_COMPONENT16, - "Inappropriate internal texture format (", GLTexFmt, ") for depth attachment. " - "GL_DEPTH_COMPONENT32F or GL_DEPTH_COMPONENT16 is expected"); - +#ifdef _DEBUG + { + const auto GLTexFmt = pTexGL->GetGLTexFormat(); + VERIFY( GLTexFmt == GL_DEPTH_COMPONENT32F || GLTexFmt == GL_DEPTH_COMPONENT16, + "Inappropriate internal texture format (", GLTexFmt, ") for depth attachment. " + "GL_DEPTH_COMPONENT32F or GL_DEPTH_COMPONENT16 is expected"); + } +#endif AttachmentPoint = GL_DEPTH_ATTACHMENT; } else if( ViewDesc.Format == TEX_FORMAT_D32_FLOAT_S8X24_UINT || ViewDesc.Format == TEX_FORMAT_D24_UNORM_S8_UINT ) { - auto GLTexFmt = pTexGL->GetGLTexFormat(); - VERIFY( GLTexFmt == GL_DEPTH24_STENCIL8 || GLTexFmt == GL_DEPTH32F_STENCIL8, - "Inappropriate internal texture format (", GLTexFmt, ") for depth-stencil attachment. " - "GL_DEPTH24_STENCIL8 or GL_DEPTH32F_STENCIL8 is expected"); - +#ifdef _DEBUG + { + const auto GLTexFmt = pTexGL->GetGLTexFormat(); + VERIFY( GLTexFmt == GL_DEPTH24_STENCIL8 || GLTexFmt == GL_DEPTH32F_STENCIL8, + "Inappropriate internal texture format (", GLTexFmt, ") for depth-stencil attachment. " + "GL_DEPTH24_STENCIL8 or GL_DEPTH32F_STENCIL8 is expected"); + } +#endif AttachmentPoint = GL_DEPTH_STENCIL_ATTACHMENT; } else diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 3adbb081..6822d61f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -612,7 +612,7 @@ void RenderDeviceGLImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) { glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, TestTextureDim, TestTextureDim); } ); - VERIFY( Success, "Failed to create dummy render target texture" ); + VERIFY( Success, "Failed to create dummy render target texture" ); (void)Success; glFramebufferTexture2D( GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ColorTex, 0 ); CHECK_GL_ERROR( "Failed to set bind dummy render target to framebuffer" ); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp index 606bf469..a919ce4a 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp @@ -152,11 +152,14 @@ void Texture2DArray_OGL::UpdateData(GLContextState &ContextState, Uint32 MipLeve ((DstBox.MaxX % 4) == 0 || DstBox.MaxX == MipWidth) && ((DstBox.MaxY % 4) == 0 || DstBox.MaxY == MipHeight), "Compressed texture update region must be 4 pixel-aligned" ); - const auto &FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); - auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; - VERIFY( SubresData.Stride == BlockBytesInRow, - "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); - +#ifdef _DEBUG + { + const auto& FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); + auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; + VERIFY( SubresData.Stride == BlockBytesInRow, + "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); + } +#endif //glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); //glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_WIDTH, 0); auto UpdateRegionWidth = DstBox.MaxX - DstBox.MinX; diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp index 87f673de..173e563a 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp @@ -154,11 +154,15 @@ void Texture2D_OGL::UpdateData( GLContextState &ContextState, Uint32 MipLevel, U ((DstBox.MaxX % 4) == 0 || DstBox.MaxX == MipWidth) && ((DstBox.MaxY % 4) == 0 || DstBox.MaxY == MipHeight), "Compressed texture update region must be 4 pixel-aligned" ); - const auto &FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); - auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; - VERIFY( SubresData.Stride == BlockBytesInRow, - "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); - +#ifdef _DEBUG + { + const auto& FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); + auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; + VERIFY( SubresData.Stride == BlockBytesInRow, + "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); + } +#endif + //glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); //glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_WIDTH, 0); auto UpdateRegionWidth = DstBox.MaxX - DstBox.MinX; diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index a09cd189..9c0a60e2 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -427,10 +427,13 @@ void TextureBaseGL :: CopyData(DeviceContextGLImpl *pDeviceCtxGL, return; } - auto *pRenderDeviceGL = ValidatedCast<RenderDeviceGLImpl>(GetDevice()); - auto &TexViewObjAllocator = pRenderDeviceGL->GetTexViewObjAllocator(); - VERIFY( &TexViewObjAllocator == &m_dbgTexViewObjAllocator, "Texture view allocator does not match allocator provided during texture initialization" ); - + auto* pRenderDeviceGL = ValidatedCast<RenderDeviceGLImpl>(GetDevice()); +#ifdef _DEBUG + { + auto& TexViewObjAllocator = pRenderDeviceGL->GetTexViewObjAllocator(); + VERIFY( &TexViewObjAllocator == &m_dbgTexViewObjAllocator, "Texture view allocator does not match allocator provided during texture initialization" ); + } +#endif auto &TexRegionRender = pRenderDeviceGL->m_TexRegionRender; TexRegionRender.SetStates(pDeviceCtxGL); @@ -490,15 +493,19 @@ void TextureBaseGL :: CopyData(DeviceContextGLImpl *pDeviceCtxGL, void TextureBaseGL::TextureMemoryBarrier( Uint32 RequiredBarriers, GLContextState &GLContextState ) { #if GL_ARB_shader_image_load_store - const Uint32 TextureBarriers = - GL_TEXTURE_FETCH_BARRIER_BIT | - GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | - GL_PIXEL_BUFFER_BARRIER_BIT | - GL_TEXTURE_UPDATE_BARRIER_BIT | - GL_FRAMEBUFFER_BARRIER_BIT; - VERIFY( (RequiredBarriers & TextureBarriers) != 0, "At least one texture memory barrier flag should be set" ); - VERIFY( (RequiredBarriers & ~TextureBarriers) == 0, "Inappropriate texture memory barrier flag" ); - + #ifdef DEBUG + { + constexpr Uint32 TextureBarriers = + GL_TEXTURE_FETCH_BARRIER_BIT | + GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | + GL_PIXEL_BUFFER_BARRIER_BIT | + GL_TEXTURE_UPDATE_BARRIER_BIT | + GL_FRAMEBUFFER_BARRIER_BIT; + VERIFY( (RequiredBarriers & TextureBarriers) != 0, "At least one texture memory barrier flag should be set" ); + VERIFY( (RequiredBarriers & ~TextureBarriers) == 0, "Inappropriate texture memory barrier flag" ); + } + #endif + GLContextState.EnsureMemoryBarrier( RequiredBarriers, this ); #endif } diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp index 03654063..042f7575 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp @@ -138,10 +138,14 @@ void TextureCubeArray_OGL::UpdateData( GLContextState &ContextState, Uint32 MipL ((DstBox.MaxX % 4) == 0 || DstBox.MaxX == MipWidth) && ((DstBox.MaxY % 4) == 0 || DstBox.MaxY == MipHeight), "Compressed texture update region must be 4 pixel-aligned" ); - const auto &FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); - auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; - VERIFY( SubresData.Stride == BlockBytesInRow, - "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); +#ifdef _DEBUG + { + const auto& FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); + auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; + VERIFY( SubresData.Stride == BlockBytesInRow, + "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); + } +#endif // Every OpenGL API call that operates on cubemap array textures takes layer-faces, not array layers. diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp index 528cafe0..1b4c9b86 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp @@ -64,7 +64,7 @@ TextureCube_OGL::TextureCube_OGL( IReferenceCounters *pRefCounters, if( InitData.pSubResources ) { - auto ExpectedSubresources = m_Desc.MipLevels*6; + const auto ExpectedSubresources = m_Desc.MipLevels*6; if( m_Desc.MipLevels*6 == InitData.NumSubresources ) { for(Uint32 Face = 0; Face < 6; ++Face) @@ -83,7 +83,7 @@ TextureCube_OGL::TextureCube_OGL( IReferenceCounters *pRefCounters, } else { - UNEXPECTED("Incorrect number of subresources. ", InitData.NumSubresources, " while ", ExpectedSubresources," is expected" ); + UNEXPECTED("Incorrect number of subresources. ", InitData.NumSubresources, " while ", ExpectedSubresources," is expected" ); (void)ExpectedSubresources; } } @@ -152,10 +152,14 @@ void TextureCube_OGL::UpdateData( GLContextState &ContextState, Uint32 MipLevel, ((DstBox.MaxX % 4) == 0 || DstBox.MaxX == MipWidth) && ((DstBox.MaxY % 4) == 0 || DstBox.MaxY == MipHeight), "Compressed texture update region must be 4 pixel-aligned" ); - const auto &FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); - auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; - VERIFY( SubresData.Stride == BlockBytesInRow, - "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); +#ifdef _DEBUG + { + const auto &FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); + auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; + VERIFY( SubresData.Stride == BlockBytesInRow, + "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); + } +#endif //glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); //glPixelStorei(GL_UNPACK_COMPRESSED_BLOCK_WIDTH, 0); diff --git a/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp index 5dd6b813..1d7937a8 100644 --- a/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp @@ -64,7 +64,7 @@ Uint64 CommandQueueVkImpl::Submit(const VkSubmitInfo& SubmitInfo) SubmitInfo.signalSemaphoreCount != 0) ? 1 : 0; auto err = vkQueueSubmit(m_VkQueue, SubmitCount, &SubmitInfo, vkFence); - DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to submit command buffer to the command queue"); + DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to submit command buffer to the command queue"); (void)err; // We must atomically place the (value, fence) pair into the deque m_pFence->AddPendingFence(std::move(vkFence), FenceValue); @@ -116,7 +116,7 @@ void CommandQueueVkImpl::SignalFence(VkFence vkFence) { std::lock_guard<std::mutex> Lock(m_QueueMutex); auto err = vkQueueSubmit(m_VkQueue, 0, nullptr, vkFence); - DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to submit command buffer to the command queue"); + DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to submit command buffer to the command queue"); (void)err; } VkResult CommandQueueVkImpl::Present(const VkPresentInfoKHR& PresentInfo) diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 67fa2840..5f045392 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -1676,13 +1676,13 @@ namespace Diligent auto vkCmdBuff = m_CommandBuffer.GetVkCmdBuffer(); auto err = vkEndCommandBuffer(vkCmdBuff); - DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to end command buffer"); + DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to end command buffer"); (void)err; auto* pDeviceVkImpl = m_pDevice.RawPtr<RenderDeviceVkImpl>(); CommandListVkImpl *pCmdListVk( NEW_RC_OBJ(m_CmdListAllocator, "CommandListVkImpl instance", CommandListVkImpl) (pDeviceVkImpl, this, vkCmdBuff) ); pCmdListVk->QueryInterface( IID_CommandList, reinterpret_cast<IObject**>(ppCommandList) ); - + m_CommandBuffer.Reset(); m_State = ContextState{}; m_DescrSetBindInfo.Reset(); @@ -1700,7 +1700,7 @@ namespace Diligent } Flush(); - + InvalidateState(); CommandListVkImpl* pCmdListVk = ValidatedCast<CommandListVkImpl>(pCommandList); diff --git a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp index 424bfb4e..a7e2f7ea 100644 --- a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp @@ -87,11 +87,11 @@ void FenceVkImpl :: Wait() { VkFence FenceToWait = val_fence.second; auto res = LogicalDevice.WaitForFences(1, &FenceToWait, VK_TRUE, UINT64_MAX); - VERIFY_EXPR(res == VK_SUCCESS); + VERIFY_EXPR(res == VK_SUCCESS); (void)res; } auto status = LogicalDevice.GetFenceStatus(val_fence.second); - VERIFY(status == VK_SUCCESS, "All pending fences must now be complete!"); + DEV_CHECK_ERR(status == VK_SUCCESS, "All pending fences must now be complete!"); (void)status; if (val_fence.first > m_LastCompletedFenceValue) m_LastCompletedFenceValue = val_fence.first; m_FencePool.DisposeFence(std::move(val_fence.second)); diff --git a/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp b/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp index 626420cb..44175264 100644 --- a/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp +++ b/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp @@ -90,7 +90,7 @@ VkFramebuffer FramebufferCache::GetFramebuffer(const FramebufferCacheKey& Key, u VkFramebuffer fb = Framebuffer; auto new_it = m_Cache.insert(std::make_pair(Key, std::move(Framebuffer))); - VERIFY(new_it.second, "New framebuffer must be inserted into the map"); + VERIFY(new_it.second, "New framebuffer must be inserted into the map"); (void)new_it; m_RenderPassToKeyMap.emplace(Key.Pass, Key); if (Key.DSV != VK_NULL_HANDLE) diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp index 8b973f7c..936419d6 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp @@ -516,7 +516,7 @@ void PipelineLayout::BindDescriptorSetsWithDynamicOffsets(DeviceContextVkImpl* #endif auto NumOffsetsWritten = BindInfo.pResourceCache->GetDynamicBufferOffsets(pCtxVkImpl, BindInfo.DynamicOffsets); - VERIFY_EXPR(NumOffsetsWritten == BindInfo.DynamicOffsetCount); + VERIFY_EXPR(NumOffsetsWritten == BindInfo.DynamicOffsetCount); (void)NumOffsetsWritten; auto& CmdBuffer = pCtxVkImpl->GetCommandBuffer(); // vkCmdBindDescriptorSets causes the sets numbered [firstSet .. firstSet+descriptorSetCount-1] to use the diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 2d807d62..6aa8db27 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -181,7 +181,7 @@ void RenderDeviceVkImpl::AllocateTransientCmdPool(VulkanUtilities::CommandPoolWr // and recorded again between each submission. CmdBuffBeginInfo.pInheritanceInfo = nullptr; // Ignored for a primary command buffer auto err = vkBeginCommandBuffer(vkCmdBuff, &CmdBuffBeginInfo); - DEV_CHECK_ERR(err == VK_SUCCESS, "vkBeginCommandBuffer() failed"); + DEV_CHECK_ERR(err == VK_SUCCESS, "vkBeginCommandBuffer() failed"); (void)err; } @@ -190,7 +190,7 @@ void RenderDeviceVkImpl::ExecuteAndDisposeTransientCmdBuff(Uint32 QueueIndex, Vk VERIFY_EXPR(vkCmdBuff != VK_NULL_HANDLE); auto err = vkEndCommandBuffer(vkCmdBuff); - DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to end command buffer"); + DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to end command buffer"); (void)err; VkSubmitInfo SubmitInfo = {}; SubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp index f4a28167..48711136 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp @@ -59,11 +59,11 @@ void ShaderResourceLayoutVk::AllocateMemory(std::shared_ptr<const SPIRVShaderRes VERIFY(!m_ResourceBuffer, "Memory has already been initialized"); VERIFY_EXPR(!m_pResources); VERIFY_EXPR(pSrcResources); - + m_pResources = std::move(pSrcResources); - Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes); - + Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes); (void)AllowedTypeBits; + // Count number of resources to allocate all needed memory m_pResources->ProcessResources( AllowedVarTypes, NumAllowedTypes, diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp index d7434bae..ad9b4a27 100644 --- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp @@ -406,7 +406,7 @@ void SwapChainVkImpl::AcquireNextImage(DeviceContextVkImpl* pDeviceCtxVk) const auto& LogicalDevice = pDeviceVk->GetLogicalDevice(); auto res = vkAcquireNextImageKHR(LogicalDevice.GetVkDevice(), m_VkSwapChain, UINT64_MAX, m_ImageAcquiredSemaphores[m_SemaphoreIndex], (VkFence)nullptr, &m_BackBufferIndex); - VERIFY(res == VK_SUCCESS, "Failed to acquire next swap chain image"); + VERIFY(res == VK_SUCCESS, "Failed to acquire next swap chain image"); (void)res; // Next command in the device context must wait for the next image to be acquired // Unlike fences or events, the act of waiting for a semaphore also unsignals that semaphore (6.4.2) diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index 7f04d036..97b9c63b 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -208,13 +208,13 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, { for(Uint32 mip = 0; mip < ImageCI.mipLevels; ++mip) { - const auto &SubResData = InitData.pSubResources[subres]; - auto &CopyRegion = Regions[subres]; + const auto& SubResData = InitData.pSubResources[subres]; (void)SubResData; + auto& CopyRegion = Regions[subres]; auto MipWidth = std::max(m_Desc.Width >> mip, 1u); auto MipHeight = std::max(m_Desc.Height >> mip, 1u); auto MipDepth = (m_Desc.Type == RESOURCE_DIM_TEX_3D) ? std::max(m_Desc.Depth >> mip, 1u) : 1u; - + CopyRegion.bufferOffset = uploadBufferSize; // offset in bytes from the start of the buffer object // bufferRowLength and bufferImageHeight specify the data in buffer memory as a subregion // of a larger two- or three-dimensional image, and control the addressing calculations of @@ -225,7 +225,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, // For block-compression formats, all parameters are still specified in texels rather than compressed texel blocks (18.4.1) CopyRegion.imageOffset = VkOffset3D{0, 0, 0}; CopyRegion.imageExtent = VkExtent3D{MipWidth, MipHeight, MipDepth}; - + CopyRegion.imageSubresource.aspectMask = aspectMask; CopyRegion.imageSubresource.mipLevel = mip; CopyRegion.imageSubresource.baseArrayLayer = layer; @@ -246,7 +246,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, auto MipSize = RowSize * MipHeight * MipDepth; VERIFY(SubResData.Stride == 0 || SubResData.Stride >= RowSize, "Stride is too small"); VERIFY(SubResData.DepthStride == 0 || SubResData.DepthStride >= RowSize * MipHeight, "Depth stride is too small"); - + // bufferOffset must be a multiple of 4 (18.4) // If the calling command's VkImage parameter is a compressed image, bufferOffset // must be a multiple of the compressed texel block size in bytes (18.4). This diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp index 90c0c16d..c7f32e16 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp @@ -75,7 +75,7 @@ VulkanUploadHeap::UploadPageInfo VulkanUploadHeap::CreateNewPage(VkDeviceSize Si auto AlignedOffset = (MemAllocation.UnalignedOffset + (MemReqs.alignment-1)) & ~(MemReqs.alignment-1); auto err = LogicalDevice.BindBufferMemory(NewBuffer, MemAllocation.Page->GetVkMemory(), AlignedOffset); - DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to bind buffer memory"); + DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to bind buffer memory"); (void)err; auto CPUAddress = reinterpret_cast<Uint8*>(MemAllocation.Page->GetCPUMemory()) + AlignedOffset; return UploadPageInfo{std::move(MemAllocation), std::move(NewBuffer), CPUAddress}; diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp index 692fbcfd..240fc871 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp @@ -67,7 +67,7 @@ namespace VulkanUtilities 0 // VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT - specifies that most or all memory resources currently // owned by the command buffer should be returned to the parent command pool. ); - DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to reset command buffer"); + DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to reset command buffer"); (void)err; m_CmdBuffers.pop_front(); } } @@ -94,7 +94,7 @@ namespace VulkanUtilities // and recorded again between each submission. CmdBuffBeginInfo.pInheritanceInfo = nullptr; // Ignored for a primary command buffer auto err = vkBeginCommandBuffer(CmdBuffer, &CmdBuffBeginInfo); - DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to begin command buffer"); + DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to begin command buffer"); (void)err; #ifdef DEVELOPMENT ++m_BuffCounter; #endif diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp index bd72879f..b4861590 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp @@ -1,264 +1,266 @@ -/*
-* Vulkan examples debug wrapper
-*
-* Appendix for VK_EXT_Debug_Report can be found at https://github.com/KhronosGroup/Vulkan-Docs/blob/1.0-VK_EXT_debug_report/doc/specs/vulkan/appendices/debug_report.txt
-*
-* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
-*
-* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-*/
-
-#include <sstream>
-
-#include "VulkanUtilities/VulkanDebug.h"
-#include "Errors.h"
-#include "DebugUtilities.h"
-
-namespace VulkanUtilities
-{
- static PFN_vkCreateDebugUtilsMessengerEXT CreateDebugUtilsMessengerEXT = nullptr;
- static PFN_vkDestroyDebugUtilsMessengerEXT DestroyDebugUtilsMessengerEXT = nullptr;
- static PFN_vkSetDebugUtilsObjectNameEXT SetDebugUtilsObjectNameEXT = nullptr;
- static PFN_vkSetDebugUtilsObjectTagEXT SetDebugUtilsObjectTagEXT = nullptr;
- static PFN_vkQueueBeginDebugUtilsLabelEXT QueueBeginDebugUtilsLabelEXT = nullptr;
- static PFN_vkQueueEndDebugUtilsLabelEXT QueueEndDebugUtilsLabelEXT = nullptr;
- static PFN_vkQueueInsertDebugUtilsLabelEXT QueueInsertDebugUtilsLabelEXT = nullptr;
- static PFN_vkCmdBeginDebugUtilsLabelEXT CmdBeginDebugUtilsLabelEXT = nullptr;
- static PFN_vkCmdEndDebugUtilsLabelEXT CmdEndDebugUtilsLabelEXT = nullptr;
- static PFN_vkCmdInsertDebugUtilsLabelEXT CmdInsertDebugUtilsLabelEXT = nullptr;
-
- static VkDebugUtilsMessengerEXT DbgMessenger = VK_NULL_HANDLE;
-
- VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessengerCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
- VkDebugUtilsMessageTypeFlagsEXT messageType,
- const VkDebugUtilsMessengerCallbackDataEXT* callbackData,
- void* userData)
- {
- std::stringstream debugMessage;
-
- // Ignore the following performance warnings:
- // 64: vkCmdClearAttachments() issued on command buffer object 0x... prior to any Draw Cmds. It is recommended you use RenderPass LOAD_OP_CLEAR on Attachments prior to any Draw.
- // 26: Vertex buffers are bound to command buffer (0x...) but no vertex buffers are attached to this Pipeline State Object (0x...).
- if ((messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) &&
- (callbackData->messageIdNumber == 64 || callbackData->messageIdNumber == 26))
- return VK_FALSE;
-
- debugMessage << "Vulkan debug message (";
-
- Diligent::DebugMessageSeverity MsgSeverity = Diligent::DebugMessageSeverity::Info;
- if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT)
- {
- debugMessage << "verbose";
- MsgSeverity = Diligent::DebugMessageSeverity::Info;
- }
- else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT)
- {
- debugMessage << "info";
- MsgSeverity = Diligent::DebugMessageSeverity::Info;
- }
- else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
- {
- debugMessage << "WARNING";
- MsgSeverity = Diligent::DebugMessageSeverity::Warning;
- }
- else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
- {
- debugMessage << "ERROR";
- MsgSeverity = Diligent::DebugMessageSeverity::Error;
- }
- else
- {
- debugMessage << "unknown severity";
- MsgSeverity = Diligent::DebugMessageSeverity::Info;
- }
-
- if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT)
- debugMessage << ", general";
- if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT)
- debugMessage << ", validation";
- if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)
- debugMessage << ", perf";
-
- debugMessage << "): " << "Message Id: " << callbackData->messageIdNumber;
- if (callbackData->pMessageIdName != nullptr)
- {
- debugMessage << " | Message Name: " << callbackData->pMessageIdName;
- }
- if (callbackData->pMessage != nullptr)
- {
- debugMessage << std::endl << " " << callbackData->pMessage;
- }
-
- if (callbackData->objectCount > 0)
- {
- for (uint32_t obj = 0; obj < callbackData->objectCount; ++obj)
- {
- const auto& Object = callbackData->pObjects[obj];
- debugMessage << std::endl << " Object[" << obj << "] (" << VkObjectTypeToString(Object.objectType)
- << "): Handle " << std::hex << "0x" << Object.objectHandle;
- if (Object.pObjectName != nullptr)
- {
- debugMessage << ", Name: '" << Object.pObjectName << '\'';
- }
- }
- }
-
- if (callbackData->cmdBufLabelCount > 0)
- {
- for (uint32_t l = 0; l < callbackData->cmdBufLabelCount; ++l)
- {
- const auto& Label = callbackData->pCmdBufLabels[l];
- debugMessage << std::endl << " Label[" << l << "]";
- if (Label.pLabelName != nullptr)
- {
- debugMessage << " - " << Label.pLabelName;
- }
- debugMessage << " {";
- debugMessage << std::fixed << std::setw(4) << Label.color[0] << ", "
- << std::fixed << std::setw(4) << Label.color[1] << ", "
- << std::fixed << std::setw(4) << Label.color[2] << ", "
- << std::fixed << std::setw(4) << Label.color[3] << "}";
- }
- }
-
- LOG_DEBUG_MESSAGE(MsgSeverity, debugMessage.str().c_str());
-
- // The return value of this callback controls wether the Vulkan call that caused
- // the validation message will be aborted or not
- // We return VK_FALSE as we DON'T want Vulkan calls that cause a validation message
- // (and return a VkResult) to abort
- return VK_FALSE;
- }
- void SetupDebugging(VkInstance instance,
+/* +* Vulkan examples debug wrapper +* +* Appendix for VK_EXT_Debug_Report can be found at https://github.com/KhronosGroup/Vulkan-Docs/blob/1.0-VK_EXT_debug_report/doc/specs/vulkan/appendices/debug_report.txt +* +* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de +* +* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +*/ + +#include <sstream> + +#include "VulkanUtilities/VulkanDebug.h" +#include "Errors.h" +#include "DebugUtilities.h" + +namespace VulkanUtilities +{ + static PFN_vkCreateDebugUtilsMessengerEXT CreateDebugUtilsMessengerEXT = nullptr; + static PFN_vkDestroyDebugUtilsMessengerEXT DestroyDebugUtilsMessengerEXT = nullptr; + static PFN_vkSetDebugUtilsObjectNameEXT SetDebugUtilsObjectNameEXT = nullptr; + static PFN_vkSetDebugUtilsObjectTagEXT SetDebugUtilsObjectTagEXT = nullptr; + static PFN_vkQueueBeginDebugUtilsLabelEXT QueueBeginDebugUtilsLabelEXT = nullptr; + static PFN_vkQueueEndDebugUtilsLabelEXT QueueEndDebugUtilsLabelEXT = nullptr; + static PFN_vkQueueInsertDebugUtilsLabelEXT QueueInsertDebugUtilsLabelEXT = nullptr; + static PFN_vkCmdBeginDebugUtilsLabelEXT CmdBeginDebugUtilsLabelEXT = nullptr; + static PFN_vkCmdEndDebugUtilsLabelEXT CmdEndDebugUtilsLabelEXT = nullptr; + static PFN_vkCmdInsertDebugUtilsLabelEXT CmdInsertDebugUtilsLabelEXT = nullptr; + + static VkDebugUtilsMessengerEXT DbgMessenger = VK_NULL_HANDLE; + + VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessengerCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + VkDebugUtilsMessageTypeFlagsEXT messageType, + const VkDebugUtilsMessengerCallbackDataEXT* callbackData, + void* userData) + { + std::stringstream debugMessage; + + // Ignore the following performance warnings: + // 64: vkCmdClearAttachments() issued on command buffer object 0x... prior to any Draw Cmds. It is recommended you use RenderPass LOAD_OP_CLEAR on Attachments prior to any Draw. + // 26: Vertex buffers are bound to command buffer (0x...) but no vertex buffers are attached to this Pipeline State Object (0x...). + if ((messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) && + (callbackData->messageIdNumber == 64 || callbackData->messageIdNumber == 26)) + return VK_FALSE; + + debugMessage << "Vulkan debug message ("; + + Diligent::DebugMessageSeverity MsgSeverity = Diligent::DebugMessageSeverity::Info; + if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) + { + debugMessage << "verbose"; + MsgSeverity = Diligent::DebugMessageSeverity::Info; + } + else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) + { + debugMessage << "info"; + MsgSeverity = Diligent::DebugMessageSeverity::Info; + } + else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) + { + debugMessage << "WARNING"; + MsgSeverity = Diligent::DebugMessageSeverity::Warning; + } + else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) + { + debugMessage << "ERROR"; + MsgSeverity = Diligent::DebugMessageSeverity::Error; + } + else + { + debugMessage << "unknown severity"; + MsgSeverity = Diligent::DebugMessageSeverity::Info; + } + + if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) + debugMessage << ", general"; + if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) + debugMessage << ", validation"; + if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) + debugMessage << ", perf"; + + debugMessage << "): " << "Message Id: " << callbackData->messageIdNumber; + if (callbackData->pMessageIdName != nullptr) + { + debugMessage << " | Message Name: " << callbackData->pMessageIdName; + } + if (callbackData->pMessage != nullptr) + { + debugMessage << std::endl << " " << callbackData->pMessage; + } + + if (callbackData->objectCount > 0) + { + for (uint32_t obj = 0; obj < callbackData->objectCount; ++obj) + { + const auto& Object = callbackData->pObjects[obj]; + debugMessage << std::endl << " Object[" << obj << "] (" << VkObjectTypeToString(Object.objectType) + << "): Handle " << std::hex << "0x" << Object.objectHandle; + if (Object.pObjectName != nullptr) + { + debugMessage << ", Name: '" << Object.pObjectName << '\''; + } + } + } + + if (callbackData->cmdBufLabelCount > 0) + { + for (uint32_t l = 0; l < callbackData->cmdBufLabelCount; ++l) + { + const auto& Label = callbackData->pCmdBufLabels[l]; + debugMessage << std::endl << " Label[" << l << "]"; + if (Label.pLabelName != nullptr) + { + debugMessage << " - " << Label.pLabelName; + } + debugMessage << " {"; + debugMessage << std::fixed << std::setw(4) << Label.color[0] << ", " + << std::fixed << std::setw(4) << Label.color[1] << ", " + << std::fixed << std::setw(4) << Label.color[2] << ", " + << std::fixed << std::setw(4) << Label.color[3] << "}"; + } + } + + LOG_DEBUG_MESSAGE(MsgSeverity, debugMessage.str().c_str()); + + // The return value of this callback controls wether the Vulkan call that caused + // the validation message will be aborted or not + // We return VK_FALSE as we DON'T want Vulkan calls that cause a validation message + // (and return a VkResult) to abort + return VK_FALSE; + } + + + void SetupDebugging(VkInstance instance, VkDebugUtilsMessageSeverityFlagsEXT messageSeverity, - VkDebugUtilsMessageTypeFlagsEXT messageType,
- void* pUserData)
- {
- CreateDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkCreateDebugUtilsMessengerEXT>(vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT"));
- DestroyDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkDestroyDebugUtilsMessengerEXT>(vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT"));
- VERIFY_EXPR(CreateDebugUtilsMessengerEXT != nullptr && DestroyDebugUtilsMessengerEXT != nullptr);
-
- VkDebugUtilsMessengerCreateInfoEXT DbgMessenger_CI = {};
- DbgMessenger_CI.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
- DbgMessenger_CI.pNext = NULL;
- DbgMessenger_CI.flags = 0;
- DbgMessenger_CI.messageSeverity = messageSeverity;
- DbgMessenger_CI.messageType = messageType;
- DbgMessenger_CI.pfnUserCallback = DebugMessengerCallback;
- DbgMessenger_CI.pUserData = pUserData;
- VkResult err = CreateDebugUtilsMessengerEXT(instance, &DbgMessenger_CI, nullptr, &DbgMessenger);
- VERIFY(err == VK_SUCCESS, "Failed to create debug utils messenger");
-
- // Load function pointers
- SetDebugUtilsObjectNameEXT = reinterpret_cast<PFN_vkSetDebugUtilsObjectNameEXT>(vkGetInstanceProcAddr(instance, "vkSetDebugUtilsObjectNameEXT"));
- VERIFY_EXPR(SetDebugUtilsObjectNameEXT != nullptr);
- SetDebugUtilsObjectTagEXT = reinterpret_cast<PFN_vkSetDebugUtilsObjectTagEXT>(vkGetInstanceProcAddr(instance, "vkSetDebugUtilsObjectTagEXT"));
- VERIFY_EXPR(SetDebugUtilsObjectTagEXT != nullptr);
-
- QueueBeginDebugUtilsLabelEXT = reinterpret_cast<PFN_vkQueueBeginDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkQueueBeginDebugUtilsLabelEXT"));
- VERIFY_EXPR(QueueBeginDebugUtilsLabelEXT != nullptr);
- QueueEndDebugUtilsLabelEXT = reinterpret_cast<PFN_vkQueueEndDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkQueueEndDebugUtilsLabelEXT"));
- VERIFY_EXPR(QueueEndDebugUtilsLabelEXT != nullptr);
- QueueInsertDebugUtilsLabelEXT = reinterpret_cast<PFN_vkQueueInsertDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkQueueInsertDebugUtilsLabelEXT"));
- VERIFY_EXPR(QueueInsertDebugUtilsLabelEXT != nullptr);
-
- CmdBeginDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdBeginDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkCmdBeginDebugUtilsLabelEXT"));
- VERIFY_EXPR(CmdBeginDebugUtilsLabelEXT != nullptr);
- CmdEndDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdEndDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkCmdEndDebugUtilsLabelEXT"));
- VERIFY_EXPR(CmdEndDebugUtilsLabelEXT != nullptr);
- CmdInsertDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdInsertDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkCmdInsertDebugUtilsLabelEXT"));
- VERIFY_EXPR(CmdInsertDebugUtilsLabelEXT != nullptr);
- }
-
- void FreeDebugging(VkInstance instance)
- {
- if (DbgMessenger != VK_NULL_HANDLE)
- {
- DestroyDebugUtilsMessengerEXT(instance, DbgMessenger, nullptr);
- }
- }
-
- void BeginCmdQueueLabelRegion(VkQueue cmdQueue, const char* pLabelName, const float* color)
- {
- VkDebugUtilsLabelEXT Label = {};
+ VkDebugUtilsMessageTypeFlagsEXT messageType, + void* pUserData) + { + CreateDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkCreateDebugUtilsMessengerEXT>(vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT")); + DestroyDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkDestroyDebugUtilsMessengerEXT>(vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT")); + VERIFY_EXPR(CreateDebugUtilsMessengerEXT != nullptr && DestroyDebugUtilsMessengerEXT != nullptr); + + VkDebugUtilsMessengerCreateInfoEXT DbgMessenger_CI = {}; + DbgMessenger_CI.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT; + DbgMessenger_CI.pNext = NULL; + DbgMessenger_CI.flags = 0; + DbgMessenger_CI.messageSeverity = messageSeverity; + DbgMessenger_CI.messageType = messageType; + DbgMessenger_CI.pfnUserCallback = DebugMessengerCallback; + DbgMessenger_CI.pUserData = pUserData; + VkResult err = CreateDebugUtilsMessengerEXT(instance, &DbgMessenger_CI, nullptr, &DbgMessenger); + VERIFY(err == VK_SUCCESS, "Failed to create debug utils messenger"); (void)err; + + // Load function pointers + SetDebugUtilsObjectNameEXT = reinterpret_cast<PFN_vkSetDebugUtilsObjectNameEXT>(vkGetInstanceProcAddr(instance, "vkSetDebugUtilsObjectNameEXT")); + VERIFY_EXPR(SetDebugUtilsObjectNameEXT != nullptr); + SetDebugUtilsObjectTagEXT = reinterpret_cast<PFN_vkSetDebugUtilsObjectTagEXT>(vkGetInstanceProcAddr(instance, "vkSetDebugUtilsObjectTagEXT")); + VERIFY_EXPR(SetDebugUtilsObjectTagEXT != nullptr); + + QueueBeginDebugUtilsLabelEXT = reinterpret_cast<PFN_vkQueueBeginDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkQueueBeginDebugUtilsLabelEXT")); + VERIFY_EXPR(QueueBeginDebugUtilsLabelEXT != nullptr); + QueueEndDebugUtilsLabelEXT = reinterpret_cast<PFN_vkQueueEndDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkQueueEndDebugUtilsLabelEXT")); + VERIFY_EXPR(QueueEndDebugUtilsLabelEXT != nullptr); + QueueInsertDebugUtilsLabelEXT = reinterpret_cast<PFN_vkQueueInsertDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkQueueInsertDebugUtilsLabelEXT")); + VERIFY_EXPR(QueueInsertDebugUtilsLabelEXT != nullptr); + + CmdBeginDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdBeginDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkCmdBeginDebugUtilsLabelEXT")); + VERIFY_EXPR(CmdBeginDebugUtilsLabelEXT != nullptr); + CmdEndDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdEndDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkCmdEndDebugUtilsLabelEXT")); + VERIFY_EXPR(CmdEndDebugUtilsLabelEXT != nullptr); + CmdInsertDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdInsertDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkCmdInsertDebugUtilsLabelEXT")); + VERIFY_EXPR(CmdInsertDebugUtilsLabelEXT != nullptr); + } + + void FreeDebugging(VkInstance instance) + { + if (DbgMessenger != VK_NULL_HANDLE) + { + DestroyDebugUtilsMessengerEXT(instance, DbgMessenger, nullptr); + } + } + + void BeginCmdQueueLabelRegion(VkQueue cmdQueue, const char* pLabelName, const float* color) + { + VkDebugUtilsLabelEXT Label = {}; Label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; Label.pNext = nullptr; Label.pLabelName = pLabelName; for(int i=0; i < 4; ++i) Label.color[i] = color[i]; QueueBeginDebugUtilsLabelEXT(cmdQueue, &Label); - }
-
- void InsertCmdQueueLabel(VkQueue cmdQueue, const char* pLabelName, const float* color)
- {
- VkDebugUtilsLabelEXT Label = {};
+ } + + void InsertCmdQueueLabel(VkQueue cmdQueue, const char* pLabelName, const float* color) + { + VkDebugUtilsLabelEXT Label = {}; Label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; Label.pNext = nullptr; Label.pLabelName = pLabelName; for(int i=0; i < 4; ++i) Label.color[i] = color[i]; QueueInsertDebugUtilsLabelEXT(cmdQueue, &Label); - }
-
- void EndCmdQueueLabelRegion(VkQueue cmdQueue)
- {
- QueueEndDebugUtilsLabelEXT(cmdQueue);
- }
-
-
- // Start a new label region
- void BeginCmdBufferLabelRegion(VkCommandBuffer cmdBuffer, const char* pLabelName, const float* color)
- {
- VkDebugUtilsLabelEXT Label = {};
+ } + + void EndCmdQueueLabelRegion(VkQueue cmdQueue) + { + QueueEndDebugUtilsLabelEXT(cmdQueue); + } + + + // Start a new label region + void BeginCmdBufferLabelRegion(VkCommandBuffer cmdBuffer, const char* pLabelName, const float* color) + { + VkDebugUtilsLabelEXT Label = {}; Label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; Label.pNext = nullptr; Label.pLabelName = pLabelName; for(int i=0; i < 4; ++i) Label.color[i] = color[i]; - CmdBeginDebugUtilsLabelEXT(cmdBuffer, &Label);
- }
-
- // End the label region
- void EndCmdBufferLabelRegion(VkCommandBuffer cmdBuffer)
- {
- CmdEndDebugUtilsLabelEXT(cmdBuffer);
- }
-
- // Start a single label
- void InsertCmdBufferLabel(VkCommandBuffer cmdBuffer, const char* pLabelName, const float* color)
- {
- VkDebugUtilsLabelEXT Label = {};
+ CmdBeginDebugUtilsLabelEXT(cmdBuffer, &Label); + } + + // End the label region + void EndCmdBufferLabelRegion(VkCommandBuffer cmdBuffer) + { + CmdEndDebugUtilsLabelEXT(cmdBuffer); + } + + // Start a single label + void InsertCmdBufferLabel(VkCommandBuffer cmdBuffer, const char* pLabelName, const float* color) + { + VkDebugUtilsLabelEXT Label = {}; Label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; Label.pNext = nullptr; Label.pLabelName = pLabelName; for(int i=0; i < 4; ++i) Label.color[i] = color[i]; - CmdInsertDebugUtilsLabelEXT(cmdBuffer, &Label);
- }
-
-
- void SetObjectName(VkDevice device, uint64_t objectHandle, VkObjectType objectType, const char *name)
- {
- // Check for valid function pointer (may not be present if not running in a debugging application)
- if (SetDebugUtilsObjectNameEXT != nullptr && name != nullptr && *name != 0)
- {
- VkDebugUtilsObjectNameInfoEXT ObjectNameInfo = {};
+ CmdInsertDebugUtilsLabelEXT(cmdBuffer, &Label); + } + + + void SetObjectName(VkDevice device, uint64_t objectHandle, VkObjectType objectType, const char *name) + { + // Check for valid function pointer (may not be present if not running in a debugging application) + if (SetDebugUtilsObjectNameEXT != nullptr && name != nullptr && *name != 0) + { + VkDebugUtilsObjectNameInfoEXT ObjectNameInfo = {}; ObjectNameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; ObjectNameInfo.pNext = nullptr; ObjectNameInfo.objectType = objectType; ObjectNameInfo.objectHandle = objectHandle; ObjectNameInfo.pObjectName = name; - VkResult res = SetDebugUtilsObjectNameEXT(device, &ObjectNameInfo);
- VERIFY_EXPR(res == VK_SUCCESS);
- }
- }
-
- void SetObjectTag(VkDevice device, uint64_t objectHandle, VkObjectType objectType, uint64_t name, size_t tagSize, const void* tag)
- {
- // Check for valid function pointer (may not be present if not running in a debugging application)
- if (SetDebugUtilsObjectTagEXT)
- {
- VkDebugUtilsObjectTagInfoEXT tagInfo = {};
+ VkResult res = SetDebugUtilsObjectNameEXT(device, &ObjectNameInfo); + VERIFY_EXPR(res == VK_SUCCESS); (void)res; + } + } + + void SetObjectTag(VkDevice device, uint64_t objectHandle, VkObjectType objectType, uint64_t name, size_t tagSize, const void* tag) + { + // Check for valid function pointer (may not be present if not running in a debugging application) + if (SetDebugUtilsObjectTagEXT) + { + VkDebugUtilsObjectTagInfoEXT tagInfo = {}; tagInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_TAG_INFO_EXT; tagInfo.pNext = nullptr; tagInfo.objectType = objectType; @@ -266,318 +268,318 @@ namespace VulkanUtilities tagInfo.tagName = name; tagInfo.tagSize = tagSize; tagInfo.pTag = tag; - SetDebugUtilsObjectTagEXT(device, &tagInfo);
- }
- }
-
- void SetCommandPoolName(VkDevice device, VkCommandPool cmdPool, const char * name)
- {
- SetObjectName(device, (uint64_t)cmdPool, VK_OBJECT_TYPE_COMMAND_POOL, name);
- }
-
- void SetCommandBufferName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name)
- {
- SetObjectName(device, (uint64_t)cmdBuffer, VK_OBJECT_TYPE_COMMAND_BUFFER, name);
- }
-
- void SetQueueName(VkDevice device, VkQueue queue, const char * name)
- {
- SetObjectName(device, (uint64_t)queue, VK_OBJECT_TYPE_QUEUE, name);
- }
-
- void SetImageName(VkDevice device, VkImage image, const char * name)
- {
- SetObjectName(device, (uint64_t)image, VK_OBJECT_TYPE_IMAGE, name);
- }
-
- void SetImageViewName(VkDevice device, VkImageView imageView, const char * name)
- {
- SetObjectName(device, (uint64_t)imageView, VK_OBJECT_TYPE_IMAGE_VIEW, name);
- }
-
- void SetSamplerName(VkDevice device, VkSampler sampler, const char * name)
- {
- SetObjectName(device, (uint64_t)sampler, VK_OBJECT_TYPE_SAMPLER, name);
- }
-
- void SetBufferName(VkDevice device, VkBuffer buffer, const char * name)
- {
- SetObjectName(device, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER, name);
- }
-
- void SetBufferViewName(VkDevice device, VkBufferView bufferView, const char * name)
- {
- SetObjectName(device, (uint64_t)bufferView, VK_OBJECT_TYPE_BUFFER_VIEW, name);
- }
-
- void SetDeviceMemoryName(VkDevice device, VkDeviceMemory memory, const char * name)
- {
- SetObjectName(device, (uint64_t)memory, VK_OBJECT_TYPE_DEVICE_MEMORY, name);
- }
-
- void SetShaderModuleName(VkDevice device, VkShaderModule shaderModule, const char * name)
- {
- SetObjectName(device, (uint64_t)shaderModule, VK_OBJECT_TYPE_SHADER_MODULE, name);
- }
-
- void SetPipelineName(VkDevice device, VkPipeline pipeline, const char * name)
- {
- SetObjectName(device, (uint64_t)pipeline, VK_OBJECT_TYPE_PIPELINE, name);
- }
-
- void SetPipelineLayoutName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name)
- {
- SetObjectName(device, (uint64_t)pipelineLayout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, name);
- }
-
- void SetRenderPassName(VkDevice device, VkRenderPass renderPass, const char * name)
- {
- SetObjectName(device, (uint64_t)renderPass, VK_OBJECT_TYPE_RENDER_PASS, name);
- }
-
- void SetFramebufferName(VkDevice device, VkFramebuffer framebuffer, const char * name)
- {
- SetObjectName(device, (uint64_t)framebuffer, VK_OBJECT_TYPE_FRAMEBUFFER, name);
- }
-
- void SetDescriptorSetLayoutName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name)
- {
- SetObjectName(device, (uint64_t)descriptorSetLayout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, name);
- }
-
- void SetDescriptorSetName(VkDevice device, VkDescriptorSet descriptorSet, const char * name)
- {
- SetObjectName(device, (uint64_t)descriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET, name);
- }
-
- void SetDescriptorPoolName(VkDevice device, VkDescriptorPool descriptorPool, const char * name)
- {
- SetObjectName(device, (uint64_t)descriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL, name);
- }
-
- void SetSemaphoreName(VkDevice device, VkSemaphore semaphore, const char * name)
- {
- SetObjectName(device, (uint64_t)semaphore, VK_OBJECT_TYPE_SEMAPHORE, name);
- }
-
- void SetFenceName(VkDevice device, VkFence fence, const char * name)
- {
- SetObjectName(device, (uint64_t)fence, VK_OBJECT_TYPE_FENCE, name);
- }
-
- void SetEventName(VkDevice device, VkEvent _event, const char * name)
- {
- SetObjectName(device, (uint64_t)_event, VK_OBJECT_TYPE_EVENT, name);
- }
-
-
-
-
- void SetVulkanObjectName(VkDevice device, VkCommandPool cmdPool, const char * name)
- {
- SetCommandPoolName(device, cmdPool, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name)
- {
- SetCommandBufferName(device, cmdBuffer, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkQueue queue, const char * name)
- {
- SetQueueName(device, queue, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkImage image, const char * name)
- {
- SetImageName(device, image, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkImageView imageView, const char * name)
- {
- SetImageViewName(device, imageView, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkSampler sampler, const char * name)
- {
- SetSamplerName(device, sampler, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkBuffer buffer, const char * name)
- {
- SetBufferName(device, buffer, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkBufferView bufferView, const char * name)
- {
- SetBufferViewName(device, bufferView, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkDeviceMemory memory, const char * name)
- {
- SetDeviceMemoryName(device, memory, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkShaderModule shaderModule, const char * name)
- {
- SetShaderModuleName(device, shaderModule, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkPipeline pipeline, const char * name)
- {
- SetPipelineName(device, pipeline, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name)
- {
- SetPipelineLayoutName(device, pipelineLayout, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkRenderPass renderPass, const char * name)
- {
- SetRenderPassName(device, renderPass, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkFramebuffer framebuffer, const char * name)
- {
- SetFramebufferName(device, framebuffer, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name)
- {
- SetDescriptorSetLayoutName(device, descriptorSetLayout, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkDescriptorSet descriptorSet, const char * name)
- {
- SetDescriptorSetName(device, descriptorSet, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkDescriptorPool descriptorPool, const char * name)
- {
- SetDescriptorPoolName(device, descriptorPool, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkSemaphore semaphore, const char * name)
- {
- SetSemaphoreName(device, semaphore, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkFence fence, const char * name)
- {
- SetFenceName(device, fence, name);
- }
-
- void SetVulkanObjectName(VkDevice device, VkEvent _event, const char * name)
- {
- SetEventName(device, _event, name);
- }
-
-
-
- const char* VkResultToString(VkResult errorCode)
- {
- switch (errorCode)
- {
-#define STR(r) case VK_ ##r: return #r
- STR(NOT_READY);
- STR(TIMEOUT);
- STR(EVENT_SET);
- STR(EVENT_RESET);
- STR(INCOMPLETE);
- STR(ERROR_OUT_OF_HOST_MEMORY);
- STR(ERROR_OUT_OF_DEVICE_MEMORY);
- STR(ERROR_INITIALIZATION_FAILED);
- STR(ERROR_DEVICE_LOST);
- STR(ERROR_MEMORY_MAP_FAILED);
- STR(ERROR_LAYER_NOT_PRESENT);
- STR(ERROR_EXTENSION_NOT_PRESENT);
- STR(ERROR_FEATURE_NOT_PRESENT);
- STR(ERROR_INCOMPATIBLE_DRIVER);
- STR(ERROR_TOO_MANY_OBJECTS);
- STR(ERROR_FORMAT_NOT_SUPPORTED);
- STR(ERROR_SURFACE_LOST_KHR);
- STR(ERROR_NATIVE_WINDOW_IN_USE_KHR);
- STR(SUBOPTIMAL_KHR);
- STR(ERROR_OUT_OF_DATE_KHR);
- STR(ERROR_INCOMPATIBLE_DISPLAY_KHR);
- STR(ERROR_VALIDATION_FAILED_EXT);
- STR(ERROR_INVALID_SHADER_NV);
-#undef STR
- default:
- return "UNKNOWN_ERROR";
- }
- }
-
- const char* VkAccessFlagBitToString(VkAccessFlagBits Bit)
- {
- VERIFY(Bit != 0 && (Bit & (Bit-1)) == 0, "Single bit is expected");
- switch(Bit)
- {
-#define ACCESS_FLAG_BIT_TO_STRING(ACCESS_FLAG_BIT)case ACCESS_FLAG_BIT: return #ACCESS_FLAG_BIT;
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_INDIRECT_COMMAND_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_INDEX_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_UNIFORM_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_INPUT_ATTACHMENT_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_SHADER_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_SHADER_WRITE_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_COLOR_ATTACHMENT_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_TRANSFER_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_TRANSFER_WRITE_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_HOST_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_HOST_WRITE_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_MEMORY_READ_BIT)
- ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_MEMORY_WRITE_BIT)
-#undef ACCESS_FLAG_BIT_TO_STRING
- default: UNEXPECTED("Unexpected bit"); return "";
- }
- }
-
- const char* VkImageLayoutToString(VkImageLayout Layout)
- {
- switch(Layout)
- {
-#define IMAGE_LAYOUT_TO_STRING(LAYOUT)case LAYOUT: return #LAYOUT;
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_UNDEFINED)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_GENERAL)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_PREINITIALIZED)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)
- IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR)
-#undef IMAGE_LAYOUT_TO_STRING
- default: UNEXPECTED("Unknown layout"); return "";
- }
- }
-
- std::string VkAccessFlagsToString(VkAccessFlags Flags)
- {
- std::string FlagsString;
- while(Flags != 0)
- {
- auto Bit = Flags & ~(Flags - 1);
- if (!FlagsString.empty())
- FlagsString += ", ";
- FlagsString += VkAccessFlagBitToString( static_cast<VkAccessFlagBits>(Bit) );
- Flags = Flags & (Flags - 1);
- }
- return std::move(FlagsString);
- }
-
- const char* VkObjectTypeToString(VkObjectType ObjectType)
- {
- switch(ObjectType)
- {
+ SetDebugUtilsObjectTagEXT(device, &tagInfo); + } + } + + void SetCommandPoolName(VkDevice device, VkCommandPool cmdPool, const char * name) + { + SetObjectName(device, (uint64_t)cmdPool, VK_OBJECT_TYPE_COMMAND_POOL, name); + } + + void SetCommandBufferName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name) + { + SetObjectName(device, (uint64_t)cmdBuffer, VK_OBJECT_TYPE_COMMAND_BUFFER, name); + } + + void SetQueueName(VkDevice device, VkQueue queue, const char * name) + { + SetObjectName(device, (uint64_t)queue, VK_OBJECT_TYPE_QUEUE, name); + } + + void SetImageName(VkDevice device, VkImage image, const char * name) + { + SetObjectName(device, (uint64_t)image, VK_OBJECT_TYPE_IMAGE, name); + } + + void SetImageViewName(VkDevice device, VkImageView imageView, const char * name) + { + SetObjectName(device, (uint64_t)imageView, VK_OBJECT_TYPE_IMAGE_VIEW, name); + } + + void SetSamplerName(VkDevice device, VkSampler sampler, const char * name) + { + SetObjectName(device, (uint64_t)sampler, VK_OBJECT_TYPE_SAMPLER, name); + } + + void SetBufferName(VkDevice device, VkBuffer buffer, const char * name) + { + SetObjectName(device, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER, name); + } + + void SetBufferViewName(VkDevice device, VkBufferView bufferView, const char * name) + { + SetObjectName(device, (uint64_t)bufferView, VK_OBJECT_TYPE_BUFFER_VIEW, name); + } + + void SetDeviceMemoryName(VkDevice device, VkDeviceMemory memory, const char * name) + { + SetObjectName(device, (uint64_t)memory, VK_OBJECT_TYPE_DEVICE_MEMORY, name); + } + + void SetShaderModuleName(VkDevice device, VkShaderModule shaderModule, const char * name) + { + SetObjectName(device, (uint64_t)shaderModule, VK_OBJECT_TYPE_SHADER_MODULE, name); + } + + void SetPipelineName(VkDevice device, VkPipeline pipeline, const char * name) + { + SetObjectName(device, (uint64_t)pipeline, VK_OBJECT_TYPE_PIPELINE, name); + } + + void SetPipelineLayoutName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name) + { + SetObjectName(device, (uint64_t)pipelineLayout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, name); + } + + void SetRenderPassName(VkDevice device, VkRenderPass renderPass, const char * name) + { + SetObjectName(device, (uint64_t)renderPass, VK_OBJECT_TYPE_RENDER_PASS, name); + } + + void SetFramebufferName(VkDevice device, VkFramebuffer framebuffer, const char * name) + { + SetObjectName(device, (uint64_t)framebuffer, VK_OBJECT_TYPE_FRAMEBUFFER, name); + } + + void SetDescriptorSetLayoutName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name) + { + SetObjectName(device, (uint64_t)descriptorSetLayout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, name); + } + + void SetDescriptorSetName(VkDevice device, VkDescriptorSet descriptorSet, const char * name) + { + SetObjectName(device, (uint64_t)descriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET, name); + } + + void SetDescriptorPoolName(VkDevice device, VkDescriptorPool descriptorPool, const char * name) + { + SetObjectName(device, (uint64_t)descriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL, name); + } + + void SetSemaphoreName(VkDevice device, VkSemaphore semaphore, const char * name) + { + SetObjectName(device, (uint64_t)semaphore, VK_OBJECT_TYPE_SEMAPHORE, name); + } + + void SetFenceName(VkDevice device, VkFence fence, const char * name) + { + SetObjectName(device, (uint64_t)fence, VK_OBJECT_TYPE_FENCE, name); + } + + void SetEventName(VkDevice device, VkEvent _event, const char * name) + { + SetObjectName(device, (uint64_t)_event, VK_OBJECT_TYPE_EVENT, name); + } + + + + + void SetVulkanObjectName(VkDevice device, VkCommandPool cmdPool, const char * name) + { + SetCommandPoolName(device, cmdPool, name); + } + + void SetVulkanObjectName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name) + { + SetCommandBufferName(device, cmdBuffer, name); + } + + void SetVulkanObjectName(VkDevice device, VkQueue queue, const char * name) + { + SetQueueName(device, queue, name); + } + + void SetVulkanObjectName(VkDevice device, VkImage image, const char * name) + { + SetImageName(device, image, name); + } + + void SetVulkanObjectName(VkDevice device, VkImageView imageView, const char * name) + { + SetImageViewName(device, imageView, name); + } + + void SetVulkanObjectName(VkDevice device, VkSampler sampler, const char * name) + { + SetSamplerName(device, sampler, name); + } + + void SetVulkanObjectName(VkDevice device, VkBuffer buffer, const char * name) + { + SetBufferName(device, buffer, name); + } + + void SetVulkanObjectName(VkDevice device, VkBufferView bufferView, const char * name) + { + SetBufferViewName(device, bufferView, name); + } + + void SetVulkanObjectName(VkDevice device, VkDeviceMemory memory, const char * name) + { + SetDeviceMemoryName(device, memory, name); + } + + void SetVulkanObjectName(VkDevice device, VkShaderModule shaderModule, const char * name) + { + SetShaderModuleName(device, shaderModule, name); + } + + void SetVulkanObjectName(VkDevice device, VkPipeline pipeline, const char * name) + { + SetPipelineName(device, pipeline, name); + } + + void SetVulkanObjectName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name) + { + SetPipelineLayoutName(device, pipelineLayout, name); + } + + void SetVulkanObjectName(VkDevice device, VkRenderPass renderPass, const char * name) + { + SetRenderPassName(device, renderPass, name); + } + + void SetVulkanObjectName(VkDevice device, VkFramebuffer framebuffer, const char * name) + { + SetFramebufferName(device, framebuffer, name); + } + + void SetVulkanObjectName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name) + { + SetDescriptorSetLayoutName(device, descriptorSetLayout, name); + } + + void SetVulkanObjectName(VkDevice device, VkDescriptorSet descriptorSet, const char * name) + { + SetDescriptorSetName(device, descriptorSet, name); + } + + void SetVulkanObjectName(VkDevice device, VkDescriptorPool descriptorPool, const char * name) + { + SetDescriptorPoolName(device, descriptorPool, name); + } + + void SetVulkanObjectName(VkDevice device, VkSemaphore semaphore, const char * name) + { + SetSemaphoreName(device, semaphore, name); + } + + void SetVulkanObjectName(VkDevice device, VkFence fence, const char * name) + { + SetFenceName(device, fence, name); + } + + void SetVulkanObjectName(VkDevice device, VkEvent _event, const char * name) + { + SetEventName(device, _event, name); + } + + + + const char* VkResultToString(VkResult errorCode) + { + switch (errorCode) + { +#define STR(r) case VK_ ##r: return #r + STR(NOT_READY); + STR(TIMEOUT); + STR(EVENT_SET); + STR(EVENT_RESET); + STR(INCOMPLETE); + STR(ERROR_OUT_OF_HOST_MEMORY); + STR(ERROR_OUT_OF_DEVICE_MEMORY); + STR(ERROR_INITIALIZATION_FAILED); + STR(ERROR_DEVICE_LOST); + STR(ERROR_MEMORY_MAP_FAILED); + STR(ERROR_LAYER_NOT_PRESENT); + STR(ERROR_EXTENSION_NOT_PRESENT); + STR(ERROR_FEATURE_NOT_PRESENT); + STR(ERROR_INCOMPATIBLE_DRIVER); + STR(ERROR_TOO_MANY_OBJECTS); + STR(ERROR_FORMAT_NOT_SUPPORTED); + STR(ERROR_SURFACE_LOST_KHR); + STR(ERROR_NATIVE_WINDOW_IN_USE_KHR); + STR(SUBOPTIMAL_KHR); + STR(ERROR_OUT_OF_DATE_KHR); + STR(ERROR_INCOMPATIBLE_DISPLAY_KHR); + STR(ERROR_VALIDATION_FAILED_EXT); + STR(ERROR_INVALID_SHADER_NV); +#undef STR + default: + return "UNKNOWN_ERROR"; + } + } + + const char* VkAccessFlagBitToString(VkAccessFlagBits Bit) + { + VERIFY(Bit != 0 && (Bit & (Bit-1)) == 0, "Single bit is expected"); + switch(Bit) + { +#define ACCESS_FLAG_BIT_TO_STRING(ACCESS_FLAG_BIT)case ACCESS_FLAG_BIT: return #ACCESS_FLAG_BIT; + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_INDIRECT_COMMAND_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_INDEX_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_UNIFORM_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_INPUT_ATTACHMENT_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_SHADER_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_SHADER_WRITE_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_COLOR_ATTACHMENT_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_TRANSFER_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_TRANSFER_WRITE_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_HOST_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_HOST_WRITE_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_MEMORY_READ_BIT) + ACCESS_FLAG_BIT_TO_STRING(VK_ACCESS_MEMORY_WRITE_BIT) +#undef ACCESS_FLAG_BIT_TO_STRING + default: UNEXPECTED("Unexpected bit"); return ""; + } + } + + const char* VkImageLayoutToString(VkImageLayout Layout) + { + switch(Layout) + { +#define IMAGE_LAYOUT_TO_STRING(LAYOUT)case LAYOUT: return #LAYOUT; + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_UNDEFINED) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_GENERAL) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_PREINITIALIZED) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_PRESENT_SRC_KHR) + IMAGE_LAYOUT_TO_STRING(VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR) +#undef IMAGE_LAYOUT_TO_STRING + default: UNEXPECTED("Unknown layout"); return ""; + } + } + + std::string VkAccessFlagsToString(VkAccessFlags Flags) + { + std::string FlagsString; + while(Flags != 0) + { + auto Bit = Flags & ~(Flags - 1); + if (!FlagsString.empty()) + FlagsString += ", "; + FlagsString += VkAccessFlagBitToString( static_cast<VkAccessFlagBits>(Bit) ); + Flags = Flags & (Flags - 1); + } + return std::move(FlagsString); + } + + const char* VkObjectTypeToString(VkObjectType ObjectType) + { + switch(ObjectType) + { case VK_OBJECT_TYPE_UNKNOWN: return "unknown"; case VK_OBJECT_TYPE_INSTANCE: return "instance"; case VK_OBJECT_TYPE_PHYSICAL_DEVICE: return "physical device"; @@ -616,7 +618,7 @@ namespace VulkanUtilities case VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT: return "debug utils messenger"; case VK_OBJECT_TYPE_VALIDATION_CACHE_EXT: return "validation cache"; case VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_NVX: return "acceleration structure NVX"; - default: return "unknown";
- }
- }
-}
+ default: return "unknown"; + } + } +} diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanFencePool.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanFencePool.cpp index 1467a1db..7b3662b8 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanFencePool.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanFencePool.cpp @@ -34,10 +34,12 @@ namespace VulkanUtilities VulkanFencePool::~VulkanFencePool() { +#ifdef DEVELOPMENT for (const auto& fence : m_Fences) { DEV_CHECK_ERR(m_LogicalDevice->GetFenceStatus(fence) == VK_SUCCESS, "Destroying a fence that has not been signaled"); } +#endif m_Fences.clear(); } diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp index 5a1e9c47..a2d28bd7 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp @@ -65,7 +65,7 @@ namespace VulkanUtilities void VulkanLogicalDevice::WaitIdle()const { auto err = vkDeviceWaitIdle(m_VkDevice); - DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to idle device"); + DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to idle device"); (void)err; } template<typename VkObjectType, typename VkCreateObjectFuncType, typename VkObjectCreateInfoType> @@ -80,7 +80,7 @@ namespace VulkanUtilities VkObjectType VkObject = VK_NULL_HANDLE; auto err = VkCreateObject(m_VkDevice, &CreateInfo, m_VkAllocator, &VkObject); CHECK_VK_ERROR_AND_THROW(err, "Failed to create Vulkan ", ObjectType, " '", DebugName, '\''); - + if (DebugName != nullptr && *DebugName != 0) SetVulkanObjectName(m_VkDevice, VkObject, DebugName); @@ -242,7 +242,7 @@ namespace VulkanUtilities VkCommandBuffer CmdBuff = VK_NULL_HANDLE; auto err = vkAllocateCommandBuffers(m_VkDevice, &AllocInfo, &CmdBuff); - DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to allocate command buffer '", DebugName, '\''); + DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to allocate command buffer '", DebugName, '\''); (void)err; if (DebugName != nullptr && *DebugName != 0) SetCommandBufferName(m_VkDevice, CmdBuff, DebugName); diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp index cad556aa..c368fb2e 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp @@ -56,7 +56,7 @@ namespace VulkanUtilities { m_SupportedExtensions.resize(ExtensionCount); auto res = vkEnumerateDeviceExtensionProperties(m_VkDevice, nullptr, &ExtensionCount, m_SupportedExtensions.data()); - VERIFY_EXPR(res == VK_SUCCESS); + VERIFY_EXPR(res == VK_SUCCESS); (void)res; VERIFY_EXPR(ExtensionCount == m_SupportedExtensions.size()); } } @@ -110,13 +110,15 @@ namespace VulkanUtilities { if (QueueFlags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT)) { - const auto &Props = m_QueueFamilyProperties[FamilyInd]; +#ifdef _DEBUG + const auto& Props = m_QueueFamilyProperties[FamilyInd]; // Queues supporting graphics and/or compute operations must report (1,1,1) // in minImageTransferGranularity, meaning that there are no additional restrictions // on the granularity of image transfer operations for these queues (4.1). VERIFY_EXPR(Props.minImageTransferGranularity.width == 1 && Props.minImageTransferGranularity.height == 1 && Props.minImageTransferGranularity.depth == 1); +#endif } } else diff --git a/Platforms/Basic/src/StandardFile.cpp b/Platforms/Basic/src/StandardFile.cpp index ef4e1a28..1f8b41a4 100644 --- a/Platforms/Basic/src/StandardFile.cpp +++ b/Platforms/Basic/src/StandardFile.cpp @@ -55,7 +55,7 @@ void StandardFile::Read(Diligent::IDataBlob *pData) auto FileSize = GetSize(); pData->Resize(FileSize); auto Res = Read(pData->GetDataPtr(), pData->GetSize()); - VERIFY(Res, "Failed to read ", FileSize, " bytes from file"); + VERIFY(Res, "Failed to read ", FileSize, " bytes from file"); (void)Res; } bool StandardFile::Read(void *Data, size_t BufferSize) |
