From 5ee7aadba299a3ac8964d75ca0fa96e31b0cbe2e Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 3 Sep 2018 21:41:29 -0700 Subject: Fixed texture usage checks to avoid false warnings in OpenGL --- Graphics/GraphicsEngine/src/Texture.cpp | 1 - Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp | 3 +++ Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp | 2 ++ Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/src/Texture.cpp b/Graphics/GraphicsEngine/src/Texture.cpp index 3411ee20..62c66047 100644 --- a/Graphics/GraphicsEngine/src/Texture.cpp +++ b/Graphics/GraphicsEngine/src/Texture.cpp @@ -182,7 +182,6 @@ void ValidateUpdateDataParams( const TextureDesc& TexDesc, Uint32 MipLevel, Uint ValidateTextureRegion(TexDesc, MipLevel, Slice, DstBox); #ifdef DEVELOPMENT - VERIFY_TEX_PARAMS( TexDesc.Usage == USAGE_DEFAULT, "Only textures created with USAGE_DEFAULT can be updated with UpdateData()" ); VERIFY_TEX_PARAMS( TexDesc.SampleCount == 1, "Only non-multisampled textures can be updated with UpdateData()" ); VERIFY_TEX_PARAMS( (SubresData.Stride & 0x03) == 0, "Texture data stride (", SubresData.Stride, ") must be at least 32-bit aligned" ); VERIFY_TEX_PARAMS( (SubresData.DepthStride & 0x03) == 0, "Texture data depth stride (", SubresData.DepthStride, ") must be at least 32-bit aligned" ); diff --git a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp index e672cf86..cb257437 100644 --- a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp @@ -149,6 +149,9 @@ TextureBaseD3D11 :: ~TextureBaseD3D11() void TextureBaseD3D11::UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) { TTextureBase::UpdateData( pContext, MipLevel, Slice, DstBox, SubresData ); + // OpenGL backend uses UpdateData() to initialize textures, so we can't check the usage in ValidateUpdateDataParams() + DEV_CHECK_ERR( m_Desc.Usage == USAGE_DEFAULT, "Only USAGE_DEFAULT textures should be updated with UpdateData()" ); + if (SubresData.pSrcBuffer != nullptr) { LOG_ERROR("D3D11 does not support updating texture subresource from a GPU buffer"); diff --git a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp index 21eeeca4..96bdc406 100644 --- a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp @@ -408,6 +408,8 @@ void TextureD3D12Impl::UpdateData( IDeviceContext* pContext, const TextureSubResData& SubresData ) { TTextureBase::UpdateData( pContext, MipLevel, Slice, DstBox, SubresData ); + // OpenGL backend uses UpdateData() to initialize textures, so we can't check the usage in ValidateUpdateDataParams() + DEV_CHECK_ERR( m_Desc.Usage == USAGE_DEFAULT, "Only USAGE_DEFAULT textures should be updated with UpdateData()" ); Box BlockAlignedBox; const auto& FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index f975e8f7..b2487bda 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -483,6 +483,8 @@ TextureVkImpl :: ~TextureVkImpl() void TextureVkImpl::UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) { TTextureBase::UpdateData( pContext, MipLevel, Slice, DstBox, SubresData ); + // OpenGL backend uses UpdateData() to initialize textures, so we can't check the usage in ValidateUpdateDataParams() + DEV_CHECK_ERR( m_Desc.Usage == USAGE_DEFAULT, "Only USAGE_DEFAULT textures should be updated with UpdateData()" ); auto *pCtxVk = ValidatedCast(pContext); //pCtxVk->CopyTextureRegion(SubresData.pSrcBuffer, SubresData.Stride, SubresData.DepthStride, this, DstSubResIndex, DstBox); -- cgit v1.2.3