Skip to content

Commit

Permalink
Fix crash with glMapBufferRange-based vertex buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
slipher authored and illwieckz committed Oct 20, 2024
1 parent bf8659b commit f989ce9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/engine/renderer/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2997,6 +2997,17 @@ void Tess_Clear()
tess.numIndexes = 0;
tess.numVertexes = 0;

// TODO: stop constantly binding VBOs we aren't going to use!
bool usingMapBufferRange = ( !glConfig2.bufferStorageAvailable || !glConfig2.syncAvailable )
&& glConfig2.mapBufferRangeAvailable;
if ( tess.verts != nullptr && tess.verts != tess.vertsBuffer && usingMapBufferRange )
{
R_BindVBO( tess.vbo );
glUnmapBuffer( GL_ARRAY_BUFFER );
R_BindIBO( tess.ibo );
glUnmapBuffer( GL_ELEMENT_ARRAY_BUFFER );
}

// This is important after doing CPU-only tessellation with Tess_MapVBOs( true ).
// A lot of code relies on a behavior of Tess_Begin: automatically map the
// default VBO *if tess.verts is null*.
Expand Down

0 comments on commit f989ce9

Please sign in to comment.