aco: Fix addressable SGPR count with extra SGPRs
The std::min must also ensure that none of the reserved extra SGPRs are addressed as normal SGPRs. Subtracting before the std::min isn't enough if sgprs is in fact greater than the SGPR limit.
If sgprs
ends up as 128, then sgprs -= get_extra_sgprs(program)
reduces sgprs
to 124 in RT shaders (since they need flat_scratch_*
).
However, this is still greater than the SGPR limit of 105 on GFX9, so we return 105.
This limit accidentally includes the flat_scratch_*
registers again, so we might end up clobbering these.
This fixes dEQP-VK.ray_query.builtin.rayqueryterminate.rgen.triangles
on GFX9.
/cc @pendingchaos