Move texture upload preparation off the main thread - #6031
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR introduces an asynchronous “upload preparation” step for textures, precomputing alpha-mask analysis and pick-mask generation off the main thread and applying the results during GL upload.
Changes:
- Added
LLImageGL::TextureUploadPreparationand APIs to prepare/apply/discard upload precomputation state. - Updated
LLImageGL::setImage()to consume prepared results and skip redundant alpha/pick-mask work. - Updated
LLViewerFetchedTexture::scheduleCreateTexture()to enqueue background preparation for eligible textures.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| indra/newview/llviewertexture.cpp | Schedules background upload preparation and applies it before enqueuing texture creation. |
| indra/llrender/llimagegl.h | Adds the upload-preparation struct, methods, and new members to store preparation state. |
| indra/llrender/llimagegl.cpp | Implements preparation logic, integrates it into setImage(), and refactors alpha mask analysis into a helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you for the contribution! Merging. |
|
I think you forgot mNeedsAlphaAndPickMask=false somewhere, a single image keeps restarting prepareForUpload job. Might also need a 'job created flag'. Or forgot to hook up mAlphaAnalyzed and mPickMaskPrepared |
|
Sorry, but I'm going to revert this. I checked how this works in more detail and not only it doesn't work right, this is a very focused uploads-only solution for a general, upload-independent problem. |
Description
Moves fetched-texture alpha classification and pick-mask generation off the frame-critical path when shared-context texture uploads are disabled.
The existing General worker pool computes the CPU-only upload metadata, then the main thread consumes it immediately before the GL upload. Explicit texture formats, unavailable queues, and shared-context uploads retain their existing paths. Prepared metadata is discarded if an upload becomes redundant.
A native Apple Silicon profile of the closely related Firestorm viewer placed
LLViewerTextureList::updateImagesCreateTextures()on roughly 9% of main-thread samples, withLLImageGL::analyzeAlpha()and pick-mask generation running insidesetImage(). The officialdevelopbranch contains the same code path.Related Issues
Issue Link: None; opened as a draft for upstream performance evaluation.
Checklist
Additional Notes
Validation performed:
git diff --checkA full official viewer build was not available because this host lacks the autobuild dependency bundle and full Xcode toolchain. This remains a draft pending native build and benchmark coverage.