mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-25 14:48:12 +02:00
zink: enforce viewport depth clamping
VUID-VkViewport-minDepth-01234 specifies that depth must be in the range [0.0, 1.0],
so the viewport must always be clamped to this range
this affects texture clears using u_blitter, as this expects to be able
to use the GL range of [-1.0, 1.0], so pass the depth value as though it's
been de-converted back to a GL z coordinate to account for viewport transform
cc: mesa-stable
fixes #6757
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17319>
(cherry picked from commit 90c5eea22b)
This commit is contained in:
parent
a9b3df51e0
commit
040658cd26
3 changed files with 16 additions and 6 deletions
|
|
@ -1237,7 +1237,7 @@
|
|||
"description": "zink: enforce viewport depth clamping",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null
|
||||
},
|
||||
|
|
|
|||
|
|
@ -443,7 +443,15 @@ zink_clear_texture(struct pipe_context *pctx,
|
|||
flags |= PIPE_CLEAR_STENCIL;
|
||||
surf = create_clear_surface(pctx, pres, level, box);
|
||||
zink_blit_begin(ctx, ZINK_BLIT_SAVE_FB | ZINK_BLIT_SAVE_FS);
|
||||
util_blitter_clear_depth_stencil(ctx->blitter, surf, flags, depth, stencil, box->x, box->y, box->width, box->height);
|
||||
/* Vulkan requires depth to be in the range of [0.0, 1.0], while GL uses
|
||||
* the viewport range of [-1.0, 1.0], creating a mismatch during u_blitter rendering;
|
||||
* to account for this, de-convert depth back to GL for viewport transform:
|
||||
|
||||
depth = (depth * 2) - 1
|
||||
|
||||
* this yields the correct result after the viewport has been clamped
|
||||
*/
|
||||
util_blitter_clear_depth_stencil(ctx->blitter, surf, flags, (depth * 2) - 1, stencil, box->x, box->y, box->width, box->height);
|
||||
}
|
||||
}
|
||||
/* this will never destroy the surface */
|
||||
|
|
|
|||
|
|
@ -627,10 +627,12 @@ zink_draw(struct pipe_context *pctx,
|
|||
ctx->vp_state.viewport_states[i].translate[1] - ctx->vp_state.viewport_states[i].scale[1],
|
||||
MAX2(ctx->vp_state.viewport_states[i].scale[0] * 2, 1),
|
||||
ctx->vp_state.viewport_states[i].scale[1] * 2,
|
||||
ctx->rast_state->base.clip_halfz ?
|
||||
ctx->vp_state.viewport_states[i].translate[2] :
|
||||
ctx->vp_state.viewport_states[i].translate[2] - ctx->vp_state.viewport_states[i].scale[2],
|
||||
ctx->vp_state.viewport_states[i].translate[2] + ctx->vp_state.viewport_states[i].scale[2]
|
||||
CLAMP(ctx->rast_state->base.clip_halfz ?
|
||||
ctx->vp_state.viewport_states[i].translate[2] :
|
||||
ctx->vp_state.viewport_states[i].translate[2] - ctx->vp_state.viewport_states[i].scale[2],
|
||||
0, 1),
|
||||
CLAMP(ctx->vp_state.viewport_states[i].translate[2] + ctx->vp_state.viewport_states[i].scale[2],
|
||||
0, 1)
|
||||
};
|
||||
viewports[i] = viewport;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue