Move fetched texture preparation to fetch worker - #6056
Conversation
There was a problem hiding this comment.
Pull request overview
This PR advances the texture pipeline optimization stack by moving CPU-side upload preparation (alpha classification and pick-mask generation) earlier into the texture fetch worker flow, reducing main-thread scheduling overhead and avoiding redundant “General” queue preparation hops.
Changes:
- Threads
LLImageGL::TextureUploadPreparationalongside decoded raw buffers throughLLTextureFetch→LLViewerFetchedTextureto apply preparation directly before GL texture creation. - Adds
LLImageGL::prepareForUpload()plus plumbing to apply/discard prepared metadata and skip re-runninganalyzeAlpha()/updatePickMask()when prepared. - Introduces an integration test validating preparation behavior (including odd dimensions) and wires it into
llrenderwhenLL_TESTSis enabled.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| indra/newview/llviewertexture.h | Extends fetched-texture creation scheduling APIs to accept precomputed upload preparation metadata. |
| indra/newview/llviewertexture.cpp | Applies/invalidates preparation during fetch-result processing and texture creation scheduling; retains a fallback worker path when needed. |
| indra/newview/lltexturefetch.h | Extends fetch APIs to return and optionally compute upload preparation on the fetch side. |
| indra/newview/lltexturefetch.cpp | Stores preparation in fetch workers, schedules preparation on the fetch request queue after decode, and hands results back to consumers. |
| indra/llrender/llimagegl.h | Introduces TextureUploadPreparation struct and new APIs for preparation/apply/discard. |
| indra/llrender/llimagegl.cpp | Implements preparation logic, consumes prepared results in setImage(), and updates pick-mask sizing math. |
| indra/llrender/tests/llimagegl_prepare_test.cpp | Adds coverage for alpha classification and pick-mask packing, including odd width/height cases. |
| indra/llrender/CMakeLists.txt | Registers the new integration test under LL_TESTS. |
Comments suppressed due to low confidence (1)
indra/newview/lltexturefetch.cpp:2842
- Same implicit-conversion concern as above: pass
raw_image.get()explicitly when callingcallbackUploadPreparation()in the fallback path.
LLTextureFetchWorker* worker = getWorker(id);
if (worker)
{
worker->callbackUploadPreparation(raw_image, {});
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # indra/llrender/llimagegl.cpp # indra/llrender/llimagegl.h # indra/llrender/tests/llimagegl_prepare_test.cpp # indra/newview/llviewertexture.cpp
There was a problem hiding this comment.
This doesn't seem to work right. I tried to upload a texture, scheduleUploadPreparation didn't get hit. I rezzed an abject and that triggered scheduleUploadPreparation. I'm not doing any uploading, yet I'm hitting upload preparation in scheduleCreateTexture.
At a minimum the naming is wrong and confusing (TextureUploadPreparation is no longer about upload), but from a 'mechanics' stadpoint, fetcher is already a thread with a bunch of workers, it should be issuing jobs to its own workers, not to the general pool. Or calculations can be done by/after decoder.
Stack
Depends on #6031. This is a stacked follow-up; the follow-up change is the commit
Move fetched texture preparation to fetch worker. The diff againstdevelopwill shrink when #6031 merges.What changed
Why
analyzeAlpha()can take multiple milliseconds. #6031 removes it from the frame-critical GL path; this follow-up performs the work earlier on the fetch worker so main-thread upload scheduling does not need another preparation hop.Validation
LL_TESTS=ON.INTEGRATION_TEST_llimagegl_prepare: 4/4 passed.secondlife-binuniversal Release target: passed.