Skip to content

Commit

Permalink
GraphicsAccessories: added GetStagingTextureDataSize function
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Oct 14, 2024
1 parent 65ecd01 commit 48f769e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,12 @@ inline Uint64 GetStagingTextureSubresourceOffset(const TextureDesc& TexDesc,
return GetStagingTextureLocationOffset(TexDesc, ArraySlice, MipLevel, Alignment, 0, 0, 0);
}

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

/// Information required to perform a copy operation between a buffer and a texture
struct BufferToTextureCopyInfo
Expand Down
2 changes: 1 addition & 1 deletion Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TextureBaseGL::TextureBaseGL(IReferenceCounters* pRefCounters,
StagingBuffName += '\'';
StagingBufferDesc.Name = StagingBuffName.c_str();

StagingBufferDesc.Size = GetStagingTextureSubresourceOffset(m_Desc, m_Desc.GetArraySize(), 0, PBOOffsetAlignment);
StagingBufferDesc.Size = GetStagingTextureDataSize(m_Desc, PBOOffsetAlignment);
StagingBufferDesc.Usage = USAGE_STAGING;
StagingBufferDesc.CPUAccessFlags = TexDesc.CPUAccessFlags;

Expand Down
4 changes: 2 additions & 2 deletions Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 Diligent Graphics LLC
* Copyright 2019-2024 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -427,7 +427,7 @@ void TextureVkImpl::CreateStagingTexture(const TextureData* pInitData, const Tex
VkStagingBuffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
VkStagingBuffCI.pNext = nullptr;
VkStagingBuffCI.flags = 0;
VkStagingBuffCI.size = GetStagingTextureSubresourceOffset(m_Desc, m_Desc.GetArraySize(), 0, StagingBufferOffsetAlignment);
VkStagingBuffCI.size = GetStagingTextureDataSize(m_Desc, StagingBufferOffsetAlignment);

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

0 comments on commit 48f769e

Please sign in to comment.