@@ -611,11 +611,12 @@ pl_starter_begin_main_pass(void)
611611 },
612612 .atColorAttachments = {
613613 {
614- .tTexture = atSwapchainImages [gptGfx -> get_current_swapchain_image_index (gptStarterCtx -> ptSwapchain )],
614+ .tTexture = ( gptStarterCtx -> tFlags & PL_STARTER_FLAGS_MSAA ) ? gptStarterCtx -> tResolveTexture : atSwapchainImages [gptGfx -> get_current_swapchain_image_index (gptStarterCtx -> ptSwapchain )],
615615 .tLoadOp = PL_LOAD_OP_CLEAR ,
616616 .tStoreOp = PL_STORE_OP_STORE ,
617617 .tUsage = PL_TEXTURE_USAGE_COLOR_ATTACHMENT ,
618- .tClearColor = {0.0f , 0.0f , 0.0f , 1.0f }
618+ .tClearColor = {0.0f , 0.0f , 0.0f , 1.0f },
619+ .tResolveTexture = (gptStarterCtx -> tFlags & PL_STARTER_FLAGS_MSAA ) ? atSwapchainImages [gptGfx -> get_current_swapchain_image_index (gptStarterCtx -> ptSwapchain )] : (plTextureHandle ){0 }
619620 }
620621 },
621622 .tDepthAttachment = {
@@ -635,9 +636,18 @@ pl_starter_begin_main_pass(void)
635636 };
636637
637638 // begin main renderpass (directly to swapchain)
638- gptGfx -> change_texture_role (ptCurrentCommandBuffer , atSwapchainImages [gptGfx -> get_current_swapchain_image_index (gptStarterCtx -> ptSwapchain )],
639- PL_PASS_RESOURCE_ROLE_NONE , PL_PASS_RESOURCE_ACCESS_NONE ,
640- PL_PASS_RESOURCE_ROLE_ATTACHMENT , PL_PASS_RESOURCE_ACCESS_WRITE );
639+ if (gptStarterCtx -> tFlags & PL_STARTER_FLAGS_MSAA )
640+ {
641+ gptGfx -> change_texture_role (ptCurrentCommandBuffer , atSwapchainImages [gptGfx -> get_current_swapchain_image_index (gptStarterCtx -> ptSwapchain )],
642+ PL_PASS_RESOURCE_ROLE_NONE , PL_PASS_RESOURCE_ACCESS_NONE ,
643+ PL_PASS_RESOURCE_ROLE_STORAGE , PL_PASS_RESOURCE_ACCESS_WRITE );
644+ }
645+ else
646+ {
647+ gptGfx -> change_texture_role (ptCurrentCommandBuffer , atSwapchainImages [gptGfx -> get_current_swapchain_image_index (gptStarterCtx -> ptSwapchain )],
648+ PL_PASS_RESOURCE_ROLE_NONE , PL_PASS_RESOURCE_ACCESS_NONE ,
649+ PL_PASS_RESOURCE_ROLE_ATTACHMENT , PL_PASS_RESOURCE_ACCESS_WRITE );
650+ }
641651
642652 gptGfx -> begin_render_pass (ptCurrentCommandBuffer , tRenderInfo , NULL );
643653 gptStarterCtx -> ptCurrentCommandBuffer = ptCurrentCommandBuffer ;
@@ -662,6 +672,22 @@ pl_starter_begin_main_pass(void)
662672 return gptStarterCtx -> ptCurrentCommandBuffer ;
663673}
664674
675+ void
676+ pl_starter_get_render_attachment_info (plRenderAttachmentFormatInfo * ptInfoOut )
677+ {
678+ plRenderAttachmentFormatInfo tRenderAttachmentFormatInfo = {
679+ .uColorCount = 1 ,
680+ .atColorFormats = {
681+ gptGfx -> get_swapchain_info (gptStarterCtx -> ptSwapchain ).tFormat
682+ }
683+ };
684+
685+ if (gptStarterCtx -> tFlags & PL_STARTER_FLAGS_DEPTH_BUFFER )
686+ tRenderAttachmentFormatInfo .tDepthFormat = PL_FORMAT_D32_FLOAT_S8_UINT ;
687+
688+ * ptInfoOut = tRenderAttachmentFormatInfo ;
689+ }
690+
665691void
666692pl_starter_end_main_pass (void )
667693{
@@ -725,9 +751,18 @@ pl_starter_end_main_pass(void)
725751 uint32_t uImageCount = 0 ;
726752 plTextureHandle * atSwapchainImages = gptGfx -> get_swapchain_images (gptStarterCtx -> ptSwapchain , & uImageCount );
727753
728- gptGfx -> change_texture_role (gptStarterCtx -> ptCurrentCommandBuffer , atSwapchainImages [gptGfx -> get_current_swapchain_image_index (gptStarterCtx -> ptSwapchain )],
729- PL_PASS_RESOURCE_ROLE_ATTACHMENT , PL_PASS_RESOURCE_ACCESS_WRITE ,
730- PL_PASS_RESOURCE_ROLE_PRESENT , PL_PASS_RESOURCE_ACCESS_READ );
754+ if (gptStarterCtx -> tFlags & PL_STARTER_FLAGS_MSAA )
755+ {
756+ gptGfx -> change_texture_role (gptStarterCtx -> ptCurrentCommandBuffer , atSwapchainImages [gptGfx -> get_current_swapchain_image_index (gptStarterCtx -> ptSwapchain )],
757+ PL_PASS_RESOURCE_ROLE_STORAGE , PL_PASS_RESOURCE_ACCESS_WRITE ,
758+ PL_PASS_RESOURCE_ROLE_PRESENT , PL_PASS_RESOURCE_ACCESS_READ );
759+ }
760+ else
761+ {
762+ gptGfx -> change_texture_role (gptStarterCtx -> ptCurrentCommandBuffer , atSwapchainImages [gptGfx -> get_current_swapchain_image_index (gptStarterCtx -> ptSwapchain )],
763+ PL_PASS_RESOURCE_ROLE_ATTACHMENT , PL_PASS_RESOURCE_ACCESS_WRITE ,
764+ PL_PASS_RESOURCE_ROLE_PRESENT , PL_PASS_RESOURCE_ACCESS_READ );
765+ }
731766
732767 // end recording
733768 gptGfx -> end_command_recording (gptStarterCtx -> ptCurrentCommandBuffer );
@@ -1332,6 +1367,7 @@ pl_load_starter_ext(plApiRegistryI* ptApiRegistry, bool bReload)
13321367 .deactivate_depth_buffer = pl_starter_deactivate_depth_buffer ,
13331368 .activate_vsync = pl_starter_activate_vsync ,
13341369 .deactivate_vsync = pl_starter_deactivate_vsync ,
1370+ .get_render_attachment_info = pl_starter_get_render_attachment_info ,
13351371 };
13361372 pl_set_api (ptApiRegistry , plStarterI , & tApi );
13371373
0 commit comments