Mesa (staging/20.0): anv: Account for the header in anv_state_stream_alloc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 1 16:06:15 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: e51b749f1dacba70a4bc690246f8484301eb1de8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e51b749f1dacba70a4bc690246f8484301eb1de8

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Thu Mar 26 12:22:48 2020 -0500

anv: Account for the header in anv_state_stream_alloc

If we have an allocation that's exactly the block size, we end up
computing a new block size to allocate that's exactly the block size,
add in the header, and then assert fail.  When computing the block size,
we need to account for the header.

Fixes: 955127db937 "anv/allocator: Add support for large stream..."
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4336>
(cherry picked from commit 63bec07e14d1cd8e01bf45bcda341bb364620cfc)

---

 .pick_status.json                | 2 +-
 src/intel/vulkan/anv_allocator.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index d2a5fe1200d..8c9d75b0e8d 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -40,7 +40,7 @@
         "description": "anv: Account for the header in anv_state_stream_alloc",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "955127db9376b49a41a428f5f89137cafec89b1c"
     },
diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index f698289155b..9b1fdc077c8 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -1226,9 +1226,10 @@ anv_state_stream_alloc(struct anv_state_stream *stream,
 
    uint32_t offset = align_u32(stream->next, alignment);
    if (offset + size > stream->block.alloc_size) {
+      uint32_t min_block_size = size + sizeof(struct anv_state_stream_block);
       uint32_t block_size = stream->block_size;
-      if (block_size < size)
-         block_size = round_to_power_of_two(size);
+      if (block_size < min_block_size)
+         block_size = round_to_power_of_two(min_block_size);
 
       stream->block = anv_state_pool_alloc_no_vg(stream->state_pool,
                                                  block_size, PAGE_SIZE);



More information about the mesa-commit mailing list