Skip to content

Commit 48f769e

Browse files
GraphicsAccessories: added GetStagingTextureDataSize function
1 parent 65ecd01 commit 48f769e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,12 @@ inline Uint64 GetStagingTextureSubresourceOffset(const TextureDesc& TexDesc,
697697
return GetStagingTextureLocationOffset(TexDesc, ArraySlice, MipLevel, Alignment, 0, 0, 0);
698698
}
699699

700+
/// Returns the total memory size required to store the staging texture data.
701+
inline Uint64 GetStagingTextureDataSize(const TextureDesc& TexDesc,
702+
Uint32 Alignment = 4)
703+
{
704+
return GetStagingTextureSubresourceOffset(TexDesc, TexDesc.GetArraySize(), 0, Alignment);
705+
}
700706

701707
/// Information required to perform a copy operation between a buffer and a texture
702708
struct BufferToTextureCopyInfo

Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ TextureBaseGL::TextureBaseGL(IReferenceCounters* pRefCounters,
7575
StagingBuffName += '\'';
7676
StagingBufferDesc.Name = StagingBuffName.c_str();
7777

78-
StagingBufferDesc.Size = GetStagingTextureSubresourceOffset(m_Desc, m_Desc.GetArraySize(), 0, PBOOffsetAlignment);
78+
StagingBufferDesc.Size = GetStagingTextureDataSize(m_Desc, PBOOffsetAlignment);
7979
StagingBufferDesc.Usage = USAGE_STAGING;
8080
StagingBufferDesc.CPUAccessFlags = TexDesc.CPUAccessFlags;
8181

Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -427,7 +427,7 @@ void TextureVkImpl::CreateStagingTexture(const TextureData* pInitData, const Tex
427427
VkStagingBuffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
428428
VkStagingBuffCI.pNext = nullptr;
429429
VkStagingBuffCI.flags = 0;
430-
VkStagingBuffCI.size = GetStagingTextureSubresourceOffset(m_Desc, m_Desc.GetArraySize(), 0, StagingBufferOffsetAlignment);
430+
VkStagingBuffCI.size = GetStagingTextureDataSize(m_Desc, StagingBufferOffsetAlignment);
431431

432432
// clang-format off
433433
DEV_CHECK_ERR((m_Desc.CPUAccessFlags & (CPU_ACCESS_READ | CPU_ACCESS_WRITE)) == CPU_ACCESS_READ ||

0 commit comments

Comments
 (0)