Jobs are now set by assembly rather than in total. This ensures that no matter what, all leds will be drawn.

This commit is contained in:
Peter Slattery 2019-11-23 00:15:40 -08:00
parent 67b402b74f
commit 4c78d8b594
1 changed files with 20 additions and 42 deletions

View File

@ -495,57 +495,35 @@ UPDATE_AND_RENDER(UpdateAndRender)
DEBUG_IF(GlobalDebugServices->Interface.RenderSculpture) // DebugServices RenderSculpture Toggle DEBUG_IF(GlobalDebugServices->Interface.RenderSculpture) // DebugServices RenderSculpture Toggle
{ {
DEBUG_TRACK_SCOPE(RenderSculpture); DEBUG_TRACK_SCOPE(RenderSculpture);
s32 JobsNeeded = PLATFORM_THREAD_COUNT;
s32 LEDBufferSize = IntegerDivideRoundUp(State->TotalLEDsCount, JobsNeeded);
draw_leds_job_data* JobDataBank = PushArray(State->Transient, draw_leds_job_data, JobsNeeded); s32 MaxLEDsPerJob = 2048;
s32 JobDataBankUsed = 0; render_quad_batch_constructor RenderLEDsBatch = PushRenderQuad3DBatch(RenderBuffer, State->TotalLEDsCount);
// TODO(Peter): Pretty sure this isn't working right now // TODO(Peter): Pretty sure this isn't working right now
m44 FaceCameraMatrix = GetLookAtMatrix(v4{0, 0, 0, 1}, V4(State->Camera.Position, 1)); m44 FaceCameraMatrix = GetLookAtMatrix(v4{0, 0, 0, 1}, V4(State->Camera.Position, 1));
FaceCameraMatrix = FaceCameraMatrix; FaceCameraMatrix = FaceCameraMatrix;
render_quad_batch_constructor BatchConstructor = PushRenderQuad3DBatch(RenderBuffer, State->TotalLEDsCount); for (s32 AssemblyIdx = 0; AssemblyIdx < State->AssembliesCount; AssemblyIdx++)
s32 CurrentAssemblyIndex = 0;
s32 LEDBufferLEDsAssignedToJobs = 0;
for (s32 Job = 0; Job < JobsNeeded; Job++)
{ {
assembly CurrentAssembly = State->AssemblyList[CurrentAssemblyIndex]; assembly Assembly = State->AssemblyList[AssemblyIdx];
s32 JobsNeeded = IntegerDivideRoundUp(Assembly.LEDCount, MaxLEDsPerJob);
draw_leds_job_data* JobData = JobDataBank + JobDataBankUsed++; for (s32 Job = 0; Job < JobsNeeded; Job++)
JobData->LEDs = CurrentAssembly.LEDs;
JobData->Colors = CurrentAssembly.Colors;
JobData->StartIndex = LEDBufferLEDsAssignedToJobs;
JobData->OnePastLastIndex = GSMin(JobData->StartIndex + LEDBufferSize, CurrentAssembly.LEDCount);
LEDBufferLEDsAssignedToJobs += JobData->OnePastLastIndex - JobData->StartIndex;
// New
JobData->Batch = &BatchConstructor;
JobData->FaceCameraMatrix = FaceCameraMatrix;
JobData->ModelViewMatrix = ModelViewMatrix;
JobData->LEDHalfWidth = LEDHalfWidth;
Context.GeneralWorkQueue->PushWorkOnQueue(
Context.GeneralWorkQueue,
DrawLEDsInBufferRangeJob,
JobData);
// NOTE: We should never go OVER the number of leds in the buffer
Assert(LEDBufferLEDsAssignedToJobs <= CurrentAssembly.LEDCount);
if (LEDBufferLEDsAssignedToJobs == CurrentAssembly.LEDCount)
{ {
if (CurrentAssemblyIndex >= State->AssembliesCount) draw_leds_job_data* JobData = PushStruct(State->Transient, draw_leds_job_data);
{ JobData->LEDs = Assembly.LEDs;
break; JobData->Colors = Assembly.Colors;
} JobData->StartIndex = Job * MaxLEDsPerJob;
else JobData->OnePastLastIndex = GSMin(JobData->StartIndex + MaxLEDsPerJob, Assembly.LEDCount);
{ JobData->Batch = &RenderLEDsBatch;
CurrentAssemblyIndex++; JobData->FaceCameraMatrix;
} JobData->ModelViewMatrix = ModelViewMatrix;
JobData->LEDHalfWidth = LEDHalfWidth;
Context.GeneralWorkQueue->PushWorkOnQueue(
Context.GeneralWorkQueue,
DrawLEDsInBufferRangeJob,
JobData);
} }
} }