diff --git a/include/bgfx.h b/include/bgfx.h index 571b6b41c..805c90053 100644 --- a/include/bgfx.h +++ b/include/bgfx.h @@ -590,14 +590,14 @@ namespace bgfx /// /// @param _num Number of indices. /// - bool checkAvailTransientIndexBuffer(uint16_t _num); + bool checkAvailTransientIndexBuffer(uint32_t _num); /// Returns true if internal transient vertex buffer has enough space. /// /// @param _num Number of vertices. /// @param _decl Vertex declaration. /// - bool checkAvailTransientVertexBuffer(uint16_t _num, const VertexDecl& _decl); + bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl); /// Returns true if both internal transient index and vertex buffer have /// enough space. @@ -606,7 +606,7 @@ namespace bgfx /// @param _decl Vertex declaration. /// @param _numIndices Number of indices. /// - bool checkAvailTransientBuffers(uint16_t _numVertices, const VertexDecl& _decl, uint16_t _numIndices); + bool checkAvailTransientBuffers(uint32_t _numVertices, const VertexDecl& _decl, uint32_t _numIndices); /// Allocate transient index buffer. /// @@ -614,7 +614,7 @@ namespace bgfx /// reused for multiple draw calls. /// @param _num number of indices to allocate. /// - void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint16_t _num); + void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num); /// Allocate transient vertex buffer. /// @@ -623,10 +623,10 @@ namespace bgfx /// @param _num number of vertices to allocate. /// @param _decl vertex declaration. /// - void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint16_t _num, const VertexDecl& _decl); + void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexDecl& _decl); /// Allocate instance data buffer. - const InstanceDataBuffer* allocInstanceDataBuffer(uint16_t _num, uint16_t _stride); + const InstanceDataBuffer* allocInstanceDataBuffer(uint32_t _num, uint16_t _stride); /// Create vertex shader from memory buffer. VertexShaderHandle createVertexShader(const Memory* _mem); diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 469a50b55..922e62988 100755 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -924,28 +924,28 @@ namespace bgfx s_ctx.destroyDynamicVertexBuffer(_handle); } - bool checkAvailTransientIndexBuffer(uint16_t _num) + bool checkAvailTransientIndexBuffer(uint32_t _num) { BGFX_CHECK_MAIN_THREAD(); BX_CHECK(0 < _num, "Requesting 0 indices."); return s_ctx.m_submit->checkAvailTransientIndexBuffer(_num); } - bool checkAvailTransientVertexBuffer(uint16_t _num, const VertexDecl& _decl) + bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl) { BGFX_CHECK_MAIN_THREAD(); BX_CHECK(0 < _num, "Requesting 0 vertices."); return s_ctx.m_submit->checkAvailTransientVertexBuffer(_num, _decl.m_stride); } - bool checkAvailTransientBuffers(uint16_t _numVertices, const VertexDecl& _decl, uint16_t _numIndices) + bool checkAvailTransientBuffers(uint32_t _numVertices, const VertexDecl& _decl, uint32_t _numIndices) { return checkAvailTransientVertexBuffer(_numVertices, _decl) && checkAvailTransientIndexBuffer(_numIndices) ; } - void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint16_t _num) + void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num) { BGFX_CHECK_MAIN_THREAD(); BX_CHECK(NULL != _tib, "_tib can't be NULL"); @@ -953,15 +953,16 @@ namespace bgfx return s_ctx.allocTransientIndexBuffer(_tib, _num); } - void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint16_t _num, const VertexDecl& _decl) + void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexDecl& _decl) { BGFX_CHECK_MAIN_THREAD(); BX_CHECK(NULL != _tvb, "_tvb can't be NULL"); BX_CHECK(0 < _num, "Requesting 0 vertices."); + BX_CHECK(UINT16_MAX >= _num, "Requesting %d vertices (max: %d).", _num, UINT16_MAX); return s_ctx.allocTransientVertexBuffer(_tvb, _num, _decl); } - const InstanceDataBuffer* allocInstanceDataBuffer(uint16_t _num, uint16_t _stride) + const InstanceDataBuffer* allocInstanceDataBuffer(uint32_t _num, uint16_t _stride) { BGFX_CHECK_MAIN_THREAD(); BX_CHECK(0 < _num, "Requesting 0 instanced data vertices."); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 9e9b13800..b6602ceb5 100755 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -1107,7 +1107,7 @@ namespace bgfx void submitMask(uint32_t _viewMask, int32_t _depth); void sort(); - bool checkAvailTransientIndexBuffer(uint16_t _num) + bool checkAvailTransientIndexBuffer(uint32_t _num) { uint32_t offset = m_iboffset; uint32_t iboffset = offset + _num*sizeof(uint16_t); @@ -1116,16 +1116,16 @@ namespace bgfx return num == _num; } - uint32_t allocTransientIndexBuffer(uint16_t& _num) + uint32_t allocTransientIndexBuffer(uint32_t& _num) { uint32_t offset = m_iboffset; m_iboffset = offset + _num*sizeof(uint16_t); m_iboffset = uint32_min(m_iboffset, BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE); - _num = uint16_t( (m_iboffset-offset)/sizeof(uint16_t) ); + _num = (m_iboffset-offset)/sizeof(uint16_t); return offset; } - bool checkAvailTransientVertexBuffer(uint16_t _num, uint16_t _stride) + bool checkAvailTransientVertexBuffer(uint32_t _num, uint16_t _stride) { uint32_t offset = strideAlign(m_vboffset, _stride); uint32_t vboffset = offset + _num * _stride; @@ -1134,12 +1134,12 @@ namespace bgfx return num == _num; } - uint32_t allocTransientVertexBuffer(uint16_t& _num, uint16_t _stride) + uint32_t allocTransientVertexBuffer(uint32_t& _num, uint16_t _stride) { uint32_t offset = strideAlign(m_vboffset, _stride); m_vboffset = offset + _num * _stride; m_vboffset = uint32_min(m_vboffset, BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE); - _num = uint16_t( (m_vboffset-offset)/_stride); + _num = (m_vboffset-offset)/_stride; return offset; } @@ -1781,7 +1781,7 @@ namespace bgfx g_free(const_cast(_ib) ); } - void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint16_t _num) + void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num) { uint32_t offset = m_submit->allocTransientIndexBuffer(_num); @@ -1838,7 +1838,7 @@ namespace bgfx g_free(const_cast(_vb) ); } - void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint16_t _num, const VertexDecl& _decl) + void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexDecl& _decl) { VertexDeclHandle declHandle = m_declRef.find(_decl.m_hash); @@ -1864,7 +1864,7 @@ namespace bgfx _tvb->decl = declHandle; } - const InstanceDataBuffer* allocInstanceDataBuffer(uint16_t _num, uint16_t _stride) + const InstanceDataBuffer* allocInstanceDataBuffer(uint32_t _num, uint16_t _stride) { uint16_t stride = BX_ALIGN_16(_stride); uint32_t offset = m_submit->allocTransientVertexBuffer(_num, stride);