aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2016-10-27 15:32:08 -0600
committerMark Young <marky@lunarg.com>2016-10-27 15:32:08 -0600
commitb7f3c87b41941e2529a0be3bc647fae3e077a36a (patch)
tree2121113b7698d269f7927904af8c2b341f2cedea
parentb0c86fa5130b49b5a9f19687cb25d3f20559ee0f (diff)
downloadusermoji-b7f3c87b41941e2529a0be3bc647fae3e077a36a.tar.xz
loader: gh1093 - Fix multiple EnumPhysDev calls
The loader was freeing a previously allocated struct of physical devices every vkEnumeratePhysicalDevice call. This caused pointers to become stale. This change doesn't fix every scenario, but it does return the loader to the behavior it had before. Future work will re-evaluate the list every time and add/remove items as necessary. Change-Id: I32b27df1fab521826e6cd15c534d3ab4b2ea0688
-rw-r--r--loader/loader.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/loader/loader.c b/loader/loader.c
index 184809b2..e607eced 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -4442,6 +4442,9 @@ terminator_EnumeratePhysicalDevices(VkInstance instance,
phys_devs[i].this_icd = icd;
icd = icd->next;
}
+ if (inst->total_gpu_count == 0) {
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
uint32_t copy_count = inst->total_gpu_count;
@@ -4456,22 +4459,19 @@ terminator_EnumeratePhysicalDevices(VkInstance instance,
copy_count = *pPhysicalDeviceCount;
}
- if (inst->phys_devs_term) {
- loader_instance_heap_free(inst, inst->phys_devs_term);
- inst->phys_devs_term = NULL;
- }
-
- if (inst->total_gpu_count > 0) {
+ if (NULL == inst->phys_devs_term) {
inst->phys_devs_term = loader_instance_heap_alloc(
inst, sizeof(struct loader_physical_device) * inst->total_gpu_count,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (!inst->phys_devs_term) {
+ if (NULL == inst->phys_devs_term) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
}
- for (i = 0; idx < inst->total_gpu_count && i < inst->total_icd_count; i++) {
- for (j = 0; j < phys_devs[i].count && idx < inst->total_gpu_count; j++) {
+ for (i = 0; idx < inst->total_gpu_count && i < inst->total_icd_count;
+ i++) {
+ for (j = 0; j < phys_devs[i].count && idx < inst->total_gpu_count;
+ j++) {
loader_set_dispatch((void *)&inst->phys_devs_term[idx],
inst->disp);
inst->phys_devs_term[idx].this_icd = phys_devs[i].this_icd;