Skip to content

Commit b351ed3

Browse files
committed
WIP
1 parent 48fabc4 commit b351ed3

File tree

9 files changed

+51
-23
lines changed

9 files changed

+51
-23
lines changed

examples/build_linux.sh

100644100755
File mode changed.

examples/build_macos.sh

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,8 @@ PL_RESULT=${BOLD}${GREEN}Successful.${NC}
941941
PL_DEFINES="-D_USE_MATH_DEFINES -DPL_PROFILING_ON -DPL_ALLOW_HOT_RELOAD -DPL_ENABLE_VALIDATION_LAYERS -DPL_CONFIG_DEBUG -DPL_EXPERIMENTAL "
942942
PL_INCLUDE_DIRECTORIES="-I../examples -I../editor -I../src -I../libs -I../extensions -I../out -I../dependencies/stb -I../dependencies/imgui "
943943
PL_LINK_DIRECTORIES="-L../out -Wl,-rpath,../out -L/usr/local/lib -Wl,-rpath,/usr/local/lib "
944-
PL_COMPILER_FLAGS="-std=c++14 --debug -g -fmodules -ObjC -fPIC "
945-
PL_LINKER_FLAGS=""
944+
PL_COMPILER_FLAGS="-std=c++14 --debug -g -fmodules -ObjC++ -fPIC "
945+
PL_LINKER_FLAGS="-lstdc++ -ldl -lm "
946946
PL_STATIC_LINK_LIBRARIES="-ldearimguid "
947947
PL_DYNAMIC_LINK_LIBRARIES=""
948948
PL_SOURCES="example_basic_5.cpp "
@@ -1017,7 +1017,7 @@ PL_RESULT=${BOLD}${GREEN}Successful.${NC}
10171017
PL_DEFINES="-D_USE_MATH_DEFINES -DPL_PROFILING_ON -DPL_ALLOW_HOT_RELOAD -DPL_ENABLE_VALIDATION_LAYERS -DPL_CONFIG_DEBUG -DPL_EXPERIMENTAL "
10181018
PL_INCLUDE_DIRECTORIES="-I../examples -I../editor -I../src -I../libs -I../extensions -I../out -I../dependencies/stb -I../dependencies/imgui "
10191019
PL_LINK_DIRECTORIES="-L../out -Wl,-rpath,../out -L/usr/local/lib -Wl,-rpath,/usr/local/lib "
1020-
PL_COMPILER_FLAGS="-std=c++14 -fmodules -ObjC -fPIC "
1020+
PL_COMPILER_FLAGS="-std=c++14 -fmodules -ObjC++ -fPIC "
10211021
PL_LINKER_FLAGS=""
10221022
PL_STATIC_LINK_LIBRARIES="-ldearimgui "
10231023
PL_DYNAMIC_LINK_LIBRARIES=""

extensions/pl_graphics_metal.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
typedef struct _plMetalFrameBuffer
8282
{
83-
MTLRenderPassDescriptor** sbptRenderPassDescriptor;
83+
MTLRenderPassDescriptor** sbptRenderPassDescriptor; // one per subpass
8484
} plMetalFrameBuffer;
8585

8686
typedef struct _plMetalRenderPass
@@ -3513,6 +3513,16 @@
35133513

35143514
}
35153515

3516+
void
3517+
pl_destroy_sampler(plDevice* ptDevice, plSamplerHandle tHandle)
3518+
{
3519+
pl_log_trace_f(gptLog, uLogChannelGraphics, "destroy sampler %u immediately", tHandle.uIndex);
3520+
[ptDevice->sbtSamplersHot[tHandle.uIndex].tSampler release];
3521+
ptDevice->sbtSamplersHot[tHandle.uIndex].tSampler = nil;
3522+
ptDevice->sbtSamplersCold[tHandle.uIndex]._uGeneration++;
3523+
pl_sb_push(ptDevice->sbtSamplerFreeIndices, tHandle.uIndex);
3524+
}
3525+
35163526
static void
35173527
pl_destroy_compute_shader(plDevice* ptDevice, plComputeShaderHandle tHandle)
35183528
{

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

scripts/gen_examples.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@
147147
# macos
148148
with pl.platform("Darwin"):
149149
with pl.compiler("clang"):
150-
pl.add_compiler_flags("-std=c++14", "--debug", "-g", "-fmodules", "-ObjC", "-fPIC")
150+
pl.add_linker_flags("-lstdc++", "-ldl", "-lm")
151+
pl.add_compiler_flags("-std=c++14", "--debug", "-g", "-fmodules", "-ObjC++", "-fPIC")
151152
pl.add_link_frameworks("Metal", "MetalKit", "Cocoa", "IOKit", "CoreVideo", "QuartzCore")
152153
pl.add_link_directories("/usr/local/lib")
153154

@@ -173,7 +174,7 @@
173174
# macos
174175
with pl.platform("Darwin"):
175176
with pl.compiler("clang"):
176-
pl.add_compiler_flags("-std=c++14", "-fmodules", "-ObjC", "-fPIC")
177+
pl.add_compiler_flags("-std=c++14", "-fmodules", "-ObjC++", "-fPIC")
177178
pl.add_link_frameworks("Metal", "MetalKit", "Cocoa", "IOKit", "CoreVideo", "QuartzCore")
178179
pl.add_link_directories("/usr/local/lib")
179180

src/build_linux.sh

100644100755
File mode changed.

src/build_macos.sh

100644100755
File mode changed.

tests/build_linux.sh

100644100755
File mode changed.

tests/build_macos.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)