I have stripped the static lighting functionality from my projects because I am only rendering with lumen at the moment so already I am trying to get the least amount of instructions possible.
Here are some information and quotes about it. Basically Epic has set the Default Shader Model for Unreal Engine to 6 instead of 5. Along with this they have resolved some other issues regarding the instruction count:
DirectX 12 with Shader Model 6 is Default on PC for New Projects
Set InstructionCount when compiling shaders with DXC, which fixes an issue where all compiles of SM6 shaders were reporting 0 instructions.
Fix an issue with âGetMaxNumInstructionsForShaderâ that reported the incorrect instruction count for the given shader type. The function was not checking to see if the shader type in the pipeline was the same as the shader type we are asking for.
Note: The shader count has never been properly counted. If it was compared to the assembly code it would always differ somewhat. Although, this is something I havenât been able to verify myself to be true or false.
Also I might not really understand the amount of vertex instructions needed to render geometry, but again⌠250 for a static mesh? compared to 108 for 5.0 shadersâŚ
Is this really a more accurate representation? Iâm really curious as to how these instructions are counted because this ofcourse is a black box looking at this in the platform stats tab.
Is there maybe a Unreal Dev that worked on this feature that can give a bit of insight into the accuracy of these stats?
So Iâm trying to get the least amount of possible shader instructions for the project that Iâm setting up. And build it up from there depending on what I need. In UE 5.0 this resulted in a pretty complex shader to have only 200 instructions.
I am fine with more instructions if previous instruction counts where wrong. I guess all I need to know is:
If the instruction counts are accurate
If the increased amount of instructions for SM6 over SM5 is also accurate
Actually you canât compare SM5 instructions with SM6 instructions because theyâre different compilers with different instruction sets ( DXBC vs DXIL ). What you could do is compare UE5.0 with SM6 and UE5.1 with SM6 which I did :). Enabling SM6 in UE5.0 involves about 5 engine modifications though but itâs possible. 5.1 does appear to have âmore instructionsâ. Actual DXIL shaders from PIX report around 1200 instructions for some simple shaders so much more than the editor reports. But r.VelocityOutputPass has been changed from 0 to 1 which means basepass shaders are beefier due to adding velocity output instructions. If you do set it to 0 like in 5.0 you end up with identical instructions for BasePass pixel shaders :).
Way more shader instructions but lower Shader count. Itâs a little beyond my understanding, but man thatâs a lot of instructions for something with no nodes plugged in.
I did a diff of the 5.0 and 5.1 base material code by going to Window->Shader Code->HLSL Code and found that the differences are likely related to refactoring of shader code for the new Strata tech that was added in 5.1. Further details can be found here:
Frustrating that the shader count is this high even with Strata features disabled. Do we have any visibility on if optimization is planned for a hotfix? Hard to take an objective eye to my shader instruction counts when weâre not sure when saves might come.
Shader instruction count shouldnât directly be affecting performance necessarily as static branching should account for this at cook time and dynamic branching at runtime (for example), although we appreciate for a long time this has been the only metric most users are able to go off. Are you seeing particular performance degradations? Have you profiled with other tools such as renderdoc to A/B test the timing of single material draw and to see if instruction count is the root cause of this or if there may be other factors at play?
We are planning an overhaul of this entire system currently though, particularly we want much better metrics than instruction count as it doesnât really give a whole picture, but unfortunately this is a few engine versions away.