17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 05:09:20 +02:00

fix(instancing): keep batches correct after load-time classification

This commit is contained in:
2026-10-01 11:51:41 +02:00
parent f05b58b0e9
commit 20f536f05e
5 changed files with 158 additions and 71 deletions

View File

@@ -215,13 +215,34 @@ opengl33_vaogeometrybank::draw_instanced_( gfx::geometry_handle const &Geometry,
GLsizei const inst_count = static_cast<GLsizei>(InstanceCount);
if( chunkrecord.index_count > 0 ) {
m_vao->bind();
::glDrawElementsInstancedBaseVertex(
chunk.type,
chunkrecord.index_count, GL_UNSIGNED_INT,
reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
inst_count,
chunkrecord.vertex_offset );
// GLES 3.0 context doesn't provide the base vertex variant, same fallbacks as in draw_()
if( glDrawElementsInstancedBaseVertex ) {
m_vao->bind();
::glDrawElementsInstancedBaseVertex(
chunk.type,
chunkrecord.index_count, GL_UNSIGNED_INT,
reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
inst_count,
chunkrecord.vertex_offset );
}
else if( glDrawElementsInstancedBaseVertexOES ) {
m_vao->bind();
::glDrawElementsInstancedBaseVertexOES(
chunk.type,
chunkrecord.index_count, GL_UNSIGNED_INT,
reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
inst_count,
chunkrecord.vertex_offset );
}
else {
setup_attrib( chunkrecord.vertex_offset );
m_vao->bind();
::glDrawElementsInstanced(
chunk.type,
chunkrecord.index_count, GL_UNSIGNED_INT,
reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
inst_count );
}
}
else {
m_vao->bind();