Skip to content

Commit 4304388

Browse files
committed
WIP 0
1 parent 131c897 commit 4304388

44 files changed

Lines changed: 3895 additions & 5200 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- name: Install Dependencies
3636
run: |
37-
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.3.296.0/windows/VulkanSDK-1.3.296.0-Installer.exe" -OutFile VulkanSDK.exe
37+
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.3.350.0/windows/VulkanSDK-1.3.350.0-Installer.exe" -OutFile VulkanSDK.exe
3838
# ./VulkanSDK.exe --help
3939
./VulkanSDK.exe --accept-licenses --default-answer --root D:/a/VulkanSDK --confirm-command install
4040
@@ -136,9 +136,9 @@ jobs:
136136

137137
- name: Install Dependencies
138138
run: |
139-
curl https://sdk.lunarg.com/sdk/download/1.3.283.0/mac/vulkansdk-macos-1.3.283.0.dmg -o vk.dmg
139+
curl https://sdk.lunarg.com/sdk/download/1.3.350.0/mac/vulkansdk-macos-1.3.350.0.dmg -o vk.dmg
140140
hdiutil attach vk.dmg
141-
sudo /Volumes/vulkansdk-macos-1.3.283.0/InstallVulkan.app/Contents/MacOS/InstallVulkan --root ~/VulkanSDK/1.3.283.0 --accept-licenses --default-answer --confirm-command install com.lunarg.vulkan.core com.lunarg.vulkan.usr com.lunarg.vulkan.sdl2 com.lunarg.vulkan.glm com.lunarg.vulkan.volk com.lunarg.vulkan.vma com.lunarg.vulkan.ios
141+
sudo /Volumes/vulkansdk-macos-1.3.350.0/InstallVulkan.app/Contents/MacOS/InstallVulkan --root ~/VulkanSDK/1.3.350.0 --accept-licenses --default-answer --confirm-command install com.lunarg.vulkan.core com.lunarg.vulkan.usr com.lunarg.vulkan.sdl2 com.lunarg.vulkan.glm com.lunarg.vulkan.volk com.lunarg.vulkan.vma com.lunarg.vulkan.ios
142142
143143
- name: Prep 1
144144
run: |

docs/changelog.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
Below is the change log for typical users. Minor and older changes stripped
66
away, please see git history for details.
77

8-
- v0.9.3 (2026-06-02)(graphics v1.10.0) -last version before 2.x with breaking changes
8+
- v0.10.0 (xx-xx-xx)
9+
- v0.9.3 (2026-06-02)(graphics v1.10.0) -last version before 2.x with breaking changes
910
-remove necessity of subpass dependencies
1011
-remove necessity of "set_texture_usage(...)"
1112
(camera v1.0.1) -fix camera zero init issues

docs/version.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
v0.9.3
1+
v0.10.0 WIP
22

33
-----------------------------------------------------------------------------
44
Versioning
@@ -56,10 +56,10 @@ the API is complete. It just means we won't break what currently exists.
5656
* Log v2.0.0 (pl_log_ext.h)
5757
* Config v1.2.0 (pl_config_ext.h)
5858
* Console v1.1.0 (pl_console_ext.h)
59-
* Draw v2.1.1 (pl_draw_ext.h)
59+
* Draw v3.0.0 (pl_draw_ext.h)
6060
* DXT v1.1.0 (pl_dxt_ext.h)
6161
* GPU Allocators v1.1.1 (pl_gpu_allocators_ext.h)
62-
* Graphics v1.10.0 (pl_graphics_ext.h)
62+
* Graphics v2.0.0 (pl_graphics_ext.h)
6363
* Image v1.2.0 (pl_image_ext.h)
6464
* Job v2.3.0 (pl_job_ext.h)
6565
* Atomics v2.0.0 (pl_platform_ext.h)
@@ -71,7 +71,7 @@ the API is complete. It just means we won't break what currently exists.
7171
* Rectangle Packing v1.1.0 (pl_rect_pack_ext.h)
7272
* Screen Log v2.2.0 (pl_screen_log_ext.h)
7373
* Shader v1.4.0 (pl_shader_ext.h)
74-
* Starter v1.4.1 (pl_starter_ext.h)
74+
* Starter v2.0.0 (pl_starter_ext.h)
7575
* Stats v1.1.0 (pl_stats_ext.h)
7676
* String Interning v2.0.0 (pl_string_intern_ext.h)
7777
* UI Tools v1.1.0 (pl_tools_ext.h)
@@ -100,13 +100,13 @@ the API is complete. It just means we won't break what currently exists.
100100
* Camera ECS v0.1.0 (pl_camera_ext.h)
101101
* Gizmo v0.1.0 (pl_gizmo_ext.h)
102102
* Model Loader v0.3.0 (pl_model_loader_ext.h)
103-
* Dear ImGui v0.1.0 (pl_dear_imgui_ext.h)
103+
* Dear ImGui v0.2.0 (pl_dear_imgui_ext.h)
104104
* Animation v0.1.0 (pl_animation_ext.h)
105105
* Material v0.1.0 (pl_material_ext.h)
106106
* Terrain v0.1.0 (pl_terrain_ext.h)
107107
* Free List v0.1.0 (pl_freelist_ext.h)
108108
* Image Ops v0.1.0 (pl_image_ops_ext.h)
109-
* Stage v0.1.0 (pl_stage_ext.h)
109+
* Stage v0.2.0 (pl_stage_ext.h)
110110
* Renderer v0.3.0 (pl_renderer_ext.h)
111111
* Renderer Terrain v0.1.0 (pl_renderer_ext.h)
112112
* Renderer Ecs v0.1.0 (pl_renderer_ext.h)

examples/example_basic_4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,11 @@ pl_app_update(plAppData* ptAppData)
384384
// the scope of the draw extension.
385385

386386
// start main pass & return the encoder being used
387-
plRenderEncoder* ptEncoder = gptStarter->begin_main_pass();
387+
plCommandBuffer* ptCmdBuffer = gptStarter->begin_main_pass();
388388

389389
// submit our drawlist
390390
plIO* ptIO = gptIO->get_io();
391-
gptDraw->submit_2d_drawlist(ptAppData->ptDrawlist, ptEncoder, ptIO->tMainViewportSize.x, ptIO->tMainViewportSize.y, 1);
391+
gptDraw->submit_2d_drawlist(ptAppData->ptDrawlist, ptCmdBuffer, ptIO->tMainViewportSize.x, ptIO->tMainViewportSize.y, 1);
392392

393393
// allows the starter extension to handle some things then ends the main pass
394394
gptStarter->end_main_pass();

examples/example_basic_5.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pl_app_update(plAppData* ptAppData)
220220
// the scope of the draw extension.
221221

222222
// start main pass & return the encoder being used
223-
plRenderEncoder* ptEncoder = gptStarter->begin_main_pass();
223+
plCommandBuffer* ptCmdBuffer = gptStarter->begin_main_pass();
224224

225225
// this must be called which handles several things but
226226
// most importantly it orders the various draw layers in
@@ -230,8 +230,8 @@ pl_app_update(plAppData* ptAppData)
230230
// now we must submit both the drawlist & debug drawlist provided by
231231
// the UI extension.
232232
plVec2 tViewportSize = gptIO->get_io()->tMainViewportSize;
233-
gptDraw->submit_2d_drawlist(gptUi->get_draw_list(), ptEncoder, tViewportSize.x, tViewportSize.y, 1);
234-
gptDraw->submit_2d_drawlist(gptUi->get_debug_draw_list(), ptEncoder, tViewportSize.x, tViewportSize.y, 1);
233+
gptDraw->submit_2d_drawlist(gptUi->get_draw_list(), ptCmdBuffer, tViewportSize.x, tViewportSize.y, 1);
234+
gptDraw->submit_2d_drawlist(gptUi->get_debug_draw_list(), ptCmdBuffer, tViewportSize.x, tViewportSize.y, 1);
235235

236236
// allows the starter extension to handle some things then ends the main pass
237237
gptStarter->end_main_pass();

examples/example_gfx_0.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
216216

217217
// create vertex buffer
218218
const plBufferDesc tBufferDesc = {
219-
.tUsage = PL_BUFFER_USAGE_VERTEX | PL_BUFFER_USAGE_TRANSFER_DESTINATION,
219+
.tUsage = PL_BUFFER_USAGE_VERTEX | PL_BUFFER_USAGE_TRANSFER,
220220
.szByteSize = sizeof(float) * PL_ARRAYSIZE(atVertexData),
221221
.pcDebugName = "vertex buffer"
222222
};
@@ -323,17 +323,17 @@ pl_app_update(plAppData* ptAppData)
323323
return;
324324

325325
// start main pass & return the encoder being used
326-
plRenderEncoder* ptEncoder = gptStarter->begin_main_pass();
326+
plCommandBuffer* ptCmdBuffer = gptStarter->begin_main_pass();
327327

328328
// submit nonindexed draw using basic API
329-
gptGfx->bind_shader(ptEncoder, ptAppData->tShader);
330-
gptGfx->bind_vertex_buffer(ptEncoder, ptAppData->tVertexBuffer);
329+
gptGfx->bind_shader(ptCmdBuffer, ptAppData->tShader);
330+
gptGfx->bind_vertex_buffer(ptCmdBuffer, ptAppData->tVertexBuffer);
331331

332332
plDraw tDraw = {
333333
.uInstanceCount = 1,
334334
.uVertexCount = 3
335335
};
336-
gptGfx->draw(ptEncoder, 1, &tDraw);
336+
gptGfx->draw(ptCmdBuffer, 1, &tDraw);
337337

338338
// allows the starter extension to handle some things then ends the main pass
339339
gptStarter->end_main_pass();

examples/example_gfx_1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
184184

185185
// create vertex buffer
186186
const plBufferDesc tVertexBufferDesc = {
187-
.tUsage = PL_BUFFER_USAGE_VERTEX | PL_BUFFER_USAGE_TRANSFER_DESTINATION,
187+
.tUsage = PL_BUFFER_USAGE_VERTEX | PL_BUFFER_USAGE_TRANSFER,
188188
.szByteSize = sizeof(float) * PL_ARRAYSIZE(atVertexData),
189189
.pcDebugName = "vertex buffer"
190190
};
@@ -236,7 +236,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
236236

237237
// create vertex buffer
238238
const plBufferDesc tStagingBufferDesc = {
239-
.tUsage = PL_BUFFER_USAGE_TRANSFER_SOURCE,
239+
.tUsage = PL_BUFFER_USAGE_TRANSFER,
240240
.szByteSize = 4096,
241241
.pcDebugName = "staging buffer"
242242
};

examples/example_gfx_4.c

Lines changed: 83 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ typedef struct _plAppData
6262
// offscreen rendering
6363
bool bResize;
6464
plSamplerHandle tDefaultSampler;
65-
plRenderPassHandle tOffscreenRenderPass;
65+
// plRenderPassHandle tOffscreenRenderPass;
6666
plVec2 tOffscreenSize;
6767
plTextureHandle tColorTexture;
6868
plBindGroupHandle tColorTextureBg;
@@ -266,54 +266,6 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
266266
// NOTE: Render passes directly map to render passes in Vulkan. In Metal
267267
// we emulate them by places appropriate barriers & fences.
268268

269-
plRenderPassAttachments atAttachmentSets[PL_MAX_FRAMES_IN_FLIGHT] = {0};
270-
271-
for(uint32_t i = 0; i < gptGfx->get_frames_in_flight(); i++)
272-
{
273-
// add textures to attachment set for render pass
274-
atAttachmentSets[i].atViewAttachments[0] = ptAppData->tDepthTexture;
275-
atAttachmentSets[i].atViewAttachments[1] = ptAppData->tColorTexture;
276-
}
277-
278-
// create offscreen renderpass layout
279-
const plRenderPassLayoutDesc tRenderPassLayoutDesc = {
280-
.atRenderTargets = {
281-
{ .tFormat = PL_FORMAT_D32_FLOAT_S8_UINT, .bDepth = true }, // depth buffer
282-
{ .tFormat = PL_FORMAT_R32G32B32A32_FLOAT } // color
283-
},
284-
.atSubpasses = {
285-
{
286-
.uRenderTargetCount = 2,
287-
.auRenderTargets = {0, 1}, // these are indices into the render targets above (depth/resolve must be before colors)
288-
},
289-
}
290-
};
291-
292-
// create offscreen renderpass
293-
const plRenderPassDesc tRenderPassDesc = {
294-
.tLayout = gptGfx->create_render_pass_layout(ptDevice, &tRenderPassLayoutDesc),
295-
.tDepthTarget = {
296-
.tLoadOp = PL_LOAD_OP_CLEAR,
297-
.tStoreOp = PL_STORE_OP_DONT_CARE,
298-
.tStencilLoadOp = PL_LOAD_OP_CLEAR,
299-
.tStencilStoreOp = PL_STORE_OP_DONT_CARE,
300-
.tPreviousUsage = PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT,
301-
.tNextUsage = PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT,
302-
.fClearZ = 1.0f
303-
},
304-
.atColorTargets = {
305-
{
306-
.tLoadOp = PL_LOAD_OP_CLEAR,
307-
.tStoreOp = PL_STORE_OP_STORE,
308-
.tPreviousUsage = PL_TEXTURE_USAGE_SAMPLED,
309-
.tNextUsage = PL_TEXTURE_USAGE_SAMPLED,
310-
.tClearColor = {0.0f, 0.0f, 0.0f, 1.0f}
311-
}
312-
},
313-
.tDimensions = {.x = ptAppData->tOffscreenSize.x, .y = ptAppData->tOffscreenSize.y}
314-
};
315-
ptAppData->tOffscreenRenderPass = gptGfx->create_render_pass(ptDevice, &tRenderPassDesc, atAttachmentSets);
316-
317269
// return app memory
318270
return ptAppData;
319271
}
@@ -442,35 +394,102 @@ pl_app_update(plAppData* ptAppData)
442394
// pass below)
443395

444396
// retrieve command buffer (already in recording state)
445-
plCommandBuffer* ptCommandBuffer = gptStarter->get_command_buffer();
397+
plFormat tFormat = PL_FORMAT_R32G32B32A32_FLOAT;
398+
plCommandBuffer* ptCommandBuffer = NULL;
399+
#if 1
400+
ptCommandBuffer = gptStarter->get_command_buffer();
401+
402+
plRenderInfo tRenderInfo = {
403+
.tRenderArea = {
404+
.tMin = {0},
405+
.tMax = ptAppData->tOffscreenSize
406+
},
407+
.atColorAttachments = {
408+
{
409+
.tTexture = ptAppData->tColorTexture,
410+
.tLoadOp = PL_LOAD_OP_CLEAR,
411+
.tStoreOp = PL_STORE_OP_STORE,
412+
.tUsage = PL_TEXTURE_USAGE_COLOR_ATTACHMENT,
413+
.tClearColor = {0.0f, 0.0f, 0.0f, 1.0f}
414+
}
415+
},
416+
.tDepthAttachment = {
417+
.tTexture = ptAppData->tDepthTexture,
418+
.tLoadOp = PL_LOAD_OP_CLEAR,
419+
.tStoreOp = PL_STORE_OP_DONT_CARE,
420+
.tUsage = PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT,
421+
.fClearZ = 1.0f
422+
},
423+
.tStencilAttachment = {
424+
.tTexture = ptAppData->tDepthTexture,
425+
.tLoadOp = PL_LOAD_OP_CLEAR,
426+
.tStoreOp = PL_STORE_OP_DONT_CARE,
427+
.tUsage = PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT,
428+
.uClearStencil = 0
429+
}
430+
};
431+
432+
// begin main renderpass (directly to swapchain)
433+
plPassTextureResource atTextureResources[] = {
434+
{
435+
.tHandle = ptAppData->tColorTexture,
436+
.tStages = PL_SHADER_STAGE_FRAGMENT | PL_SHADER_STAGE_VERTEX,
437+
.tAccess = PL_PASS_RESOURCE_ACCESS_WRITE,
438+
.eUsage = PL_PASS_RESOURCE_ROLE_ATTACHMENT
439+
},
440+
{
441+
.tHandle = ptAppData->tDepthTexture,
442+
.tStages = PL_SHADER_STAGE_FRAGMENT | PL_SHADER_STAGE_VERTEX,
443+
.tAccess = PL_PASS_RESOURCE_ACCESS_WRITE,
444+
.eUsage = PL_PASS_RESOURCE_ROLE_ATTACHMENT
445+
}
446+
};
447+
plPassResources tResources = {
448+
.atTextures = atTextureResources,
449+
.uTextureCount = 2
450+
};
446451

447452
// begin offscreen renderpass
448-
plRenderEncoder* ptEncoder = gptGfx->begin_render_pass(ptCommandBuffer, ptAppData->tOffscreenRenderPass, NULL);
453+
gptGfx->set_roles(ptCommandBuffer, &tResources);
454+
gptGfx->begin_render_pass(ptCommandBuffer, tRenderInfo, &tResources);
449455

450456
// submit our 3D drawlist
457+
458+
plRenderAttachmentFormatInfo tInfo = {
459+
.uColorCount = 1,
460+
.atColorFormats = {
461+
PL_FORMAT_R32G32B32A32_FLOAT
462+
},
463+
.tDepthFormat = PL_FORMAT_D32_FLOAT_S8_UINT,
464+
.tStencilFormat = PL_FORMAT_D32_FLOAT_S8_UINT
465+
};
466+
451467
gptDraw->submit_3d_drawlist(ptAppData->pt3dDrawlist,
452-
ptEncoder,
468+
ptCommandBuffer,
453469
ptAppData->tOffscreenSize.x,
454470
ptAppData->tOffscreenSize.y,
455471
&ptAppData->tCamera.tViewProjMat,
456-
PL_DRAW_FLAG_DEPTH_TEST | PL_DRAW_FLAG_DEPTH_WRITE, 1);
472+
PL_DRAW_FLAG_DEPTH_TEST | PL_DRAW_FLAG_DEPTH_WRITE, 1, &tInfo);
457473

458474
// end offscreen render pass
459-
gptGfx->end_render_pass(ptEncoder);
475+
gptGfx->end_render_pass(ptCommandBuffer);
476+
gptGfx->reset_roles(ptCommandBuffer);
460477

461478
// submit and return our command buffer
462479
gptStarter->submit_command_buffer(ptCommandBuffer);
480+
#endif
463481

464482
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~main~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465483

466484
// add full screen quad for offscreen render
467485
gptDraw->add_image(ptAppData->ptFGLayer, ptAppData->tColorTextureBg.uData, (plVec2){0}, ptIO->tMainViewportSize);
468486

469487
// begin main renderpass (directly to swapchain)
470-
plRenderEncoder* ptMainEncoder = gptStarter->begin_main_pass();
488+
ptCommandBuffer = gptStarter->begin_main_pass();
471489

472490
// submit drawlists
473-
gptDraw->submit_2d_drawlist(ptAppData->ptAppDrawlist, ptMainEncoder, ptIO->tMainViewportSize.x, ptIO->tMainViewportSize.y, 1);
491+
tInfo.atColorFormats[0] = gptGfx->get_swapchain_info(gptStarter->get_swapchain()).tFormat;
492+
gptDraw->submit_2d_drawlist(ptAppData->ptAppDrawlist, ptCommandBuffer, ptIO->tMainViewportSize.x, ptIO->tMainViewportSize.y, 1, &tInfo);
474493

475494
// allows the starter extension to handle some things then ends the main pass
476495
gptStarter->end_main_pass();
@@ -551,15 +570,15 @@ resize_offscreen_resources(plAppData* ptAppData)
551570
};
552571
gptGfx->update_bind_group(ptDevice, ptAppData->tColorTextureBg, &tBGData);
553572

554-
plRenderPassAttachments atAttachmentSets[PL_MAX_FRAMES_IN_FLIGHT] = {0};
573+
// plRenderPassAttachments atAttachmentSets[PL_MAX_FRAMES_IN_FLIGHT] = {0};
555574

556-
for(uint32_t i = 0; i < gptGfx->get_frames_in_flight(); i++)
557-
{
558-
// add textures to attachment set for render pass
559-
atAttachmentSets[i].atViewAttachments[0] = ptAppData->tDepthTexture;
560-
atAttachmentSets[i].atViewAttachments[1] = ptAppData->tColorTexture;
561-
}
575+
// for(uint32_t i = 0; i < gptGfx->get_frames_in_flight(); i++)
576+
// {
577+
// // add textures to attachment set for render pass
578+
// atAttachmentSets[i].atViewAttachments[0] = ptAppData->tDepthTexture;
579+
// atAttachmentSets[i].atViewAttachments[1] = ptAppData->tColorTexture;
580+
// }
562581

563582
// don't create new render pass, just update the attachments
564-
gptGfx->update_render_pass_attachments(ptDevice, ptAppData->tOffscreenRenderPass, ptAppData->tOffscreenSize, atAttachmentSets);
583+
// gptGfx->update_render_pass_attachments(ptDevice, ptAppData->tOffscreenRenderPass, ptAppData->tOffscreenSize, atAttachmentSets);
565584
}

0 commit comments

Comments
 (0)