diff --git a/include/bgfx.h b/include/bgfx.h index 0c42b6b8..3afff85e 100644 --- a/include/bgfx.h +++ b/include/bgfx.h @@ -643,6 +643,10 @@ namespace bgfx /// calls. /// @param _num Number of indices to allocate. /// + /// NOTE: + /// You must call setIndexBuffer after alloc in order to avoid memory + /// leak. + /// void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num); /// Allocate transient vertex buffer. @@ -653,9 +657,18 @@ namespace bgfx /// @param _num Number of vertices to allocate. /// @param _decl Vertex declaration. /// + /// NOTE: + /// You must call setVertexBuffer after alloc in order to avoid memory + /// leak. + /// void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexDecl& _decl); /// Allocate instance data buffer. + /// + /// NOTE: + /// You must call setInstanceDataBuffer after alloc in order to avoid + /// memory leak. + /// const InstanceDataBuffer* allocInstanceDataBuffer(uint32_t _num, uint16_t _stride); /// Create vertex shader from memory buffer. @@ -951,6 +964,9 @@ namespace bgfx /// void submitMask(uint32_t _viewMask, int32_t _depth = 0); + /// Discard all previously set state for draw call. + void discard(); + /// Request screen shot. void saveScreenShot(const char* _filePath); diff --git a/src/bgfx.cpp b/src/bgfx.cpp index dc2def0d..5853ede7 100755 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -529,7 +529,7 @@ namespace bgfx { if (m_discard) { - m_discard = false; + discard(); return; } @@ -566,7 +566,7 @@ namespace bgfx { if (m_discard) { - m_discard = false; + discard(); return; } @@ -1496,6 +1496,12 @@ namespace bgfx s_ctx.m_submit->submitMask(_viewMask, _depth); } + void discard() + { + BGFX_CHECK_MAIN_THREAD(); + s_ctx.m_submit->discard(); + } + void saveScreenShot(const char* _filePath) { BGFX_CHECK_MAIN_THREAD(); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index f94d1fbb..b62a904d 100755 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -1153,6 +1153,13 @@ namespace bgfx } } + void discard() + { + m_discard = false; + m_state.clear(); + m_flags = BGFX_STATE_NONE; + } + void submit(uint8_t _id, int32_t _depth); void submitMask(uint32_t _viewMask, int32_t _depth); void sort();