i965,anv: Fix fractional viewport coordinates handling

Open Danylo Piliaiev requested to merge GL/mesa:fix/fractional-viewport-coordinates into main

On gen8+ fractional translation of viewport moved it by a whole integer. The behaviour in this case isn't defined anywhere but some apps like Wine may depend on viewport's width and height being ceiled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106526

There is a similar bug filed for Nvidia driver https://devtalk.nvidia.com/default/topic/971005/linux/glviewportindexedf-wrongly-rounding-down-x-and-y-parameters/ . I wasn't able to find the exact specification for such case but e.g. Wine expects coordinates not to be shifted (see wined3d_caps_gl_ctx_test_viewport_subpixel_bits function in Wine).

The closest line in specs is in the specification of ARB_viewport_array extension:

Direct3D 11 specifies that rasterization along the one-pixel edges of fractional viewports to be undefined. If implementations want defined behavior with fractional viewports, they can program a slightly wider viewport and scissor away the pixels along the edge of the expanded viewport.

Viewport's width and height are already ceiled on radeon driver (e50e1f86) and i965 behaves the same before gen8.

This patch was moved from the mailing lists. It passes CI https://mesa-ci.01.org/global_logic/builds/58/group/63a9f0ea7bb98050796b649e85481845

Edited by Jordan Justen

Merge request reports