zink: handle !half_pixel_center

the shader is already getting a -0.5,-0.5 bias, but the viewport also
needs to be shifted by 0.5 to match

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17775>
(cherry picked from commit 55a4a6b8dc)

Conflicts:
	src/gallium/drivers/zink/zink_state.c
This commit is contained in:
Mike Blumenkrantz 2022-07-28 12:20:54 -04:00 committed by Dylan Baker
parent 50e133465c
commit 1889d87783
3 changed files with 14 additions and 1 deletions

View file

@ -481,7 +481,7 @@
"description": "zink: handle !half_pixel_center",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -588,6 +588,15 @@ zink_draw(struct pipe_context *pctx,
CLAMP(ctx->vp_state.viewport_states[i].translate[2] + ctx->vp_state.viewport_states[i].scale[2],
0, 1)
};
if (!ctx->rast_state->base.half_pixel_center) {
/* magic constant value from dxvk */
float cf = 0.5f - (1.0f / 128.0f);
viewport.x += cf;
if (viewport.height < 0)
viewport.y += cf;
else
viewport.y -= cf;
}
viewports[i] = viewport;
}
if (DYNAMIC_STATE != ZINK_NO_DYNAMIC_STATE)

View file

@ -635,6 +635,7 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
bool force_persample_interp = ctx->rast_state ? ctx->rast_state->hw_state.force_persample_interp : false;
bool clip_halfz = ctx->rast_state ? ctx->rast_state->hw_state.clip_halfz : false;
bool rasterizer_discard = ctx->rast_state ? ctx->rast_state->base.rasterizer_discard : false;
bool half_pixel_center = ctx->rast_state ? ctx->rast_state->base.half_pixel_center : true;
ctx->rast_state = cso;
if (ctx->rast_state) {
@ -678,6 +679,9 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
if (ctx->rast_state->base.force_persample_interp != force_persample_interp)
zink_set_fs_key(ctx)->force_persample_interp = ctx->rast_state->base.force_persample_interp;
if (ctx->rast_state->base.half_pixel_center != half_pixel_center)
ctx->vp_state_changed = true;
}
}