Mesa (master): anv/cmd_buffer: Reset state in cmd_buffer_destroy

Lionel Landwerlin llandwerlin at kemper.freedesktop.org
Fri Oct 6 16:33:32 UTC 2017


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

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Thu Sep 28 23:57:45 2017 +0100

anv/cmd_buffer: Reset state in cmd_buffer_destroy

This ensures that everything gets cleaned up properly. In particular,
it fixes a memory leak where we were leaking the push constants
structs.

Valgrind stats on
dEQP-VK.pipeline.push_constant.graphics_pipeline.range_size_128 :

Before:
HEAP SUMMARY:
    in use at exit: 2,467,513 bytes in 1,305 blocks
  total heap usage: 697,853 allocs, 696,530 frees, 138,466,600 bytes allocated

LEAK SUMMARY:
   definitely lost: 1,068 bytes in 11 blocks
   indirectly lost: 24,669 bytes in 412 blocks
     possibly lost: 0 bytes in 0 blocks
   still reachable: 2,441,776 bytes in 882 blocks
        suppressed: 0 bytes in 0 blocks

After:
HEAP SUMMARY:
    in use at exit: 2,467,381 bytes in 1,304 blocks
  total heap usage: 697,853 allocs, 696,531 frees, 138,466,600 bytes allocated

LEAK SUMMARY:
   definitely lost: 936 bytes in 10 blocks
   indirectly lost: 24,669 bytes in 412 blocks
     possibly lost: 0 bytes in 0 blocks
   still reachable: 2,441,776 bytes in 882 blocks
        suppressed: 0 bytes in 0 blocks

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Cc: "17.2 17.1" <mesa-stable at lists.freedesktop.org>

---

 src/intel/vulkan/anv_cmd_buffer.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c
index ec4ebf7c6f..5eec67cb60 100644
--- a/src/intel/vulkan/anv_cmd_buffer.c
+++ b/src/intel/vulkan/anv_cmd_buffer.c
@@ -150,10 +150,8 @@ anv_cmd_state_reset(struct anv_cmd_buffer *cmd_buffer)
    state->pma_fix_enabled = false;
    state->hiz_enabled = false;
 
-   if (state->attachments != NULL) {
-      vk_free(&cmd_buffer->pool->alloc, state->attachments);
-      state->attachments = NULL;
-   }
+   vk_free(&cmd_buffer->pool->alloc, state->attachments);
+   state->attachments = NULL;
 
    state->gen7.index_buffer = NULL;
 }
@@ -271,8 +269,6 @@ VkResult anv_AllocateCommandBuffers(
 static void
 anv_cmd_buffer_destroy(struct anv_cmd_buffer *cmd_buffer)
 {
-   struct anv_cmd_state *state = &cmd_buffer->state;
-
    list_del(&cmd_buffer->pool_link);
 
    anv_cmd_buffer_fini_batch_bo_chain(cmd_buffer);
@@ -280,10 +276,8 @@ anv_cmd_buffer_destroy(struct anv_cmd_buffer *cmd_buffer)
    anv_state_stream_finish(&cmd_buffer->surface_state_stream);
    anv_state_stream_finish(&cmd_buffer->dynamic_state_stream);
 
-   for (uint32_t i = 0; i < ARRAY_SIZE(state->push_descriptors); i++)
-      vk_free(&cmd_buffer->pool->alloc, state->push_descriptors[i]);
+   anv_cmd_state_reset(cmd_buffer);
 
-   vk_free(&cmd_buffer->pool->alloc, state->attachments);
    vk_free(&cmd_buffer->pool->alloc, cmd_buffer);
 }
 




More information about the mesa-commit mailing list