From 2b6a43bc5a5ebcb2e46fad395c2778b27d0bdb01 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 25 Nov 2018 13:02:49 -0800 Subject: Closed https://github.com/DiligentGraphics/DiligentCore/issues/15 Fixed issue with mapping dynamic buffer in Vk --- Graphics/GraphicsEngine/include/TextureBase.h | 24 +++++++++++++++--------- Graphics/GraphicsEngine/interface/TextureView.h | 5 ++++- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/TextureBase.h b/Graphics/GraphicsEngine/include/TextureBase.h index 1a9e11c1..23eb1078 100644 --- a/Graphics/GraphicsEngine/include/TextureBase.h +++ b/Graphics/GraphicsEngine/include/TextureBase.h @@ -214,13 +214,16 @@ protected: template void TextureBase :: CorrectTextureViewDesc(struct TextureViewDesc& ViewDesc) { -#define TEX_VIEW_VALIDATION_ERROR(...) LOG_ERROR_AND_THROW( "Texture view \"", ViewDesc.Name ? ViewDesc.Name : "", "\": ", ##__VA_ARGS__ ) +#define TEX_VIEW_VALIDATION_ERROR(...) LOG_ERROR_AND_THROW( "Texture view '", ViewDesc.Name ? ViewDesc.Name : "", "': ", ##__VA_ARGS__ ) if( !(ViewDesc.ViewType > TEXTURE_VIEW_UNDEFINED && ViewDesc.ViewType < TEXTURE_VIEW_NUM_VIEWS) ) TEX_VIEW_VALIDATION_ERROR( "Texture view type is not specified" ); - if( ViewDesc.MostDetailedMip + ViewDesc.NumMipLevels > this->m_Desc.MipLevels ) - TEX_VIEW_VALIDATION_ERROR( "Most detailed mip (", ViewDesc.MostDetailedMip, ") and number of mip levels in the view (", ViewDesc.NumMipLevels, ") specify more levels than target texture has (", this->m_Desc.MipLevels, ")" ); + if( ViewDesc.MostDetailedMip >= this->m_Desc.MipLevels ) + TEX_VIEW_VALIDATION_ERROR( "Most detailed mip (", ViewDesc.MostDetailedMip, ") is out of range. Texture '", this->m_Desc.Name, "' has only ", this->m_Desc.MipLevels, " mip ", (this->m_Desc.MipLevels >= 1 ? "levels." : "level.")); + + if( ViewDesc.NumMipLevels != TextureViewDesc::RemainingMipLevels && ViewDesc.MostDetailedMip + ViewDesc.NumMipLevels > this->m_Desc.MipLevels ) + TEX_VIEW_VALIDATION_ERROR( "Most detailed mip (", ViewDesc.MostDetailedMip, ") and number of mip levels in the view (", ViewDesc.NumMipLevels, ") is out of range. Texture '", this->m_Desc.Name, "' has only ", this->m_Desc.MipLevels, " mip ", (this->m_Desc.MipLevels >= 1 ? "levels." : "level.")); if( ViewDesc.Format == TEX_FORMAT_UNKNOWN ) ViewDesc.Format = GetDefaultTextureViewFormat( this->m_Desc.Format, ViewDesc.ViewType, this->m_Desc.BindFlags ); @@ -340,7 +343,7 @@ void TextureBase 1) + if(ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices && ViewDesc.NumArraySlices > 1) TEX_VIEW_VALIDATION_ERROR( "Number of slices in the view (", ViewDesc.NumArraySlices, ") must be 1 (or 0) for non-array texture 1D/2D views" ); } else if( ViewDesc.TextureDim == RESOURCE_DIM_TEX_1D_ARRAY || @@ -367,7 +370,10 @@ void TextureBase this->m_Desc.ArraySize ) + if( ViewDesc.FirstArraySlice >= this->m_Desc.ArraySize ) + TEX_VIEW_VALIDATION_ERROR( "First array slice (", ViewDesc.FirstArraySlice, ") exceeds the number of slices in the texture array (", this->m_Desc.ArraySize, ")" ); + + if( ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices && ViewDesc.FirstArraySlice + ViewDesc.NumArraySlices > this->m_Desc.ArraySize ) TEX_VIEW_VALIDATION_ERROR( "First slice (", ViewDesc.FirstArraySlice, ") and number of slices in the view (", ViewDesc.NumArraySlices, ") specify more slices than target texture has (", this->m_Desc.ArraySize, ")" ); } else if( ViewDesc.TextureDim == RESOURCE_DIM_TEX_3D ) @@ -388,7 +394,7 @@ void TextureBasem_Desc.MipLevels - ViewDesc.MostDetailedMip; @@ -396,7 +402,7 @@ void TextureBase(-1); + static constexpr Uint32 RemainingArraySlices = static_cast(-1); + /// Describes the texture view type, see Diligent::TEXTURE_VIEW_TYPE for details. TEXTURE_VIEW_TYPE ViewType; @@ -111,7 +114,7 @@ struct TextureViewDesc : DeviceObjectAttribs /// Member | Default value /// --------------------|-------------- /// ViewType | TEXTURE_VIEW_UNDEFINED - /// TextureDim | RESOURCE_DIM_UNDEFINED + /// TextureDim | RESOURCE_DIM_UNDEFINED /// Format | TEX_FORMAT_UNKNOWN /// MostDetailedMip | 0 /// NumMipLevels | 0 -- cgit v1.2.3