Skip to content

Commit 5cfee81

Browse files
committed
WIP
1 parent c2e1512 commit 5cfee81

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

extensions/pl_graphics_vulkan.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,7 +3672,10 @@ pl_create_swapchain(plDevice* ptDevice, plSurface* ptSurface, const plSwapchainI
36723672
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
36733673
};
36743674
for (uint32_t i = 0; i < gptGraphics->uFramesInFlight; i++)
3675+
{
36753676
PL_VULKAN(vkCreateSemaphore(ptDevice->tLogicalDevice, &tSemaphoreInfo, gptGraphics->ptAllocationCallbacks, &ptSwap->atImageAvailable[i]));
3677+
pl__set_vulkan_object_name(ptDevice, (uint64_t)ptSwap->atImageAvailable[i], VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, "image available");
3678+
}
36763679
return ptSwap;
36773680
}
36783681

@@ -3830,9 +3833,14 @@ void
38303833
pl_recreate_swapchain(plSwapchain* ptSwap, const plSwapchainInit* ptInit)
38313834
{
38323835
pl_begin_cpu_sample(gptProfile, 0, __FUNCTION__);
3836+
3837+
plDevice* ptDevice = ptSwap->ptDevice;
3838+
VkSurfaceCapabilitiesKHR tCapabilities = {0};
3839+
PL_VULKAN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(ptDevice->tPhysicalDevice, ptSwap->ptSurface->tSurface, &tCapabilities));
3840+
38333841
ptSwap->tInfo.bVSync = ptInit->bVSync;
3834-
ptSwap->tInfo.uWidth = ptInit->uWidth;
3835-
ptSwap->tInfo.uHeight = ptInit->uHeight;
3842+
ptSwap->tInfo.uWidth = tCapabilities.currentExtent.width;
3843+
ptSwap->tInfo.uHeight = tCapabilities.currentExtent.height;
38363844
ptSwap->tInfo.tSampleCount = pl_min(ptInit->tSampleCount, ptSwap->ptDevice->tInfo.tMaxSampleCount);
38373845
if(ptSwap->tInfo.tSampleCount == 0)
38383846
ptSwap->tInfo.tSampleCount = 1;
@@ -5185,11 +5193,17 @@ pl__create_swapchain(uint32_t uWidth, uint32_t uHeight, plSwapchain* ptSwap)
51855193
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
51865194
};
51875195

5188-
const uint32_t uNewSemaphoreCount = ptSwap->uImageCount - pl_sb_size(ptSwap->sbtRenderFinish);
5189-
for (uint32_t i = 0; i < uNewSemaphoreCount; i++)
5196+
for (uint32_t i = 0; i < pl_sb_size(ptSwap->sbtRenderFinish); i++)
5197+
{
5198+
vkDestroySemaphore(ptDevice->tLogicalDevice, ptSwap->sbtRenderFinish[i], gptGraphics->ptAllocationCallbacks);
5199+
}
5200+
pl_sb_reset(ptSwap->sbtRenderFinish);
5201+
5202+
for (uint32_t i = 0; i < ptSwap->uImageCount; i++)
51905203
{
51915204
pl_sb_add(ptSwap->sbtRenderFinish);
51925205
PL_VULKAN(vkCreateSemaphore(ptDevice->tLogicalDevice, &tSemaphoreInfo, gptGraphics->ptAllocationCallbacks, &pl_sb_top(ptSwap->sbtRenderFinish)));
5206+
pl__set_vulkan_object_name(ptDevice, (uint64_t)pl_sb_top(ptSwap->sbtRenderFinish), VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, "render finish");
51935207
}
51945208

51955209
for (uint32_t i = 0; i < ptSwap->uImageCount; i++)

extensions/pl_starter_ext.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ pl_starter_resize(void)
363363
if(gptStarterCtx->tFlags & PL_STARTER_FLAGS_DEPTH_BUFFER)
364364
{
365365
plVec3 tNewDimensions = {
366-
gptIOI->get_io()->tMainViewportSize.x * ptIO->tMainFramebufferScale.x,
367-
gptIOI->get_io()->tMainViewportSize.y * ptIO->tMainFramebufferScale.y,
366+
(float)tInfo.uWidth * ptIO->tMainFramebufferScale.x,
367+
(float)tInfo.uHeight * ptIO->tMainFramebufferScale.y,
368368
1};
369369

370370
plTexture* ptTexture = gptGfx->get_texture(gptStarterCtx->ptDevice, gptStarterCtx->tDepthTexture);
@@ -485,7 +485,7 @@ pl_starter_resize(void)
485485
gptGfx->return_command_buffer(ptCommandBuffer);
486486
}
487487

488-
gptGfx->update_render_pass_attachments(gptStarterCtx->ptDevice, gptStarterCtx->tRenderPass, gptIOI->get_io()->tMainViewportSize, atMainAttachmentSets);
488+
gptGfx->update_render_pass_attachments(gptStarterCtx->ptDevice, gptStarterCtx->tRenderPass, (plVec2){(float)tInfo.uWidth, (float)tInfo.uHeight}, atMainAttachmentSets);
489489
}
490490

491491
void

0 commit comments

Comments
 (0)