radv: only emit cache flushes when the pool size is large enough
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 28 Feb 2018 19:28:53 +0000 (20:28 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 1 Mar 2018 08:53:40 +0000 (09:53 +0100)
This is an optimization which reduces the number of flushes for
small pool buffers.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_meta_buffer.c
src/amd/vulkan/radv_private.h
src/amd/vulkan/radv_query.c

index e6ad235e93b840b96b56992da5d8c449c896ae1e..2e1ba2c7b22693fa0468e1ede74aa99f0323b5e6 100644 (file)
@@ -4,12 +4,6 @@
 #include "sid.h"
 #include "radv_cs.h"
 
-/*
- * This is the point we switch from using CP to compute shader
- * for certain buffer operations.
- */
-#define RADV_BUFFER_OPS_CS_THRESHOLD 4096
-
 static nir_shader *
 build_buffer_fill_shader(struct radv_device *dev)
 {
index 752b6a759220b610efdad6a05fc414c44e83abdd..0f8ddb2e106946aed59d7f4727b33f891f485635 100644 (file)
@@ -95,6 +95,12 @@ typedef uint32_t xcb_window_t;
 
 #define NUM_DEPTH_CLEAR_PIPELINES 3
 
+/*
+ * This is the point we switch from using CP to compute shader
+ * for certain buffer operations.
+ */
+#define RADV_BUFFER_OPS_CS_THRESHOLD 4096
+
 enum radv_mem_heap {
        RADV_MEM_HEAP_VRAM,
        RADV_MEM_HEAP_VRAM_CPU_ACCESS,
index ff2782bae8970cf34776b807f7a0f78f6b5c209d..9fee4d2b49141cb3d3e35eb5ae7aca6b7d084cdb 100644 (file)
@@ -1092,11 +1092,15 @@ void radv_CmdBeginQuery(
        radv_cs_add_buffer(cmd_buffer->device->ws, cs, pool->bo, 8);
 
        if (cmd_buffer->pending_reset_query) {
-               /* Make sure to flush caches if the query pool has been
-                * previously resetted using the compute shader path.
-                */
-               si_emit_cache_flush(cmd_buffer);
-               cmd_buffer->pending_reset_query = false;
+               if (pool->size >= RADV_BUFFER_OPS_CS_THRESHOLD) {
+                       /* Only need to flush caches if the query pool size is
+                        * large enough to be resetted using the compute shader
+                        * path. Small pools don't need any cache flushes
+                        * because we use a CP dma clear.
+                        */
+                       si_emit_cache_flush(cmd_buffer);
+                       cmd_buffer->pending_reset_query = false;
+               }
        }
 
        switch (pool->type) {