Skip to content

Commit 90e622d

Browse files
Merge pull request #1435 from AnyOldName3/partial-compatibility
Partial compatibility
2 parents 222b713 + 94fa9b7 commit 90e622d

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

include/vsg/state/PipelineLayout.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ namespace vsg
4343
void release(uint32_t deviceID) { _implementation[deviceID] = {}; }
4444
void release() { _implementation.clear(); }
4545

46+
// returns whether the layouts are push-constant-compatible and the lowest N for which the layouts are not compatible for descriptor set N
47+
std::pair<bool, uint32_t> computeCompatibility(const PipelineLayout& other);
48+
4649
public:
4750
ref_ptr<Object> clone(const CopyOp& copyop = {}) const override { return PipelineLayout::create(*this, copyop); }
4851
int compare(const Object& rhs) const override;

src/vsg/state/PipelineLayout.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ PipelineLayout::~PipelineLayout()
4545
{
4646
}
4747

48+
std::pair<bool, uint32_t> vsg::PipelineLayout::computeCompatibility(const PipelineLayout& other)
49+
{
50+
auto result = std::make_pair<bool, uint32_t>(compare_value_container(pushConstantRanges, other.pushConstantRanges) == 0, 0);
51+
if (!result.first)
52+
return result;
53+
#ifdef VK_EXT_graphics_pipeline_library
54+
if ((flags & VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT) != (other.flags & VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT))
55+
return result;
56+
#endif
57+
for (result.second = 0; result.second < std::min(setLayouts.size(), other.setLayouts.size()); ++result.second)
58+
{
59+
// if this is a partial layout for a graphics pipeline library, it may be made compatible later
60+
if (!setLayouts[result.second] || !other.setLayouts[result.second])
61+
continue;
62+
if (compare_value_container(setLayouts[result.second]->bindings, other.setLayouts[result.second]->bindings) != 0)
63+
break;
64+
}
65+
return result;
66+
}
67+
4868
int PipelineLayout::compare(const Object& rhs_object) const
4969
{
5070
int result = Object::compare(rhs_object);

0 commit comments

Comments
 (0)