safe: Fix VK_EXT_sample_locations

This commit is contained in:
sjfricke 2024-09-09 14:47:19 -07:00 committed by Spencer Fricke
parent fbb4db92c6
commit ea5774a13e
3 changed files with 153 additions and 52 deletions

View file

@ -10301,13 +10301,41 @@ struct safe_VkSampleLocationsInfoEXT {
VkSampleLocationsInfoEXT* ptr() { return reinterpret_cast<VkSampleLocationsInfoEXT*>(this); } VkSampleLocationsInfoEXT* ptr() { return reinterpret_cast<VkSampleLocationsInfoEXT*>(this); }
VkSampleLocationsInfoEXT const* ptr() const { return reinterpret_cast<VkSampleLocationsInfoEXT const*>(this); } VkSampleLocationsInfoEXT const* ptr() const { return reinterpret_cast<VkSampleLocationsInfoEXT const*>(this); }
}; };
struct safe_VkAttachmentSampleLocationsEXT {
uint32_t attachmentIndex;
safe_VkSampleLocationsInfoEXT sampleLocationsInfo;
safe_VkAttachmentSampleLocationsEXT(const VkAttachmentSampleLocationsEXT* in_struct, PNextCopyState* copy_state = {});
safe_VkAttachmentSampleLocationsEXT(const safe_VkAttachmentSampleLocationsEXT& copy_src);
safe_VkAttachmentSampleLocationsEXT& operator=(const safe_VkAttachmentSampleLocationsEXT& copy_src);
safe_VkAttachmentSampleLocationsEXT();
~safe_VkAttachmentSampleLocationsEXT();
void initialize(const VkAttachmentSampleLocationsEXT* in_struct, PNextCopyState* copy_state = {});
void initialize(const safe_VkAttachmentSampleLocationsEXT* copy_src, PNextCopyState* copy_state = {});
VkAttachmentSampleLocationsEXT* ptr() { return reinterpret_cast<VkAttachmentSampleLocationsEXT*>(this); }
VkAttachmentSampleLocationsEXT const* ptr() const { return reinterpret_cast<VkAttachmentSampleLocationsEXT const*>(this); }
};
struct safe_VkSubpassSampleLocationsEXT {
uint32_t subpassIndex;
safe_VkSampleLocationsInfoEXT sampleLocationsInfo;
safe_VkSubpassSampleLocationsEXT(const VkSubpassSampleLocationsEXT* in_struct, PNextCopyState* copy_state = {});
safe_VkSubpassSampleLocationsEXT(const safe_VkSubpassSampleLocationsEXT& copy_src);
safe_VkSubpassSampleLocationsEXT& operator=(const safe_VkSubpassSampleLocationsEXT& copy_src);
safe_VkSubpassSampleLocationsEXT();
~safe_VkSubpassSampleLocationsEXT();
void initialize(const VkSubpassSampleLocationsEXT* in_struct, PNextCopyState* copy_state = {});
void initialize(const safe_VkSubpassSampleLocationsEXT* copy_src, PNextCopyState* copy_state = {});
VkSubpassSampleLocationsEXT* ptr() { return reinterpret_cast<VkSubpassSampleLocationsEXT*>(this); }
VkSubpassSampleLocationsEXT const* ptr() const { return reinterpret_cast<VkSubpassSampleLocationsEXT const*>(this); }
};
struct safe_VkRenderPassSampleLocationsBeginInfoEXT { struct safe_VkRenderPassSampleLocationsBeginInfoEXT {
VkStructureType sType; VkStructureType sType;
const void* pNext{}; const void* pNext{};
uint32_t attachmentInitialSampleLocationsCount; uint32_t attachmentInitialSampleLocationsCount;
const VkAttachmentSampleLocationsEXT* pAttachmentInitialSampleLocations{}; safe_VkAttachmentSampleLocationsEXT* pAttachmentInitialSampleLocations{};
uint32_t postSubpassSampleLocationsCount; uint32_t postSubpassSampleLocationsCount;
const VkSubpassSampleLocationsEXT* pPostSubpassSampleLocations{}; safe_VkSubpassSampleLocationsEXT* pPostSubpassSampleLocations{};
safe_VkRenderPassSampleLocationsBeginInfoEXT(const VkRenderPassSampleLocationsBeginInfoEXT* in_struct, safe_VkRenderPassSampleLocationsBeginInfoEXT(const VkRenderPassSampleLocationsBeginInfoEXT* in_struct,
PNextCopyState* copy_state = {}, bool copy_pnext = true); PNextCopyState* copy_state = {}, bool copy_pnext = true);

View file

@ -107,6 +107,9 @@ class SafeStructOutputGenerator(BaseGenerator):
for member in struct.members: for member in struct.members:
if member.pointer: if member.pointer:
return True return True
# The VK_EXT_sample_locations design created edge case, easiest to handle here
if struct.name == 'VkAttachmentSampleLocationsEXT' or struct.name == 'VkSubpassSampleLocationsEXT':
return True
return False return False
def containsObjectHandle(self, member: Member) -> bool: def containsObjectHandle(self, member: Member) -> bool:
@ -170,7 +173,7 @@ class SafeStructOutputGenerator(BaseGenerator):
#include <vulkan/utility/vk_safe_struct_utils.hpp> #include <vulkan/utility/vk_safe_struct_utils.hpp>
namespace vku { namespace vku {
// Mapping of unknown stype codes to structure lengths. This should be set up by the application // Mapping of unknown stype codes to structure lengths. This should be set up by the application
// before vkCreateInstance() and not modified afterwards. // before vkCreateInstance() and not modified afterwards.
std::vector<std::pair<uint32_t, uint32_t>>& GetCustomStypeInfo(); std::vector<std::pair<uint32_t, uint32_t>>& GetCustomStypeInfo();

View file

@ -2688,6 +2688,75 @@ void safe_VkSampleLocationsInfoEXT::initialize(const safe_VkSampleLocationsInfoE
} }
} }
safe_VkAttachmentSampleLocationsEXT::safe_VkAttachmentSampleLocationsEXT(const VkAttachmentSampleLocationsEXT* in_struct,
[[maybe_unused]] PNextCopyState* copy_state)
: attachmentIndex(in_struct->attachmentIndex), sampleLocationsInfo(&in_struct->sampleLocationsInfo) {}
safe_VkAttachmentSampleLocationsEXT::safe_VkAttachmentSampleLocationsEXT() : attachmentIndex() {}
safe_VkAttachmentSampleLocationsEXT::safe_VkAttachmentSampleLocationsEXT(const safe_VkAttachmentSampleLocationsEXT& copy_src) {
attachmentIndex = copy_src.attachmentIndex;
sampleLocationsInfo.initialize(&copy_src.sampleLocationsInfo);
}
safe_VkAttachmentSampleLocationsEXT& safe_VkAttachmentSampleLocationsEXT::operator=(
const safe_VkAttachmentSampleLocationsEXT& copy_src) {
if (&copy_src == this) return *this;
attachmentIndex = copy_src.attachmentIndex;
sampleLocationsInfo.initialize(&copy_src.sampleLocationsInfo);
return *this;
}
safe_VkAttachmentSampleLocationsEXT::~safe_VkAttachmentSampleLocationsEXT() {}
void safe_VkAttachmentSampleLocationsEXT::initialize(const VkAttachmentSampleLocationsEXT* in_struct,
[[maybe_unused]] PNextCopyState* copy_state) {
attachmentIndex = in_struct->attachmentIndex;
sampleLocationsInfo.initialize(&in_struct->sampleLocationsInfo);
}
void safe_VkAttachmentSampleLocationsEXT::initialize(const safe_VkAttachmentSampleLocationsEXT* copy_src,
[[maybe_unused]] PNextCopyState* copy_state) {
attachmentIndex = copy_src->attachmentIndex;
sampleLocationsInfo.initialize(&copy_src->sampleLocationsInfo);
}
safe_VkSubpassSampleLocationsEXT::safe_VkSubpassSampleLocationsEXT(const VkSubpassSampleLocationsEXT* in_struct,
[[maybe_unused]] PNextCopyState* copy_state)
: subpassIndex(in_struct->subpassIndex), sampleLocationsInfo(&in_struct->sampleLocationsInfo) {}
safe_VkSubpassSampleLocationsEXT::safe_VkSubpassSampleLocationsEXT() : subpassIndex() {}
safe_VkSubpassSampleLocationsEXT::safe_VkSubpassSampleLocationsEXT(const safe_VkSubpassSampleLocationsEXT& copy_src) {
subpassIndex = copy_src.subpassIndex;
sampleLocationsInfo.initialize(&copy_src.sampleLocationsInfo);
}
safe_VkSubpassSampleLocationsEXT& safe_VkSubpassSampleLocationsEXT::operator=(const safe_VkSubpassSampleLocationsEXT& copy_src) {
if (&copy_src == this) return *this;
subpassIndex = copy_src.subpassIndex;
sampleLocationsInfo.initialize(&copy_src.sampleLocationsInfo);
return *this;
}
safe_VkSubpassSampleLocationsEXT::~safe_VkSubpassSampleLocationsEXT() {}
void safe_VkSubpassSampleLocationsEXT::initialize(const VkSubpassSampleLocationsEXT* in_struct,
[[maybe_unused]] PNextCopyState* copy_state) {
subpassIndex = in_struct->subpassIndex;
sampleLocationsInfo.initialize(&in_struct->sampleLocationsInfo);
}
void safe_VkSubpassSampleLocationsEXT::initialize(const safe_VkSubpassSampleLocationsEXT* copy_src,
[[maybe_unused]] PNextCopyState* copy_state) {
subpassIndex = copy_src->subpassIndex;
sampleLocationsInfo.initialize(&copy_src->sampleLocationsInfo);
}
safe_VkRenderPassSampleLocationsBeginInfoEXT::safe_VkRenderPassSampleLocationsBeginInfoEXT( safe_VkRenderPassSampleLocationsBeginInfoEXT::safe_VkRenderPassSampleLocationsBeginInfoEXT(
const VkRenderPassSampleLocationsBeginInfoEXT* in_struct, [[maybe_unused]] PNextCopyState* copy_state, bool copy_pnext) const VkRenderPassSampleLocationsBeginInfoEXT* in_struct, [[maybe_unused]] PNextCopyState* copy_state, bool copy_pnext)
: sType(in_struct->sType), : sType(in_struct->sType),
@ -2698,16 +2767,17 @@ safe_VkRenderPassSampleLocationsBeginInfoEXT::safe_VkRenderPassSampleLocationsBe
if (copy_pnext) { if (copy_pnext) {
pNext = SafePnextCopy(in_struct->pNext, copy_state); pNext = SafePnextCopy(in_struct->pNext, copy_state);
} }
if (in_struct->pAttachmentInitialSampleLocations) { if (attachmentInitialSampleLocationsCount && in_struct->pAttachmentInitialSampleLocations) {
pAttachmentInitialSampleLocations = new VkAttachmentSampleLocationsEXT[in_struct->attachmentInitialSampleLocationsCount]; pAttachmentInitialSampleLocations = new safe_VkAttachmentSampleLocationsEXT[attachmentInitialSampleLocationsCount];
memcpy((void*)pAttachmentInitialSampleLocations, (void*)in_struct->pAttachmentInitialSampleLocations, for (uint32_t i = 0; i < attachmentInitialSampleLocationsCount; ++i) {
sizeof(VkAttachmentSampleLocationsEXT) * in_struct->attachmentInitialSampleLocationsCount); pAttachmentInitialSampleLocations[i].initialize(&in_struct->pAttachmentInitialSampleLocations[i]);
}
} }
if (postSubpassSampleLocationsCount && in_struct->pPostSubpassSampleLocations) {
if (in_struct->pPostSubpassSampleLocations) { pPostSubpassSampleLocations = new safe_VkSubpassSampleLocationsEXT[postSubpassSampleLocationsCount];
pPostSubpassSampleLocations = new VkSubpassSampleLocationsEXT[in_struct->postSubpassSampleLocationsCount]; for (uint32_t i = 0; i < postSubpassSampleLocationsCount; ++i) {
memcpy((void*)pPostSubpassSampleLocations, (void*)in_struct->pPostSubpassSampleLocations, pPostSubpassSampleLocations[i].initialize(&in_struct->pPostSubpassSampleLocations[i]);
sizeof(VkSubpassSampleLocationsEXT) * in_struct->postSubpassSampleLocationsCount); }
} }
} }
@ -2727,17 +2797,17 @@ safe_VkRenderPassSampleLocationsBeginInfoEXT::safe_VkRenderPassSampleLocationsBe
postSubpassSampleLocationsCount = copy_src.postSubpassSampleLocationsCount; postSubpassSampleLocationsCount = copy_src.postSubpassSampleLocationsCount;
pPostSubpassSampleLocations = nullptr; pPostSubpassSampleLocations = nullptr;
pNext = SafePnextCopy(copy_src.pNext); pNext = SafePnextCopy(copy_src.pNext);
if (attachmentInitialSampleLocationsCount && copy_src.pAttachmentInitialSampleLocations) {
if (copy_src.pAttachmentInitialSampleLocations) { pAttachmentInitialSampleLocations = new safe_VkAttachmentSampleLocationsEXT[attachmentInitialSampleLocationsCount];
pAttachmentInitialSampleLocations = new VkAttachmentSampleLocationsEXT[copy_src.attachmentInitialSampleLocationsCount]; for (uint32_t i = 0; i < attachmentInitialSampleLocationsCount; ++i) {
memcpy((void*)pAttachmentInitialSampleLocations, (void*)copy_src.pAttachmentInitialSampleLocations, pAttachmentInitialSampleLocations[i].initialize(&copy_src.pAttachmentInitialSampleLocations[i]);
sizeof(VkAttachmentSampleLocationsEXT) * copy_src.attachmentInitialSampleLocationsCount); }
} }
if (postSubpassSampleLocationsCount && copy_src.pPostSubpassSampleLocations) {
if (copy_src.pPostSubpassSampleLocations) { pPostSubpassSampleLocations = new safe_VkSubpassSampleLocationsEXT[postSubpassSampleLocationsCount];
pPostSubpassSampleLocations = new VkSubpassSampleLocationsEXT[copy_src.postSubpassSampleLocationsCount]; for (uint32_t i = 0; i < postSubpassSampleLocationsCount; ++i) {
memcpy((void*)pPostSubpassSampleLocations, (void*)copy_src.pPostSubpassSampleLocations, pPostSubpassSampleLocations[i].initialize(&copy_src.pPostSubpassSampleLocations[i]);
sizeof(VkSubpassSampleLocationsEXT) * copy_src.postSubpassSampleLocationsCount); }
} }
} }
@ -2755,17 +2825,17 @@ safe_VkRenderPassSampleLocationsBeginInfoEXT& safe_VkRenderPassSampleLocationsBe
postSubpassSampleLocationsCount = copy_src.postSubpassSampleLocationsCount; postSubpassSampleLocationsCount = copy_src.postSubpassSampleLocationsCount;
pPostSubpassSampleLocations = nullptr; pPostSubpassSampleLocations = nullptr;
pNext = SafePnextCopy(copy_src.pNext); pNext = SafePnextCopy(copy_src.pNext);
if (attachmentInitialSampleLocationsCount && copy_src.pAttachmentInitialSampleLocations) {
if (copy_src.pAttachmentInitialSampleLocations) { pAttachmentInitialSampleLocations = new safe_VkAttachmentSampleLocationsEXT[attachmentInitialSampleLocationsCount];
pAttachmentInitialSampleLocations = new VkAttachmentSampleLocationsEXT[copy_src.attachmentInitialSampleLocationsCount]; for (uint32_t i = 0; i < attachmentInitialSampleLocationsCount; ++i) {
memcpy((void*)pAttachmentInitialSampleLocations, (void*)copy_src.pAttachmentInitialSampleLocations, pAttachmentInitialSampleLocations[i].initialize(&copy_src.pAttachmentInitialSampleLocations[i]);
sizeof(VkAttachmentSampleLocationsEXT) * copy_src.attachmentInitialSampleLocationsCount); }
} }
if (postSubpassSampleLocationsCount && copy_src.pPostSubpassSampleLocations) {
if (copy_src.pPostSubpassSampleLocations) { pPostSubpassSampleLocations = new safe_VkSubpassSampleLocationsEXT[postSubpassSampleLocationsCount];
pPostSubpassSampleLocations = new VkSubpassSampleLocationsEXT[copy_src.postSubpassSampleLocationsCount]; for (uint32_t i = 0; i < postSubpassSampleLocationsCount; ++i) {
memcpy((void*)pPostSubpassSampleLocations, (void*)copy_src.pPostSubpassSampleLocations, pPostSubpassSampleLocations[i].initialize(&copy_src.pPostSubpassSampleLocations[i]);
sizeof(VkSubpassSampleLocationsEXT) * copy_src.postSubpassSampleLocationsCount); }
} }
return *this; return *this;
@ -2788,17 +2858,17 @@ void safe_VkRenderPassSampleLocationsBeginInfoEXT::initialize(const VkRenderPass
postSubpassSampleLocationsCount = in_struct->postSubpassSampleLocationsCount; postSubpassSampleLocationsCount = in_struct->postSubpassSampleLocationsCount;
pPostSubpassSampleLocations = nullptr; pPostSubpassSampleLocations = nullptr;
pNext = SafePnextCopy(in_struct->pNext, copy_state); pNext = SafePnextCopy(in_struct->pNext, copy_state);
if (attachmentInitialSampleLocationsCount && in_struct->pAttachmentInitialSampleLocations) {
if (in_struct->pAttachmentInitialSampleLocations) { pAttachmentInitialSampleLocations = new safe_VkAttachmentSampleLocationsEXT[attachmentInitialSampleLocationsCount];
pAttachmentInitialSampleLocations = new VkAttachmentSampleLocationsEXT[in_struct->attachmentInitialSampleLocationsCount]; for (uint32_t i = 0; i < attachmentInitialSampleLocationsCount; ++i) {
memcpy((void*)pAttachmentInitialSampleLocations, (void*)in_struct->pAttachmentInitialSampleLocations, pAttachmentInitialSampleLocations[i].initialize(&in_struct->pAttachmentInitialSampleLocations[i]);
sizeof(VkAttachmentSampleLocationsEXT) * in_struct->attachmentInitialSampleLocationsCount); }
} }
if (postSubpassSampleLocationsCount && in_struct->pPostSubpassSampleLocations) {
if (in_struct->pPostSubpassSampleLocations) { pPostSubpassSampleLocations = new safe_VkSubpassSampleLocationsEXT[postSubpassSampleLocationsCount];
pPostSubpassSampleLocations = new VkSubpassSampleLocationsEXT[in_struct->postSubpassSampleLocationsCount]; for (uint32_t i = 0; i < postSubpassSampleLocationsCount; ++i) {
memcpy((void*)pPostSubpassSampleLocations, (void*)in_struct->pPostSubpassSampleLocations, pPostSubpassSampleLocations[i].initialize(&in_struct->pPostSubpassSampleLocations[i]);
sizeof(VkSubpassSampleLocationsEXT) * in_struct->postSubpassSampleLocationsCount); }
} }
} }
@ -2810,17 +2880,17 @@ void safe_VkRenderPassSampleLocationsBeginInfoEXT::initialize(const safe_VkRende
postSubpassSampleLocationsCount = copy_src->postSubpassSampleLocationsCount; postSubpassSampleLocationsCount = copy_src->postSubpassSampleLocationsCount;
pPostSubpassSampleLocations = nullptr; pPostSubpassSampleLocations = nullptr;
pNext = SafePnextCopy(copy_src->pNext); pNext = SafePnextCopy(copy_src->pNext);
if (attachmentInitialSampleLocationsCount && copy_src->pAttachmentInitialSampleLocations) {
if (copy_src->pAttachmentInitialSampleLocations) { pAttachmentInitialSampleLocations = new safe_VkAttachmentSampleLocationsEXT[attachmentInitialSampleLocationsCount];
pAttachmentInitialSampleLocations = new VkAttachmentSampleLocationsEXT[copy_src->attachmentInitialSampleLocationsCount]; for (uint32_t i = 0; i < attachmentInitialSampleLocationsCount; ++i) {
memcpy((void*)pAttachmentInitialSampleLocations, (void*)copy_src->pAttachmentInitialSampleLocations, pAttachmentInitialSampleLocations[i].initialize(&copy_src->pAttachmentInitialSampleLocations[i]);
sizeof(VkAttachmentSampleLocationsEXT) * copy_src->attachmentInitialSampleLocationsCount); }
} }
if (postSubpassSampleLocationsCount && copy_src->pPostSubpassSampleLocations) {
if (copy_src->pPostSubpassSampleLocations) { pPostSubpassSampleLocations = new safe_VkSubpassSampleLocationsEXT[postSubpassSampleLocationsCount];
pPostSubpassSampleLocations = new VkSubpassSampleLocationsEXT[copy_src->postSubpassSampleLocationsCount]; for (uint32_t i = 0; i < postSubpassSampleLocationsCount; ++i) {
memcpy((void*)pPostSubpassSampleLocations, (void*)copy_src->pPostSubpassSampleLocations, pPostSubpassSampleLocations[i].initialize(&copy_src->pPostSubpassSampleLocations[i]);
sizeof(VkSubpassSampleLocationsEXT) * copy_src->postSubpassSampleLocationsCount); }
} }
} }