diff --git a/layers/sync/sync_error_messages.cpp b/layers/sync/sync_error_messages.cpp index 2015ba57cd9..40e1e616631 100644 --- a/layers/sync/sync_error_messages.cpp +++ b/layers/sync/sync_error_messages.cpp @@ -402,6 +402,12 @@ std::string ErrorMessages::ClearAttachmentError(const HazardResult& hazard, cons return Error(hazard, cb_context, command, resource_description, additional_info); } +std::string ErrorMessages::RenderPassAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, + vvl::Func command, const std::string& resource_description) const { + // TODO: revisit error message when this function is covered by the tests. + return Error(hazard, cb_context, command, resource_description); +} + static const char* GetLoadOpActionName(VkAttachmentLoadOp load_op) { if (load_op == VK_ATTACHMENT_LOAD_OP_LOAD) { return "reads"; @@ -624,49 +630,6 @@ std::string ErrorMessages::FirstUseError(const HazardResult& hazard, const Comma return message; } -std::string ErrorMessages::RenderPassColorAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, - const vvl::ImageView& view, uint32_t attachment, - vvl::Func command) const { - const auto format = "Hazard %s for %s in %s, Subpass #%d, and pColorAttachments #%d. Access info %s."; - ReportKeyValues key_values; - - const std::string access_info = cb_context.FormatHazard(hazard, key_values); - std::string message = Format(format, string_SyncHazard(hazard.Hazard()), validator_.FormatHandle(view.Handle()).c_str(), - validator_.FormatHandle(cb_context.GetCBState().Handle()).c_str(), - cb_context.GetCBState().GetActiveSubpass(), attachment, access_info.c_str()); - - if (extra_properties_) { - key_values.Add(kPropertyMessageType, "RenderPassColorAttachmentError"); - key_values.Add(kPropertyHazardType, string_SyncHazard(hazard.Hazard())); - key_values.Add(kPropertyCommand, vvl::String(command)); - AddCbContextExtraProperties(cb_context, hazard.Tag(), key_values); - message += key_values.GetExtraPropertiesSection(pretty_print_extra_); - } - return message; -} - -std::string ErrorMessages::RenderPassDepthStencilAttachmentError(const HazardResult& hazard, - const CommandBufferAccessContext& cb_context, - const vvl::ImageView& view, bool is_depth, - vvl::Func command) const { - const auto format = "Hazard %s for %s in %s, Subpass #%d, and %s part of pDepthStencilAttachment. Access info %s."; - ReportKeyValues key_values; - - const std::string access_info = cb_context.FormatHazard(hazard, key_values); - std::string message = Format(format, string_SyncHazard(hazard.Hazard()), validator_.FormatHandle(view.Handle()).c_str(), - validator_.FormatHandle(cb_context.GetCBState().Handle()).c_str(), - cb_context.GetCBState().GetActiveSubpass(), is_depth ? "depth" : "stencil", access_info.c_str()); - - if (extra_properties_) { - key_values.Add(kPropertyMessageType, "RenderPassDepthStencilAttachmentError"); - key_values.Add(kPropertyHazardType, string_SyncHazard(hazard.Hazard())); - key_values.Add(kPropertyCommand, vvl::String(command)); - AddCbContextExtraProperties(cb_context, hazard.Tag(), key_values); - message += key_values.GetExtraPropertiesSection(pretty_print_extra_); - } - return message; -} - std::string ErrorMessages::PresentError(const HazardResult& hazard, const QueueBatchContext& batch_context, uint32_t present_index, const VulkanTypedHandle& swapchain_handle, uint32_t image_index, const VulkanTypedHandle& image_handle, vvl::Func command) const { diff --git a/layers/sync/sync_error_messages.h b/layers/sync/sync_error_messages.h index e81fa6f668b..a1684b36023 100644 --- a/layers/sync/sync_error_messages.h +++ b/layers/sync/sync_error_messages.h @@ -92,6 +92,9 @@ class ErrorMessages { const std::string& resource_description, VkImageAspectFlagBits aspect, uint32_t clear_rect_index, const VkClearRect& clear_rect) const; + std::string RenderPassAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, + vvl::Func command, const std::string& resource_description) const; + std::string BeginRenderingError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, vvl::Func command, const std::string& resource_description, VkAttachmentLoadOp load_op) const; std::string EndRenderingResolveError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, @@ -138,12 +141,6 @@ class ErrorMessages { const CommandBufferAccessContext& recorded_context, uint32_t command_buffer_index, VkCommandBuffer recorded_handle, vvl::Func command) const; - std::string RenderPassColorAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, - const vvl::ImageView& view, uint32_t attachment, vvl::Func command) const; - - std::string RenderPassDepthStencilAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, - const vvl::ImageView& view, bool is_depth, vvl::Func command) const; - std::string PresentError(const HazardResult& hazard, const QueueBatchContext& batch_context, uint32_t present_index, const VulkanTypedHandle& swapchain_handle, uint32_t image_index, const VulkanTypedHandle& image_handle, vvl::Func command) const; diff --git a/layers/sync/sync_renderpass.cpp b/layers/sync/sync_renderpass.cpp index 50f81973c17..99433bad179 100644 --- a/layers/sync/sync_renderpass.cpp +++ b/layers/sync/sync_renderpass.cpp @@ -510,17 +510,39 @@ void RenderPassAccessContext::RecordLayoutTransitions(const vvl::RenderPass &rp_ // TODO: SyncError reporting places in this function are not covered by the tests. bool RenderPassAccessContext::ValidateDrawSubpassAttachment(const CommandBufferAccessContext &cb_context, vvl::Func command) const { bool skip = false; - const auto &sync_state = cb_context.GetSyncState(); + const auto lv_bind_point = ConvertToLvlBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS); const vvl::CommandBuffer &cmd_buffer = cb_context.GetCBState(); const auto &last_bound_state = cmd_buffer.lastBound[lv_bind_point]; const auto *pipe = last_bound_state.pipeline_state; - if (!pipe || pipe->RasterizationDisabled()) return skip; + + if (!pipe || pipe->RasterizationDisabled()) { + return skip; + } const auto &list = pipe->fragmentShader_writable_output_location_list; const auto &subpass = rp_state_->create_info.pSubpasses[current_subpass_]; - const auto ¤t_context = CurrentContext(); + const auto &sync_state = cb_context.GetSyncState(); + + auto report_atachment_hazard = [&sync_state, &cb_context, command](const HazardResult &hazard, + const vvl::ImageView &attachment_view, + std::string_view attachment_description) { + const vvl::Image &attachment_image = *attachment_view.image_state; + LogObjectList objlist(cb_context.GetCBState().Handle(), attachment_view.Handle(), attachment_image.Handle()); + const Location loc(command); + + std::stringstream ss; + ss << attachment_description; + ss << " (" << sync_state.FormatHandle(attachment_view.Handle()); + ss << ", " << sync_state.FormatHandle(attachment_image.Handle()) << ")"; + const std::string resource_description = ss.str(); + + const std::string error = + sync_state.error_messages_.RenderPassAttachmentError(hazard, cb_context, command, resource_description); + return sync_state.SyncError(hazard.Hazard(), objlist, loc, error); + }; + // Subpass's inputAttachment has been done in ValidateDispatchDrawDescriptorSet if (subpass.pColorAttachments && subpass.colorAttachmentCount && !list.empty()) { for (const auto location : list) { @@ -534,11 +556,10 @@ bool RenderPassAccessContext::ValidateDrawSubpassAttachment(const CommandBufferA current_context.DetectHazard(view_gen, AttachmentViewGen::Gen::kRenderArea, SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_WRITE, SyncOrdering::kColorAttachment); if (hazard.IsHazard()) { - const VkImageView view_handle = view_gen.GetViewState()->VkHandle(); - const Location loc(command); - const auto error = sync_state.error_messages_.RenderPassColorAttachmentError( - hazard, cb_context, *view_gen.GetViewState(), location, command); - skip |= sync_state.SyncError(hazard.Hazard(), view_handle, loc, error); + std::stringstream ss; + ss << "color attachment " << location << " in subpass " << cmd_buffer.GetActiveSubpass(); + const std::string attachment_description = ss.str(); + skip |= report_atachment_hazard(hazard, *view_gen.GetViewState(), attachment_description); } } } @@ -566,10 +587,10 @@ bool RenderPassAccessContext::ValidateDrawSubpassAttachment(const CommandBufferA SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_WRITE, SyncOrdering::kDepthStencilAttachment); if (hazard.IsHazard()) { - const Location loc(command); - const auto error = - sync_state.error_messages_.RenderPassDepthStencilAttachmentError(hazard, cb_context, view_state, true, command); - skip |= sync_state.SyncError(hazard.Hazard(), view_state.Handle(), loc, error); + std::stringstream ss; + ss << "depth aspect of depth-stencil attachment in subpass " << cmd_buffer.GetActiveSubpass(); + const std::string attachment_description = ss.str(); + skip |= report_atachment_hazard(hazard, view_state, attachment_description); } } if (stencil_write) { @@ -577,10 +598,10 @@ bool RenderPassAccessContext::ValidateDrawSubpassAttachment(const CommandBufferA SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_WRITE, SyncOrdering::kDepthStencilAttachment); if (hazard.IsHazard()) { - const Location loc(command); - const auto error = sync_state.error_messages_.RenderPassDepthStencilAttachmentError(hazard, cb_context, view_state, - false, command); - skip |= sync_state.SyncError(hazard.Hazard(), view_state.Handle(), loc, error); + std::stringstream ss; + ss << "stencil aspect of depth-stencil attachment in subpass " << cmd_buffer.GetActiveSubpass(); + const std::string attachment_description = ss.str(); + skip |= report_atachment_hazard(hazard, view_state, attachment_description); } } }