"Cached Mesh Draw commands use loose parameters" for Instanced static meshes. How to fix it?

I build UE-5.0.3 from source for some unreal projects in Ubuntu. When I build the Engine in Debug mode (instead of default development mode) and open a level with instanced static meshes, I get the following warning in the Ubuntu terminal.

[2022.11.17-04.52.03:607][  1]LogRenderer: Warning: One or more Cached Mesh Draw commands use loose parameters. This causes overhead and will break dynamic instancing, potentially reducing performance further. Use Uniform Buffers instead.

This can be easily reproduced by opening a blank level and adding a few instanced static meshes in it. You may also see this issue in unreal 5.1.0. The warning suggests that there is an additional overhead when caching the mesh draw calls and hence it leads to significantly high loading time, but the eventual performance is pretty smooth once the draw calls get cached. How do I fix warning?

Additional info:

  • On some investigation, it seems like these 6 float4 variables in LocalVertexFactory.ush stay as loose params when the shader is compiled
float4 InstancingViewZCompareZero;  // w contains random lod scale 
float4 InstancingViewZCompareOne;
float4 InstancingViewZConstant;
float4 InstancingTranslatedWorldViewOriginZero;
float4 InstancingTranslatedWorldViewOriginOne;
float4 InstancingFadeOutParams;

Getting rid of these variables stops this warning but these variables are essential for rendering the scene properly.

  • This warning doesn’t appear in the development build of unreal. However the underlying issue of loose params still exist. The warning is simply being suppressed since appropriate validation checks are disabled. You can enable these checks by building unreal in debug mode or by setting the C++ macro #define DO_GUARD_SLOW 1

  • When looking into the shader compilation dump, these 6 float4 params are being stored as PackedGlobal instead of being packaged into a UniformBuffer. Not sure whether it’s related to this issue though.

1 Like