Skip to content

Commit

Permalink
sync: Update render pass attachment messages
Browse files Browse the repository at this point in the history
So far simplified form (but with enough information) until this will
be convered by the tests.
  • Loading branch information
artem-lunarg committed Feb 27, 2025
1 parent ee05dcb commit 01707bb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 65 deletions.
49 changes: 6 additions & 43 deletions layers/sync/sync_error_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 3 additions & 6 deletions layers/sync/sync_error_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
53 changes: 37 additions & 16 deletions layers/sync/sync_renderpass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &current_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) {
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -566,21 +587,21 @@ 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) {
HazardResult hazard = current_context.DetectHazard(view_gen, AttachmentViewGen::Gen::kStencilOnlyRenderArea,
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);
}
}
}
Expand Down

0 comments on commit 01707bb

Please sign in to comment.