iris: actually emit stencil packets
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 3 Aug 2018 23:18:09 +0000 (16:18 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:08 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_clear.c
src/gallium/drivers/iris/iris_resource.c
src/gallium/drivers/iris/iris_resource.h
src/gallium/drivers/iris/iris_state.c

index 2ee70855bf8984ec8acbea5d915d3edd081f4184..d05e69df16b8787709cefe6aec704a6a55cc76ed 100644 (file)
 #include "iris_screen.h"
 #include "intel/compiler/brw_compiler.h"
 
-static void
-split_depth_stencil_resources(struct pipe_resource *res,
-                              struct pipe_resource **out_z,
-                              struct pipe_resource **out_s)
-{
-   const struct util_format_description *desc =
-      util_format_description(res->format);
-
-   if (util_format_has_depth(desc)) {
-      *out_z = res;
-      *out_s = iris_resource_get_separate_stencil(res);
-   } else {
-      assert(util_format_has_stencil(desc));
-      *out_z = NULL;
-      *out_s = res;
-   }
-}
-
 /**
  * The pipe->clear() driver hook.
  *
@@ -78,22 +60,22 @@ iris_clear(struct pipe_context *ctx,
 
    if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
       struct pipe_surface *psurf = cso_fb->zsbuf;
-      struct pipe_resource *z_res;
-      struct pipe_resource *stencil_res;
+      struct iris_resource *z_res;
+      struct iris_resource *stencil_res;
       struct blorp_surf z_surf;
       struct blorp_surf stencil_surf;
       const unsigned num_layers =
          psurf->u.tex.last_layer - psurf->u.tex.first_layer + 1;
 
-      split_depth_stencil_resources(psurf->texture, &z_res, &stencil_res);
+      iris_get_depth_stencil_resources(psurf->texture, &z_res, &stencil_res);
 
       if (z_res) {
-         iris_blorp_surf_for_resource(&z_surf, z_res,
+         iris_blorp_surf_for_resource(&z_surf, &z_res->base,
                                       ISL_AUX_USAGE_NONE, true);
       }
 
       if (stencil_res) {
-         iris_blorp_surf_for_resource(&stencil_surf, stencil_res,
+         iris_blorp_surf_for_resource(&stencil_surf, &stencil_res->base,
                                       ISL_AUX_USAGE_NONE, true);
       }
 
index 3417cef893c1aae72ca840228022944c54861252..6a2a6c3b79f7d3a5bcb43aa74eaedf69664c8a4f 100644 (file)
@@ -170,6 +170,30 @@ iris_resource_get_separate_stencil(struct pipe_resource *p_res)
    return p_res->next;
 }
 
+void
+iris_get_depth_stencil_resources(struct pipe_resource *res,
+                                 struct iris_resource **out_z,
+                                 struct iris_resource **out_s)
+{
+   if (!res) {
+      *out_z = NULL;
+      *out_s = NULL;
+      return;
+   }
+
+   const struct util_format_description *desc =
+      util_format_description(res->format);
+
+   if (util_format_has_depth(desc)) {
+      *out_z = (void *) res;
+      *out_s = (void *) iris_resource_get_separate_stencil(res);
+   } else {
+      assert(util_format_has_stencil(desc));
+      *out_z = NULL;
+      *out_s = (void *) res;
+   }
+}
+
 static void
 iris_resource_destroy(struct pipe_screen *screen,
                       struct pipe_resource *resource)
index 4679036fcd5f355a1bf86f20bf637d40ef21594f..06ade481921e6cb0f81f083352c149408fab1cc1 100644 (file)
@@ -89,6 +89,10 @@ enum isl_format iris_isl_format_for_pipe_format(enum pipe_format pf);
 
 struct pipe_resource *iris_resource_get_separate_stencil(struct pipe_resource *);
 
+void iris_get_depth_stencil_resources(struct pipe_resource *res,
+                                      struct iris_resource **out_z,
+                                      struct iris_resource **out_s);
+
 void iris_init_screen_resource_functions(struct pipe_screen *pscreen);
 
 #endif
index d67c9bd84b2426d3262b42bb3498edf06b4160e6..c8ae43fa01dc8f80373e6d242410019a5cde1788 100644 (file)
@@ -1641,6 +1641,8 @@ iris_set_framebuffer_state(struct pipe_context *ctx,
    struct iris_screen *screen = (struct iris_screen *)ctx->screen;
    struct isl_device *isl_dev = &screen->isl_dev;
    struct pipe_framebuffer_state *cso = &ice->state.framebuffer;
+   struct iris_resource *zres;
+   struct iris_resource *stencil_res;
 
    unsigned samples = util_framebuffer_get_num_samples(state);
 
@@ -1674,41 +1676,33 @@ iris_set_framebuffer_state(struct pipe_context *ctx,
       .mocs = MOCS_WB,
    };
 
-   struct iris_resource *zres =
-      (void *) (cso->zsbuf ? cso->zsbuf->texture : NULL);
-
-   if (zres) {
-      view.usage |= ISL_SURF_USAGE_DEPTH_BIT;
-
-      info.depth_surf = &zres->surf;
-      info.depth_address = zres->bo->gtt_offset;
-
-      view.format = zres->surf.format;
+   if (cso->zsbuf) {
+      iris_get_depth_stencil_resources(cso->zsbuf->texture, &zres,
+                                       &stencil_res);
 
       view.base_level = cso->zsbuf->u.tex.level;
       view.base_array_layer = cso->zsbuf->u.tex.first_layer;
       view.array_len =
          cso->zsbuf->u.tex.last_layer - cso->zsbuf->u.tex.first_layer + 1;
 
-      info.hiz_usage = ISL_AUX_USAGE_NONE;
-   }
+      if (zres) {
+         view.usage |= ISL_SURF_USAGE_DEPTH_BIT;
 
-#if 0
-   if (stencil_mt) {
-      view.usage |= ISL_SURF_USAGE_STENCIL_BIT;
-      info.stencil_surf = &stencil_mt->surf;
-
-      if (!depth_mt) {
-         view.base_level = stencil_irb->mt_level - stencil_irb->mt->first_level;
-         view.base_array_layer = stencil_irb->mt_layer;
-         view.array_len = MAX2(stencil_irb->layer_count, 1);
-         view.format = stencil_mt->surf.format;
+         info.depth_surf = &zres->surf;
+         info.depth_address = zres->bo->gtt_offset;
+         info.hiz_usage = ISL_AUX_USAGE_NONE;
+
+         view.format = zres->surf.format;
       }
 
-      uint32_t stencil_offset = 0;
-      info.stencil_address = stencil_mt->bo->gtt_offset + stencil_mt->offset;
+      if (stencil_res) {
+         view.usage |= ISL_SURF_USAGE_STENCIL_BIT;
+         info.stencil_surf = &stencil_res->surf;
+         info.stencil_address = stencil_res->bo->gtt_offset;
+         if (!zres)
+            view.format = stencil_res->surf.format;
+      }
    }
-#endif
 
    isl_emit_depth_stencil_hiz_s(isl_dev, cso_z->packets, &info);