radv/winsys: Fix radv_amdgpu_cs_grow min_size argument. (v2)
authorGustaw Smolarczyk <wielkiegie@gmail.com>
Thu, 6 Oct 2016 17:50:47 +0000 (19:50 +0200)
committerDave Airlie <airlied@redhat.com>
Tue, 11 Oct 2016 23:06:30 +0000 (09:06 +1000)
It's supposed to be how much at least we want to grow the cs, not the
minimum size of the cs after growth.

v2: Unbreak use_ib_bos.
    Don't mask the ib_size when !use_ib_bos, since it's not needed.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c

index 330b59b174a7aa7b1d6963ac5afa944a556d0c62..41dfcd323e246abac631c0c115198997b4a7ddce 100644 (file)
@@ -180,10 +180,6 @@ radv_amdgpu_cs_create(struct radeon_winsys *ws,
 static void radv_amdgpu_cs_grow(struct radeon_winsys_cs *_cs, size_t min_size)
 {
        struct radv_amdgpu_cs *cs = radv_amdgpu_cs(_cs);
-       uint64_t ib_size = MAX2(min_size * 4 + 16, cs->base.max_dw * 4 * 2);
-
-       /* max that fits in the chain size field. */
-       ib_size = MIN2(ib_size, 0xfffff);
 
        if (cs->failed) {
                cs->base.cdw = 0;
@@ -191,6 +187,8 @@ 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);
                if (new_buf) {
                        cs->base.buf = new_buf;
@@ -202,6 +200,11 @@ static void radv_amdgpu_cs_grow(struct radeon_winsys_cs *_cs, size_t min_size)
                return;
        }
 
+       uint64_t ib_size = MAX2(min_size * 4 + 16, cs->base.max_dw * 4 * 2);
+
+       /* max that fits in the chain size field. */
+       ib_size = MIN2(ib_size, 0xfffff);
+
        while (!cs->base.cdw || (cs->base.cdw & 7) != 4)
                cs->base.buf[cs->base.cdw++] = 0xffff1000;