iris: use u_transfer_helper for depth stencil packing/unpacking
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 8 Aug 2018 21:54:09 +0000 (14:54 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:08 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_resource.c
src/gallium/drivers/iris/iris_resource.h

index b49cf62d21192633591c53205f49f9cc100bf83d..3c2e3848a1e10d26db568abb68937893f6b6cae9 100644 (file)
@@ -40,6 +40,7 @@
 #include "util/u_inlines.h"
 #include "util/u_format.h"
 #include "util/u_transfer.h"
+#include "util/u_transfer_helper.h"
 #include "util/u_upload_mgr.h"
 #include "util/ralloc.h"
 #include "iris_batch.h"
@@ -170,6 +171,14 @@ iris_resource_get_separate_stencil(struct pipe_resource *p_res)
    return p_res->next;
 }
 
+static void
+iris_resource_set_separate_stencil(struct pipe_resource *p_res,
+                                   struct pipe_resource *stencil)
+{
+   assert(util_format_has_depth(util_format_description(p_res->format)));
+   p_res->next = stencil;
+}
+
 void
 iris_get_depth_stencil_resources(struct pipe_resource *res,
                                  struct iris_resource **out_z,
@@ -282,6 +291,7 @@ iris_resource_create_with_modifiers(struct pipe_screen *pscreen,
    }
 
    enum pipe_format pfmt = templ->format;
+   res->internal_format = pfmt;
 
    if (util_format_is_depth_and_stencil(pfmt)) {
       struct pipe_resource t = *templ;
@@ -786,13 +796,6 @@ iris_transfer_map(struct pipe_context *ctx,
    return map->ptr;
 }
 
-static void
-iris_transfer_flush_region(struct pipe_context *pipe,
-                           struct pipe_transfer *transfer,
-                           const struct pipe_box *box)
-{
-}
-
 static void
 iris_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer *xfer)
 {
@@ -822,24 +825,44 @@ iris_flush_resource(struct pipe_context *ctx, struct pipe_resource *resource)
 {
 }
 
+static enum pipe_format
+iris_resource_get_internal_format(struct pipe_resource *p_res)
+{
+   struct iris_resource *res = (void *) p_res;
+   return res->internal_format;
+}
+
+static const struct u_transfer_vtbl transfer_vtbl = {
+   .resource_create       = iris_resource_create,
+   .resource_destroy      = iris_resource_destroy,
+   .transfer_map          = iris_transfer_map,
+   .transfer_unmap        = iris_transfer_unmap,
+   .transfer_flush_region = u_default_transfer_flush_region,
+   .get_internal_format   = iris_resource_get_internal_format,
+   .set_stencil           = iris_resource_set_separate_stencil,
+   .get_stencil           = iris_resource_get_separate_stencil,
+};
+
 void
 iris_init_screen_resource_functions(struct pipe_screen *pscreen)
 {
    pscreen->resource_create_with_modifiers =
       iris_resource_create_with_modifiers;
-   pscreen->resource_create = iris_resource_create;
+   pscreen->resource_create = u_transfer_helper_resource_create;
    pscreen->resource_from_handle = iris_resource_from_handle;
    pscreen->resource_get_handle = iris_resource_get_handle;
-   pscreen->resource_destroy = iris_resource_destroy;
+   pscreen->resource_destroy = u_transfer_helper_resource_destroy;
+   pscreen->transfer_helper =
+      u_transfer_helper_create(&transfer_vtbl, true, true, false, false);
 }
 
 void
 iris_init_resource_functions(struct pipe_context *ctx)
 {
    ctx->flush_resource = iris_flush_resource;
-   ctx->transfer_map = iris_transfer_map;
-   ctx->transfer_flush_region = iris_transfer_flush_region;
-   ctx->transfer_unmap = iris_transfer_unmap;
+   ctx->transfer_map = u_transfer_helper_transfer_map;
+   ctx->transfer_flush_region = u_transfer_helper_transfer_flush_region;
+   ctx->transfer_unmap = u_transfer_helper_transfer_unmap;
    ctx->buffer_subdata = u_default_buffer_subdata;
    ctx->texture_subdata = u_default_texture_subdata;
 }
index 06ade481921e6cb0f81f083352c149408fab1cc1..c6e1e1de174a21b6ad627e4d48080401d9a3b76c 100644 (file)
@@ -38,6 +38,7 @@
  */
 struct iris_resource {
    struct pipe_resource        base;
+   enum pipe_format internal_format;
    struct isl_surf surf;
    struct iris_bo *bo;
 };