Skip to content

Commit 842995d

Browse files
layers: Improve layout descriptor error messages
1 parent 102c306 commit 842995d

File tree

4 files changed

+39
-41
lines changed

4 files changed

+39
-41
lines changed

layers/core_checks/cc_image_layout.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ bool CoreChecks::VerifyImageLayoutRange(const vvl::CommandBuffer &cb_state, cons
9090
const subresource_adapter::Subresource subresource = image_state.subresource_encoder.Decode(range.begin);
9191
const LogObjectList objlist(cb_state.Handle(), image_state.Handle());
9292
local_skip |= LogError(mismatch_layout_vuid, objlist, loc,
93-
"Cannot use %s (layer=%" PRIu32 " mip=%" PRIu32
93+
"Cannot use %s (layer %" PRIu32 ", mip %" PRIu32
9494
") with specific layout %s that doesn't match the "
9595
"%s layout %s.",
9696
FormatHandle(image_state).c_str(), subresource.arrayLayer, subresource.mipLevel,
@@ -130,22 +130,6 @@ bool CoreChecks::VerifyImageLayoutSubresource(const vvl::CommandBuffer &cb_state
130130
*image_layout_map, std::move(range_gen), loc, vuid, nullptr);
131131
}
132132

133-
bool CoreChecks::VerifyImageLayout(const vvl::CommandBuffer &cb_state, const vvl::ImageView &image_view_state,
134-
VkImageLayout explicit_layout, const Location &loc, const char *mismatch_layout_vuid,
135-
bool *error) const {
136-
if (disabled[image_layout_validation]) {
137-
return false;
138-
}
139-
const auto image_layout_map = cb_state.GetImageLayoutMap(image_view_state.image_state->VkHandle());
140-
if (!image_layout_map) {
141-
return false;
142-
}
143-
144-
return VerifyImageLayoutRange(cb_state, *image_view_state.image_state, image_view_state.create_info.subresourceRange.aspectMask,
145-
explicit_layout, *image_layout_map, RangeGenerator(image_view_state.range_generator), loc,
146-
mismatch_layout_vuid, error);
147-
}
148-
149133
bool CoreChecks::VerifyVideoImageLayout(const vvl::CommandBuffer &cb_state, const vvl::Image &image_state,
150134
const VkImageSubresourceRange &normalized_subresource_range, VkImageLayout explicit_layout,
151135
const Location &loc, const char *mismatch_layout_vuid, bool *error) const {

layers/core_checks/core_validation.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,17 +1082,13 @@ class CoreChecks : public vvl::DeviceProxy {
10821082
bool VerifyImageLayoutRange(const vvl::CommandBuffer& cb_state, const vvl::Image& image_state, VkImageAspectFlags aspect_mask,
10831083
VkImageLayout explicit_layout, const CommandBufferImageLayoutMap& cb_layout_map,
10841084
subresource_adapter::RangeGenerator&& range_gen, const Location& image_loc,
1085-
const char* mismatch_layout_vuid, bool* error) const;
1085+
const char* mismatch_layout_vuid, bool* error) const override;
10861086

10871087
// NOTE: depth_offset/depth_extent parameters are used to support per-slice image layout transitions in 3d image
10881088
bool VerifyImageLayoutSubresource(const vvl::CommandBuffer& cb_state, const vvl::Image& image_state,
10891089
const VkImageSubresourceLayers& subLayers, int32_t depth_offset, uint32_t depth_extent,
10901090
VkImageLayout explicit_layout, const Location& image_loc, const char* vuid) const;
10911091

1092-
bool VerifyImageLayout(const vvl::CommandBuffer& cb_state, const vvl::ImageView& image_view_state,
1093-
VkImageLayout explicit_layout, const Location& image_loc, const char* mismatch_layout_vuid,
1094-
bool* error) const override;
1095-
10961092
bool VerifyVideoImageLayout(const vvl::CommandBuffer& cb_state, const vvl::Image& image_state,
10971093
const VkImageSubresourceRange& normalized_subresource_range, VkImageLayout explicit_layout,
10981094
const Location& image_loc, const char* mismatch_layout_vuid, bool* error) const;

layers/drawdispatch/descriptor_validator.cpp

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ std::string DescriptorValidator::DescribeDescriptor(const spirv::ResourceInterfa
102102
break;
103103
}
104104

105-
ss << "descriptor [" << FormatHandle(descriptor_set.Handle()) << ", Set " << set_index << ", Binding "
106-
<< resource_variable.decorations.binding << ", Index " << index;
105+
ss << "descriptor [";
106+
if (!descriptor_set.IsPushDescriptor()) {
107+
ss << FormatHandle(descriptor_set.Handle()) << ", ";
108+
}
109+
ss << "Set " << set_index << ", Binding " << resource_variable.decorations.binding << ", Index " << index;
107110

108111
// If multiple variables tied to a binding, don't attempt to detect which one
109112
if (!resource_variable.debug_name.empty()) {
@@ -534,21 +537,28 @@ bool DescriptorValidator::ValidateDescriptor(const spirv::ResourceInterfaceVaria
534537
// Verify Image Layout
535538
// No "invalid layout" VUID required for this call, since the optimal_layout parameter is UNDEFINED.
536539
bool hit_error = false;
537-
dev_proxy.VerifyImageLayout(cb_state, *image_view_state, image_layout, loc.Get(),
538-
"VUID-VkDescriptorImageInfo-imageLayout-00344", &hit_error);
539-
if (hit_error) {
540-
std::stringstream msg;
541-
if (!descriptor_set.IsPushDescriptor()) {
542-
msg << "Descriptor set " << FormatHandle(descriptor_set.Handle())
543-
<< " Image layout specified by vkCmdBindDescriptorSets doesn't match actual image layout at time "
544-
"descriptor is used.";
545-
} else {
546-
msg << "Image layout specified by vkCmdPushDescriptorSet doesn't match actual image layout at time "
547-
"descriptor is used.";
540+
if (const auto image_layout_map = cb_state.GetImageLayoutMap(image_state->VkHandle())) {
541+
dev_proxy.VerifyImageLayoutRange(cb_state, *image_state, image_view_state->create_info.subresourceRange.aspectMask,
542+
image_layout, *image_layout_map,
543+
subresource_adapter::RangeGenerator(image_view_state->range_generator), loc.Get(),
544+
"VUID-VkDescriptorImageInfo-imageLayout-00344", &hit_error);
545+
546+
if (hit_error) {
547+
std::stringstream msg;
548+
if (!descriptor_set.IsPushDescriptor()) {
549+
msg << "Descriptor set " << FormatHandle(descriptor_set.Handle())
550+
<< " Image layout specified by vkCmdBindDescriptorSets ";
551+
} else {
552+
msg << "Image layout specified by vkCmdPushDescriptorSet ";
553+
}
554+
msg << "doesn't match actual image layout at time descriptor ("
555+
<< DescribeDescriptor(resource_variable, index, descriptor_type) << ") is used.";
556+
// TODO - This is bad, VerifyImageLayoutRange should be able to return a bool (or pass info into it) and only have a
557+
// single VU here https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/10730
558+
msg << " See previous error callback for specific details." << DescribeInstruction();
559+
const LogObjectList objlist(cb_state.Handle(), this->objlist, descriptor_set.Handle(), image_view);
560+
skip |= LogError(vuids->descriptor_buffer_bit_set_08114, objlist, loc.Get(), "%s.", msg.str().c_str());
548561
}
549-
msg << " See previous error callback for specific details." << DescribeInstruction();
550-
const LogObjectList objlist(cb_state.Handle(), this->objlist, descriptor_set.Handle(), image_view);
551-
skip |= LogError(vuids->descriptor_buffer_bit_set_08114, objlist, loc.Get(), "%s.", msg.str().c_str());
552562
}
553563
}
554564

layers/state_tracker/state_tracker.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ namespace spirv {
9191
struct StatelessData;
9292
} // namespace spirv
9393

94+
namespace subresource_adapter {
95+
class RangeGenerator;
96+
} // namespace subresource_adapter
97+
98+
class CommandBufferImageLayoutMap;
99+
94100
#define VALSTATETRACK_MAP_AND_TRAITS(handle_type, state_type, map_member) \
95101
vvl::concurrent_unordered_map<handle_type, std::shared_ptr<state_type>> map_member; \
96102
template <typename Dummy> \
@@ -2191,9 +2197,11 @@ class DeviceProxy : public vvl::base::Device {
21912197
}
21922198

21932199
// Currently no GPU-AV check
2194-
virtual bool VerifyImageLayout(const vvl::CommandBuffer& cb_state, const vvl::ImageView& image_view_state,
2195-
VkImageLayout explicit_layout, const Location& image_loc, const char* mismatch_layout_vuid,
2196-
bool* error) const {
2200+
virtual bool VerifyImageLayoutRange(const vvl::CommandBuffer& cb_state, const vvl::Image& image_state,
2201+
VkImageAspectFlags aspect_mask, VkImageLayout explicit_layout,
2202+
const CommandBufferImageLayoutMap& cb_layout_map,
2203+
subresource_adapter::RangeGenerator&& range_gen, const Location& image_loc,
2204+
const char* mismatch_layout_vuid, bool* error) const {
21972205
return false;
21982206
}
21992207

0 commit comments

Comments
 (0)