anv: Delete use_relocations flag

There are no relocations.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18208>
This commit is contained in:
Kenneth Graunke 2022-08-30 15:12:27 -07:00 committed by Marge Bot
parent 97b98dcea9
commit 215b1b69cb
5 changed files with 94 additions and 221 deletions

View file

@ -454,23 +454,12 @@ anv_batch_bo_link(struct anv_cmd_buffer *cmd_buffer,
assert(((*bb_start >> 29) & 0x07) == 0);
assert(((*bb_start >> 23) & 0x3f) == 49);
if (anv_use_relocations(cmd_buffer->device->physical)) {
uint32_t reloc_idx = prev_bbo->relocs.num_relocs - 1;
assert(prev_bbo->relocs.relocs[reloc_idx].offset == bb_start_offset + 4);
assert(anv_bo_is_pinned(prev_bbo->bo));
assert(anv_bo_is_pinned(next_bbo->bo));
prev_bbo->relocs.reloc_bos[reloc_idx] = next_bbo->bo;
prev_bbo->relocs.relocs[reloc_idx].delta = next_bbo_offset;
/* Use a bogus presumed offset to force a relocation */
prev_bbo->relocs.relocs[reloc_idx].presumed_offset = -1;
} else {
assert(anv_bo_is_pinned(prev_bbo->bo));
assert(anv_bo_is_pinned(next_bbo->bo));
write_reloc(cmd_buffer->device,
prev_bbo->bo->map + bb_start_offset + 4,
next_bbo->bo->offset + next_bbo_offset, true);
}
write_reloc(cmd_buffer->device,
prev_bbo->bo->map + bb_start_offset + 4,
next_bbo->bo->offset + next_bbo_offset, true);
}
static void
@ -528,7 +517,7 @@ anv_cmd_buffer_current_batch_bo(struct anv_cmd_buffer *cmd_buffer)
struct anv_address
anv_cmd_buffer_surface_base_address(struct anv_cmd_buffer *cmd_buffer)
{
struct anv_state_pool *pool = anv_binding_table_pool(cmd_buffer->device);
struct anv_state_pool *pool = &cmd_buffer->device->binding_table_pool;
struct anv_state *bt_block = u_vector_head(&cmd_buffer->bt_block_states);
return (struct anv_address) {
.bo = pool->block_pool.bo,
@ -589,8 +578,6 @@ static void
anv_cmd_buffer_record_chain_submit(struct anv_cmd_buffer *cmd_buffer_from,
struct anv_cmd_buffer *cmd_buffer_to)
{
assert(!anv_use_relocations(cmd_buffer_from->device->physical));
uint32_t *bb_start = cmd_buffer_from->batch_end;
struct anv_batch_bo *last_bbo =
@ -619,8 +606,6 @@ anv_cmd_buffer_record_chain_submit(struct anv_cmd_buffer *cmd_buffer_from,
static void
anv_cmd_buffer_record_end_submit(struct anv_cmd_buffer *cmd_buffer)
{
assert(!anv_use_relocations(cmd_buffer->device->physical));
struct anv_batch_bo *last_bbo =
list_last_entry(&cmd_buffer->batch_bos, struct anv_batch_bo, link);
last_bbo->chained = false;
@ -1557,23 +1542,10 @@ setup_execbuf_for_cmd_buffer(struct anv_execbuf *execbuf,
&cmd_buffer->device->surface_state_pool;
VkResult result;
if (anv_use_relocations(cmd_buffer->device->physical)) {
/* Since we aren't in the softpin case, all of our STATE_BASE_ADDRESS BOs
* will get added automatically by processing relocations on the batch
* buffer. We have to add the surface state BO manually because it has
* relocations of its own that we need to be sure are processed.
*/
result = anv_execbuf_add_bo(cmd_buffer->device, execbuf,
ss_pool->block_pool.bo,
&cmd_buffer->surface_relocs, 0);
if (result != VK_SUCCESS)
return result;
} else {
/* Add surface dependencies (BOs) to the execbuf */
anv_execbuf_add_bo_bitset(cmd_buffer->device, execbuf,
cmd_buffer->surface_relocs.dep_words,
cmd_buffer->surface_relocs.deps, 0);
}
/* Add surface dependencies (BOs) to the execbuf */
anv_execbuf_add_bo_bitset(cmd_buffer->device, execbuf,
cmd_buffer->surface_relocs.dep_words,
cmd_buffer->surface_relocs.deps, 0);
/* First, we walk over all of the bos we've seen and add them and their
* relocations to the validate list.
@ -1629,56 +1601,49 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf,
}
/* Add all the global BOs to the object list for softpin case. */
if (!anv_use_relocations(device->physical)) {
anv_block_pool_foreach_bo(bo, &ss_pool->block_pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
anv_block_pool_foreach_bo(bo, &ss_pool->block_pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
struct anv_block_pool *pool;
pool = &device->dynamic_state_pool.block_pool;
anv_block_pool_foreach_bo(bo, pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
struct anv_block_pool *pool;
pool = &device->dynamic_state_pool.block_pool;
anv_block_pool_foreach_bo(bo, pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
pool = &device->general_state_pool.block_pool;
anv_block_pool_foreach_bo(bo, pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
pool = &device->general_state_pool.block_pool;
anv_block_pool_foreach_bo(bo, pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
pool = &device->instruction_state_pool.block_pool;
anv_block_pool_foreach_bo(bo, pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
pool = &device->instruction_state_pool.block_pool;
anv_block_pool_foreach_bo(bo, pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
pool = &device->binding_table_pool.block_pool;
anv_block_pool_foreach_bo(bo, pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
pool = &device->binding_table_pool.block_pool;
anv_block_pool_foreach_bo(bo, pool) {
result = anv_execbuf_add_bo(device, execbuf, bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
/* Add the BOs for all user allocated memory objects because we can't
* track after binding updates of VK_EXT_descriptor_indexing.
*/
list_for_each_entry(struct anv_device_memory, mem,
&device->memory_objects, link) {
result = anv_execbuf_add_bo(device, execbuf, mem->bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
} else {
/* We do not support chaining primary command buffers without
* softpin.
*/
assert(num_cmd_buffers == 1);
/* Add the BOs for all user allocated memory objects because we can't
* track after binding updates of VK_EXT_descriptor_indexing.
*/
list_for_each_entry(struct anv_device_memory, mem,
&device->memory_objects, link) {
result = anv_execbuf_add_bo(device, execbuf, mem->bo, NULL, 0);
if (result != VK_SUCCESS)
return result;
}
bool no_reloc = true;
@ -1757,8 +1722,7 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf,
}
/* If we are pinning our BOs, we shouldn't have to relocate anything */
if (!anv_use_relocations(device->physical))
assert(!execbuf->has_relocs);
assert(!execbuf->has_relocs);
/* Now we go through and fixup all of the relocation lists to point to the
* correct indices in the object array (I915_EXEC_HANDLE_LUT). We have to

View file

@ -219,7 +219,7 @@ get_device_extensions(const struct anv_physical_device *device,
.KHR_maintenance4 = true,
.KHR_multiview = true,
.KHR_performance_query =
!anv_use_relocations(device) && device->perf &&
device->perf &&
(device->perf->i915_perf_version >= 3 ||
INTEL_DEBUG(DEBUG_NO_OACONFIG)) &&
device->use_call_secondary,
@ -827,10 +827,7 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
goto fail_base;
}
device->use_relocations = false;
if (!device->use_relocations &&
!anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_SOFTPIN)) {
if (!anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_SOFTPIN)) {
result = vk_errorf(device, VK_ERROR_INITIALIZATION_FAILED,
"kernel missing softpin");
goto fail_alloc;
@ -871,8 +868,7 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
if (result != VK_SUCCESS)
goto fail_base;
assert(device->supports_48bit_addresses == !device->use_relocations);
device->use_softpin = !device->use_relocations;
device->use_softpin = true;
device->has_context_isolation =
anv_gem_get_param(fd, I915_PARAM_HAS_CONTEXT_ISOLATION);
@ -3127,28 +3123,26 @@ VkResult anv_CreateDevice(
}
}
if (!anv_use_relocations(physical_device)) {
if (pthread_mutex_init(&device->vma_mutex, NULL) != 0) {
result = vk_error(device, VK_ERROR_INITIALIZATION_FAILED);
goto fail_queues;
}
/* keep the page with address zero out of the allocator */
util_vma_heap_init(&device->vma_lo,
LOW_HEAP_MIN_ADDRESS, LOW_HEAP_SIZE);
util_vma_heap_init(&device->vma_cva, CLIENT_VISIBLE_HEAP_MIN_ADDRESS,
CLIENT_VISIBLE_HEAP_SIZE);
/* Leave the last 4GiB out of the high vma range, so that no state
* base address + size can overflow 48 bits. For more information see
* the comment about Wa32bitGeneralStateOffset in anv_allocator.c
*/
util_vma_heap_init(&device->vma_hi, HIGH_HEAP_MIN_ADDRESS,
physical_device->gtt_size - (1ull << 32) -
HIGH_HEAP_MIN_ADDRESS);
if (pthread_mutex_init(&device->vma_mutex, NULL) != 0) {
result = vk_error(device, VK_ERROR_INITIALIZATION_FAILED);
goto fail_queues;
}
/* keep the page with address zero out of the allocator */
util_vma_heap_init(&device->vma_lo,
LOW_HEAP_MIN_ADDRESS, LOW_HEAP_SIZE);
util_vma_heap_init(&device->vma_cva, CLIENT_VISIBLE_HEAP_MIN_ADDRESS,
CLIENT_VISIBLE_HEAP_SIZE);
/* Leave the last 4GiB out of the high vma range, so that no state
* base address + size can overflow 48 bits. For more information see
* the comment about Wa32bitGeneralStateOffset in anv_allocator.c
*/
util_vma_heap_init(&device->vma_hi, HIGH_HEAP_MIN_ADDRESS,
physical_device->gtt_size - (1ull << 32) -
HIGH_HEAP_MIN_ADDRESS);
list_inithead(&device->memory_objects);
device->robust_buffer_access = robust_buffer_access;
@ -3228,7 +3222,7 @@ VkResult anv_CreateDevice(
"binding table pool",
BINDING_TABLE_POOL_MIN_ADDRESS, 0,
BINDING_TABLE_POOL_BLOCK_SIZE);
} else if (!anv_use_relocations(physical_device)) {
} else {
int64_t bt_pool_offset = (int64_t)BINDING_TABLE_POOL_MIN_ADDRESS -
(int64_t)SURFACE_STATE_POOL_MIN_ADDRESS;
assert(INT32_MIN < bt_pool_offset && bt_pool_offset < 0);
@ -3387,8 +3381,7 @@ VkResult anv_CreateDevice(
device->aux_map_ctx = NULL;
}
fail_binding_table_pool:
if (!anv_use_relocations(physical_device))
anv_state_pool_finish(&device->binding_table_pool);
anv_state_pool_finish(&device->binding_table_pool);
fail_surface_state_pool:
anv_state_pool_finish(&device->surface_state_pool);
fail_instruction_state_pool:
@ -3406,11 +3399,9 @@ VkResult anv_CreateDevice(
fail_mutex:
pthread_mutex_destroy(&device->mutex);
fail_vmas:
if (!anv_use_relocations(physical_device)) {
util_vma_heap_finish(&device->vma_hi);
util_vma_heap_finish(&device->vma_cva);
util_vma_heap_finish(&device->vma_lo);
}
util_vma_heap_finish(&device->vma_hi);
util_vma_heap_finish(&device->vma_cva);
util_vma_heap_finish(&device->vma_lo);
fail_queues:
for (uint32_t i = 0; i < device->queue_count; i++)
anv_queue_finish(&device->queues[i]);
@ -3477,8 +3468,7 @@ void anv_DestroyDevice(
device->aux_map_ctx = NULL;
}
if (!anv_use_relocations(device->physical))
anv_state_pool_finish(&device->binding_table_pool);
anv_state_pool_finish(&device->binding_table_pool);
anv_state_pool_finish(&device->surface_state_pool);
anv_state_pool_finish(&device->instruction_state_pool);
anv_state_pool_finish(&device->dynamic_state_pool);
@ -3488,11 +3478,9 @@ void anv_DestroyDevice(
anv_bo_cache_finish(&device->bo_cache);
if (!anv_use_relocations(device->physical)) {
util_vma_heap_finish(&device->vma_hi);
util_vma_heap_finish(&device->vma_cva);
util_vma_heap_finish(&device->vma_lo);
}
util_vma_heap_finish(&device->vma_hi);
util_vma_heap_finish(&device->vma_cva);
util_vma_heap_finish(&device->vma_lo);
pthread_cond_destroy(&device->queue_submit);
pthread_mutex_destroy(&device->mutex);

View file

@ -962,7 +962,6 @@ struct anv_physical_device {
bool has_userptr_probe;
uint64_t gtt_size;
bool use_relocations;
bool use_softpin;
bool always_use_bindless;
bool use_call_secondary;
@ -1231,47 +1230,17 @@ struct anv_device {
#define ANV_ALWAYS_SOFTPIN false
#endif
static inline bool
anv_use_relocations(const struct anv_physical_device *pdevice)
{
#if defined(GFX_VERx10) && GFX_VERx10 >= 90
/* Sky Lake and later always uses softpin */
assert(!pdevice->use_relocations);
return false;
#elif defined(GFX_VERx10) && GFX_VERx10 < 80
/* Haswell and earlier never use softpin */
assert(pdevice->use_relocations);
return true;
#else
/* If we don't have a GFX_VERx10 #define, we need to look at the physical
* device. Also, for GFX version 8, we need to look at the physical
* device because Broadwell softpins but Cherryview doesn't.
*/
return pdevice->use_relocations;
#endif
}
static inline struct anv_state_pool *
anv_binding_table_pool(struct anv_device *device)
{
if (anv_use_relocations(device->physical))
return &device->surface_state_pool;
else
return &device->binding_table_pool;
}
static inline struct anv_state
anv_binding_table_pool_alloc(struct anv_device *device)
{
assert(!anv_use_relocations(device->physical));
return anv_state_pool_alloc(&device->binding_table_pool,
device->binding_table_pool.block_size, 0);
}
static inline void
anv_binding_table_pool_free(struct anv_device *device, struct anv_state state) {
anv_state_pool_free(anv_binding_table_pool(device), state);
anv_binding_table_pool_free(struct anv_device *device, struct anv_state state)
{
anv_state_pool_free(&device->binding_table_pool, state);
}
static inline uint32_t
@ -2821,8 +2790,8 @@ struct anv_cmd_buffer {
static inline bool
anv_cmd_buffer_is_chainable(struct anv_cmd_buffer *cmd_buffer)
{
return !anv_use_relocations(cmd_buffer->device->physical) &&
!(cmd_buffer->usage_flags & VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT);
return !(cmd_buffer->usage_flags &
VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT);
}
VkResult anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer);

View file

@ -175,22 +175,10 @@ genX(cmd_buffer_emit_state_base_address)(struct anv_cmd_buffer *cmd_buffer)
sba.InstructionMOCS = mocs;
sba.InstructionBaseAddressModifyEnable = true;
/* Broadwell requires that we specify a buffer size for a bunch of
* these fields. However, since we will be growing the BO's live, we
* just set them all to the maximum.
*/
sba.GeneralStateBufferSize = 0xfffff;
sba.IndirectObjectBufferSize = 0xfffff;
if (anv_use_relocations(device->physical)) {
sba.DynamicStateBufferSize = 0xfffff;
sba.InstructionBufferSize = 0xfffff;
} else {
/* With softpin, we use fixed addresses so we actually know how big
* our base addresses are.
*/
sba.DynamicStateBufferSize = DYNAMIC_STATE_POOL_SIZE / 4096;
sba.InstructionBufferSize = INSTRUCTION_STATE_POOL_SIZE / 4096;
}
sba.DynamicStateBufferSize = DYNAMIC_STATE_POOL_SIZE / 4096;
sba.InstructionBufferSize = INSTRUCTION_STATE_POOL_SIZE / 4096;
sba.GeneralStateBufferSizeModifyEnable = true;
sba.IndirectObjectBufferSizeModifyEnable = true;
sba.DynamicStateBufferSizeModifyEnable = true;
@ -280,19 +268,9 @@ static void
add_surface_reloc(struct anv_cmd_buffer *cmd_buffer,
struct anv_state state, struct anv_address addr)
{
VkResult result;
if (anv_use_relocations(cmd_buffer->device->physical)) {
const struct isl_device *isl_dev = &cmd_buffer->device->isl_dev;
result = anv_reloc_list_add(&cmd_buffer->surface_relocs,
&cmd_buffer->vk.pool->alloc,
state.offset + isl_dev->ss.addr_offset,
addr.bo, addr.offset, NULL);
} else {
result = anv_reloc_list_add_bo(&cmd_buffer->surface_relocs,
&cmd_buffer->vk.pool->alloc,
addr.bo);
}
VkResult result = anv_reloc_list_add_bo(&cmd_buffer->surface_relocs,
&cmd_buffer->vk.pool->alloc,
addr.bo);
if (unlikely(result != VK_SUCCESS))
anv_batch_set_error(&cmd_buffer->batch, result);
@ -554,7 +532,6 @@ anv_image_init_aux_tt(struct anv_cmd_buffer *cmd_buffer,
aux_entry_map = intel_aux_map_get_entry(cmd_buffer->device->aux_map_ctx,
address, &aux_entry_addr64);
assert(!anv_use_relocations(cmd_buffer->device->physical));
struct anv_address aux_entry_address = {
.bo = NULL,
.offset = aux_entry_addr64,
@ -2324,11 +2301,8 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
if (bt_state->map == NULL)
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
/* We only need to emit relocs if we're not using softpin. If we are using
* softpin then we always keep all user-allocated memory objects resident.
*/
const bool need_client_mem_relocs =
anv_use_relocations(cmd_buffer->device->physical);
/* Note that we always keep all user-allocated memory objects resident. */
struct anv_push_constants *push = &pipe_state->push_constants;
for (uint32_t s = 0; s < map->surface_count; s++) {
@ -2373,10 +2347,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
assert(surface_state.map);
bt_map[s] = surface_state.offset + state_offset;
if (need_client_mem_relocs) {
add_surface_reloc(cmd_buffer, surface_state,
cmd_buffer->state.compute.num_workgroups);
}
break;
}
@ -2432,8 +2402,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
desc->image_view->planes[binding->plane].optimal_sampler_surface_state;
surface_state = sstate.state;
assert(surface_state.alloc_size);
if (need_client_mem_relocs)
add_surface_state_relocs(cmd_buffer, sstate);
} else {
surface_state = cmd_buffer->device->null_surface_state;
}
@ -2462,8 +2430,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
"set and the image does not have a "
"corresponding SPIR-V format enum.");
}
if (surface_state.offset && need_client_mem_relocs)
add_surface_state_relocs(cmd_buffer, sstate);
} else {
surface_state = cmd_buffer->device->null_surface_state;
}
@ -2475,10 +2441,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
if (desc->set_buffer_view) {
surface_state = desc->set_buffer_view->surface_state;
assert(surface_state.alloc_size);
if (need_client_mem_relocs) {
add_surface_reloc(cmd_buffer, surface_state,
desc->set_buffer_view->address);
}
} else {
surface_state = cmd_buffer->device->null_surface_state;
}
@ -2488,10 +2450,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
if (desc->buffer_view) {
surface_state = desc->buffer_view->surface_state;
assert(surface_state.alloc_size);
if (need_client_mem_relocs) {
add_surface_reloc(cmd_buffer, surface_state,
desc->buffer_view->address);
}
} else {
surface_state = cmd_buffer->device->null_surface_state;
}
@ -2530,8 +2488,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
format, ISL_SWIZZLE_IDENTITY,
usage, address, range, 1);
if (need_client_mem_relocs)
add_surface_reloc(cmd_buffer, surface_state, address);
} else {
surface_state = cmd_buffer->device->null_surface_state;
}
@ -2544,10 +2500,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
? desc->buffer_view->lowered_storage_surface_state
: desc->buffer_view->storage_surface_state;
assert(surface_state.alloc_size);
if (need_client_mem_relocs) {
add_surface_reloc(cmd_buffer, surface_state,
desc->buffer_view->address);
}
} else {
surface_state = cmd_buffer->device->null_surface_state;
}
@ -5581,7 +5533,7 @@ genX(cmd_buffer_set_binding_for_gfx8_vb_flush)(struct anv_cmd_buffer *cmd_buffer
struct anv_address vb_address,
uint32_t vb_size)
{
if (GFX_VER > 9 || anv_use_relocations(cmd_buffer->device->physical))
if (GFX_VER > 9)
return;
struct anv_vb_cache_range *bound, *dirty;
@ -5611,7 +5563,7 @@ genX(cmd_buffer_update_dirty_vbs_for_gfx8_vb_flush)(struct anv_cmd_buffer *cmd_b
uint32_t access_type,
uint64_t vb_used)
{
if (GFX_VER > 9 || anv_use_relocations(cmd_buffer->device->physical))
if (GFX_VER > 9)
return;
if (access_type == RANDOM) {

View file

@ -242,7 +242,7 @@ genX(emit_so_memcpy)(struct anv_memcpy_state *state,
struct anv_address dst, struct anv_address src,
uint32_t size)
{
if (GFX_VER == 9 && !anv_use_relocations(state->device->physical) &&
if (GFX_VER == 9 &&
anv_gfx8_9_vb_cache_range_needs_workaround(&state->vb_bound,
&state->vb_dirty,
src, size)) {