mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 19:49:19 +02: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()
|
bool gl::fence::is_signalled()
|
||||||
{
|
{
|
||||||
GLsizei len = 0;
|
// glClientWaitSync is faster than glGetSynciv. glGetSynciv probably tries to synchronize cpu and gpu
|
||||||
GLint val;
|
// https://stackoverflow.com/questions/34601376/which-to-use-for-opengl-client-side-waiting-glgetsynciv-vs-glclientwaitsync
|
||||||
glGetSynciv(sync, GL_SYNC_STATUS, 1, &len, &val);
|
GLenum r = glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, 1);
|
||||||
return len == 1 && val == GL_SIGNALED;
|
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("rendermode::color");
|
||||||
|
|
||||||
glDebug("context switch");
|
glDebug("context switch");
|
||||||
glfwMakeContextCurrent(vp.window);
|
static bool was_made = false;
|
||||||
|
|
||||||
|
if (m_current_viewport != &vp)
|
||||||
|
{
|
||||||
|
glfwMakeContextCurrent(vp.window);
|
||||||
m_current_viewport = &vp;
|
m_current_viewport = &vp;
|
||||||
|
}
|
||||||
|
|
||||||
if ((!simulation::is_ready) || (Global.gfx_skiprendering))
|
if ((!simulation::is_ready) || (Global.gfx_skiprendering))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user