summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild.bat10
-rwxr-xr-xbuild.sh4
-rw-r--r--effects.cpp4
-rw-r--r--keyframes.cpp5
-rw-r--r--main.cpp34
-rw-r--r--prenderer.cpp17
6 files changed, 61 insertions, 13 deletions
diff --git a/build.bat b/build.bat
new file mode 100755
index 0000000..9fd305b
--- /dev/null
+++ b/build.bat
@@ -0,0 +1,10 @@
+REM call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
+@set SDL2_DIR=C:\lib\SDL2-2.0.22
+@set FFMPEG_DIR=C:\lib\ffmpeg-n5.0-latest-win64-lgpl-shared-5.0
+@set OUT_EXE=real2d
+@set INCLUDES=/I.. /Iimgui /I%SDL2_DIR%\include /IC:\lib\glew-2.1.0\include /I%FFMPEG_DIR%\include
+@set IMGUI_SOURCES=imgui\backends\imgui_impl_sdl.cpp imgui\backends\imgui_impl_opengl3.cpp imgui\imgui*.cpp
+@set SDL_LIBS=/LIBPATH:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib shell32.lib
+@set FFMPEG_LIBS=/LIBPATH:%FFMPEG_DIR%\lib avcodec.lib avfilter.lib avformat.lib swscale.lib avutil.lib
+@set PREPROCESSORS=/DWINDOWS=1 /DARM=0 /DTHREADED=0 /DPACKEDRGB=1
+cl /nologo /Zi /MD %PREPROCESSORS% %INCLUDES% main.cpp %IMGUI_SOURCES% /Febin/real2d.exe /Fobin/ /link %SDL_LIBS% %FFMPEG_LIBS% /subsystem:console \ No newline at end of file
diff --git a/build.sh b/build.sh
index 39f05cd..5f10e49 100755
--- a/build.sh
+++ b/build.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-WINDOWS=1
+WINDOWS=0
WARNING_FLAGS="
-Wall -Wextra \
@@ -8,7 +8,7 @@ WARNING_FLAGS="
-Wno-missing-field-initializers -Wno-sign-compare -Wno-write-strings -Wno-unused-but-set-parameter \
-Wno-missing-braces -Wno-format-security
-fno-exceptions -Wno-strict-aliasing \
- -DDEBUG=1 -DARM=0 -DTHREADED=1 -DPACKEDRGB=1 \
+ -DDEBUG=1 -DARM=0 -DTHREADED=0 -DPACKEDRGB=1 \
"
if [[ "$WINDOWS" == 1 ]]; then
diff --git a/effects.cpp b/effects.cpp
index fe593a4..5532a97 100644
--- a/effects.cpp
+++ b/effects.cpp
@@ -184,6 +184,9 @@ DrawGradient(pixel_buffer *Buffer, memory *Memory, property_channel Property[])
v4 EndColor = Property[1].CurrentValue.col;
}
+#if WINDOWS
+global_variable effect_header EffectList[2];
+#else
global_variable effect_header EffectList[] {
{
"Solid Color",
@@ -201,6 +204,7 @@ global_variable effect_header EffectList[] {
}
}
};
+#endif
#if 0
{
"Solid Color",
diff --git a/keyframes.cpp b/keyframes.cpp
index a7ff37a..42234d8 100644
--- a/keyframes.cpp
+++ b/keyframes.cpp
@@ -238,7 +238,12 @@ ClampKeyframeHandles(property_channel *Property, int16 b, int16 dir) {
keyframe *Keyframe = KeyframeLookupIndex(Property, b - 1);
keyframe *NextKeyframe = KeyframeLookupIndex(Property, b);
real32 XSpan = NextKeyframe->FrameNumber - Keyframe->FrameNumber;
+ // TODO(fox): Fix this!
+#if WINDOWS
+ if (NextKeyframe->TangentLeft.x > XSpan)
+#else
if (abs(NextKeyframe->TangentLeft.x) > XSpan)
+#endif
NextKeyframe->TangentLeft.x = -XSpan;
if (NextKeyframe->TangentLeft.x > 0)
NextKeyframe->TangentLeft.x = 0;
diff --git a/main.cpp b/main.cpp
index 844a6f7..59d0e3a 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,4 +1,3 @@
-#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#if WINDOWS
@@ -6,6 +5,15 @@
#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
@@ -15,7 +23,11 @@
#include "imgui/imgui.h"
#include "imgui/backends/imgui_impl_sdl.h"
#include "imgui/backends/imgui_impl_opengl3.h"
+#if WINDOWS
+#include <SDL.h>
+#else
#include <SDL2/SDL.h>
+#endif
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <SDL_opengles2.h>
#else
@@ -104,7 +116,10 @@ SDL_sem *Semaphore;
#include "effects.cpp"
#include "keyframes.cpp"
#include "layer.cpp"
+#if THREADED
#include "threading.cpp"
+#else
+#endif
#include "prenderer.cpp"
#include "video.cpp"
#include "createcalls.cpp"
@@ -416,7 +431,7 @@ int main(int argc, char *argv[]) {
RenderInfo.File = &File;
RenderInfo.State = &State;
RenderInfo.CompBuffer = &CompBuffer;
-
+#if THREADED
thread_info ThreadInfo[7];
for (int i = 0; i < 7; i++) {
@@ -425,7 +440,7 @@ int main(int argc, char *argv[]) {
ThreadInfo[i].RenderInfo = &RenderInfo;
thread[i] = SDL_CreateThread(TestThread, str, &ThreadInfo[i]);
}
-
+#endif
sdl_input Input;
sdl_input OldInput;
@@ -564,6 +579,7 @@ int main(int argc, char *argv[]) {
State.UpdateFrame = 0;
}
+#if THREADED
if (IsRendering) {
while (CompletedJobs != 16) {
CheckQueue(RenderInfo, 8);
@@ -586,6 +602,18 @@ int main(int argc, char *argv[]) {
}
}
+#else
+#if PACKEDRGB
+ Unpack4x4Chunk(&CompBuffer);
+ // SSE_CopyToBuffer(CompBuffer);
+#else
+ PackBitmapRGB(&CompBuffer);
+#endif
+ EndRenderState(&State);
+ glBindTexture(GL_TEXTURE_2D, textureID);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, CompBuffer.Width, CompBuffer.Height, GL_RGBA, GL_UNSIGNED_BYTE,
+ CompBuffer.EffectBuffer);
+#endif
ImGui::Render();
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
diff --git a/prenderer.cpp b/prenderer.cpp
index 4080af1..4d4152d 100644
--- a/prenderer.cpp
+++ b/prenderer.cpp
@@ -7,7 +7,7 @@ RenderLayerNeon(project_layer *Layer, pixel_buffer *Buffer, rectangle RenderRegi
internal void
AVX2_RenderLayer(transform_info TransformInfo, pixel_buffer *Buffer, rectangle RenderRegion);
internal void
-RenderLayer(transform_info TransformInfo, pixel_buffer *Buffer, rectangle RenderRegion);
+Fallback_RenderLayer(transform_info TransformInfo, pixel_buffer *Buffer, rectangle RenderRegion);
internal bool32
CheckQueue(render_queue RenderInfo, uint16 Index);
@@ -106,10 +106,11 @@ 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);
+#endif
}
@@ -159,7 +160,7 @@ QueueCurrentFrame(project_data *File, pixel_buffer *CompBuffer, project_state *S
// State->NumberOfLayersToRender = 0;
#else
- DEBUG_CycleCountStart(3);
+ // DEBUG_CycleCountStart(3);
rectangle RenderRegion = {0, 0, (int32)CompBuffer->Width, (int32)CompBuffer->Height};
for (int16 i = 0; i < RenderInfo.State->NumberOfLayersToRender; i++) {
@@ -168,15 +169,15 @@ QueueCurrentFrame(project_data *File, pixel_buffer *CompBuffer, project_state *S
RenderLayerNeon(RenderInfo.File->Layer[Idx], RenderInfo.CompBuffer, RenderRegion);
#else
// RenderLayerSSE(RenderInfo.File->Layer[Idx]->TransformInfo, RenderInfo.CompBuffer, RenderRegion);
- if (Old)
- RenderLayer(RenderInfo.File->Layer[Idx]->TransformInfo, RenderInfo.CompBuffer, RenderRegion);
- else
+ if (AVXEnabled)
AVX2_RenderLayer(RenderInfo.File->Layer[Idx]->TransformInfo, RenderInfo.CompBuffer, RenderRegion);
+ else
+ Fallback_RenderLayer(RenderInfo.File->Layer[Idx]->TransformInfo, RenderInfo.CompBuffer, RenderRegion);
#endif
}
- DEBUG_CycleCountEnd(3);
- Debug.ExecutionAmount[4] += 1280*720;
+ // DEBUG_CycleCountEnd(3);
+ // Debug.ExecutionAmount[4] += 1280*720;
for (int16 i = 0; i < State->NumberOfLayersToRender; i++)
{