Skip to content

Commit ff42779

Browse files
Dynamic Buffer: added GetVirtualSize method
1 parent 26c9841 commit ff42779

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

Graphics/GraphicsTools/interface/DynamicBuffer.hpp

Lines changed: 11 additions & 1 deletion
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");
@@ -173,6 +173,16 @@ class DynamicBuffer
173173
return m_Version.load();
174174
}
175175

176+
177+
/// Returns the virtual size of the sparse buffer.
178+
///
179+
/// \remarks If the internal buffer has not been initialized yet,
180+
/// the method returns zero.
181+
Uint64 GetVirtualSize() const
182+
{
183+
return m_pBuffer ? m_VirtualSize : 0;
184+
}
185+
176186
private:
177187
void InitBuffer(IRenderDevice* pDevice);
178188
void CreateSparseBuffer(IRenderDevice* pDevice);

Graphics/GraphicsTools/src/DynamicBuffer.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");
@@ -66,7 +66,7 @@ DynamicBuffer::DynamicBuffer(IRenderDevice* pDevice,
6666
const DynamicBufferCreateInfo& CI) :
6767
m_Name{CI.Desc.Name != nullptr ? CI.Desc.Name : "Dynamic buffer"},
6868
m_Desc{CI.Desc},
69-
m_VirtualSize{CI.VirtualSize},
69+
m_VirtualSize{CI.Desc.Usage == USAGE_SPARSE ? CI.VirtualSize : 0},
7070
m_MemoryPageSize{CI.MemoryPageSize}
7171
{
7272
if (m_Desc.BindFlags & (BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS))

0 commit comments

Comments
 (0)