Commit d5a0a7f7 authored by Kenneth Graunke's avatar Kenneth Graunke
Browse files

anv: Remove anv_batch_emit_reloc and just open-code it

We don't need the relocation offsets anymore, and just want to pin the
BO, and combine the address into a uint64_t.  We can just open code
those two things; it's actually less code.
parent 8c9476a3
Pipeline #677294 waiting for manual action with stages
......@@ -1441,35 +1441,17 @@ anv_batch_has_error(struct anv_batch *batch)
return batch->status != VK_SUCCESS;
}
static inline uint64_t
anv_batch_emit_reloc(struct anv_batch *batch,
void *location, struct anv_bo *bo, uint32_t delta)
{
uint64_t address_u64 = bo->offset + delta;
VkResult result = anv_reloc_list_add_bo(batch->relocs, batch->alloc, bo);
if (unlikely(result != VK_SUCCESS)) {
anv_batch_set_error(batch, result);
return 0;
}
return address_u64;
}
static inline uint64_t
_anv_combine_address(struct anv_batch *batch, void *location,
const struct anv_address address, uint32_t delta)
{
if (address.bo == NULL) {
if (address.bo == NULL)
return address.offset + delta;
} else if (batch == NULL) {
return anv_address_physical(anv_address_add(address, delta));
} else {
assert(batch->start <= location && location < batch->end);
/* i915 relocations are signed. */
assert(INT32_MIN <= address.offset && address.offset <= INT32_MAX);
return anv_batch_emit_reloc(batch, location, address.bo, address.offset + delta);
}
if (batch)
anv_reloc_list_add_bo(batch->relocs, batch->alloc, address.bo);
return anv_address_physical(anv_address_add(address, delta));
}
#define __gen_address_type struct anv_address
......
......@@ -71,10 +71,13 @@ blorp_emit_reloc(struct blorp_batch *batch,
void *location, struct blorp_address address, uint32_t delta)
{
struct anv_cmd_buffer *cmd_buffer = batch->driver_batch;
assert(cmd_buffer->batch.start <= location &&
location < cmd_buffer->batch.end);
return anv_batch_emit_reloc(&cmd_buffer->batch, location,
address.buffer, address.offset + delta);
struct anv_address anv_addr = {
.bo = address.buffer,
.offset = address.offset,
};
anv_reloc_list_add_bo(cmd_buffer->batch.relocs,
cmd_buffer->batch.alloc, anv_addr.bo);
return anv_address_physical(anv_address_add(anv_addr, delta));
}
static void
......
......@@ -5723,12 +5723,11 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
const struct anv_address depth_address =
anv_image_address(image, &depth_surface->memory_range);
info.depth_surf = &depth_surface->isl;
anv_reloc_list_add_bo(cmd_buffer->batch.relocs,
cmd_buffer->batch.alloc, depth_address.bo);
info.depth_address =
anv_batch_emit_reloc(&cmd_buffer->batch,
dw + device->isl_dev.ds.depth_offset / 4,
depth_address.bo, depth_address.offset);
info.depth_surf = &depth_surface->isl;
info.depth_address = anv_address_physical(depth_address);
info.mocs =
anv_mocs(device, depth_address.bo, ISL_SURF_USAGE_DEPTH_BIT);
......@@ -5741,12 +5740,11 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
const struct anv_address hiz_address =
anv_image_address(image, &hiz_surface->memory_range);
info.hiz_surf = &hiz_surface->isl;
anv_reloc_list_add_bo(cmd_buffer->batch.relocs,
cmd_buffer->batch.alloc, hiz_address.bo);
info.hiz_address =
anv_batch_emit_reloc(&cmd_buffer->batch,
dw + device->isl_dev.ds.hiz_offset / 4,
hiz_address.bo, hiz_address.offset);
info.hiz_surf = &hiz_surface->isl;
info.hiz_address = anv_address_physical(hiz_address);
info.depth_clear_value = ANV_HZ_FC_VAL;
}
......@@ -5763,13 +5761,13 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
const struct anv_address stencil_address =
anv_image_address(image, &stencil_surface->memory_range);
anv_reloc_list_add_bo(cmd_buffer->batch.relocs,
cmd_buffer->batch.alloc, stencil_address.bo);
info.stencil_surf = &stencil_surface->isl;
info.stencil_aux_usage = image->planes[stencil_plane].aux_usage;
info.stencil_address =
anv_batch_emit_reloc(&cmd_buffer->batch,
dw + device->isl_dev.ds.stencil_offset / 4,
stencil_address.bo, stencil_address.offset);
info.stencil_address = anv_address_physical(stencil_address);
info.mocs =
anv_mocs(device, stencil_address.bo, ISL_SURF_USAGE_STENCIL_BIT);
}
......@@ -5818,14 +5816,17 @@ cmd_buffer_emit_cps_control_buffer(struct anv_cmd_buffer *cmd_buffer,
struct isl_cpb_emit_info info = { };
if (fsr_iview) {
const struct anv_image_binding *binding = &fsr_iview->image->bindings[0];
anv_reloc_list_add_bo(cmd_buffer->batch.relocs,
cmd_buffer->batch.alloc, binding->address.bo);
struct anv_address addr =
anv_address_add(binding->address, binding->memory_range.offset);
info.view = &fsr_iview->planes[0].isl;
info.surf = &fsr_iview->image->planes[0].primary_surface.isl;
info.address =
anv_batch_emit_reloc(&cmd_buffer->batch,
dw + device->isl_dev.cpb.offset / 4,
fsr_iview->image->bindings[0].address.bo,
fsr_iview->image->bindings[0].address.offset +
fsr_iview->image->bindings[0].memory_range.offset);
info.address = anv_address_physical(addr);
info.mocs =
anv_mocs(device, fsr_iview->image->bindings[0].address.bo,
ISL_SURF_USAGE_CPB_BIT);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment