Skip to content

Commit

Permalink
Tolerate empty support format lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Dec 17, 2024
1 parent 421e200 commit f99d34a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static List<VulkanImageType> images(
.collect(Collectors.toList());
}

private VulkanSwapChainAcquisitionResultType acquireImage(
private static VulkanSwapChainAcquisitionResultType acquireImage(
final VulkanLWJGLKHRSwapChain chain,
final long timeout,
final VulkanSemaphoreBinaryType semaphore,
Expand Down Expand Up @@ -467,7 +467,7 @@ public VulkanSwapChainAcquisitionResultType acquireImageWithSemaphore(
throws VulkanException
{
Objects.requireNonNull(semaphore, "semaphore");
return this.extension.acquireImage(this, timeout, semaphore, null);
return acquireImage(this, timeout, semaphore, null);
}

@Override
Expand All @@ -477,7 +477,7 @@ public VulkanSwapChainAcquisitionResultType acquireImageWithFence(
throws VulkanException
{
Objects.requireNonNull(fence, "fence");
return this.extension.acquireImage(this, timeout, null, fence);
return acquireImage(this, timeout, null, fence);
}

@Override
Expand All @@ -489,7 +489,7 @@ public VulkanSwapChainAcquisitionResultType acquireImageWithSemaphoreAndFence(
{
Objects.requireNonNull(semaphore, "semaphore");
Objects.requireNonNull(fence, "fence");
return this.extension.acquireImage(this, timeout, semaphore, fence);
return acquireImage(this, timeout, semaphore, fence);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.io7m.jcoronado.extensions.khr_surface.api.VulkanExtKHRSurfaceType;
import com.io7m.jcoronado.extensions.khr_surface.api.VulkanSurfaceCapabilitiesKHR;
import com.io7m.jcoronado.extensions.khr_surface.api.VulkanSurfaceFormatKHR;
import com.io7m.jcoronado.extensions.khr_swapchain.api.VulkanColorSpaceKHR;
import com.io7m.jcoronado.extensions.khr_swapchain.api.VulkanExtKHRSwapChainType;
import com.io7m.jcoronado.extensions.khr_swapchain.api.VulkanPresentInfoKHR;
import com.io7m.jcoronado.extensions.khr_swapchain.api.VulkanPresentModeKHR;
Expand Down Expand Up @@ -657,9 +658,19 @@ private VulkanSurfaceFormatKHR pickSurfaceFormat()

/*
* None of our preferred formats were supported (or we didn't claim to
* prefer any). Use the first supported format.
* prefer any). The spec says that at least one format must be returned,
* but implementations have been seen in the wild that return an empty
* list. For those implementations, the assumption is that any RGBA
* format mandated by the spec as renderable can be used.
*/

if (availableList.isEmpty()) {
return VulkanSurfaceFormatKHR.of(
VulkanFormat.VK_FORMAT_B8G8R8A8_UNORM,
VulkanColorSpaceKHR.VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
);
}

return availableList.get(0);
}

Expand Down

0 comments on commit f99d34a

Please sign in to comment.