From e9963a8d675a251b8d28d3da2a5678f217709782 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 2 Sep 2018 12:03:43 -0700 Subject: Implemented texture mapping in Vulkan (fixed https://github.com/DiligentGraphics/DiligentCore/issues/28) --- Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h | 8 ++++---- Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h index bfde19bb..ea70fc8a 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h @@ -212,25 +212,25 @@ private: std::vector > > m_PendingFences; - struct TextureUploadAllocationKey + struct MappedTextureKey { TextureD3D12Impl* const Texture; UINT const Subresource; - bool operator == (const TextureUploadAllocationKey& rhs)const + bool operator == (const MappedTextureKey& rhs)const { return Texture == rhs.Texture && Subresource == rhs.Subresource; } struct Hasher { - size_t operator()(const TextureUploadAllocationKey& Key)const + size_t operator()(const MappedTextureKey& Key)const { return ComputeHash(Key.Texture, Key.Subresource); } }; }; - std::unordered_map m_TextureUploadAllocations; + std::unordered_map m_MappedTextures; }; } diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 52898a5d..1f7ab435 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -933,13 +933,12 @@ namespace Diligent { const auto& TexDesc = TextureD3D12.GetDesc(); auto UploadSpace = AllocateTextureUploadSpace(TexDesc.Format, MapRegion); - const auto AlignedOffset = (UploadSpace.Allocation.Offset + (D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT-1)) & ~(D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT-1); MappedData.pData = reinterpret_cast(UploadSpace.Allocation.CPUAddress) + (UploadSpace.AlignedOffset - UploadSpace.Allocation.Offset); MappedData.Stride = UploadSpace.Stride; MappedData.DepthStride = UploadSpace.DepthStride; auto Subres = D3D12CalcSubresource(MipLevel, ArraySlice, 0, TexDesc.MipLevels, TexDesc.ArraySize); - auto it = m_TextureUploadAllocations.emplace(TextureUploadAllocationKey{&TextureD3D12, Subres}, std::move(UploadSpace)); + auto it = m_MappedTextures.emplace(MappedTextureKey{&TextureD3D12, Subres}, std::move(UploadSpace)); if(!it.second) LOG_ERROR_MESSAGE("Mip level ", MipLevel, ", slice ", ArraySlice, " of texture '", TexDesc.Name, "' has already been mapped"); } @@ -950,8 +949,8 @@ namespace Diligent { const auto& TexDesc = TextureD3D12.GetDesc(); auto Subres = D3D12CalcSubresource(MipLevel, ArraySlice, 0, TexDesc.MipLevels, TexDesc.ArraySize); - auto UploadSpaceIt = m_TextureUploadAllocations.find(TextureUploadAllocationKey{&TextureD3D12, Subres}); - if(UploadSpaceIt != m_TextureUploadAllocations.end()) + auto UploadSpaceIt = m_MappedTextures.find(MappedTextureKey{&TextureD3D12, Subres}); + if(UploadSpaceIt != m_MappedTextures.end()) { auto& UploadSpace = UploadSpaceIt->second; CopyTextureRegion(UploadSpace.Allocation.pBuffer, @@ -962,7 +961,7 @@ namespace Diligent TextureD3D12, Subres, UploadSpace.Region); - m_TextureUploadAllocations.erase(UploadSpaceIt); + m_MappedTextures.erase(UploadSpaceIt); } else { -- cgit v1.2.3