Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: Categorize error messages #8936

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ vvl_sources = [
"layers/sync/sync_commandbuffer.h",
"layers/sync/sync_common.cpp",
"layers/sync/sync_common.h",
"layers/sync/sync_error_messages.cpp",
"layers/sync/sync_error_messages.h",
"layers/sync/sync_image.h",
"layers/sync/sync_op.cpp",
"layers/sync/sync_op.h",
Expand Down
2 changes: 2 additions & 0 deletions layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ target_sources(vvl PRIVATE
sync/sync_commandbuffer.h
sync/sync_common.cpp
sync/sync_common.h
sync/sync_error_messages.cpp
sync/sync_error_messages.h
sync/sync_image.h
sync/sync_op.cpp
sync/sync_op.h
Expand Down
40 changes: 0 additions & 40 deletions layers/sync/sync_access_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,46 +1037,6 @@ SyncBarrier::SyncBarrier(const std::vector<SyncBarrier> &barriers) : SyncBarrier
Merge(barrier);
}
}
const char *string_SyncHazard(SyncHazard hazard) {
switch (hazard) {
case SyncHazard::NONE:
return "NONE";
break;
case SyncHazard::READ_AFTER_WRITE:
return "READ_AFTER_WRITE";
break;
case SyncHazard::WRITE_AFTER_READ:
return "WRITE_AFTER_READ";
break;
case SyncHazard::WRITE_AFTER_WRITE:
return "WRITE_AFTER_WRITE";
break;
case SyncHazard::READ_RACING_WRITE:
return "READ_RACING_WRITE";
break;
case SyncHazard::WRITE_RACING_WRITE:
return "WRITE_RACING_WRITE";
break;
case SyncHazard::WRITE_RACING_READ:
return "WRITE_RACING_READ";
break;
case SyncHazard::READ_AFTER_PRESENT:
return "READ_AFTER_PRESENT";
break;
case SyncHazard::WRITE_AFTER_PRESENT:
return "WRITE_AFTER_PRESENT";
break;
case SyncHazard::PRESENT_AFTER_WRITE:
return "PRESENT_AFTER_WRITE";
break;
case SyncHazard::PRESENT_AFTER_READ:
return "PRESENT_AFTER_READ";
break;
default:
assert(0);
}
return "INVALID HAZARD";
}

const char *string_SyncHazardVUID(SyncHazard hazard) {
switch (hazard) {
Expand Down
1 change: 0 additions & 1 deletion layers/sync/sync_access_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ enum class SyncOrdering : uint8_t {
kRaster = 3,
kNumOrderings = 4,
};
const char *string_SyncHazard(SyncHazard hazard);
const char *string_SyncHazardVUID(SyncHazard hazard);

class HazardResult {
Expand Down
110 changes: 41 additions & 69 deletions layers/sync/sync_commandbuffer.cpp

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions layers/sync/sync_commandbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

class SyncValidator;

namespace syncval {
class ErrorMessages;
} // namespace syncval

class AlternateResourceUsage {
public:
struct RecordBase;
Expand Down Expand Up @@ -179,8 +183,7 @@ class CommandExecutionContext {
public:
using AccessLog = std::vector<ResourceUsageRecord>;
using CommandBufferSet = std::vector<std::shared_ptr<const vvl::CommandBuffer>>;
CommandExecutionContext(const SyncValidator& sync_validator, VkQueueFlags queue_flags)
: sync_state_(sync_validator), queue_flags_(queue_flags) {}
CommandExecutionContext(const SyncValidator &sync_validator, VkQueueFlags queue_flags);
virtual ~CommandExecutionContext() = default;

// Are imported command buffers Submitted (QueueBatchContext), or Executed (CommandBufferAccessContext)
Expand All @@ -191,11 +194,11 @@ class CommandExecutionContext {

virtual ExecutionType Type() const = 0;

const char *ExecutionTypeString() {
const char *ExecutionTypeString() const {
const char *type_string[] = {"Executed", "Submitted"};
return type_string[Type()];
}
const char *ExecutionUsageString() {
const char *ExecutionUsageString() const {
const char *usage_string[] = {"executed_usage", "submitted_usage"};
return usage_string[Type()];
}
Expand All @@ -214,6 +217,7 @@ class CommandExecutionContext {

protected:
const SyncValidator &sync_state_;
const syncval::ErrorMessages &error_messages_;
const VkQueueFlags queue_flags_;
};

Expand Down
368 changes: 368 additions & 0 deletions layers/sync/sync_error_messages.cpp

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions layers/sync/sync_error_messages.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/* Copyright (c) 2024 The Khronos Group Inc.
* Copyright (c) 2024 Valve Corporation
* Copyright (c) 2024 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include "sync/sync_renderpass.h" // DynamicRenderingInfo::Attachment

#include <vulkan/vulkan.h>
#include <string>

class CommandBufferAccessContext;
class HazardResult;
class QueueBatchContext;
class ValidationObject;

namespace vvl {
class DescriptorSet;
class Pipeline;
} // namespace vvl

namespace syncval {

class ErrorMessages {
public:
ErrorMessages(ValidationObject& validator) : validator_(validator) {}

std::string Error(const HazardResult& hazard, const char* description, const CommandBufferAccessContext& cb_context) const;

std::string BufferError(const HazardResult& hazard, VkBuffer buffer, const char* buffer_description,
const CommandBufferAccessContext& cb_context) const;

std::string BufferRegionError(const HazardResult& hazard, VkBuffer buffer, bool is_src_buffer, uint32_t region_index,
const CommandBufferAccessContext& cb_context) const;

std::string ImageRegionError(const HazardResult& hazard, VkImage image, bool is_src_image, uint32_t region_index,
const CommandBufferAccessContext& cb_context) const;

std::string ImageSubresourceRangeError(const HazardResult& hazard, VkImage image, uint32_t subresource_range_index,
const CommandBufferAccessContext& cb_context) const;

std::string BeginRenderingError(const HazardResult& hazard, const syncval_state::DynamicRenderingInfo::Attachment& attachment,
const CommandBufferAccessContext& cb_context) const;

std::string EndRenderingResolveError(const HazardResult& hazard, const VulkanTypedHandle& image_view_handle,
VkResolveModeFlagBits resolve_mode, const CommandBufferAccessContext& cb_context) const;

std::string EndRenderingStoreError(const HazardResult& hazard, const VulkanTypedHandle& image_view_handle,
VkAttachmentStoreOp store_op, const CommandBufferAccessContext& cb_context) const;

std::string DrawDispatchImageError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const vvl::ImageView& image_view, const vvl::Pipeline& pipeline,
const vvl::DescriptorSet& descriptor_set, VkDescriptorType descriptor_type,
VkImageLayout image_layout, uint32_t descriptor_binding, uint32_t binding_index) const;

std::string DrawDispatchTexelBufferError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const vvl::BufferView& buffer_view, const vvl::Pipeline& pipeline,
const vvl::DescriptorSet& descriptor_set, VkDescriptorType descriptor_type,
uint32_t descriptor_binding, uint32_t binding_index) const;

std::string DrawDispatchBufferError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const vvl::Buffer& buffer, const vvl::Pipeline& pipeline,
const vvl::DescriptorSet& descriptor_set, VkDescriptorType descriptor_type,
uint32_t descriptor_binding, uint32_t binding_index) const;

std::string DrawVertexBufferError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const vvl::Buffer& vertex_buffer) const;

std::string DrawIndexBufferError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const vvl::Buffer& index_buffer) const;

std::string DrawAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const vvl::ImageView& attachment_view) const;

std::string ClearColorAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const std::string& subpass_attachment_info) const;

std::string ClearDepthStencilAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const std::string& subpass_attachment_info, VkImageAspectFlagBits aspect) const;

std::string PipelineBarrierError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
uint32_t image_barrier_index, const vvl::Image& image) const;

std::string WaitEventsError(const HazardResult& hazard, const CommandExecutionContext& exec_context,
uint32_t image_barrier_index, const vvl::Image& image) const;

std::string FirstUseError(const HazardResult& hazard, const CommandExecutionContext& exec_context,
const CommandBufferAccessContext& recorded_context, uint32_t command_buffer_index,
VkCommandBuffer recorded_handle) const;

std::string RenderPassResolveError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, uint32_t subpass,
const char* aspect_name, const char* attachment_name, uint32_t src_attachment,
uint32_t dst_attachment) const;

std::string RenderPassLayoutTransitionVsStoreResolveError(const HazardResult& hazard, uint32_t subpass, uint32_t attachment,
VkImageLayout old_layout, VkImageLayout new_layout,
uint32_t store_resolve_subpass) const;

std::string RenderPassLayoutTransitionError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
uint32_t subpass, uint32_t attachment, VkImageLayout old_layout,
VkImageLayout new_layout) const;

std::string RenderPassLoadOpVsLayoutTransitionError(const HazardResult& hazard, uint32_t subpass, uint32_t attachment,
const char* aspect_name, const char* load_op_name) const;

std::string RenderPassLoadOpError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, uint32_t subpass,
uint32_t attachment, const char* aspect_name, const char* load_op_name) const;

std::string RenderPassStoreOpError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context, uint32_t subpass,
uint32_t attachment, const char* aspect_name, const char* store_op_type_name,
const char* store_op_name) const;

std::string RenderPassColorAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const vvl::ImageView& view, uint32_t attachment) const;

std::string RenderPassDepthStencilAttachmentError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
const vvl::ImageView& view, bool is_depth) const;

std::string RenderPassFinalLayoutTransitionVsStoreResolveError(const HazardResult& hazard,
const CommandBufferAccessContext& cb_context, uint32_t subpass,
uint32_t attachment, VkImageLayout old_layout,
VkImageLayout new_layout) const;

std::string RenderPassFinalLayoutTransitionError(const HazardResult& hazard, const CommandBufferAccessContext& cb_context,
uint32_t subpass, uint32_t attachment, VkImageLayout old_layout,
VkImageLayout new_layout) 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) const;

std::string VideoReferencePictureError(const HazardResult& hazard, uint32_t reference_picture_index,
const CommandBufferAccessContext& cb_context) const;

private:
ValidationObject& validator_;
};

} // namespace syncval
25 changes: 9 additions & 16 deletions layers/sync/sync_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,9 @@ bool SyncOpPipelineBarrier::Validate(const CommandBufferAccessContext &cb_contex
// PHASE1 TODO -- add tag information to log msg when useful.
const Location loc(command_);
const auto &sync_state = cb_context.GetSyncState();
skip |= sync_state.LogError(string_SyncHazardVUID(hazard.Hazard()), image_state->Handle(), loc,
"Hazard %s for image barrier %" PRIu32 " %s. Access info %s.",
string_SyncHazard(hazard.Hazard()), image_barrier.index,
sync_state.FormatHandle(image_state->Handle()).c_str(),
cb_context.FormatHazard(hazard).c_str());
const auto error =
sync_state.error_messages_.PipelineBarrierError(hazard, cb_context, image_barrier.index, *image_state);
skip |= sync_state.SyncError(hazard.Hazard(), image_state->Handle(), loc, error);
}
}
return skip;
Expand Down Expand Up @@ -648,11 +646,9 @@ bool SyncOpWaitEvents::DoValidate(const CommandExecutionContext &exec_context, c
*image_state, subresource_range, sync_event->scope.exec_scope, src_access_scope, queue_id,
sync_event->FirstScope(), sync_event->first_scope_tag, AccessContext::DetectOptions::kDetectAll);
if (hazard.IsHazard()) {
skip |= sync_state.LogError(string_SyncHazardVUID(hazard.Hazard()), image_state->Handle(), loc,
"Hazard %s for image barrier %" PRIu32 " %s. Access info %s.",
string_SyncHazard(hazard.Hazard()), image_memory_barrier.index,
sync_state.FormatHandle(image_state->Handle()).c_str(),
exec_context.FormatHazard(hazard).c_str());
const auto error =
sync_state.error_messages_.WaitEventsError(hazard, exec_context, image_memory_barrier.index, *image_state);
skip |= sync_state.SyncError(hazard.Hazard(), image_state->Handle(), loc, error);
break;
}
}
Expand Down Expand Up @@ -1234,12 +1230,9 @@ bool ReplayState::DetectFirstUseHazard(const ResourceUsageRange &first_use_range
const SyncValidator &sync_state = exec_context_.GetSyncState();
const auto handle = exec_context_.Handle();
const VkCommandBuffer recorded_handle = recorded_context_.GetCBState().VkHandle();
skip |= sync_state.LogError(
string_SyncHazardVUID(hazard.Hazard()), handle, error_obj_.location,
"Hazard %s for entry %" PRIu32 ", %s, %s access info %s. Access info %s.", string_SyncHazard(hazard.Hazard()),
index_, sync_state.FormatHandle(recorded_handle).c_str(), exec_context_.ExecutionTypeString(),
recorded_context_.FormatUsage(exec_context_.ExecutionUsageString(), *hazard.RecordedAccess()).c_str(),
exec_context_.FormatHazard(hazard).c_str());
const auto error =
sync_state.error_messages_.FirstUseError(hazard, exec_context_, recorded_context_, index_, recorded_handle);
skip |= sync_state.SyncError(hazard.Hazard(), handle, error_obj_.location, error);
}
}
return skip;
Expand Down
Loading