[Mesa-stable] [PATCH] anv/cmd_buffer: fix dynamic state leak

cstout at chromium.org cstout at chromium.org
Wed Mar 29 19:11:55 UTC 2017


From: Craig Stout <cstout at google.com>

anv_state_pool_alloc requires a matching free, whereas
anv_state_stream_alloc will be cleaned up on finish.

Applies only to 13.0 branch.
x
https://bugs.freedesktop.org/show_bug.cgi?id=100365
---
 src/intel/vulkan/anv_private.h     | 12 ++++++++++++
 src/intel/vulkan/genX_cmd_buffer.c | 32 ++++++++++++++++----------------
 2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index dd67508..12a6aa1 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -765,6 +765,18 @@ _anv_combine_address(struct anv_batch *batch, void *location,
       __state;                                                          \
    })
 
+#define anv_state_stream_emit(stream, cmd, align, ...)                                             \
+   ({                                                                                              \
+      const uint32_t __size = __anv_cmd_length(cmd) * 4;                                           \
+      struct anv_state __state = anv_state_stream_alloc((stream), __size, align);                  \
+      struct cmd __template = {__VA_ARGS__};                                                       \
+      __anv_cmd_pack(cmd)(NULL, __state.map, &__template);                                         \
+      VG(VALGRIND_CHECK_MEM_IS_DEFINED(__state.map, __anv_cmd_length(cmd) * 4));                   \
+      if (!(stream)->block_pool->device->info.has_llc)                                             \
+         anv_state_clflush(__state);                                                               \
+      __state;                                                                                     \
+   })
+
 #define GEN7_MOCS (struct GEN7_MEMORY_OBJECT_CONTROL_STATE) {  \
    .GraphicsDataTypeGFDT                        = 0,           \
    .LLCCacheabilityControlLLCCC                 = 0,           \
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 45fefc9..33db7ce 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -1367,26 +1367,26 @@ flush_compute_descriptor_set(struct anv_cmd_buffer *cmd_buffer)
    const uint32_t slm_size = encode_slm_size(GEN_GEN, prog_data->total_shared);
 
    struct anv_state state =
-      anv_state_pool_emit(&device->dynamic_state_pool,
-                          GENX(INTERFACE_DESCRIPTOR_DATA), 64,
-                          .KernelStartPointer = pipeline->cs_simd,
-                          .BindingTablePointer = surfaces.offset,
-                          .BindingTableEntryCount = 0,
-                          .SamplerStatePointer = samplers.offset,
-                          .SamplerCount = 0,
+      anv_state_stream_emit(&cmd_buffer->dynamic_state_stream,
+                            GENX(INTERFACE_DESCRIPTOR_DATA), 64,
+                            .KernelStartPointer = pipeline->cs_simd,
+                            .BindingTablePointer = surfaces.offset,
+                            .BindingTableEntryCount = 0,
+                            .SamplerStatePointer = samplers.offset,
+                            .SamplerCount = 0,
 #if !GEN_IS_HASWELL
-                          .ConstantURBEntryReadOffset = 0,
+                            .ConstantURBEntryReadOffset = 0,
 #endif
-                          .ConstantURBEntryReadLength =
-                             cs_prog_data->push.per_thread.regs,
+                            .ConstantURBEntryReadLength =
+                              cs_prog_data->push.per_thread.regs,
 #if GEN_GEN >= 8 || GEN_IS_HASWELL
-                          .CrossThreadConstantDataReadLength =
-                             cs_prog_data->push.cross_thread.regs,
+                            .CrossThreadConstantDataReadLength =
+                              cs_prog_data->push.cross_thread.regs,
 #endif
-                          .BarrierEnable = cs_prog_data->uses_barrier,
-                          .SharedLocalMemorySize = slm_size,
-                          .NumberofThreadsinGPGPUThreadGroup =
-                             cs_prog_data->threads);
+                            .BarrierEnable = cs_prog_data->uses_barrier,
+                            .SharedLocalMemorySize = slm_size,
+                            .NumberofThreadsinGPGPUThreadGroup =
+                              cs_prog_data->threads);
 
    uint32_t size = GENX(INTERFACE_DESCRIPTOR_DATA_length) * sizeof(uint32_t);
    anv_batch_emit(&cmd_buffer->batch,
-- 
2.7.4



More information about the mesa-stable mailing list