mesa/src/gallium/include/pipe
Christian Gmeiner 9c972a61d5 gallium: Add pipe cap for masked clears and support stencil masking
Add a new PIPE_CAP_CLEAR_MASKED capability that allows drivers to
handle buffer clears with color and stencil masks directly, instead
of falling back to drawing a quad in Mesa.

This patch introduces several changes:

1. Add the new pipe cap PIPE_CAP_CLEAR_MASKED to pipe_defines.h and
   document it in the Gallium screen documentation.

2. Add color_clear_mask and stencil_clear_mask parameters to the
   pipe_context::clear() hook:
   - color_clear_mask (uint32_t): contains 4 color mask bits per draw buffer
     (max 8 buffers = 32 bits)
   - stencil_clear_mask (uint8_t): contains the stencil write mask (8 bits)

3. Update the state tracker to use the masked clear path when the
   driver supports it:
   - Pass ctx->Color.ColorMask for color buffer clears
   - Pass ctx->Stencil.WriteMask for stencil clears
   - Allow both color and stencil clears to avoid the quad path when
     masks are present and the driver advertises support

4. Update all existing driver clear() hooks to accept the new
   color_clear_mask and stencil_clear_mask parameter.

This optimization allows drivers that can efficiently handle masked
clears in hardware to do so, improving performance for applications
that frequently clear buffers with masks enabled.

Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31512>
2026-01-27 00:57:26 +00:00
..
p_context.h gallium: Add pipe cap for masked clears and support stencil masking 2026-01-27 00:57:26 +00:00
p_defines.h gallium: Add pipe cap for masked clears and support stencil masking 2026-01-27 00:57:26 +00:00
p_screen.h gallium: add a flag to finalize_nir to allow drivers to skip NIR opts 2025-11-29 07:29:05 +00:00
p_shader_tokens.h tgsi: Remove return type from tgsi_instruction_texture 2025-08-15 08:03:04 +00:00
p_state.h gallium: declare pipe_resource::height0 as 32-bit integer for 64K textures 2025-12-05 21:22:36 +00:00
p_video_codec.h p_video_codec::encode_bitstream_sliced: Add last_slice_completion_fence for PIPE_VIDEO_SLICE_MODE_AUTO 2025-10-20 13:37:16 +00:00
p_video_enums.h pipe: Remove MPEG4 decode support 2026-01-12 14:51:35 +00:00
p_video_state.h pipe: Remove MPEG4 decode support 2026-01-12 14:51:35 +00:00