}
static vg_lines;
+#define VG_LINES_BUFFER_SIZE 50000 * sizeof( struct vg_lines_vert )
+
static void async_vg_lines_init( void *payload, u32 payload_size ){
glGenVertexArrays( 1, &vg_lines.vao );
glGenBuffers( 1, &vg_lines.vbo );
glBindVertexArray( vg_lines.vao );
glBindBuffer( GL_ARRAY_BUFFER, vg_lines.vbo );
- u32 size = 50000 * sizeof( struct vg_lines_vert );
-
- vg_lines.vertex_buffer =
- vg_create_linear_allocator(vg_mem.rtmemory, size, VG_MEMORY_REALTIME);
-
- glBufferData( GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW );
+ glBufferData( GL_ARRAY_BUFFER, VG_LINES_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW );
glBindVertexArray( vg_lines.vao );
VG_CHECK_GL_ERR();
}
static void vg_lines_init(void){
+ vg_lines.vertex_buffer =
+ vg_create_linear_allocator( vg_mem.rtmemory,
+ VG_LINES_BUFFER_SIZE, VG_MEMORY_REALTIME);
+
vg_async_call( async_vg_lines_init, NULL, 0 );
vg_console_reg_var( "vg_lines", &vg_lines.draw, k_var_dtype_i32,
VG_VAR_CHEAT );
vg_shader_register( &_shader_lines );
-
}
static void vg_lines_drawall( void ){
alloc->cur = 0;
}
-/* allocate a FIXED SIZE linear allocator */
+/* allocate a FIXED SIZE linear allocator
+ *
+ * FIXME: there was a bug in vg's code that caused a race condition between
+ * two system allocations. make this IMPOSSIBLE by requiring a lock
+ * on the allocater to be passed between threads.
+ *
+ * luckily that bug only exists when using development tools, but still!
+ *
+ * this should then only be checked and turned on in debugging.
+ *
+ */
static void *_vg_create_linear_allocator( void *lin_alloc, u32 size,
u16 flags, const char *constr_name)
{