Browse Source

Added check available memory for instance buffer.

bkaradzic 12 years ago
parent
commit
e79102bf0e
2 changed files with 14 additions and 0 deletions
  1. 7 0
      include/bgfx.h
  2. 7 0
      src/bgfx.cpp

+ 7 - 0
include/bgfx.h

@@ -606,6 +606,13 @@ namespace bgfx
 	///
 	///
 	bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl);
 	bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl);
 
 
+	/// Returns true if internal instance data buffer has enough space.
+	///
+	/// @param _num Number of instances.
+	/// @param _stride Stride per instance.
+	///
+	bool checkAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride);
+
 	/// Returns true if both internal transient index and vertex buffer have
 	/// Returns true if both internal transient index and vertex buffer have
 	/// enough space.
 	/// enough space.
 	///
 	///

+ 7 - 0
src/bgfx.cpp

@@ -938,6 +938,13 @@ namespace bgfx
 		return s_ctx.m_submit->checkAvailTransientVertexBuffer(_num, _decl.m_stride);
 		return s_ctx.m_submit->checkAvailTransientVertexBuffer(_num, _decl.m_stride);
 	}
 	}
 
 
+	bool checkAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride)
+	{
+		BGFX_CHECK_MAIN_THREAD();
+		BX_CHECK(0 < _num, "Requesting 0 instances.");
+		return s_ctx.m_submit->checkAvailTransientVertexBuffer(_num, _stride);
+	}
+
 	bool checkAvailTransientBuffers(uint32_t _numVertices, const VertexDecl& _decl, uint32_t _numIndices)
 	bool checkAvailTransientBuffers(uint32_t _numVertices, const VertexDecl& _decl, uint32_t _numIndices)
 	{
 	{
 		return checkAvailTransientVertexBuffer(_numVertices, _decl)
 		return checkAvailTransientVertexBuffer(_numVertices, _decl)