&set->buffer_views[bind_layout->buffer_index + element];
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->address = (struct anv_address) {
+ .bo = buffer->bo,
+ .offset = buffer->offset + offset,
+ };
/* If we're writing descriptors through a push command, we need to
* allocate the surface state from the command buffer. Otherwise it will
anv_fill_buffer_surface_state(device, bview->surface_state,
bview->format,
- bview->offset, bview->range, 1);
+ bview->address, bview->range, 1);
*desc = (struct anv_descriptor) {
.type = type,
void
anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
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,
- .address = offset,
+ .address = anv_address_physical(address),
.mocs = device->default_mocs,
.size = range,
.format = format,
VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_TILING_LINEAR);
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,
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,
+ };
+
if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) {
view->surface_state = alloc_surface_state(device);
anv_fill_buffer_surface_state(device, view->surface_state,
view->format,
- view->offset, view->range, format_bs);
+ view->address, view->range, format_bs);
} else {
view->surface_state = (struct anv_state){ 0 };
}
anv_fill_buffer_surface_state(device, view->storage_surface_state,
storage_format,
- view->offset, view->range,
+ view->address, view->range,
(storage_format == ISL_FORMAT_RAW ? 1 :
isl_format_get_layout(storage_format)->bpb / 8));
/* Write-only accesses should use the original format. */
anv_fill_buffer_surface_state(device, view->writeonly_storage_surface_state,
view->format,
- view->offset, view->range,
+ view->address, view->range,
isl_format_get_layout(view->format)->bpb / 8);
isl_buffer_fill_image_param(&device->isl_dev,
struct anv_buffer_view {
enum isl_format format; /**< VkBufferViewCreateInfo::format */
- struct anv_bo *bo;
- uint32_t offset; /**< Offset into bo. */
uint64_t range; /**< VkBufferViewCreateInfo::range */
+ struct anv_address address;
+
struct anv_state surface_state;
struct anv_state storage_surface_state;
struct anv_state writeonly_storage_surface_state;
void anv_fill_buffer_surface_state(struct anv_device *device,
struct anv_state state,
enum isl_format format,
- uint32_t offset, uint32_t range,
- uint32_t stride);
+ struct anv_address address,
+ uint32_t range, uint32_t stride);
static inline void
anv_clear_color_from_att_state(union isl_color_value *clear_color,
const enum isl_format format =
anv_isl_format_for_descriptor_type(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
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;
add_surface_state_reloc(cmd_buffer, surface_state, bo, bo_offset);
surface_state = desc->buffer_view->surface_state;
assert(surface_state.alloc_size);
add_surface_state_reloc(cmd_buffer, surface_state,
- desc->buffer_view->bo,
- desc->buffer_view->offset);
+ desc->buffer_view->address.bo,
+ desc->buffer_view->address.offset);
break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
/* 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,
+ };
+
surface_state =
anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64);
enum isl_format format =
anv_isl_format_for_descriptor_type(desc->type);
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,
- desc->buffer->bo,
- desc->buffer->offset + offset);
+ address.bo, address.offset);
break;
}
: desc->buffer_view->storage_surface_state;
assert(surface_state.alloc_size);
add_surface_state_reloc(cmd_buffer, surface_state,
- desc->buffer_view->bo,
- desc->buffer_view->offset);
+ desc->buffer_view->address.bo,
+ desc->buffer_view->address.offset);
struct brw_image_param *image_param =
&cmd_buffer->state.push_constants[stage]->images[image++];
if (desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) {
read_len = MIN2(range->length,
DIV_ROUND_UP(desc->buffer_view->range, 32) - range->start);
- read_addr = (struct anv_address) {
- .bo = desc->buffer_view->bo,
- .offset = desc->buffer_view->offset +
- range->start * 32,
- };
+ read_addr = anv_address_add(desc->buffer_view->address,
+ range->start * 32);
} else {
assert(desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC);