From 313ca58550163380e072880b360bc6076d27c8e5 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Wed, 27 Jul 2022 15:46:42 -0400 Subject: switched threading to SDL; works on windows now --- prenderer.cpp | 56 +++++++++++--------------------------------------------- 1 file changed, 11 insertions(+), 45 deletions(-) (limited to 'prenderer.cpp') diff --git a/prenderer.cpp b/prenderer.cpp index 356ecd7..72c2893 100644 --- a/prenderer.cpp +++ b/prenderer.cpp @@ -97,13 +97,6 @@ internal void EndRenderState(project_state *State) { IsRendering = false; - DEBUG_CycleCountEnd(3); - //TODO(fox): proper pixel accounting - // Debug.ExecutionAmount[4] += 1280*720; - - // printf("%lu %lu, avg %lu\n", Debug.EndCycleCount[3], Debug.ExecutionAmount[4], - // Debug.EndCycleCount[3] / Debug.ExecutionAmount[4]); - // Debug = {}; for (int16 i = 0; i < State->NumberOfLayersToRender; i++) { @@ -112,9 +105,9 @@ EndRenderState(project_state *State) State->NumberOfLayersToRender = 0; #if THREADED - __atomic_store_n(&EntryCount, 0, __ATOMIC_SEQ_CST); - __atomic_store_n(&NextEntryToDo, 0, __ATOMIC_SEQ_CST); - __atomic_store_n(&CompletedJobs, 0, __ATOMIC_SEQ_CST); + SDL_AtomicSet(&CurrentEntry, 0); + SDL_AtomicSet(&QueuedEntries, 0); + SDL_AtomicSet(&CompletedEntries, 0); #endif } @@ -138,9 +131,6 @@ QueueCurrentFrame(project_data *File, pixel_buffer *CompBuffer, project_state *S IsRendering = true; render_queue RenderInfo = {File, State, CompBuffer}; - uint16 TileWidth = (CompBuffer->Width - (CompBuffer->Width & 3)) / 4; - uint16 TileHeight = (CompBuffer->Height - (CompBuffer->Height & 3)) / 4; - for (int16 i = 0; i < File->NumberOfLayers; i++) { if (File->Layer[i]->StartFrame <= File->CurrentFrame && @@ -153,54 +143,30 @@ QueueCurrentFrame(project_data *File, pixel_buffer *CompBuffer, project_state *S } #if THREADED + + uint16 TileWidth = CompBuffer->Width / 4; + uint16 TileHeight = CompBuffer->Height / 4; + DEBUG_CycleCountStart(3); for (int y = 0; y < 4; y++) { for (int x = 0; x < 4; x++) { // if (x == y) { rectangle RenderRegion = {TileWidth*x, TileHeight*y, TileWidth + TileWidth*x, TileHeight + TileHeight*y}; + if (RenderRegion.Max.x > CompBuffer->Width) + RenderRegion.Max.x = CompBuffer->Width; + if (RenderRegion.Max.y > CompBuffer->Height) + RenderRegion.Max.y = CompBuffer->Height; PushRect(RenderRegion); // } } } - // while (CompletedJobs != 16) { - // // CheckQueue(RenderInfo, 8); - // } - // DEBUG_CycleCountEnd(3); - // // //TODO(fox): proper pixel accounting - // Debug.ExecutionAmount[4] += 1280*720; - - // for (int16 i = 0; i < State->NumberOfLayersToRender; i++) - // { - // State->LayersToRender[i] = 0; - // } - - // State->NumberOfLayersToRender = 0; - #else - // DEBUG_CycleCountStart(3); rectangle RenderRegion = {0, 0, (int32)CompBuffer->Width, (int32)CompBuffer->Height}; RenderLayers(&RenderInfo, RenderRegion); - // DEBUG_CycleCountEnd(3); - // Debug.ExecutionAmount[4] += 1280*720; - - for (int16 i = 0; i < State->NumberOfLayersToRender; i++) - { - State->LayersToRender[i] = 0; - } - - State->NumberOfLayersToRender = 0; - #endif - - // printf("Completed jobs: %i\n", CompletedJobs); - // printf("Next: %i\n", NextEntryToDo); - // Assert(CompletedJobs == 4*4); - // __atomic_store_n(&EntryCount, 0, __ATOMIC_SEQ_CST); - // __atomic_store_n(&NextEntryToDo, 0, __ATOMIC_SEQ_CST); - // __atomic_store_n(&CompletedJobs, 0, __ATOMIC_SEQ_CST); } -- cgit v1.2.3