summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsTools
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-04-09 04:18:30 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-04-09 04:18:30 +0000
commit3de54383619299c592bd4ab0e85d48ae8c9bd95f (patch)
treef541125dff7a2bd050596124505060dc63db361e /Graphics/GraphicsTools
parentUpdated ITextureUploader to allow synchronous execution (diff)
downloadDiligentCore-3de54383619299c592bd4ab0e85d48ae8c9bd95f.tar.gz
DiligentCore-3de54383619299c592bd4ab0e85d48ae8c9bd95f.zip
Added Texture uploader test plus fixed a bunch of issues
Diffstat (limited to 'Graphics/GraphicsTools')
-rw-r--r--Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp3
-rw-r--r--Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp8
-rw-r--r--Graphics/GraphicsTools/src/TextureUploaderGL.cpp27
3 files changed, 21 insertions, 17 deletions
diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp
index 5e47e3a7..10c178ee 100644
--- a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp
+++ b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp
@@ -384,7 +384,8 @@ void TextureUploaderD3D11::AllocateUploadBuffer(IDeviceContext* pContext
return;
}
- LOG_INFO_MESSAGE("TextureUploaderD3D11: created ", Desc.Width, 'x', Desc.Height, 'x', Desc.Depth, ' ', Desc.MipLevels, "-mip ",
+ LOG_INFO_MESSAGE("TextureUploaderD3D11: created ", Desc.Width, 'x', Desc.Height, 'x', Desc.Depth, ' ',
+ Desc.MipLevels, "-mip ", Desc.ArraySize, "-slice ",
m_pDevice->GetTextureFormatInfo(Desc.Format).Name, " staging texture");
pUploadBuffer = MakeNewRCObj<UploadBufferD3D11>()(Desc, pStagingTex);
diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp
index 043e05f6..85db9e93 100644
--- a/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp
+++ b/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp
@@ -181,7 +181,9 @@ struct TextureUploaderD3D12_Vk::InternalData
{
const auto& desc = it.first;
auto& FmtInfo = GetTextureFormatAttribs(desc.Format);
- LOG_INFO_MESSAGE("TextureUploaderD3D12_Vk: releasing ", it.second.size(), ' ', desc.Width, 'x', desc.Height, 'x', desc.Depth, ' ', FmtInfo.Name, " upload buffer(s) ");
+ LOG_INFO_MESSAGE("TextureUploaderD3D12_Vk: releasing ", it.second.size(), ' ',
+ desc.Width, 'x', desc.Height, 'x', desc.Depth, ' ', FmtInfo.Name,
+ " upload buffer(s)", (it.second.size() == 1 ? "" : "s"));
}
}
}
@@ -383,11 +385,12 @@ void TextureUploaderD3D12_Vk::AllocateUploadBuffer(IDeviceContext* pCont
if (!pUploadTexture)
{
TextureDesc StagingTexDesc;
- StagingTexDesc.Type = RESOURCE_DIM_TEX_2D;
+ StagingTexDesc.Type = Desc.ArraySize == 1 ? RESOURCE_DIM_TEX_2D : RESOURCE_DIM_TEX_2D_ARRAY;
StagingTexDesc.Width = Desc.Width;
StagingTexDesc.Height = Desc.Height;
StagingTexDesc.Format = Desc.Format;
StagingTexDesc.MipLevels = Desc.MipLevels;
+ StagingTexDesc.ArraySize = Desc.ArraySize;
StagingTexDesc.CPUAccessFlags = CPU_ACCESS_WRITE;
StagingTexDesc.Usage = USAGE_STAGING;
@@ -395,6 +398,7 @@ void TextureUploaderD3D12_Vk::AllocateUploadBuffer(IDeviceContext* pCont
m_pDevice->CreateTexture(StagingTexDesc, nullptr, &pStagingTexture);
LOG_INFO_MESSAGE("Created ", Desc.Width, "x", Desc.Height, 'x', Desc.Depth, ' ', Desc.MipLevels, "-mip ",
+ Desc.ArraySize, "-slice ",
GetTextureFormatAttribs(Desc.Format).Name, " staging texture");
pUploadTexture = MakeNewRCObj<UploadTexture>()(Desc, pStagingTexture);
diff --git a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp
index 485d5f8c..484d4f3d 100644
--- a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp
+++ b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp
@@ -53,25 +53,24 @@ public:
m_SubresourceStrides(Desc.MipLevels * Desc.ArraySize )
// clang-format on
{
- const auto& FmtAttribs = GetTextureFormatAttribs(Desc.Format);
- Uint32 SubRes = 0;
+ TextureDesc TexDesc;
+ TexDesc.Format = Desc.Format;
+ TexDesc.Width = Desc.Width;
+ TexDesc.Height = Desc.Height;
+ TexDesc.Depth = Desc.Depth;
+ TexDesc.Type = Desc.ArraySize == 1 ? RESOURCE_DIM_TEX_2D : RESOURCE_DIM_TEX_2D_ARRAY;
+
+ Uint32 SubRes = 0;
for (Uint32 Slice = 0; Slice < Desc.ArraySize; ++Slice)
{
for (Uint32 Mip = 0; Mip < Desc.MipLevels; ++Mip)
{
- auto MipWidth = std::max(Desc.Width >> Mip, 1u);
- auto MipHeight = std::max(Desc.Height >> Mip, 1u);
- if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
- {
- MipWidth = Align(MipWidth, Uint32{FmtAttribs.BlockWidth});
- MipHeight = Align(MipHeight, Uint32{FmtAttribs.BlockHeight});
- }
-
+ auto MipProps = GetMipLevelProperties(TexDesc, Mip);
// Stride must be 32-bit aligned in OpenGL
- auto RowStride = Align(MipWidth / Uint32{FmtAttribs.BlockWidth} * FmtAttribs.GetElementSize(), Uint32{4});
+ auto RowStride = Align(MipProps.RowSize, Uint32{4});
m_SubresourceStrides[SubRes] = RowStride;
- auto MipSize = MipHeight / Uint32{FmtAttribs.BlockHeight} * RowStride;
+ auto MipSize = MipProps.StorageHeight * RowStride;
m_SubresourceOffsets[SubRes + 1] = m_SubresourceOffsets[SubRes] + MipSize;
++SubRes;
}
@@ -293,7 +292,7 @@ void TextureUploaderGL::InternalData::Execute(IRenderDevice* pDevice,
TextureSubResData SubResData(pBuffer->m_pStagingBuffer, SrcOffset, SrcStride);
- auto MipLevelProps = GetMipLevelProperties(TexDesc, Mip);
+ auto MipLevelProps = GetMipLevelProperties(TexDesc, OperationInfo.DstMip + Mip);
Box DstBox;
DstBox.MaxX = MipLevelProps.LogicalWidth;
DstBox.MaxY = MipLevelProps.LogicalHeight;
@@ -336,7 +335,7 @@ void TextureUploaderGL::AllocateUploadBuffer(IDeviceContext* pContext,
{
pUploadBuffer = MakeNewRCObj<UploadBufferGL>()(Desc);
LOG_INFO_MESSAGE("TextureUploaderGL: created upload buffer for ", Desc.Width, 'x', Desc.Height, 'x',
- Desc.Depth, ' ', Desc.MipLevels, "-mip ",
+ Desc.Depth, ' ', Desc.MipLevels, "-mip ", Desc.ArraySize, "-slice ",
m_pDevice->GetTextureFormatInfo(Desc.Format).Name, " texture");
}