Skip to content

Commit 0616fe8

Browse files
committed
WIP
1 parent 5feb7a1 commit 0616fe8

File tree

8 files changed

+318
-6
lines changed

8 files changed

+318
-6
lines changed

extensions/pl_draw_backend_ext.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,8 @@ pl_submit_2d_drawlist(plDrawList2D* ptDrawlist, plRenderEncoder* ptEncoder, floa
669669
if(pl_sb_size(ptDrawlist->sbtVertexBuffer) == 0u)
670670
return;
671671

672+
gptGfx->push_render_debug_group(ptEncoder, "2D Draw", (plVec4){0.33f, 0.02f, 0.10f, 1.0f});
673+
672674
plDevice* ptDevice = gptDrawBackendCtx->ptDevice;
673675

674676
const uint32_t uFrameIdx = gptGfx->get_current_frame_index();
@@ -853,11 +855,15 @@ pl_submit_2d_drawlist(plDrawList2D* ptDrawlist, plRenderEncoder* ptEncoder, floa
853855
// bump vertex & index buffer offset
854856
ptBufferInfo->uVertexBufferOffset += uVtxBufSzNeeded;
855857
gptDrawBackendCtx->auIndexBufferOffset[uFrameIdx] += uIdxBufSzNeeded;
858+
859+
gptGfx->pop_render_debug_group(ptEncoder);
856860
}
857861

858862
static void
859863
pl_submit_3d_drawlist(plDrawList3D* ptDrawlist, plRenderEncoder* ptEncoder, float fWidth, float fHeight, const plMat4* ptMVP, plDrawFlags tFlags, uint32_t uMSAASampleCount)
860864
{
865+
gptGfx->push_render_debug_group(ptEncoder, "3D Draw", (plVec4){0.33f, 0.02f, 0.10f, 1.0f});
866+
861867
plDevice* ptDevice = gptDrawBackendCtx->ptDevice;
862868
const uint32_t uFrameIdx = gptGfx->get_current_frame_index();
863869

@@ -1078,6 +1084,7 @@ pl_submit_3d_drawlist(plDrawList3D* ptDrawlist, plRenderEncoder* ptEncoder, floa
10781084

10791085
gptDraw->submit_2d_layer(ptDrawlist->ptLayer);
10801086
pl_submit_2d_drawlist(ptDrawlist->pt2dDrawlist, ptEncoder, fWidth, fHeight, uMSAASampleCount);
1087+
gptGfx->pop_render_debug_group(ptEncoder);
10811088
}
10821089

10831090
plBindGroupPool*

extensions/pl_graphics_cpu.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,52 @@ pl_destroy_compute_shader(plDevice* ptDevice, plComputeShaderHandle tHandle)
886886
{
887887
}
888888

889+
void
890+
pl_push_render_debug_group(plRenderEncoder* ptEncoder, const char* pcLabel, plVec4 tColor)
891+
{
892+
}
893+
894+
void
895+
pl_pop_render_debug_group(plRenderEncoder* ptEncoder)
896+
{
897+
}
898+
899+
void
900+
pl_push_blit_debug_group(plBlitEncoder* ptEncoder, const char* pcLabel, plVec4 tColor)
901+
{
902+
}
903+
904+
void
905+
pl_pop_blit_debug_group(plBlitEncoder* ptEncoder)
906+
{
907+
}
908+
909+
void
910+
pl_push_compute_debug_group(plComputeEncoder* ptEncoder, const char* pcLabel, plVec4 tColor)
911+
{
912+
}
913+
914+
void
915+
pl_pop_compute_debug_group(plComputeEncoder* ptEncoder)
916+
{
917+
}
918+
919+
void
920+
pl_insert_debug_label(plCommandBuffer* ptCmdBuffer, const char* pcLabel, plVec4 tColor)
921+
{
922+
923+
}
924+
925+
void
926+
pl_push_debug_group(plCommandBuffer* ptCmdBuffer, const char* pcLabel, plVec4 tColor)
927+
{
928+
}
929+
930+
void
931+
pl_pop_debug_group(plCommandBuffer* ptCmdBuffer)
932+
{
933+
}
934+
889935
//-----------------------------------------------------------------------------
890936
// [SECTION] internal api implementation
891937
//-----------------------------------------------------------------------------

extensions/pl_graphics_ext.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,15 @@ pl_load_graphics_ext(plApiRegistryI* ptApiRegistry, bool bReload)
11851185
.invalidate_memory = pl_gfx_invalidate_memory,
11861186
.flush_memory = pl_gfx_flush_memory,
11871187
.get_data_type_size = pl_get_data_type_size,
1188+
.push_debug_group = pl_push_debug_group,
1189+
.pop_debug_group = pl_pop_debug_group,
1190+
.push_render_debug_group = pl_push_render_debug_group,
1191+
.pop_render_debug_group = pl_pop_render_debug_group,
1192+
.push_blit_debug_group = pl_push_blit_debug_group,
1193+
.pop_blit_debug_group = pl_pop_blit_debug_group,
1194+
.push_compute_debug_group = pl_push_compute_debug_group,
1195+
.pop_compute_debug_group = pl_pop_compute_debug_group,
1196+
.insert_debug_label = pl_insert_debug_label,
11881197

11891198
#if defined(PL_GRAPHICS_EXPOSE_VULKAN) && defined(PL_VULKAN_BACKEND)
11901199
.get_vulkan_instance = pl_get_vulkan_instance,

extensions/pl_graphics_ext.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Index of this file:
114114
// [SECTION] apis
115115
//-----------------------------------------------------------------------------
116116

117-
#define plGraphicsI_version {1, 3, 0}
117+
#define plGraphicsI_version {1, 4, 0}
118118

119119
//-----------------------------------------------------------------------------
120120
// [SECTION] includes
@@ -504,6 +504,20 @@ typedef struct _plGraphicsI
504504
bool (*invalidate_memory)(plDevice*, uint32_t rangeCount, const plDeviceMemoryRange*); // call after writing from device on non-coherent memory
505505
const plDeviceMemoryAllocation* (*get_allocations)(plDevice*, uint32_t* sizeOut);
506506

507+
//------------------------------DEBUGGING--------------------------------------
508+
509+
void (*push_render_debug_group) (plRenderEncoder*, const char*, plVec4 color);
510+
void (*pop_render_debug_group) (plRenderEncoder*);
511+
void (*push_blit_debug_group) (plBlitEncoder*, const char*, plVec4 color);
512+
void (*pop_blit_debug_group) (plBlitEncoder*);
513+
void (*push_compute_debug_group)(plComputeEncoder*, const char*, plVec4 color);
514+
void (*pop_compute_debug_group) (plComputeEncoder*);
515+
516+
// vulkan only
517+
void (*insert_debug_label)(plCommandBuffer*, const char*, plVec4 color);
518+
void (*push_debug_group) (plCommandBuffer*, const char*, plVec4 color);
519+
void (*pop_debug_group) (plCommandBuffer*);
520+
507521
//---------------------------------MISC----------------------------------------
508522

509523
size_t (*get_data_type_size)(plDataType);

extensions/pl_graphics_metal.m

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,6 +2892,51 @@
28922892
pl__cleanup_common_device(ptDevice);
28932893
}
28942894

2895+
void
2896+
pl_push_render_debug_group(plRenderEncoder* ptEncoder, const char* pcLabel, plVec4 tColor)
2897+
{
2898+
}
2899+
2900+
void
2901+
pl_pop_render_debug_group(plRenderEncoder* ptEncoder)
2902+
{
2903+
}
2904+
2905+
void
2906+
pl_push_blit_debug_group(plBlitEncoder* ptEncoder, const char* pcLabel, plVec4 tColor)
2907+
{
2908+
}
2909+
2910+
void
2911+
pl_pop_blit_debug_group(plBlitEncoder* ptEncoder)
2912+
{
2913+
}
2914+
2915+
void
2916+
pl_push_compute_debug_group(plComputeEncoder* ptEncoder, const char* pcLabel, plVec4 tColor)
2917+
{
2918+
}
2919+
2920+
void
2921+
pl_pop_compute_debug_group(plComputeEncoder* ptEncoder)
2922+
{
2923+
}
2924+
2925+
void
2926+
pl_insert_debug_label(plCommandBuffer* ptCmdBuffer, const char* pcLabel, plVec4 tColor)
2927+
{
2928+
}
2929+
2930+
void
2931+
pl_push_debug_group(plCommandBuffer* ptCmdBuffer, const char* pcLabel, plVec4 tColor)
2932+
{
2933+
}
2934+
2935+
void
2936+
pl_pop_debug_group(plCommandBuffer* ptCmdBuffer)
2937+
{
2938+
}
2939+
28952940
//-----------------------------------------------------------------------------
28962941
// [SECTION] internal api implementation
28972942
//-----------------------------------------------------------------------------

extensions/pl_graphics_vulkan.c

Lines changed: 172 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ typedef struct _plDevice
290290
PFN_vkCmdDebugMarkerBeginEXT vkCmdDebugMarkerBegin;
291291
PFN_vkCmdDebugMarkerEndEXT vkCmdDebugMarkerEnd;
292292
PFN_vkCmdDebugMarkerInsertEXT vkCmdDebugMarkerInsert;
293+
PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabel;
294+
PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabel;
295+
PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabel;
293296

294297
// memory blocks
295298
plDeviceMemoryAllocation* sbtMemoryBlocks;
@@ -1977,6 +1980,150 @@ pl_update_render_pass_attachments(plDevice* ptDevice, plRenderPassHandle tHandle
19771980
}
19781981
}
19791982

1983+
void
1984+
pl_insert_debug_label(plCommandBuffer* ptCmdBuffer, const char* pcLabel, plVec4 tColor)
1985+
{
1986+
plDevice* ptDevice = ptCmdBuffer->ptDevice;
1987+
1988+
if(ptDevice->vkCmdInsertDebugUtilsLabel == NULL)
1989+
return;
1990+
1991+
VkDebugUtilsLabelEXT tLabel = {
1992+
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
1993+
.pNext = NULL,
1994+
.pLabelName = pcLabel,
1995+
.color = {
1996+
tColor.r,
1997+
tColor.g,
1998+
tColor.b,
1999+
tColor.a
2000+
}
2001+
};
2002+
ptDevice->vkCmdInsertDebugUtilsLabel(ptCmdBuffer->tCmdBuffer, &tLabel);
2003+
}
2004+
2005+
void
2006+
pl_push_debug_group(plCommandBuffer* ptCmdBuffer, const char* pcLabel, plVec4 tColor)
2007+
{
2008+
2009+
plDevice* ptDevice = ptCmdBuffer->ptDevice;
2010+
2011+
if(ptDevice->vkCmdBeginDebugUtilsLabel == NULL)
2012+
return;
2013+
2014+
VkDebugUtilsLabelEXT tLabel = {
2015+
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
2016+
.pNext = NULL,
2017+
.pLabelName = pcLabel,
2018+
.color = {
2019+
tColor.r,
2020+
tColor.g,
2021+
tColor.b,
2022+
tColor.a
2023+
}
2024+
};
2025+
ptDevice->vkCmdBeginDebugUtilsLabel(ptCmdBuffer->tCmdBuffer, &tLabel);
2026+
}
2027+
2028+
void
2029+
pl_pop_debug_group(plCommandBuffer* ptCmdBuffer)
2030+
{
2031+
plDevice* ptDevice = ptCmdBuffer->ptDevice;
2032+
if(ptDevice->vkCmdEndDebugUtilsLabel)
2033+
ptDevice->vkCmdEndDebugUtilsLabel(ptCmdBuffer->tCmdBuffer);
2034+
}
2035+
2036+
void
2037+
pl_push_render_debug_group(plRenderEncoder* ptEncoder, const char* pcLabel, plVec4 tColor)
2038+
{
2039+
2040+
plDevice* ptDevice = ptEncoder->ptCommandBuffer->ptDevice;
2041+
2042+
if(ptDevice->vkCmdBeginDebugUtilsLabel == NULL)
2043+
return;
2044+
2045+
VkDebugUtilsLabelEXT tLabel = {
2046+
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
2047+
.pNext = NULL,
2048+
.pLabelName = pcLabel,
2049+
.color = {
2050+
tColor.r,
2051+
tColor.g,
2052+
tColor.b,
2053+
tColor.a
2054+
}
2055+
};
2056+
ptDevice->vkCmdBeginDebugUtilsLabel(ptEncoder->ptCommandBuffer->tCmdBuffer, &tLabel);
2057+
}
2058+
2059+
void
2060+
pl_pop_render_debug_group(plRenderEncoder* ptEncoder)
2061+
{
2062+
plDevice* ptDevice = ptEncoder->ptCommandBuffer->ptDevice;
2063+
if(ptDevice->vkCmdEndDebugUtilsLabel)
2064+
ptDevice->vkCmdEndDebugUtilsLabel(ptEncoder->ptCommandBuffer->tCmdBuffer);
2065+
}
2066+
2067+
void
2068+
pl_push_blit_debug_group(plBlitEncoder* ptEncoder, const char* pcLabel, plVec4 tColor)
2069+
{
2070+
plDevice* ptDevice = ptEncoder->ptCommandBuffer->ptDevice;
2071+
2072+
if(ptDevice->vkCmdBeginDebugUtilsLabel == NULL)
2073+
return;
2074+
2075+
VkDebugUtilsLabelEXT tLabel = {
2076+
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
2077+
.pNext = NULL,
2078+
.pLabelName = pcLabel,
2079+
.color = {
2080+
tColor.r,
2081+
tColor.g,
2082+
tColor.b,
2083+
tColor.a
2084+
}
2085+
};
2086+
ptDevice->vkCmdBeginDebugUtilsLabel(ptEncoder->ptCommandBuffer->tCmdBuffer, &tLabel);
2087+
}
2088+
2089+
void
2090+
pl_pop_blit_debug_group(plBlitEncoder* ptEncoder)
2091+
{
2092+
plDevice* ptDevice = ptEncoder->ptCommandBuffer->ptDevice;
2093+
if(ptDevice->vkCmdEndDebugUtilsLabel)
2094+
ptDevice->vkCmdEndDebugUtilsLabel(ptEncoder->ptCommandBuffer->tCmdBuffer);
2095+
}
2096+
2097+
void
2098+
pl_push_compute_debug_group(plComputeEncoder* ptEncoder, const char* pcLabel, plVec4 tColor)
2099+
{
2100+
plDevice* ptDevice = ptEncoder->ptCommandBuffer->ptDevice;
2101+
2102+
if(ptDevice->vkCmdBeginDebugUtilsLabel == NULL)
2103+
return;
2104+
2105+
VkDebugUtilsLabelEXT tLabel = {
2106+
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
2107+
.pNext = NULL,
2108+
.pLabelName = pcLabel,
2109+
.color = {
2110+
tColor.r,
2111+
tColor.g,
2112+
tColor.b,
2113+
tColor.a
2114+
}
2115+
};
2116+
ptDevice->vkCmdBeginDebugUtilsLabel(ptEncoder->ptCommandBuffer->tCmdBuffer, &tLabel);
2117+
}
2118+
2119+
void
2120+
pl_pop_compute_debug_group(plComputeEncoder* ptEncoder)
2121+
{
2122+
plDevice* ptDevice = ptEncoder->ptCommandBuffer->ptDevice;
2123+
if(ptDevice->vkCmdEndDebugUtilsLabel)
2124+
ptDevice->vkCmdEndDebugUtilsLabel(ptEncoder->ptCommandBuffer->tCmdBuffer);
2125+
}
2126+
19802127
void
19812128
pl_begin_command_recording(plCommandBuffer* ptCommandBuffer, const plBeginCommandInfo* ptBeginInfo)
19822129
{
@@ -1995,9 +2142,23 @@ pl_begin_command_recording(plCommandBuffer* ptCommandBuffer, const plBeginComman
19952142
plRenderEncoder*
19962143
pl_begin_render_pass(plCommandBuffer* ptCmdBuffer, plRenderPassHandle tPass, const plPassResources* ptResource)
19972144
{
1998-
plDevice* ptDevice = ptCmdBuffer->ptDevice;
19992145

2146+
plDevice* ptDevice = ptCmdBuffer->ptDevice;
20002147
plRenderPass* ptRenderPass = &ptDevice->sbtRenderPassesCold[tPass.uIndex];
2148+
2149+
// VkDebugUtilsLabelEXT tLabel = {
2150+
// .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
2151+
// .pNext = NULL,
2152+
// .pLabelName = ptRenderPass->tDesc.pcDebugName,
2153+
// .color[0] = 0.33f,
2154+
// .color[1] = 0.02f,
2155+
// .color[2] = 0.10f,
2156+
// .color[3] = 1.0f
2157+
// };
2158+
2159+
// if(ptDevice->vkCmdBeginDebugUtilsLabel)
2160+
// ptDevice->vkCmdBeginDebugUtilsLabel(ptCmdBuffer->tCmdBuffer, &tLabel);
2161+
20012162
plVulkanRenderPass* ptVulkanRenderPass = &ptDevice->sbtRenderPassesHot[tPass.uIndex];
20022163
plRenderPassLayout* ptLayout = &ptDevice->sbtRenderPassLayoutsCold[ptRenderPass->tDesc.tLayout.uIndex];
20032164

@@ -2136,6 +2297,9 @@ pl_end_render_pass(plRenderEncoder* ptEncoder)
21362297
}
21372298
vkCmdEndRenderPass(ptCmdBuffer->tCmdBuffer);
21382299

2300+
// if(ptDevice->vkCmdEndDebugUtilsLabel)
2301+
// ptDevice->vkCmdEndDebugUtilsLabel(ptCmdBuffer->tCmdBuffer);
2302+
21392303
pl__return_render_encoder(ptEncoder);
21402304
}
21412305

@@ -3124,11 +3288,14 @@ pl_create_device(const plDeviceInit* ptInit)
31243288

31253289
if (gptGraphics->bValidationActive)
31263290
{
3127-
ptDevice->vkDebugMarkerSetObjectTag = (PFN_vkDebugMarkerSetObjectTagEXT)vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkDebugMarkerSetObjectTagEXT");
3291+
ptDevice->vkDebugMarkerSetObjectTag = (PFN_vkDebugMarkerSetObjectTagEXT)vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkDebugMarkerSetObjectTagEXT");
31283292
ptDevice->vkDebugMarkerSetObjectName = (PFN_vkDebugMarkerSetObjectNameEXT)vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkDebugMarkerSetObjectNameEXT");
3129-
ptDevice->vkCmdDebugMarkerBegin = (PFN_vkCmdDebugMarkerBeginEXT)vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkCmdDebugMarkerBeginEXT");
3130-
ptDevice->vkCmdDebugMarkerEnd = (PFN_vkCmdDebugMarkerEndEXT)vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkCmdDebugMarkerEndEXT");
3131-
ptDevice->vkCmdDebugMarkerInsert = (PFN_vkCmdDebugMarkerInsertEXT)vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkCmdDebugMarkerInsertEXT");
3293+
ptDevice->vkCmdDebugMarkerBegin = (PFN_vkCmdDebugMarkerBeginEXT)vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkCmdDebugMarkerBeginEXT");
3294+
ptDevice->vkCmdDebugMarkerEnd = (PFN_vkCmdDebugMarkerEndEXT)vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkCmdDebugMarkerEndEXT");
3295+
ptDevice->vkCmdDebugMarkerInsert = (PFN_vkCmdDebugMarkerInsertEXT)vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkCmdDebugMarkerInsertEXT");
3296+
ptDevice->vkCmdBeginDebugUtilsLabel = (PFN_vkCmdBeginDebugUtilsLabelEXT) vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkCmdBeginDebugUtilsLabelEXT");
3297+
ptDevice->vkCmdEndDebugUtilsLabel = (PFN_vkCmdEndDebugUtilsLabelEXT) vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkCmdEndDebugUtilsLabelEXT");
3298+
ptDevice->vkCmdInsertDebugUtilsLabel = (PFN_vkCmdInsertDebugUtilsLabelEXT) vkGetDeviceProcAddr(ptDevice->tLogicalDevice, "vkCmdInsertDebugUtilsLabelEXT");
31323299
}
31333300

31343301
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~main descriptor pool~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)