vkd3d-shader: Lower SM1 loop instructions.

The usual way of looping in SM1 is through the rep instruction, whose backend support was added by !1873 (merged).

However ps_3_0 also has the loop instruction which has two src arguments, the aL register, and an CONSTINT iSRC register. Not to be confused with the SM4 loop instruction which doesn't take any.

To my knowledge, the only advantage of this instruction is that, besides specifying the number of iterations with iSRC.x, one can specify the iteration start and step using iSRC.y and iSRC.z respectively, and that the aL register can be used for relative addressing of the input COLOR register. This is also the only use of the aL register I know of.

It is worth mentioning that it is hard to construct HLSL code so that the native compiler will emit a loop instruction, see for instance, the last test in tests/hlsl/loop-sm3.shader_test. And so far I haven't seen an application that requires it, so this is a rather edge case.

Merge request reports

Loading