Skip to content

Commit

Permalink
Revert "Fix breaking bug with features not being populated from VkGet…
Browse files Browse the repository at this point in the history
…PhysicalDeviceFeatures2"

This reverts commit 21e400c.
  • Loading branch information
charles-lunarg committed Apr 18, 2021
1 parent 4bfc21f commit 77be102
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 34 deletions.
5 changes: 1 addition & 4 deletions src/VkBootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,12 +1015,9 @@ PhysicalDeviceSelector::PhysicalDeviceDesc PhysicalDeviceSelector::populate_devi
prev = &extension;
}
if(desc.extension_features.size() > 0) {
desc.device_features2.pNext = desc.extension_features[0].structure;
desc.device_features2.pNext = &desc.extension_features[0].structure;
}
detail::vulkan_functions().fp_vkGetPhysicalDeviceFeatures2(phys_device, &desc.device_features2);
for(auto& extension : desc.extension_features) {
extension.update();
}
}
#endif
return desc;
Expand Down
41 changes: 11 additions & 30 deletions src/VkBootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,34 +198,28 @@ class PhysicalDeviceSelector;
struct ExtensionFeatures {

using DeleteProc = void(*)(ExtensionFeatures&);
using UpdateProc = void(*)(ExtensionFeatures&);
using CopyProc = void(*)(const ExtensionFeatures&, ExtensionFeatures&);

ExtensionFeatures() = default;

ExtensionFeatures (const ExtensionFeatures& other) : delete_proc(other.delete_proc),
update_proc(other.update_proc),
copy_proc(other.copy_proc) {
ExtensionFeatures (const ExtensionFeatures& other) : delete_proc(other.delete_proc), copy_proc(other.copy_proc) {
if(copy_proc) { copy_proc(other, *this); }
}

ExtensionFeatures (ExtensionFeatures&& other) : delete_proc(std::exchange(other.delete_proc, nullptr)),
update_proc(std::exchange(other.update_proc, nullptr)),
copy_proc(std::exchange(other.copy_proc, nullptr)),
structure(std::exchange(other.structure, nullptr)),
fields(std::exchange(other.fields, {})) {}

ExtensionFeatures& operator=(const ExtensionFeatures& other) {
delete_proc = other.delete_proc;
update_proc = other.update_proc;
copy_proc = other.copy_proc;
if(copy_proc) { copy_proc(other, *this); }
return *this;
}

ExtensionFeatures& operator=(ExtensionFeatures&& other) {
delete_proc = std::exchange(other.delete_proc, nullptr);
update_proc = std::exchange(other.update_proc, nullptr);
copy_proc = std::exchange(other.copy_proc, nullptr);
structure = std::exchange(other.structure, nullptr);
fields = std::exchange(other.fields, {});
Expand All @@ -240,6 +234,14 @@ struct ExtensionFeatures {
*new_features_structure = src;
extension_features.structure = reinterpret_cast<VkBaseOutStructure*>(new_features_structure);

auto structure_field_count =
(sizeof(T) - (sizeof(VkStructureType) + sizeof(void*))) / sizeof(VkBool32);
extension_features.fields.resize(structure_field_count);
memcpy(extension_features.fields.data(),
reinterpret_cast<unsigned char*>(extension_features.structure) +
(sizeof(VkStructureType) + sizeof(void*)),
sizeof(VkBool32) * extension_features.fields.size());

extension_features.delete_proc = [](ExtensionFeatures& features) {

features.fields = {};
Expand All @@ -250,16 +252,6 @@ struct ExtensionFeatures {

};

extension_features.update_proc = [](ExtensionFeatures& features) {

auto structure_field_count = (sizeof(T) - (sizeof(void*) * 2)) / sizeof(VkBool32);
features.fields.resize(structure_field_count);
memcpy(features.fields.data(),
reinterpret_cast<unsigned char*>(features.structure) + (sizeof(void*) * 2),
sizeof(VkBool32) * features.fields.size());

};

extension_features.copy_proc = [](const ExtensionFeatures& src, ExtensionFeatures& dst) {

if(dst.structure) {
Expand All @@ -273,19 +265,9 @@ struct ExtensionFeatures {

};

extension_features.update();

return extension_features;
}

void update() {

if(update_proc) {
update_proc(*this);
}

}

bool match(const ExtensionFeatures& other) const {

if(!structure || !other.structure || structure->sType != other.structure->sType) { return false; }
Expand All @@ -308,9 +290,8 @@ struct ExtensionFeatures {
VkBaseOutStructure* structure = nullptr;
std::vector<VkBool32> fields;
private:
DeleteProc delete_proc = nullptr;
UpdateProc update_proc = nullptr;
CopyProc copy_proc = nullptr;
DeleteProc delete_proc = {};
CopyProc copy_proc = {};
};

struct Instance {
Expand Down

0 comments on commit 77be102

Please sign in to comment.