This updates m*x* instructions to use a temporary register if the first source register is the same as the destination register, since this is not allowed in d3d9.
Loops through each register to see if the same register is used for both the destination register and the first source register.
Adds a new line using a temporary register and updates the m*x* line to use the temporary register.
If there is no unused register or there are no arithmetic instructions remaining it will disable the line to allow shader assembly to be compiled.
Note: the source register can use negative modifier and swizzles.
RegEx break down:
(m.x.) - This checks for any m*x* instructions.
(r" + std::to_string(j) + ") - This checks the destination register.
((-?)r" + std::to_string(j) + "([\\.xyzw]*)) - This checks to verify if the the first source register is the same as the destination register. It also includes any negative modifier and swizzles used.
(?![0-9]) - This verifies that there is no number after the match. You don't want this to match on this line m3x3 r1, r11, for example.
This updates m*x* instructions to use a temporary register if the first source register is the same as the destination register, since this is not allowed in d3d9.
Fixes the issue NFS HP2 (2002) transparent cars.
Code does the following:
Note: the source register can use negative modifier and swizzles.
RegEx break down:
(m.x.)
- This checks for any m*x* instructions.(r" + std::to_string(j) + ")
- This checks the destination register.((-?)r" + std::to_string(j) + "([\\.xyzw]*))
- This checks to verify if the the first source register is the same as the destination register. It also includes any negative modifier and swizzles used.(?![0-9])
- This verifies that there is no number after the match. You don't want this to match on this linem3x3 r1, r11
, for example.This fixes the following error:
In this case the code will update this line:
To be this: