summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-03-14 02:11:59 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:22 +0000
commit00219a5bdbe63aee3957de193fe640f499f01eb4 (patch)
tree5bb5cddda4b76861fe5f0e8d2120f9b085bd2173 /Graphics
parentDirect3D11: added BindPointsD3D11 instead of TBindPoints and TBindPointsAndAc... (diff)
downloadDiligentCore-00219a5bdbe63aee3957de193fe640f499f01eb4.tar.gz
DiligentCore-00219a5bdbe63aee3957de193fe640f499f01eb4.zip
Renamed Align to AlignUp
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsAccessories/interface/RingBuffer.hpp4
-rw-r--r--Graphics/GraphicsAccessories/interface/VariableSizeAllocationsManager.hpp4
-rw-r--r--Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp14
-rw-r--r--Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp2
-rw-r--r--Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.hpp30
-rw-r--r--Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp1
-rw-r--r--Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp12
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp17
-rw-r--r--Graphics/GraphicsEngineD3D12/src/D3D12DynamicHeap.cpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp2
-rw-r--r--Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/ShaderResourcesGL.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp10
-rw-r--r--Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp6
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp4
-rw-r--r--Graphics/GraphicsTools/src/BufferSuballocator.cpp4
-rw-r--r--Graphics/GraphicsTools/src/TextureUploaderGL.cpp2
-rw-r--r--Graphics/ShaderTools/src/SPIRVShaderResources.cpp2
23 files changed, 72 insertions, 66 deletions
diff --git a/Graphics/GraphicsAccessories/interface/RingBuffer.hpp b/Graphics/GraphicsAccessories/interface/RingBuffer.hpp
index 92d35ace..3c942076 100644
--- a/Graphics/GraphicsAccessories/interface/RingBuffer.hpp
+++ b/Graphics/GraphicsAccessories/interface/RingBuffer.hpp
@@ -116,14 +116,14 @@ public:
{
VERIFY_EXPR(Size > 0);
VERIFY(IsPowerOfTwo(Alignment), "Alignment (", Alignment, ") must be power of 2");
- Size = Align(Size, Alignment);
+ Size = AlignUp(Size, Alignment);
if (m_UsedSize + Size > m_MaxSize)
{
return InvalidOffset;
}
- auto AlignedHead = Align(m_Head, Alignment);
+ auto AlignedHead = AlignUp(m_Head, Alignment);
if (m_Head >= m_Tail)
{
// AlignedHead
diff --git a/Graphics/GraphicsAccessories/interface/VariableSizeAllocationsManager.hpp b/Graphics/GraphicsAccessories/interface/VariableSizeAllocationsManager.hpp
index a8bef483..6ecfb1cc 100644
--- a/Graphics/GraphicsAccessories/interface/VariableSizeAllocationsManager.hpp
+++ b/Graphics/GraphicsAccessories/interface/VariableSizeAllocationsManager.hpp
@@ -189,7 +189,7 @@ public:
{
VERIFY_EXPR(Size > 0);
VERIFY(IsPowerOfTwo(Alignment), "Alignment (", Alignment, ") must be power of 2");
- Size = Align(Size, Alignment);
+ Size = AlignUp(Size, Alignment);
if (m_FreeSize < Size)
return Allocation::InvalidAllocation();
@@ -214,7 +214,7 @@ public:
//
auto Offset = SmallestBlockIt->first;
VERIFY_EXPR(Offset % m_CurrAlignment == 0);
- auto AlignedOffset = Align(Offset, Alignment);
+ auto AlignedOffset = AlignUp(Offset, Alignment);
auto AdjustedSize = Size + (AlignedOffset - Offset);
VERIFY_EXPR(AdjustedSize <= Size + AlignmentReserve);
auto NewOffset = Offset + AdjustedSize;
diff --git a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
index 52bdb00c..ac633267 100644
--- a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
+++ b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
@@ -1351,8 +1351,8 @@ MipLevelProperties GetMipLevelProperties(const TextureDesc& TexDesc, Uint32 MipL
VERIFY((FmtAttribs.BlockWidth & (FmtAttribs.BlockWidth - 1)) == 0, "Compressed block width is expected to be power of 2");
VERIFY((FmtAttribs.BlockHeight & (FmtAttribs.BlockHeight - 1)) == 0, "Compressed block height is expected to be power of 2");
// For block-compression formats, all parameters are still specified in texels rather than compressed texel blocks (18.4.1)
- MipProps.StorageWidth = Align(MipProps.LogicalWidth, Uint32{FmtAttribs.BlockWidth});
- MipProps.StorageHeight = Align(MipProps.LogicalHeight, Uint32{FmtAttribs.BlockHeight});
+ MipProps.StorageWidth = AlignUp(MipProps.LogicalWidth, Uint32{FmtAttribs.BlockWidth});
+ MipProps.StorageHeight = AlignUp(MipProps.LogicalHeight, Uint32{FmtAttribs.BlockHeight});
MipProps.RowSize = MipProps.StorageWidth / Uint32{FmtAttribs.BlockWidth} * Uint32{FmtAttribs.ComponentSize}; // ComponentSize is the block size
MipProps.DepthSliceSize = MipProps.StorageHeight / Uint32{FmtAttribs.BlockHeight} * MipProps.RowSize;
MipProps.MipSize = MipProps.DepthSliceSize * MipProps.Depth;
@@ -1575,7 +1575,7 @@ Uint32 GetStagingTextureLocationOffset(const TextureDesc& TexDesc,
for (Uint32 mip = 0; mip < TexDesc.MipLevels; ++mip)
{
auto MipInfo = GetMipLevelProperties(TexDesc, mip);
- ArraySliceSize += Align(MipInfo.MipSize, Alignment);
+ ArraySliceSize += AlignUp(MipInfo.MipSize, Alignment);
}
Offset = ArraySliceSize;
@@ -1589,7 +1589,7 @@ Uint32 GetStagingTextureLocationOffset(const TextureDesc& TexDesc,
for (Uint32 mip = 0; mip < MipLevel; ++mip)
{
auto MipInfo = GetMipLevelProperties(TexDesc, mip);
- Offset += Align(MipInfo.MipSize, Alignment);
+ Offset += AlignUp(MipInfo.MipSize, Alignment);
}
if (ArraySlice == TexDesc.ArraySize)
@@ -1641,8 +1641,8 @@ BufferToTextureCopyInfo GetBufferToTextureCopyInfo(const TextureDesc& TexDesc,
// Align update region size by the block size
VERIFY_EXPR(IsPowerOfTwo(FmtAttribs.BlockWidth));
VERIFY_EXPR(IsPowerOfTwo(FmtAttribs.BlockHeight));
- const auto BlockAlignedRegionWidth = Align(UpdateRegionWidth, Uint32{FmtAttribs.BlockWidth});
- const auto BlockAlignedRegionHeight = Align(UpdateRegionHeight, Uint32{FmtAttribs.BlockHeight});
+ const auto BlockAlignedRegionWidth = AlignUp(UpdateRegionWidth, Uint32{FmtAttribs.BlockWidth});
+ const auto BlockAlignedRegionHeight = AlignUp(UpdateRegionHeight, Uint32{FmtAttribs.BlockHeight});
CopyInfo.RowSize = BlockAlignedRegionWidth / Uint32{FmtAttribs.BlockWidth} * Uint32{FmtAttribs.ComponentSize};
CopyInfo.RowCount = BlockAlignedRegionHeight / FmtAttribs.BlockHeight;
@@ -1654,7 +1654,7 @@ BufferToTextureCopyInfo GetBufferToTextureCopyInfo(const TextureDesc& TexDesc,
}
VERIFY_EXPR(IsPowerOfTwo(RowStrideAlignment));
- CopyInfo.RowStride = Align(CopyInfo.RowSize, RowStrideAlignment);
+ CopyInfo.RowStride = AlignUp(CopyInfo.RowSize, RowStrideAlignment);
if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
{
CopyInfo.RowStrideInTexels = CopyInfo.RowStride / Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.BlockWidth};
diff --git a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp
index ea457eb4..755d0280 100644
--- a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp
+++ b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp
@@ -443,7 +443,7 @@ public:
const auto ShaderGroupBaseAlignment = this->m_pDevice->GetProperties().ShaderGroupBaseAlignment;
const auto AlignToLarger = [ShaderGroupBaseAlignment](size_t offset) -> Uint32 {
- return Align(static_cast<Uint32>(offset), ShaderGroupBaseAlignment);
+ return AlignUp(static_cast<Uint32>(offset), ShaderGroupBaseAlignment);
};
const Uint32 RayGenOffset = 0;
diff --git a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.hpp
index 2f523ea5..99afb43f 100644
--- a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.hpp
+++ b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.hpp
@@ -30,33 +30,33 @@
/// \file
/// Declaration of Diligent::BufferD3D11Impl class
+#include "EngineD3D11ImplTraits.hpp"
#include "BufferD3D11.h"
-#include "RenderDeviceD3D11.h"
#include "BufferBase.hpp"
-#include "BufferViewD3D11Impl.hpp"
-#include "RenderDeviceD3D11Impl.hpp"
namespace Diligent
{
+class RenderDeviceD3D11Impl;
+
/// Buffer object implementation in Direct3D11 backend.
class BufferD3D11Impl final : public BufferBase<EngineD3D11ImplTraits>
{
public:
using TBufferBase = BufferBase<EngineD3D11ImplTraits>;
- BufferD3D11Impl(IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
- class RenderDeviceD3D11Impl* pDeviceD3D11,
- const BufferDesc& BuffDesc,
- const BufferData* pBuffData = nullptr);
-
- BufferD3D11Impl(IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
- class RenderDeviceD3D11Impl* pDeviceD3D11,
- const BufferDesc& BuffDesc,
- RESOURCE_STATE InitialState,
- ID3D11Buffer* pd3d11Buffer);
+ BufferD3D11Impl(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
+ RenderDeviceD3D11Impl* pDeviceD3D11,
+ const BufferDesc& BuffDesc,
+ const BufferData* pBuffData = nullptr);
+
+ BufferD3D11Impl(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
+ RenderDeviceD3D11Impl* pDeviceD3D11,
+ const BufferDesc& BuffDesc,
+ RESOURCE_STATE InitialState,
+ ID3D11Buffer* pd3d11Buffer);
~BufferD3D11Impl();
diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp
index cb39652d..fd238c16 100644
--- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp
+++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp
@@ -34,6 +34,7 @@
#include "ShaderResourceCacheCommon.hpp"
#include "TextureBaseD3D11.hpp"
#include "BufferD3D11Impl.hpp"
+#include "BufferViewD3D11Impl.hpp"
#include "SamplerD3D11Impl.hpp"
#include "PipelineResourceAttribsD3D11.hpp"
diff --git a/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp
index 7568006c..3166c4aa 100644
--- a/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/BufferD3D11Impl.cpp
@@ -26,15 +26,19 @@
*/
#include "pch.h"
-#include <atlbase.h>
#include "BufferD3D11Impl.hpp"
+
+#include <atlbase.h>
+
#include "RenderDeviceD3D11Impl.hpp"
#include "DeviceContextD3D11Impl.hpp"
-#include "D3D11TypeConversions.hpp"
#include "BufferViewD3D11Impl.hpp"
+
+#include "D3D11TypeConversions.hpp"
#include "GraphicsAccessories.hpp"
#include "EngineMemory.h"
+#include "Align.hpp"
namespace Diligent
{
@@ -67,8 +71,8 @@ BufferD3D11Impl::BufferD3D11Impl(IReferenceCounters* pRefCounters,
if (m_Desc.BindFlags & BIND_UNIFORM_BUFFER)
{
- Uint32 AlignmentMask = 15;
- m_Desc.uiSizeInBytes = (m_Desc.uiSizeInBytes + AlignmentMask) & (~AlignmentMask);
+ static constexpr Uint32 Alignment = 16;
+ m_Desc.uiSizeInBytes = AlignUp(m_Desc.uiSizeInBytes, Alignment);
}
D3D11_BUFFER_DESC D3D11BuffDesc;
diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp
index 52b2e638..a254d526 100755
--- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp
@@ -28,6 +28,7 @@
#include "pch.h"
#include "ShaderResourceCacheD3D11.hpp"
+
#include "TextureBaseD3D11.hpp"
#include "BufferD3D11Impl.hpp"
#include "SamplerD3D11Impl.hpp"
@@ -45,10 +46,10 @@ size_t ShaderResourceCacheD3D11::GetRequriedMemorySize(const TResourceCount& Res
auto SamplerCount = ResCount[DESCRIPTOR_RANGE_SAMPLER];
auto UAVCount = ResCount[DESCRIPTOR_RANGE_UAV];
size_t MemSize = 0;
- MemSize = Align(MemSize + (sizeof(CachedCB) + sizeof(BindPointsD3D11) + sizeof(ID3D11Buffer*)) * CBCount, MaxAlignment);
- MemSize = Align(MemSize + (sizeof(CachedResource) + sizeof(BindPointsD3D11) + sizeof(ID3D11ShaderResourceView*)) * SRVCount, MaxAlignment);
- MemSize = Align(MemSize + (sizeof(CachedSampler) + sizeof(BindPointsD3D11) + sizeof(ID3D11SamplerState*)) * SamplerCount, MaxAlignment);
- MemSize = Align(MemSize + (sizeof(CachedResource) + sizeof(BindPointsD3D11) + sizeof(ID3D11UnorderedAccessView*)) * UAVCount, MaxAlignment);
+ MemSize = AlignUp(MemSize + (sizeof(CachedCB) + sizeof(BindPointsD3D11) + sizeof(ID3D11Buffer*)) * CBCount, MaxAlignment);
+ MemSize = AlignUp(MemSize + (sizeof(CachedResource) + sizeof(BindPointsD3D11) + sizeof(ID3D11ShaderResourceView*)) * SRVCount, MaxAlignment);
+ MemSize = AlignUp(MemSize + (sizeof(CachedSampler) + sizeof(BindPointsD3D11) + sizeof(ID3D11SamplerState*)) * SamplerCount, MaxAlignment);
+ MemSize = AlignUp(MemSize + (sizeof(CachedResource) + sizeof(BindPointsD3D11) + sizeof(ID3D11UnorderedAccessView*)) * UAVCount, MaxAlignment);
// clang-format on
VERIFY(MemSize < InvalidResourceOffset, "Memory size exeed the maximum allowed size.");
return MemSize;
@@ -80,10 +81,10 @@ void ShaderResourceCacheD3D11::Initialize(const TResourceCount& ResCount, IMemor
VERIFY(UAVCount == m_UAVCount, "UAVs count (", UAVCount, ") exceeds maximum representable value");
// m_CBOffset = 0
- m_SRVOffset = static_cast<OffsetType>(Align(m_CBOffset + (sizeof(CachedCB) + sizeof(BindPointsD3D11) + sizeof(ID3D11Buffer*)) * CBCount, MaxAlignment));
- m_SamplerOffset = static_cast<OffsetType>(Align(m_SRVOffset + (sizeof(CachedResource) + sizeof(BindPointsD3D11) + sizeof(ID3D11ShaderResourceView*)) * SRVCount, MaxAlignment));
- m_UAVOffset = static_cast<OffsetType>(Align(m_SamplerOffset + (sizeof(CachedSampler) + sizeof(BindPointsD3D11) + sizeof(ID3D11SamplerState*)) * SamplerCount, MaxAlignment));
- size_t BufferSize = static_cast<OffsetType>(Align(m_UAVOffset + (sizeof(CachedResource) + sizeof(BindPointsD3D11) + sizeof(ID3D11UnorderedAccessView*)) * UAVCount, MaxAlignment));
+ m_SRVOffset = static_cast<OffsetType>(AlignUp(m_CBOffset + (sizeof(CachedCB) + sizeof(BindPointsD3D11) + sizeof(ID3D11Buffer*)) * CBCount, MaxAlignment));
+ m_SamplerOffset = static_cast<OffsetType>(AlignUp(m_SRVOffset + (sizeof(CachedResource) + sizeof(BindPointsD3D11) + sizeof(ID3D11ShaderResourceView*)) * SRVCount, MaxAlignment));
+ m_UAVOffset = static_cast<OffsetType>(AlignUp(m_SamplerOffset + (sizeof(CachedSampler) + sizeof(BindPointsD3D11) + sizeof(ID3D11SamplerState*)) * SamplerCount, MaxAlignment));
+ size_t BufferSize = static_cast<OffsetType>(AlignUp(m_UAVOffset + (sizeof(CachedResource) + sizeof(BindPointsD3D11) + sizeof(ID3D11UnorderedAccessView*)) * UAVCount, MaxAlignment));
// clang-format on
VERIFY_EXPR(m_pResourceData == nullptr);
diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12DynamicHeap.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12DynamicHeap.cpp
index aac0bf87..c6454098 100644
--- a/Graphics/GraphicsEngineD3D12/src/D3D12DynamicHeap.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/D3D12DynamicHeap.cpp
@@ -197,7 +197,7 @@ D3D12DynamicAllocation D3D12DynamicHeap::Allocate(Uint64 SizeInBytes, Uint64 Ali
VERIFY_EXPR(Alignment > 0);
VERIFY(IsPowerOfTwo(Alignment), "Alignment (", Alignment, ") must be power of 2");
- if (m_CurrOffset == InvalidOffset || SizeInBytes + (Align(m_CurrOffset, Alignment) - m_CurrOffset) > m_AvailableSize)
+ if (m_CurrOffset == InvalidOffset || SizeInBytes + (AlignUp(m_CurrOffset, Alignment) - m_CurrOffset) > m_AvailableSize)
{
auto NewPageSize = m_PageSize;
while (NewPageSize < SizeInBytes)
@@ -216,9 +216,9 @@ D3D12DynamicAllocation D3D12DynamicHeap::Allocate(Uint64 SizeInBytes, Uint64 Ali
}
}
- if (m_CurrOffset != InvalidOffset && SizeInBytes + (Align(m_CurrOffset, Alignment) - m_CurrOffset) <= m_AvailableSize)
+ if (m_CurrOffset != InvalidOffset && SizeInBytes + (AlignUp(m_CurrOffset, Alignment) - m_CurrOffset) <= m_AvailableSize)
{
- auto AlignedOffset = Align(m_CurrOffset, Alignment);
+ auto AlignedOffset = AlignUp(m_CurrOffset, Alignment);
auto AdjustedSize = SizeInBytes + (AlignedOffset - m_CurrOffset);
VERIFY_EXPR(AdjustedSize <= m_AvailableSize);
m_AvailableSize -= AdjustedSize;
diff --git a/Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp
index 8495287f..13a695da 100644
--- a/Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/QueryManagerD3D12.cpp
@@ -93,7 +93,7 @@ QueryManagerD3D12::QueryManagerD3D12(ID3D12Device* pd3d12Device,
// AlignedDestinationBufferOffset must be a multiple of 8 bytes.
// https://microsoft.github.io/DirectX-Specs/d3d/CountersAndQueries.html#resolvequerydata
- Uint32 AlignedQueryDataSize = Align(GetQueryDataSize(static_cast<QUERY_TYPE>(QueryType)), Uint32{8});
+ Uint32 AlignedQueryDataSize = AlignUp(GetQueryDataSize(static_cast<QUERY_TYPE>(QueryType)), Uint32{8});
HeapInfo.AvailableQueries.resize(HeapInfo.HeapSize);
HeapInfo.ResolveBufferOffsets.resize(HeapInfo.HeapSize);
for (Uint32 i = 0; i < HeapInfo.HeapSize; ++i)
diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
index 0142bea1..43ccd2bb 100644
--- a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
+++ b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
@@ -85,7 +85,7 @@ void ShaderResources::AllocateMemory(IMemoryAllocator& Allocator,
m_AccelStructsOffset = AdvanceOffset(ResCounters.NumAccelStructs);
m_TotalResources = AdvanceOffset(0);
- auto AlignedResourceNamesPoolSize = Align(ResourceNamesPoolSize, sizeof(void*));
+ auto AlignedResourceNamesPoolSize = AlignUp(ResourceNamesPoolSize, sizeof(void*));
auto MemorySize = m_TotalResources * sizeof(D3DShaderResourceAttribs) + AlignedResourceNamesPoolSize * sizeof(char);
VERIFY_EXPR(GetNumCBs() == ResCounters.NumCBs);
diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderResourcesGL.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderResourcesGL.cpp
index 8a27e3cd..43a528c0 100644
--- a/Graphics/GraphicsEngineOpenGL/src/ShaderResourcesGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/ShaderResourcesGL.cpp
@@ -104,7 +104,7 @@ void ShaderResourcesGL::AllocateResources(std::vector<UniformBufferInfo>& Unifor
StringPoolDataSize += strlen(sb.Name) + 1;
}
- auto AlignedStringPoolDataSize = Align(StringPoolDataSize, sizeof(void*));
+ auto AlignedStringPoolDataSize = AlignUp(StringPoolDataSize, sizeof(void*));
// clang-format off
size_t TotalMemorySize =
diff --git a/Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp
index 08154083..46d53207 100644
--- a/Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp
@@ -149,7 +149,7 @@ BottomLevelASVkImpl::BottomLevelASVkImpl(IReferenceCounters* pRefCounters,
VERIFY(IsPowerOfTwo(MemReqs.alignment), "Alignment is not power of 2!");
m_MemoryAllocation = pRenderDeviceVk->AllocateMemory(MemReqs.size, MemReqs.alignment, MemoryTypeIndex, VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT);
- m_MemoryAlignedOffset = Align(VkDeviceSize{m_MemoryAllocation.UnalignedOffset}, MemReqs.alignment);
+ m_MemoryAlignedOffset = AlignUp(VkDeviceSize{m_MemoryAllocation.UnalignedOffset}, MemReqs.alignment);
VERIFY(m_MemoryAllocation.Size >= MemReqs.size + (m_MemoryAlignedOffset - m_MemoryAllocation.UnalignedOffset), "Size of memory allocation is too small");
auto Memory = m_MemoryAllocation.Page->GetVkMemory();
auto err = LogicalDevice.BindBufferMemory(m_VulkanBuffer, Memory, m_MemoryAlignedOffset);
diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp
index 45b7a69e..e5d85485 100644
--- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp
@@ -261,7 +261,7 @@ BufferVkImpl::BufferVkImpl(IReferenceCounters* pRefCounters,
VERIFY(IsPowerOfTwo(MemReqs.alignment), "Alignment is not power of 2!");
m_MemoryAllocation = pRenderDeviceVk->AllocateMemory(MemReqs.size, MemReqs.alignment, MemoryTypeIndex, AllocateFlags);
- m_BufferMemoryAlignedOffset = Align(VkDeviceSize{m_MemoryAllocation.UnalignedOffset}, MemReqs.alignment);
+ m_BufferMemoryAlignedOffset = AlignUp(VkDeviceSize{m_MemoryAllocation.UnalignedOffset}, MemReqs.alignment);
VERIFY(m_MemoryAllocation.Size >= MemReqs.size + (m_BufferMemoryAlignedOffset - m_MemoryAllocation.UnalignedOffset), "Size of memory allocation is too small");
auto Memory = m_MemoryAllocation.Page->GetVkMemory();
auto err = LogicalDevice.BindBufferMemory(m_VulkanBuffer, Memory, m_BufferMemoryAlignedOffset);
@@ -312,7 +312,7 @@ BufferVkImpl::BufferVkImpl(IReferenceCounters* pRefCounters,
// to the host (10.2)
auto StagingMemoryAllocation = pRenderDeviceVk->AllocateMemory(StagingBufferMemReqs, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
auto StagingBufferMemory = StagingMemoryAllocation.Page->GetVkMemory();
- auto AlignedStagingMemOffset = Align(VkDeviceSize{StagingMemoryAllocation.UnalignedOffset}, StagingBufferMemReqs.alignment);
+ auto AlignedStagingMemOffset = AlignUp(VkDeviceSize{StagingMemoryAllocation.UnalignedOffset}, StagingBufferMemReqs.alignment);
VERIFY_EXPR(StagingMemoryAllocation.Size >= StagingBufferMemReqs.size + (AlignedStagingMemOffset - StagingMemoryAllocation.UnalignedOffset));
auto* StagingData = reinterpret_cast<uint8_t*>(StagingMemoryAllocation.Page->GetCPUMemory());
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index a9c0a7ad..723e2c7c 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -2333,8 +2333,8 @@ void DeviceContextVkImpl::MapTextureSubresource(ITexture* pTextu
// Reaback memory is not created with HOST_COHERENT flag, so we have to explicitly invalidate the mapped range
// to make device writes visible to CPU reads
VERIFY_EXPR(pMapRegion->MaxZ >= 1 && pMapRegion->MaxY >= 1);
- auto BlockAlignedMaxX = Align(pMapRegion->MaxX, Uint32{FmtAttribs.BlockWidth});
- auto BlockAlignedMaxY = Align(pMapRegion->MaxY, Uint32{FmtAttribs.BlockHeight});
+ auto BlockAlignedMaxX = AlignUp(pMapRegion->MaxX, Uint32{FmtAttribs.BlockWidth});
+ auto BlockAlignedMaxY = AlignUp(pMapRegion->MaxY, Uint32{FmtAttribs.BlockHeight});
auto MapEndOffset = SubresourceOffset +
((pMapRegion->MaxZ - 1) * MipLevelAttribs.StorageHeight + (BlockAlignedMaxY - FmtAttribs.BlockHeight)) / FmtAttribs.BlockHeight * MipLevelAttribs.RowSize +
(BlockAlignedMaxX / FmtAttribs.BlockWidth) * FmtAttribs.GetElementSize();
diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
index 6b4d538e..c96dedb0 100644
--- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
@@ -190,7 +190,7 @@ TextureVkImpl::TextureVkImpl(IReferenceCounters* pRefCounters,
VERIFY(IsPowerOfTwo(MemReqs.alignment), "Alignment is not power of 2!");
m_MemoryAllocation = pRenderDeviceVk->AllocateMemory(MemReqs, ImageMemoryFlags);
- auto AlignedOffset = Align(m_MemoryAllocation.UnalignedOffset, MemReqs.alignment);
+ auto AlignedOffset = AlignUp(m_MemoryAllocation.UnalignedOffset, MemReqs.alignment);
VERIFY_EXPR(m_MemoryAllocation.Size >= MemReqs.size + (AlignedOffset - m_MemoryAllocation.UnalignedOffset));
auto Memory = m_MemoryAllocation.Page->GetVkMemory();
auto err = LogicalDevice.BindImageMemory(m_VulkanImage, Memory, AlignedOffset);
@@ -304,7 +304,7 @@ TextureVkImpl::TextureVkImpl(IReferenceCounters* pRefCounters,
// to the host (10.2)
auto StagingMemoryAllocation = pRenderDeviceVk->AllocateMemory(StagingBufferMemReqs, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
auto StagingBufferMemory = StagingMemoryAllocation.Page->GetVkMemory();
- auto AlignedStagingMemOffset = Align(StagingMemoryAllocation.UnalignedOffset, StagingBufferMemReqs.alignment);
+ auto AlignedStagingMemOffset = AlignUp(StagingMemoryAllocation.UnalignedOffset, StagingBufferMemReqs.alignment);
VERIFY_EXPR(StagingMemoryAllocation.Size >= StagingBufferMemReqs.size + (AlignedStagingMemOffset - StagingMemoryAllocation.UnalignedOffset));
auto* StagingData = reinterpret_cast<uint8_t*>(StagingMemoryAllocation.Page->GetCPUMemory());
@@ -426,7 +426,7 @@ TextureVkImpl::TextureVkImpl(IReferenceCounters* pRefCounters,
// which requires the ranges to be aligned by nonCoherentAtomSize.
const auto& DeviceLimits = pRenderDeviceVk->GetPhysicalDevice().GetProperties().limits;
// Align the buffer size to ensure that any aligned range is always in bounds.
- VkStagingBuffCI.size = Align(VkStagingBuffCI.size, DeviceLimits.nonCoherentAtomSize);
+ VkStagingBuffCI.size = AlignUp(VkStagingBuffCI.size, DeviceLimits.nonCoherentAtomSize);
}
else if (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE)
{
@@ -454,7 +454,7 @@ TextureVkImpl::TextureVkImpl(IReferenceCounters* pRefCounters,
m_MemoryAllocation = pRenderDeviceVk->AllocateMemory(StagingBufferMemReqs, MemProperties);
auto StagingBufferMemory = m_MemoryAllocation.Page->GetVkMemory();
- auto AlignedStagingMemOffset = Align(m_MemoryAllocation.UnalignedOffset, StagingBufferMemReqs.alignment);
+ auto AlignedStagingMemOffset = AlignUp(m_MemoryAllocation.UnalignedOffset, StagingBufferMemReqs.alignment);
VERIFY_EXPR(m_MemoryAllocation.Size >= StagingBufferMemReqs.size + (AlignedStagingMemOffset - m_MemoryAllocation.UnalignedOffset));
auto err = LogicalDevice.BindBufferMemory(m_StagingBuffer, StagingBufferMemory, AlignedStagingMemOffset);
@@ -787,7 +787,7 @@ void TextureVkImpl::InvalidateStagingRange(VkDeviceSize Offset, VkDeviceSize Siz
Offset += m_StagingDataAlignedOffset;
auto AlignedOffset = AlignDown(Offset, PhysDeviceLimits.nonCoherentAtomSize);
Size += Offset - AlignedOffset;
- auto AlignedSize = Align(Size, PhysDeviceLimits.nonCoherentAtomSize);
+ auto AlignedSize = AlignUp(Size, PhysDeviceLimits.nonCoherentAtomSize);
InvalidateRange.offset = AlignedOffset;
InvalidateRange.size = AlignedSize;
diff --git a/Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp
index 2c0de29a..68f1f58a 100644
--- a/Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp
@@ -90,7 +90,7 @@ TopLevelASVkImpl::TopLevelASVkImpl(IReferenceCounters* pRefCounters,
VERIFY(IsPowerOfTwo(MemReqs.alignment), "Alignment is not power of 2!");
m_MemoryAllocation = pRenderDeviceVk->AllocateMemory(MemReqs.size, MemReqs.alignment, MemoryTypeIndex, VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT);
- m_MemoryAlignedOffset = Align(VkDeviceSize{m_MemoryAllocation.UnalignedOffset}, MemReqs.alignment);
+ m_MemoryAlignedOffset = AlignUp(VkDeviceSize{m_MemoryAllocation.UnalignedOffset}, MemReqs.alignment);
VERIFY(m_MemoryAllocation.Size >= MemReqs.size + (m_MemoryAlignedOffset - m_MemoryAllocation.UnalignedOffset), "Size of memory allocation is too small");
auto Memory = m_MemoryAllocation.Page->GetVkMemory();
auto err = LogicalDevice.BindBufferMemory(m_VulkanBuffer, Memory, m_MemoryAlignedOffset);
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp
index c2a9f6e6..11212308 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp
@@ -234,7 +234,7 @@ VulkanDynamicAllocation VulkanDynamicHeap::Allocate(Uint32 SizeInBytes, Uint32 A
auto MasterBlock = m_GlobalDynamicMemMgr.AllocateMasterBlock(SizeInBytes, Alignment);
if (MasterBlock.IsValid())
{
- AlignedOffset = Align(MasterBlock.UnalignedOffset, size_t{Alignment});
+ AlignedOffset = AlignUp(MasterBlock.UnalignedOffset, size_t{Alignment});
AlignedSize = MasterBlock.Size;
VERIFY_EXPR(MasterBlock.Size >= SizeInBytes + (AlignedOffset - MasterBlock.UnalignedOffset));
m_CurrAllocatedSize += static_cast<Uint32>(MasterBlock.Size);
@@ -243,7 +243,7 @@ VulkanDynamicAllocation VulkanDynamicHeap::Allocate(Uint32 SizeInBytes, Uint32 A
}
else
{
- if (m_CurrOffset == InvalidOffset || SizeInBytes + (Align(m_CurrOffset, size_t{Alignment}) - m_CurrOffset) > m_AvailableSize)
+ if (m_CurrOffset == InvalidOffset || SizeInBytes + (AlignUp(m_CurrOffset, size_t{Alignment}) - m_CurrOffset) > m_AvailableSize)
{
auto MasterBlock = m_GlobalDynamicMemMgr.AllocateMasterBlock(m_MasterBlockSize, 0);
if (MasterBlock.IsValid())
@@ -257,7 +257,7 @@ VulkanDynamicAllocation VulkanDynamicHeap::Allocate(Uint32 SizeInBytes, Uint32 A
if (m_CurrOffset != InvalidOffset)
{
- AlignedOffset = Align(m_CurrOffset, size_t{Alignment});
+ AlignedOffset = AlignUp(m_CurrOffset, size_t{Alignment});
AlignedSize = SizeInBytes + (AlignedOffset - m_CurrOffset);
if (AlignedSize <= m_AvailableSize)
{
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp
index 9de39fc4..8567531a 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUploadHeap.cpp
@@ -109,7 +109,7 @@ VulkanUploadAllocation VulkanUploadHeap::Allocate(VkDeviceSize SizeInBytes, VkDe
}
else
{
- auto AlignmentOffset = Align(m_CurrPage.CurrOffset, Alignment) - m_CurrPage.CurrOffset;
+ auto AlignmentOffset = AlignUp(m_CurrPage.CurrOffset, Alignment) - m_CurrPage.CurrOffset;
if (m_CurrPage.AvailableSize < SizeInBytes + AlignmentOffset)
{
// Allocate new page
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp
index a7b3147a..c7f6f504 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp
@@ -107,7 +107,7 @@ VulkanMemoryAllocation VulkanMemoryPage::Allocate(VkDeviceSize size, VkDeviceSiz
{
// Offset may not necessarily be aligned, but the allocation is guaranteed to be large enough
// to accomodate requested alignment
- VERIFY_EXPR(Diligent::Align(VkDeviceSize{Allocation.UnalignedOffset}, alignment) - Allocation.UnalignedOffset + size <= Allocation.Size);
+ VERIFY_EXPR(Diligent::AlignUp(VkDeviceSize{Allocation.UnalignedOffset}, alignment) - Allocation.UnalignedOffset + size <= Allocation.Size);
return VulkanMemoryAllocation{this, Allocation.UnalignedOffset, Allocation.Size};
}
else
@@ -201,7 +201,7 @@ VulkanMemoryAllocation VulkanMemoryManager::Allocate(VkDeviceSize Size, VkDevice
if (Allocation.Page != nullptr)
{
- VERIFY_EXPR(Size + Diligent::Align(Allocation.UnalignedOffset, Alignment) - Allocation.UnalignedOffset <= Allocation.Size);
+ VERIFY_EXPR(Size + Diligent::AlignUp(Allocation.UnalignedOffset, Alignment) - Allocation.UnalignedOffset <= Allocation.Size);
}
m_CurrUsedSize[stat_ind].fetch_add(Allocation.Size);
diff --git a/Graphics/GraphicsTools/src/BufferSuballocator.cpp b/Graphics/GraphicsTools/src/BufferSuballocator.cpp
index 2c5d60cd..2913e4ed 100644
--- a/Graphics/GraphicsTools/src/BufferSuballocator.cpp
+++ b/Graphics/GraphicsTools/src/BufferSuballocator.cpp
@@ -176,7 +176,7 @@ public:
while (!Subregion.IsValid())
{
auto ExtraSize = m_ExpansionSize != 0 ?
- std::max(m_ExpansionSize, Align(Size, Alignment)) :
+ std::max(m_ExpansionSize, AlignUp(Size, Alignment)) :
m_Mgr.GetMaxSize();
m_Mgr.Extend(ExtraSize);
@@ -189,7 +189,7 @@ public:
NEW_RC_OBJ(m_SuballocationsAllocator, "BufferSuballocationImpl instance", BufferSuballocationImpl)
(
this,
- Align(static_cast<Uint32>(Subregion.UnalignedOffset), Alignment),
+ AlignUp(static_cast<Uint32>(Subregion.UnalignedOffset), Alignment),
Size,
std::move(Subregion)
)
diff --git a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp
index 0fabd561..de9df6db 100644
--- a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp
+++ b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp
@@ -66,7 +66,7 @@ public:
{
auto MipProps = GetMipLevelProperties(TexDesc, Mip);
// Stride must be 32-bit aligned in OpenGL
- auto RowStride = Align(MipProps.RowSize, Uint32{4});
+ auto RowStride = AlignUp(MipProps.RowSize, Uint32{4});
m_SubresourceStrides[SubRes] = RowStride;
auto MipSize = MipProps.StorageHeight * RowStride;
diff --git a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
index 15c5751b..c4cfd8a5 100644
--- a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
+++ b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
@@ -597,7 +597,7 @@ void SPIRVShaderResources::Initialize(IMemoryAllocator& Allocator,
VERIFY(NumShaderStageInputs <= MaxOffset, "Max offset exceeded");
m_NumShaderStageInputs = static_cast<OffsetType>(NumShaderStageInputs);
- auto AlignedResourceNamesPoolSize = Align(ResourceNamesPoolSize, sizeof(void*));
+ auto AlignedResourceNamesPoolSize = AlignUp(ResourceNamesPoolSize, sizeof(void*));
static_assert(sizeof(SPIRVShaderResourceAttribs) % sizeof(void*) == 0, "Size of SPIRVShaderResourceAttribs struct must be multiple of sizeof(void*)");
// clang-format off