Skip to content

Commit

Permalink
Revert "safestruct: Remove safe_VkDescriptorDataEXT"
Browse files Browse the repository at this point in the history
This reverts commit 1135918.
  • Loading branch information
ziga-lunarg authored and spencer-lunarg committed Apr 20, 2024
1 parent 6e6a4e0 commit d0ffc68
Show file tree
Hide file tree
Showing 4 changed files with 519 additions and 9 deletions.
24 changes: 23 additions & 1 deletion include/vulkan/utility/vk_safe_struct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13494,11 +13494,33 @@ 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;
VkDescriptorDataEXT data;
safe_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: 6 additions & 2 deletions scripts/generators/safe_struct_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ 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 @@ -191,6 +192,9 @@ 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) {
: sType(in_struct->sType), type(in_struct->type), data(&in_struct->data, in_struct->type) {
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(), data() {}
: sType(VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT), pNext(nullptr), type() {}

safe_VkDescriptorGetInfoEXT::safe_VkDescriptorGetInfoEXT(const safe_VkDescriptorGetInfoEXT& copy_src) {
sType = copy_src.sType;
type = copy_src.type;
data = copy_src.data;
data.initialize(&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 = copy_src.data;
data.initialize(&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 = in_struct->data;
data.initialize(&in_struct->data, in_struct->type);
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 = copy_src->data;
data.initialize(&copy_src->data);
pNext = SafePnextCopy(copy_src->pNext);
}

Expand Down
Loading

0 comments on commit d0ffc68

Please sign in to comment.