Skip to content

Texture streaming rework#5829

Merged
Geenz merged 15 commits into
release/26.3from
geenz/texture-quality
May 22, 2026
Merged

Texture streaming rework#5829
Geenz merged 15 commits into
release/26.3from
geenz/texture-quality

Conversation

@Geenz
Copy link
Copy Markdown
Collaborator

@Geenz Geenz commented May 18, 2026

Reworks the texture streaming system for more consistent signal composition and better VRAM accounting.

  • Discard is now driven by a normalized 0..1 signal: distance x on-screen-size x per-channel exponent, with staleness / background / VRAM-pressure floors layered on top. Close textures stay less aggressively downrezzed than far ones at every pressure level
  • Post-decode textures can downrez down to 1x1, independent of the j2c's encoded mip count.
  • Terrain LOD now participates in streaming (was pinned to discard 0). Distance is sourced from the closest visible patch each frame.
  • Per-texture last-bind time drives a progressive staleness floor that downrezzes long-idle textures.
  • Backgrounded windows ramp a global discard floor over time, capped at (dim_max - TextureBackgroundDiscardOffset) so some baseline quality survives.
  • Close-camera bubble: textures within TextureCloseBubbleMeters of the camera get dist_factor = 0; the ramp to 1 spans (bubble, draw_distance).
  • New RenderTextureQuality preset (Low/Medium/High/Ultra) drives texture cap + per-channel exponents.
  • Per-channel exponents are now four individual F32 debug settings (TextureChannelNormal/BaseColor/Specular/Emissive) instead of a Vector4

Geenz added 5 commits April 29, 2026 18:03
This is a big one:
- Reworks the discard signal almost entirely.  Now has a normalized 0..1 discard signal: distance x size x channel exponent, floored by staleness and background app state.  Shaped by VRAM pressure.
- Textures can now scale down to the smallest GPU mip (1×1), independent of the codec's encoded mip
  count.
- Terrain texture LOD now works.  Useful for 2K textures and PBR on terrain.  Based upon camera distance to nearest terrain patch.
- New texture quality setting.  Low/Medium/High/Ultra
  - Caps texture resolution on Low to 1024, and otherwise shifts the discard signal around.  Makes distance based texture LOD work a lot more predictably.
- We now track last bind state for textures, and discard accordingly.  We progressively discard based upon last bind time.
- Avatar textures get a residency boost to stay loaded in VRAM longer under pressure.
auto iter = sTextureAllocs.find(texName);
if (iter != sTextureAllocs.end())
{
iter->second += size;
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.

I take it something substructs the old value? Where does it happen?

Comment thread indra/newview/app_settings/settings.xml
desired_discard = llmin(desired_discard, getMaxDiscardLevel());
// Clamp the fetch request to what the codestream encodes; deeper
// discards are served from the GL mip pyramid via scaleDown.
desired_discard = llmin(desired_discard, (S32)mCodecMaxDiscardLevel);
Copy link
Copy Markdown
Contributor

@akleshchev akleshchev May 18, 2026

Choose a reason for hiding this comment

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

This might need to be conditional.
Ex: Some texture (profile icons) get intentionally requested at max resolution and then scaled down (icons) to a reasonable size. Some textures aren't JPEG2000 and don't discard well.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point - and FWIW the discards now better relate to how they work on the GPU with mip levels and such. I'll go ahead and add some guard rails to make sure profile images and similar (like picks) don't get accidentally downrez'd.

Geenz added 3 commits May 19, 2026 12:19
New "high res" bubble near the camera, minimum discard settings, and discard scaling.
@TommyTheTerrible
Copy link
Copy Markdown
Contributor

Why is this reverting the J2C size calculations back to the previous "pre-aug 2024" method? Was there an issue with the updated method? Why is this action not described in the scope of the PR?

@Geenz
Copy link
Copy Markdown
Collaborator Author

Geenz commented May 20, 2026

@TommyTheTerrible So some of that might've been messing with some of the KDU code stream stuff which had a bit of a knock on effect in other parts of the texture pipeline. It's also not quite accurate to say that it reverts it - we just use a different code path for KDU vs. OpenJPEG now.

@github-actions github-actions Bot added the llkdu label May 20, 2026
@TommyTheTerrible
Copy link
Copy Markdown
Contributor

@TommyTheTerrible So some of that might've been messing with some of the KDU code stream stuff which had a bit of a knock on effect in other parts of the texture pipeline. It's also not quite accurate to say that it reverts it - we just use a different code path for KDU vs. OpenJPEG now.

I'm quoting your commit which states "Bring back the pre-aug 2024 byte estimation for j2c streams".

Why would the amount of needed file loaded be different between the two decoders? What "knock on" effects are you alluding to? And if these effects are a problem then why is KDU still being supported when OpenJPEG works?

I think this is going to cause KDU to under-decode textures again and then viewers using KDU will miraculously use less VRAM all of a sudden without telling users that all those 2k textures they are paying to upload are never being decoded fully in 2k on KDU viewers.

@Geenz
Copy link
Copy Markdown
Collaborator Author

Geenz commented May 20, 2026

RE: 2k textures - those still appear to work to me. And I do have quite the library to test with. And the knock on appears to be overallocation on the KDU end of things - I'm still profiling and validating various parts of this part of the pipeline.

@TommyTheTerrible
Copy link
Copy Markdown
Contributor

RE: 2k textures - those still appear to work to me. And I do have quite the library to test with. And the knock on appears to be overallocation on the KDU end of things - I'm still profiling and validating various parts of this part of the pipeline.

Alright, well it would be nice to have an explanation but I guess I don't deserve one.

I wish you luck with your tinkering.

@Geenz Geenz enabled auto-merge May 22, 2026 17:13
@Geenz Geenz merged commit 6b4e3f3 into release/26.3 May 22, 2026
7 checks passed
@Geenz Geenz deleted the geenz/texture-quality branch May 22, 2026 17:13
@github-actions github-actions Bot locked and limited conversation to collaborators May 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants