On Tue, 21 Jul 2026 05:37:25 GMT, Jayathirth D V <[email protected]> wrote:
> When we use XOR mode to clear the drawn content in Metal pipeline, it is > leaving some traces. > We noticed similar issue when Metal pipeline was under development: > [JDK-8251167](https://bugs.openjdk.org/browse/JDK-8251167). But the fix is > not complete and we still see some traces. Using uiScale 1.0 with contrasting > background and foreground color reveals this not so easily noticeable issue. > > In case of Metal XOR mode is implemented using shaders and we are using an > interpolated position passed from Vertex shader to determine the current > position of fragment/pixel. We also add magic offsets to line vertices in > MTLRenderer.DrawLine() and it can cause different approximations while > calculating the interpolated position. > > Because of this we end up in mismatch between the pixel from which we are > reading the content and the pixel to which we are writing. Instead of using > interpolated position we should use the rasterized position present in > fragment shader to pick the appropriate pixel. When we use rasterized > position mismatch doesn't happen and XOR draw clears the content properly. > > We need this change in both `frag_col_xorMode` and `frag_txt_xorMode` > shaders. Gradient and texture paint shaders are no-op in case of XOR as they > use software loops, so no change is made in those shaders. Regression test is > added only for color shader as mathematically i was able to reproduce issue > only for color shader, but product fix is needed in case of text shader also. > > If we use rasterized position to pick pixels we don't need fix done under > [JDK-8251167](https://bugs.openjdk.org/browse/JDK-8251167), so that change is > also reverted. > > Code update is tested in CI and no regressions seen. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). LGTM! ------------- Marked as reviewed by aghaisas (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/31981#pullrequestreview-4753659768
