|
|
@@ -2703,8 +2703,12 @@ namespace bgfx
|
|
|
|
|
|
if (!isValid(declHandle) )
|
|
|
{
|
|
|
- VertexDeclHandle temp = { m_vertexDeclHandle.alloc() };
|
|
|
- declHandle = temp;
|
|
|
+ declHandle.idx = m_vertexDeclHandle.alloc();
|
|
|
+ if (!isValid(declHandle) )
|
|
|
+ {
|
|
|
+ return declHandle;
|
|
|
+ }
|
|
|
+
|
|
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexDecl);
|
|
|
cmdbuf.write(declHandle);
|
|
|
cmdbuf.write(_decl);
|
|
|
@@ -2717,10 +2721,16 @@ namespace bgfx
|
|
|
{
|
|
|
VertexBufferHandle handle = { m_vertexBufferHandle.alloc() };
|
|
|
|
|
|
- BX_WARN(isValid(handle), "Failed to allocate vertex buffer handle.");
|
|
|
if (isValid(handle) )
|
|
|
{
|
|
|
VertexDeclHandle declHandle = findVertexDecl(_decl);
|
|
|
+ if (!isValid(declHandle) )
|
|
|
+ {
|
|
|
+ BX_TRACE("WARNING: Failed to allocate vertex decl handle (BGFX_CONFIG_MAX_VERTEX_DECLS, max: %d).", BGFX_CONFIG_MAX_VERTEX_DECLS);
|
|
|
+ m_vertexBufferHandle.free(handle.idx);
|
|
|
+ return BGFX_INVALID_HANDLE;
|
|
|
+ }
|
|
|
+
|
|
|
m_declRef.add(handle, declHandle, _decl.m_hash);
|
|
|
|
|
|
m_vertexBuffers[handle.idx].m_stride = _decl.m_stride;
|
|
|
@@ -2730,13 +2740,14 @@ namespace bgfx
|
|
|
cmdbuf.write(_mem);
|
|
|
cmdbuf.write(declHandle);
|
|
|
cmdbuf.write(_flags);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- release(_mem);
|
|
|
+
|
|
|
+ return handle;
|
|
|
}
|
|
|
|
|
|
- return handle;
|
|
|
+ BX_TRACE("WARNING: Failed to allocate vertex buffer handle (BGFX_CONFIG_MAX_VERTEX_BUFFERS, max: %d).", BGFX_CONFIG_MAX_VERTEX_BUFFERS);
|
|
|
+ release(_mem);
|
|
|
+
|
|
|
+ return BGFX_INVALID_HANDLE;
|
|
|
}
|
|
|
|
|
|
BGFX_API_FUNC(void destroyVertexBuffer(VertexBufferHandle _handle) )
|
|
|
@@ -2960,6 +2971,7 @@ namespace bgfx
|
|
|
VertexBufferHandle vertexBufferHandle = { m_vertexBufferHandle.alloc() };
|
|
|
if (!isValid(vertexBufferHandle) )
|
|
|
{
|
|
|
+ BX_TRACE("WARNING: Failed to allocate vertex buffer handle (BGFX_CONFIG_MAX_VERTEX_BUFFERS, max: %d).", BGFX_CONFIG_MAX_VERTEX_BUFFERS);
|
|
|
return handle;
|
|
|
}
|
|
|
|
|
|
@@ -2980,8 +2992,19 @@ namespace bgfx
|
|
|
}
|
|
|
|
|
|
VertexDeclHandle declHandle = findVertexDecl(_decl);
|
|
|
+ if (!isValid(declHandle) )
|
|
|
+ {
|
|
|
+ BX_TRACE("WARNING: Failed to allocate vertex decl handle (BGFX_CONFIG_MAX_VERTEX_DECLS, max: %d).", BGFX_CONFIG_MAX_VERTEX_DECLS);
|
|
|
+ return handle;
|
|
|
+ }
|
|
|
|
|
|
handle.idx = m_dynamicVertexBufferHandle.alloc();
|
|
|
+ if (!isValid(handle) )
|
|
|
+ {
|
|
|
+ BX_TRACE("WARNING: Failed to allocate dynamic vertex buffer handle (BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS, max: %d).", BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS);
|
|
|
+ return handle;
|
|
|
+ }
|
|
|
+
|
|
|
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[handle.idx];
|
|
|
dvb.m_handle.idx = uint16_t(ptr>>32);
|
|
|
dvb.m_offset = uint32_t(ptr);
|