anv/cmd_buffer: Refactor surface state relocation handling

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
This commit is contained in:
Jason Ekstrand
2016-10-24 19:25:20 -07:00
parent 9be9f5f1c7
commit 818c7bfb31

View File

@@ -162,6 +162,18 @@ add_surface_state_reloc(struct anv_cmd_buffer *cmd_buffer,
state.offset + isl_dev->ss.addr_offset, bo, offset); state.offset + isl_dev->ss.addr_offset, bo, offset);
} }
static void
add_image_view_relocs(struct anv_cmd_buffer *cmd_buffer,
const struct anv_image_view *iview,
struct anv_state state)
{
const struct isl_device *isl_dev = &cmd_buffer->device->isl_dev;
anv_reloc_list_add(&cmd_buffer->surface_relocs, &cmd_buffer->pool->alloc,
state.offset + isl_dev->ss.addr_offset,
iview->bo, iview->offset);
}
/** /**
* Setup anv_cmd_state::attachments for vkCmdBeginRenderPass. * Setup anv_cmd_state::attachments for vkCmdBeginRenderPass.
*/ */
@@ -289,8 +301,8 @@ genX(cmd_buffer_setup_attachments)(struct anv_cmd_buffer *cmd_buffer,
.view = &view, .view = &view,
.mocs = cmd_buffer->device->default_mocs); .mocs = cmd_buffer->device->default_mocs);
add_surface_state_reloc(cmd_buffer, add_image_view_relocs(cmd_buffer, iview,
state->attachments[i].color_rt_state, iview->bo, iview->offset); state->attachments[i].color_rt_state);
} }
} }
@@ -858,8 +870,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
struct anv_pipeline_binding *binding = &map->surface_to_descriptor[s]; struct anv_pipeline_binding *binding = &map->surface_to_descriptor[s];
struct anv_state surface_state; struct anv_state surface_state;
struct anv_bo *bo;
uint32_t bo_offset;
if (binding->set == ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS) { if (binding->set == ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS) {
/* Color attachment binding */ /* Color attachment binding */
@@ -891,15 +901,13 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
surface_state = desc->image_view->sampler_surface_state; surface_state = desc->image_view->sampler_surface_state;
assert(surface_state.alloc_size); assert(surface_state.alloc_size);
bo = desc->image_view->bo; add_image_view_relocs(cmd_buffer, desc->image_view, surface_state);
bo_offset = desc->image_view->offset;
break; break;
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: { case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: {
surface_state = desc->image_view->storage_surface_state; surface_state = desc->image_view->storage_surface_state;
assert(surface_state.alloc_size); assert(surface_state.alloc_size);
bo = desc->image_view->bo; add_image_view_relocs(cmd_buffer, desc->image_view, surface_state);
bo_offset = desc->image_view->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++];
@@ -916,15 +924,17 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_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);
bo = desc->buffer_view->bo; add_surface_state_reloc(cmd_buffer, surface_state,
bo_offset = desc->buffer_view->offset; desc->buffer_view->bo,
desc->buffer_view->offset);
break; break;
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
surface_state = desc->buffer_view->storage_surface_state; surface_state = desc->buffer_view->storage_surface_state;
assert(surface_state.alloc_size); assert(surface_state.alloc_size);
bo = desc->buffer_view->bo; add_surface_state_reloc(cmd_buffer, surface_state,
bo_offset = desc->buffer_view->offset; desc->buffer_view->bo,
desc->buffer_view->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++];
@@ -939,7 +949,6 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
} }
bt_map[bias + s] = surface_state.offset + state_offset; bt_map[bias + s] = surface_state.offset + state_offset;
add_surface_state_reloc(cmd_buffer, surface_state, bo, bo_offset);
} }
assert(image == map->image_count); assert(image == map->image_count);