Skip to content

Commit 81514a7

Browse files
committed
WIP
1 parent 846c38b commit 81514a7

15 files changed

Lines changed: 796 additions & 935 deletions

docs/version.txt

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,37 @@ the API is complete. It just means we won't break what currently exists.
5353

5454
## Stable APIs
5555

56-
* Log v2.0.0 (pl_log_ext.h)
57-
* Config v1.2.0 (pl_config_ext.h)
58-
* Console v1.1.0 (pl_console_ext.h)
59-
* Draw v2.1.1 (pl_draw_ext.h)
60-
* DXT v1.1.0 (pl_dxt_ext.h)
61-
* GPU Allocators v1.1.1 (pl_gpu_allocators_ext.h)
62-
* Graphics v1.9.0 (pl_graphics_ext.h)
63-
* Image v1.2.0 (pl_image_ext.h)
64-
* Job v2.3.0 (pl_job_ext.h)
65-
* Atomics v2.0.0 (pl_platform_ext.h)
66-
* File v1.1.0 (pl_platform_ext.h)
67-
* Network v1.0.0 (pl_platform_ext.h)
68-
* Threads v1.0.1 (pl_platform_ext.h)
69-
* Virtual Memory v1.0.0 (pl_platform_ext.h)
70-
* Profile v2.0.0 (pl_profile_ext.h)
71-
* Rectangle Packing v1.1.0 (pl_rect_pack_ext.h)
72-
* Screen Log v2.2.0 (pl_screen_log_ext.h)
73-
* Shader v1.4.0 (pl_shader_ext.h)
74-
* Starter v1.4.1 (pl_starter_ext.h)
75-
* Stats v1.1.0 (pl_stats_ext.h)
76-
* String Interning v2.0.0 (pl_string_intern_ext.h)
77-
* UI Tools v1.1.0 (pl_tools_ext.h)
78-
* UI v1.2.0 (pl_ui_ext.h)
79-
* Pak Files v1.2.0 (pl_pak_ext.h)
80-
* Date & Time v1.1.0 (pl_datetime_ext.h)
81-
* Compression v1.1.0 (pl_compress_ext.h)
82-
* Virtual File System v2.1.0 (pl_vfs_ext.h)
83-
* ECS v1.1.0 (pl_ecs_ext.h)
84-
* DDS v1.1.0 (pl_dds_ext.h)
85-
* Resource v1.5.0 (pl_resource_ext.h)
86-
* Camera v1.0.2 (pl_camera_ext.h)
56+
* Log v2.0.0 (pl_log_ext.h)
57+
* Config v1.2.0 (pl_config_ext.h)
58+
* Console v1.1.0 (pl_console_ext.h)
59+
* Draw v2.1.1 (pl_draw_ext.h)
60+
* DXT v1.1.0 (pl_dxt_ext.h)
61+
* GPU Allocators v1.1.1 (pl_gpu_allocators_ext.h)
62+
* Graphics v1.10.0 (pl_graphics_ext.h)
63+
* Image v1.2.0 (pl_image_ext.h)
64+
* Job v2.3.0 (pl_job_ext.h)
65+
* Atomics v2.0.0 (pl_platform_ext.h)
66+
* File v1.1.0 (pl_platform_ext.h)
67+
* Network v1.0.0 (pl_platform_ext.h)
68+
* Threads v1.0.1 (pl_platform_ext.h)
69+
* Virtual Memory v1.0.0 (pl_platform_ext.h)
70+
* Profile v2.0.0 (pl_profile_ext.h)
71+
* Rectangle Packing v1.1.0 (pl_rect_pack_ext.h)
72+
* Screen Log v2.2.0 (pl_screen_log_ext.h)
73+
* Shader v1.4.0 (pl_shader_ext.h)
74+
* Starter v1.4.1 (pl_starter_ext.h)
75+
* Stats v1.1.0 (pl_stats_ext.h)
76+
* String Interning v2.0.0 (pl_string_intern_ext.h)
77+
* UI Tools v1.1.0 (pl_tools_ext.h)
78+
* UI v1.2.0 (pl_ui_ext.h)
79+
* Pak Files v1.2.0 (pl_pak_ext.h)
80+
* Date & Time v1.1.0 (pl_datetime_ext.h)
81+
* Compression v1.1.0 (pl_compress_ext.h)
82+
* Virtual File System v2.1.0 (pl_vfs_ext.h)
83+
* ECS v1.1.0 (pl_ecs_ext.h)
84+
* DDS v1.1.0 (pl_dds_ext.h)
85+
* Resource v1.5.0 (pl_resource_ext.h)
86+
* Camera v1.0.2 (pl_camera_ext.h)
8787

8888
## Nearly Stable APIs
8989

examples/example_gfx_2.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,6 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
308308
// bind memory
309309
gptGfx->bind_texture_to_memory(ptDevice, ptAppData->tTexture, &tTextureAllocation);
310310

311-
// set the initial texture usage (this is a no-op in metal but does layout transition for vulkan)
312-
gptGfx->set_texture_usage(ptEncoder, ptAppData->tTexture, PL_TEXTURE_USAGE_SAMPLED, 0);
313-
314311
// copy memory to mapped staging buffer
315312
memcpy(&ptStagingBuffer->tMemoryAllocation.pHostMapped[2048], pucImageData, iImageWidth * iImageHeight * 4);
316313

examples/example_gfx_4.c

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,6 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
257257
// a bind group for use to use for drawing
258258
ptAppData->tColorTextureBg = gptDraw->create_bind_group_for_texture(ptAppData->tColorTexture);
259259

260-
// begin blit pass, copy buffer, end pass
261-
plBlitEncoder* ptEncoder = gptStarter->get_blit_encoder();
262-
263-
// set the initial texture usage (this is a no-op in metal but does layout transition for vulkan)
264-
gptGfx->set_texture_usage(ptEncoder, ptAppData->tColorTexture, PL_TEXTURE_USAGE_SAMPLED, 0);
265-
gptGfx->set_texture_usage(ptEncoder, ptAppData->tDepthTexture, PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT, 0);
266-
267-
gptStarter->return_blit_encoder(ptEncoder);
268-
269260
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~render pass stuff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270261

271262
// NOTE: even if you don't need to double buffer a texture, the number of
@@ -295,24 +286,6 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
295286
.uRenderTargetCount = 2,
296287
.auRenderTargets = {0, 1}, // these are indices into the render targets above (depth/resolve must be before colors)
297288
},
298-
},
299-
.atSubpassDependencies = { // this map directly in Vulkan
300-
{
301-
.uSourceSubpass = UINT32_MAX,
302-
.uDestinationSubpass = 0,
303-
.tSourceStageMask = PL_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT | PL_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS | PL_PIPELINE_STAGE_LATE_FRAGMENT_TESTS | PL_PIPELINE_STAGE_COMPUTE_SHADER,
304-
.tDestinationStageMask = PL_PIPELINE_STAGE_FRAGMENT_SHADER | PL_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT | PL_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS | PL_PIPELINE_STAGE_LATE_FRAGMENT_TESTS,
305-
.tSourceAccessMask = PL_ACCESS_COLOR_ATTACHMENT_WRITE | PL_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE | PL_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ,
306-
.tDestinationAccessMask = PL_ACCESS_SHADER_READ | PL_ACCESS_COLOR_ATTACHMENT_WRITE | PL_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE | PL_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ,
307-
},
308-
{
309-
.uSourceSubpass = 0,
310-
.uDestinationSubpass = UINT32_MAX,
311-
.tSourceStageMask = PL_PIPELINE_STAGE_FRAGMENT_SHADER | PL_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT | PL_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS | PL_PIPELINE_STAGE_LATE_FRAGMENT_TESTS,
312-
.tDestinationStageMask = PL_PIPELINE_STAGE_FRAGMENT_SHADER | PL_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT | PL_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS | PL_PIPELINE_STAGE_LATE_FRAGMENT_TESTS | PL_PIPELINE_STAGE_COMPUTE_SHADER,
313-
.tSourceAccessMask = PL_ACCESS_SHADER_READ | PL_ACCESS_COLOR_ATTACHMENT_WRITE | PL_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE | PL_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ,
314-
.tDestinationAccessMask = PL_ACCESS_SHADER_READ | PL_ACCESS_COLOR_ATTACHMENT_WRITE | PL_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE | PL_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ,
315-
},
316289
}
317290
};
318291

@@ -324,17 +297,17 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
324297
.tStoreOp = PL_STORE_OP_DONT_CARE,
325298
.tStencilLoadOp = PL_LOAD_OP_CLEAR,
326299
.tStencilStoreOp = PL_STORE_OP_DONT_CARE,
327-
.tCurrentUsage = PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT,
300+
.tPreviousUsage = PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT,
328301
.tNextUsage = PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT,
329302
.fClearZ = 1.0f
330303
},
331304
.atColorTargets = {
332305
{
333-
.tLoadOp = PL_LOAD_OP_CLEAR,
334-
.tStoreOp = PL_STORE_OP_STORE,
335-
.tCurrentUsage = PL_TEXTURE_USAGE_SAMPLED,
336-
.tNextUsage = PL_TEXTURE_USAGE_SAMPLED,
337-
.tClearColor = {0.0f, 0.0f, 0.0f, 1.0f}
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}
338311
}
339312
},
340313
.tDimensions = {.x = ptAppData->tOffscreenSize.x, .y = ptAppData->tOffscreenSize.y}
@@ -515,8 +488,6 @@ resize_offscreen_resources(plAppData* ptAppData)
515488
{
516489
plDevice* ptDevice = gptStarter->get_device();
517490

518-
plBlitEncoder* ptEncoder = gptStarter->get_blit_encoder();
519-
520491
const plTextureDesc tColorTextureDesc = {
521492
.tDimensions = {ptAppData->tOffscreenSize.x, ptAppData->tOffscreenSize.y, 1},
522493
.tFormat = PL_FORMAT_R32G32B32A32_FLOAT,
@@ -565,9 +536,6 @@ resize_offscreen_resources(plAppData* ptAppData)
565536
gptGfx->bind_texture_to_memory(ptDevice, ptAppData->tColorTexture, &tColorAllocation);
566537
gptGfx->bind_texture_to_memory(ptDevice, ptAppData->tDepthTexture, &tDepthAllocation);
567538

568-
// set initialial usage
569-
gptGfx->set_texture_usage(ptEncoder, ptAppData->tColorTexture, PL_TEXTURE_USAGE_SAMPLED, 0);
570-
gptGfx->set_texture_usage(ptEncoder, ptAppData->tDepthTexture, PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT, 0);
571539

572540
// update our previous allocated bind group
573541
const plBindGroupUpdateTextureData atBGTextureData[] = {
@@ -592,8 +560,6 @@ resize_offscreen_resources(plAppData* ptAppData)
592560
atAttachmentSets[i].atViewAttachments[1] = ptAppData->tColorTexture;
593561
}
594562

595-
gptStarter->return_blit_encoder(ptEncoder);
596-
597563
// don't create new render pass, just update the attachments
598564
gptGfx->update_render_pass_attachments(ptDevice, ptAppData->tOffscreenRenderPass, ptAppData->tOffscreenSize, atAttachmentSets);
599565
}

extensions/pl_draw_ext.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,22 +2557,16 @@ pl_draw_build_font_atlas(plCommandBuffer* ptCommandBuffer, plFontAtlas* ptAtlas)
25572557
// begin recording
25582558
gptGfx->begin_command_recording(ptCommandBuffer, NULL);
25592559

2560-
// begin blit pass, copy texture, end pass
2561-
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
2562-
2563-
gptGfx->pipeline_barrier_blit(ptEncoder, PL_PIPELINE_STAGE_VERTEX_SHADER | PL_PIPELINE_STAGE_COMPUTE_SHADER | PL_PIPELINE_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_PIPELINE_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);
2564-
2565-
gptGfx->set_texture_usage(ptEncoder, tTexture, PL_TEXTURE_USAGE_SAMPLED, 0);
2566-
25672560
const plBufferImageCopy tBufferImageCopy = {
25682561
.uImageWidth = (uint32_t)ptAtlas->tAtlasSize.x,
25692562
.uImageHeight = (uint32_t)ptAtlas->tAtlasSize.y,
25702563
.uImageDepth = 1,
25712564
.uLayerCount = 1
25722565
};
25732566

2567+
// begin blit pass, copy texture, end pass
2568+
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
25742569
gptGfx->copy_buffer_to_texture(ptEncoder, tStagingBuffer, tTexture, 1, &tBufferImageCopy);
2575-
gptGfx->pipeline_barrier_blit(ptEncoder, PL_PIPELINE_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_PIPELINE_STAGE_VERTEX_SHADER | PL_PIPELINE_STAGE_COMPUTE_SHADER | PL_PIPELINE_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
25762570
gptGfx->end_blit_pass(ptEncoder);
25772571

25782572
// finish recording

extensions/pl_graphics_cpu.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,8 @@ typedef struct _plInternalDeviceAllocatorData
3535

3636
typedef struct _plRenderPassCommonData
3737
{
38-
uint32_t uDependencyCount;
39-
uint32_t uColorAttachmentCount;
40-
// VkAttachmentDescription atAttachments[PL_MAX_RENDER_TARGETS];
41-
// VkSubpassDependency atSubpassDependencies[PL_MAX_SUBPASSES];
42-
// VkSubpassDescription atSubpasses[PL_MAX_SUBPASSES];
43-
// VkAttachmentReference atSubpassColorAttachmentReferences[PL_MAX_RENDER_TARGETS][PL_MAX_SUBPASSES];
44-
// VkAttachmentReference atSubpassInputAttachmentReferences[PL_MAX_RENDER_TARGETS][PL_MAX_SUBPASSES];
45-
// VkAttachmentReference tDepthAttachmentReference;
46-
// VkAttachmentReference tResolveAttachmentReference;
38+
uint32_t uDependencyCount;
39+
uint32_t uColorAttachmentCount;
4740
} plRenderPassCommonData;
4841

4942
typedef struct _plCpuDynamicBuffer

extensions/pl_graphics_ext.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ pl__cleanup_common_graphics(void)
584584
while(ptCurrentComputeEncoder)
585585
{
586586
plComputeEncoder* ptNextEncoder = ptCurrentComputeEncoder->ptNext;
587+
pl_sb_free(ptCurrentComputeEncoder->sbtTextures);
587588
PL_FREE(ptCurrentComputeEncoder);
588589
ptCurrentComputeEncoder = ptNextEncoder;
589590
}
@@ -996,6 +997,7 @@ pl__return_render_encoder(plRenderEncoder* ptEncoder)
996997
static void
997998
pl__return_compute_encoder(plComputeEncoder* ptEncoder)
998999
{
1000+
pl_sb_reset(ptEncoder->sbtTextures);
9991001
ptEncoder->ptNext = gptGraphics->ptComputeEncoderFreeList;
10001002
gptGraphics->ptComputeEncoderFreeList = ptEncoder;
10011003
}
@@ -1220,8 +1222,6 @@ pl_load_graphics_ext(plApiRegistryI* ptApiRegistry, bool bReload)
12201222
.end_compute_pass = pl_graphics_end_compute_pass,
12211223
.begin_blit_pass = pl_graphics_begin_blit_pass,
12221224
.end_blit_pass = pl_graphics_end_blit_pass,
1223-
.set_texture_usage = pl_graphics_set_texture_usage,
1224-
.set_texture_usage_ex = pl_graphics_set_texture_usage_ex,
12251225
.draw_stream = pl_graphics_draw_stream,
12261226
.draw = pl_graphics_draw,
12271227
.draw_indexed = pl_graphics_draw_indexed,
@@ -1355,6 +1355,11 @@ pl_load_graphics_ext(plApiRegistryI* ptApiRegistry, bool bReload)
13551355
.get_metal_texture = pl_graphics_get_metal_texture,
13561356
.get_metal_bind_group_texture = pl_graphics_get_metal_bind_group_texture,
13571357
#endif
1358+
1359+
#ifndef PL_DISABLE_OBSOLETE
1360+
.set_texture_usage = pl_graphics_set_texture_usage,
1361+
.set_texture_usage_ex = pl_graphics_set_texture_usage_ex,
1362+
#endif
13581363
};
13591364
pl_set_api(ptApiRegistry, plGraphicsI, &tApi);
13601365

0 commit comments

Comments
 (0)