Skip to content

Commit 7daa680

Browse files
committed
mgc::ShmBuffer: Fix texture setup synchronisation.
Because we're on an `EGLContextExecutor` we're probably on a different thread to where the GL state is going to be used, *and* we don't have implicit flushing with `eglMakeCurrent` happening (because the context just stays current on the `EGLContextExecutor`. If the GL implementation has per-thread execution queues (for example, amdgpu by default), this might mean that the texture setup commands aren't visible to command stream that's actually using the texture. Explicitly `glFlush()` after our texture setup, to ensure these commands are visible to any `EGLContext` that might need them.
1 parent ed3b80e commit 7daa680

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/platforms/common/server/shm_buffer.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ auto get_tex_id_on_context(mgc::EGLContextExecutor& egl_executor) -> std::shared
122122

123123
// ...and then restore the previous GL state.
124124
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(previous_texture));
125+
126+
/* We need these commands to be in the driver command stream before
127+
* anything which uses them can be executed (which will likely be
128+
* on another thread, in another EGLContext).
129+
*
130+
* glFlush() before the promise synchronisation point will ensure
131+
* those commands are visible to the driver before we try and use
132+
* their results.
133+
*/
134+
glFlush();
125135
tex_promise->set_value(tex);
126136
});
127137
return tex_promise->get_future();

0 commit comments

Comments
 (0)