radv/winsys: fix padding command stream for SI
authorDave Airlie <airlied@redhat.com>
Wed, 26 Jul 2017 02:25:24 +0000 (03:25 +0100)
committerDave Airlie <airlied@redhat.com>
Wed, 26 Jul 2017 22:38:23 +0000 (23:38 +0100)
We were adding pad to size after creating the object, so we could
submit a CS bigger than the bo created for it.

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 0d89b950d2e11d075b926d10110c51441341d307..ad4b0b3f9dc28c8418ebcb17ab67859d1233d7f4 100644 (file)
@@ -841,7 +841,7 @@ static int radv_amdgpu_winsys_cs_submit_sysmem(struct radeon_winsys_ctx *_ctx,
                uint32_t *ptr;
                unsigned cnt = 0;
                unsigned size = 0;
-
+               unsigned pad_words = 0;
                if (preamble_cs)
                        size += preamble_cs->cdw;
 
@@ -850,6 +850,10 @@ static int radv_amdgpu_winsys_cs_submit_sysmem(struct radeon_winsys_ctx *_ctx,
                        ++cnt;
                }
 
+               while(!size || (size & 7)) {
+                       size++;
+                       pad_words++;
+               }
                assert(cnt);
 
                bo = ws->buffer_create(ws, 4 * size, 4096, RADEON_DOMAIN_GTT, RADEON_FLAG_CPU_ACCESS);
@@ -867,10 +871,8 @@ static int radv_amdgpu_winsys_cs_submit_sysmem(struct radeon_winsys_ctx *_ctx,
 
                }
 
-               while(!size || (size & 7)) {
+               for (unsigned j = 0; j < pad_words; ++j)
                        *ptr++ = pad_word;
-                       ++size;
-               }
 
                memset(&request, 0, sizeof(request));