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

Fix puck rendering behavior Android #2957

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Conversation

alasram
Copy link
Collaborator

@alasram alasram commented Oct 22, 2024

The puck is typically rendered last and while its VAO is bound command that change the VAO are executed causing glitches. I didn't debug what commands are affecting the VAO but as a workaround the VAO is unbound after drawing which ensures the state of a Drawable object remains clean without adding overhead. This works around #2879

@alasram alasram requested review from mwilsnd, TimSylvester and louwers and removed request for mwilsnd October 22, 2024 23:22
Copy link

github-actions bot commented Oct 23, 2024

Bloaty Results (iOS) 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results-ios/pr-2957-compared-to-main.txt

Copy link

github-actions bot commented Oct 23, 2024

Bloaty Results 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +144  +0.0%     +96    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-2957-compared-to-main.txt

Compared to d387090 (legacy)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +28% +32.4Mi  +426% +25.4Mi    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-2957-compared-to-legacy.txt

Copy link

github-actions bot commented Oct 23, 2024

Benchmark Results ⚡

Benchmark                                                     Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------
OVERALL_GEOMEAN                                            -0.0064         -0.0060             0             0             0             0

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/benchmark-results/pr-2957-compared-to-main.txt

@TimSylvester
Copy link
Collaborator

Curious, I don't think that should be necessary. Doesn't it mean that either those commands shouldn't be happening at all, or that they are happening with the wrong bindings?

@louwers
Copy link
Collaborator

louwers commented Oct 23, 2024

Android render test timing out is just because we were running benchmarks, should restart...

@louwers louwers closed this Oct 23, 2024
@louwers louwers reopened this Oct 23, 2024
@louwers louwers requested review from adrian-cojocaru and alexcristici and removed request for mwilsnd October 25, 2024 15:41
@louwers louwers added OpenGL Issues related to the OpenGL renderer backend bug Something isn't working labels Oct 25, 2024
@louwers louwers changed the title Alasram/fix puck Fix puck rendering behavior Android Oct 27, 2024
@alasram
Copy link
Collaborator Author

alasram commented Oct 28, 2024

@TimSylvester I haven't really debug this. I only noticed in renderdoc that the buffers bound to the VAO change when the glitch happens. This means that while the puck VAO is bound (It's the last drawable in the frame), and before the next frame's drawable, there are calls that bind buffers such as glBindBuffer(GL_ELEMENT_ARRAY_BUFFER)

@louwers
Copy link
Collaborator

louwers commented Nov 1, 2024

@TimSylvester Since we have multiple people that report this is an issue, do you think this is an acceptable work-around?

@adrian-cojocaru
Copy link
Collaborator

I haven't been able to reproduce the glitch, but from what @alasram described a single glBindVertexArray(0) at the end of the frame (context::endFrame) should block any further updates to the puck's VAO.

@alasram
Copy link
Collaborator Author

alasram commented Nov 4, 2024

This is a legit fix.
After puck rendering, the upload pass might create or update index buffers. This can lead to issues with VAO bindings, as the newly created/updated buffers are bound to GL_ELEMENT_ARRAY_BUFFER without considering the active VAO: calls to UploadPass::createIndexBufferResource or UploadPass::updateIndexBufferResource
This PR is enough to address the issue. An alternative approach, though less conservative, is to unbind the VAO at the start of the upload pass (reducing GL calls). Unless there's evidence of performance benefits with VAOs in a specific implementation, the simpler approach is bind a dummy VAO when a context is created and bind vertex buffers directly for each drawable.
I recommend merging this PR as it provides a straightforward solution to a real bug.

@louwers louwers merged commit a5b0059 into maplibre:main Nov 4, 2024
68 checks passed
@TimSylvester
Copy link
Collaborator

Sorry, I was out since 10/30. Something must be making GL calls without binding its own buffer first but if it's not leading to an observed bug, I guess it's not a big deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working OpenGL Issues related to the OpenGL renderer backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants