On 4/20/21 3:15 AM, Matteo Bruni wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
I think a better way to handle this is to use a separate temp variable for each LOAD of the uniform, thus replacing each uniform LOAD with a STORE to a temp variable and a LOAD from that. That way we get less register pressure without having to complicate the register allocation or liveness computation algorithms. That is assuming that register pressure on the temporary registers is quite problematic for SM2 or even SM3 shaders since there are so few of them and there is no spilling to save the day.
Of course there is a complication with that, that is preserving "writes" to uniforms. That could be taken into account pretty simply with write tracking, but another option is to do the above optimization only when legacy mode is not set (AFAIU writing to uniforms / globals is only allowed on older d3dx9 / d3dcompiler versions).
Just food for thought. Also, ignore everything if you have something fancier already queued up.
It's a bit orthogonal to this patch, but yes, I see the point. It's not clear to me that write tracking isn't more complicated, though. Personally I'm inclined to leave it alone until it actually does become a problem.
(as a side note—I don't know if it makes sense to try to code register limits into the HLSL compiler (or validator). As I understand wined3d/vkd3d shader translation layers won't care, which removes much of the reason for us to. Not that wine should be considered vkd3d-shader's only customer, but...)