iris: add iris_flush_and_dirty_for_history
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 21 Nov 2018 08:52:25 +0000 (00:52 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:10 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_resource.c
src/gallium/drivers/iris/iris_resource.h

index 652cf6f7b7afd9ada29f737d7f31d45eb324d4f0..67586b22751099cef4db5e0ec79d3eff7b05a022 100644 (file)
@@ -887,6 +887,46 @@ iris_flush_resource(struct pipe_context *ctx, struct pipe_resource *resource)
 {
 }
 
+void
+iris_flush_and_dirty_for_history(struct iris_context *ice,
+                                 struct iris_resource *res)
+{
+   if (res->base.target != PIPE_BUFFER)
+      return;
+
+   unsigned flush = PIPE_CONTROL_CS_STALL;
+   uint64_t dirty = 0ull;
+
+   if (res->bind_history & PIPE_BIND_CONSTANT_BUFFER) {
+      flush |= PIPE_CONTROL_CONST_CACHE_INVALIDATE |
+               PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE;
+      dirty |= IRIS_DIRTY_CONSTANTS_VS |
+               IRIS_DIRTY_CONSTANTS_TCS |
+               IRIS_DIRTY_CONSTANTS_TES |
+               IRIS_DIRTY_CONSTANTS_GS |
+               IRIS_DIRTY_CONSTANTS_FS |
+               IRIS_DIRTY_CONSTANTS_CS |
+               IRIS_ALL_DIRTY_BINDINGS;
+   }
+
+   if (res->bind_history & PIPE_BIND_SAMPLER_VIEW)
+      flush |= PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE;
+
+   if (res->bind_history & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER))
+      flush |= PIPE_CONTROL_VF_CACHE_INVALIDATE;
+
+   if (res->bind_history & (PIPE_BIND_SHADER_BUFFER | PIPE_BIND_SHADER_IMAGE))
+      flush |= PIPE_CONTROL_DATA_CACHE_FLUSH;
+
+   // XXX: don't emit flushes in both engines...?
+   for (int i = 0; i < IRIS_BATCH_COUNT; i++) {
+      if (ice->batches[i].contains_draw)
+         iris_emit_pipe_control_flush(&ice->batches[i], flush);
+   }
+
+   ice->state.dirty |= dirty;
+}
+
 static enum pipe_format
 iris_resource_get_internal_format(struct pipe_resource *p_res)
 {
index 6ec73de39b944a39c4a8d6c3bf036e9378811ed6..cff0efe49ad069ae08a8723d08bf5483e4be3372 100644 (file)
@@ -27,6 +27,8 @@
 #include "util/u_inlines.h"
 #include "intel/isl/isl.h"
 
+struct iris_context;
+
 struct iris_format_info {
    enum isl_format fmt;
    struct isl_swizzle swizzle;
@@ -133,4 +135,7 @@ void iris_get_depth_stencil_resources(struct pipe_resource *res,
 
 void iris_init_screen_resource_functions(struct pipe_screen *pscreen);
 
+void iris_flush_and_dirty_for_history(struct iris_context *ice,
+                                      struct iris_resource *res);
+
 #endif