mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Merge pull request #52 from docentYT/code-optimization
Small code optimizations that results with 3x faster main loop
This commit is contained in:
@@ -13,8 +13,8 @@ gl::fence::~fence()
|
||||
|
||||
bool gl::fence::is_signalled()
|
||||
{
|
||||
GLsizei len = 0;
|
||||
GLint val;
|
||||
glGetSynciv(sync, GL_SYNC_STATUS, 1, &len, &val);
|
||||
return len == 1 && val == GL_SIGNALED;
|
||||
// glClientWaitSync is faster than glGetSynciv. glGetSynciv probably tries to synchronize cpu and gpu
|
||||
// https://stackoverflow.com/questions/34601376/which-to-use-for-opengl-client-side-waiting-glgetsynciv-vs-glclientwaitsync
|
||||
GLenum r = glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, 1);
|
||||
return r == GL_ALREADY_SIGNALED || r == GL_CONDITION_SATISFIED;
|
||||
}
|
||||
|
||||
@@ -657,9 +657,13 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
||||
glDebug("rendermode::color");
|
||||
|
||||
glDebug("context switch");
|
||||
glfwMakeContextCurrent(vp.window);
|
||||
static bool was_made = false;
|
||||
|
||||
m_current_viewport = &vp;
|
||||
if (m_current_viewport != &vp)
|
||||
{
|
||||
glfwMakeContextCurrent(vp.window);
|
||||
m_current_viewport = &vp;
|
||||
}
|
||||
|
||||
if ((!simulation::is_ready) || (Global.gfx_skiprendering))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user