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,37 +495,28 @@ 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; assembly Assembly = State->AssemblyList[AssemblyIdx];
s32 LEDBufferLEDsAssignedToJobs = 0; s32 JobsNeeded = IntegerDivideRoundUp(Assembly.LEDCount, MaxLEDsPerJob);
for (s32 Job = 0; Job < JobsNeeded; Job++) for (s32 Job = 0; Job < JobsNeeded; Job++)
{ {
assembly CurrentAssembly = State->AssemblyList[CurrentAssemblyIndex]; draw_leds_job_data* JobData = PushStruct(State->Transient, draw_leds_job_data);
JobData->LEDs = Assembly.LEDs;
draw_leds_job_data* JobData = JobDataBank + JobDataBankUsed++; JobData->Colors = Assembly.Colors;
JobData->LEDs = CurrentAssembly.LEDs; JobData->StartIndex = Job * MaxLEDsPerJob;
JobData->Colors = CurrentAssembly.Colors; JobData->OnePastLastIndex = GSMin(JobData->StartIndex + MaxLEDsPerJob, Assembly.LEDCount);
JobData->StartIndex = LEDBufferLEDsAssignedToJobs; JobData->Batch = &RenderLEDsBatch;
JobData->OnePastLastIndex = GSMin(JobData->StartIndex + LEDBufferSize, CurrentAssembly.LEDCount); JobData->FaceCameraMatrix;
LEDBufferLEDsAssignedToJobs += JobData->OnePastLastIndex - JobData->StartIndex;
// New
JobData->Batch = &BatchConstructor;
JobData->FaceCameraMatrix = FaceCameraMatrix;
JobData->ModelViewMatrix = ModelViewMatrix; JobData->ModelViewMatrix = ModelViewMatrix;
JobData->LEDHalfWidth = LEDHalfWidth; JobData->LEDHalfWidth = LEDHalfWidth;
@ -533,19 +524,6 @@ UPDATE_AND_RENDER(UpdateAndRender)
Context.GeneralWorkQueue, Context.GeneralWorkQueue,
DrawLEDsInBufferRangeJob, DrawLEDsInBufferRangeJob,
JobData); 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)
{
break;
}
else
{
CurrentAssemblyIndex++;
}
} }
} }