Browse Source

Allow allocation of DVBs/DIBs larger than the predefined sizes.

jdryg 9 years ago
parent
commit
c325a56ed0
1 changed files with 8 additions and 4 deletions
  1. 8 4
      src/bgfx_p.h

+ 8 - 4
src/bgfx_p.h

@@ -2282,12 +2282,14 @@ namespace bgfx
 					return ptr;
 				}
 
+				uint32_t allocSize = bx::uint32_max(BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE, _size);
+
 				CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicIndexBuffer);
 				cmdbuf.write(indexBufferHandle);
-				cmdbuf.write(BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE);
+				cmdbuf.write(allocSize);
 				cmdbuf.write(_flags);
 
-				m_dynIndexBufferAllocator.add(uint64_t(indexBufferHandle.idx) << 32, BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE);
+				m_dynIndexBufferAllocator.add(uint64_t(indexBufferHandle.idx) << 32, allocSize);
 				ptr = m_dynIndexBufferAllocator.alloc(_size);
 			}
 
@@ -2432,12 +2434,14 @@ namespace bgfx
 					return NonLocalAllocator::invalidBlock;
 				}
 
+				uint32_t allocSize = bx::uint32_max(BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE, _size);
+
 				CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer);
 				cmdbuf.write(vertexBufferHandle);
-				cmdbuf.write(BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE);
+				cmdbuf.write(allocSize);
 				cmdbuf.write(_flags);
 
-				m_dynVertexBufferAllocator.add(uint64_t(vertexBufferHandle.idx)<<32, BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE);
+				m_dynVertexBufferAllocator.add(uint64_t(vertexBufferHandle.idx) << 32, allocSize);
 				ptr = m_dynVertexBufferAllocator.alloc(_size);
 			}