vrend_clear: clear and restore rasterizer discard and depth clamp

vrend_clear is passed in from gallium clear which, unlike glClear, must
not obey rasterizer discard and depth_clmap. However, the guest doesn't
foreard the latest update of the rendering states to the host before issuing
"clear". Therefore, the host clear command must clear these states before
calling glClear in turn. After calling glClear these states are again brought
into sync with what the host assumes.

Fixes CTS:
   dEQP-GLES3.functional.rasterizer_discard.fbo.*

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
macos/master
Gert Wollny 7 years ago committed by Jakob Bornecrantz
parent 9f1fe32c9c
commit bab29c2243
  1. 17
      src/vrend_renderer.c

@ -2485,6 +2485,8 @@ void vrend_clear(struct vrend_context *ctx,
} else {
glClearDepth(depth);
}
if (!ctx->sub->hw_rs_state.depth_clip)
glDisable(GL_DEPTH_CLAMP);
}
if (buffers & PIPE_CLEAR_STENCIL) {
@ -2492,6 +2494,9 @@ void vrend_clear(struct vrend_context *ctx,
glClearStencil(stencil);
}
if (ctx->sub->hw_rs_state.rasterizer_discard)
glDisable(GL_RASTERIZER_DISCARD);
if (buffers & PIPE_CLEAR_COLOR) {
uint32_t mask = 0;
int i;
@ -2525,9 +2530,19 @@ void vrend_clear(struct vrend_context *ctx,
if (bits)
glClear(bits);
if (buffers & PIPE_CLEAR_DEPTH)
/* Is it really necessary to restore the old states? The only reason we
* get here is because the guest cleared all those states but gallium
* didn't forward them before calling the clear command
*/
if (ctx->sub->hw_rs_state.rasterizer_discard)
glEnable(GL_RASTERIZER_DISCARD);
if (buffers & PIPE_CLEAR_DEPTH) {
if (!ctx->sub->dsa_state.depth.writemask)
glDepthMask(GL_FALSE);
if (!ctx->sub->hw_rs_state.depth_clip)
glEnable(GL_DEPTH_CLAMP);
}
/* Restore previous stencil buffer write masks for both front and back faces */
if (buffers & PIPE_CLEAR_STENCIL) {

Loading…
Cancel
Save