radv: do not update vertex descriptors if the allocation failed
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 6 Sep 2017 15:25:27 +0000 (17:25 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 8 Sep 2017 14:04:51 +0000 (16:04 +0200)
A return code error is stored in the command buffer and should
be returned to the user via EndCommandBuffer().

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c

index b5da9f6785e4ad7df12c45927fc14f87a85b6623..406399fb3578fdd60705cc9fe2bb38d94ea51cdc 100644 (file)
@@ -1578,7 +1578,7 @@ static void radv_emit_primitive_reset_state(struct radv_cmd_buffer *cmd_buffer,
        }
 }
 
-static void
+static bool
 radv_cmd_buffer_update_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer)
 {
        struct radv_device *device = cmd_buffer->device;
@@ -1594,8 +1594,9 @@ radv_cmd_buffer_update_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer)
                uint64_t va;
 
                /* allocate some descriptor state for vertex buffers */
-               radv_cmd_buffer_upload_alloc(cmd_buffer, count * 16, 256,
-                                            &vb_offset, &vb_ptr);
+               if (!radv_cmd_buffer_upload_alloc(cmd_buffer, count * 16, 256,
+                                                 &vb_offset, &vb_ptr))
+                       return false;
 
                for (i = 0; i < count; i++) {
                        uint32_t *desc = &((uint32_t *)vb_ptr)[i * 4];
@@ -1625,6 +1626,8 @@ radv_cmd_buffer_update_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer)
                                           AC_UD_VS_VERTEX_BUFFERS, va);
        }
        cmd_buffer->state.vb_dirty = false;
+
+       return true;
 }
 
 static void
@@ -1639,7 +1642,8 @@ radv_cmd_buffer_flush_state(struct radv_cmd_buffer *cmd_buffer,
        MAYBE_UNUSED unsigned cdw_max = radeon_check_space(cmd_buffer->device->ws,
                                                           cmd_buffer->cs, 4096);
 
-       radv_cmd_buffer_update_vertex_descriptors(cmd_buffer);
+       if (!radv_cmd_buffer_update_vertex_descriptors(cmd_buffer))
+               return;
 
        if (cmd_buffer->state.dirty & RADV_CMD_DIRTY_PIPELINE)
                radv_emit_graphics_pipeline(cmd_buffer, pipeline);