summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp105
1 files changed, 15 insertions, 90 deletions
diff --git a/main.cpp b/main.cpp
index 3a517be..4d513c4 100644
--- a/main.cpp
+++ b/main.cpp
@@ -5,15 +5,6 @@
#include <sys/mman.h>
#endif
-// TODO(fox): Switch all thread code to SDL!
-#if WINDOWS
-#else
-#if THREADED
-#include <pthread.h>
-#else
-#endif
-#endif
-
#if ARM
#include <arm_neon.h>
#else
@@ -101,11 +92,10 @@ typedef double real64;
#include "main.h"
#include "debug.h"
-global_variable uint32 volatile CompletedJobs;
-global_variable uint32 volatile NextEntryToDo;
-global_variable uint32 volatile EntryCount;
+SDL_atomic_t CurrentEntry;
+SDL_atomic_t QueuedEntries;
+SDL_atomic_t CompletedEntries;
global_variable bool32 IsRendering = false;
-global_variable bool32 D = true;
global_variable instruction_mode InstructionMode = scalar_only;
@@ -314,11 +304,9 @@ int main(int argc, char *argv[]) {
InstructionMode = avx_enabled;
}
- InstructionMode = scalar_only;
-
project_data File = {};
- File.Width = 1280;
- File.Height = 720;
+ File.Width = 1283;
+ File.Height = 723;
File.NumberOfFrames = 65;
File.FPS = 30;
File.CurrentFrame = 1;
@@ -337,14 +325,6 @@ int main(int argc, char *argv[]) {
ui UI = {};
- // File.NumberOfSources = 2;
- // File.Source[0] = (char *)AllocateMemory(&Memory, STRING_SIZE, F_Strings);
- // File.Source[1] = (char *)AllocateMemory(&Memory, STRING_SIZE, F_Strings);
- // sprintf(File.Source[0], "../asset/b.jpg");
- // sprintf(File.Source[1], "../asset/24.mp4");
- // CreateLayerFromSource(&File, &State, &Memory, File.Source[0]);
- // CreateLayerFromSource(&File, &State, &Memory, File.Source[1]);
-
// shm_unlink("/testl");
// int fd = shm_open("/testl", O_CREAT | O_EXCL | O_RDWR,
// S_IRUSR | S_IWUSR);
@@ -367,68 +347,6 @@ int main(int argc, char *argv[]) {
// if (sem_init(&shmp->sem2, 1, 0) == -1)
// Assert(0);
- // CreateLayerFromSource(&File, &State, &Memory, "../asset/24.mp4");
- // project_layer *Layer1 = CreateDebugLayer(&File, &Memory, 9, 14);
- // project_layer *Layer1 = CreateSolidLayer(&File, &Memory, 9, 13, V4(1.0, 1.0, 1.0, 1.0));
- // Layer1->x.CurrentValue.f = 7;
- // Layer1->y.CurrentValue.f = 4;
- // Layer1->StartFrame = 0;
- // Layer1->EndFrame = File.EndFrame;
-
- // CreateDebugLayer(&File, &Memory, 12, 8);
- // File.Layer[0]->Name = "debug";
- // File.Layer[0]->StartFrame = 0;
- // File.Layer[0]->EndFrame = 65;
-
- // CreateLayer(&File, &Memory);
-
- // CreateRenderInfo(File.Layer[0], &Memory, File, image, "./asset/r.jpg");
-
- // File.Layer[0]->Name = "Robot";
- // File.Layer[0]->x.CurrentValue.f = 200;
- // File.Layer[0]->y.CurrentValue.f = 250;
- // File.Layer[0]->scale.CurrentValue.f = 1.1;
- // File.Layer[0]->opacity.CurrentValue.f = 1.0;
- // File.Layer[0]->StartFrame = 0;
- // File.Layer[0]->EndFrame = 65;
-
- // ManualKeyframeInsertF(&File.Layer[0]->x, &Memory, 2, 100);
- // ManualKeyframeInsertF(&File.Layer[0]->x, &Memory, 60, 500);
-
-
- // ManualKeyframeInsertF(&File.Layer[0]->x, &Memory, 3, 300);
- // ManualKeyframeInsertF(&File.Layer[0]->x, &Memory, 8, 800);
- // ManualKeyframeInsertF(&File.Layer[0]->x, &Memory, 5, 500);
- // ManualKeyframeInsertF(&File.Layer[0]->x, &Memory, 6, 600);
- // ManualKeyframeInsertF(&File.Layer[0]->x, &Memory, 7, 700);
-
- // File.Layer[0]->x.KeyframeBlock[0]->Keyframe[2].IsSelected = true;
- // File.Layer[0]->x.KeyframeBlock[0]->Keyframe[3].IsSelected = true;
- // File.Layer[0]->x.KeyframeBlock[0]->Keyframe[4].IsSelected = true;
- // File.Layer[0]->x.KeyframeBlock[0]->Keyframe[6].IsSelected = true;
-
- // DeleteSelectedKeyframes(&File, &Memory);
-
- // for (int16 i = 0; i < 10; i++) {
- // ManualKeyframeInsertF(&File.Layer[0]->x, &Memory, i*6 + 3, i*100);
- // }
-
- // int16 kef = 2;
- // for (int16 i = 0; i < kef; i++) {
- // int16 p = kef - i;
- // ManualKeyframeInsertF(&File.Layer[0]->x, &Memory, p*4, p*100);
- // }
- // &File.Layer[1]->x.KeyframeBlock[0]->Keyframe[2];
- // KeyframeDelete(&File.Layer[1]->x, &Memory, 2);
-
- // AddEffect(File.Layer[0], &Memory, 0);
- // AddEffect(File.Layer[0], &Memory, 0);
-
- // for (int i = 0; i < 3; i++)
- // CreateLayer(&File, &Memory);
-
- // DebugPrintMemoryUsage(Memory);
-
SDL_Init(SDL_INIT_VIDEO);
Semaphore = SDL_CreateSemaphore(0);
@@ -583,18 +501,24 @@ int main(int argc, char *argv[]) {
// File.CurrentFrame = shmp->shared_framenumber;
// }
+ // Right now IsRendering does nothing. I have it here if we want to
+ // completely detatch the rendering updater onto its own thread so the
+ // UI never lags.
+
if (State.UpdateFrame && !IsRendering) {
MainFunction(0, &Memory, &State, &File, &Cache, &CompBuffer);
State.UpdateFrame = 0;
- OutputToViewport(&CompBuffer, &State, textureID);
}
#if THREADED
+ uint32 C = SDL_AtomicGet(&CompletedEntries);
if (IsRendering) {
- while (CompletedJobs != 16) {
+ while (C != 16) {
+ C = SDL_AtomicGet(&CompletedEntries);
CheckQueue(RenderInfo, 8);
}
- if (CompletedJobs == 16) {
+ C = SDL_AtomicGet(&CompletedEntries);
+ if (C == 16) {
Convert4x4Chunk(&CompBuffer, 1);
EndRenderState(&State);
glBindTexture(GL_TEXTURE_2D, textureID);
@@ -608,6 +532,7 @@ int main(int argc, char *argv[]) {
}
}
#else
+ OutputToViewport(&CompBuffer, &State, textureID);
#endif
ImGui::Render();