#include "anv_private.h"
-#include "genxml/gen7_pack.h"
#include "genxml/gen8_pack.h"
#include "util/debug.h"
return VK_SUCCESS;
}
-uint64_t
+VkResult
anv_reloc_list_add(struct anv_reloc_list *list,
const VkAllocationCallbacks *alloc,
uint32_t offset, struct anv_bo *target_bo, uint32_t delta)
const uint32_t domain =
target_bo->is_winsys_bo ? I915_GEM_DOMAIN_RENDER : 0;
- anv_reloc_list_grow(list, alloc, 1);
- /* TODO: Handle failure */
+ VkResult result = anv_reloc_list_grow(list, alloc, 1);
+ if (result != VK_SUCCESS)
+ return result;
/* XXX: Can we use I915_EXEC_HANDLE_LUT? */
index = list->num_relocs++;
entry->write_domain = domain;
VG(VALGRIND_CHECK_MEM_IS_DEFINED(entry, sizeof(*entry)));
- return target_bo->offset + delta;
+ return VK_SUCCESS;
}
-static void
+static VkResult
anv_reloc_list_append(struct anv_reloc_list *list,
const VkAllocationCallbacks *alloc,
struct anv_reloc_list *other, uint32_t offset)
{
- anv_reloc_list_grow(list, alloc, other->num_relocs);
- /* TODO: Handle failure */
+ VkResult result = anv_reloc_list_grow(list, alloc, other->num_relocs);
+ if (result != VK_SUCCESS)
+ return result;
memcpy(&list->relocs[list->num_relocs], &other->relocs[0],
other->num_relocs * sizeof(other->relocs[0]));
list->relocs[i + list->num_relocs].offset += offset;
list->num_relocs += other->num_relocs;
+ return VK_SUCCESS;
}
/*-----------------------------------------------------------------------*
void *
anv_batch_emit_dwords(struct anv_batch *batch, int num_dwords)
{
- if (batch->next + num_dwords * 4 > batch->end)
- batch->extend_cb(batch, batch->user_data);
+ if (batch->next + num_dwords * 4 > batch->end) {
+ VkResult result = batch->extend_cb(batch, batch->user_data);
+ if (result != VK_SUCCESS) {
+ anv_batch_set_error(batch, result);
+ return NULL;
+ }
+ }
void *p = batch->next;
anv_batch_emit_reloc(struct anv_batch *batch,
void *location, struct anv_bo *bo, uint32_t delta)
{
- return anv_reloc_list_add(batch->relocs, batch->alloc,
- location - batch->start, bo, delta);
+ VkResult result = anv_reloc_list_add(batch->relocs, batch->alloc,
+ location - batch->start, bo, delta);
+ if (result != VK_SUCCESS) {
+ anv_batch_set_error(batch, result);
+ return 0;
+ }
+
+ return bo->offset + delta;
}
void
size = other->next - other->start;
assert(size % 4 == 0);
- if (batch->next + size > batch->end)
- batch->extend_cb(batch, batch->user_data);
+ if (batch->next + size > batch->end) {
+ VkResult result = batch->extend_cb(batch, batch->user_data);
+ if (result != VK_SUCCESS) {
+ anv_batch_set_error(batch, result);
+ return;
+ }
+ }
assert(batch->next + size <= batch->end);
memcpy(batch->next, other->start, size);
offset = batch->next - batch->start;
- anv_reloc_list_append(batch->relocs, batch->alloc,
- other->relocs, offset);
+ VkResult result = anv_reloc_list_append(batch->relocs, batch->alloc,
+ other->relocs, offset);
+ if (result != VK_SUCCESS) {
+ anv_batch_set_error(batch, result);
+ return;
+ }
batch->next += size;
}
* gens.
*/
+#define GEN7_MI_BATCH_BUFFER_START_length 2
+#define GEN7_MI_BATCH_BUFFER_START_length_bias 2
+
const uint32_t gen7_length =
GEN7_MI_BATCH_BUFFER_START_length - GEN7_MI_BATCH_BUFFER_START_length_bias;
const uint32_t gen8_length =
&cmd_buffer->device->surface_state_block_pool;
int32_t *offset = u_vector_add(&cmd_buffer->bt_blocks);
- if (offset == NULL)
+ if (offset == NULL) {
+ anv_batch_set_error(&cmd_buffer->batch, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ }
*offset = anv_block_pool_alloc_back(block_pool);
cmd_buffer->bt_next = 0;
goto fail_bt_blocks;
cmd_buffer->last_ss_pool_center = 0;
- anv_cmd_buffer_new_binding_table_block(cmd_buffer);
+ result = anv_cmd_buffer_new_binding_table_block(cmd_buffer);
+ if (result != VK_SUCCESS)
+ goto fail_bt_blocks;
return VK_SUCCESS;
cmd_buffer->batch.end += GEN8_MI_BATCH_BUFFER_START_length * 4;
assert(cmd_buffer->batch.end == batch_bo->bo.map + batch_bo->bo.size);
- anv_batch_emit(&cmd_buffer->batch, GEN7_MI_BATCH_BUFFER_END, bbe);
+ anv_batch_emit(&cmd_buffer->batch, GEN8_MI_BATCH_BUFFER_END, bbe);
/* Round batch up to an even number of dwords. */
if ((cmd_buffer->batch.next - cmd_buffer->batch.start) & 4)
- anv_batch_emit(&cmd_buffer->batch, GEN7_MI_NOOP, noop);
+ anv_batch_emit(&cmd_buffer->batch, GEN8_MI_NOOP, noop);
cmd_buffer->exec_mode = ANV_CMD_BUFFER_EXEC_MODE_PRIMARY;
}
}
if (flush && !device->info.has_llc)
- anv_clflush_range(p, reloc_size);
+ anv_flush_range(p, reloc_size);
}
static void
adjust_relocations_from_state_pool(ss_pool, &cmd_buffer->surface_relocs,
cmd_buffer->last_ss_pool_center);
- anv_execbuf_add_bo(&execbuf, &ss_pool->bo, &cmd_buffer->surface_relocs,
- &cmd_buffer->pool->alloc);
+ VkResult result =
+ anv_execbuf_add_bo(&execbuf, &ss_pool->bo, &cmd_buffer->surface_relocs,
+ &cmd_buffer->pool->alloc);
+ if (result != VK_SUCCESS)
+ return result;
/* First, we walk over all of the bos we've seen and add them and their
* relocations to the validate list.
cmd_buffer->surface_relocs.relocs[i].presumed_offset = -1;
}
- VkResult result = anv_device_execbuf(device, &execbuf.execbuf, execbuf.bos);
+ result = anv_device_execbuf(device, &execbuf.execbuf, execbuf.bos);
anv_execbuf_finish(&execbuf, &cmd_buffer->pool->alloc);