From: Kristian Høgsberg Kristensen Date: Sat, 9 Jan 2016 07:43:20 +0000 (-0800) Subject: vk: Assert on use of uninitialized surface state X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bbb2a85c8115bd003639e5e854c0753d613cec95;p=mesa.git 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. --- diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index 5507400c84a..d146f9ac467 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -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; diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c index 257cb35aca9..88598cea18e 100644 --- a/src/vulkan/gen7_state.c +++ b/src/vulkan/gen7_state.c @@ -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; } } diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index c29d100f9f5..13b7e1149d9 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -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; } }