diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-11-24 23:45:15 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-11-24 23:45:15 +0000 |
| commit | df67308c3b1236ff4c9445a17393f665e1ddd452 (patch) | |
| tree | d7f21995a5154546234865764111da6a90cceee8 /Graphics/GraphicsEngineVulkan | |
| parent | Moved/renamed `IBuffer::UpdateData()` to `IDeviceContext::UpdateBuffer()` (diff) | |
| download | DiligentCore-df67308c3b1236ff4c9445a17393f665e1ddd452.tar.gz DiligentCore-df67308c3b1236ff4c9445a17393f665e1ddd452.zip | |
Renamed/moved ITexture::UpdateData() to IDeviceContext::UpdateTexture()
Renamed/moved IBuffer::CopyData() to IDeviceContext::CopyTexture()
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
4 files changed, 91 insertions, 90 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index c2176442..23761996 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -99,6 +99,19 @@ public: virtual void CopyBuffer(IBuffer *pSrcBuffer, IBuffer *pDstBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size)override final; + virtual void UpdateTexture(ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData)override final; + + virtual void CopyTexture(ITexture* pSrcTexture, + Uint32 SrcMipLevel, + Uint32 SrcSlice, + const Box* pSrcBox, + ITexture* pDstTexture, + Uint32 DstMipLevel, + Uint32 DstSlice, + Uint32 DstX, + Uint32 DstY, + Uint32 DstZ)override final; + virtual void FinishCommandList(class ICommandList** ppCommandList)override final; virtual void ExecuteCommandList(class ICommandList* pCommandList)override final; diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h index eddf48af..7bf6c4db 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h @@ -63,8 +63,6 @@ public: virtual void QueryInterface( const Diligent::INTERFACE_ID& IID, IObject** ppInterface )override; - virtual void UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData )override; - //virtual void CopyData(CTexture* pSrcTexture, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size); virtual void Map(IDeviceContext* pContext, Uint32 MipLevel, @@ -82,17 +80,6 @@ public: return vkImage; } - void CopyData(IDeviceContext* pContext, - ITexture* pSrcTexture, - Uint32 SrcMipLevel, - Uint32 SrcSlice, - const Box* pSrcBox, - Uint32 DstMipLevel, - Uint32 DstSlice, - Uint32 DstX, - Uint32 DstY, - Uint32 DstZ); - ITextureView* GetMipLevelSRV(Uint32 MipLevel) { return m_MipLevelSRV[MipLevel].get(); diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 3b2d961a..79590137 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -1280,6 +1280,84 @@ namespace Diligent ++m_State.NumCommands; } + void DeviceContextVkImpl::UpdateTexture(ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData) + { + TDeviceContextBase::UpdateTexture( pTexture, MipLevel, Slice, DstBox, SubresData ); + + auto* pTexVk = ValidatedCast<TextureVkImpl>(pTexture); + // OpenGL backend uses UpdateData() to initialize textures, so we can't check the usage in ValidateUpdateTextureParams() + DEV_CHECK_ERR( pTexVk->GetDesc().Usage == USAGE_DEFAULT, "Only USAGE_DEFAULT textures should be updated with UpdateData()" ); + + //pCtxVk->CopyTextureRegion(SubresData.pSrcBuffer, SubresData.Stride, SubresData.DepthStride, this, DstSubResIndex, DstBox); + UpdateTextureRegion(SubresData.pData, SubresData.Stride, SubresData.DepthStride, *pTexVk, MipLevel, Slice, DstBox); + } + + void DeviceContextVkImpl::CopyTexture(ITexture* pSrcTexture, + Uint32 SrcMipLevel, + Uint32 SrcSlice, + const Box* pSrcBox, + ITexture* pDstTexture, + Uint32 DstMipLevel, + Uint32 DstSlice, + Uint32 DstX, + Uint32 DstY, + Uint32 DstZ) + { + TDeviceContextBase::CopyTexture( pSrcTexture, SrcMipLevel, SrcSlice, pSrcBox, + pDstTexture, DstMipLevel, DstSlice, DstX, DstY, DstZ ); + + auto* pSrcTexVk = ValidatedCast<TextureVkImpl>( pSrcTexture ); + auto* pDstTexVk = ValidatedCast<TextureVkImpl>( pDstTexture ); + const auto& DstTexDesc = pDstTexVk->GetDesc(); + VkImageCopy CopyRegion = {}; + if( pSrcBox ) + { + CopyRegion.srcOffset.x = pSrcBox->MinX; + CopyRegion.srcOffset.y = pSrcBox->MinY; + CopyRegion.srcOffset.z = pSrcBox->MinZ; + CopyRegion.extent.width = pSrcBox->MaxX - pSrcBox->MinX; + CopyRegion.extent.height = std::max(pSrcBox->MaxY - pSrcBox->MinY, 1u); + CopyRegion.extent.depth = std::max(pSrcBox->MaxZ - pSrcBox->MinZ, 1u); + } + else + { + CopyRegion.srcOffset = VkOffset3D{0,0,0}; + CopyRegion.extent.width = std::max(DstTexDesc.Width >> SrcMipLevel, 1u); + CopyRegion.extent.height = std::max(DstTexDesc.Height >> SrcMipLevel, 1u); + if(DstTexDesc.Type == RESOURCE_DIM_TEX_3D) + CopyRegion.extent.depth = std::max(DstTexDesc.Depth >> SrcMipLevel, 1u); + else + CopyRegion.extent.depth = 1; + } + + const auto& FmtAttribs = GetDevice()->GetTextureFormatInfo(DstTexDesc.Format); + VkImageAspectFlags aspectMask = 0; + if (FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH) + aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + else if (FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH_STENCIL) + { + aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + } + else + aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + + CopyRegion.srcSubresource.baseArrayLayer = SrcSlice; + CopyRegion.srcSubresource.layerCount = 1; + CopyRegion.srcSubresource.mipLevel = SrcMipLevel; + CopyRegion.srcSubresource.aspectMask = aspectMask; + + CopyRegion.dstSubresource.baseArrayLayer = DstSlice; + CopyRegion.dstSubresource.layerCount = 1; + CopyRegion.dstSubresource.mipLevel = DstMipLevel; + CopyRegion.dstSubresource.aspectMask = aspectMask; + + CopyRegion.dstOffset.x = DstX; + CopyRegion.dstOffset.y = DstY; + CopyRegion.dstOffset.z = DstZ; + + CopyTextureRegion(pSrcTexVk, pDstTexVk, CopyRegion); + } + void DeviceContextVkImpl::CopyTextureRegion(TextureVkImpl *pSrcTexture, TextureVkImpl *pDstTexture, const VkImageCopy &CopyRegion) { EnsureVkCmdBuffer(); diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index f49e6629..f1169c04 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -494,83 +494,6 @@ TextureVkImpl :: ~TextureVkImpl() m_pDevice->SafeReleaseDeviceObject(std::move(m_MemoryAllocation), m_Desc.CommandQueueMask); } -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<DeviceContextVkImpl>(pContext); - //pCtxVk->CopyTextureRegion(SubresData.pSrcBuffer, SubresData.Stride, SubresData.DepthStride, this, DstSubResIndex, DstBox); - pCtxVk->UpdateTextureRegion(SubresData.pData, SubresData.Stride, SubresData.DepthStride, *this, MipLevel, Slice, DstBox); -} - -void TextureVkImpl :: CopyData(IDeviceContext* pContext, - ITexture* pSrcTexture, - Uint32 SrcMipLevel, - Uint32 SrcSlice, - const Box* pSrcBox, - Uint32 DstMipLevel, - Uint32 DstSlice, - Uint32 DstX, - Uint32 DstY, - Uint32 DstZ) -{ - TTextureBase::CopyData( pContext, pSrcTexture, SrcMipLevel, SrcSlice, pSrcBox, - DstMipLevel, DstSlice, DstX, DstY, DstZ ); - - auto *pSrcTexVk = ValidatedCast<TextureVkImpl>( pSrcTexture ); - - VkImageCopy CopyRegion = {}; - if( pSrcBox ) - { - CopyRegion.srcOffset.x = pSrcBox->MinX; - CopyRegion.srcOffset.y = pSrcBox->MinY; - CopyRegion.srcOffset.z = pSrcBox->MinZ; - CopyRegion.extent.width = pSrcBox->MaxX - pSrcBox->MinX; - CopyRegion.extent.height = std::max(pSrcBox->MaxY - pSrcBox->MinY, 1u); - CopyRegion.extent.depth = std::max(pSrcBox->MaxZ - pSrcBox->MinZ, 1u); - } - else - { - CopyRegion.srcOffset = VkOffset3D{0,0,0}; - CopyRegion.extent.width = std::max(m_Desc.Width >> SrcMipLevel, 1u); - CopyRegion.extent.height = std::max(m_Desc.Height >> SrcMipLevel, 1u); - if(m_Desc.Type == RESOURCE_DIM_TEX_3D) - CopyRegion.extent.depth = std::max(m_Desc.Depth >> SrcMipLevel, 1u); - else - CopyRegion.extent.depth = 1; - } - - const auto& FmtAttribs = GetDevice()->GetTextureFormatInfo(m_Desc.Format); - VkImageAspectFlags aspectMask = 0; - if (FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH) - aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; - else if (FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH_STENCIL) - { - aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; - } - else - aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - - CopyRegion.srcSubresource.baseArrayLayer = SrcSlice; - CopyRegion.srcSubresource.layerCount = 1; - CopyRegion.srcSubresource.mipLevel = SrcMipLevel; - CopyRegion.srcSubresource.aspectMask = aspectMask; - - CopyRegion.dstSubresource.baseArrayLayer = DstSlice; - CopyRegion.dstSubresource.layerCount = 1; - CopyRegion.dstSubresource.mipLevel = DstMipLevel; - CopyRegion.dstSubresource.aspectMask = aspectMask; - - CopyRegion.dstOffset.x = DstX; - CopyRegion.dstOffset.y = DstY; - CopyRegion.dstOffset.z = DstZ; - - auto *pCtxVk = ValidatedCast<DeviceContextVkImpl>(pContext); - pCtxVk->CopyTextureRegion(pSrcTexVk, this, CopyRegion); -} - void TextureVkImpl :: Map(IDeviceContext* pContext, Uint32 MipLevel, Uint32 ArraySlice, |
