return node->VAO[0]->BufferBinding[0].Stride;
}
-
-/* These buffers should be a reasonable size to support upload to
- * hardware. Current vbo implementation will re-upload on any
- * changes, so don't make too big or apps which dynamically create
- * dlists and use only a few times will suffer.
- *
- * Consider stategy of uploading regions from the VBO on demand in the
- * case of dynamic vbos. Then make the dlist code signal that
- * likelyhood as it occurs. No reason we couldn't change usage
- * internally even though this probably isn't allowed for client VBOs?
+/* Default size for the buffer holding the vertices and the indices.
+ * A bigger buffer helps reducing the number of draw calls but may
+ * waste memory.
*/
-#define VBO_SAVE_BUFFER_SIZE (256*1024) /* dwords */
-#define VBO_SAVE_PRIM_SIZE 128
-#define VBO_SAVE_PRIM_MODE_MASK 0x3f
-#define VBO_SAVE_INDEX_SIZE (32 * 1024)
+#define VBO_SAVE_BUFFER_SIZE (20*1024*1024)
+#define VBO_SAVE_PRIM_MODE_MASK 0x3f
struct vbo_save_vertex_store {
fi_type *buffer_in_ram;
if (!store)
store = CALLOC_STRUCT(vbo_save_vertex_store);
- int new_size = MAX2(vertex_count * vertex_size, VBO_SAVE_BUFFER_SIZE) * sizeof(GLfloat);
+ int new_size = MAX2(vertex_count * vertex_size * sizeof(GLfloat), 1024 * 1024);
if (new_size > store->buffer_in_ram_size) {
store->buffer_in_ram_size = new_size;
store->buffer_in_ram = realloc(store->buffer_in_ram, store->buffer_in_ram_size);
{
if (store == NULL)
store = CALLOC_STRUCT(vbo_save_primitive_store);
+
uint32_t old_size = store->size;
- store->size = MAX3(store->size, prim_count, VBO_SAVE_PRIM_SIZE);
+ store->size = MAX3(store->size, prim_count, 128);
store->prims = realloc(store->prims, store->size * sizeof(struct _mesa_prim));
memset(&store->prims[old_size], 0, (store->size - old_size) * sizeof(struct _mesa_prim));
store->used = 0;
realloc_storage(struct gl_context *ctx, int prim_count, int vertex_count)
{
struct vbo_save_context *save = &vbo_context(ctx)->save;
- const int ten_MB = 10 * 1024 * 1024;
/* Limit how much memory we allocate. */
if (save->prim_store->used > 0 &&
vertex_count > 0 &&
- vertex_count * save->vertex_size > ten_MB) {
+ vertex_count * save->vertex_size > VBO_SAVE_BUFFER_SIZE) {
wrap_filled_vertex(ctx);
- vertex_count = ten_MB / save->vertex_size;
+ vertex_count = VBO_SAVE_BUFFER_SIZE / save->vertex_size;
}
if (prim_count > 0 &&
- prim_count * sizeof(struct _mesa_prim) > ten_MB) {
+ prim_count * sizeof(struct _mesa_prim) > VBO_SAVE_BUFFER_SIZE) {
if (save->prim_store->used > 0)
compile_vertex_list(ctx);
- prim_count = ten_MB / sizeof(struct _mesa_prim);
+ prim_count = VBO_SAVE_BUFFER_SIZE / sizeof(struct _mesa_prim);
}
if (vertex_count >= 0)
save->current_bo = ctx->Driver.NewBufferObject(ctx, VBO_BUF_ID + 1);
bool success = ctx->Driver.BufferData(ctx,
GL_ELEMENT_ARRAY_BUFFER_ARB,
- MAX2(total_bytes_needed, VBO_SAVE_BUFFER_SIZE * sizeof(uint32_t)),
+ MAX2(total_bytes_needed, VBO_SAVE_BUFFER_SIZE),
NULL,
GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT,
save->current_bo);
save->current_bo = ctx->Driver.NewBufferObject(ctx, VBO_BUF_ID + 1);
bool success = ctx->Driver.BufferData(ctx,
GL_ELEMENT_ARRAY_BUFFER_ARB,
- VBO_SAVE_BUFFER_SIZE * sizeof(uint32_t),
+ VBO_SAVE_BUFFER_SIZE,
NULL,
GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT,
save->current_bo);