mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Added ability to configure minimum uniform buffer size. PR #3478.
This commit is contained in:
committed by
Бранимир Караџић
parent
16cf4f8683
commit
55f997002f
11
src/bgfx_p.h
11
src/bgfx_p.h
@@ -1478,7 +1478,7 @@ namespace bgfx
|
||||
class UniformBuffer
|
||||
{
|
||||
public:
|
||||
static UniformBuffer* create(uint32_t _size) // = BGFX_CONFIG_UNIFORM_BUFFER_SIZE)
|
||||
static UniformBuffer* create(uint32_t _size)
|
||||
{
|
||||
const uint32_t structSize = sizeof(UniformBuffer)-sizeof(UniformBuffer::m_buffer);
|
||||
|
||||
@@ -1493,13 +1493,16 @@ namespace bgfx
|
||||
bx::free(g_allocator, _uniformBuffer);
|
||||
}
|
||||
|
||||
static void update(UniformBuffer** _uniformBuffer, uint32_t _threshold = 64<<10, uint32_t _grow = 1<<20)
|
||||
static void update(UniformBuffer** _uniformBuffer)
|
||||
{
|
||||
constexpr uint32_t kThreshold = BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_THRESHOLD_SIZE;
|
||||
constexpr uint32_t kIncrement = BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_INCREMENT_SIZE;
|
||||
|
||||
UniformBuffer* uniformBuffer = *_uniformBuffer;
|
||||
if (_threshold >= uniformBuffer->m_size - uniformBuffer->m_pos)
|
||||
if (kThreshold >= uniformBuffer->m_size - uniformBuffer->m_pos)
|
||||
{
|
||||
const uint32_t structSize = sizeof(UniformBuffer)-sizeof(UniformBuffer::m_buffer);
|
||||
uint32_t size = bx::alignUp(uniformBuffer->m_size + _grow, 16);
|
||||
uint32_t size = bx::alignUp(uniformBuffer->m_size + kIncrement, 16);
|
||||
void* data = bx::realloc(g_allocator, uniformBuffer, size+structSize);
|
||||
uniformBuffer = reinterpret_cast<UniformBuffer*>(data);
|
||||
uniformBuffer->m_size = size;
|
||||
|
||||
10
src/config.h
10
src/config.h
@@ -338,6 +338,16 @@ static_assert(bx::isPowerOf2(BGFX_CONFIG_MAX_VIEWS), "BGFX_CONFIG_MAX_VIEWS must
|
||||
# define BGFX_CONFIG_MIN_UNIFORM_BUFFER_SIZE (1<<20)
|
||||
#endif // BGFX_CONFIG_MIN_UNIFORM_BUFFER_SIZE
|
||||
|
||||
#ifndef BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_THRESHOLD_SIZE
|
||||
/// Max amount of unused uniform buffer space before uniform buffer resize.
|
||||
# define BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_THRESHOLD_SIZE (64<<10)
|
||||
#endif // BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_THRESHOLD_SIZE
|
||||
|
||||
#ifndef BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_INCREMENT_SIZE
|
||||
/// Increment of uniform buffer resize.
|
||||
# define BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_INCREMENT_SIZE (1<<20)
|
||||
#endif // BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_INCREMENT_SIZE
|
||||
|
||||
#ifndef BGFX_CONFIG_CACHED_DEVICE_MEMORY_ALLOCATIONS_SIZE
|
||||
/// Amount of allowed memory allocations left on device to use for recycling during
|
||||
/// later allocations. This can be beneficial in case the driver is slow allocating memory
|
||||
|
||||
Reference in New Issue
Block a user