Browse Source

Replaced checkAvail* with getAvail* API.

Branimir Karadžić 9 years ago
parent
commit
07aae82d16

+ 1 - 1
examples/07-callback/callback.cpp

@@ -148,7 +148,7 @@ struct BgfxCallback : public bgfx::CallbackI
 		bx::Error err;
 		bx::Error err;
 		if (bx::open(reader, filePath, &err) )
 		if (bx::open(reader, filePath, &err) )
 		{
 		{
-			uint32_t size = bx::getSize(reader);
+			uint32_t size = (uint32_t)bx::getSize(reader);
 			bx::close(reader);
 			bx::close(reader);
 			// Return size of shader file.
 			// Return size of shader file.
 			return size;
 			return size;

+ 1 - 1
examples/09-hdr/hdr.cpp

@@ -36,7 +36,7 @@ bgfx::VertexDecl PosColorTexCoord0Vertex::ms_decl;
 
 
 void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f)
 void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f)
 {
 {
-	if (bgfx::checkAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) )
+	if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) )
 	{
 	{
 		bgfx::TransientVertexBuffer vb;
 		bgfx::TransientVertexBuffer vb;
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl);
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl);

+ 2 - 2
examples/16-shadowmaps/shadowmaps.cpp

@@ -1057,7 +1057,7 @@ bgfx::VertexDecl PosColorTexCoord0Vertex::ms_decl;
 
 
 void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = true, float _width = 1.0f, float _height = 1.0f)
 void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = true, float _width = 1.0f, float _height = 1.0f)
 {
 {
-	if (bgfx::checkAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) )
+	if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) )
 	{
 	{
 		bgfx::TransientVertexBuffer vb;
 		bgfx::TransientVertexBuffer vb;
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl);
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl);
@@ -2691,7 +2691,7 @@ int _main_(int _argc, char** _argv)
 			// Craft stencil mask for point light shadow map packing.
 			// Craft stencil mask for point light shadow map packing.
 			if(LightType::PointLight == settings.m_lightType && settings.m_stencilPack)
 			if(LightType::PointLight == settings.m_lightType && settings.m_stencilPack)
 			{
 			{
-				if (bgfx::checkAvailTransientVertexBuffer(6, posDecl) )
+				if (6 == bgfx::getAvailTransientVertexBuffer(6, posDecl) )
 				{
 				{
 					struct Pos
 					struct Pos
 					{
 					{

+ 1 - 1
examples/18-ibl/ibl.cpp

@@ -89,7 +89,7 @@ bgfx::VertexDecl PosColorTexCoord0Vertex::ms_decl;
 
 
 void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f)
 void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f)
 {
 {
-	if (bgfx::checkAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) )
+	if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) )
 	{
 	{
 		bgfx::TransientVertexBuffer vb;
 		bgfx::TransientVertexBuffer vb;
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl);
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl);

+ 1 - 1
examples/19-oit/oit.cpp

@@ -90,7 +90,7 @@ inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, flo
 
 
 void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f)
 void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f)
 {
 {
-	if (bgfx::checkAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) )
+	if (3 == bgfx::getAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) )
 	{
 	{
 		bgfx::TransientVertexBuffer vb;
 		bgfx::TransientVertexBuffer vb;
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl);
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl);

+ 1 - 1
examples/21-deferred/deferred.cpp

@@ -159,7 +159,7 @@ static const uint16_t s_cubeIndices[36] =
 
 
 void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f)
 void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f)
 {
 {
-	if (bgfx::checkAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl) )
+	if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl) )
 	{
 	{
 		bgfx::TransientVertexBuffer vb;
 		bgfx::TransientVertexBuffer vb;
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl);
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl);

+ 1 - 1
examples/23-vectordisplay/vectordisplay.cpp

@@ -741,7 +741,7 @@ void VectorDisplay::getSize(float* _outWidth, float* _outHeight)
 
 
 void VectorDisplay::screenSpaceQuad(float _textureWidth, float _textureHeight, float _width, float _height)
 void VectorDisplay::screenSpaceQuad(float _textureWidth, float _textureHeight, float _width, float _height)
 {
 {
-	if (bgfx::checkAvailTransientVertexBuffer(3, PosColorUvVertex::ms_decl) )
+	if (3 == getAvailTransientVertexBuffer(3, PosColorUvVertex::ms_decl) )
 	{
 	{
 		bgfx::TransientVertexBuffer vb;
 		bgfx::TransientVertexBuffer vb;
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorUvVertex::ms_decl);
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorUvVertex::ms_decl);

+ 1 - 1
examples/31-rsm/reflectiveshadowmap.cpp

@@ -127,7 +127,7 @@ bgfx::VertexDecl PosTexCoord0Vertex::ms_decl;
 // Utility function to draw a screen space quad for deferred rendering
 // Utility function to draw a screen space quad for deferred rendering
 void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f)
 void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f)
 {
 {
-	if (bgfx::checkAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl) )
+	if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl) )
 	{
 	{
 		bgfx::TransientVertexBuffer vb;
 		bgfx::TransientVertexBuffer vb;
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl);
 		bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl);

+ 14 - 0
examples/common/bgfx_utils.h

@@ -15,6 +15,20 @@ bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName);
 bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, bgfx::TextureInfo* _info = NULL);
 bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, bgfx::TextureInfo* _info = NULL);
 void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexDecl _decl, const uint16_t* _indices, uint32_t _numIndices);
 void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexDecl _decl, const uint16_t* _indices, uint32_t _numIndices);
 
 
+/// Returns true if both internal transient index and vertex buffer have
+/// enough space.
+///
+/// @param[in] _numVertices Number of vertices.
+/// @param[in] _decl Vertex declaration.
+/// @param[in] _numIndices Number of indices.
+///
+inline bool checkAvailTransientBuffers(uint32_t _numVertices, const bgfx::VertexDecl& _decl, uint32_t _numIndices)
+{
+	return _numVertices == bgfx::getAvailTransientVertexBuffer(_numVertices, _decl)
+		&& _numIndices  == bgfx::getAvailTransientIndexBuffer(_numIndices)
+		;
+}
+
 struct MeshState
 struct MeshState
 {
 {
 	struct Texture
 	struct Texture

+ 3 - 2
examples/common/debugdraw/debugdraw.cpp

@@ -6,6 +6,7 @@
 #include <bgfx/bgfx.h>
 #include <bgfx/bgfx.h>
 #include <bgfx/embedded_shader.h>
 #include <bgfx/embedded_shader.h>
 #include "debugdraw.h"
 #include "debugdraw.h"
+#include "../bgfx_utils.h"
 #include "../packrect.h"
 #include "../packrect.h"
 
 
 #include <bx/fpumath.h>
 #include <bx/fpumath.h>
@@ -1838,7 +1839,7 @@ private:
 	{
 	{
 		if (0 != m_pos)
 		if (0 != m_pos)
 		{
 		{
-			if (bgfx::checkAvailTransientBuffers(m_pos, DebugVertex::ms_decl, m_indexPos) )
+			if (checkAvailTransientBuffers(m_pos, DebugVertex::ms_decl, m_indexPos) )
 			{
 			{
 				bgfx::TransientVertexBuffer tvb;
 				bgfx::TransientVertexBuffer tvb;
 				bgfx::allocTransientVertexBuffer(&tvb, m_pos, DebugVertex::ms_decl);
 				bgfx::allocTransientVertexBuffer(&tvb, m_pos, DebugVertex::ms_decl);
@@ -1876,7 +1877,7 @@ private:
 		if (0 != m_posQuad)
 		if (0 != m_posQuad)
 		{
 		{
 			const uint32_t numIndices = m_posQuad/4*6;
 			const uint32_t numIndices = m_posQuad/4*6;
-			if (bgfx::checkAvailTransientBuffers(m_posQuad, DebugUvVertex::ms_decl, numIndices) )
+			if (checkAvailTransientBuffers(m_posQuad, DebugUvVertex::ms_decl, numIndices) )
 			{
 			{
 				bgfx::TransientVertexBuffer tvb;
 				bgfx::TransientVertexBuffer tvb;
 				bgfx::allocTransientVertexBuffer(&tvb, m_posQuad, DebugUvVertex::ms_decl);
 				bgfx::allocTransientVertexBuffer(&tvb, m_posQuad, DebugUvVertex::ms_decl);

+ 5 - 4
examples/common/imgui/imgui.cpp

@@ -32,6 +32,7 @@
 
 
 #include "imgui.h"
 #include "imgui.h"
 #include "ocornut_imgui.h"
 #include "ocornut_imgui.h"
+#include "../bgfx_utils.h"
 #include "../nanovg/nanovg.h"
 #include "../nanovg/nanovg.h"
 
 
 #include <bgfx/embedded_shader.h>
 #include <bgfx/embedded_shader.h>
@@ -1800,7 +1801,7 @@ struct Imgui
 
 
 		const uint32_t numVertices = 14;
 		const uint32_t numVertices = 14;
 		const uint32_t numIndices  = 36;
 		const uint32_t numIndices  = 36;
-		if (bgfx::checkAvailTransientBuffers(numVertices, PosNormalVertex::ms_decl, numIndices) )
+		if (checkAvailTransientBuffers(numVertices, PosNormalVertex::ms_decl, numIndices) )
 		{
 		{
 			bgfx::TransientVertexBuffer tvb;
 			bgfx::TransientVertexBuffer tvb;
 			bgfx::allocTransientVertexBuffer(&tvb, numVertices, PosNormalVertex::ms_decl);
 			bgfx::allocTransientVertexBuffer(&tvb, numVertices, PosNormalVertex::ms_decl);
@@ -2335,7 +2336,7 @@ struct Imgui
 		}
 		}
 
 
 		uint32_t numVertices = _numCoords*6 + (_numCoords-2)*3;
 		uint32_t numVertices = _numCoords*6 + (_numCoords-2)*3;
-		if (bgfx::checkAvailTransientVertexBuffer(numVertices, PosColorVertex::ms_decl) )
+		if (numVertices == bgfx::getAvailTransientVertexBuffer(numVertices, PosColorVertex::ms_decl) )
 		{
 		{
 			bgfx::TransientVertexBuffer tvb;
 			bgfx::TransientVertexBuffer tvb;
 			bgfx::allocTransientVertexBuffer(&tvb, numVertices, PosColorVertex::ms_decl);
 			bgfx::allocTransientVertexBuffer(&tvb, numVertices, PosColorVertex::ms_decl);
@@ -2622,7 +2623,7 @@ struct Imgui
 			getTextLength(m_fonts[m_currentFontIdx].m_cdata, _text, numVertices);
 			getTextLength(m_fonts[m_currentFontIdx].m_cdata, _text, numVertices);
 		}
 		}
 
 
-		if (bgfx::checkAvailTransientVertexBuffer(numVertices, PosColorUvVertex::ms_decl) )
+		if (numVertices == bgfx::getAvailTransientVertexBuffer(numVertices, PosColorUvVertex::ms_decl) )
 		{
 		{
 			bgfx::TransientVertexBuffer tvb;
 			bgfx::TransientVertexBuffer tvb;
 			bgfx::allocTransientVertexBuffer(&tvb, numVertices, PosColorUvVertex::ms_decl);
 			bgfx::allocTransientVertexBuffer(&tvb, numVertices, PosColorUvVertex::ms_decl);
@@ -2712,7 +2713,7 @@ struct Imgui
 
 
 	bool screenQuad(int32_t _x, int32_t _y, int32_t _width, uint32_t _height, bool _originBottomLeft = false)
 	bool screenQuad(int32_t _x, int32_t _y, int32_t _width, uint32_t _height, bool _originBottomLeft = false)
 	{
 	{
-		if (bgfx::checkAvailTransientVertexBuffer(6, PosUvVertex::ms_decl) )
+		if (6 == bgfx::getAvailTransientVertexBuffer(6, PosUvVertex::ms_decl) )
 		{
 		{
 			bgfx::TransientVertexBuffer vb;
 			bgfx::TransientVertexBuffer vb;
 			bgfx::allocTransientVertexBuffer(&vb, 6, PosUvVertex::ms_decl);
 			bgfx::allocTransientVertexBuffer(&vb, 6, PosUvVertex::ms_decl);

+ 2 - 2
examples/common/imgui/ocornut_imgui.cpp

@@ -11,6 +11,7 @@
 #include <ocornut-imgui/imgui.h>
 #include <ocornut-imgui/imgui.h>
 #include "imgui.h"
 #include "imgui.h"
 #include "ocornut_imgui.h"
 #include "ocornut_imgui.h"
+#include "../bgfx_utils.h"
 
 
 #ifndef USE_ENTRY
 #ifndef USE_ENTRY
 #	if defined(SCI_NAMESPACE)
 #	if defined(SCI_NAMESPACE)
@@ -86,8 +87,7 @@ struct OcornutImguiContext
 			uint32_t numVertices = (uint32_t)drawList->VtxBuffer.size();
 			uint32_t numVertices = (uint32_t)drawList->VtxBuffer.size();
 			uint32_t numIndices  = (uint32_t)drawList->IdxBuffer.size();
 			uint32_t numIndices  = (uint32_t)drawList->IdxBuffer.size();
 
 
-			if (!bgfx::checkAvailTransientVertexBuffer(numVertices, m_decl)
-			||  !bgfx::checkAvailTransientIndexBuffer(numIndices) )
+			if (!checkAvailTransientBuffers(numVertices, m_decl, numIndices) )
 			{
 			{
 				// not enough space in transient buffer just quit drawing the rest...
 				// not enough space in transient buffer just quit drawing the rest...
 				break;
 				break;

+ 10 - 25
include/bgfx/bgfx.h

@@ -1391,46 +1391,31 @@ namespace bgfx
 	///
 	///
 	void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle);
 	void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle);
 
 
-	/// Returns true if internal transient index buffer has enough space.
+	/// Returns number of available indices.
 	///
 	///
-	/// @param[in] _num Number of indices.
+	/// @param[in] _num Number of required indices.
 	///
 	///
-	/// @attention C99 equivalent is `bgfx_check_avail_transient_index_buffer`.
+	/// @attention C99 equivalent is `bgfx_get_avail_transient_index_buffer`.
 	///
 	///
-	bool checkAvailTransientIndexBuffer(uint32_t _num);
+	uint32_t getAvailTransientIndexBuffer(uint32_t _num);
 
 
-	/// Returns true if internal transient vertex buffer has enough space.
+	/// Returns number of available vertices.
 	///
 	///
-	/// @param[in] _num Number of vertices.
+	/// @param[in] _num Number of required vertices.
 	/// @param[in] _decl Vertex declaration.
 	/// @param[in] _decl Vertex declaration.
 	///
 	///
 	/// @attention C99 equivalent is `bgfx_check_avail_transient_vertex_buffer`.
 	/// @attention C99 equivalent is `bgfx_check_avail_transient_vertex_buffer`.
 	///
 	///
-	bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl);
+	uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl);
 
 
-	/// Returns true if internal instance data buffer has enough space.
+	/// Returns number of available instance buffer slots.
 	///
 	///
-	/// @param[in] _num Number of instances.
+	/// @param[in] _num Number of required instances.
 	/// @param[in] _stride Stride per instance.
 	/// @param[in] _stride Stride per instance.
 	///
 	///
 	/// @attention C99 equivalent is `bgfx_check_avail_instance_data_buffer`.
 	/// @attention C99 equivalent is `bgfx_check_avail_instance_data_buffer`.
 	///
 	///
-	bool checkAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride);
-
-	/// Returns true if both internal transient index and vertex buffer have
-	/// enough space.
-	///
-	/// @param[in] _numVertices Number of vertices.
-	/// @param[in] _decl Vertex declaration.
-	/// @param[in] _numIndices Number of indices.
-	///
-	/// @attention C99 equivalent is `bgfx_check_avail_transient_buffers`.
-	///
-	bool checkAvailTransientBuffers(
-		  uint32_t _numVertices
-		, const VertexDecl& _decl
-		, uint32_t _numIndices
-		);
+	uint32_t getAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride);
 
 
 	/// Allocate transient index buffer.
 	/// Allocate transient index buffer.
 	///
 	///

+ 3 - 6
include/bgfx/c99/bgfx.h

@@ -648,16 +648,13 @@ BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_han
 BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle);
 BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle);
 
 
 /**/
 /**/
-BGFX_C_API bool bgfx_check_avail_transient_index_buffer(uint32_t _num);
+BGFX_C_API uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num);
 
 
 /**/
 /**/
-BGFX_C_API bool bgfx_check_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl);
+BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl);
 
 
 /**/
 /**/
-BGFX_C_API bool bgfx_check_avail_instance_data_buffer(uint32_t _num, uint16_t _stride);
-
-/**/
-BGFX_C_API bool bgfx_check_avail_transient_buffers(uint32_t _numVertices, const bgfx_vertex_decl_t* _decl, uint32_t _numIndices);
+BGFX_C_API uint32_t bgfx_get_avail_instance_data_buffer(uint32_t _num, uint16_t _stride);
 
 
 /**/
 /**/
 BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num);
 BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num);

+ 3 - 4
include/bgfx/c99/platform.h

@@ -113,10 +113,9 @@ typedef struct bgfx_interface_vtbl
     bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer_mem)(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
     bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer_mem)(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
     void (*update_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t* _mem);
     void (*update_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t* _mem);
     void (*destroy_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle);
     void (*destroy_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle);
-    bool (*check_avail_transient_index_buffer)(uint32_t _num);
-    bool (*check_avail_transient_vertex_buffer)(uint32_t _num, const bgfx_vertex_decl_t* _decl);
-    bool (*check_avail_instance_data_buffer)(uint32_t _num, uint16_t _stride);
-    bool (*check_avail_transient_buffers)(uint32_t _numVertices, const bgfx_vertex_decl_t* _decl, uint32_t _numIndices);
+    uint32_t (*get_avail_transient_index_buffer)(uint32_t _num);
+    uint32_t (*get_avail_transient_vertex_buffer)(uint32_t _num, const bgfx_vertex_decl_t* _decl);
+    uint32_t (*get_avail_instance_data_buffer)(uint32_t _num, uint16_t _stride);
     void (*alloc_transient_index_buffer)(bgfx_transient_index_buffer_t* _tib, uint32_t _num);
     void (*alloc_transient_index_buffer)(bgfx_transient_index_buffer_t* _tib, uint32_t _num);
     void (*alloc_transient_vertex_buffer)(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t* _decl);
     void (*alloc_transient_vertex_buffer)(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t* _decl);
     bool (*alloc_transient_buffers)(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices);
     bool (*alloc_transient_buffers)(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices);

+ 1 - 1
include/bgfx/defines.h

@@ -6,7 +6,7 @@
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 
 
-#define BGFX_API_VERSION UINT32_C(33)
+#define BGFX_API_VERSION UINT32_C(34)
 
 
 ///
 ///
 #define BGFX_STATE_RGB_WRITE               UINT64_C(0x0000000000000001) //!< Enable RGB write.
 #define BGFX_STATE_RGB_WRITE               UINT64_C(0x0000000000000001) //!< Enable RGB write.

+ 17 - 31
src/bgfx.cpp

@@ -2862,34 +2862,26 @@ error:
 		s_ctx->destroyDynamicVertexBuffer(_handle);
 		s_ctx->destroyDynamicVertexBuffer(_handle);
 	}
 	}
 
 
-	bool checkAvailTransientIndexBuffer(uint32_t _num)
+	uint32_t getAvailTransientIndexBuffer(uint32_t _num)
 	{
 	{
 		BGFX_CHECK_MAIN_THREAD();
 		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(0 < _num, "Requesting 0 indices.");
 		BX_CHECK(0 < _num, "Requesting 0 indices.");
-		return s_ctx->checkAvailTransientIndexBuffer(_num);
+		return s_ctx->getAvailTransientIndexBuffer(_num);
 	}
 	}
 
 
-	bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl)
+	uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl)
 	{
 	{
 		BGFX_CHECK_MAIN_THREAD();
 		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(0 < _num, "Requesting 0 vertices.");
 		BX_CHECK(0 < _num, "Requesting 0 vertices.");
 		BX_CHECK(0 != _decl.m_stride, "Invalid VertexDecl.");
 		BX_CHECK(0 != _decl.m_stride, "Invalid VertexDecl.");
-		return s_ctx->checkAvailTransientVertexBuffer(_num, _decl.m_stride);
+		return s_ctx->getAvailTransientVertexBuffer(_num, _decl.m_stride);
 	}
 	}
 
 
-	bool checkAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride)
+	uint32_t getAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride)
 	{
 	{
 		BGFX_CHECK_MAIN_THREAD();
 		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(0 < _num, "Requesting 0 instances.");
 		BX_CHECK(0 < _num, "Requesting 0 instances.");
-		return s_ctx->checkAvailTransientVertexBuffer(_num, _stride);
-	}
-
-	bool checkAvailTransientBuffers(uint32_t _numVertices, const VertexDecl& _decl, uint32_t _numIndices)
-	{
-		BX_CHECK(0 != _decl.m_stride, "Invalid VertexDecl.");
-		return checkAvailTransientVertexBuffer(_numVertices, _decl)
-			&& checkAvailTransientIndexBuffer(_numIndices)
-			;
+		return s_ctx->getAvailTransientVertexBuffer(_num, _stride);
 	}
 	}
 
 
 	void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num)
 	void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num)
@@ -2920,7 +2912,8 @@ error:
 
 
 	bool allocTransientBuffers(bgfx::TransientVertexBuffer* _tvb, const bgfx::VertexDecl& _decl, uint32_t _numVertices, bgfx::TransientIndexBuffer* _tib, uint32_t _numIndices)
 	bool allocTransientBuffers(bgfx::TransientVertexBuffer* _tvb, const bgfx::VertexDecl& _decl, uint32_t _numVertices, bgfx::TransientIndexBuffer* _tib, uint32_t _numIndices)
 	{
 	{
-		if (checkAvailTransientBuffers(_numVertices, _decl, _numIndices) )
+		if (_numVertices == getAvailTransientVertexBuffer(_numVertices, _decl)
+		&&  _numIndices  == getAvailTransientIndexBuffer(_numIndices) )
 		{
 		{
 			allocTransientVertexBuffer(_tvb, _numVertices, _decl);
 			allocTransientVertexBuffer(_tvb, _numVertices, _decl);
 			allocTransientIndexBuffer(_tib, _numIndices);
 			allocTransientIndexBuffer(_tib, _numIndices);
@@ -4274,26 +4267,20 @@ BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_ha
 	bgfx::destroyDynamicVertexBuffer(handle.cpp);
 	bgfx::destroyDynamicVertexBuffer(handle.cpp);
 }
 }
 
 
-BGFX_C_API bool bgfx_check_avail_transient_index_buffer(uint32_t _num)
+BGFX_C_API uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num)
 {
 {
-	return bgfx::checkAvailTransientIndexBuffer(_num);
+	return bgfx::getAvailTransientIndexBuffer(_num);
 }
 }
 
 
-BGFX_C_API bool bgfx_check_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl)
+BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl)
 {
 {
 	const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
 	const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
-	return bgfx::checkAvailTransientVertexBuffer(_num, decl);
+	return bgfx::getAvailTransientVertexBuffer(_num, decl);
 }
 }
 
 
-BGFX_C_API bool bgfx_check_avail_instance_data_buffer(uint32_t _num, uint16_t _stride)
+BGFX_C_API uint32_t bgfx_get_avail_instance_data_buffer(uint32_t _num, uint16_t _stride)
 {
 {
-	return bgfx::checkAvailInstanceDataBuffer(_num, _stride);
-}
-
-BGFX_C_API bool bgfx_check_avail_transient_buffers(uint32_t _numVertices, const bgfx_vertex_decl_t* _decl, uint32_t _numIndices)
-{
-	const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
-	return bgfx::checkAvailTransientBuffers(_numVertices, decl, _numIndices);
+	return bgfx::getAvailInstanceDataBuffer(_num, _stride);
 }
 }
 
 
 BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num)
 BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num)
@@ -4886,10 +4873,9 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
 	BGFX_IMPORT_FUNC(create_dynamic_vertex_buffer_mem) \
 	BGFX_IMPORT_FUNC(create_dynamic_vertex_buffer_mem) \
 	BGFX_IMPORT_FUNC(update_dynamic_vertex_buffer) \
 	BGFX_IMPORT_FUNC(update_dynamic_vertex_buffer) \
 	BGFX_IMPORT_FUNC(destroy_dynamic_vertex_buffer) \
 	BGFX_IMPORT_FUNC(destroy_dynamic_vertex_buffer) \
-	BGFX_IMPORT_FUNC(check_avail_transient_index_buffer) \
-	BGFX_IMPORT_FUNC(check_avail_transient_vertex_buffer) \
-	BGFX_IMPORT_FUNC(check_avail_instance_data_buffer) \
-	BGFX_IMPORT_FUNC(check_avail_transient_buffers) \
+	BGFX_IMPORT_FUNC(get_avail_transient_index_buffer) \
+	BGFX_IMPORT_FUNC(get_avail_transient_vertex_buffer) \
+	BGFX_IMPORT_FUNC(get_avail_instance_data_buffer) \
 	BGFX_IMPORT_FUNC(alloc_transient_index_buffer) \
 	BGFX_IMPORT_FUNC(alloc_transient_index_buffer) \
 	BGFX_IMPORT_FUNC(alloc_transient_vertex_buffer) \
 	BGFX_IMPORT_FUNC(alloc_transient_vertex_buffer) \
 	BGFX_IMPORT_FUNC(alloc_transient_buffers) \
 	BGFX_IMPORT_FUNC(alloc_transient_buffers) \

+ 18 - 16
src/bgfx_p.h

@@ -1701,39 +1701,41 @@ namespace bgfx
 
 
 		void sort();
 		void sort();
 
 
-		bool checkAvailTransientIndexBuffer(uint32_t _num)
+		uint32_t getAvailTransientIndexBuffer(uint32_t _num)
 		{
 		{
-			uint32_t offset = m_iboffset;
+			uint32_t offset   = bx::strideAlign(m_iboffset, sizeof(uint16_t) );
 			uint32_t iboffset = offset + _num*sizeof(uint16_t);
 			uint32_t iboffset = offset + _num*sizeof(uint16_t);
 			iboffset = bx::uint32_min(iboffset, BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE);
 			iboffset = bx::uint32_min(iboffset, BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE);
 			uint32_t num = (iboffset-offset)/sizeof(uint16_t);
 			uint32_t num = (iboffset-offset)/sizeof(uint16_t);
-			return num == _num;
+			return num;
 		}
 		}
 
 
 		uint32_t allocTransientIndexBuffer(uint32_t& _num)
 		uint32_t allocTransientIndexBuffer(uint32_t& _num)
 		{
 		{
 			uint32_t offset = bx::strideAlign(m_iboffset, sizeof(uint16_t) );
 			uint32_t offset = bx::strideAlign(m_iboffset, sizeof(uint16_t) );
-			m_iboffset = offset + _num*sizeof(uint16_t);
-			m_iboffset = bx::uint32_min(m_iboffset, BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE);
-			_num = (m_iboffset-offset)/sizeof(uint16_t);
+			uint32_t num    = getAvailTransientIndexBuffer(_num);
+			m_iboffset = offset + num*sizeof(uint16_t);
+			_num = num;
+
 			return offset;
 			return offset;
 		}
 		}
 
 
-		bool checkAvailTransientVertexBuffer(uint32_t _num, uint16_t _stride)
+		uint32_t getAvailTransientVertexBuffer(uint32_t _num, uint16_t _stride)
 		{
 		{
-			uint32_t offset = bx::strideAlign(m_vboffset, _stride);
+			uint32_t offset   = bx::strideAlign(m_vboffset, _stride);
 			uint32_t vboffset = offset + _num * _stride;
 			uint32_t vboffset = offset + _num * _stride;
 			vboffset = bx::uint32_min(vboffset, BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE);
 			vboffset = bx::uint32_min(vboffset, BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE);
 			uint32_t num = (vboffset-offset)/_stride;
 			uint32_t num = (vboffset-offset)/_stride;
-			return num == _num;
+			return num;
 		}
 		}
 
 
 		uint32_t allocTransientVertexBuffer(uint32_t& _num, uint16_t _stride)
 		uint32_t allocTransientVertexBuffer(uint32_t& _num, uint16_t _stride)
 		{
 		{
 			uint32_t offset = bx::strideAlign(m_vboffset, _stride);
 			uint32_t offset = bx::strideAlign(m_vboffset, _stride);
-			m_vboffset = offset + _num * _stride;
-			m_vboffset = bx::uint32_min(m_vboffset, BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE);
-			_num = (m_vboffset-offset)/_stride;
+			uint32_t num    = getAvailTransientVertexBuffer(_num, _stride);
+			m_vboffset = offset + num * _stride;
+			_num = num;
+
 			return offset;
 			return offset;
 		}
 		}
 
 
@@ -2689,14 +2691,14 @@ namespace bgfx
 			m_dynamicVertexBufferHandle.free(_handle.idx);
 			m_dynamicVertexBufferHandle.free(_handle.idx);
 		}
 		}
 
 
-		BGFX_API_FUNC(bool checkAvailTransientIndexBuffer(uint32_t _num) const)
+		BGFX_API_FUNC(uint32_t getAvailTransientIndexBuffer(uint32_t _num) const)
 		{
 		{
-			return m_submit->checkAvailTransientIndexBuffer(_num);
+			return m_submit->getAvailTransientIndexBuffer(_num);
 		}
 		}
 
 
-		BGFX_API_FUNC(bool checkAvailTransientVertexBuffer(uint32_t _num, uint16_t _stride) const)
+		BGFX_API_FUNC(uint32_t getAvailTransientVertexBuffer(uint32_t _num, uint16_t _stride) const)
 		{
 		{
-			return m_submit->checkAvailTransientVertexBuffer(_num, _stride);
+			return m_submit->getAvailTransientVertexBuffer(_num, _stride);
 		}
 		}
 
 
 		TransientIndexBuffer* createTransientIndexBuffer(uint32_t _size)
 		TransientIndexBuffer* createTransientIndexBuffer(uint32_t _size)

+ 1 - 1
tools/texturev/texturev.cpp

@@ -384,7 +384,7 @@ bgfx::VertexDecl PosUvColorVertex::ms_decl;
 
 
 bool screenQuad(int32_t _x, int32_t _y, int32_t _width, uint32_t _height, uint32_t _abgr, bool _originBottomLeft = false)
 bool screenQuad(int32_t _x, int32_t _y, int32_t _width, uint32_t _height, uint32_t _abgr, bool _originBottomLeft = false)
 {
 {
-	if (bgfx::checkAvailTransientVertexBuffer(6, PosUvColorVertex::ms_decl) )
+	if (6 == bgfx::getAvailTransientVertexBuffer(6, PosUvColorVertex::ms_decl) )
 	{
 	{
 		bgfx::TransientVertexBuffer vb;
 		bgfx::TransientVertexBuffer vb;
 		bgfx::allocTransientVertexBuffer(&vb, 6, PosUvColorVertex::ms_decl);
 		bgfx::allocTransientVertexBuffer(&vb, 6, PosUvColorVertex::ms_decl);