r300: channel merging can sometimes create instructions with multiple const sources
When testing channel merging on r400 I've spotted weird regression with temp registers in shaderdb.
temps HURT: shaders/unity/33-GrassBillboard.shader_test VS: 7 -> 8 (14.29%)
temps HURT: shaders/unity/41-GrassBillboard.shader_test VS: 6 -> 7 (16.67%)
temps HURT: shaders/unity/15.shader_test VS: 5 -> 6 (20.00%)
temps HURT: shaders/godot3.4/28-49.shader_test VS: 3 -> 4 (33.33%)
temps HURT: shaders/0ad/9.shader_test VS: 1 -> 2 (100.00%)
temps HURT: shaders/unity/151-Slices.shader_test VS: 2 -> 4 (100.00%)
(Which shouldn't happen as we only remove some instructions.)
45: MOV temp[1].x, const[8].y___;
46: MOV temp[1].y, const[9]._y__;
47: MOV temp[1].z, const[10].__y_;
48: MUL temp[1].xyz, temp[1].xyz_, input[1].yyy_;
49: MOV temp[2].x, const[8].x___;
50: MOV temp[2].y, const[9]._x__;
51: MOV temp[2].z, const[10].__x_;
52: MAD temp[1].xyz, temp[2].xyz_, input[1].xxx_, temp[1].xyz_;
53: MOV temp[2].x, const[8].z___;
54: MOV temp[2].y, const[9]._z__;
55: MOV temp[2].z, const[10].__z_;
is converted to
44: MAD temp[1].xyz, const[10].11y_, const[8].y01_, const[9].0y0_;
45: MUL temp[1].xyz, temp[1].xyz_, input[1].yyy_;
46: MAD temp[2].xyz, const[10].11x_, const[8].x01_, const[9].0x0_;
47: MAD temp[1].xyz, temp[2].xyz_, input[1].xxx_, temp[1].xyz_;
48: MAD temp[2].xyz, const[10].11z_, const[8].z01_, const[9].0z0_;
Which later becomes:
48: MOV temp[11], const[9];
49: MOV temp[12], const[8];
50: MAD temp[1].xyz, const[10].11y_, temp[12].y01_, temp[11].0y0_;
51: MUL temp[1].xyz, temp[1].xyz_, input[1].yyy_;
52: MOV temp[13], const[9];
53: MOV temp[14], const[8];
54: MAD temp[2].xyz, const[10].11x_, temp[14].x01_, temp[13].0x0_;
55: MAD temp[1].xyz, temp[2].xyz_, input[1].xxx_, temp[1].xyz_;
56: MOV temp[15], const[9];
57: MOV temp[16], const[8];
58: MAD temp[2].xyz, const[10].11z_, temp[16].z01_, temp[15].0z0_;
I'm guessing constrains aren't working correctly when the merging happens multiple times in row.
CC @ondracka