Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffstadt committed Dec 13, 2024
1 parent e4e3cbf commit e65ada9
Show file tree
Hide file tree
Showing 13 changed files with 182 additions and 105 deletions.
6 changes: 6 additions & 0 deletions examples/example_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)

// begin blit pass, copy buffer, end pass
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);

plSwapchainInfo tInfo = gptGfx->get_swapchain_info(ptAppData->ptSwapchain);
const plTextureDesc tColorTextureDesc = {
.tDimensions = {(float)tInfo.uWidth, (float)tInfo.uHeight, 1},
Expand Down Expand Up @@ -249,6 +251,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
// set initial usage
gptGfx->set_texture_usage(ptEncoder, ptAppData->tMSAATexture, PL_TEXTURE_USAGE_COLOR_ATTACHMENT, 0);

gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
gptGfx->end_blit_pass(ptEncoder);

// finish recording
Expand Down Expand Up @@ -379,6 +382,8 @@ pl_app_resize(plAppData* ptAppData)

// begin blit pass, copy buffer, end pass
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);

plSwapchainInfo tInfo = gptGfx->get_swapchain_info(ptAppData->ptSwapchain);
const plTextureDesc tColorTextureDesc = {
.tDimensions = {(float)tInfo.uWidth, (float)tInfo.uHeight, 1},
Expand Down Expand Up @@ -413,6 +418,7 @@ pl_app_resize(plAppData* ptAppData)
// set initial usage
gptGfx->set_texture_usage(ptEncoder, ptAppData->tMSAATexture, PL_TEXTURE_USAGE_COLOR_ATTACHMENT, 0);

gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
gptGfx->end_blit_pass(ptEncoder);

// finish recording
Expand Down
2 changes: 2 additions & 0 deletions examples/example_5.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,10 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)

// begin blit pass, copy buffer, end pass
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);
gptGfx->copy_buffer(ptEncoder, ptAppData->tStagingBuffer, ptAppData->tVertexBuffer, 0, 0, sizeof(float) * 24);
gptGfx->copy_buffer(ptEncoder, ptAppData->tStagingBuffer, ptAppData->tIndexBuffer, 1024, 0, sizeof(uint32_t) * 6);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
gptGfx->end_blit_pass(ptEncoder);

// finish recording
Expand Down
2 changes: 2 additions & 0 deletions examples/example_6.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)

// begin blit pass, copy buffer, end pass
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);
gptGfx->copy_buffer(ptEncoder, ptAppData->tStagingBuffer, ptAppData->tVertexBuffer, 0, 0, sizeof(float) * 16);
gptGfx->copy_buffer(ptEncoder, ptAppData->tStagingBuffer, ptAppData->tIndexBuffer, 1024, 0, sizeof(uint32_t) * 6);

Expand Down Expand Up @@ -417,6 +418,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
gptGfx->copy_buffer_to_texture(ptEncoder, ptAppData->tStagingBuffer, ptAppData->tTexture, 1, &tBufferImageCopy);

// end blit pass
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
gptGfx->end_blit_pass(ptEncoder);

// finish recording
Expand Down
5 changes: 4 additions & 1 deletion examples/example_8.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)

// begin blit pass, copy buffer, end pass
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);

// create main render pass
const plRenderPassDesc tMainRenderPassDesc = {
Expand Down Expand Up @@ -335,7 +336,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
atMainAttachmentSets[i].atViewAttachments[1] = atSwapchainImages[i];
}
ptAppData->tMainRenderPass = gptGfx->create_render_pass(ptAppData->ptDevice, &tMainRenderPassDesc, atMainAttachmentSets);

gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
gptGfx->end_blit_pass(ptEncoder);

// finish recording
Expand Down Expand Up @@ -405,6 +406,7 @@ pl_app_resize(plAppData* ptAppData)

// begin blit pass, copy buffer, end pass
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);
const plTextureDesc tDepthTextureDesc = {
.tDimensions = {gptIO->get_io()->tMainViewportSize.x, gptIO->get_io()->tMainViewportSize.y, 1},
.tFormat = PL_FORMAT_D32_FLOAT_S8_UINT,
Expand Down Expand Up @@ -441,6 +443,7 @@ pl_app_resize(plAppData* ptAppData)
atMainAttachmentSets[i].atViewAttachments[1] = atSwapchainImages[i];
}

gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
gptGfx->end_blit_pass(ptEncoder);

// finish recording
Expand Down
4 changes: 4 additions & 0 deletions examples/example_9.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)

// begin blit pass, copy buffer, end pass
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);

const plTextureDesc tColorTextureDesc = {
.tDimensions = {ptAppData->tOffscreenSize.x, ptAppData->tOffscreenSize.y, 1},
Expand Down Expand Up @@ -392,6 +393,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
atAttachmentSets[i].atViewAttachments[1] = ptAppData->atColorTexture[i];
}

gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
gptGfx->end_blit_pass(ptEncoder);

// finish recording
Expand Down Expand Up @@ -769,6 +771,7 @@ resize_offscreen_resources(plAppData* ptAppData)

// begin blit pass, copy buffer, end pass
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);

plIO* ptIO = gptIO->get_io();
ptAppData->tCamera.fAspectRatio = ptIO->tMainViewportSize.x / ptIO->tMainViewportSize.y;
Expand Down Expand Up @@ -835,6 +838,7 @@ resize_offscreen_resources(plAppData* ptAppData)
atAttachmentSets[i].atViewAttachments[1] = ptAppData->atColorTexture[i];
}

gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
gptGfx->end_blit_pass(ptEncoder);

// finish recording
Expand Down
3 changes: 3 additions & 0 deletions extensions/pl_draw_backend_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ pl_build_font_atlas_backend(plCommandBuffer* ptCommandBuffer, plFontAtlas* ptAtl
// begin blit pass, copy texture, end pass
plBlitEncoder* ptEncoder = gptGfx->begin_blit_pass(ptCommandBuffer);

gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE);

gptGfx->set_texture_usage(ptEncoder, tTexture, PL_TEXTURE_USAGE_SAMPLED, 0);

const plBufferImageCopy tBufferImageCopy = {
Expand All @@ -293,6 +295,7 @@ pl_build_font_atlas_backend(plCommandBuffer* ptCommandBuffer, plFontAtlas* ptAtl
};

gptGfx->copy_buffer_to_texture(ptEncoder, tStagingBuffer, tTexture, 1, &tBufferImageCopy);
gptGfx->pipeline_barrier_blit(ptEncoder, PL_STAGE_TRANSFER, PL_ACCESS_TRANSFER_WRITE, PL_STAGE_VERTEX | PL_STAGE_COMPUTE | PL_STAGE_TRANSFER, PL_ACCESS_SHADER_READ | PL_ACCESS_TRANSFER_READ);
gptGfx->end_blit_pass(ptEncoder);

// finish recording
Expand Down
2 changes: 1 addition & 1 deletion extensions/pl_ecs_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ pl_ecs_remove_entity(plComponentLibrary* ptLibrary, plEntity tEntity)
{
plEntity tLastEntity = pl_sb_back(ptLibrary->_ptManagers[i]->sbtEntities);
pl_hm_remove(ptLibrary->_ptManagers[i]->ptHashmap, tLastEntity.uIndex);
uint32_t _unUsed = pl_hm_get_free_index(ptLibrary->_ptManagers[i]->ptHashmap); // burn slot
uint64_t _unUsed = pl_hm_get_free_index(ptLibrary->_ptManagers[i]->ptHashmap); // burn slot
pl_hm_insert(ptLibrary->_ptManagers[i]->ptHashmap, tLastEntity.uIndex, uEntityValue);
}

Expand Down
2 changes: 2 additions & 0 deletions extensions/pl_graphics_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,8 @@ pl_load_graphics_ext(plApiRegistryI* ptApiRegistry, bool bReload)
.create_bind_group_pool = pl_create_bind_group_pool,
.cleanup_bind_group_pool = pl_cleanup_bind_group_pool,
.reset_bind_group_pool = pl_reset_bind_group_pool,
.pipeline_barrier_blit = pl_pipeline_barrier_blit,
.pipeline_barrier_compute = pl_pipeline_barrier_compute
};
pl_set_api(ptApiRegistry, plGraphicsI, &tApi);

Expand Down
Loading

0 comments on commit e65ada9

Please sign in to comment.