Skip to content

Pass light grid light data to mobile shaders through a uniform buffer #27

@GapingPixel

Description

@GapingPixel

Many mobile devices have hardware optimizations for uniform buffers which make them faster to read than standard buffers, as long as the uniform buffers are small. The Light Grid data won't all fit into a small uniform buffer, but we can at least get the light data into one. That ends up being most of the memory reads performed for a lit object, resulting in a nice performance boost. Across various test scenes, we measured a performance improvement on Quest 3 between 3% and 25% less total frame time, depending on the scene and number of lights.

This optimization is enabled by the new CVar r.Mobile.PackLightGridLightDataToUBO.Enable. This CVar defaults to off, but depending on the performance across a wider set of devices and the number of lights mobile games tend to use, it might make sense to default it on.

Further improvements are possible by reducing the light limit from 32 to 20 or even 8 lights. Unfortunately, we couldn't find a good way to put this on a CVar. Note that it's extremely important that each array member gets its own SPIR-V declaration, so that unused members can be optimized out. This rules out the strategy that e.g. FBatchedPrimitiveShaderData uses of putting all the data into one big array.

https://github.com/EpicGames/UnrealEngine/pull/13655

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions