mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibGL+Lib*GPU: Set model view and projection matrices separately
LibSoftGPU used to calculate the normal transformation based on the model view transformation for every primitive, because that's when we sent over the matrix. By making LibGL a bit smarter and only update the matrices when they could have changed, we only need to calculate the normal transformation once on every matrix update. When viewing `Tuba.obj` in 3DFileViewer, this brings the percentage of time spent in `FloatMatrix4x4::inverse()` down from 15% to 0%. :^)
This commit is contained in:
parent
126adfc392
commit
edcb6176ce
8 changed files with 75 additions and 24 deletions
|
@ -125,6 +125,7 @@ void GLContext::gl_pop_matrix()
|
|||
|
||||
m_current_matrix_stack->take_last();
|
||||
m_current_matrix = &m_current_matrix_stack->last();
|
||||
m_matrices_dirty = true;
|
||||
}
|
||||
|
||||
void GLContext::gl_push_matrix()
|
||||
|
@ -135,6 +136,7 @@ void GLContext::gl_push_matrix()
|
|||
|
||||
m_current_matrix_stack->append(*m_current_matrix);
|
||||
m_current_matrix = &m_current_matrix_stack->last();
|
||||
m_matrices_dirty = true;
|
||||
}
|
||||
|
||||
void GLContext::gl_rotate(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
|
||||
|
@ -167,4 +169,15 @@ void GLContext::gl_translate(GLfloat x, GLfloat y, GLfloat z)
|
|||
update_current_matrix(*m_current_matrix * translation_matrix);
|
||||
}
|
||||
|
||||
void GLContext::sync_matrices()
|
||||
{
|
||||
if (!m_matrices_dirty)
|
||||
return;
|
||||
|
||||
m_rasterizer->set_model_view_transform(model_view_matrix());
|
||||
m_rasterizer->set_projection_transform(projection_matrix());
|
||||
|
||||
m_matrices_dirty = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue