From 48f769e8b36f0e803a5683ecbfbeedbc52eb556a Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 14 Oct 2024 14:28:06 -0700 Subject: [PATCH] GraphicsAccessories: added GetStagingTextureDataSize function --- .../GraphicsAccessories/interface/GraphicsAccessories.hpp | 6 ++++++ Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 2 +- Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp index 6dfb81510..ba1d8af12 100644 --- a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp +++ b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp @@ -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 diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index 6c7e78330..151198109 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -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; diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index 288c50c13..2ba6ef339 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -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"); @@ -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 ||