summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-11-25 04:31:42 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-11-25 04:31:42 +0000
commit17b24246757390d29be93ce3447745e7b4936f5a (patch)
tree7c0ad81014bd2c61debf7f3b4c89c445eab73beb /Graphics/GraphicsEngineD3D12
parentUpdated parameter order of IDeviceContext::CopyBuffer (diff)
downloadDiligentCore-17b24246757390d29be93ce3447745e7b4936f5a.tar.gz
DiligentCore-17b24246757390d29be93ce3447745e7b4936f5a.zip
Renamed/moved ITexture::Map() to IDeviceContext::MapTextureSubresource()
Renamed/moved ITexture::Unmap() to IDeviceContext::UnmapTextureSubresource()
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h29
-rw-r--r--Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h9
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp47
-rw-r--r--Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp43
4 files changed, 46 insertions, 82 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
index 004b2757..893545c9 100644
--- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
@@ -105,6 +105,16 @@ public:
Uint32 DstY,
Uint32 DstZ)override final;
+ virtual void MapTextureSubresource( ITexture* pTexture,
+ Uint32 MipLevel,
+ Uint32 ArraySlice,
+ MAP_TYPE MapType,
+ Uint32 MapFlags,
+ const Box* pMapRegion,
+ MappedTextureSubresource& MappedData )override final;
+
+ virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)override final;
+
virtual void FinishFrame()override final;
virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)override final;
@@ -119,17 +129,10 @@ public:
virtual void TransitionBufferState(IBuffer *pBuffer, D3D12_RESOURCE_STATES State)override final;
- ///// Clears the state caches. This function is called once per frame
- ///// (before present) to release all outstanding objects
- ///// that are only kept alive by references in the cache
- //void ClearShaderStateCache();
-
///// Number of different shader types (Vertex, Pixel, Geometry, Domain, Hull, Compute)
//static constexpr int NumShaderTypes = 6;
void UpdateBufferRegion(class BufferD3D12Impl *pBuffD3D12, D3D12DynamicAllocation& Allocation, Uint64 DstOffset, Uint64 NumBytes);
- void UpdateBufferRegion(class BufferD3D12Impl *pBuffD3D12, const void *pData, Uint64 DstOffset, Uint64 NumBytes);
- void CopyBufferRegion(class BufferD3D12Impl *pSrcBuffD3D12, class BufferD3D12Impl *pDstBuffD3D12, Uint64 SrcOffset, Uint64 DstOffset, Uint64 NumBytes);
void CopyTextureRegion(class TextureD3D12Impl *pSrcTexture, Uint32 SrcSubResIndex, const D3D12_BOX* pD3D12SrcBox,
class TextureD3D12Impl *pDstTexture, Uint32 DstSubResIndex, Uint32 DstX, Uint32 DstY, Uint32 DstZ);
void CopyTextureRegion(IBuffer* pSrcBuffer,
@@ -155,18 +158,6 @@ public:
Uint32 DstSubResIndex,
const Box& DstBox);
- void MapTexture( class TextureD3D12Impl& TextureD3D12,
- Uint32 MipLevel,
- Uint32 ArraySlice,
- MAP_TYPE MapType,
- Uint32 MapFlags,
- const Box& MapRegion,
- MappedTextureSubresource& MappedData );
-
- void UnmapTexture( class TextureD3D12Impl& TextureD3D12,
- Uint32 MipLevel,
- Uint32 ArraySlice);
-
void GenerateMips(class TextureViewD3D12Impl *pTexView);
D3D12DynamicAllocation AllocateDynamicSpace(size_t NumBytes, size_t Alignment);
diff --git a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h
index 4d0e6468..af4dfc3a 100644
--- a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h
@@ -61,15 +61,6 @@ public:
virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final;
- virtual void Map( IDeviceContext* pContext,
- Uint32 MipLevel,
- Uint32 ArraySlice,
- MAP_TYPE MapType,
- Uint32 MapFlags,
- const Box* pMapRegion,
- MappedTextureSubresource& MappedData )override final;
- virtual void Unmap( IDeviceContext *pContext, Uint32 MipLevel, Uint32 ArraySlice)override final;
-
virtual ID3D12Resource* GetD3D12Texture(){ return GetD3D12Resource(); }
virtual void* GetNativeHandle()override final { return GetD3D12Texture(); }
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index ef523328..8bb084f9 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -1212,16 +1212,40 @@ namespace Diligent
DstBox);
}
- void DeviceContextD3D12Impl::MapTexture( TextureD3D12Impl& TextureD3D12,
- Uint32 MipLevel,
- Uint32 ArraySlice,
- MAP_TYPE MapType,
- Uint32 MapFlags,
- const Box& MapRegion,
- MappedTextureSubresource& MappedData )
+ void DeviceContextD3D12Impl::MapTextureSubresource( ITexture* pTexture,
+ Uint32 MipLevel,
+ Uint32 ArraySlice,
+ MAP_TYPE MapType,
+ Uint32 MapFlags,
+ const Box* pMapRegion,
+ MappedTextureSubresource& MappedData )
{
+ TDeviceContextBase::MapTextureSubresource(pTexture, MipLevel, ArraySlice, MapType, MapFlags, pMapRegion, MappedData);
+
+ if (MapType != MAP_WRITE)
+ {
+ LOG_ERROR("Textures can currently only be mapped for writing in D3D12 backend");
+ MappedData = MappedTextureSubresource{};
+ return;
+ }
+
+ if( (MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_DO_NOT_SYNCHRONIZE)) != 0 )
+ LOG_WARNING_MESSAGE_ONCE("Mapping textures with flags MAP_FLAG_DISCARD or MAP_FLAG_DO_NOT_SYNCHRONIZE has no effect in D3D12 backend");
+
+ auto& TextureD3D12 = *ValidatedCast<TextureD3D12Impl>(pTexture);
const auto& TexDesc = TextureD3D12.GetDesc();
- auto UploadSpace = AllocateTextureUploadSpace(TexDesc.Format, MapRegion);
+
+ 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);
+ pMapRegion = &FullExtentBox;
+ }
+
+ auto UploadSpace = AllocateTextureUploadSpace(TexDesc.Format, *pMapRegion);
MappedData.pData = reinterpret_cast<Uint8*>(UploadSpace.Allocation.CPUAddress) + (UploadSpace.AlignedOffset - UploadSpace.Allocation.Offset);
MappedData.Stride = UploadSpace.Stride;
MappedData.DepthStride = UploadSpace.DepthStride;
@@ -1232,10 +1256,11 @@ namespace Diligent
LOG_ERROR_MESSAGE("Mip level ", MipLevel, ", slice ", ArraySlice, " of texture '", TexDesc.Name, "' has already been mapped");
}
- void DeviceContextD3D12Impl::UnmapTexture( TextureD3D12Impl& TextureD3D12,
- Uint32 MipLevel,
- Uint32 ArraySlice)
+ void DeviceContextD3D12Impl::UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)
{
+ TDeviceContextBase::UnmapTextureSubresource( pTexture, MipLevel, ArraySlice);
+
+ TextureD3D12Impl& TextureD3D12 = *ValidatedCast<TextureD3D12Impl>(pTexture);
const auto& TexDesc = TextureD3D12.GetDesc();
auto Subres = D3D12CalcSubresource(MipLevel, ArraySlice, 0, TexDesc.MipLevels, TexDesc.ArraySize);
auto UploadSpaceIt = m_MappedTextures.find(MappedTextureKey{&TextureD3D12, Subres});
diff --git a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp
index 1497692a..cdc89e94 100644
--- a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp
@@ -420,49 +420,6 @@ TextureD3D12Impl :: ~TextureD3D12Impl()
pDeviceD3D12Impl->SafeReleaseDeviceObject(std::move(m_pd3d12Resource), m_Desc.CommandQueueMask);
}
-void TextureD3D12Impl :: Map( IDeviceContext* pContext,
- Uint32 MipLevel,
- Uint32 ArraySlice,
- MAP_TYPE MapType,
- Uint32 MapFlags,
- const Box* pMapRegion,
- MappedTextureSubresource& MappedData )
-{
- TTextureBase::Map(pContext, MipLevel, ArraySlice, MapType, MapFlags, pMapRegion, MappedData);
-
- auto* pDeviceContextD3D12 = ValidatedCast<DeviceContextD3D12Impl>(pContext);
- MappedData = MappedTextureSubresource{};
-
- Box FullExtentBox;
- if (pMapRegion == nullptr)
- {
- FullExtentBox.MaxX = std::max(m_Desc.Width >> MipLevel, 1u);
- FullExtentBox.MaxY = std::max(m_Desc.Height >> MipLevel, 1u);
- if (m_Desc.Type == RESOURCE_DIM_TEX_3D)
- FullExtentBox.MaxZ = std::max(m_Desc.Depth >> MipLevel, 1u);
- pMapRegion = &FullExtentBox;
- }
-
- if(MapType == MAP_WRITE)
- {
- if( (MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_DO_NOT_SYNCHRONIZE)) != 0 )
- LOG_WARNING_MESSAGE_ONCE("Mapping textures with flags MAP_FLAG_DISCARD or MAP_FLAG_DO_NOT_SYNCHRONIZE has no effect in D3D12 backend");
- pDeviceContextD3D12->MapTexture(*this, MipLevel, ArraySlice, MapType, MapFlags, *pMapRegion, MappedData);
- }
- else
- {
- LOG_ERROR("Textures can currently only be mapped for writing in D3D12 backend");
- }
-}
-
-void TextureD3D12Impl::Unmap(IDeviceContext* pContext, Uint32 MipLevel, Uint32 ArraySlice)
-{
- TTextureBase::Unmap(pContext, MipLevel, ArraySlice);
- auto* pDeviceContextD3D12 = ValidatedCast<DeviceContextD3D12Impl>(pContext);
- pDeviceContextD3D12->UnmapTexture(*this, MipLevel, ArraySlice);
-}
-
-
void TextureD3D12Impl::CreateSRV( TextureViewDesc& SRVDesc, D3D12_CPU_DESCRIPTOR_HANDLE SRVHandle )
{
VERIFY( SRVDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE, "Incorrect view type: shader resource is expected" );