const VkAllocationCallbacks *pAllocator) {
struct loader_instance *ptr_instance = loader_get_instance(instance);
-// Android doesn't have to worry about multiple ICD scenario, but the rest do.
-#ifndef VK_USE_PLATFORM_ANDROID_KHR
VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
if (NULL != icd_surface->real_icd_surfaces) {
for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
// The real_icd_surface for any ICD not supporting the proper
// interface version should be NULL. If not, then we have a
// problem.
- assert(NULL == icd_surface->real_icd_surfaces[i]);
+ assert(NULL == (void*)icd_surface->real_icd_surfaces[i]);
}
}
loader_instance_heap_free(ptr_instance, icd_surface->real_icd_surfaces);
}
-#endif // !VK_USE_PLATFORM_XLIB_KHR
loader_instance_heap_free(ptr_instance, (void *)surface);
}
assert(icd->GetPhysicalDeviceSurfaceSupportKHR &&
"loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
-// Android doesn't have to worry about multiple ICD scenario, but the rest do.
-#ifndef VK_USE_PLATFORM_ANDROID_KHR
VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
if (NULL != icd_surface->real_icd_surfaces &&
NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
phys_dev->phys_dev, queueFamilyIndex,
icd_surface->real_icd_surfaces[phys_dev->icd_index], pSupported);
}
-#endif
return icd->GetPhysicalDeviceSurfaceSupportKHR(
phys_dev->phys_dev, queueFamilyIndex, surface, pSupported);
assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR &&
"loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
-// Android doesn't have to worry about multiple ICD scenario, but the rest do.
-#ifndef VK_USE_PLATFORM_ANDROID_KHR
VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
if (NULL != icd_surface->real_icd_surfaces &&
NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
icd_surface->real_icd_surfaces[phys_dev->icd_index],
pSurfaceCapabilities);
}
-#endif
return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
phys_dev->phys_dev, surface, pSurfaceCapabilities);
assert(icd->GetPhysicalDeviceSurfaceFormatsKHR &&
"loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
-// Android doesn't have to worry about multiple ICD scenario, but the rest do.
-#ifndef VK_USE_PLATFORM_ANDROID_KHR
VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
if (NULL != icd_surface->real_icd_surfaces &&
NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
icd_surface->real_icd_surfaces[phys_dev->icd_index],
pSurfaceFormatCount, pSurfaceFormats);
}
-#endif
return icd->GetPhysicalDeviceSurfaceFormatsKHR(
phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
assert(icd->GetPhysicalDeviceSurfacePresentModesKHR &&
"loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
-// Android doesn't have to worry about multiple ICD scenario, but the rest do.
-#ifndef VK_USE_PLATFORM_ANDROID_KHR
VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
if (NULL != icd_surface->real_icd_surfaces &&
NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
icd_surface->real_icd_surfaces[phys_dev->icd_index],
pPresentModeCount, pPresentModes);
}
-#endif
return icd->GetPhysicalDeviceSurfacePresentModesKHR(
phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes);
struct loader_icd *icd = loader_get_icd_and_device(device, &dev, &icd_index);
if (NULL != icd &&
NULL != icd->CreateSwapchainKHR) {
- // Android doesn't have to worry about multiple ICD scenario, but the rest do.
-#ifndef VK_USE_PLATFORM_ANDROID_KHR
VkIcdSurface *icd_surface = (VkIcdSurface *)(pCreateInfo->surface);
if (NULL != icd_surface->real_icd_surfaces) {
if (NULL != (void *)icd_surface->real_icd_surfaces[icd_index]) {
return icd->CreateSwapchainKHR(device, pCreateCopy, pAllocator, pSwapchain);
}
}
-#endif
return icd->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
}
return VK_SUCCESS;
return disp->QueuePresentKHR(queue, pPresentInfo);
}
+static VkIcdSurface *AllocateIcdSurfaceStruct(struct loader_instance *instance,
+ size_t base_size,
+ size_t platform_size,
+ bool create_icd_surfs) {
+ // Next, if so, proceed with the implementation of this function:
+ VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
+ instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ if (pIcdSurface != NULL) {
+ // Setup the new sizes and offsets so we can grow the structures in the
+ // future without having problems
+ pIcdSurface->base_size = (uint32_t)base_size;
+ pIcdSurface->platform_size = (uint32_t)platform_size;
+ pIcdSurface->non_platform_offset = (uint32_t)(
+ (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
+ pIcdSurface->entire_size = sizeof(VkIcdSurface);
+
+ if (create_icd_surfs) {
+ pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
+ instance, sizeof(VkSurfaceKHR) * instance->total_icd_count,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ if (pIcdSurface->real_icd_surfaces == NULL) {
+ loader_instance_heap_free(instance, pIcdSurface);
+ pIcdSurface = NULL;
+ } else {
+ memset(pIcdSurface->real_icd_surfaces, 0,
+ sizeof(VkSurfaceKHR) * instance->total_icd_count);
+ }
+ } else {
+ pIcdSurface->real_icd_surfaces = NULL;
+ }
+ }
+ return pIcdSurface;
+}
+
#ifdef VK_USE_PLATFORM_WIN32_KHR
VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
VkResult vkRes = VK_SUCCESS;
+ // Initialize pSurface to NULL just to be safe.
+ *pSurface = VK_NULL_HANDLE;
// First, check to ensure the appropriate extension was enabled:
struct loader_instance *ptr_instance = loader_get_instance(instance);
if (!ptr_instance->wsi_win32_surface_enabled) {
}
// Next, if so, proceed with the implementation of this function:
- VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ VkIcdSurface *pIcdSurface = AllocateIcdSurfaceStruct(
+ ptr_instance, sizeof(pIcdSurface->win_surf.base),
+ sizeof(pIcdSurface->win_surf), true);
if (pIcdSurface == NULL) {
vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
pIcdSurface->win_surf.hinstance = pCreateInfo->hinstance;
pIcdSurface->win_surf.hwnd = pCreateInfo->hwnd;
- // Setup the new sizes and offsets so we can grow the structures in the
- // future withouth having problems
- pIcdSurface->base_size = sizeof(pIcdSurface->win_surf.base);
- pIcdSurface->platform_size = sizeof(pIcdSurface->win_surf);
- pIcdSurface->non_platform_offset = (uint32_t)(
- (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
- pIcdSurface->entire_size = sizeof(VkIcdSurface);
-
- pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
- VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
- if (pIcdSurface == NULL) {
- vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
- }
- memset(pIcdSurface->real_icd_surfaces, 0,
- sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
-
// Loop through each ICD and determine if they need to create a surface
for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
if (ptr_instance->icd_libs.list[i].interface_version >=
if (NULL != pIcdSurface->real_icd_surfaces) {
for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
struct loader_icd *icd = &ptr_instance->icds[i];
- if (NULL != pIcdSurface->real_icd_surfaces[i] &&
+ if (NULL != (void*)pIcdSurface->real_icd_surfaces[i] &&
NULL != icd->DestroySurfaceKHR) {
icd->DestroySurfaceKHR(
icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
}
// Next, if so, proceed with the implementation of this function:
- VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ VkIcdSurface *pIcdSurface = AllocateIcdSurfaceStruct(
+ ptr_instance, sizeof(pIcdSurface->mir_surf.base),
+ sizeof(pIcdSurface->mir_surf), true);
if (pIcdSurface == NULL) {
vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
pIcdSurface->mir_surf.connection = pCreateInfo->connection;
pIcdSurface->mir_surf.mirSurface = pCreateInfo->mirSurface;
- // Setup the new sizes and offsets so we can grow the structures in the
- // future withouth having problems
- pIcdSurface->base_size = sizeof(pIcdSurface->mir_surf.base);
- pIcdSurface->platform_size = sizeof(pIcdSurface->mir_surf);
- pIcdSurface->non_platform_offset = (uint32_t)(
- (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
- pIcdSurface->entire_size = sizeof(VkIcdSurface);
-
- pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
- VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
- if (pIcdSurface == NULL) {
- vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
- }
- memset(pIcdSurface->real_icd_surfaces, 0,
- sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
-
// Loop through each ICD and determine if they need to create a surface
for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
if (ptr_instance->icd_libs.list[i].interface_version >=
}
// Next, if so, proceed with the implementation of this function:
- VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ VkIcdSurface *pIcdSurface = AllocateIcdSurfaceStruct(
+ ptr_instance, sizeof(pIcdSurface->wayland_surf.base),
+ sizeof(pIcdSurface->wayland_surf), true);
if (pIcdSurface == NULL) {
vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
pIcdSurface->wayland_surf.display = pCreateInfo->display;
pIcdSurface->wayland_surf.surface = pCreateInfo->surface;
- // Setup the new sizes and offsets so we can grow the structures in the
- // future withouth having problems
- pIcdSurface->base_size = sizeof(pIcdSurface->wayland_surf.base);
- pIcdSurface->platform_size = sizeof(pIcdSurface->wayland_surf);
- pIcdSurface->non_platform_offset = (uint32_t)(
- (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
- pIcdSurface->entire_size = sizeof(VkIcdSurface);
-
- pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
- VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
- if (pIcdSurface == NULL) {
- vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
- }
- memset(pIcdSurface->real_icd_surfaces, 0,
- sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
-
// Loop through each ICD and determine if they need to create a surface
for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
if (ptr_instance->icd_libs.list[i].interface_version >=
}
// Next, if so, proceed with the implementation of this function:
- VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ VkIcdSurface *pIcdSurface = AllocateIcdSurfaceStruct(
+ ptr_instance, sizeof(pIcdSurface->xcb_surf.base),
+ sizeof(pIcdSurface->xcb_surf), true);
if (pIcdSurface == NULL) {
vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
pIcdSurface->xcb_surf.connection = pCreateInfo->connection;
pIcdSurface->xcb_surf.window = pCreateInfo->window;
- // Setup the new sizes and offsets so we can grow the structures in the
- // future withouth having problems
- pIcdSurface->base_size = sizeof(pIcdSurface->xcb_surf.base);
- pIcdSurface->platform_size = sizeof(pIcdSurface->xcb_surf);
- pIcdSurface->non_platform_offset = (uint32_t)(
- (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
- pIcdSurface->entire_size = sizeof(VkIcdSurface);
-
- pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
- VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
- if (pIcdSurface == NULL) {
- vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
- }
- memset(pIcdSurface->real_icd_surfaces, 0,
- sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
-
// Loop through each ICD and determine if they need to create a surface
for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
if (ptr_instance->icd_libs.list[i].interface_version >=
}
// Next, if so, proceed with the implementation of this function:
- VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ VkIcdSurface *pIcdSurface = AllocateIcdSurfaceStruct(
+ ptr_instance, sizeof(pIcdSurface->xlib_surf.base),
+ sizeof(pIcdSurface->xlib_surf), true);
if (pIcdSurface == NULL) {
vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
pIcdSurface->xlib_surf.dpy = pCreateInfo->dpy;
pIcdSurface->xlib_surf.window = pCreateInfo->window;
- // Setup the new sizes and offsets so we can grow the structures in the
- // future withouth having problems
- pIcdSurface->base_size = sizeof(pIcdSurface->xlib_surf.base);
- pIcdSurface->platform_size = sizeof(pIcdSurface->xlib_surf);
- pIcdSurface->non_platform_offset = (uint32_t)(
- (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
- pIcdSurface->entire_size = sizeof(VkIcdSurface);
-
- pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
- VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
- if (pIcdSurface == NULL) {
- vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
- }
- memset(pIcdSurface->real_icd_surfaces, 0,
- sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
-
// Loop through each ICD and determine if they need to create a surface
for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
if (ptr_instance->icd_libs.list[i].interface_version >=
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
- pIcdSurface = loader_instance_heap_alloc(inst, sizeof(VkIcdSurface),
- VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ // The VK_KHR_display path will continue to use the old path (hence the
+ // false as the last parameter).
+ pIcdSurface =
+ AllocateIcdSurfaceStruct(inst, sizeof(pIcdSurface->display_surf.base),
+ sizeof(pIcdSurface->display_surf), false);
if (pIcdSurface == NULL) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
pIcdSurface->display_surf.alphaMode = pCreateInfo->alphaMode;
pIcdSurface->display_surf.imageExtent = pCreateInfo->imageExtent;
- // Setup the new sizes and offsets so we can grow the structures in the
- // future withouth having problems
- pIcdSurface->real_icd_surfaces = NULL;
- pIcdSurface->base_size = sizeof(pIcdSurface->display_surf.base);
- pIcdSurface->platform_size = sizeof(pIcdSurface->display_surf);
- pIcdSurface->non_platform_offset = (uint32_t)(
- (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
- pIcdSurface->entire_size = sizeof(VkIcdSurface);
-
*pSurface = (VkSurfaceKHR)pIcdSurface;
return VK_SUCCESS;