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

Author: Gustaw Smolarczyk <wielkie...@gmail.com>
Date:   Thu Oct 13 22:54:12 2016 +0200

radv/winsys: Fail early on overgrown cs.

When !use_ib_bos, we can't easily chain ibs one to another. If the
required cs size grows over 1Mi - 8 dwords just fail the cs so that we
won't assert-fail in radv_amdgpu_winsys_cs_submit later on.

Reviewed-by: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>

---

 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c 
b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
index 41dfcd3..b8558fa 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
@@ -187,12 +187,22 @@ static void radv_amdgpu_cs_grow(struct radeon_winsys_cs 
*_cs, size_t min_size)
        }
 
        if (!cs->ws->use_ib_bos) {
-               uint64_t ib_size = MAX2((cs->base.cdw + min_size) * 4 + 16,
-                                       cs->base.max_dw * 4 * 2);
-               uint32_t *new_buf = realloc(cs->base.buf, ib_size);
+               const uint64_t limit_dws = 0xffff8;
+               uint64_t ib_dws = MAX2(cs->base.cdw + min_size,
+                                      MIN2(cs->base.max_dw * 2, limit_dws));
+
+               /* The total ib size cannot exceed limit_dws dwords. */
+               if (ib_dws > limit_dws)
+               {
+                       cs->failed = true;
+                       cs->base.cdw = 0;
+                       return;
+               }
+
+               uint32_t *new_buf = realloc(cs->base.buf, ib_dws * 4);
                if (new_buf) {
                        cs->base.buf = new_buf;
-                       cs->base.max_dw = ib_size / 4;
+                       cs->base.max_dw = ib_dws;
                } else {
                        cs->failed = true;
                        cs->base.cdw = 0;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to