I was profilering our game using Arm Graphics analyzer and noticed that in the profiler there is a column in the shader window called spilling uses.It said that when the number required for work registers it too great,it will store variable to RAM istead. And saidly most of our game shader program causes the register spilling. But something strange is that some shader program uses 8 uniform registers and 16 work registers and dosn not cause spilling while other shader programs with 16 uniform registers and only 8 work registers cause spilling. I wander if the maximun number of the uniform registers and work registers is fixed? Or the maximun allowed work registers have nothing to do with uniform registers number?
thank you for your reply. I know the more threads in compute shader will result in less registers, but i thought for normal shader like vertex/pixal shader,they have fix number of register assigned to them, is it wrong. And i also want to know that for those 8k or 16k registers, do them contain uniform register as well? Or just contain the temperary register(or work register in Arm Graphics analyzer)? I use quite a lot uniform variable in my shader program will result a large number of uniform registers, I wonder if it the reason cause the register spilling problem. Again, thank you for your help.
And i forget to said that the GPU i mentioned above is Mali, GPU for mobile phone.
Hi CloudBunny,
The work registers and uniform registers are separate allocations from different register pools. When we talk about spilling we are generally talking about the work registers.
Mali can allocate work registers in variable amounts:
Increasing the size of the register allocation reduces spilling, but it also reduces the number of concurrent threads that can be executed in the shader core. This reduces the shader core's ability to hide cache misses and data fetches, which can impact performance.
How many registers are selected is a compiler-managed heuristic trying to balance thread occupancy and spilling. In general the shader compiler will try hard to keep fragment shaders in 4 or 32 registers, giving the highest thread occupancy, for other shader types the compiler is a little more relaxed and will allow the shader program to use 8 or 64 more of the time.
The quickest way to reduce spilling is to reduce variable precision - Mali can store packed vectors in the registers, so we can fit twice as many "mediump" variables in a register than "highp" variables. They also generally process faster and arithmetic operations on 16-bit values need less energy, so it's generally a good thing to use mediump variables as much as possible.
Kind regards, Pete
P.S. Note that the current Graphics Analyzer always runs on Mali-T880, which is an older GPU now and quite a different architecture to the more recent Bifrost and Valhall GPUs. The Mali Offline Compiler that ships in Mobile Studio will let you test the problem shaders against newer GPUs.
thank you for your answer,it help a lot