Skip to content

#6055 Optimize LLImageGL::analyzeAlpha - #6073

Open
akleshchev wants to merge 1 commit into
developfrom
andreyk/viewer_6055_2
Open

#6055 Optimize LLImageGL::analyzeAlpha#6073
akleshchev wants to merge 1 commit into
developfrom
andreyk/viewer_6055_2

Conversation

@akleshchev

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 WorkQueue worker 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.

Comment thread indra/llrender/llimagegl.h
Comment thread indra/llrender/llimagegl.cpp
Comment thread indra/llrender/llimagegl.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread indra/llrender/llimagegl.cpp
Comment thread indra/llrender/llimagegl.h Outdated
@akleshchev
akleshchev force-pushed the andreyk/viewer_6055_2 branch 2 times, most recently from b5d6900 to 934c192 Compare July 30, 2026 23:38
@akleshchev
akleshchev requested a review from Copilot July 30, 2026 23:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_stride rather than reading mAlphaOffset/mAlphaStride again. 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();

Comment thread indra/llrender/llimagegl.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants