mirror of https://github.com/bkaradzic/bgfx
Added texture&rt memory stats.
This commit is contained in:
parent
498175746e
commit
e5031c5897
|
@ -838,6 +838,9 @@ namespace bgfx
|
|||
uint16_t numVertexBuffers; //!< Number of used vertex buffers.
|
||||
uint16_t numVertexDecls; //!< Number of used vertex declarations.
|
||||
|
||||
int64_t textureMemoryUsed; //!<
|
||||
int64_t rtMemoryUsed; //!<
|
||||
|
||||
int64_t gpuMemoryMax; //!< Maximum available GPU memory for application.
|
||||
int64_t gpuMemoryUsed; //!< Amount of GPU memory used by the application.
|
||||
|
||||
|
|
|
@ -386,6 +386,9 @@ typedef struct bgfx_stats
|
|||
uint16_t numVertexBuffers;
|
||||
uint16_t numVertexDecls;
|
||||
|
||||
int64_t textureMemoryUsed;
|
||||
int64_t rtMemoryUsed;
|
||||
|
||||
int64_t gpuMemoryMax;
|
||||
int64_t gpuMemoryUsed;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
||||
#define BGFX_API_VERSION UINT32_C(63)
|
||||
#define BGFX_API_VERSION UINT32_C(64)
|
||||
|
||||
/// Color RGB/alpha/depth write. When it's not specified write will be disabled.
|
||||
#define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write.
|
||||
|
|
64
src/bgfx_p.h
64
src/bgfx_p.h
|
@ -2679,6 +2679,8 @@ namespace bgfx
|
|||
, m_colorPaletteDirty(0)
|
||||
, m_frames(0)
|
||||
, m_debug(BGFX_DEBUG_NONE)
|
||||
, m_rtMemoryUsed(0)
|
||||
, m_textureMemoryUsed(0)
|
||||
, m_renderCtx(NULL)
|
||||
, m_renderMain(NULL)
|
||||
, m_renderNoop(NULL)
|
||||
|
@ -2819,6 +2821,9 @@ namespace bgfx
|
|||
stats.numVertexBuffers = m_vertexBufferHandle.getNumHandles();
|
||||
stats.numVertexDecls = m_vertexDeclHandle.getNumHandles();
|
||||
|
||||
stats.textureMemoryUsed = m_textureMemoryUsed;
|
||||
stats.rtMemoryUsed = m_rtMemoryUsed;
|
||||
|
||||
return &stats;
|
||||
}
|
||||
|
||||
|
@ -3869,11 +3874,22 @@ namespace bgfx
|
|||
TextureRef& ref = m_textureRef[handle.idx];
|
||||
ref.init(_ratio
|
||||
, _info->format
|
||||
, _info->storageSize
|
||||
, imageContainer.m_numMips
|
||||
, 0 != (g_caps.supported & BGFX_CAPS_TEXTURE_DIRECT_ACCESS)
|
||||
, _immutable
|
||||
, 0 != (_flags & BGFX_TEXTURE_RT_MASK)
|
||||
);
|
||||
|
||||
if (ref.m_rt)
|
||||
{
|
||||
m_rtMemoryUsed += int64_t(ref.m_storageSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_textureMemoryUsed += int64_t(ref.m_storageSize);
|
||||
}
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateTexture);
|
||||
cmdbuf.write(handle);
|
||||
cmdbuf.write(_mem);
|
||||
|
@ -3991,6 +4007,15 @@ namespace bgfx
|
|||
{
|
||||
ref.m_name.clear();
|
||||
|
||||
if (ref.m_rt)
|
||||
{
|
||||
m_rtMemoryUsed -= int64_t(ref.m_storageSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_textureMemoryUsed -= int64_t(ref.m_storageSize);
|
||||
}
|
||||
|
||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
||||
BX_CHECK(ok, "Texture handle %d is already destroyed!", _handle.idx);
|
||||
|
||||
|
@ -4648,28 +4673,34 @@ namespace bgfx
|
|||
void init(
|
||||
BackbufferRatio::Enum _ratio
|
||||
, TextureFormat::Enum _format
|
||||
, uint32_t _storageSize
|
||||
, uint8_t _numMips
|
||||
, bool _ptrPending
|
||||
, bool _immutable
|
||||
, bool _rt
|
||||
)
|
||||
{
|
||||
m_ptr = _ptrPending ? (void*)UINTPTR_MAX : NULL;
|
||||
m_refCount = 1;
|
||||
m_bbRatio = uint8_t(_ratio);
|
||||
m_format = uint8_t(_format);
|
||||
m_numMips = _numMips;
|
||||
m_owned = false;
|
||||
m_immutable = _immutable;
|
||||
m_ptr = _ptrPending ? (void*)UINTPTR_MAX : NULL;
|
||||
m_storageSize = _storageSize;
|
||||
m_refCount = 1;
|
||||
m_bbRatio = uint8_t(_ratio);
|
||||
m_format = uint8_t(_format);
|
||||
m_numMips = _numMips;
|
||||
m_owned = false;
|
||||
m_immutable = _immutable;
|
||||
m_rt = _rt;
|
||||
}
|
||||
|
||||
String m_name;
|
||||
void* m_ptr;
|
||||
int16_t m_refCount;
|
||||
uint8_t m_bbRatio;
|
||||
uint8_t m_format;
|
||||
uint8_t m_numMips;
|
||||
bool m_owned;
|
||||
bool m_immutable;
|
||||
String m_name;
|
||||
void* m_ptr;
|
||||
uint32_t m_storageSize;
|
||||
int16_t m_refCount;
|
||||
uint8_t m_bbRatio;
|
||||
uint8_t m_format;
|
||||
uint8_t m_numMips;
|
||||
bool m_owned;
|
||||
bool m_immutable;
|
||||
bool m_rt;
|
||||
};
|
||||
|
||||
struct FrameBufferRef
|
||||
|
@ -4711,6 +4742,9 @@ namespace bgfx
|
|||
uint32_t m_frames;
|
||||
uint32_t m_debug;
|
||||
|
||||
int64_t m_rtMemoryUsed;
|
||||
int64_t m_textureMemoryUsed;
|
||||
|
||||
TextVideoMemBlitter m_textVideoMemBlitter;
|
||||
ClearQuad m_clearQuad;
|
||||
|
||||
|
|
Loading…
Reference in New Issue