Skip to content

Mark more textures as discardable - #113781

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
clayjohn:rd-discardable
Jan 27, 2026
Merged

Mark more textures as discardable#113781
Repiteo merged 1 commit into
godotengine:masterfrom
clayjohn:rd-discardable

Conversation

@clayjohn

@clayjohn clayjohn commented Dec 9, 2025

Copy link
Copy Markdown
Member

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

@BastiaanOlij BastiaanOlij 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.

All makes sense to me

@BastiaanOlij

BastiaanOlij commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

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)

@Repiteo
Repiteo merged commit 75cd151 into godotengine:master Jan 27, 2026
20 checks passed
@Repiteo

Repiteo commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

Thanks!

@lord-muad-dib

lord-muad-dib commented Jan 27, 2026

Copy link
Copy Markdown

Windows 11 Vulkan: First frame displays a distorted screen.

i get flickering each time i switch tabs aswell...
edit: it doesn't seem happen on the previous gh built v4.7.dev.gh [8fb5cd8]
edit2: a simple way to trigger it seem to just hoover over the workstation tabs on top and wait for a tooltip

@clayjohn
clayjohn deleted the rd-discardable branch January 27, 2026 23:37
@clayjohn

Copy link
Copy Markdown
Member Author

Windows 11 Vulkan: First frame displays a distorted screen.

i get flickering each time i switch tabs aswell... edit: it doesn't seem happen on the previous gh built v4.7.dev.gh [8fb5cd8] edit2: a simple way to trigger it seem to just hoover over the workstation tabs on top and wait for a tooltip

Are you saying you see a flicker when you hover over a tooltip? Or when you click on one of the upper-right drop-down menus?

What do you mean by switch tabs? Do you mean when you switch between scene tabs, or do you have tabs in a pop-up menu or something?

@lord-muad-dib

Copy link
Copy Markdown

Are you saying you see a flicker when you hover over a tooltip? Or when you click on one of the upper-right drop-down menus?

What do you mean by switch tabs? Do you mean when you switch between scene tabs, or do you have tabs in a pop-up menu or something?

sorry, i was replying on mobile and autocorrection made a mess.

i mean here, for example
immagine
for the flickering of the whole godot window with garbage to show up, you hoover on those buttons, tooltip shows up and the whole window goes nuts for about a sec.
it happens also when the project is opening , or when you switch 3d/2d/etc on those buttons.
later today i will try to catch it with obs. i will also check on the igfx.
thanks

@clayjohn

Copy link
Copy Markdown
Member Author

@lord-muad-dib Can you post your system specs here? I can't reproduce the issue on any of my devices

@lord-muad-dib

Copy link
Copy Markdown

@lord-muad-dib Can you post your system specs here? I can't reproduce the issue on any of my devices

Godot v4.7.dev (77579f9) - Windows 11 (build 26200) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1050 Ti (NVIDIA; 32.0.15.8180) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 threads) - 15.88 GiB memory

https://github.com/user-attachments/assets/cdc4142a-1afa-4cee-8ed2-8f97a2cd033b
as you can see even playing with the window size triggers majour issues
doesn't happen on intel 630 uhd igfx
sorry for the late reply, and thanks

@clayjohn

clayjohn commented Jan 28, 2026

Copy link
Copy Markdown
Member Author

Thank you! A few others stumbled on the same issue as well. Turns out it is indeed an NVidia only issue (I am on AMD which is why I couldn't reproduce the issue).

I have a fix lined up already #115530 that others have confirmed works for them. So with any luck we will have this problem resolved within a day

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.

5 participants