zink: add more clear hooks
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 18 Jun 2021 15:47:23 +0000 (11:47 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 22 Jun 2021 12:45:39 +0000 (12:45 +0000)
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11466>

src/gallium/drivers/zink/zink_clear.c
src/gallium/drivers/zink/zink_clear.h
src/gallium/drivers/zink/zink_context.c

index 3594396..bf38e97 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "zink_context.h"
+#include "zink_query.h"
 #include "zink_resource.h"
 #include "zink_screen.h"
 
@@ -468,6 +469,32 @@ zink_clear_buffer(struct pipe_context *pctx,
    pipe_buffer_unmap(pctx, xfer);
 }
 
+void
+zink_clear_render_target(struct pipe_context *pctx, struct pipe_surface *dst,
+                         const union pipe_color_union *color, unsigned dstx,
+                         unsigned dsty, unsigned width, unsigned height,
+                         bool render_condition_enabled)
+{
+   struct zink_context *ctx = zink_context(pctx);
+   zink_blit_begin(ctx, ZINK_BLIT_SAVE_FB | ZINK_BLIT_SAVE_FS | (render_condition_enabled ? 0 : ZINK_BLIT_NO_COND_RENDER));
+   util_blitter_clear_render_target(ctx->blitter, dst, color, dstx, dsty, width, height);
+   if (!render_condition_enabled && ctx->render_condition_active)
+      zink_start_conditional_render(ctx);
+}
+
+void
+zink_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *dst,
+                         unsigned clear_flags, double depth, unsigned stencil,
+                         unsigned dstx, unsigned dsty, unsigned width, unsigned height,
+                         bool render_condition_enabled)
+{
+   struct zink_context *ctx = zink_context(pctx);
+   zink_blit_begin(ctx, ZINK_BLIT_SAVE_FB | ZINK_BLIT_SAVE_FS | (render_condition_enabled ? 0 : ZINK_BLIT_NO_COND_RENDER));
+   util_blitter_clear_depth_stencil(ctx->blitter, dst, clear_flags, depth, stencil, dstx, dsty, width, height);
+   if (!render_condition_enabled && ctx->render_condition_active)
+      zink_start_conditional_render(ctx);
+}
+
 bool
 zink_fb_clear_needs_explicit(struct zink_framebuffer_clear *fb_clear)
 {
index 2eb8127..5f6492a 100644 (file)
@@ -72,6 +72,19 @@ zink_clear_buffer(struct pipe_context *pctx,
                   unsigned size,
                   const void *clear_value,
                   int clear_value_size);
+
+void
+zink_clear_render_target(struct pipe_context *ctx, struct pipe_surface *dst,
+                         const union pipe_color_union *color, unsigned dstx,
+                         unsigned dsty, unsigned width, unsigned height,
+                         bool render_condition_enabled);
+
+void
+zink_clear_depth_stencil(struct pipe_context *ctx, struct pipe_surface *dst,
+                         unsigned clear_flags, double depth, unsigned stencil,
+                         unsigned dstx, unsigned dsty, unsigned width, unsigned height,
+                         bool render_condition_enabled);
+
 bool
 zink_fb_clear_needs_explicit(struct zink_framebuffer_clear *fb_clear);
 
index 5b5dbea..087df64 100644 (file)
@@ -3378,6 +3378,8 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
    ctx->base.clear = zink_clear;
    ctx->base.clear_texture = zink_clear_texture;
    ctx->base.clear_buffer = zink_clear_buffer;
+   ctx->base.clear_render_target = zink_clear_render_target;
+   ctx->base.clear_depth_stencil = zink_clear_depth_stencil;
 
    ctx->base.draw_vbo = zink_draw_vbo;
    ctx->base.launch_grid = zink_launch_grid;