summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNanley Chery <nanley.g.chery@intel.com>2020-11-06 10:55:03 -0800
committerDylan Baker <dylan.c.baker@intel.com>2020-11-17 10:57:31 -0800
commitb37d613da5b0393f1a2ba34dd5baea9916dd0b9b (patch)
tree77a022955e3e8dd01d4a350bf8c6427ae61fb63d
parentd47cb4124ac9d515bd91fa3c1e807ac1c05bda35 (diff)
mesa: Clamp some depth values in glClearBufferfi
OpenGL 3.0 spec, section 4.2.3 "Clearing the Buffers": depth and stencil are the values to clear the depth and stencil buffers to, respectively. Clamping and type conversion for fixed-point depth buffers are performed in the same fashion as for ClearDepth. Enables iris to pass the clearbuffer-depth-stencil piglit test. Cc: mesa-stable Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7410> (cherry picked from commit 2e713313a29422b38435c91f8277c1893fcad095)
-rw-r--r--.pick_status.json2
-rw-r--r--src/mesa/main/clear.c16
2 files changed, 15 insertions, 3 deletions
diff --git a/.pick_status.json b/.pick_status.json
index ad51376792f..2396e4edd37 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1084,7 +1084,7 @@
"description": "mesa: Clamp some depth values in glClearBufferfi",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
},
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 0a51a868bae..ba978a06ad6 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -738,8 +738,20 @@ clear_bufferfi(struct gl_context *ctx, GLenum buffer, GLint drawbuffer,
const GLclampd clearDepthSave = ctx->Depth.Clear;
const GLuint clearStencilSave = ctx->Stencil.Clear;
- /* set new clear values */
- ctx->Depth.Clear = depth;
+ /* set new clear values
+ *
+ * Page 263 (page 279 of the PDF) of the OpenGL 3.0 spec says:
+ *
+ * "depth and stencil are the values to clear the depth and stencil
+ * buffers to, respectively. Clamping and type conversion for
+ * fixed-point depth buffers are performed in the same fashion as
+ * for ClearDepth."
+ */
+ const struct gl_renderbuffer *rb =
+ ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ const bool has_float_depth = rb &&
+ _mesa_has_depth_float_channel(rb->InternalFormat);
+ ctx->Depth.Clear = has_float_depth ? depth : SATURATE(depth);
ctx->Stencil.Clear = stencil;
/* clear buffers */