Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgc::ShmBuffer: Fix texture setup synchronisation #3800

Merged
merged 3 commits into from
Mar 6, 2025

Conversation

RAOF
Copy link
Contributor

@RAOF RAOF commented Mar 6, 2025

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.

Closes: #3792

RAOF added 2 commits March 6, 2025 18:15
`GL_TEXTURE_BINDING_2D` is how you query the current `GL_TEXTURE_2D` 🤦‍♀️
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.
@RAOF RAOF requested a review from a team as a code owner March 6, 2025 07:26
@AlanGriffiths
Copy link
Collaborator

Fixes the bug but...

250/255 Test #252: unit-tests-do-not-link-with-GL-or-EGL ......................................................................***Failed    0.02 sec
  NEEDED               libGLESv2.so.2
  NEEDED               libGLESv2.so.2

@AlanGriffiths
Copy link
Collaborator

Looks like MockGL is missing glFlush

Copy link
Collaborator

@AlanGriffiths AlanGriffiths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes more sense than my hack

@AlanGriffiths AlanGriffiths enabled auto-merge March 6, 2025 09:37
@AlanGriffiths AlanGriffiths added this pull request to the merge queue Mar 6, 2025
Merged via the queue into main with commit 5205fc7 Mar 6, 2025
22 of 28 checks passed
@AlanGriffiths AlanGriffiths deleted the fix-shmbuffer-gl-threading branch March 6, 2025 10:24
@AlanGriffiths AlanGriffiths mentioned this pull request Mar 6, 2025
Saviq pushed a commit that referenced this pull request Mar 6, 2025
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.

Closes: #3792
Saviq pushed a commit that referenced this pull request Mar 6, 2025
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.

Closes: #3792
Saviq pushed a commit that referenced this pull request Mar 6, 2025
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.

Closes: #3792
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[main & 2.20] Windows not rendering, black rectangles, ...
2 participants