Reducing HDRP/Lit RAM usage

In our HDRP game, In a built player, the HDRP/Lit shader uses a ton of memory. After removing a bunch of features in our HDRP Asset (see screenshot at the bottom of this post), we’re now at 1.25 GB usage only for the HDRP/Lit Shader, down from 2+ GB. It’s something, but it’s still quite huge.

Now I wonder, is there a way to reduce this further? I have a hard time understanding exactly how the shader stripping works under the hood.

Would removing all materials using a given keyword of the HDRP/Lit shader reduce the shader’s size? So, if I found that there’s a single material in a scene using a specific keyword, could I remove the HDRP/Lit memory usage by modifying that material? If that’s the case, is there a known tool that I could use to track usage of keywords?

3 Likes

The same thing happens on a PS4/PS5 build, the HDRP/Lit shader takes over 1GB which is a pretty ridiculous amount.

They really need to add texture streaming for built-in shaders. I’ve noticed all ambitious games made with HDRP suffer with VRAM usage. Pretty big issue.

1 Like

I agree, I have a RTX 3080 w/10 GB VRAM, and run out of vram pretty quick

Hi, we miss information to be able to provide help.
What is your Unity binary version and hdrp version?
Also have you modify hdrp? (maybe you have left #pragma enable_d3d11_debug_symbols
lastly are you doing a heavy usage of shadergraph? (with a lot of unique shader graph) ?

if you are on 20.3 or above it is possible to reduce variant futher by using shader frequency stage: Per-stage shader keywords in HDRP by FrancescoC-unity · Pull Request #2996 · Unity-Technologies/Graphics · GitHub (note: there is multiple PR for this one so best to check on master the correct keyword stage frequency to put) - This work have been done only for 21.x and above

They really need to add texture streaming for built-in shaders.
This is call asset bundle in Unity.

1 Like

I believe what he means is to have Virtual Texturing support for HDRP Lit so that we aren’t suffering too much for the outstanding size of HDRP Lit shader. As of now, VT needs to be manually added in shader graphs, does not work with built in shader, and does not work with Asset Bundles. This makes VT/Granite pretty much useless for any ongoing projet (and not a solution to fix high Unity memory usage).

2 Likes

exactly :slight_smile:

I’m using Unity 2020.3.17, HDRP 10.6.0. By 20.3, do you mean Unity 2020.3?

I do have some Shadergraph shaders, some using the Lit material in the graph settings (see image), but I’m not too sure if they impact the actual HDRP/Lit shader memory usage in the profiler.

7527248--929027--upload_2021-9-27_11-56-54.png

I don’t think we’ve modified HDRP. Do you mean modifying the HDRP asset, or modifying files in the package itself? If it’s the latter, we didn’t modify anything. We do have #pragma enable_d3d11_debug_symbols in the Crest asset from the Asset Store, but it’s on another shader, could this have an impact on the HDRP/Lit shader?

As for asset bundles, I’m already using Addressables, is there a way I could minimize the size of the loaded HDRP/Lit shader with it?

At the end of the day, I think the most useful way to address this would be a way to associate a renderer with a specific variant and, optionally, the memory it consumes. So if, for example, I have a single renderer which uses a specific variant taking a bunch of memory, maybe we could remove features from said renderer in order to save a bunch of memory. Is there any tool like this, and if there isn’t, is there a way I could code something that would do something like it.

7527248--929027--upload_2021-9-27_11-56-54.png

So, I tried to remove the whole Crest asset and most shadergraph shaders, and it does not change anything on the memory taken by HDRP/Lit in a build, it stays the same. I guess I’ll have to find another strategy to solve this issue.

1 Like

Can anyone tell me how do you know which shader is specifically taking up the RAM, is this data available in memory profiler or the normal memory tab in profiler?

Memory profiler → Detailed → Take Sample Playmode
It’ll be in Assets->Shader

2 Likes
  • Now that the information has been provided, can we get an answer on: Is it “as designed” for HDRP Lit shader to take more than 1 gb of memory at runtime?
  • What are the most memory-impactful features on HDRP that could help us reduce its memory footprint on Gen8 consoles?
  • Is there any ways we can have more info on untracked memory from the memory profiler?

Do you mean the Untracked Memory as shown in the Memory Profiler Module (2021.2+) or Memory Profiler package?
If so:

I’ll leave the rest of the questions for @SebLagarde as they are more HDRP specific than profiling specific and I unfortunately have too few insights there to contribute.

Edit: Not sure why I quoted myself there, as the info is also in the Package documentation, but I’m currently working on butting it directly into the tool.

1 Like

Thanks for the quick response Martin. We use the Memory Profiler Package. I did not know about the new module on 2021.2. Does it offer more insight on untracked memory?

We are using DOTS so we’re kind of stuck on LTS for now, but if there’s more info on memory, maybe I hack things so it runs on 2021.2 to see if I can learn something or not.

No, the package has more info. The module is just visually adjusted for clarity and to match the new package summary UI. The package has more info in general and also more info integrated into the high level summary bars, i.e. ExecutableAndDlls and Mono Virtual Machine memory. Most data memory Profiler adjustment and additions are likely to get backported too, so I would upgrade due to that.

This is on PC with the hightest settings for our game.

The game looks great and really benefits from HDRP, but right now it seems like porting to PS4 and Xbox One is nearly impossible. By stripping out almost all features, the HDRP Lit still takes a lot of memory and likewise for the Untracked Memory which can’t be analysed.

1 Like

Yeah, I hope this issue isn’t ignored. Let alone consoles, even PCs can really struggle. It can cause massive performance issues.

Well, it can be, e.g. with Pix on windows and Xbox. And with that high amount of Untracked, I think it is warranted to do so too. It’s just not (yet) readily possible with built-in Unity tools that give a higher level and contextual overview of that memory…

PIX does not give that much info either. I mean, what it tells me is: “There is something taking a lot of memory, good luck with that!”.

I am aware I’m just there complaining but I’ve been using Unity for 10 years now and it is the first time I have to dive that deep to figure out how to save on memory. Usually we just lower our texture resolution and split our scenes in chunks, but now even an empty scene has difficulty running on Gen 8 hardware.

Anyways. We’re continuing our quest to find a way to reduce that huge memory footprint and if I find anything, I’ll be happy to share it here for others.

5 Likes

Is it normal that the HDRP/Lit shader use considerably more memory in a build? With the HDRP demo scene, I have 1.3MB in the editor and over 16MB in a build. Is the profiler memory usage in the editor reliable for Assets/shader memory usage?