Skip to content

Commit

Permalink
Include size information in swapchain images.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Dec 17, 2024
1 parent 3379380 commit abdd173
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.io7m.jcoronado.utility.swapchain;

import com.io7m.jcoronado.api.VulkanException;
import com.io7m.jcoronado.api.VulkanExtent2D;
import com.io7m.jcoronado.api.VulkanFenceType;
import com.io7m.jcoronado.api.VulkanImageType;
import com.io7m.jcoronado.api.VulkanImageViewType;
Expand All @@ -31,6 +32,12 @@
public interface JCSwapchainImageType
extends AutoCloseable
{
/**
* @return The image size
*/

VulkanExtent2D size();

/**
* @return The index of the image within the swapchain
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ private SwapchainHolder createNewSwapchain()
renderDoneSemaphores,
renderDoneFences,
presentDoneFences,
resources
resources,
extent
);
} catch (final Exception e) {
eventCreationFailed.errorMessage = e.getMessage();
Expand Down Expand Up @@ -708,6 +709,7 @@ private static final class SwapchainImage
private final VulkanFenceType presentDoneFence;
private final VulkanExtKHRSwapChainType.VulkanKHRSwapChainType swapchain;
private final VulkanFenceType renderFinishedFence;
private final VulkanExtent2D size;

SwapchainImage(
final SwapchainHolder inHolder,
Expand All @@ -717,7 +719,8 @@ private static final class SwapchainImage
final VulkanSemaphoreBinaryType inRenderFinishedSemaphore,
final VulkanFenceType inPresentDoneFence,
final VulkanExtKHRSwapChainType.VulkanKHRSwapChainType inSwapchain,
final VulkanFenceType inRenderFinishedFence)
final VulkanFenceType inRenderFinishedFence,
final VulkanExtent2D inSize)
{
this.holder =
Objects.requireNonNull(inHolder, "inHolder");
Expand All @@ -736,6 +739,8 @@ private static final class SwapchainImage
Objects.requireNonNull(inSwapchain, "swapchain");
this.renderFinishedFence =
Objects.requireNonNull(inRenderFinishedFence, "renderFinishedFence");
this.size =
Objects.requireNonNull(inSize, "size");
}

@Override
Expand All @@ -744,6 +749,12 @@ public String toString()
return "[SwapchainImage %s]".formatted(this.index);
}

@Override
public VulkanExtent2D size()
{
return this.size;
}

@Override
public JCSwapchainImageIndex index()
{
Expand Down Expand Up @@ -826,6 +837,7 @@ private static final class SwapchainHolder
private final Map<JCSwapchainFrameIndex, VulkanFenceType> renderDoneFences;
private final Map<JCSwapchainFrameIndex, VulkanFenceType> presentDoneFences;
private final CloseableCollectionType<VulkanResourceException> resources;
private final VulkanExtent2D extent;
private final JCSwapchainManager manager;
private final VulkanExtKHRSwapChainType.VulkanKHRSwapChainType swapchain;
private final Map<JCSwapchainImageIndex, VulkanImageViewType> swapChainImages;
Expand All @@ -841,7 +853,8 @@ private static final class SwapchainHolder
final Map<JCSwapchainFrameIndex, VulkanSemaphoreBinaryType> inRenderDoneSemaphores,
final Map<JCSwapchainFrameIndex, VulkanFenceType> inRenderDoneFences,
final Map<JCSwapchainFrameIndex, VulkanFenceType> inPresentDoneFences,
final CloseableCollectionType<VulkanResourceException> inResources)
final CloseableCollectionType<VulkanResourceException> inResources,
final VulkanExtent2D inExtent)
{
this.manager =
Objects.requireNonNull(inManager, "manager");
Expand All @@ -859,6 +872,8 @@ private static final class SwapchainHolder
Map.copyOf(inPresentDoneFences);
this.resources =
Objects.requireNonNull(inResources, "resources");
this.extent =
Objects.requireNonNull(inExtent, "inExtent");
this.frameIndex =
new JCSwapchainFrameIndex(0);
this.id =
Expand Down Expand Up @@ -933,11 +948,11 @@ public void close()

public JCSwapchainImageType acquire(
final VulkanLogicalDeviceType device)
throws
VulkanException,
throws VulkanException,
SwapchainOutOfDate,
SwapchainNotReady,
SwapchainRenderingDoneFenceTimedOut, SwapchainAcquireTimedOut
SwapchainRenderingDoneFenceTimedOut,
SwapchainAcquireTimedOut
{
Objects.requireNonNull(device, "device");

Expand Down Expand Up @@ -1011,7 +1026,8 @@ public JCSwapchainImageType acquire(
renderDoneSemaphore,
presentDoneFence,
this.swapchain,
renderDoneFence
renderDoneFence,
this.extent
);

this.frameIndex = this.nextFrameIndex();
Expand Down

0 comments on commit abdd173

Please sign in to comment.