Module: Mesa
Branch: master
Commit: cdc546ae7fe7477d97cf7b09ac8db0e44a3cfc45
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cdc546ae7fe7477d97cf7b09ac8db0e44a3cfc45

Author: Jason Ekstrand <[email protected]>
Date:   Mon Oct 19 22:33:05 2020 -0500

iris: Flush caches based on brw_compiler::indirect_ubos_use_sampler

Reviewed-by: Kenneth Graunke <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7230>

---

 src/gallium/drivers/iris/iris_program.c  |  6 ++++--
 src/gallium/drivers/iris/iris_resource.c | 15 ++++++++++-----
 src/gallium/drivers/iris/iris_resource.h |  3 ++-
 src/gallium/drivers/iris/iris_state.c    |  2 +-
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_program.c 
b/src/gallium/drivers/iris/iris_program.c
index c8930b763a6..8157e921850 100644
--- a/src/gallium/drivers/iris/iris_program.c
+++ b/src/gallium/drivers/iris/iris_program.c
@@ -171,12 +171,14 @@ iris_upload_ubo_ssbo_surf_state(struct iris_context *ice,
    struct iris_bo *surf_bo = iris_resource_bo(surf_state->res);
    surf_state->offset += iris_bo_offset_from_base_address(surf_bo);
 
+   const bool dataport = ssbo || !screen->compiler->indirect_ubos_use_sampler;
+
    isl_buffer_fill_state(&screen->isl_dev, map,
                          .address = res->bo->gtt_offset + res->offset +
                                     buf->buffer_offset,
                          .size_B = buf->buffer_size - res->offset,
-                         .format = ssbo ? ISL_FORMAT_RAW
-                                        : ISL_FORMAT_R32G32B32A32_FLOAT,
+                         .format = dataport ? ISL_FORMAT_RAW
+                                            : ISL_FORMAT_R32G32B32A32_FLOAT,
                          .swizzle = ISL_SWIZZLE_IDENTITY,
                          .stride_B = 1,
                          .mocs = iris_mocs(res->bo, &screen->isl_dev, usage));
diff --git a/src/gallium/drivers/iris/iris_resource.c 
b/src/gallium/drivers/iris/iris_resource.c
index bba5c120c87..19b4669c550 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -1984,7 +1984,7 @@ iris_transfer_flush_region(struct pipe_context *ctx,
          history_flush |= PIPE_CONTROL_RENDER_TARGET_FLUSH;
 
       if (map->dest_had_defined_contents)
-         history_flush |= iris_flush_bits_for_history(res);
+         history_flush |= iris_flush_bits_for_history(ice, res);
 
       util_range_add(&res->base, &res->valid_buffer_range, box->x, box->x + 
box->width);
    }
@@ -2132,13 +2132,18 @@ iris_dirty_for_history(struct iris_context *ice,
  * resource becomes visible, and any stale read cache data is invalidated.
  */
 uint32_t
-iris_flush_bits_for_history(struct iris_resource *res)
+iris_flush_bits_for_history(struct iris_context *ice,
+                            struct iris_resource *res)
 {
+   struct iris_screen *screen = (struct iris_screen *) ice->ctx.screen;
+
    uint32_t flush = PIPE_CONTROL_CS_STALL;
 
    if (res->bind_history & PIPE_BIND_CONSTANT_BUFFER) {
-      flush |= PIPE_CONTROL_CONST_CACHE_INVALIDATE |
-               PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE;
+      flush |= PIPE_CONTROL_CONST_CACHE_INVALIDATE;
+      flush |= screen->compiler->indirect_ubos_use_sampler ?
+               PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE :
+               PIPE_CONTROL_DATA_CACHE_FLUSH;
    }
 
    if (res->bind_history & PIPE_BIND_SAMPLER_VIEW)
@@ -2163,7 +2168,7 @@ iris_flush_and_dirty_for_history(struct iris_context *ice,
    if (res->base.target != PIPE_BUFFER)
       return;
 
-   uint32_t flush = iris_flush_bits_for_history(res) | extra_flags;
+   uint32_t flush = iris_flush_bits_for_history(ice, res) | extra_flags;
 
    iris_emit_pipe_control_flush(batch, reason, flush);
 
diff --git a/src/gallium/drivers/iris/iris_resource.h 
b/src/gallium/drivers/iris/iris_resource.h
index 0c29a1e182a..2662181666a 100644
--- a/src/gallium/drivers/iris/iris_resource.h
+++ b/src/gallium/drivers/iris/iris_resource.h
@@ -320,7 +320,8 @@ void iris_init_screen_resource_functions(struct pipe_screen 
*pscreen);
 
 void iris_dirty_for_history(struct iris_context *ice,
                             struct iris_resource *res);
-uint32_t iris_flush_bits_for_history(struct iris_resource *res);
+uint32_t iris_flush_bits_for_history(struct iris_context *ice,
+                                     struct iris_resource *res);
 
 void iris_flush_and_dirty_for_history(struct iris_context *ice,
                                       struct iris_batch *batch,
diff --git a/src/gallium/drivers/iris/iris_state.c 
b/src/gallium/drivers/iris/iris_state.c
index 5816df9a853..ab7d3d0ac37 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -3684,7 +3684,7 @@ iris_set_stream_output_targets(struct pipe_context *ctx,
             if (tgt) {
                struct iris_resource *res = (void *) tgt->base.buffer;
 
-               flush |= iris_flush_bits_for_history(res);
+               flush |= iris_flush_bits_for_history(ice, res);
                iris_dirty_for_history(ice, res);
             }
          }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to