anv: Use an anv_address in anv_buffer_view
Instead of storing a BO and offset separately, use an anv_address. This changes anv_fill_buffer_surface_state to use anv_address and we now call anv_address_physical and pass that into ISL. Reviewed-by: Scott D Phillips <scott.d.phillips@intel.com>
This commit is contained in:
@@ -745,9 +745,11 @@ anv_descriptor_set_write_buffer(struct anv_descriptor_set *set,
|
|||||||
&set->buffer_views[bind_layout->buffer_index + element];
|
&set->buffer_views[bind_layout->buffer_index + element];
|
||||||
|
|
||||||
bview->format = anv_isl_format_for_descriptor_type(type);
|
bview->format = anv_isl_format_for_descriptor_type(type);
|
||||||
bview->bo = buffer->bo;
|
|
||||||
bview->offset = buffer->offset + offset;
|
|
||||||
bview->range = anv_buffer_get_range(buffer, offset, range);
|
bview->range = anv_buffer_get_range(buffer, offset, range);
|
||||||
|
bview->address = (struct anv_address) {
|
||||||
|
.bo = buffer->bo,
|
||||||
|
.offset = buffer->offset + offset,
|
||||||
|
};
|
||||||
|
|
||||||
/* If we're writing descriptors through a push command, we need to
|
/* If we're writing descriptors through a push command, we need to
|
||||||
* allocate the surface state from the command buffer. Otherwise it will
|
* allocate the surface state from the command buffer. Otherwise it will
|
||||||
@@ -758,7 +760,7 @@ anv_descriptor_set_write_buffer(struct anv_descriptor_set *set,
|
|||||||
|
|
||||||
anv_fill_buffer_surface_state(device, bview->surface_state,
|
anv_fill_buffer_surface_state(device, bview->surface_state,
|
||||||
bview->format,
|
bview->format,
|
||||||
bview->offset, bview->range, 1);
|
bview->address, bview->range, 1);
|
||||||
|
|
||||||
*desc = (struct anv_descriptor) {
|
*desc = (struct anv_descriptor) {
|
||||||
.type = type,
|
.type = type,
|
||||||
|
@@ -2711,10 +2711,11 @@ void anv_DestroyBuffer(
|
|||||||
void
|
void
|
||||||
anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
|
anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
|
||||||
enum isl_format format,
|
enum isl_format format,
|
||||||
uint32_t offset, uint32_t range, uint32_t stride)
|
struct anv_address address,
|
||||||
|
uint32_t range, uint32_t stride)
|
||||||
{
|
{
|
||||||
isl_buffer_fill_state(&device->isl_dev, state.map,
|
isl_buffer_fill_state(&device->isl_dev, state.map,
|
||||||
.address = offset,
|
.address = anv_address_physical(address),
|
||||||
.mocs = device->default_mocs,
|
.mocs = device->default_mocs,
|
||||||
.size = range,
|
.size = range,
|
||||||
.format = format,
|
.format = format,
|
||||||
|
@@ -1467,18 +1467,21 @@ anv_CreateBufferView(VkDevice _device,
|
|||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
VK_IMAGE_TILING_LINEAR);
|
VK_IMAGE_TILING_LINEAR);
|
||||||
const uint32_t format_bs = isl_format_get_layout(view->format)->bpb / 8;
|
const uint32_t format_bs = isl_format_get_layout(view->format)->bpb / 8;
|
||||||
view->bo = buffer->bo;
|
|
||||||
view->offset = buffer->offset + pCreateInfo->offset;
|
|
||||||
view->range = anv_buffer_get_range(buffer, pCreateInfo->offset,
|
view->range = anv_buffer_get_range(buffer, pCreateInfo->offset,
|
||||||
pCreateInfo->range);
|
pCreateInfo->range);
|
||||||
view->range = align_down_npot_u32(view->range, format_bs);
|
view->range = align_down_npot_u32(view->range, format_bs);
|
||||||
|
|
||||||
|
view->address = (struct anv_address) {
|
||||||
|
.bo = buffer->bo,
|
||||||
|
.offset = buffer->offset + pCreateInfo->offset,
|
||||||
|
};
|
||||||
|
|
||||||
if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) {
|
if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) {
|
||||||
view->surface_state = alloc_surface_state(device);
|
view->surface_state = alloc_surface_state(device);
|
||||||
|
|
||||||
anv_fill_buffer_surface_state(device, view->surface_state,
|
anv_fill_buffer_surface_state(device, view->surface_state,
|
||||||
view->format,
|
view->format,
|
||||||
view->offset, view->range, format_bs);
|
view->address, view->range, format_bs);
|
||||||
} else {
|
} else {
|
||||||
view->surface_state = (struct anv_state){ 0 };
|
view->surface_state = (struct anv_state){ 0 };
|
||||||
}
|
}
|
||||||
@@ -1495,14 +1498,14 @@ anv_CreateBufferView(VkDevice _device,
|
|||||||
|
|
||||||
anv_fill_buffer_surface_state(device, view->storage_surface_state,
|
anv_fill_buffer_surface_state(device, view->storage_surface_state,
|
||||||
storage_format,
|
storage_format,
|
||||||
view->offset, view->range,
|
view->address, view->range,
|
||||||
(storage_format == ISL_FORMAT_RAW ? 1 :
|
(storage_format == ISL_FORMAT_RAW ? 1 :
|
||||||
isl_format_get_layout(storage_format)->bpb / 8));
|
isl_format_get_layout(storage_format)->bpb / 8));
|
||||||
|
|
||||||
/* Write-only accesses should use the original format. */
|
/* Write-only accesses should use the original format. */
|
||||||
anv_fill_buffer_surface_state(device, view->writeonly_storage_surface_state,
|
anv_fill_buffer_surface_state(device, view->writeonly_storage_surface_state,
|
||||||
view->format,
|
view->format,
|
||||||
view->offset, view->range,
|
view->address, view->range,
|
||||||
isl_format_get_layout(view->format)->bpb / 8);
|
isl_format_get_layout(view->format)->bpb / 8);
|
||||||
|
|
||||||
isl_buffer_fill_image_param(&device->isl_dev,
|
isl_buffer_fill_image_param(&device->isl_dev,
|
||||||
|
@@ -1388,10 +1388,10 @@ struct anv_descriptor_set {
|
|||||||
|
|
||||||
struct anv_buffer_view {
|
struct anv_buffer_view {
|
||||||
enum isl_format format; /**< VkBufferViewCreateInfo::format */
|
enum isl_format format; /**< VkBufferViewCreateInfo::format */
|
||||||
struct anv_bo *bo;
|
|
||||||
uint32_t offset; /**< Offset into bo. */
|
|
||||||
uint64_t range; /**< VkBufferViewCreateInfo::range */
|
uint64_t range; /**< VkBufferViewCreateInfo::range */
|
||||||
|
|
||||||
|
struct anv_address address;
|
||||||
|
|
||||||
struct anv_state surface_state;
|
struct anv_state surface_state;
|
||||||
struct anv_state storage_surface_state;
|
struct anv_state storage_surface_state;
|
||||||
struct anv_state writeonly_storage_surface_state;
|
struct anv_state writeonly_storage_surface_state;
|
||||||
@@ -2993,8 +2993,8 @@ anv_sanitize_image_offset(const VkImageType imageType,
|
|||||||
void anv_fill_buffer_surface_state(struct anv_device *device,
|
void anv_fill_buffer_surface_state(struct anv_device *device,
|
||||||
struct anv_state state,
|
struct anv_state state,
|
||||||
enum isl_format format,
|
enum isl_format format,
|
||||||
uint32_t offset, uint32_t range,
|
struct anv_address address,
|
||||||
uint32_t stride);
|
uint32_t range, uint32_t stride);
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
anv_clear_color_from_att_state(union isl_color_value *clear_color,
|
anv_clear_color_from_att_state(union isl_color_value *clear_color,
|
||||||
|
@@ -1978,7 +1978,9 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
const enum isl_format format =
|
const enum isl_format format =
|
||||||
anv_isl_format_for_descriptor_type(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
anv_isl_format_for_descriptor_type(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||||
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
|
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
|
||||||
format, bo_offset, 12, 1);
|
format,
|
||||||
|
cmd_buffer->state.compute.num_workgroups,
|
||||||
|
12, 1);
|
||||||
|
|
||||||
bt_map[0] = surface_state.offset + state_offset;
|
bt_map[0] = surface_state.offset + state_offset;
|
||||||
add_surface_state_reloc(cmd_buffer, surface_state, bo, bo_offset);
|
add_surface_state_reloc(cmd_buffer, surface_state, bo, bo_offset);
|
||||||
@@ -2095,8 +2097,8 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
surface_state = desc->buffer_view->surface_state;
|
surface_state = desc->buffer_view->surface_state;
|
||||||
assert(surface_state.alloc_size);
|
assert(surface_state.alloc_size);
|
||||||
add_surface_state_reloc(cmd_buffer, surface_state,
|
add_surface_state_reloc(cmd_buffer, surface_state,
|
||||||
desc->buffer_view->bo,
|
desc->buffer_view->address.bo,
|
||||||
desc->buffer_view->offset);
|
desc->buffer_view->address.offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||||
@@ -2110,16 +2112,20 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
/* Clamp the range to the buffer size */
|
/* Clamp the range to the buffer size */
|
||||||
uint32_t range = MIN2(desc->range, desc->buffer->size - offset);
|
uint32_t range = MIN2(desc->range, desc->buffer->size - offset);
|
||||||
|
|
||||||
|
struct anv_address address = {
|
||||||
|
.bo = desc->buffer->bo,
|
||||||
|
.offset = desc->buffer->offset + offset,
|
||||||
|
};
|
||||||
|
|
||||||
surface_state =
|
surface_state =
|
||||||
anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64);
|
anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64);
|
||||||
enum isl_format format =
|
enum isl_format format =
|
||||||
anv_isl_format_for_descriptor_type(desc->type);
|
anv_isl_format_for_descriptor_type(desc->type);
|
||||||
|
|
||||||
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
|
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
|
||||||
format, offset, range, 1);
|
format, address, range, 1);
|
||||||
add_surface_state_reloc(cmd_buffer, surface_state,
|
add_surface_state_reloc(cmd_buffer, surface_state,
|
||||||
desc->buffer->bo,
|
address.bo, address.offset);
|
||||||
desc->buffer->offset + offset);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2129,8 +2135,8 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
: desc->buffer_view->storage_surface_state;
|
: desc->buffer_view->storage_surface_state;
|
||||||
assert(surface_state.alloc_size);
|
assert(surface_state.alloc_size);
|
||||||
add_surface_state_reloc(cmd_buffer, surface_state,
|
add_surface_state_reloc(cmd_buffer, surface_state,
|
||||||
desc->buffer_view->bo,
|
desc->buffer_view->address.bo,
|
||||||
desc->buffer_view->offset);
|
desc->buffer_view->address.offset);
|
||||||
|
|
||||||
struct brw_image_param *image_param =
|
struct brw_image_param *image_param =
|
||||||
&cmd_buffer->state.push_constants[stage]->images[image++];
|
&cmd_buffer->state.push_constants[stage]->images[image++];
|
||||||
@@ -2389,11 +2395,8 @@ cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
if (desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) {
|
if (desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) {
|
||||||
read_len = MIN2(range->length,
|
read_len = MIN2(range->length,
|
||||||
DIV_ROUND_UP(desc->buffer_view->range, 32) - range->start);
|
DIV_ROUND_UP(desc->buffer_view->range, 32) - range->start);
|
||||||
read_addr = (struct anv_address) {
|
read_addr = anv_address_add(desc->buffer_view->address,
|
||||||
.bo = desc->buffer_view->bo,
|
range->start * 32);
|
||||||
.offset = desc->buffer_view->offset +
|
|
||||||
range->start * 32,
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
assert(desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC);
|
assert(desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user