diff --git a/src/app/foldhaus_app.cpp b/src/app/foldhaus_app.cpp index afb801e..a202b38 100644 --- a/src/app/foldhaus_app.cpp +++ b/src/app/foldhaus_app.cpp @@ -314,8 +314,7 @@ CreateDMXBuffers(assembly Assembly, led_system* LedSystem, s32 BufferHeaderSize, for (u32 i = 0; i < Strip.LedCount; i++) { u32 LedIndex = Strip.LedLUT[i]; - led LED = LedBuffer->Leds[LedIndex]; - pixel Color = LedBuffer->Colors[LED.Index]; + pixel Color = LedBuffer->Colors[LedIndex]; DestChannel[0] = Color.R; DestChannel[1] = Color.G; @@ -529,6 +528,7 @@ UPDATE_AND_RENDER(UpdateAndRender) Context->GeneralWorkQueue->ResetWorkQueue(Context->GeneralWorkQueue); // Checking for overflows +#if 0 { DEBUG_TRACK_SCOPE(OverflowChecks); AssertAllocationsNoOverflow(State->Permanent); @@ -538,6 +538,7 @@ UPDATE_AND_RENDER(UpdateAndRender) AssertAllocationsNoOverflow(Assembly->Arena); } } +#endif } CLEANUP_APPLICATION(CleanupApplication) diff --git a/src/app/foldhaus_app.h b/src/app/foldhaus_app.h index 0e08eb1..6fe067c 100644 --- a/src/app/foldhaus_app.h +++ b/src/app/foldhaus_app.h @@ -94,18 +94,18 @@ TestPatternOne(led_buffer* Assembly, r32 Time) { for (u32 LedIndex = 0; LedIndex < Assembly->LedCount; LedIndex++) { - led Led = Assembly->Leds[LedIndex]; - if (Led.Position.x < 0) + v4 LedPosition = Assembly->Positions[LedIndex]; + if (LedPosition.x < 0) { - Assembly->Colors[Led.Index].R = 255; - Assembly->Colors[Led.Index].B = 255; - Assembly->Colors[Led.Index].G = 255; + Assembly->Colors[LedIndex].R = 255; + Assembly->Colors[LedIndex].B = 255; + Assembly->Colors[LedIndex].G = 255; } else { - Assembly->Colors[Led.Index].R = 0; - Assembly->Colors[Led.Index].B = 0; - Assembly->Colors[Led.Index].G = 0; + Assembly->Colors[LedIndex].R = 0; + Assembly->Colors[LedIndex].B = 0; + Assembly->Colors[LedIndex].G = 0; } } } @@ -132,9 +132,7 @@ TestPatternTwo(led_buffer* Assembly, r32 Time) for (u32 LedIndex = 0; LedIndex < Assembly->LedCount; LedIndex++) { - led Led = Assembly->Leds[LedIndex]; - - v4 Position = Led.Position; + v4 Position = Assembly->Positions[LedIndex]; v4 ToFront = Position + FrontCenter; v4 ToBack = Position + BackCenter; @@ -150,16 +148,16 @@ TestPatternTwo(led_buffer* Assembly, r32 Time) { if (XOR(ToFrontDotNormal > 0, ToBackDotNormal > 0)) { - Assembly->Colors[Led.Index] = Color; + Assembly->Colors[LedIndex] = Color; } else { - //Assembly->Colors[Led.Index] = {}; + //Assembly->Colors[LedIndex] = {}; } } else { - //Assembly->Colors[Led.Index] = {}; + //Assembly->Colors[LedIndex] = {}; } } } @@ -178,23 +176,23 @@ TestPatternThree(led_buffer* Assembly, r32 Time) for (u32 LedIndex = 0; LedIndex < Assembly->LedCount; LedIndex++) { - led Led = Assembly->Leds[LedIndex]; + v4 LedPosition = Assembly->Positions[LedIndex]; u8 Red = 0; u8 Green = 0; u8 Blue = 0; - r32 GreenDist = GSAbs(Mag(Led.Position - GreenCenter) - GreenRadius); + r32 GreenDist = GSAbs(Mag(LedPosition - GreenCenter) - GreenRadius); r32 GreenBrightness = GSClamp(0.f, FadeDist - GSAbs(GreenDist), FadeDist); Green = (u8)(GreenBrightness * 255); - r32 TealDist = GSAbs(Mag(Led.Position - TealCenter) - TealRadius); + r32 TealDist = GSAbs(Mag(LedPosition - TealCenter) - TealRadius); r32 TealBrightness = GSClamp(0.f, FadeDist - GSAbs(TealDist), FadeDist); Red = (u8)(TealBrightness * 255); Blue = (u8)(TealBrightness * 255); - Assembly->Colors[Led.Index].R = Red; - Assembly->Colors[Led.Index].B = Green; - Assembly->Colors[Led.Index].G = Green; + Assembly->Colors[LedIndex].R = Red; + Assembly->Colors[LedIndex].B = Green; + Assembly->Colors[LedIndex].G = Green; } } diff --git a/src/app/foldhaus_assembly.cpp b/src/app/foldhaus_assembly.cpp index da5841e..97cdbf2 100644 --- a/src/app/foldhaus_assembly.cpp +++ b/src/app/foldhaus_assembly.cpp @@ -34,7 +34,7 @@ LedSystemTakeFreeBuffer(led_system* System, u32 LedCount) { if (System->Buffers[i].LedCount == 0 && System->Buffers[i].Colors == 0 - && System->Buffers[i].Leds == 0) + && System->Buffers[i].Positions == 0) { Result = i; break; @@ -46,7 +46,7 @@ LedSystemTakeFreeBuffer(led_system* System, u32 LedCount) led_buffer* Buffer = &System->Buffers[Result]; Buffer->LedCount = LedCount; Buffer->Colors = PlatformAllocArray(System->PlatformMemory, pixel, Buffer->LedCount); - Buffer->Leds = PlatformAllocArray(System->PlatformMemory, led, Buffer->LedCount); + Buffer->Positions = PlatformAllocArray(System->PlatformMemory, v4, Buffer->LedCount); System->LedsCountTotal += LedCount; @@ -59,7 +59,7 @@ LedSystemFreeBuffer(led_system* System, u32 BufferIndex) Assert(BufferIndex < System->BuffersCountMax); led_buffer* Buffer = &System->Buffers[BufferIndex]; PlatformFreeArray(System->PlatformMemory, Buffer->Colors, pixel, Buffer->LedCount); - PlatformFreeArray(System->PlatformMemory, Buffer->Leds, led, Buffer->LedCount); + PlatformFreeArray(System->PlatformMemory, Buffer->Positions, v4, Buffer->LedCount); System->LedsCountTotal -= Buffer->LedCount; *Buffer = {}; } @@ -75,8 +75,7 @@ internal void LedBufferSetLed(led_buffer* Buffer, u32 Led, v4 Position) { Assert(Led < Buffer->LedCount); - Buffer->Leds[Led].Position = Position; - Buffer->Leds[Led].Index = Led; + Buffer->Positions[Led] = Position; } // Assembly diff --git a/src/app/foldhaus_assembly.h b/src/app/foldhaus_assembly.h index 68c4f24..97c153a 100644 --- a/src/app/foldhaus_assembly.h +++ b/src/app/foldhaus_assembly.h @@ -5,13 +5,6 @@ // #ifndef FOLDHAUS_ASSEMBLY_H -struct led -{ - // TODO(Peter): Pretty sure we don't need this. led and pixel are always parallel arrays - s32 Index; - v4 Position; -}; - union pixel { struct @@ -27,7 +20,7 @@ struct led_buffer { u32 LedCount; pixel* Colors; - led* Leds; + v4* Positions; }; struct led_system @@ -50,6 +43,7 @@ struct v2_tag struct v2_strip { s32 ControlBoxID; // TODO(Peter): I don't think we need this anymore + // TODO(Peter): Add in info for Serial, ArtNet, etc. s32 StartUniverse; s32 StartChannel; diff --git a/src/app/foldhaus_default_nodes.h b/src/app/foldhaus_default_nodes.h index fd68674..7083ce2 100644 --- a/src/app/foldhaus_default_nodes.h +++ b/src/app/foldhaus_default_nodes.h @@ -117,7 +117,7 @@ NODE_PROC(SinWave, sin_wave_data) // ///////////////////////////////// -GSMetaTag(node_struct); +GSMetaTag(node_struct); struct multiply_patterns_data { GSMetaTag(node_input); @@ -132,28 +132,25 @@ struct multiply_patterns_data NODE_PROC(MultiplyPatterns, multiply_patterns_data) { - led* LED = Data->Result.LEDs; - for (s32 l = 0; l < Data->Result.LEDCount; l++) + for (s32 LedIndex = 0; LedIndex < Data->Result.LEDCount; LedIndex++) { - Assert(LED->Index >= 0 && LED->Index < Data->Result.LEDCount); + Assert(LedIndex >= 0 && LedIndex < Data->Result.LEDCount); - s32 AR = Data->A.Colors[LED->Index].R; - s32 AG = Data->A.Colors[LED->Index].G; - s32 AB = Data->A.Colors[LED->Index].B; + s32 AR = Data->A.Colors[LedIndex].R; + s32 AG = Data->A.Colors[LedIndex].G; + s32 AB = Data->A.Colors[LedIndex].B; - s32 BR = Data->B.Colors[LED->Index].R; - s32 BG = Data->B.Colors[LED->Index].G; - s32 BB = Data->B.Colors[LED->Index].B; + s32 BR = Data->B.Colors[LedIndex].R; + s32 BG = Data->B.Colors[LedIndex].G; + s32 BB = Data->B.Colors[LedIndex].B; s32 RCombined = (AR * BR) / 255; s32 GCombined = (AG * BG) / 255; s32 BCombined = (AB * BB) / 255; - Data->Result.Colors[LED->Index].R = (u8)RCombined; - Data->Result.Colors[LED->Index].G = (u8)GCombined; - Data->Result.Colors[LED->Index].B = (u8)BCombined; - - LED++; + Data->Result.Colors[LedIndex].R = (u8)RCombined; + Data->Result.Colors[LedIndex].G = (u8)GCombined; + Data->Result.Colors[LedIndex].B = (u8)BCombined; } } diff --git a/src/app/foldhaus_node.h b/src/app/foldhaus_node.h index b51b9ca..17a6c7b 100644 --- a/src/app/foldhaus_node.h +++ b/src/app/foldhaus_node.h @@ -14,7 +14,7 @@ typedef enum node_type node_type; struct color_buffer { - led* LEDs; + v4* LedPositions; pixel* Colors; s32 LEDCount; }; @@ -66,7 +66,7 @@ struct node_specification_ struct pattern_node { // TODO(Peter): Something to think about further down the line is the fact that - // SpecificationIndex doesn't have to stay static throughout a single instance of + // SpecificationIndex doesn't have to stay static throughout a single instance of // an application, let alone across separate runs. If you recompile (hot load or not) // with a new specification, the indecies all get thrown off. Should we hash the spec // names or something? @@ -90,7 +90,7 @@ struct pattern_node_workspace gs_bucket Connections; // This is storage for all the structures which follow. - // It is cleared when new nodes are added so that the + // It is cleared when new nodes are added so that the // acceleration structures can be recalculated memory_arena Storage; s32* SparseToSortedNodeMap; @@ -109,7 +109,7 @@ struct data_name struct data_name #define NODE_PROC(proc_name, input_type) \ -void proc_name(input_type* Data, r32 DeltaTime) +void proc_name(input_type* Data, r32 DeltaTime) #define NODE_IN(type, name) type name #define NODE_OUT(type, name) type name diff --git a/src/app/generated/gs_meta_generated_typeinfo.h b/src/app/generated/gs_meta_generated_typeinfo.h index e5cc3e0..9395469 100644 --- a/src/app/generated/gs_meta_generated_typeinfo.h +++ b/src/app/generated/gs_meta_generated_typeinfo.h @@ -39,10 +39,9 @@ enum gsm_struct_type gsm_StructType_v4, gsm_StructType_float, gsm_StructType_color_buffer, - gsm_StructType_led, - gsm_StructType_s32, gsm_StructType_pixel, gsm_StructType_u8, + gsm_StructType_s32, gsm_StructType_sin_wave_data, gsm_StructType_r32, gsm_StructType_revolving_discs_data, @@ -62,10 +61,6 @@ static gsm_struct_member_type_info StructMembers_v4[] = { { "a", 1, (u64)&((v4*)0)->a, {}, 0}, { "E", 1, (u64)&((v4*)0)->E, {}, 0}, }; -static gsm_struct_member_type_info StructMembers_led[] = { -{ "Index", 5, (u64)&((led*)0)->Index, {}, 0}, -{ "Position", 8, (u64)&((led*)0)->Position, {}, 0}, -}; static gsm_struct_member_type_info StructMembers_pixel[] = { { "R", 1, (u64)&((pixel*)0)->R, {}, 0}, { "G", 1, (u64)&((pixel*)0)->G, {}, 0}, @@ -73,7 +68,7 @@ static gsm_struct_member_type_info StructMembers_pixel[] = { { "Channels", 8, (u64)&((pixel*)0)->Channels, {}, 0}, }; static gsm_struct_member_type_info StructMembers_color_buffer[] = { -{ "LEDs", 4, (u64)&((color_buffer*)0)->LEDs, {}, 0}, +{ "LedPositions", 12, (u64)&((color_buffer*)0)->LedPositions, {}, 0}, { "Colors", 6, (u64)&((color_buffer*)0)->Colors, {}, 0}, { "LEDCount", 8, (u64)&((color_buffer*)0)->LEDCount, {}, 0}, }; @@ -115,14 +110,13 @@ static gsm_struct_type_info StructTypes[] = { { gsm_StructType_v4, "v4", 2, 16, 0, 0, StructMembers_v4, 3 }, { gsm_StructType_float, "float", 5, 4, 0, 0, 0, 0 }, { gsm_StructType_color_buffer, "color_buffer", 12, 20, 0, 0, StructMembers_color_buffer, 3 }, -{ gsm_StructType_led, "led", 3, 20, 0, 0, StructMembers_led, 2 }, -{ gsm_StructType_s32, "s32", 3, 4, 0, 0, 0, 0 }, { gsm_StructType_pixel, "pixel", 5, 3, 0, 0, StructMembers_pixel, 2 }, { gsm_StructType_u8, "u8", 2, 1, 0, 0, 0, 0 }, +{ gsm_StructType_s32, "s32", 3, 4, 0, 0, 0, 0 }, { gsm_StructType_sin_wave_data, "sin_wave_data", 13, 20, 0, 0, StructMembers_sin_wave_data, 5 }, { gsm_StructType_r32, "r32", 3, 4, 0, 0, 0, 0 }, { gsm_StructType_revolving_discs_data, "revolving_discs_data", 20, 60, 0, 0, StructMembers_revolving_discs_data, 8 }, { gsm_StructType_vertical_color_fade_data, "vertical_color_fade_data", 24, 44, 0, 0, StructMembers_vertical_color_fade_data, 4 }, { gsm_StructType_multiply_patterns_data, "multiply_patterns_data", 22, 60, 0, 0, StructMembers_multiply_patterns_data, 3 }, }; -static gsm_u32 StructTypesCount = 13; +static gsm_u32 StructTypesCount = 12; diff --git a/src/app/panels/foldhaus_panel_sculpture_view.h b/src/app/panels/foldhaus_panel_sculpture_view.h index 4d239f3..7ff61ee 100644 --- a/src/app/panels/foldhaus_panel_sculpture_view.h +++ b/src/app/panels/foldhaus_panel_sculpture_view.h @@ -71,7 +71,7 @@ SculptureView_Cleanup(panel* Panel, app_state* State) struct draw_leds_job_data { - led* LEDs; + v4* Positions; pixel* Colors; s32 StartIndex; s32 OnePastLastIndex; @@ -107,15 +107,13 @@ DrawLEDsInBufferRangeJob (s32 ThreadID, void* JobData) v2 UV2 = v2{1, 1}; v2 UV3 = v2{0, 1}; - led* LED = Data->LEDs + Data->StartIndex; - for (s32 LEDIdx = 0; - LEDIdx < LEDCount; - LEDIdx++) + + for (s32 LedIndex = 0; LedIndex < LEDCount; LedIndex++) { - pixel PixelColor = Data->Colors[LED->Index]; + pixel PixelColor = Data->Colors[LedIndex]; v4 Color = v4{PixelColor.R / 255.f, PixelColor.G / 255.f, PixelColor.B / 255.f, 1.0f}; - v4 V4Position = LED->Position; + v4 V4Position = Data->Positions[Data->StartIndex + LedIndex]; V4Position.w = 0; v4 P0 = P0_In + V4Position; v4 P1 = P1_In + V4Position; @@ -126,8 +124,6 @@ DrawLEDsInBufferRangeJob (s32 ThreadID, void* JobData) P0, P1, P2, UV0, UV1, UV2, Color, Color, Color); SetTri3DInBatch(Data->Batch, BatchReservedRange.Start + TrisUsed++, P0, P2, P3, UV0, UV2, UV3, Color, Color, Color); - - LED++; } } @@ -165,7 +161,7 @@ SculptureView_Render(panel Panel, rect PanelBounds, render_command_buffer* Rende for (u32 Job = 0; Job < JobsNeeded; Job++) { draw_leds_job_data* JobData = PushStruct(&State->Transient, draw_leds_job_data); - JobData->LEDs = LedBuffer->Leds; + JobData->Positions = LedBuffer->Positions; JobData->Colors = LedBuffer->Colors; JobData->StartIndex = Job * MaxLEDsPerJob; JobData->OnePastLastIndex = GSMin(JobData->StartIndex + MaxLEDsPerJob, LedBuffer->LedCount); diff --git a/src/app/test_patterns.h b/src/app/test_patterns.h index 4215ae0..51da616 100644 --- a/src/app/test_patterns.h +++ b/src/app/test_patterns.h @@ -8,49 +8,47 @@ GSMetaTag(node_struct); struct solid_color_data { - GSMetaTag(node_input); + GSMetaTag(node_input); v4 Color; GSMetaTag(node_output); color_buffer Result; }; -GSMetaTag(node_proc); // :TagParamsForNodeParamStructs +GSMetaTag(node_proc); // :TagParamsForNodeParamStructs void SolidColorProc(solid_color_data* Data) { u8 R = (u8)GSClamp(0.f, (Data->Color.r * 255), 255.f); u8 G = (u8)GSClamp(0.f, (Data->Color.g * 255), 255.f); u8 B = (u8)GSClamp(0.f, (Data->Color.b * 255), 255.f); - led* LED = Data->Result.LEDs; - for (s32 l = 0; l < Data->Result.LEDCount; l++) + for (s32 LedIndex = 0; LedIndex < Data->Result.LEDCount; LedIndex++) { - Assert(LED->Index >= 0 && LED->Index < Data->Result.LEDCount); + Assert(LedIndex >= 0 && LedIndex < Data->Result.LEDCount); - Data->Result.Colors[LED->Index].R = R; - Data->Result.Colors[LED->Index].G = G; - Data->Result.Colors[LED->Index].B = B; - LED++; + Data->Result.Colors[LedIndex].R = R; + Data->Result.Colors[LedIndex].G = G; + Data->Result.Colors[LedIndex].B = B; } } GSMetaTag(node_struct); struct vertical_color_fade_data { - GSMetaTag(node_input); + GSMetaTag(node_input); v4 Color; - GSMetaTag(node_input); + GSMetaTag(node_input); r32 Min; - GSMetaTag(node_input); + GSMetaTag(node_input); r32 Max; GSMetaTag(node_output); color_buffer Result; }; -GSMetaTag(node_proc); // :TagParamsForNodeParamStructs +GSMetaTag(node_proc); // :TagParamsForNodeParamStructs void VerticalColorFadeProc(vertical_color_fade_data* Data) { r32 R = (Data->Color.r * 255); @@ -59,18 +57,18 @@ void VerticalColorFadeProc(vertical_color_fade_data* Data) r32 Range = Data->Max - Data->Min; - led* LED = Data->Result.LEDs; - for (s32 l = 0; l < Data->Result.LEDCount; l++) + + for (s32 LedIndex = 0; LedIndex < Data->Result.LEDCount; LedIndex++) { - Assert(LED->Index >= 0 && LED->Index < Data->Result.LEDCount); + Assert(LedIndex >= 0 && LedIndex < Data->Result.LEDCount); + v4 LedPosition = Data->Result.LedPositions[LedIndex]; - r32 Amount = (LED->Position.y - Data->Min) / Range; + r32 Amount = (LedPosition.y - Data->Min) / Range; Amount = GSClamp01(1.0f - Amount); - Data->Result.Colors[LED->Index].R = (u8)(R * Amount); - Data->Result.Colors[LED->Index].G = (u8)(G * Amount); - Data->Result.Colors[LED->Index].B = (u8)(B * Amount); - LED++; + Data->Result.Colors[LedIndex].R = (u8)(R * Amount); + Data->Result.Colors[LedIndex].G = (u8)(G * Amount); + Data->Result.Colors[LedIndex].B = (u8)(B * Amount); } } @@ -78,32 +76,32 @@ void VerticalColorFadeProc(vertical_color_fade_data* Data) GSMetaTag(node_struct); struct revolving_discs_data { - GSMetaTag(node_input); + GSMetaTag(node_input); r32 Rotation; - GSMetaTag(node_input); + GSMetaTag(node_input); r32 ThetaZ; - GSMetaTag(node_input); + GSMetaTag(node_input); r32 ThetaY; - GSMetaTag(node_input); + GSMetaTag(node_input); r32 DiscWidth; - GSMetaTag(node_input); + GSMetaTag(node_input); r32 InnerRadius; - GSMetaTag(node_input); + GSMetaTag(node_input); r32 OuterRadius; - GSMetaTag(node_input); + GSMetaTag(node_input); v4 Color; GSMetaTag(node_output); color_buffer Result; }; -GSMetaTag(node_proc); // :TagParamsForNodeParamStructs +GSMetaTag(node_proc); // :TagParamsForNodeParamStructs void RevolvingDiscs(revolving_discs_data* Data) { DEBUG_TRACK_FUNCTION; @@ -124,10 +122,9 @@ void RevolvingDiscs(revolving_discs_data* Data) r32 OuterRadiusSquared = Data->OuterRadius * Data->OuterRadius; r32 InnerRadiusSquared = Data->InnerRadius * Data->InnerRadius; - led* LED = Data->Result.LEDs; - for (s32 l = 0; l < Data->Result.LEDCount; l++) + for (s32 LedIndex = 0; LedIndex < Data->Result.LEDCount; LedIndex++) { - v4 Position = LED->Position; + v4 Position = Data->Result.LedPositions[LedIndex]; v4 ToFront = Position + FrontCenter; v4 ToBack = Position + BackCenter; @@ -143,10 +140,9 @@ void RevolvingDiscs(revolving_discs_data* Data) { if (XOR(ToFrontDotNormal > 0, ToBackDotNormal > 0)) { - Data->Result.Colors[LED->Index] = Color; + Data->Result.Colors[LedIndex] = Color; } } - LED++; } } diff --git a/src/app/win32_foldhaus_memory.h b/src/app/win32_foldhaus_memory.h index e786c44..c1c8c1c 100644 --- a/src/app/win32_foldhaus_memory.h +++ b/src/app/win32_foldhaus_memory.h @@ -10,8 +10,8 @@ PLATFORM_ALLOC(Win32Alloc) { - u8* Result = (u8*)VirtualAlloc(NULL, Size, - MEM_COMMIT | MEM_RESERVE, + u8* Result = (u8*)VirtualAlloc(NULL, Size, + MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); return Result; } @@ -21,7 +21,7 @@ PLATFORM_FREE(Win32Free) b32 Result = VirtualFree(Base, 0, MEM_RELEASE); if (!Result) { - s32 Error = WSAGetLastError(); + s32 Error = GetLastError(); // TODO(Peter): I'm waiting to see an error actually occur here // to know what it could possibly be. InvalidCodePath;