iris: clears
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 24 Jun 2018 22:16:34 +0000 (15:16 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:07 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_blit.c
src/gallium/drivers/iris/iris_clear.c
src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_resource.h
src/gallium/drivers/iris/iris_state.c

index 9c328ac12f1f5d795896611c1cd92c93d9129584..f6b6e3b15307af6ed67b35feaf242af7b4da8c90 100644 (file)
 #include "iris_resource.h"
 #include "iris_screen.h"
 
-static void
-blorp_surf_for_resource(struct blorp_surf *surf,
-                        struct pipe_resource *p_res,
-                        enum isl_aux_usage aux_usage,
-                        bool is_render_target)
+void
+iris_blorp_surf_for_resource(struct blorp_surf *surf,
+                             struct pipe_resource *p_res,
+                             enum isl_aux_usage aux_usage,
+                             bool is_render_target)
 {
    struct iris_resource *res = (void *) p_res;
 
@@ -72,10 +72,10 @@ iris_blit(struct pipe_context *ctx, const struct pipe_blit_info *info)
 {
    struct iris_context *ice = (void *) ctx;
    struct blorp_surf src_surf, dst_surf;
-   blorp_surf_for_resource(&src_surf, info->src.resource, ISL_AUX_USAGE_NONE,
-                           false);
-   blorp_surf_for_resource(&dst_surf, info->dst.resource, ISL_AUX_USAGE_NONE,
-                           true);
+   iris_blorp_surf_for_resource(&src_surf, info->src.resource,
+                                ISL_AUX_USAGE_NONE, false);
+   iris_blorp_surf_for_resource(&dst_surf, info->dst.resource,
+                                ISL_AUX_USAGE_NONE, true);
 
    enum isl_format src_isl_format = iris_get_blorp_format(info->src.format);
    enum isl_format dst_isl_format = iris_get_blorp_format(info->dst.format);
index 807e9ef7ec251eefa4007cc4a07c6f9a6464d8cb..793777dbee3994c2fca5d526e9d00adcfded700c 100644 (file)
 static void
 iris_clear(struct pipe_context *ctx,
            unsigned buffers,
-           const union pipe_color_union *color,
+           const union pipe_color_union *p_color,
            double depth,
            unsigned stencil)
 {
+   struct iris_context *ice = (void *) ctx;
+   assert(buffers != 0);
+
+   struct blorp_batch blorp_batch;
+   blorp_batch_init(&ice->blorp, &blorp_batch, &ice->render_batch, 0);
+
+   if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
+      fprintf(stderr, "XXX: depth/stencil clears not implemented\n");
+   }
+
+   if (buffers & PIPE_CLEAR_COLOR) {
+      struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
+      /* pipe_color_union and isl_color_value are interchangeable */
+      union isl_color_value *clear_color = (void *) p_color;
+      bool color_write_disable[4] = { false, false, false, false };
+
+      for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
+         if (buffers & (PIPE_CLEAR_COLOR0 << i)) {
+            struct pipe_surface *psurf = cso_fb->cbufs[i];
+            struct iris_surface *isurf = (void *) psurf;
+            struct blorp_surf surf;
+
+            iris_blorp_surf_for_resource(&surf, psurf->texture,
+                                         ISL_AUX_USAGE_NONE, true);
+
+            blorp_clear(&blorp_batch, &surf, isurf->view.format,
+                        ISL_SWIZZLE_IDENTITY, 0, 0, cso_fb->layers,
+                        0, 0, cso_fb->width, cso_fb->height,
+                        *clear_color, color_write_disable);
+         }
+      }
+   }
+
+   blorp_batch_finish(&blorp_batch);
 }
 
 static void
@@ -52,6 +86,7 @@ iris_clear_render_target(struct pipe_context *ctx,
                          unsigned width, unsigned height,
                          bool render_condition_enabled)
 {
+   fprintf(stderr, "XXX: iris_clear_render_target\n");
 }
 
 static void
@@ -64,6 +99,7 @@ iris_clear_depth_stencil(struct pipe_context *ctx,
                          unsigned width, unsigned height,
                          bool render_condition_enabled)
 {
+   fprintf(stderr, "XXX: iris_clear_depth_stencil\n");
 }
 
 void
index 14620b3be2a5a487d0067722f69edede1fea026e..b5489c7e46ece80a55c1b93f10c4ba2d43d13028 100644 (file)
@@ -308,6 +308,12 @@ void iris_init_resource_functions(struct pipe_context *ctx);
 void iris_init_query_functions(struct pipe_context *ctx);
 void iris_update_compiled_shaders(struct iris_context *ice);
 
+/* iris_blit.c */
+void iris_blorp_surf_for_resource(struct blorp_surf *surf,
+                                  struct pipe_resource *p_res,
+                                  enum isl_aux_usage aux_usage,
+                                  bool is_render_target);
+
 /* iris_draw.c */
 
 void iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info);
index 6225509aa11ba596e416a6bf7859e3eea1f39378..45b8cf6a6c7847449a997cb10e9fdf37221f7f17 100644 (file)
@@ -44,4 +44,13 @@ iris_resource_bo(struct pipe_resource *p_res)
    return res->bo;
 }
 
+struct iris_surface {
+   struct pipe_surface pipe;
+   struct isl_view view;
+
+   /** The resource (BO) holding our SURFACE_STATE. */
+   struct pipe_resource *surface_state_resource;
+   unsigned surface_state_offset;
+};
+
 #endif
index 91ff1f811a436b227e858e2386e0e190b70618c6..67d098d601a0a9ddd3b4ce9b5850c706615ce111 100644 (file)
@@ -980,15 +980,6 @@ iris_create_sampler_view(struct pipe_context *ctx,
    return &isv->pipe;
 }
 
-struct iris_surface {
-   struct pipe_surface pipe;
-   struct isl_view view;
-
-   /** The resource (BO) holding our SURFACE_STATE. */
-   struct pipe_resource *surface_state_resource;
-   unsigned surface_state_offset;
-};
-
 static struct pipe_surface *
 iris_create_surface(struct pipe_context *ctx,
                     struct pipe_resource *tex,