@AlfredOne
Hans seems to be too busy to answer, I'll try based on my experiences and observations instead.
Unfortunately
this has not been fixed during the last 3,5 years.
It's hard to give any precise info on what to change without seeing your shader code, but there are some rule of thumbs and hints I can give.
I suggest to get your hands on a standalone SPIR-V compiler (glslangValidator) and a SPIR-V disassembler (I use the windows spirv-dis.exe, was too lazy to try to port that to aos4 so far). Taking a look at the disassembly (no worries, it's pretty easy to grasp) of your shader will help you to get an idea about the ~ overall register requirements and where your shader "loses" the most registers, in case of Nova. The reason is:
SPIR-V has no concept of registers. For many operations it simply introduces new "dummy" variables to hold intermediate calculation results or to pass function parameters around. And it doesn't reuse such variables, it simply doesn't care and adds new ones. Nova
should of course have a register manager which doesn't do that but instead transforms those dummy variables into true
temporary register usage. Unfortunately that isn't the case. Which is why until now and right now the first rule of thumb is:
Nova's register demands are roughly equivalent to the SPIR-V source's variable usage.Probably the biggest reason for register-waste are function calls, the more parameters the function has the worst. This is because SPIR-V creates variables for every parameter passed. If you want to make Nova's shader translator to give up real fast then have many functions and / or functions with many parameters and / functions that are called multiple times.
Therefore try to avoid this. If your function isn't recursive and reasonably small, consider making it a #define. If your function has tons of single float parameters, consider packing those into vec4 or so. Or maybe, as a last resort and if possible without side-effects, work with global variables instead.
It may also help if you keep the amount of true named non-temporary variables low in general and also try to reuse your own temporary variables instead of coming up with new ones.
As a last resort, if you run out of ScalarGPRs (stuff like "float") then try to use VectorGPRs (stuff like "vec2") instead and vice versa.
Also, try to avoid arrays, Nova is particularly wasteful with those. Of course that's often not an option.
Hope that helps a bit, cheers!
Edited by Daytona675x on 2020/7/22 10:37:59
Edited by Daytona675x on 2020/7/23 8:41:12