Skip to content

Commit

Permalink
safestruct: Remove safe_VkDescriptorDataEXT
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Apr 25, 2024
1 parent bbd4b77 commit 8d89862
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 519 deletions.
24 changes: 1 addition & 23 deletions include/vulkan/utility/vk_safe_struct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13494,33 +13494,11 @@ struct safe_VkDescriptorBufferBindingPushDescriptorBufferHandleEXT {
return reinterpret_cast<VkDescriptorBufferBindingPushDescriptorBufferHandleEXT const*>(this);
}
};
union safe_VkDescriptorDataEXT {
const VkSampler* pSampler{};
const VkDescriptorImageInfo* pCombinedImageSampler;
const VkDescriptorImageInfo* pInputAttachmentImage;
const VkDescriptorImageInfo* pSampledImage;
const VkDescriptorImageInfo* pStorageImage;
safe_VkDescriptorAddressInfoEXT* pUniformTexelBuffer;
safe_VkDescriptorAddressInfoEXT* pStorageTexelBuffer;
safe_VkDescriptorAddressInfoEXT* pUniformBuffer;
safe_VkDescriptorAddressInfoEXT* pStorageBuffer;
VkDeviceAddress accelerationStructure;
char type_at_end[sizeof(VkDescriptorDataEXT) + sizeof(VkDescriptorGetInfoEXT::type)];
safe_VkDescriptorDataEXT(const VkDescriptorDataEXT* in_struct, const VkDescriptorType type, PNextCopyState* copy_state = {});
safe_VkDescriptorDataEXT(const safe_VkDescriptorDataEXT& copy_src);
safe_VkDescriptorDataEXT& operator=(const safe_VkDescriptorDataEXT& copy_src);
safe_VkDescriptorDataEXT();
~safe_VkDescriptorDataEXT();
void initialize(const VkDescriptorDataEXT* in_struct, const VkDescriptorType type, PNextCopyState* copy_state = {});
void initialize(const safe_VkDescriptorDataEXT* copy_src, PNextCopyState* copy_state = {});
VkDescriptorDataEXT* ptr() { return reinterpret_cast<VkDescriptorDataEXT*>(this); }
VkDescriptorDataEXT const* ptr() const { return reinterpret_cast<VkDescriptorDataEXT const*>(this); }
};
struct safe_VkDescriptorGetInfoEXT {
VkStructureType sType;
const void* pNext{};
VkDescriptorType type;
safe_VkDescriptorDataEXT data;
VkDescriptorDataEXT data;

safe_VkDescriptorGetInfoEXT(const VkDescriptorGetInfoEXT* in_struct, PNextCopyState* copy_state = {}, bool copy_pnext = true);
safe_VkDescriptorGetInfoEXT(const safe_VkDescriptorGetInfoEXT& copy_src);
Expand Down
8 changes: 2 additions & 6 deletions scripts/generators/safe_struct_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,15 @@ def __init__(self):
# vku::safe::AccelerationStructureGeometryKHR needs to know if we're doing a host or device build
'VkAccelerationStructureGeometryKHR' :
', const bool is_host, const VkAccelerationStructureBuildRangeInfoKHR *build_range_info',
# vku::safe::DescriptorDataEXT needs to know what field of union is intialized
'VkDescriptorDataEXT' :
', const VkDescriptorType type',
}

# Determine if a structure needs a safe_struct helper function
# That is, it has an sType or one of its members is a pointer
def needSafeStruct(self, struct: Struct) -> bool:
if struct.name in self.no_autogen:
return False
if struct.name in self.union_of_pointers:
return False
if 'VkBase' in struct.name:
return False # Ingore structs like VkBaseOutStructure
if struct.sType is not None:
Expand Down Expand Up @@ -192,9 +191,6 @@ def generateHeader(self):
else:
out.append(f'{member.cDeclaration}{initialize};\n')

if (struct.name == 'VkDescriptorDataEXT'):
out.append('char type_at_end[sizeof(VkDescriptorDataEXT)+sizeof(VkDescriptorGetInfoEXT::type)];')

constructParam = self.custom_construct_params.get(struct.name, '')
out.append(f'''
{safe_name}(const {struct.name}* in_struct{constructParam}, PNextCopyState* copy_state = {{}}{copy_pnext});
Expand Down
12 changes: 6 additions & 6 deletions src/vulkan/vk_safe_struct_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9179,19 +9179,19 @@ void safe_VkDescriptorBufferBindingPushDescriptorBufferHandleEXT::initialize(

safe_VkDescriptorGetInfoEXT::safe_VkDescriptorGetInfoEXT(const VkDescriptorGetInfoEXT* in_struct,
[[maybe_unused]] PNextCopyState* copy_state, bool copy_pnext)
: sType(in_struct->sType), type(in_struct->type), data(&in_struct->data, in_struct->type) {
: sType(in_struct->sType), type(in_struct->type), data(in_struct->data) {
if (copy_pnext) {
pNext = SafePnextCopy(in_struct->pNext, copy_state);
}
}

safe_VkDescriptorGetInfoEXT::safe_VkDescriptorGetInfoEXT()
: sType(VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT), pNext(nullptr), type() {}
: sType(VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT), pNext(nullptr), type(), data() {}

safe_VkDescriptorGetInfoEXT::safe_VkDescriptorGetInfoEXT(const safe_VkDescriptorGetInfoEXT& copy_src) {
sType = copy_src.sType;
type = copy_src.type;
data.initialize(&copy_src.data);
data = copy_src.data;
pNext = SafePnextCopy(copy_src.pNext);
}

Expand All @@ -9202,7 +9202,7 @@ safe_VkDescriptorGetInfoEXT& safe_VkDescriptorGetInfoEXT::operator=(const safe_V

sType = copy_src.sType;
type = copy_src.type;
data.initialize(&copy_src.data);
data = copy_src.data;
pNext = SafePnextCopy(copy_src.pNext);

return *this;
Expand All @@ -9214,15 +9214,15 @@ void safe_VkDescriptorGetInfoEXT::initialize(const VkDescriptorGetInfoEXT* in_st
FreePnextChain(pNext);
sType = in_struct->sType;
type = in_struct->type;
data.initialize(&in_struct->data, in_struct->type);
data = in_struct->data;
pNext = SafePnextCopy(in_struct->pNext, copy_state);
}

void safe_VkDescriptorGetInfoEXT::initialize(const safe_VkDescriptorGetInfoEXT* copy_src,
[[maybe_unused]] PNextCopyState* copy_state) {
sType = copy_src->sType;
type = copy_src->type;
data.initialize(&copy_src->data);
data = copy_src->data;
pNext = SafePnextCopy(copy_src->pNext);
}

Expand Down
Loading

0 comments on commit 8d89862

Please sign in to comment.