diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-11-25 21:02:49 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-11-25 21:02:49 +0000 |
| commit | 2b6a43bc5a5ebcb2e46fad395c2778b27d0bdb01 (patch) | |
| tree | 7490f75975fb368e38f784c71c50b82daf498ca5 /Graphics/GraphicsEngine | |
| parent | Renamed/moved IBuffer::Map() to IDeviceContext::MapBuffer() (diff) | |
| download | DiligentCore-2b6a43bc5a5ebcb2e46fad395c2778b27d0bdb01.tar.gz DiligentCore-2b6a43bc5a5ebcb2e46fad395c2778b27d0bdb01.zip | |
Closed https://github.com/DiligentGraphics/DiligentCore/issues/15
Fixed issue with mapping dynamic buffer in Vk
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/include/TextureBase.h | 24 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/TextureView.h | 5 |
2 files changed, 19 insertions, 10 deletions
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<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: 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<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj { if(ViewDesc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE) TEX_VIEW_VALIDATION_ERROR( "Unexpected view type: SRV is expected"); - if(ViewDesc.NumArraySlices != 6 && ViewDesc.NumArraySlices != 0) + if(ViewDesc.NumArraySlices != 6 && ViewDesc.NumArraySlices != 0 && ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices) TEX_VIEW_VALIDATION_ERROR( "Texture cube SRV is expected to have 6 array slices, while ", ViewDesc.NumArraySlices, " is provided" ); if(ViewDesc.FirstArraySlice != 0) TEX_VIEW_VALIDATION_ERROR( "First slice (", ViewDesc.FirstArraySlice, ") must be 0 for non-array texture cube SRV" ); @@ -349,7 +352,7 @@ void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj { if(ViewDesc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE ) TEX_VIEW_VALIDATION_ERROR( "Unexpected view type: SRV is expected"); - if((ViewDesc.NumArraySlices % 6) != 0) + if(ViewDesc.NumArraySlices != TextureViewDesc::RemainingArraySlices && (ViewDesc.NumArraySlices % 6) != 0) TEX_VIEW_VALIDATION_ERROR( "Number of slices in texture cube array SRV is expected to be multiple of 6. ", ViewDesc.NumArraySlices, " slices provided." ); } @@ -359,7 +362,7 @@ void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj if(ViewDesc.FirstArraySlice != 0) TEX_VIEW_VALIDATION_ERROR( "First slice (", ViewDesc.FirstArraySlice, ") must be 0 for non-array texture 1D/2D views" ); - if(ViewDesc.NumArraySlices > 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<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE || ViewDesc.TextureDim == RESOURCE_DIM_TEX_CUBE_ARRAY ) { - if( ViewDesc.FirstArraySlice + ViewDesc.NumArraySlices > 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 TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj #undef TEX_VIEW_VALIDATION_ERROR - if( ViewDesc.NumMipLevels == 0 ) + if( ViewDesc.NumMipLevels == 0 || ViewDesc.NumMipLevels == TextureViewDesc::RemainingMipLevels ) { if( ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE ) ViewDesc.NumMipLevels = this->m_Desc.MipLevels - ViewDesc.MostDetailedMip; @@ -396,7 +402,7 @@ void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObj ViewDesc.NumMipLevels = 1; } - if( ViewDesc.NumArraySlices == 0 ) + if( ViewDesc.NumArraySlices == 0 || ViewDesc.NumArraySlices == TextureViewDesc::RemainingArraySlices ) { if( ViewDesc.TextureDim == RESOURCE_DIM_TEX_1D_ARRAY || ViewDesc.TextureDim == RESOURCE_DIM_TEX_2D_ARRAY || diff --git a/Graphics/GraphicsEngine/interface/TextureView.h b/Graphics/GraphicsEngine/interface/TextureView.h index 3141e9be..6b7de1f7 100644 --- a/Graphics/GraphicsEngine/interface/TextureView.h +++ b/Graphics/GraphicsEngine/interface/TextureView.h @@ -56,6 +56,9 @@ enum UAV_ACCESS_FLAG : Int32 /// Texture view description struct TextureViewDesc : DeviceObjectAttribs { + static constexpr Uint32 RemainingMipLevels = static_cast<Uint32>(-1); + static constexpr Uint32 RemainingArraySlices = static_cast<Uint32>(-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 |
