anv: Soft-pin batch buffers
Co-authored-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Scott D Phillips <scott.d.phillips@intel.com>
This commit is contained in:

committed by
Jason Ekstrand

parent
a0b133286a
commit
f3dbe0419d
@@ -985,6 +985,7 @@ anv_bo_pool_finish(struct anv_bo_pool *pool)
|
||||
struct bo_pool_bo_link link_copy = VG_NOACCESS_READ(link);
|
||||
|
||||
anv_gem_munmap(link_copy.bo.map, link_copy.bo.size);
|
||||
anv_vma_free(pool->device, &link_copy.bo);
|
||||
anv_gem_close(pool->device, link_copy.bo.gem_handle);
|
||||
link = link_copy.next;
|
||||
}
|
||||
@@ -1024,11 +1025,15 @@ anv_bo_pool_alloc(struct anv_bo_pool *pool, struct anv_bo *bo, uint32_t size)
|
||||
|
||||
new_bo.flags = pool->bo_flags;
|
||||
|
||||
if (!anv_vma_alloc(pool->device, &new_bo))
|
||||
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
|
||||
assert(new_bo.size == pow2_size);
|
||||
|
||||
new_bo.map = anv_gem_mmap(pool->device, new_bo.gem_handle, 0, pow2_size, 0);
|
||||
if (new_bo.map == MAP_FAILED) {
|
||||
anv_gem_close(pool->device, new_bo.gem_handle);
|
||||
anv_vma_free(pool->device, &new_bo);
|
||||
return vk_error(VK_ERROR_MEMORY_MAP_FAILED);
|
||||
}
|
||||
|
||||
|
@@ -429,6 +429,14 @@ anv_batch_bo_link(struct anv_cmd_buffer *cmd_buffer,
|
||||
assert(((*bb_start >> 29) & 0x07) == 0);
|
||||
assert(((*bb_start >> 23) & 0x3f) == 49);
|
||||
|
||||
if (cmd_buffer->device->instance->physicalDevice.use_softpin) {
|
||||
assert(prev_bbo->bo.flags & EXEC_OBJECT_PINNED);
|
||||
assert(next_bbo->bo.flags & EXEC_OBJECT_PINNED);
|
||||
|
||||
write_reloc(cmd_buffer->device,
|
||||
prev_bbo->bo.map + bb_start_offset + 4,
|
||||
next_bbo->bo.offset + next_bbo_offset, true);
|
||||
} else {
|
||||
uint32_t reloc_idx = prev_bbo->relocs.num_relocs - 1;
|
||||
assert(prev_bbo->relocs.relocs[reloc_idx].offset == bb_start_offset + 4);
|
||||
|
||||
@@ -438,6 +446,7 @@ anv_batch_bo_link(struct anv_cmd_buffer *cmd_buffer,
|
||||
/* Use a bogus presumed offset to force a relocation */
|
||||
prev_bbo->relocs.relocs[reloc_idx].presumed_offset = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
anv_batch_bo_destroy(struct anv_batch_bo *bbo,
|
||||
|
@@ -1326,6 +1326,11 @@ anv_device_init_trivial_batch(struct anv_device *device)
|
||||
if (device->instance->physicalDevice.has_exec_async)
|
||||
device->trivial_batch_bo.flags |= EXEC_OBJECT_ASYNC;
|
||||
|
||||
if (device->instance->physicalDevice.use_softpin)
|
||||
device->trivial_batch_bo.flags |= EXEC_OBJECT_PINNED;
|
||||
|
||||
anv_vma_alloc(device, &device->trivial_batch_bo);
|
||||
|
||||
void *map = anv_gem_mmap(device, device->trivial_batch_bo.gem_handle,
|
||||
0, 4096, 0);
|
||||
|
||||
@@ -1607,7 +1612,8 @@ VkResult anv_CreateDevice(
|
||||
uint64_t bo_flags =
|
||||
(physical_device->supports_48bit_addresses ? EXEC_OBJECT_SUPPORTS_48B_ADDRESS : 0) |
|
||||
(physical_device->has_exec_async ? EXEC_OBJECT_ASYNC : 0) |
|
||||
(physical_device->has_exec_capture ? EXEC_OBJECT_CAPTURE : 0);
|
||||
(physical_device->has_exec_capture ? EXEC_OBJECT_CAPTURE : 0) |
|
||||
(physical_device->use_softpin ? EXEC_OBJECT_PINNED : 0);
|
||||
|
||||
anv_bo_pool_init(&device->batch_bo_pool, device, bo_flags);
|
||||
|
||||
@@ -1615,9 +1621,7 @@ VkResult anv_CreateDevice(
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_batch_bo_pool;
|
||||
|
||||
if (physical_device->use_softpin)
|
||||
bo_flags |= EXEC_OBJECT_PINNED;
|
||||
else
|
||||
if (!physical_device->use_softpin)
|
||||
bo_flags &= ~EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
|
||||
|
||||
result = anv_state_pool_init(&device->dynamic_state_pool, device,
|
||||
@@ -1754,6 +1758,7 @@ void anv_DestroyDevice(
|
||||
anv_gem_munmap(device->workaround_bo.map, device->workaround_bo.size);
|
||||
anv_gem_close(device, device->workaround_bo.gem_handle);
|
||||
|
||||
anv_vma_free(device, &device->trivial_batch_bo);
|
||||
anv_gem_close(device, device->trivial_batch_bo.gem_handle);
|
||||
if (device->info.gen >= 10)
|
||||
anv_gem_close(device, device->hiz_clear_bo.gem_handle);
|
||||
|
@@ -81,7 +81,7 @@ anv_device_submit_simple_batch(struct anv_device *device,
|
||||
exec2_objects[0].relocs_ptr = 0;
|
||||
exec2_objects[0].alignment = 0;
|
||||
exec2_objects[0].offset = bo.offset;
|
||||
exec2_objects[0].flags = 0;
|
||||
exec2_objects[0].flags = bo.flags;
|
||||
exec2_objects[0].rsvd1 = 0;
|
||||
exec2_objects[0].rsvd2 = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user