diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-04-19 15:11:58 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-04-19 15:11:58 +0000 |
| commit | 3f81d1daa7b13e935cf43a6af30367f2b39c09bf (patch) | |
| tree | 6203a390741d2179acca18397eced96af33167cb /Graphics/GraphicsEngineVulkan | |
| parent | Fixed parameter issue in ALLOCATE macro (diff) | |
| download | DiligentCore-3f81d1daa7b13e935cf43a6af30367f2b39c09bf.tar.gz DiligentCore-3f81d1daa7b13e935cf43a6af30367f2b39c09bf.zip | |
Fixed issues with multi-mip level staging resource in Vk and D3D12 back-ends
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h | 10 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp | 21 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp | 28 |
3 files changed, 11 insertions, 48 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h index d3d0883a..39ec0ea1 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h @@ -38,16 +38,6 @@ namespace Diligent class FixedBlockMemoryAllocator; -struct MipLevelProperties -{ - Uint32 Width = 0; - Uint32 Height = 0; - Uint32 Depth = 1; - Uint32 RowSize = 0; - Uint32 MipSize = 0; -}; - -MipLevelProperties GetMipLevelProperties(const TextureDesc& TexDesc, Uint32 MipLevel); Uint32 GetStagingDataOffset(const TextureDesc& TexDesc, Uint32 ArraySlice, Uint32 MipLevel); /// Base implementation of the Diligent::ITextureVk interface diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index ee6331fb..865d4177 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -31,6 +31,7 @@ #include "BufferVkImpl.h" #include "VulkanTypeConversions.h" #include "CommandListVkImpl.h" +#include "GraphicsAccessories.h" namespace Diligent { @@ -1331,12 +1332,10 @@ namespace Diligent Box FullMipBox; if (pSrcBox == nullptr) { - FullMipBox.MaxX = std::max(DstTexDesc.Width >> CopyAttribs.SrcMipLevel, 1u); - FullMipBox.MaxY = std::max(DstTexDesc.Height >> CopyAttribs.SrcMipLevel, 1u); - if(DstTexDesc.Type == RESOURCE_DIM_TEX_3D) - FullMipBox.MaxZ = std::max(DstTexDesc.Depth >> CopyAttribs.SrcMipLevel, 1u); - else - FullMipBox.MaxZ = 1; + auto MipLevelAttribs = GetMipLevelProperties(SrcTexDesc, CopyAttribs.SrcMipLevel); + FullMipBox.MaxX = MipLevelAttribs.Width; + FullMipBox.MaxY = MipLevelAttribs.Height; + FullMipBox.MaxZ = MipLevelAttribs.Depth; pSrcBox = &FullMipBox; } const auto& DstFmtAttribs = GetTextureFormatAttribs(DstTexDesc.Format); @@ -1714,10 +1713,10 @@ namespace Diligent Box FullExtentBox; if (pMapRegion == nullptr) { - FullExtentBox.MaxX = std::max(TexDesc.Width >> MipLevel, 1u); - FullExtentBox.MaxY = std::max(TexDesc.Height >> MipLevel, 1u); - if (TexDesc.Type == RESOURCE_DIM_TEX_3D) - FullExtentBox.MaxZ = std::max(TexDesc.Depth >> MipLevel, 1u); + auto MipLevelAttribs = GetMipLevelProperties(TexDesc, MipLevel); + FullExtentBox.MaxX = MipLevelAttribs.Width; + FullExtentBox.MaxY = MipLevelAttribs.Height; + FullExtentBox.MaxZ = MipLevelAttribs.Depth; pMapRegion = &FullExtentBox; } @@ -1774,7 +1773,7 @@ namespace Diligent MappedData.pData = TextureVk.GetStagingDataCPUAddress() + MapStartOffset; MappedData.Stride = MipLevelAttribs.RowSize; - MappedData.DepthStride = MipLevelAttribs.RowSize * MipLevelAttribs.Height; + MappedData.DepthStride = MipLevelAttribs.DepthSliceSize; if (MapType == MAP_READ) { diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index c6f336ee..dfed36b9 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -30,37 +30,11 @@ #include "VulkanTypeConversions.h" #include "EngineMemory.h" #include "StringTools.h" +#include "GraphicsAccessories.h" namespace Diligent { -MipLevelProperties GetMipLevelProperties(const TextureDesc& TexDesc, Uint32 MipLevel) -{ - MipLevelProperties MipProps; - const auto& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format); - - MipProps.Width = std::max(TexDesc.Width >> MipLevel, 1u); - MipProps.Height = std::max(TexDesc.Height >> MipLevel, 1u); - MipProps.Depth = (TexDesc.Type == RESOURCE_DIM_TEX_3D) ? std::max(TexDesc.Depth >> MipLevel, 1u) : 1u; - if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED) - { - VERIFY_EXPR(FmtAttribs.BlockWidth > 1 && FmtAttribs.BlockHeight > 1); - VERIFY((FmtAttribs.BlockWidth & (FmtAttribs.BlockWidth-1)) == 0, "Compressed block widht is expected to be power of 2"); - VERIFY((FmtAttribs.BlockHeight & (FmtAttribs.BlockHeight-1)) == 0, "Compressed block widht is expected to be power of 2"); - // For block-compression formats, all parameters are still specified in texels rather than compressed texel blocks (18.4.1) - MipProps.Width = Align(MipProps.Width, Uint32{FmtAttribs.BlockWidth}); - MipProps.Height = Align(MipProps.Height,Uint32{FmtAttribs.BlockHeight}); - MipProps.RowSize = MipProps.Width / Uint32{FmtAttribs.BlockWidth} * Uint32{FmtAttribs.ComponentSize}; // ComponentSize is the block size - } - else - { - MipProps.RowSize = MipProps.Width * Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - } - MipProps.MipSize = MipProps.RowSize * MipProps.Height * MipProps.Depth; - - return MipProps; -} - TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, RenderDeviceVkImpl* pRenderDeviceVk, |
