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

Avoid redundant bindings/states based on Metal profiler feedback. #2006

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

TimSylvester
Copy link
Collaborator

Addresses some of the issues reported by the Metal capture/profile tools, specifically redundant vertex bindings, depth/stencil and sampler state descriptors, and blit encoders.

Screenshot 2024-01-08 at 12 51 46 PM Screenshot 2024-01-08 at 5 00 56 PM

A large number of issues are still reported, mostly around binding the same "bytes" (where the data is placed directly in the encoder as opposed to a Metal buffer reference). This is to be expected, as similar drawables will bind the same values for some arguments to the same indexes.

The implication that these bindings can be elided does not seem to be true, however. Checking for buffer content equality in addition to buffer instance equality does resolve most of the reported issues, but does not render correctly. This appears to be an inconsistency between the debug tool and the actual encoder behavior. It's possible that it was just a bug, however, and it would be possible to elide many more of the set[Fragment|Vertex]Bytes calls, at the cost of memcmp calls.

While this eliminates some hundreds of objc_msgSend calls per frame and improves the times reported by the Time Profiler tool, unfortunately it didn't produce any significant difference in measured encoding or rendering times from the benchmark app.

Copy link

codecov bot commented Jan 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (43e52d0) 85.70% compared to head (7fff6ec) 85.72%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2006      +/-   ##
==========================================
+ Coverage   85.70%   85.72%   +0.01%     
==========================================
  Files         569      569              
  Lines       28053    28053              
==========================================
+ Hits        24044    24048       +4     
+ Misses       4009     4005       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Jan 9, 2024

Bloaty Results 🐋

Compared to main

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

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

Compared to d387090 (legacy)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +19% +21.6Mi  +400% +23.9Mi    TOTAL

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

Copy link

github-actions bot commented Jan 9, 2024

Bloaty Results (iOS) 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0% +2.07Ki  [ = ]       0    TOTAL

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

@TimSylvester TimSylvester merged commit 5c30461 into main Jan 22, 2024
29 checks passed
@TimSylvester TimSylvester deleted the metal-issues branch January 22, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants