Skip to content

Commit 29fb030

Browse files
MathiasMagnuscharles-lunarg
authored andcommitted
Fix twocall_chain_vectors mechanism
Instead of unconditionally querying properties twice, only call the query again if the given output struct has array members. Also fix the case where if there are no output structs with array properties (VulkanSC), then don't end up with unresolved external symbols.
1 parent 4c63e84 commit 29fb030

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

scripts/vulkaninfo_generator.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -901,19 +901,10 @@ def PrintChainStruct(listName, structures, all_structures, chain_details, extTyp
901901
out += ' }\n'
902902
out += '}\n'
903903

904-
should_print_twocall_func = False
905-
for s in structs_to_print:
906-
if not s.hasLengthmember:
907-
continue
908-
if s.name in STRUCT_BLACKLIST:
909-
continue
910-
should_print_twocall_func = True
911-
912-
if not should_print_twocall_func:
913-
return out
914-
915904
out += '\n'
916-
out += f'void prepare_{listName}_twocall_chain_vectors(std::unique_ptr<{listName}_chain>& chain) {{\n'
905+
out += f'bool prepare_{listName}_twocall_chain_vectors(std::unique_ptr<{listName}_chain>& chain) {{\n'
906+
out += ' (void)chain;\n'
907+
is_twocall = False
917908
for s in structs_to_print:
918909
if not s.hasLengthmember:
919910
continue
@@ -925,6 +916,8 @@ def PrintChainStruct(listName, structures, all_structures, chain_details, extTyp
925916
out += f' chain->{s.name}_{member.name}.resize(chain->{s.name[2:]}.{member.arrayLength});\n'
926917
out += f' chain->{s.name[2:]}.{member.name} = chain->{s.name}_{member.name}.data();\n'
927918
out += AddGuardFooter(s)
919+
is_twocall = True
920+
out += f' return {"true" if is_twocall else "false"};\n'
928921
out += '}\n'
929922

930923
return out

vulkaninfo/generated/vulkaninfo.hpp

+28-1
Original file line numberDiff line numberDiff line change
@@ -4061,13 +4061,15 @@ void chain_iterator_phys_device_props2(Printer &p, AppInstance &inst, AppGpu &gp
40614061
}
40624062
}
40634063

4064-
void prepare_phys_device_props2_twocall_chain_vectors(std::unique_ptr<phys_device_props2_chain>& chain) {
4064+
bool prepare_phys_device_props2_twocall_chain_vectors(std::unique_ptr<phys_device_props2_chain>& chain) {
4065+
(void)chain;
40654066
chain->VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopySrcLayouts.resize(chain->PhysicalDeviceHostImageCopyPropertiesEXT.copySrcLayoutCount);
40664067
chain->PhysicalDeviceHostImageCopyPropertiesEXT.pCopySrcLayouts = chain->VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopySrcLayouts.data();
40674068
chain->VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopyDstLayouts.resize(chain->PhysicalDeviceHostImageCopyPropertiesEXT.copyDstLayoutCount);
40684069
chain->PhysicalDeviceHostImageCopyPropertiesEXT.pCopyDstLayouts = chain->VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopyDstLayouts.data();
40694070
chain->VkPhysicalDeviceLayeredApiPropertiesListKHR_pLayeredApis.resize(chain->PhysicalDeviceLayeredApiPropertiesListKHR.layeredApiCount);
40704071
chain->PhysicalDeviceLayeredApiPropertiesListKHR.pLayeredApis = chain->VkPhysicalDeviceLayeredApiPropertiesListKHR_pLayeredApis.data();
4072+
return true;
40714073
}
40724074
struct phys_device_mem_props2_chain {
40734075
phys_device_mem_props2_chain() = default;
@@ -4096,6 +4098,11 @@ void setup_phys_device_mem_props2_chain(VkPhysicalDeviceMemoryProperties2& start
40964098
chain->initialize_chain(gpu);
40974099
start.pNext = chain->start_of_chain;
40984100
};
4101+
4102+
bool prepare_phys_device_mem_props2_twocall_chain_vectors(std::unique_ptr<phys_device_mem_props2_chain>& chain) {
4103+
(void)chain;
4104+
return false;
4105+
}
40994106
struct phys_device_features2_chain {
41004107
phys_device_features2_chain() = default;
41014108
phys_device_features2_chain(const phys_device_features2_chain &) = delete;
@@ -5408,6 +5415,11 @@ void chain_iterator_phys_device_features2(Printer &p, AppGpu &gpu, bool show_pro
54085415
place = structure->pNext;
54095416
}
54105417
}
5418+
5419+
bool prepare_phys_device_features2_twocall_chain_vectors(std::unique_ptr<phys_device_features2_chain>& chain) {
5420+
(void)chain;
5421+
return false;
5422+
}
54115423
struct surface_capabilities2_chain {
54125424
surface_capabilities2_chain() = default;
54135425
surface_capabilities2_chain(const surface_capabilities2_chain &) = delete;
@@ -5474,6 +5486,11 @@ void chain_iterator_surface_capabilities2(Printer &p, AppInstance &inst, AppGpu
54745486
place = structure->pNext;
54755487
}
54765488
}
5489+
5490+
bool prepare_surface_capabilities2_twocall_chain_vectors(std::unique_ptr<surface_capabilities2_chain>& chain) {
5491+
(void)chain;
5492+
return false;
5493+
}
54775494
struct format_properties2_chain {
54785495
format_properties2_chain() = default;
54795496
format_properties2_chain(const format_properties2_chain &) = delete;
@@ -5524,6 +5541,11 @@ void chain_iterator_format_properties2(Printer &p, AppGpu &gpu, void * place) {
55245541
place = structure->pNext;
55255542
}
55265543
}
5544+
5545+
bool prepare_format_properties2_twocall_chain_vectors(std::unique_ptr<format_properties2_chain>& chain) {
5546+
(void)chain;
5547+
return false;
5548+
}
55275549
struct queue_properties2_chain {
55285550
queue_properties2_chain() = default;
55295551
queue_properties2_chain(const queue_properties2_chain &) = delete;
@@ -5583,6 +5605,11 @@ void chain_iterator_queue_properties2(Printer &p, AppGpu &gpu, void * place) {
55835605
place = structure->pNext;
55845606
}
55855607
}
5608+
5609+
bool prepare_queue_properties2_twocall_chain_vectors(std::unique_ptr<queue_properties2_chain>& chain) {
5610+
(void)chain;
5611+
return false;
5612+
}
55865613
bool operator==(const VkExtent2D & a, const VkExtent2D b);
55875614
bool operator==(const VkSurfaceCapabilities2EXT & a, const VkSurfaceCapabilities2EXT b);
55885615
bool operator==(const VkSurfaceCapabilities2KHR & a, const VkSurfaceCapabilities2KHR b);

vulkaninfo/vulkaninfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void setup_surface_capabilities2_chain(VkSurfaceCapabilities2KHR &start, std::un
274274
void setup_format_properties2_chain(VkFormatProperties2 &start, std::unique_ptr<format_properties2_chain> &chain, AppGpu &gpu);
275275
void setup_queue_properties2_chain(VkQueueFamilyProperties2 &start, std::unique_ptr<queue_properties2_chain> &chain, AppGpu &gpu);
276276

277-
void prepare_phys_device_props2_twocall_chain_vectors(std::unique_ptr<phys_device_props2_chain> &chain);
277+
bool prepare_phys_device_props2_twocall_chain_vectors(std::unique_ptr<phys_device_props2_chain> &chain);
278278

279279
/* An ptional contains either a value or nothing. The optional asserts if a value is trying to be gotten but none exist.
280280
* The interface is taken from C++17's <optional> with many aspects removed.

0 commit comments

Comments
 (0)