Skip to content

Conversation

@clayjohn
Copy link
Member

@clayjohn clayjohn commented Dec 9, 2025

This is a follow up to #98670

In #98670 we were very conservative with which textures we marked as discardable as we were already making a huge change, we didn't want to create more regressions than necessary. Therefore, we left it as a follow up to find more opportunities for improvement.

Well, now it is time for the follow up!

This PR adds the is_discardable hint to many of our render targets that are refreshed every frame. Particularly important are the:

  1. 3D depth texture
  2. 2D render target

This ensures that we don't save the depth texture back to VRAM unless it is needed. It also ensures that we don't needlessly copy the 2D render target into tile memory right before overwriting the whole thing in the 3D tonemap pass.

The is_discardable hint allows the ARG to avoid loading the contents of the texture into tile memory when rendering into the texture if the contents won't be used anyway. Similarly, it allows the ARG to avoid saving the memory off tile memory if the texture isn't going to be used again in the frame. This is especially important on ARM Mali devices because memory bandwidth from tile memory is a common bottleneck.

The only change I am not 100% sure about is the VRS texture. But I discussed with @BastiaanOlij and he confirms that we fully overwrite the VRS texture each frame and we don't rely on it being available for multiple frames at a time, so this is a safe change there too.

This is an optimization specifically for TBDR GPUs, so it isn't expected to have any impact on desktop GPUs. Further, it will only benefit performance for bandwidth limited scenes. However, for non-bandwidth limited scenes, it is still hugely beneficial as bandwidth usage has a very strong impact on battery consumption. So this PR will help battery consumption a lot.

Testing a very simple scene with just a couple of objects I get the following numbers

Mali G715
Before: 1.8 mspf - 2.0 mspf
After: 1.2 mspf - 1.3 mspf

Adreno 640
Before: 4.7 mspf
After: 2.9 mspf

To be very clear, I don't expect to see any performance gains in most games, but very simple 3D games may see some benefit. And all games should have some battery savings as a result of this.

This allows the ARG to better optimize their usage for mobile devices.

In particular, this allows the ARG to avoid loading the contents of the texture into tile memory when rendering into the texture if the contents won't be used anyway.
@clayjohn clayjohn added this to the 4.7 milestone Dec 9, 2025
@clayjohn clayjohn requested a review from a team as a code owner December 9, 2025 00:14
Copy link
Contributor

@BastiaanOlij BastiaanOlij left a comment

Choose a reason for hiding this comment

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

All makes sense to me

@BastiaanOlij
Copy link
Contributor

BastiaanOlij commented Dec 9, 2025

The only change I am not 100% sure about is the VRS texture. But I discussed with @BastiaanOlij and he confirms that we fully overwrite the VRS texture each frame and we don't rely on it being available for multiple frames at a time, so this is a safe change there too.

Indeed, either we use an external VRS texture in which case this is skipped/not used, or we copy from a uniform texture format to this internal buffer formatting the data as the used extension requires.

So there is no reason to keep the texture, nor load its current data from VRAM.
(though probably it will be written to VRAM as its used in the next pass)

@zhangjiangen11
Copy link

Windows 11 Vulkan: First frame displays a distorted screen.

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.

4 participants