iris: implement texture/memory barriers
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 25 Jul 2018 04:15:13 +0000 (21:15 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:07 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_context.c
src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_pipe_control.c

index 9d0ec83afb499791023c6457fb1ff1e2c297b51b..d0bc9e5e8dc093673bccb1c93eca8f9f24960fd3 100644 (file)
@@ -136,6 +136,7 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
    iris_init_program_functions(ctx);
    iris_init_resource_functions(ctx);
    iris_init_query_functions(ctx);
+   iris_init_flush_functions(ctx);
 
    iris_init_program_cache(ice);
    iris_init_border_color_pool(ice);
index cda649127c794bc9dec6b4a55b1cdd8ed500e0ff..5aba49a2832e99ef6a75474523e144746ca9700c 100644 (file)
@@ -390,6 +390,8 @@ void iris_render_cache_add_bo(struct iris_batch *batch,
 void iris_cache_flush_for_depth(struct iris_batch *batch, struct iris_bo *bo);
 void iris_depth_cache_add_bo(struct iris_batch *batch, struct iris_bo *bo);
 
+void iris_init_flush_functions(struct pipe_context *ctx);
+
 /* iris_blorp.c */
 
 void gen9_init_blorp(struct iris_context *ice);
index ed261fdc1c0dd6b83e9a636ed4629476f8149103..1dcb0ad3e625eff02658d71b4256ba3a0542f311 100644 (file)
@@ -246,3 +246,52 @@ iris_depth_cache_add_bo(struct iris_batch *batch, struct iris_bo *bo)
 {
    _mesa_set_add(batch->cache.depth, bo);
 }
+
+static void
+iris_texture_barrier(struct pipe_context *ctx, unsigned flags)
+{
+   struct iris_context *ice = (void *) ctx;
+
+   // XXX: compute batch?
+
+   flush_depth_and_render_caches(&ice->render_batch);
+}
+
+static void
+iris_memory_barrier(struct pipe_context *ctx, unsigned flags)
+{
+   struct iris_context *ice = (void *) ctx;
+   unsigned bits = PIPE_CONTROL_DATA_CACHE_FLUSH | PIPE_CONTROL_CS_STALL;
+
+   if (flags & (PIPE_BARRIER_VERTEX_BUFFER |
+                PIPE_BARRIER_INDEX_BUFFER |
+                PIPE_BARRIER_INDIRECT_BUFFER)) {
+      bits |= PIPE_CONTROL_VF_CACHE_INVALIDATE;
+   }
+
+   if (flags & PIPE_BARRIER_CONSTANT_BUFFER) {
+      bits |= PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
+              PIPE_CONTROL_CONST_CACHE_INVALIDATE;
+   }
+
+   if (flags & PIPE_BARRIER_TEXTURE) {
+      bits |= PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE;
+   }
+
+   if (flags & PIPE_BARRIER_FRAMEBUFFER) {
+      bits |= PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
+              PIPE_CONTROL_RENDER_TARGET_FLUSH;
+   }
+
+   // XXX: MAPPED_BUFFER, QUERY_BUFFER, STREAMOUT_BUFFER, GLOBAL_BUFFER?
+   // XXX: compute batch?
+
+   iris_emit_pipe_control_flush(&ice->render_batch, bits);
+}
+
+void
+iris_init_flush_functions(struct pipe_context *ctx)
+{
+   ctx->memory_barrier = iris_memory_barrier;
+   ctx->texture_barrier = iris_texture_barrier;
+}