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

layers: Remove duplicate DescriptorSetLayoutDef compare #8842

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
35 changes: 0 additions & 35 deletions layers/state_tracker/descriptor_sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,41 +184,6 @@ DescriptorSetLayoutId GetCanonicalId(const VkDescriptorSetLayoutCreateInfo *p_cr
return descriptor_set_layout_dict.LookUp(DescriptorSetLayoutDef(p_create_info));
}

bool operator==(const DescriptorSetLayoutDef &lhs, const DescriptorSetLayoutDef &rhs) {
// trivial types
if ((lhs.GetCreateFlags() != rhs.GetCreateFlags()) || (lhs.GetBindingFlags() != rhs.GetBindingFlags())) {
return false;
}
// vectors of enums
if (lhs.GetMutableTypes() != rhs.GetMutableTypes()) {
return false;
}
// vectors of vku::safe_VkDescriptorSetLayoutBinding structures
const auto &lhs_bindings = lhs.GetBindings();
const auto &rhs_bindings = rhs.GetBindings();
if (lhs_bindings.size() != rhs_bindings.size()) {
return false;
}
for (size_t i = 0; i < lhs_bindings.size(); i++) {
const auto &l = lhs_bindings[i];
const auto &r = rhs_bindings[i];
// For things where we are comparing with the bound pipeline, the binding will always be right, but when comparing two
// arbitrary layouts (ex. templates, Device Generated Commands, etc) the bindings might be different
if (l.binding != r.binding) {
return false;
}
if (l.descriptorType != r.descriptorType || l.descriptorCount != r.descriptorCount || l.stageFlags != r.stageFlags) {
return false;
}
for (uint32_t s = 0; s < l.descriptorCount; s++) {
if (l.pImmutableSamplers[s] != r.pImmutableSamplers[s]) {
return false;
}
}
}
return true;
}

std::string DescriptorSetLayoutDef::DescribeDifference(uint32_t index, const DescriptorSetLayoutDef &other) const {
std::ostringstream ss;
ss << "Set " << index << " ";
Expand Down
22 changes: 12 additions & 10 deletions layers/state_tracker/descriptor_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ class DescriptorSetLayoutDef {
using DescriptorSetLayoutDict = hash_util::Dictionary<DescriptorSetLayoutDef, hash_util::HasHashMember<DescriptorSetLayoutDef>>;
using DescriptorSetLayoutId = DescriptorSetLayoutDict::Id;

// Compare is in header and static because hash_util KeyValueEqual need the symbol at compile time
//
// https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/8497
// This just checks pointers, but two different VkSampler handles could be created with same createInfo.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the comment seems out of place now

// Since this is rare enough, mark as "not the same" and check later when checking for compatibility.
static inline bool operator==(const DescriptorSetLayoutDef &lhs, const DescriptorSetLayoutDef &rhs) {
// trivial types
if ((lhs.GetCreateFlags() != rhs.GetCreateFlags()) || (lhs.GetBindingFlags() != rhs.GetBindingFlags())) {
Expand All @@ -265,20 +270,17 @@ static inline bool operator==(const DescriptorSetLayoutDef &lhs, const Descripto
for (size_t i = 0; i < lhs_bindings.size(); i++) {
const auto &l = lhs_bindings[i];
const auto &r = rhs_bindings[i];
if (l.descriptorType != r.descriptorType || l.descriptorCount != r.descriptorCount || l.stageFlags != r.stageFlags) {
// For things where we are comparing with the bound pipeline, the binding will always be right, but when comparing two
// arbitrary layouts (ex. templates, Device Generated Commands, etc) the bindings might be different
if (l.binding != r.binding) {
return false;
}
if (l.pImmutableSamplers != r.pImmutableSamplers) {
if (l.descriptorType != r.descriptorType || l.descriptorCount != r.descriptorCount || l.stageFlags != r.stageFlags) {
return false;
}
if (l.pImmutableSamplers) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you still need to check for l.pImmutableSamplers and r.l.pImmutableSamplers to be non null it seems

for (uint32_t s = 0; s < l.descriptorCount; s++) {
if (l.pImmutableSamplers[s] != r.pImmutableSamplers[s]) {
// https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/8497
// This just checks pointers, but two different VkSampler handles could be created with same createInfo.
// Since this is rare enough, mark as "not the same" and check later when checking for compatibility.
return false;
}
for (uint32_t s = 0; s < l.descriptorCount; s++) {
if (l.pImmutableSamplers[s] != r.pImmutableSamplers[s]) {
return false; // only checking pointers
}
}
}
Expand Down
Loading