svga: Don't crash if only one of Depth or Stencil buffer is present
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

This piglit test arb_clear_texture-depth was crashing because we assume
we always have stencil and depth buffer.

Signed-off-by: Ian Forbes <ian.forbes@broadcom.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38836>
This commit is contained in:
Ian Forbes 2025-12-05 14:31:54 -06:00 committed by Marge Bot
parent d2f336c108
commit d75f5e0add
2 changed files with 9 additions and 10 deletions

View file

@ -150,7 +150,7 @@ spec@!opengl es 3.0@gles-3.0-transform-feedback-uniform-buffer-object,Fail
spec@arb_arrays_of_arrays@execution@atomic_counters@fs-indirect-index,Fail
spec@arb_arrays_of_arrays@execution@atomic_counters@vs-indirect-index,Fail
spec@arb_arrays_of_arrays@execution@sampler@fs-nested-struct-arrays-nonconst-nested-array,Fail
spec@arb_clear_texture@arb_clear_texture-depth,Crash
spec@arb_clear_texture@arb_clear_texture-depth,Fail
spec@arb_clear_texture@arb_clear_texture-depth-stencil,Fail
spec@arb_clear_texture@arb_clear_texture-stencil,Fail
spec@arb_clip_control@arb_clip_control-clip-control,Fail

View file

@ -289,24 +289,23 @@ svga_clear_texture(struct pipe_context *pipe,
util_format_description(surface->format);
if (util_format_is_depth_or_stencil(surface->format)) {
float depth;
uint8_t stencil;
float depth = 0.0f;
uint8_t stencil = 0;
unsigned clear_flags = 0;
/* If data is NULL, then set depthValue and stencilValue to zeros */
if (data == NULL) {
depth = 0.0;
stencil = 0;
} else {
util_format_unpack_z_float(surface->format, &depth, data, 1);
util_format_unpack_s_8uint(surface->format, &stencil, data, 1);
}
if (util_format_has_depth(desc)) {
clear_flags |= PIPE_CLEAR_DEPTH;
if (data) {
util_format_unpack_z_float(surface->format, &depth, data, 1);
}
}
if (util_format_has_stencil(desc)) {
clear_flags |= PIPE_CLEAR_STENCIL;
if (data) {
util_format_unpack_s_8uint(surface->format, &stencil, data, 1);
}
}
/* Setup depth stencil view */