05-22-2013, 05:13 AM
Well, I shouldn't say preround maybe. A better way to put it would be "don't convert colortest/alphatest values to float just to convert them back to integers again." Clearly there's something wrong, but I'm not sure what it is.
I suspect that the rounding (0.5) is not working correctly, but on my Android, it doesn't work correctly without it (at least for alphatest.) Maybe it needs to use even/odd rounding or something... ugh.
Do you have a compiler to test a few things? The trouble is, I don't have any games (that I know of) which this caused problems for, so it's hard for me to debug. If you (or someone reading this topic) can try things, this is the line to try a few variations of:
WRITE(p, "if (roundAndScaleTo255v(v.rgb) %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]);
First off, does it change things to comment it out? That will confirm that it's incorrectly discarding when it shouldn't.
Next, what about:
WRITE(p, "if (floor(v.rgb * 255.0) %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]);
If that does work, then it's a rounding issue. Another thing worth trying:
WRITE(p, "if (floor(v.rgb * 255.0) %s u_alphacolorref.rgb) if (roundAndScaleTo255v(v.rgb) %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]);
If that works, it probably doesn't discard quite enough, but it could be a better situation than currently, and I think (?) it might not hurt performance for the common case.
-[Unknown]
I suspect that the rounding (0.5) is not working correctly, but on my Android, it doesn't work correctly without it (at least for alphatest.) Maybe it needs to use even/odd rounding or something... ugh.
Do you have a compiler to test a few things? The trouble is, I don't have any games (that I know of) which this caused problems for, so it's hard for me to debug. If you (or someone reading this topic) can try things, this is the line to try a few variations of:
WRITE(p, "if (roundAndScaleTo255v(v.rgb) %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]);
First off, does it change things to comment it out? That will confirm that it's incorrectly discarding when it shouldn't.
Next, what about:
WRITE(p, "if (floor(v.rgb * 255.0) %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]);
If that does work, then it's a rounding issue. Another thing worth trying:
WRITE(p, "if (floor(v.rgb * 255.0) %s u_alphacolorref.rgb) if (roundAndScaleTo255v(v.rgb) %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]);
If that works, it probably doesn't discard quite enough, but it could be a better situation than currently, and I think (?) it might not hurt performance for the common case.
-[Unknown]

