radeonsi: handle constant buffer alloc failures
authorMarek Olšák <marek.olsak@amd.com>
Thu, 10 Sep 2015 15:42:31 +0000 (17:42 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 24 Sep 2015 17:51:42 +0000 (19:51 +0200)
Cc: 11.0 <mesa-stable@lists.freedesktop.org>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_descriptors.c

index 92a7068e7159340c2b13ff45e4d177b05326abba..b07ab3b94acaee00fef45ef724108592ff1aec3a 100644 (file)
@@ -472,7 +472,8 @@ void si_upload_const_buffer(struct si_context *sctx, struct r600_resource **rbuf
 
        u_upload_alloc(sctx->b.uploader, 0, size, const_offset,
                       (struct pipe_resource**)rbuffer, &tmp);
-       util_memcpy_cpu_to_le32(tmp, ptr, size);
+       if (rbuffer)
+               util_memcpy_cpu_to_le32(tmp, ptr, size);
 }
 
 static void si_set_constant_buffer(struct pipe_context *ctx, uint shader, uint slot,
@@ -504,6 +505,11 @@ static void si_set_constant_buffer(struct pipe_context *ctx, uint shader, uint s
                        si_upload_const_buffer(sctx,
                                               (struct r600_resource**)&buffer, input->user_buffer,
                                               input->buffer_size, &buffer_offset);
+                       if (!buffer) {
+                               /* Just unbind on failure. */
+                               si_set_constant_buffer(ctx, shader, slot, NULL);
+                               return;
+                       }
                        va = r600_resource(buffer)->gpu_address + buffer_offset;
                } else {
                        pipe_resource_reference(&buffer, input->buffer);