Skip to content

Commit 4ff9957

Browse files
committed
feat: command pool/buffer api work
1 parent b3f8042 commit 4ff9957

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

extensions/pl_graphics_cpu.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ typedef struct _plCommandPool
150150
// VkCommandBuffer* sbtReadyCommandBuffers; // completed command buffers
151151
// VkCommandBuffer* sbtPendingCommandBuffers; // recently submitted command buffers
152152
plCommandBuffer* ptCommandBufferFreeList; // free list of command buffers
153-
plPoolAllocator* tAllocator;
153+
plPoolAllocator* ptCommandPoolList;
154154

155155
size_t szBufferSize;
156-
void* ptCommandPool; // TODO: does this need to be a void pointer?
156+
void* ptCommandPoolBuffer; // TODO: does this need to be a void pointer?
157157
} plCommandPool;
158158

159159
typedef struct _plBindGroupPool
@@ -894,7 +894,7 @@ pl_return_command_buffer(plCommandBuffer* ptCmdBuffer)
894894
}
895895

896896
memset(ptCmdBuffer, 0, sizeof(plCommandBuffer));
897-
pl_pool_allocator_free(ptCmdBuffer->ptPool->tAllocator, ptCmdBuffer);
897+
pl_pool_allocator_free(ptCmdBuffer->ptPool->ptCommandPoolList, ptCmdBuffer);
898898
}
899899

900900
plBindGroupPool*
@@ -922,17 +922,21 @@ pl_create_command_pool(plDevice* ptDevice, const plCommandPoolDesc* ptDesc)
922922
plCommandPool* ptPool = PL_ALLOC(sizeof(plCommandPool));
923923
memset(ptPool, 0, sizeof(plCommandPool));
924924

925+
plPoolAllocator* tAllocator = PL_ALLOC(sizeof(plPoolAllocator));
926+
memset(tAllocator, 0, sizeof(plPoolAllocator));
927+
925928
ptPool->ptDevice = ptDevice;
929+
ptPool->ptCommandPoolList = tAllocator;
926930

927931
// TODO: sort out max command pool stuff once virtual memory limits exist (virtual GPU)
928932
// hard coding 100 buffers for now
929933
size_t szBufferSize = 0;
930-
pl_pool_allocator_init(ptPool->tAllocator, 100, sizeof(plCommandBuffer), 0, &szBufferSize, NULL);
934+
pl_pool_allocator_init(ptPool->ptCommandPoolList, 100, sizeof(plCommandBuffer), 0, &szBufferSize, NULL);
931935

932-
ptPool->ptCommandPool = PL_ALLOC(sizeof(szBufferSize));
933-
memset(ptPool->ptCommandPool, 0, sizeof(szBufferSize));
936+
ptPool->ptCommandPoolBuffer = PL_ALLOC(sizeof(szBufferSize));
937+
memset(ptPool->ptCommandPoolBuffer, 0, sizeof(szBufferSize));
934938

935-
pl_pool_allocator_init(ptPool->tAllocator, 100, sizeof(plCommandBuffer), 0, &szBufferSize, ptPool->ptCommandPool);
939+
pl_pool_allocator_init(ptPool->ptCommandPoolList, 100, sizeof(plCommandBuffer), 0, &szBufferSize, ptPool->ptCommandPoolBuffer);
936940
ptPool->szBufferSize = szBufferSize;
937941

938942
return ptPool;
@@ -941,7 +945,8 @@ pl_create_command_pool(plDevice* ptDevice, const plCommandPoolDesc* ptDesc)
941945
void
942946
pl_cleanup_command_pool(plCommandPool* ptPool)
943947
{
944-
PL_FREE(ptPool->ptCommandPool);
948+
PL_FREE(ptPool->ptCommandPoolList);
949+
PL_FREE(ptPool->ptCommandPoolBuffer);
945950
PL_FREE(ptPool);
946951
}
947952

@@ -955,8 +960,8 @@ pl_reset_command_pool(plCommandPool* ptPool, plCommandPoolResetFlags tFlags)
955960
return;
956961
}
957962

958-
pl_pool_allocator_init(ptPool->tAllocator, 100, sizeof(plCommandBuffer), 0, &ptPool->szBufferSize, ptPool->ptCommandPool);
959-
memset(ptPool->ptCommandPool, 0, ptPool->szBufferSize);
963+
pl_pool_allocator_init(ptPool->ptCommandPoolList, 100, sizeof(plCommandBuffer), 0, &ptPool->szBufferSize, ptPool->ptCommandPoolBuffer);
964+
memset(ptPool->ptCommandPoolBuffer, 0, ptPool->szBufferSize);
960965

961966
}
962967

@@ -976,7 +981,7 @@ pl_reset_command_buffer(plCommandBuffer* ptCommandBuffer)
976981
plCommandBuffer*
977982
pl_request_command_buffer(plCommandPool* ptPool, const char* pcDebugName)
978983
{
979-
plCommandBuffer* ptCommandBuffer = pl_pool_allocator_alloc(ptPool->tAllocator);
984+
plCommandBuffer* ptCommandBuffer = pl_pool_allocator_alloc(ptPool->ptCommandPoolList);
980985

981986
if(ptCommandBuffer == NULL)
982987
{

0 commit comments

Comments
 (0)