Skip to content

Commit dd66a09

Browse files
committed
apply fixes to uint8_t clamping of swapchain values
1 parent e890b47 commit dd66a09

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

include/nbl/video/CVulkanSwapchain.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CVulkanSwapchain final : public ISwapchain
2424
inline VkSwapchainKHR getInternalObject() const {return m_vkSwapchainKHR;}
2525

2626
// returns the maximum number of time acquire can be called without releasing the image index through present.
27-
inline uint8_t getMaxBlockingAcquiresBeforePresent() const override { return static_cast<uint8_t>(m_maxBlockingAcquiresBeforePresent); }
27+
inline uint8_t getMaxBlockingAcquiresBeforePresent() const override { return m_maxBlockingAcquiresBeforePresent; }
2828

2929
// returns the maximum number of acquires you can request without waiting for previous acquire semaphores to signal.
3030
uint8_t getMaxAcquiresInFlight() const override { return getImageCount(); }
@@ -39,7 +39,7 @@ class CVulkanSwapchain final : public ISwapchain
3939
const VkSemaphore* const _acquireAdaptorSemaphores,
4040
const VkSemaphore* const _prePresentSemaphores,
4141
const VkSemaphore* const _presentAdaptorSemaphores,
42-
const uint32_t maxAcquiresBeforePresent
42+
const uint8_t maxAcquiresBeforePresent
4343
);
4444
~CVulkanSwapchain();
4545

@@ -58,7 +58,7 @@ class CVulkanSwapchain final : public ISwapchain
5858
uint64_t m_perImageAcquireCount[ISwapchain::MaxImages] = { 0 };
5959
// nasty way to fight UB of the Vulkan spec
6060
bool m_needToWaitIdle = true;
61-
uint32_t m_maxBlockingAcquiresBeforePresent = 0u;
61+
uint8_t m_maxBlockingAcquiresBeforePresent = 0u;
6262
};
6363

6464
}

src/nbl/video/CVulkanSwapchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ core::smart_refctd_ptr<CVulkanSwapchain> CVulkanSwapchain::create(core::smart_re
151151
ISurface::SCapabilities caps = {};
152152
params.surface->getSurfaceCapabilitiesForPhysicalDevice(physDev, caps);
153153
// read https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap34.html#swapchain-acquire-forward-progress
154-
const uint32_t maxAcquiresWithoutPresent = imageCount - caps.minImageCount + 1u;
154+
const uint8_t maxAcquiresWithoutPresent = core::min(imageCount,ISwapchain::MaxImages) - caps.minImageCount + 1u;
155155

156156
return core::smart_refctd_ptr<CVulkanSwapchain>(new CVulkanSwapchain(std::move(device),std::move(params),imageCount,std::move(oldSwapchain),vk_swapchain,semaphores+imageCount,semaphores,semaphores+2*imageCount, maxAcquiresWithoutPresent),core::dont_grab);
157157
}
@@ -165,7 +165,7 @@ CVulkanSwapchain::CVulkanSwapchain(
165165
const VkSemaphore* const _acquireAdaptorSemaphores,
166166
const VkSemaphore* const _prePresentSemaphores,
167167
const VkSemaphore* const _presentAdaptorSemaphores,
168-
const uint32_t maxAcquiresBeforePresent)
168+
const uint8_t maxAcquiresBeforePresent)
169169
: ISwapchain(std::move(logicalDevice),std::move(params),imageCount,std::move(oldSwapchain)),
170170
m_imgMemRequirements{.size=0,.memoryTypeBits=0x0u,.alignmentLog2=63,.prefersDedicatedAllocation=true,.requiresDedicatedAllocation=true}, m_vkSwapchainKHR(swapchain), m_maxBlockingAcquiresBeforePresent(maxAcquiresBeforePresent)
171171
{

0 commit comments

Comments
 (0)