commit 053b37bf1a9396e853105b33e69120fba332d715 parent 6fc8931245a0a9f1361a2f16df0ddd73e4c4939c Author: Michael Savage <mikejsavage@gmail.com> Date: Thu Aug 31 22:44:59 +0300 Map UBO with INVALIDATE_BUFFER/UNSYNCHRONIZED to avoid stalls entirely Diffstat:
renderer.cc | | | 6 | +++--- |
diff --git a/renderer.cc b/renderer.cc @@ -102,6 +102,7 @@ static void bind_fb( FB fb ) { void renderer_init() { glGenBuffers( 1, &uniforms ); glBindBuffer( GL_UNIFORM_BUFFER, uniforms ); + glBufferData( GL_UNIFORM_BUFFER, UNIFORM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW ); in_frame = false; in_pass = false; @@ -123,8 +124,8 @@ void renderer_begin_frame() { deletes.clear(); render_passes.clear(); - glBufferData( GL_UNIFORM_BUFFER, UNIFORM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW ); - uniforms_buffer = ( u8 * ) glMapBuffer( GL_UNIFORM_BUFFER, GL_WRITE_ONLY ); + GLbitfield bits = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT; + uniforms_buffer = ( u8 * ) glMapBufferRange( GL_UNIFORM_BUFFER, 0, UNIFORM_BUFFER_SIZE, bits ); ASSERT( uniforms_buffer != NULL ); uniforms_offset = 0; } @@ -137,7 +138,6 @@ void renderer_end_frame() { ASSERT( in_frame ); in_frame = false; - glBindBuffer( GL_UNIFORM_BUFFER, uniforms ); // TODO: not necessary glUnmapBuffer( GL_UNIFORM_BUFFER ); uniforms_buffer = NULL;