@@ -325,7 +325,7 @@ pl__renderer_create_local_buffer(const plBufferDesc* ptDesc, const char* pcName,
325325 {
326326 const plBufferDesc tStagingBufferDesc = {
327327 .tUsage = PL_BUFFER_USAGE_STAGING ,
328- .szByteSize = 268435456 ,
328+ .szByteSize = pl_max ( 268435456 , szSize ) ,
329329 .pcDebugName = "Renderer Staging Buffer"
330330 };
331331
@@ -334,6 +334,24 @@ pl__renderer_create_local_buffer(const plBufferDesc* ptDesc, const char* pcName,
334334 gptData -> atStagingBufferHandle [gptGfx -> get_current_frame_index ()].szOffset = 0 ;
335335 gptData -> atStagingBufferHandle [gptGfx -> get_current_frame_index ()].szSize = tStagingBufferDesc .szByteSize ;
336336 }
337+ else
338+ {
339+ plBuffer * ptStagingBuffer = gptGfx -> get_buffer (ptDevice , tStagingBuffer );
340+ if (ptStagingBuffer -> tDesc .szByteSize < szSize )
341+ {
342+ gptGfx -> queue_buffer_for_deletion (ptDevice , tStagingBuffer );
343+ const plBufferDesc tStagingBufferDesc = {
344+ .tUsage = PL_BUFFER_USAGE_STAGING ,
345+ .szByteSize = szSize ,
346+ .pcDebugName = "Renderer Staging Buffer"
347+ };
348+
349+ gptData -> atStagingBufferHandle [gptGfx -> get_current_frame_index ()].tStagingBufferHandle = pl__renderer_create_staging_buffer (& tStagingBufferDesc , "staging" , gptGfx -> get_current_frame_index ());
350+ tStagingBuffer = gptData -> atStagingBufferHandle [gptGfx -> get_current_frame_index ()].tStagingBufferHandle ;
351+ gptData -> atStagingBufferHandle [gptGfx -> get_current_frame_index ()].szOffset = 0 ;
352+ gptData -> atStagingBufferHandle [gptGfx -> get_current_frame_index ()].szSize = tStagingBufferDesc .szByteSize ;
353+ }
354+ }
337355 gptData -> atStagingBufferHandle [gptGfx -> get_current_frame_index ()].dLastTimeActive = gptIO -> dTime ;
338356
339357 // copy data to staging buffer
0 commit comments