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

Author: Marek Olšák <[email protected]>
Date:   Sun Mar 28 06:49:55 2021 -0400

winsys/amdgpu: remove another 8 bytes from amdgpu_winsys_bo by packing better

Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9809>

---

 src/gallium/winsys/amdgpu/drm/amdgpu_bo.h | 6 +++---
 src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 7 +++++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
index 895d4fb7b5e..48bce54ec2f 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
@@ -93,9 +93,9 @@ struct amdgpu_winsys_bo {
    } u;
 
    amdgpu_bo_handle bo; /* NULL for slab entries and sparse buffers */
+   uint64_t va;
 
    uint32_t unique_id;
-   uint64_t va;
    simple_mtx_t lock;
 
    /* how many command streams, which are being emitted in a separate
@@ -103,8 +103,8 @@ struct amdgpu_winsys_bo {
    volatile int num_active_ioctls;
 
    /* Fences for buffer synchronization. */
-   unsigned num_fences;
-   unsigned max_fences;
+   uint16_t num_fences;
+   uint16_t max_fences;
    struct pipe_fence_handle **fences;
 
    struct pb_cache_entry cache_entry[];
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
index bde2508847f..008894043a3 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
@@ -1334,13 +1334,16 @@ void amdgpu_add_fences(struct amdgpu_winsys_bo *bo,
          REALLOC(bo->fences,
                  bo->num_fences * sizeof(*new_fences),
                  new_max_fences * sizeof(*new_fences));
-      if (likely(new_fences)) {
+      if (likely(new_fences && new_max_fences < UINT16_MAX)) {
          bo->fences = new_fences;
          bo->max_fences = new_max_fences;
       } else {
          unsigned drop;
 
-         fprintf(stderr, "amdgpu_add_fences: allocation failure, dropping 
fence(s)\n");
+         fprintf(stderr, new_fences ? "amdgpu_add_fences: too many fences, 
dropping some\n"
+                                    : "amdgpu_add_fences: allocation failure, 
dropping fence(s)\n");
+         free(new_fences);
+
          if (!bo->num_fences)
             return;
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to