Skip to content

Commit

Permalink
fix: metal backend MSAA
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffstadt committed Feb 21, 2025
1 parent a8c90c4 commit 38cbe22
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
11 changes: 8 additions & 3 deletions extensions/pl_graphics_metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,11 @@
plTimelineSemaphore* ptSemaphoreFreeList;

// render pass layouts
plRenderPassLayoutHandle tMainRenderPassLayout;
plMetalRenderPassLayout* sbtRenderPassLayoutsHot;
plRenderPassLayout* sbtRenderPassLayoutsCold;
uint16_t* sbtRenderPassLayoutFreeIndices;

// render passes
plRenderPassHandle tMainRenderPass;
plMetalRenderPass* sbtRenderPassesHot;
plRenderPass* sbtRenderPassesCold;
uint16_t* sbtRenderPassFreeIndices;
Expand Down Expand Up @@ -1607,7 +1605,7 @@
for(uint32_t i = 0; i < gptGraphics->uFramesInFlight; i++)
{
plFrameContext tFrame = {
.tFrameBoundarySemaphore = dispatch_semaphore_create(1),
.tFrameBoundarySemaphore = dispatch_semaphore_create(gptGraphics->uFramesInFlight),
};
pl_sb_resize(tFrame.sbtDynamicBuffers, 1);
static char atNameBuffer[PL_MAX_NAME_LENGTH] = {0};
Expand Down Expand Up @@ -1689,6 +1687,13 @@
ptSwap->tInfo.tSampleCount = pl_min(ptInit->tSampleCount, ptSwap->ptDevice->tInfo.tMaxSampleCount);
if(ptSwap->tInfo.tSampleCount == 0)
ptSwap->tInfo.tSampleCount = 1;

uint32_t uNextFrameIndex = (gptGraphics->uCurrentFrameIndex + 1) % gptGraphics->uFramesInFlight;
plFrameContext* ptFrame1 = &ptSwap->ptDevice->sbtFrames[uNextFrameIndex];
plFrameContext* ptFrame0 = pl__get_frame_resources(ptSwap->ptDevice);
// dispatch_semaphore_wait(ptFrame->tFrameBoundarySemaphore, DISPATCH_TIME_FOREVER);
dispatch_semaphore_signal(ptFrame0->tFrameBoundarySemaphore);
dispatch_semaphore_signal(ptFrame1->tFrameBoundarySemaphore);
}

static plCommandPool*
Expand Down
2 changes: 1 addition & 1 deletion extensions/pl_renderer_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -3944,7 +3944,7 @@ pl_refr_begin_frame(void)
.tLayout = gptData->tMainRenderPassLayout,
.atColorTargets = { // msaa
{
.tLoadOp = PL_LOAD_OP_DONT_CARE,
.tLoadOp = PL_LOAD_OP_CLEAR,
.tStoreOp = PL_STORE_OP_STORE,
.tCurrentUsage = PL_TEXTURE_USAGE_UNSPECIFIED,
.tNextUsage = PL_TEXTURE_USAGE_PRESENT,
Expand Down
5 changes: 3 additions & 2 deletions src/pl_main_macos.m
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,8 @@ - (void)unmarkText
void
pl_wake_all_condition_variable(plConditionVariable* ptConditionVariable)
{
pthread_cond_broadcast(&ptConditionVariable->tHandle);
if(ptConditionVariable)
pthread_cond_broadcast(&ptConditionVariable->tHandle);
}

void
Expand Down Expand Up @@ -2098,4 +2099,4 @@ - (void)unmarkText
// [SECTION] unity build
//-----------------------------------------------------------------------------

#include "pl.c"
#include "pl.c"

0 comments on commit 38cbe22

Please sign in to comment.