Skip to content

Commit c3b6bcf

Browse files
committed
fix: starter ext MSAA & DEPTH issues
1 parent ccbc349 commit c3b6bcf

2 files changed

Lines changed: 35 additions & 18 deletions

File tree

extensions/pl_starter_ext.c

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ pl_starter_resize(void)
338338
plIO* ptIO = gptIOI->get_io();
339339
plSwapchainInit tDesc = {
340340
.bVSync = true,
341-
.uWidth = (uint32_t)ptIO->tMainViewportSize.x,
342-
.uHeight = (uint32_t)ptIO->tMainViewportSize.y,
341+
.uWidth = (uint32_t)(ptIO->tMainViewportSize.x * ptIO->tMainFramebufferScale.x),
342+
.uHeight = (uint32_t)(ptIO->tMainViewportSize.y * ptIO->tMainFramebufferScale.y),
343343
.tSampleCount = (gptStarterCtx->tFlags & PL_STARTER_FLAGS_MSAA) ? gptGfx->get_device_info(gptStarterCtx->ptDevice)->tMaxSampleCount : 1
344344
};
345345
gptGfx->recreate_swapchain(gptStarterCtx->ptSwapchain, &tDesc);
@@ -363,7 +363,10 @@ pl_starter_resize(void)
363363
gptGfx->queue_texture_for_deletion(gptStarterCtx->ptDevice, gptStarterCtx->tDepthTexture);
364364

365365
const plTextureDesc tDepthTextureDesc = {
366-
.tDimensions = {gptIOI->get_io()->tMainViewportSize.x, gptIOI->get_io()->tMainViewportSize.y, 1},
366+
.tDimensions = {
367+
gptIOI->get_io()->tMainViewportSize.x * ptIO->tMainFramebufferScale.x,
368+
gptIOI->get_io()->tMainViewportSize.y * ptIO->tMainFramebufferScale.y,
369+
1},
367370
.tFormat = PL_FORMAT_D32_FLOAT_S8_UINT,
368371
.uLayers = 1,
369372
.uMips = 1,
@@ -391,7 +394,10 @@ pl_starter_resize(void)
391394
gptGfx->queue_texture_for_deletion(gptStarterCtx->ptDevice, gptStarterCtx->tResolveTexture);
392395

393396
const plTextureDesc tDepthTextureDesc = {
394-
.tDimensions = {(float)tInfo.uWidth, (float)tInfo.uHeight, 1},
397+
.tDimensions = {
398+
(float)tInfo.uWidth,
399+
(float)tInfo.uHeight,
400+
1},
395401
.tFormat = tInfo.tFormat,
396402
.uLayers = 1,
397403
.uMips = 1,
@@ -424,8 +430,8 @@ pl_starter_resize(void)
424430
if(gptStarterCtx->tFlags & PL_STARTER_FLAGS_DEPTH_BUFFER && gptStarterCtx->tFlags & PL_STARTER_FLAGS_MSAA)
425431
{
426432
atMainAttachmentSets[i].atViewAttachments[0] = gptStarterCtx->tDepthTexture;
427-
atMainAttachmentSets[i].atViewAttachments[1] = gptStarterCtx->tResolveTexture;
428-
atMainAttachmentSets[i].atViewAttachments[2] = atSwapchainImages[i];
433+
atMainAttachmentSets[i].atViewAttachments[1] = atSwapchainImages[i];
434+
atMainAttachmentSets[i].atViewAttachments[2] = gptStarterCtx->tResolveTexture;
429435
}
430436
else if(gptStarterCtx->tFlags & PL_STARTER_FLAGS_DEPTH_BUFFER)
431437
{
@@ -925,8 +931,8 @@ pl__starter_activate_msaa(void)
925931
plIO* ptIO = gptIOI->get_io();
926932
plSwapchainInit tDesc = {
927933
.bVSync = true,
928-
.uWidth = (uint32_t)ptIO->tMainViewportSize.x,
929-
.uHeight = (uint32_t)ptIO->tMainViewportSize.y,
934+
.uWidth = (uint32_t)(ptIO->tMainViewportSize.x * ptIO->tMainFramebufferScale.x),
935+
.uHeight = (uint32_t)(ptIO->tMainViewportSize.y * ptIO->tMainFramebufferScale.y),
930936
.tSampleCount = gptGfx->get_device_info(gptStarterCtx->ptDevice)->tMaxSampleCount
931937
};
932938
gptGfx->recreate_swapchain(gptStarterCtx->ptSwapchain, &tDesc);
@@ -969,7 +975,10 @@ pl__starter_activate_msaa(void)
969975
gptGfx->queue_texture_for_deletion(gptStarterCtx->ptDevice, gptStarterCtx->tDepthTexture);
970976
plBlitEncoder* ptEncoder = pl_starter_get_blit_encoder();
971977
const plTextureDesc tDepthTextureDesc = {
972-
.tDimensions = {gptIOI->get_io()->tMainViewportSize.x, gptIOI->get_io()->tMainViewportSize.y, 1},
978+
.tDimensions = {
979+
gptIOI->get_io()->tMainViewportSize.x * ptIO->tMainFramebufferScale.x,
980+
gptIOI->get_io()->tMainViewportSize.y * ptIO->tMainFramebufferScale.y,
981+
1},
973982
.tFormat = PL_FORMAT_D32_FLOAT_S8_UINT,
974983
.uLayers = 1,
975984
.uMips = 1,
@@ -1009,8 +1018,8 @@ pl__starter_deactivate_msaa(void)
10091018
plIO* ptIO = gptIOI->get_io();
10101019
plSwapchainInit tDesc = {
10111020
.bVSync = true,
1012-
.uWidth = (uint32_t)ptIO->tMainViewportSize.x,
1013-
.uHeight = (uint32_t)ptIO->tMainViewportSize.y,
1021+
.uWidth = (uint32_t)(ptIO->tMainViewportSize.x * ptIO->tMainFramebufferScale.x),
1022+
.uHeight = (uint32_t)(ptIO->tMainViewportSize.y * ptIO->tMainFramebufferScale.y),
10141023
.tSampleCount = 1
10151024
};
10161025
gptGfx->recreate_swapchain(gptStarterCtx->ptSwapchain, &tDesc);
@@ -1024,7 +1033,10 @@ pl__starter_deactivate_msaa(void)
10241033
gptGfx->queue_texture_for_deletion(gptStarterCtx->ptDevice, gptStarterCtx->tDepthTexture);
10251034
plBlitEncoder* ptEncoder = pl_starter_get_blit_encoder();
10261035
const plTextureDesc tDepthTextureDesc = {
1027-
.tDimensions = {gptIOI->get_io()->tMainViewportSize.x, gptIOI->get_io()->tMainViewportSize.y, 1},
1036+
.tDimensions = {
1037+
gptIOI->get_io()->tMainViewportSize.x * ptIO->tMainFramebufferScale.x,
1038+
gptIOI->get_io()->tMainViewportSize.y * ptIO->tMainFramebufferScale.y,
1039+
1},
10281040
.tFormat = PL_FORMAT_D32_FLOAT_S8_UINT,
10291041
.uLayers = 1,
10301042
.uMips = 1,
@@ -1068,7 +1080,10 @@ pl__starter_activate_depth_buffer(void)
10681080

10691081
plBlitEncoder* ptEncoder = pl_starter_get_blit_encoder();
10701082
const plTextureDesc tDepthTextureDesc = {
1071-
.tDimensions = {gptIOI->get_io()->tMainViewportSize.x, gptIOI->get_io()->tMainViewportSize.y, 1},
1083+
.tDimensions = {
1084+
gptIOI->get_io()->tMainViewportSize.x * gptIOI->get_io()->tMainFramebufferScale.x,
1085+
gptIOI->get_io()->tMainViewportSize.y * gptIOI->get_io()->tMainFramebufferScale.y,
1086+
1},
10721087
.tFormat = PL_FORMAT_D32_FLOAT_S8_UINT,
10731088
.uLayers = 1,
10741089
.uMips = 1,
@@ -1342,8 +1357,9 @@ pl__starter_create_render_pass_with_msaa_and_depth(void)
13421357
const plRenderPassLayoutDesc tMainRenderPassLayoutDesc = {
13431358
.atRenderTargets = {
13441359
{ .tFormat = PL_FORMAT_D32_FLOAT_S8_UINT, .bDepth = true, .tSamples = gptGfx->get_device_info(gptStarterCtx->ptDevice)->tMaxSampleCount }, // depth buffer
1345-
{ .tFormat = gptGfx->get_swapchain_info(gptStarterCtx->ptSwapchain).tFormat, .tSamples = gptGfx->get_device_info(gptStarterCtx->ptDevice)->tMaxSampleCount}, // msaa
13461360
{ .tFormat = gptGfx->get_swapchain_info(gptStarterCtx->ptSwapchain).tFormat, .bResolve = true }, // swapchain
1361+
{ .tFormat = gptGfx->get_swapchain_info(gptStarterCtx->ptSwapchain).tFormat, .tSamples = gptGfx->get_device_info(gptStarterCtx->ptDevice)->tMaxSampleCount}, // msaa
1362+
13471363

13481364
},
13491365
.atSubpasses = {
@@ -1395,7 +1411,7 @@ pl__starter_create_render_pass_with_msaa_and_depth(void)
13951411
.atColorTargets = {
13961412
{
13971413
.tLoadOp = PL_LOAD_OP_CLEAR,
1398-
.tStoreOp = PL_STORE_OP_STORE,
1414+
.tStoreOp = PL_STORE_OP_STORE_MULTISAMPLE_RESOLVE,
13991415
.tCurrentUsage = PL_TEXTURE_USAGE_UNSPECIFIED,
14001416
.tNextUsage = PL_TEXTURE_USAGE_PRESENT,
14011417
.tClearColor = {0.0f, 0.0f, 0.0f, 1.0f}
@@ -1418,8 +1434,9 @@ pl__starter_create_render_pass_with_msaa_and_depth(void)
14181434
for(uint32_t i = 0; i < uImageCount; i++)
14191435
{
14201436
atMainAttachmentSets[i].atViewAttachments[0] = gptStarterCtx->tDepthTexture;
1421-
atMainAttachmentSets[i].atViewAttachments[1] = gptStarterCtx->tResolveTexture;
1422-
atMainAttachmentSets[i].atViewAttachments[2] = atSwapchainImages[i];
1437+
atMainAttachmentSets[i].atViewAttachments[1] = atSwapchainImages[i];
1438+
atMainAttachmentSets[i].atViewAttachments[2] = gptStarterCtx->tResolveTexture;
1439+
14231440
}
14241441
gptStarterCtx->tRenderPass = gptGfx->create_render_pass(gptStarterCtx->ptDevice, &tMainRenderPassDesc, atMainAttachmentSets);
14251442

extensions/pl_starter_ext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Index of this file:
6060
// [SECTION] APIs
6161
//-----------------------------------------------------------------------------
6262

63-
#define plStarterI_version {1, 0, 1}
63+
#define plStarterI_version {1, 0, 2}
6464

6565
//-----------------------------------------------------------------------------
6666
// [SECTION] includes

0 commit comments

Comments
 (0)