- Home /
Question by
ChristopherKroll · Apr 04, 2019 at 10:03 PM ·
shadersoptimizationshader programmingperformance optimizationgpu
Why do static arrays in shaders cause massive slowdown?
I recently switched from using a static array to a uniform array in a shader.
From this:
static fixed _ExampleArray[200] = { 0, 0.1, 0.3, ...... };
To this:
// Values passed in using Shader.SetGlobalFloatArray("_ExampleArray", exampleArray) in C#
uniform fixed _ExampleArray[200];
After the switch, I saw a massive performance increase. The performance increase was greatest in low end hardware (Integrated GPUs). In some cases the FPS increased by 4x or more. Can anyone explain what is going on with static arrays?
As a side note, are there any other best practices for increasing performance on systems with Integrated GPUs in particular?
Comment
Your answer
Follow this Question
Related Questions
How to setup Shader Variant Collection 0 Answers
GPU Instancing with textures 1 Answer
Shader: 1 Base Texture Overlaid by 1 Transparent Texture. 0 Answers
Setting custom camera projection matrix 2 Answers