[Mesa-dev] [PATCH] i965: Fix fractional viewport coordinates handling on gen8+

danylo danylo.piliaiev at gmail.com
Mon Jun 18 10:34:52 UTC 2018


Could anyone review this patch?

Here is a Wine dev reporting similar bug to Nvidia 
<https://devtalk.nvidia.com/default/topic/971005/linux/glviewportindexedf-wrongly-rounding-down-x-and-y-parameters/>.
Test in Wine source to enable a workaround for this issue 
<https://source.winehq.org/git/wine.git/blob/HEAD:/dlls/wined3d/utils.c#l3568>.
Similar patch for gallium/radeon 
<https://patchwork.freedesktop.org/patch/81255/>.

Hope this will help.

-Danil

On 04.06.18 13:41, Danylo Piliaiev wrote:
> 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
> Signed-off-by: Danylo Piliaiev <danylo.piliaiev at gmail.com>
> ---
>   src/mesa/drivers/dri/i965/genX_state_upload.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
> index 88fde9d..886290f 100644
> --- a/src/mesa/drivers/dri/i965/genX_state_upload.c
> +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
> @@ -2586,12 +2586,11 @@ genX(upload_sf_clip_viewport)(struct brw_context *brw)
>          * pipeline stall so we're better off just being a little more clever
>          * with our viewport so we can emit it once at context creation time.
>          */
> -      const float viewport_Xmin = MAX2(ctx->ViewportArray[i].X, 0);
> -      const float viewport_Ymin = MAX2(ctx->ViewportArray[i].Y, 0);
> -      const float viewport_Xmax =
> -         MIN2(ctx->ViewportArray[i].X + ctx->ViewportArray[i].Width, fb_width);
> -      const float viewport_Ymax =
> -         MIN2(ctx->ViewportArray[i].Y + ctx->ViewportArray[i].Height, fb_height);
> +      const struct gl_viewport_attrib *vp = &ctx->ViewportArray[i];
> +      const float viewport_Xmin = MAX2(vp->X, 0);
> +      const float viewport_Ymin = MAX2(vp->Y, 0);
> +      const float viewport_Xmax = MIN2(ceilf(vp->X + vp->Width), fb_width);
> +      const float viewport_Ymax = MIN2(ceilf(vp->Y + vp->Height), fb_height);
>   
>         if (render_to_fbo) {
>            sfv.XMinViewPort = viewport_Xmin;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180618/a9db2fc5/attachment.html>


More information about the mesa-dev mailing list