vk: Assert on use of uninitialized surface state
This exposes a case where we want to anv_CmdCopyBufferToImage() on an image that wasn't created with VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT and end up using uninitialized color_rt_surface_state from the meta image view.
This commit is contained in:
@@ -657,6 +657,7 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
||||
const struct anv_image_view *iview =
|
||||
fb->attachments[subpass->color_attachments[a]];
|
||||
|
||||
assert(iview->color_rt_surface_state.alloc_size);
|
||||
bt_map[a] = iview->color_rt_surface_state.offset + state_offset;
|
||||
add_surface_state_reloc(cmd_buffer, iview->color_rt_surface_state,
|
||||
iview->bo, iview->offset);
|
||||
@@ -716,12 +717,14 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||
surface_state = desc->image_view->nonrt_surface_state;
|
||||
assert(surface_state.alloc_size);
|
||||
bo = desc->image_view->bo;
|
||||
bo_offset = desc->image_view->offset;
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: {
|
||||
surface_state = desc->image_view->storage_surface_state;
|
||||
assert(surface_state.alloc_size);
|
||||
bo = desc->image_view->bo;
|
||||
bo_offset = desc->image_view->offset;
|
||||
|
||||
@@ -740,12 +743,14 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||
surface_state = desc->buffer_view->surface_state;
|
||||
assert(surface_state.alloc_size);
|
||||
bo = desc->buffer_view->bo;
|
||||
bo_offset = desc->buffer_view->offset;
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||
surface_state = desc->buffer_view->storage_surface_state;
|
||||
assert(surface_state.alloc_size);
|
||||
bo = desc->buffer_view->bo;
|
||||
bo_offset = desc->buffer_view->offset;
|
||||
|
||||
|
||||
@@ -251,6 +251,8 @@ genX(image_view_init)(struct anv_image_view *iview,
|
||||
|
||||
if (!device->info.has_llc)
|
||||
anv_state_clflush(iview->nonrt_surface_state);
|
||||
} else {
|
||||
iview->nonrt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_color_rt_surface_state) {
|
||||
@@ -271,6 +273,8 @@ genX(image_view_init)(struct anv_image_view *iview,
|
||||
&surface_state);
|
||||
if (!device->info.has_llc)
|
||||
anv_state_clflush(iview->color_rt_surface_state);
|
||||
} else {
|
||||
iview->color_rt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_storage_surface_state) {
|
||||
@@ -287,5 +291,7 @@ genX(image_view_init)(struct anv_image_view *iview,
|
||||
|
||||
GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->storage_surface_state.map,
|
||||
&surface_state);
|
||||
} else {
|
||||
iview->storage_surface_state.alloc_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,6 +310,8 @@ genX(image_view_init)(struct anv_image_view *iview,
|
||||
&surface_state);
|
||||
if (!device->info.has_llc)
|
||||
anv_state_clflush(iview->nonrt_surface_state);
|
||||
} else {
|
||||
iview->nonrt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_color_rt_surface_state) {
|
||||
@@ -329,6 +331,8 @@ genX(image_view_init)(struct anv_image_view *iview,
|
||||
&surface_state);
|
||||
if (!device->info.has_llc)
|
||||
anv_state_clflush(iview->color_rt_surface_state);
|
||||
} else {
|
||||
iview->color_rt_surface_state.alloc_size = 0;
|
||||
}
|
||||
|
||||
if (image->needs_storage_surface_state) {
|
||||
@@ -346,6 +350,8 @@ genX(image_view_init)(struct anv_image_view *iview,
|
||||
|
||||
GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->storage_surface_state.map,
|
||||
&surface_state);
|
||||
} else {
|
||||
iview->storage_surface_state.alloc_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user