A bit disappointing. And the compiler doesn't even recognize that it could use xyzw in this case, because of the write mask.Humus said:That kind of swizzling isn't allowed, this is what the compiler says:
(52): error X5202: (Third source param) Invalid source selector: .rgbb/xyzz. The only available source swizzles in this shader version are: .rgba/xyzw (same as not specifying swizzle), .r/x, .g/y, .b/z, .a/w, .gbra/yzxw, .brga/zxyw and .abgr/wzyx.
I figured that's impossible to reduce an iteration to two instructions without arbitrary swizzle. However, I found a way to put two iterations in 5 instructions:
def c1, 0.0, 2.0, -2.0, 0.0
// calculate (Xi² + Cx) and (Xi * Yi + Cy)
mad r1.xy, r0.x, r0, t0
// Xi+1 = -Yi² + (Xi² + Cx)
mad r0.x, r0.y, -r0.y, r1.x
// Yi+1 = 2 * (Xi * Yi + Cy) - Cy
// -Yi+1 = -2 * (Xi * Yi + Cy) + Cy
mad r0.yz, c1, r1.y, t0.wzyx
// Next iteration
// calculate (Xi² + Cx) and (Xi * Yi + Cy)
mad r1.xy, r0.x, r0, t0
// Xi+1 = Yi * (-Yi) + (Xi² + Cx)
// Yi+1 = Yi * Xi + (Xi² + Cx)
mad r0.xy, r0.y, r0.zxyw, r1
Again, t0.z must contain -Cy