[Mesa-dev] [PATCH v4 10/23] anv: Use an anv_address in anv_buffer
Jason Ekstrand
jason at jlekstrand.net
Thu May 31 15:46:31 UTC 2018
---
src/intel/vulkan/anv_blorp.c | 16 ++++++++--------
src/intel/vulkan/anv_descriptor_set.c | 5 +----
src/intel/vulkan/anv_device.c | 12 ++++++------
src/intel/vulkan/anv_image.c | 5 +----
src/intel/vulkan/anv_private.h | 3 +--
src/intel/vulkan/gen7_cmd_buffer.c | 8 ++++----
src/intel/vulkan/gen8_cmd_buffer.c | 3 +--
src/intel/vulkan/genX_cmd_buffer.c | 32 +++++++++-----------------------
src/intel/vulkan/genX_query.c | 11 +++--------
9 files changed, 34 insertions(+), 61 deletions(-)
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index c4a3e4a..359ebfb 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -154,8 +154,8 @@ get_blorp_surf_for_anv_buffer(struct anv_device *device,
*blorp_surf = (struct blorp_surf) {
.surf = isl_surf,
.addr = {
- .buffer = buffer->bo,
- .offset = buffer->offset + offset,
+ .buffer = buffer->address.bo,
+ .offset = buffer->address.offset + offset,
.mocs = device->default_mocs,
},
};
@@ -662,13 +662,13 @@ void anv_CmdCopyBuffer(
for (unsigned r = 0; r < regionCount; r++) {
struct blorp_address src = {
- .buffer = src_buffer->bo,
- .offset = src_buffer->offset + pRegions[r].srcOffset,
+ .buffer = src_buffer->address.bo,
+ .offset = src_buffer->address.offset + pRegions[r].srcOffset,
.mocs = cmd_buffer->device->default_mocs,
};
struct blorp_address dst = {
- .buffer = dst_buffer->bo,
- .offset = dst_buffer->offset + pRegions[r].dstOffset,
+ .buffer = dst_buffer->address.bo,
+ .offset = dst_buffer->address.offset + pRegions[r].dstOffset,
.mocs = cmd_buffer->device->default_mocs,
};
@@ -720,8 +720,8 @@ void anv_CmdUpdateBuffer(
.mocs = cmd_buffer->device->default_mocs,
};
struct blorp_address dst = {
- .buffer = dst_buffer->bo,
- .offset = dst_buffer->offset + dstOffset,
+ .buffer = dst_buffer->address.bo,
+ .offset = dst_buffer->address.offset + dstOffset,
.mocs = cmd_buffer->device->default_mocs,
};
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index 0380e13..9534ba8 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -746,10 +746,7 @@ anv_descriptor_set_write_buffer(struct anv_descriptor_set *set,
bview->format = anv_isl_format_for_descriptor_type(type);
bview->range = anv_buffer_get_range(buffer, offset, range);
- bview->address = (struct anv_address) {
- .bo = buffer->bo,
- .offset = buffer->offset + offset,
- };
+ bview->address = anv_address_add(buffer->address, offset);
/* If we're writing descriptors through a push command, we need to
* allocate the surface state from the command buffer. Otherwise it will
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 3deeea5..19fa1b7 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -2516,11 +2516,12 @@ anv_bind_buffer_memory(const VkBindBufferMemoryInfo *pBindInfo)
if (mem) {
assert((buffer->usage & mem->type->valid_buffer_usage) == buffer->usage);
- buffer->bo = mem->bo;
- buffer->offset = pBindInfo->memoryOffset;
+ buffer->address = (struct anv_address) {
+ .bo = mem->bo,
+ .offset = pBindInfo->memoryOffset,
+ };
} else {
- buffer->bo = NULL;
- buffer->offset = 0;
+ buffer->address = ANV_NULL_ADDRESS;
}
}
@@ -2686,8 +2687,7 @@ VkResult anv_CreateBuffer(
buffer->size = pCreateInfo->size;
buffer->usage = pCreateInfo->usage;
- buffer->bo = NULL;
- buffer->offset = 0;
+ buffer->address = ANV_NULL_ADDRESS;
*pBuffer = anv_buffer_to_handle(buffer);
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 090d061..bbb740e 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -1471,10 +1471,7 @@ anv_CreateBufferView(VkDevice _device,
pCreateInfo->range);
view->range = align_down_npot_u32(view->range, format_bs);
- view->address = (struct anv_address) {
- .bo = buffer->bo,
- .offset = buffer->offset + pCreateInfo->offset,
- };
+ view->address = anv_address_add(buffer->address, pCreateInfo->offset);
if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) {
view->surface_state = alloc_surface_state(device);
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 95d3e4d..ecc0cb9 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1558,8 +1558,7 @@ struct anv_buffer {
VkBufferUsageFlags usage;
/* Set when bound */
- struct anv_bo * bo;
- VkDeviceSize offset;
+ struct anv_address address;
};
static inline uint64_t
diff --git a/src/intel/vulkan/gen7_cmd_buffer.c b/src/intel/vulkan/gen7_cmd_buffer.c
index cbeb838..aa4dcde 100644
--- a/src/intel/vulkan/gen7_cmd_buffer.c
+++ b/src/intel/vulkan/gen7_cmd_buffer.c
@@ -247,10 +247,10 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
ib.IndexFormat = cmd_buffer->state.gfx.gen7.index_type;
ib.MemoryObjectControlState = GENX(MOCS);
- ib.BufferStartingAddress =
- (struct anv_address) { buffer->bo, buffer->offset + offset };
- ib.BufferEndingAddress =
- (struct anv_address) { buffer->bo, buffer->offset + buffer->size };
+ ib.BufferStartingAddress = anv_address_add(buffer->address,
+ offset);
+ ib.BufferEndingAddress = anv_address_add(buffer->address,
+ buffer->size);
}
}
diff --git a/src/intel/vulkan/gen8_cmd_buffer.c b/src/intel/vulkan/gen8_cmd_buffer.c
index 2999c99..ca2baf8 100644
--- a/src/intel/vulkan/gen8_cmd_buffer.c
+++ b/src/intel/vulkan/gen8_cmd_buffer.c
@@ -566,8 +566,7 @@ void genX(CmdBindIndexBuffer)(
anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_INDEX_BUFFER), ib) {
ib.IndexFormat = vk_to_gen_index_type[indexType];
ib.MemoryObjectControlState = GENX(MOCS);
- ib.BufferStartingAddress =
- (struct anv_address) { buffer->bo, buffer->offset + offset };
+ ib.BufferStartingAddress = anv_address_add(buffer->address, offset);
ib.BufferSize = buffer->size - offset;
}
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index d38c5f8..65aea3f 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2112,10 +2112,8 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
/* Clamp the range to the buffer size */
uint32_t range = MIN2(desc->range, desc->buffer->size - offset);
- struct anv_address address = {
- .bo = desc->buffer->bo,
- .offset = desc->buffer->offset + offset,
- };
+ struct anv_address address =
+ anv_address_add(desc->buffer->address, offset);
surface_state =
anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64);
@@ -2409,11 +2407,8 @@ cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer,
read_len = MIN2(range->length,
DIV_ROUND_UP(buf_range, 32) - range->start);
- read_addr = (struct anv_address) {
- .bo = desc->buffer->bo,
- .offset = desc->buffer->offset + buf_offset +
- range->start * 32,
- };
+ read_addr = anv_address_add(desc->buffer->address,
+ buf_offset + range->start * 32);
}
if (read_len > 0) {
@@ -2501,12 +2496,12 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
.AddressModifyEnable = true,
.BufferPitch = pipeline->binding_stride[vb],
- .BufferStartingAddress = { buffer->bo, buffer->offset + offset },
+ .BufferStartingAddress = anv_address_add(buffer->address, offset),
#if GEN_GEN >= 8
.BufferSize = buffer->size - offset
#else
- .EndAddress = { buffer->bo, buffer->offset + buffer->size - 1},
+ .EndAddress = anv_address_add(buffer->address, buffer->size - 1),
#endif
};
@@ -2857,10 +2852,7 @@ void genX(CmdDrawIndirect)(
genX(cmd_buffer_flush_state)(cmd_buffer);
for (uint32_t i = 0; i < drawCount; i++) {
- struct anv_address draw = {
- .bo = buffer->bo,
- .offset = buffer->offset + offset,
- };
+ struct anv_address draw = anv_address_add(buffer->address, offset);
if (vs_prog_data->uses_firstvertex ||
vs_prog_data->uses_baseinstance)
@@ -2898,10 +2890,7 @@ void genX(CmdDrawIndexedIndirect)(
genX(cmd_buffer_flush_state)(cmd_buffer);
for (uint32_t i = 0; i < drawCount; i++) {
- struct anv_address draw = {
- .bo = buffer->bo,
- .offset = buffer->offset + offset,
- };
+ struct anv_address draw = anv_address_add(buffer->address, offset);
/* TODO: We need to stomp base vertex to 0 somehow */
if (vs_prog_data->uses_firstvertex ||
@@ -3153,10 +3142,7 @@ void genX(CmdDispatchIndirect)(
ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
struct anv_pipeline *pipeline = cmd_buffer->state.compute.base.pipeline;
const struct brw_cs_prog_data *prog_data = get_cs_prog_data(pipeline);
- struct anv_address addr = {
- .bo = buffer->bo,
- .offset = buffer->offset + offset,
- };
+ struct anv_address addr = anv_address_add(buffer->address, offset);
struct anv_batch *batch = &cmd_buffer->batch;
anv_cmd_buffer_push_base_group_id(cmd_buffer, 0, 0, 0);
diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c
index 4efcc57..de409be 100644
--- a/src/intel/vulkan/genX_query.c
+++ b/src/intel/vulkan/genX_query.c
@@ -686,19 +686,14 @@ gpu_write_query_result(struct anv_batch *batch,
anv_batch_emit(batch, GENX(MI_STORE_REGISTER_MEM), srm) {
srm.RegisterAddress = reg;
- srm.MemoryAddress = (struct anv_address) {
- .bo = dst_buffer->bo,
- .offset = dst_buffer->offset + dst_offset,
- };
+ srm.MemoryAddress = anv_address_add(dst_buffer->address, dst_offset);
}
if (flags & VK_QUERY_RESULT_64_BIT) {
anv_batch_emit(batch, GENX(MI_STORE_REGISTER_MEM), srm) {
srm.RegisterAddress = reg + 4;
- srm.MemoryAddress = (struct anv_address) {
- .bo = dst_buffer->bo,
- .offset = dst_buffer->offset + dst_offset + 4,
- };
+ srm.MemoryAddress = anv_address_add(dst_buffer->address,
+ dst_offset + 4);
}
}
}
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list