anv: Update usage of block_pool->bo.
Change block_pool->bo to be a pointer, and update its usage everywhere. This makes it simpler to switch it later to a list of BOs. v3: - Use a static "bos" field in the struct, instead of malloc'ing it. This will be later changed to a fixed length array of BOs. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
@@ -436,7 +436,9 @@ anv_block_pool_init(struct anv_block_pool *pool,
|
|||||||
pool->bo_flags = bo_flags;
|
pool->bo_flags = bo_flags;
|
||||||
pool->start_address = gen_canonical_address(start_address);
|
pool->start_address = gen_canonical_address(start_address);
|
||||||
|
|
||||||
anv_bo_init(&pool->bo, 0, 0);
|
pool->bo = &pool->bos;
|
||||||
|
|
||||||
|
anv_bo_init(pool->bo, 0, 0);
|
||||||
|
|
||||||
pool->fd = memfd_create("block pool", MFD_CLOEXEC);
|
pool->fd = memfd_create("block pool", MFD_CLOEXEC);
|
||||||
if (pool->fd == -1)
|
if (pool->fd == -1)
|
||||||
@@ -584,13 +586,13 @@ anv_block_pool_expand_range(struct anv_block_pool *pool,
|
|||||||
* the EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag and the kernel does all of the
|
* the EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag and the kernel does all of the
|
||||||
* hard work for us.
|
* hard work for us.
|
||||||
*/
|
*/
|
||||||
anv_bo_init(&pool->bo, gem_handle, size);
|
anv_bo_init(pool->bo, gem_handle, size);
|
||||||
if (pool->bo_flags & EXEC_OBJECT_PINNED) {
|
if (pool->bo_flags & EXEC_OBJECT_PINNED) {
|
||||||
pool->bo.offset = pool->start_address + BLOCK_POOL_MEMFD_CENTER -
|
pool->bo->offset = pool->start_address + BLOCK_POOL_MEMFD_CENTER -
|
||||||
center_bo_offset;
|
center_bo_offset;
|
||||||
}
|
}
|
||||||
pool->bo.flags = pool->bo_flags;
|
pool->bo->flags = pool->bo_flags;
|
||||||
pool->bo.map = map;
|
pool->bo->map = map;
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -604,7 +606,7 @@ anv_block_pool_expand_range(struct anv_block_pool *pool,
|
|||||||
void*
|
void*
|
||||||
anv_block_pool_map(struct anv_block_pool *pool, int32_t offset)
|
anv_block_pool_map(struct anv_block_pool *pool, int32_t offset)
|
||||||
{
|
{
|
||||||
return pool->bo.map + pool->center_bo_offset + offset;
|
return pool->bo->map + pool->center_bo_offset + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Grows and re-centers the block pool.
|
/** Grows and re-centers the block pool.
|
||||||
@@ -656,7 +658,7 @@ anv_block_pool_grow(struct anv_block_pool *pool, struct anv_block_state *state)
|
|||||||
|
|
||||||
assert(state == &pool->state || back_used > 0);
|
assert(state == &pool->state || back_used > 0);
|
||||||
|
|
||||||
uint32_t old_size = pool->bo.size;
|
uint32_t old_size = pool->bo->size;
|
||||||
|
|
||||||
/* The block pool is always initialized to a nonzero size and this function
|
/* The block pool is always initialized to a nonzero size and this function
|
||||||
* is always called after initialization.
|
* is always called after initialization.
|
||||||
@@ -682,7 +684,7 @@ anv_block_pool_grow(struct anv_block_pool *pool, struct anv_block_state *state)
|
|||||||
while (size < back_required + front_required)
|
while (size < back_required + front_required)
|
||||||
size *= 2;
|
size *= 2;
|
||||||
|
|
||||||
assert(size > pool->bo.size);
|
assert(size > pool->bo->size);
|
||||||
|
|
||||||
/* We compute a new center_bo_offset such that, when we double the size
|
/* We compute a new center_bo_offset such that, when we double the size
|
||||||
* of the pool, we maintain the ratio of how much is used by each side.
|
* of the pool, we maintain the ratio of how much is used by each side.
|
||||||
@@ -719,7 +721,7 @@ anv_block_pool_grow(struct anv_block_pool *pool, struct anv_block_state *state)
|
|||||||
|
|
||||||
result = anv_block_pool_expand_range(pool, center_bo_offset, size);
|
result = anv_block_pool_expand_range(pool, center_bo_offset, size);
|
||||||
|
|
||||||
pool->bo.flags = pool->bo_flags;
|
pool->bo->flags = pool->bo_flags;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
pthread_mutex_unlock(&pool->device->mutex);
|
pthread_mutex_unlock(&pool->device->mutex);
|
||||||
@@ -730,7 +732,7 @@ done:
|
|||||||
* needs to do so in order to maintain its concurrency model.
|
* needs to do so in order to maintain its concurrency model.
|
||||||
*/
|
*/
|
||||||
if (state == &pool->state) {
|
if (state == &pool->state) {
|
||||||
return pool->bo.size - pool->center_bo_offset;
|
return pool->bo->size - pool->center_bo_offset;
|
||||||
} else {
|
} else {
|
||||||
assert(pool->center_bo_offset > 0);
|
assert(pool->center_bo_offset > 0);
|
||||||
return pool->center_bo_offset;
|
return pool->center_bo_offset;
|
||||||
|
@@ -500,7 +500,7 @@ anv_cmd_buffer_surface_base_address(struct anv_cmd_buffer *cmd_buffer)
|
|||||||
{
|
{
|
||||||
struct anv_state *bt_block = u_vector_head(&cmd_buffer->bt_block_states);
|
struct anv_state *bt_block = u_vector_head(&cmd_buffer->bt_block_states);
|
||||||
return (struct anv_address) {
|
return (struct anv_address) {
|
||||||
.bo = &anv_binding_table_pool(cmd_buffer->device)->block_pool.bo,
|
.bo = anv_binding_table_pool(cmd_buffer->device)->block_pool.bo,
|
||||||
.offset = bt_block->offset,
|
.offset = bt_block->offset,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1227,7 +1227,7 @@ adjust_relocations_to_state_pool(struct anv_state_pool *pool,
|
|||||||
* relocations that point to the pool bo with the correct offset.
|
* relocations that point to the pool bo with the correct offset.
|
||||||
*/
|
*/
|
||||||
for (size_t i = 0; i < relocs->num_relocs; i++) {
|
for (size_t i = 0; i < relocs->num_relocs; i++) {
|
||||||
if (relocs->reloc_bos[i] == &pool->block_pool.bo) {
|
if (relocs->reloc_bos[i] == pool->block_pool.bo) {
|
||||||
/* Adjust the delta value in the relocation to correctly
|
/* Adjust the delta value in the relocation to correctly
|
||||||
* correspond to the new delta. Initially, this value may have
|
* correspond to the new delta. Initially, this value may have
|
||||||
* been negative (if treated as unsigned), but we trust in
|
* been negative (if treated as unsigned), but we trust in
|
||||||
@@ -1335,7 +1335,7 @@ relocate_cmd_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
* given time. The only option is to always relocate them.
|
* given time. The only option is to always relocate them.
|
||||||
*/
|
*/
|
||||||
anv_reloc_list_apply(cmd_buffer->device, &cmd_buffer->surface_relocs,
|
anv_reloc_list_apply(cmd_buffer->device, &cmd_buffer->surface_relocs,
|
||||||
&cmd_buffer->device->surface_state_pool.block_pool.bo,
|
cmd_buffer->device->surface_state_pool.block_pool.bo,
|
||||||
true /* always relocate surface states */);
|
true /* always relocate surface states */);
|
||||||
|
|
||||||
/* Since we own all of the batch buffers, we know what values are stored
|
/* Since we own all of the batch buffers, we know what values are stored
|
||||||
@@ -1364,7 +1364,7 @@ setup_execbuf_for_cmd_buffer(struct anv_execbuf *execbuf,
|
|||||||
|
|
||||||
adjust_relocations_from_state_pool(ss_pool, &cmd_buffer->surface_relocs,
|
adjust_relocations_from_state_pool(ss_pool, &cmd_buffer->surface_relocs,
|
||||||
cmd_buffer->last_ss_pool_center);
|
cmd_buffer->last_ss_pool_center);
|
||||||
VkResult result = anv_execbuf_add_bo(execbuf, &ss_pool->block_pool.bo,
|
VkResult result = anv_execbuf_add_bo(execbuf, ss_pool->block_pool.bo,
|
||||||
&cmd_buffer->surface_relocs, 0,
|
&cmd_buffer->surface_relocs, 0,
|
||||||
&cmd_buffer->device->alloc);
|
&cmd_buffer->device->alloc);
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
|
@@ -721,7 +721,7 @@ void anv_CmdUpdateBuffer(
|
|||||||
anv_state_flush(cmd_buffer->device, tmp_data);
|
anv_state_flush(cmd_buffer->device, tmp_data);
|
||||||
|
|
||||||
struct blorp_address src = {
|
struct blorp_address src = {
|
||||||
.buffer = &cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
.buffer = cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
||||||
.offset = tmp_data.offset,
|
.offset = tmp_data.offset,
|
||||||
.mocs = cmd_buffer->device->default_mocs,
|
.mocs = cmd_buffer->device->default_mocs,
|
||||||
};
|
};
|
||||||
|
@@ -633,7 +633,10 @@ struct anv_block_pool {
|
|||||||
|
|
||||||
uint64_t bo_flags;
|
uint64_t bo_flags;
|
||||||
|
|
||||||
struct anv_bo bo;
|
struct anv_bo *bo;
|
||||||
|
|
||||||
|
/* A single BO for now */
|
||||||
|
struct anv_bo bos;
|
||||||
|
|
||||||
/* The address where the start of the pool is pinned. The various bos that
|
/* The address where the start of the pool is pinned. The various bos that
|
||||||
* are created as the pool grows will have addresses in the range
|
* are created as the pool grows will have addresses in the range
|
||||||
|
@@ -610,7 +610,7 @@ void genX(CmdSetEvent)(
|
|||||||
pc.DestinationAddressType = DAT_PPGTT,
|
pc.DestinationAddressType = DAT_PPGTT,
|
||||||
pc.PostSyncOperation = WriteImmediateData,
|
pc.PostSyncOperation = WriteImmediateData,
|
||||||
pc.Address = (struct anv_address) {
|
pc.Address = (struct anv_address) {
|
||||||
&cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
||||||
event->state.offset
|
event->state.offset
|
||||||
};
|
};
|
||||||
pc.ImmediateData = VK_EVENT_SET;
|
pc.ImmediateData = VK_EVENT_SET;
|
||||||
@@ -634,7 +634,7 @@ void genX(CmdResetEvent)(
|
|||||||
pc.DestinationAddressType = DAT_PPGTT;
|
pc.DestinationAddressType = DAT_PPGTT;
|
||||||
pc.PostSyncOperation = WriteImmediateData;
|
pc.PostSyncOperation = WriteImmediateData;
|
||||||
pc.Address = (struct anv_address) {
|
pc.Address = (struct anv_address) {
|
||||||
&cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
||||||
event->state.offset
|
event->state.offset
|
||||||
};
|
};
|
||||||
pc.ImmediateData = VK_EVENT_RESET;
|
pc.ImmediateData = VK_EVENT_RESET;
|
||||||
@@ -663,7 +663,7 @@ void genX(CmdWaitEvents)(
|
|||||||
sem.CompareOperation = COMPARE_SAD_EQUAL_SDD,
|
sem.CompareOperation = COMPARE_SAD_EQUAL_SDD,
|
||||||
sem.SemaphoreDataDword = VK_EVENT_SET,
|
sem.SemaphoreDataDword = VK_EVENT_SET,
|
||||||
sem.SemaphoreAddress = (struct anv_address) {
|
sem.SemaphoreAddress = (struct anv_address) {
|
||||||
&cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
||||||
event->state.offset
|
event->state.offset
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -84,7 +84,7 @@ blorp_get_surface_base_address(struct blorp_batch *batch)
|
|||||||
{
|
{
|
||||||
struct anv_cmd_buffer *cmd_buffer = batch->driver_batch;
|
struct anv_cmd_buffer *cmd_buffer = batch->driver_batch;
|
||||||
return (struct blorp_address) {
|
return (struct blorp_address) {
|
||||||
.buffer = &cmd_buffer->device->surface_state_pool.block_pool.bo,
|
.buffer = cmd_buffer->device->surface_state_pool.block_pool.bo,
|
||||||
.offset = 0,
|
.offset = 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ blorp_alloc_vertex_buffer(struct blorp_batch *batch, uint32_t size,
|
|||||||
anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, size, 64);
|
anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, size, 64);
|
||||||
|
|
||||||
*addr = (struct blorp_address) {
|
*addr = (struct blorp_address) {
|
||||||
.buffer = &cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
.buffer = cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
||||||
.offset = vb_state.offset,
|
.offset = vb_state.offset,
|
||||||
.mocs = cmd_buffer->device->default_mocs,
|
.mocs = cmd_buffer->device->default_mocs,
|
||||||
};
|
};
|
||||||
|
@@ -95,7 +95,7 @@ genX(cmd_buffer_emit_state_base_address)(struct anv_cmd_buffer *cmd_buffer)
|
|||||||
sba.SurfaceStateBaseAddressModifyEnable = true;
|
sba.SurfaceStateBaseAddressModifyEnable = true;
|
||||||
|
|
||||||
sba.DynamicStateBaseAddress =
|
sba.DynamicStateBaseAddress =
|
||||||
(struct anv_address) { &device->dynamic_state_pool.block_pool.bo, 0 };
|
(struct anv_address) { device->dynamic_state_pool.block_pool.bo, 0 };
|
||||||
sba.DynamicStateMOCS = GENX(MOCS);
|
sba.DynamicStateMOCS = GENX(MOCS);
|
||||||
sba.DynamicStateBaseAddressModifyEnable = true;
|
sba.DynamicStateBaseAddressModifyEnable = true;
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ genX(cmd_buffer_emit_state_base_address)(struct anv_cmd_buffer *cmd_buffer)
|
|||||||
sba.IndirectObjectBaseAddressModifyEnable = true;
|
sba.IndirectObjectBaseAddressModifyEnable = true;
|
||||||
|
|
||||||
sba.InstructionBaseAddress =
|
sba.InstructionBaseAddress =
|
||||||
(struct anv_address) { &device->instruction_state_pool.block_pool.bo, 0 };
|
(struct anv_address) { device->instruction_state_pool.block_pool.bo, 0 };
|
||||||
sba.InstructionMOCS = GENX(MOCS);
|
sba.InstructionMOCS = GENX(MOCS);
|
||||||
sba.InstructionBaseAddressModifyEnable = true;
|
sba.InstructionBaseAddressModifyEnable = true;
|
||||||
|
|
||||||
@@ -886,7 +886,7 @@ genX(copy_fast_clear_dwords)(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
|
assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
|
||||||
|
|
||||||
struct anv_address ss_clear_addr = {
|
struct anv_address ss_clear_addr = {
|
||||||
.bo = &cmd_buffer->device->surface_state_pool.block_pool.bo,
|
.bo = cmd_buffer->device->surface_state_pool.block_pool.bo,
|
||||||
.offset = surface_state.offset +
|
.offset = surface_state.offset +
|
||||||
cmd_buffer->device->isl_dev.ss.clear_value_offset,
|
cmd_buffer->device->isl_dev.ss.clear_value_offset,
|
||||||
};
|
};
|
||||||
@@ -1522,7 +1522,7 @@ genX(CmdExecuteCommands)(
|
|||||||
* we allocated for them in BeginCommandBuffer.
|
* we allocated for them in BeginCommandBuffer.
|
||||||
*/
|
*/
|
||||||
struct anv_bo *ss_bo =
|
struct anv_bo *ss_bo =
|
||||||
&primary->device->surface_state_pool.block_pool.bo;
|
primary->device->surface_state_pool.block_pool.bo;
|
||||||
struct anv_state src_state = primary->state.render_pass_states;
|
struct anv_state src_state = primary->state.render_pass_states;
|
||||||
struct anv_state dst_state = secondary->state.render_pass_states;
|
struct anv_state dst_state = secondary->state.render_pass_states;
|
||||||
assert(src_state.alloc_size == dst_state.alloc_size);
|
assert(src_state.alloc_size == dst_state.alloc_size);
|
||||||
@@ -2110,7 +2110,7 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
anv_cmd_buffer_alloc_surface_state(cmd_buffer);
|
anv_cmd_buffer_alloc_surface_state(cmd_buffer);
|
||||||
|
|
||||||
struct anv_address constant_data = {
|
struct anv_address constant_data = {
|
||||||
.bo = &pipeline->device->dynamic_state_pool.block_pool.bo,
|
.bo = pipeline->device->dynamic_state_pool.block_pool.bo,
|
||||||
.offset = pipeline->shaders[stage]->constant_data.offset,
|
.offset = pipeline->shaders[stage]->constant_data.offset,
|
||||||
};
|
};
|
||||||
unsigned constant_data_size =
|
unsigned constant_data_size =
|
||||||
@@ -2487,7 +2487,7 @@ cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
uint32_t read_len;
|
uint32_t read_len;
|
||||||
if (binding->set == ANV_DESCRIPTOR_SET_SHADER_CONSTANTS) {
|
if (binding->set == ANV_DESCRIPTOR_SET_SHADER_CONSTANTS) {
|
||||||
struct anv_address constant_data = {
|
struct anv_address constant_data = {
|
||||||
.bo = &pipeline->device->dynamic_state_pool.block_pool.bo,
|
.bo = pipeline->device->dynamic_state_pool.block_pool.bo,
|
||||||
.offset = pipeline->shaders[stage]->constant_data.offset,
|
.offset = pipeline->shaders[stage]->constant_data.offset,
|
||||||
};
|
};
|
||||||
unsigned constant_data_size =
|
unsigned constant_data_size =
|
||||||
@@ -2535,7 +2535,7 @@ cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
|
|
||||||
if (state.alloc_size > 0) {
|
if (state.alloc_size > 0) {
|
||||||
c.ConstantBody.Buffer[n] = (struct anv_address) {
|
c.ConstantBody.Buffer[n] = (struct anv_address) {
|
||||||
.bo = &cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
.bo = cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
||||||
.offset = state.offset,
|
.offset = state.offset,
|
||||||
};
|
};
|
||||||
c.ConstantBody.ReadLength[n] =
|
c.ConstantBody.ReadLength[n] =
|
||||||
@@ -2744,7 +2744,7 @@ emit_base_vertex_instance(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
anv_state_flush(cmd_buffer->device, id_state);
|
anv_state_flush(cmd_buffer->device, id_state);
|
||||||
|
|
||||||
struct anv_address addr = {
|
struct anv_address addr = {
|
||||||
.bo = &cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
.bo = cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
||||||
.offset = id_state.offset,
|
.offset = id_state.offset,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2762,7 +2762,7 @@ emit_draw_index(struct anv_cmd_buffer *cmd_buffer, uint32_t draw_index)
|
|||||||
anv_state_flush(cmd_buffer->device, state);
|
anv_state_flush(cmd_buffer->device, state);
|
||||||
|
|
||||||
struct anv_address addr = {
|
struct anv_address addr = {
|
||||||
.bo = &cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
.bo = cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
||||||
.offset = state.offset,
|
.offset = state.offset,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3224,7 +3224,7 @@ void genX(CmdDispatchBase)(
|
|||||||
sizes[2] = groupCountZ;
|
sizes[2] = groupCountZ;
|
||||||
anv_state_flush(cmd_buffer->device, state);
|
anv_state_flush(cmd_buffer->device, state);
|
||||||
cmd_buffer->state.compute.num_workgroups = (struct anv_address) {
|
cmd_buffer->state.compute.num_workgroups = (struct anv_address) {
|
||||||
.bo = &cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
.bo = cmd_buffer->device->dynamic_state_pool.block_pool.bo,
|
||||||
.offset = state.offset,
|
.offset = state.offset,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user