mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
mesa: Clamp some depth values in glClearBufferfv
OpenGL 3.0 spec, section 4.2.3 "Clearing the Buffers":
If buffer is DEPTH, drawbuffer must be zero, and value points to the
single depth value to clear the depth buffer to. 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 piglit test.
v2. Add spec citation. (Eric Anholt)
v3. Don't clamp floating point formats. (Eric Anholt)
Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7410>
(cherry picked from commit 1bf539b3a2)
This commit is contained in:
parent
5b83eb0b09
commit
d47cb4124a
2 changed files with 16 additions and 2 deletions
|
|
@ -1093,7 +1093,7 @@
|
|||
"description": "mesa: Clamp some depth values in glClearBufferfv",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"master_sha": null,
|
||||
"because_sha": null
|
||||
},
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
|
||||
|
||||
#include "glformats.h"
|
||||
#include "glheader.h"
|
||||
#include "clear.h"
|
||||
#include "context.h"
|
||||
|
|
@ -589,7 +590,20 @@ clear_bufferfv(struct gl_context *ctx, GLenum buffer, GLint drawbuffer,
|
|||
* hook instead.
|
||||
*/
|
||||
const GLclampd clearSave = ctx->Depth.Clear;
|
||||
ctx->Depth.Clear = *value;
|
||||
|
||||
/* Page 263 (page 279 of the PDF) of the OpenGL 3.0 spec says:
|
||||
*
|
||||
* "If buffer is DEPTH, drawbuffer must be zero, and value points
|
||||
* to the single depth value to clear the depth buffer to.
|
||||
* 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 is_float_depth =
|
||||
_mesa_has_depth_float_channel(rb->InternalFormat);
|
||||
ctx->Depth.Clear = is_float_depth ? *value : SATURATE(*value);
|
||||
|
||||
ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH);
|
||||
ctx->Depth.Clear = clearSave;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue