#6055 Optimize LLImageGL::analyzeAlpha - #6073
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes LLImageGL::analyzeAlpha() by moving expensive alpha-mask analysis off the main thread for large textures, reducing main-thread stalls during texture creation paths that still run on the main thread (e.g. uploads / picker).
Changes:
- Refactors the alpha-mask histogram logic into a new static helper (
analyzeAlphaData()). - Defers alpha analysis to a
WorkQueueworker when running on the main thread for larger images, applying results back on the main thread. - Adds a request-serial (
mAlphaAnalysisSerial) to ignore stale async results and invalidates pending jobs on certain state changes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| indra/llrender/llimagegl.h | Adds the new static helper declaration and introduces mAlphaAnalysisSerial for async request tracking. |
| indra/llrender/llimagegl.cpp | Implements the helper and adds async deferral + request tracking/invalidation in alpha analysis flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
306bc88 to
950e4a6
Compare
b5d6900 to
934c192
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
indra/llrender/llimagegl.cpp:2362
- Profiler label typo: "Deffered" -> "Deferred".
LL_PROFILE_ZONE_NAMED("Deffered alpha mask analysis");
indra/llrender/llimagegl.cpp:2388
- In the synchronous fallback, use the captured
alpha_offset/alpha_striderather than readingmAlphaOffset/mAlphaStrideagain. This keeps the analysis inputs consistent with what was captured for the request (and avoids potential races if those members are changed before this line executes).
delete[] data_copy;
mIsMask = analyzeAlphaData(data_in, w, h, mAlphaOffset, mAlphaStride);
unref();
934c192 to
7b98434
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
indra/llrender/llimagegl.cpp:2362
- Profiler zone label has a spelling error ("Deffered"). This makes profiling views harder to search/aggregate consistently.
LL_PROFILE_ZONE_NAMED("Deffered alpha mask analysis");
Some of the image get created on a thread, but some large images (uploads, picker) get created on main thread and do alpha analyzis. Alpha calculations are pricey, so when large textures goes through main thread, move alpha calculations to a worker thread.