summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bitmap_calls.cpp2
-rwxr-xr-xbuild.bat43
-rw-r--r--defines.h4
-rw-r--r--effects.h15
-rw-r--r--ffmpeg_backend.cpp2
-rw-r--r--ffmpeg_backend.h2
-rw-r--r--main.cpp3
-rw-r--r--main.h2
-rw-r--r--my_imgui_internal_widgets.cpp14
-rw-r--r--prenderer.cpp12
10 files changed, 59 insertions, 40 deletions
diff --git a/bitmap_calls.cpp b/bitmap_calls.cpp
index f37f493..46f0c31 100644
--- a/bitmap_calls.cpp
+++ b/bitmap_calls.cpp
@@ -249,7 +249,7 @@ Bitmap_StencilAlpha(void *Input, void *Output, uint16 BytesPerPixel, uint64 Tota
uint64 RemainderBytes = TotalBytes % ByteOffset;
__m256i AlphaBytes = _mm256_set1_epi32(0x00FFFFFF);
- __m256 Zeroi = _mm256_set1_epi32(0);
+ __m256i Zeroi = _mm256_set1_epi32(0);
while (bytes <= TotalBytes - RemainderBytes) {
uint8 *Pixel = (uint8 *)Row + bytes;
diff --git a/build.bat b/build.bat
index f325dd8..c2735c1 100755
--- a/build.bat
+++ b/build.bat
@@ -1,10 +1,35 @@
+@echo off
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
-cl /nologo /Zi /MD %PREPROCESSORS% %INCLUDES% main.cpp %IMGUI_SOURCES% /Febin/real2d.exe /Fobin/ /link %SDL_LIBS% %FFMPEG_LIBS% /subsystem:console
+
+set SDL2_DIR=C:\lib\SDL2-2.0.22
+set FFMPEG_DIR=C:\lib\ffmpeg-n5.0-latest-win64-lgpl-shared-5.0
+
+REM /Zi /O2
+set OPTIMIZATION=/Zi
+set DEBUG=1
+set IMGUI=0
+set THREADED=1
+set WINDOWS=1
+set ARM=0
+set PACKEDRGB=0
+set PERF=0
+
+set INCLUDES=/I.. /Iimgui /I%SDL2_DIR%\include /IC:\lib\glew-2.1.0\include /I%FFMPEG_DIR%\include /Ilib/glad/include
+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 IMGUI_FILES=imgui\backends\imgui_impl_sdl.cpp imgui\backends\imgui_impl_opengl3.cpp imgui\imgui*.cpp
+set WARNING_FLAGS=/W2 /wd4805 /wd4477 /wd4244 /wd4305
+
+if %DEBUG%==1 ( set PREPROCESSORS="/DDEBUG=1" )
+if %THREADED%==1 ( set PREPROCESSORS=%PREPROCESSORS% "/DTHREADED=1" )
+if %WINDOWS%==1 ( set PREPROCESSORS=%PREPROCESSORS% "/DWINDOWS=1" )
+if %ARM%==1 ( set PREPROCESSORS=%PREPROCESSORS% "/DARM=1" )
+if %PACKEDRGB%==1 ( set PREPROCESSORS=%PREPROCESSORS% "/DPACKEDRGB=1" )
+if %PERF%==1 ( set PREPROCESSORS=%PREPROCESSORS% "/DPERF=1" )
+
+cl /nologo %OPTIMIZATION% /MD /I.. /Iimgui /I%SDL2_DIR%\include my_imgui_internal_widgets.cpp /Fobin/ /c
+if %IMGUI%==1 ( cl /nologo %OPTIMIZATION% /MD /I.. /Iimgui /I%SDL2_DIR%\include %IMGUI_FILES% /Fobin/ /c )
+
+cl /nologo %OPTIMIZATION% /MD /I.. /Ilib/glad/include lib/glad.c /Fobin/ /c
+
+cl /nologo /Zi /MD %WARNING_FLAGS% %PREPROCESSORS% %INCLUDES% main.cpp bin/*.obj /Febin/real2d.exe /Fobin/ /link %SDL_LIBS% %FFMPEG_LIBS% /subsystem:console
diff --git a/defines.h b/defines.h
index d3ccc16..c124f53 100644
--- a/defines.h
+++ b/defines.h
@@ -15,8 +15,8 @@ typedef double real64;
typedef uint64 ptrsize; // is there a compiler variable for 32 vs 64 bit like this?
-#define NORMALIZED_COL_MIN { .col = V4(0.0f, 0.0f, 0.0f, 0.0f) }
-#define NORMALIZED_COL_MAX { .col = V4(1.0f, 1.0f, 1.0f, 1.0f) }
+#define NORMALIZED_COL_MIN V4(0.0f, 0.0f, 0.0f, 0.0f)
+#define NORMALIZED_COL_MAX V4(1.0f, 1.0f, 1.0f, 1.0f)
#define NORMALIZED_REAL_MIN { 0.0f }
#define NORMALIZED_REAL_MAX { 1.0f }
diff --git a/effects.h b/effects.h
index 58787c2..fdd311e 100644
--- a/effects.h
+++ b/effects.h
@@ -43,15 +43,12 @@ struct effect {
};
-#if WINDOWS
-static effect_header EffectList[3];
-#else
static effect_header EffectList[] {
{
"Solid Color",
&Effect_DrawColor, 2, standard, {
- {"Color", {.col = V4(0.0f, 0.0f, 0.0f, 1.0f)}, type_color, NORMALIZED_COL_MIN, NORMALIZED_COL_MAX},
- {"Blend mode", {.blendmode = blend_normal}, type_blendmode},
+ {"Color", { V4(0.0f, 0.0f, 0.0f, 1.0f) }, type_color, { NORMALIZED_COL_MIN }, { NORMALIZED_COL_MAX} },
+ {"Blend mode", { blend_normal }, type_blendmode},
}
},
{
@@ -60,9 +57,9 @@ static effect_header EffectList[] {
{"Start point", {0.0f}, type_real},
{"Mid point", {1.0f}, type_real},
{"End point", {1.0f}, type_real},
- {"Start Col", {.col = V4(0.0f)}, type_color},
- {"Mid Col", {.col = V4(1.0f)}, type_color},
- {"End Col", {.col = V4(1.0f)}, type_color},
+ {"Start Col", { V4(0.0f)}, type_color},
+ {"Mid Col", { V4(1.0f)}, type_color},
+ {"End Col", { V4(1.0f)}, type_color},
}
},
{
@@ -72,5 +69,3 @@ static effect_header EffectList[] {
}
}
};
-#endif
-
diff --git a/ffmpeg_backend.cpp b/ffmpeg_backend.cpp
index 6e16e76..89c0c91 100644
--- a/ffmpeg_backend.cpp
+++ b/ffmpeg_backend.cpp
@@ -6,7 +6,6 @@ extern "C" {
#include <libswscale/swscale.h>
}
-/*
// workaround to make libav error printing work
#ifdef av_err2str
#undef av_err2str
@@ -17,7 +16,6 @@ av_always_inline std::string av_err2string(int errnum) {
}
#define av_err2str(err) av_err2string(err).c_str()
#endif // av_err2str
-*/
#include "ffmpeg_backend.h"
diff --git a/ffmpeg_backend.h b/ffmpeg_backend.h
index de73ff4..62134fe 100644
--- a/ffmpeg_backend.h
+++ b/ffmpeg_backend.h
@@ -5,7 +5,7 @@
// position. Different files don't exhibit this behavior.
struct av_info {
- uint64 PreviousPTS = -1; // PTS value of the previous frame, used to check timings.
+ uint64 PreviousPTS = (uint64)-1; // PTS value of the previous frame, used to check timings.
AVCodecParameters *VideoCodecParameters; // Used to supply info about the decoder.
const AVCodec* VideoCodec;
diff --git a/main.cpp b/main.cpp
index 3456aa8..7cb0288 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,10 +1,11 @@
#include <glad/glad.h>
-#include <unistd.h>
#include <stdio.h>
#if WINDOWS
+#include <windows.h>
#else
#include <sys/mman.h>
+#include <unistd.h>
#endif
#if ARM
diff --git a/main.h b/main.h
index 50242c3..b0d1a1c 100644
--- a/main.h
+++ b/main.h
@@ -143,8 +143,8 @@ enum blend_mode
union val {
- real32 f;
v4 col;
+ real32 f;
blend_mode blendmode;
};
diff --git a/my_imgui_internal_widgets.cpp b/my_imgui_internal_widgets.cpp
index 705b898..d398ca1 100644
--- a/my_imgui_internal_widgets.cpp
+++ b/my_imgui_internal_widgets.cpp
@@ -151,7 +151,7 @@ bool ImGui::TestLine(ImVec2 p0, ImVec2 p1)
ImU32 col = ImGui::GetColorU32(ImGuiCol_ScrollbarGrab);
- if (abs(g.IO.MousePos.x - point.x) < 3 && abs(g.IO.MousePos.y - point.y) < 3 &&
+ if (ImFabs(g.IO.MousePos.x - point.x) < 3 && ImFabs(g.IO.MousePos.y - point.y) < 3 &&
point.x != p0.x && point.y != p0.y &&
point.x != p1.x && point.y != p1.y)
{
@@ -191,9 +191,9 @@ bool ImGui::BezierInteractive(ImVec2 p0, ImVec2 p1, ImVec2 p2, ImVec2 p3)
ImVec2 point = ImBezierCubicClosestPointCasteljau(p0, p1, p2, p3, g.IO.MousePos, GetStyle().CurveTessellationTol);
- if (abs(g.IO.MousePos.x - point.x) < 3 && abs(g.IO.MousePos.y - point.y) < 3 &&
- abs(p0.x - point.x) > 3 && abs(p0.y - point.y) > 3 &&
- abs(p1.x - point.x) > 3 && abs(p1.y - point.y) > 3)
+ if (ImFabs(g.IO.MousePos.x - point.x) < 3 && ImFabs(g.IO.MousePos.y - point.y) < 3 &&
+ ImFabs(p0.x - point.x) > 3 && ImFabs(p0.y - point.y) > 3 &&
+ ImFabs(p1.x - point.x) > 3 && ImFabs(p1.y - point.y) > 3)
{
hovered = true;
}
@@ -212,9 +212,9 @@ bool ImGui::LineInteractive(ImVec2 p0, ImVec2 p1)
ImVec2 point = ImLineClosestPoint(p0, p1, g.IO.MousePos);
- if (abs(g.IO.MousePos.x - point.x) < 3 && abs(g.IO.MousePos.y - point.y) < 3 &&
- abs(p0.x - point.x) > 3 && abs(p0.y - point.y) > 3 &&
- abs(p1.x - point.x) > 3 && abs(p1.y - point.y) > 3)
+ if (ImFabs(g.IO.MousePos.x - point.x) < 3 && ImFabs(g.IO.MousePos.y - point.y) < 3 &&
+ ImFabs(p0.x - point.x) > 3 && ImFabs(p0.y - point.y) > 3 &&
+ ImFabs(p1.x - point.x) > 3 && ImFabs(p1.y - point.y) > 3)
{
hovered = true;
}
diff --git a/prenderer.cpp b/prenderer.cpp
index 1fa3e71..9752663 100644
--- a/prenderer.cpp
+++ b/prenderer.cpp
@@ -494,12 +494,12 @@ AVX2_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegion)
// Preventing overlap between threads for non-packed. One nice thing
// about packed is that the 4-padded bitmap means we can set up the
// boundaries so we don't have to check this ever.
- __m256i TileBarrier = _mm256_cmp_ps(PixelX, LayerBoundsMaxX, 13);
+ __m256i TileBarrier = _mm256_cvtps_epi32(_mm256_cmp_ps(PixelX, LayerBoundsMaxX, 13));
// Zero - no points pass
// One - all points pass; not an edge
- __m256i Mask = _mm256_cmp_ps(Avg, Zero, 14);
- __m256i NonEdge = _mm256_cmp_ps(Avg, One, 13);
+ __m256i Mask = _mm256_cvtps_epi32(_mm256_cmp_ps(Avg, Zero, 14));
+ __m256i NonEdge = _mm256_cvtps_epi32(_mm256_cmp_ps(Avg, One, 13));
__m256i TotalMask = _mm256_andnot_si256(TileBarrier, _mm256_and_si256(Mask, NonEdge));
// __m256 LayerMask = _mm256_and_ps(_mm256_and_ps(_mm256_cmp_ps(U, Zero, 13), _mm256_cmp_ps(U, One, 1)),
@@ -598,7 +598,7 @@ AVX2_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegion)
// Apply anti-aliasing to edges if there are any
if (_mm256_movemask_epi8(EdgeMask))
{
- A_Col = _mm256_blendv_ps(A_Col, _mm256_mul_ps(A_Col, Avg), EdgeMask);
+ A_Col = _mm256_blendv_ps(A_Col, _mm256_mul_ps(A_Col, Avg), _mm256_cvtepi32_ps(EdgeMask));
}
IACA_END;
@@ -621,7 +621,7 @@ AVX2_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegion)
__m256 A_Blend = LayerAlpha;
// Only load the dest pixel if we actually need to (a pixel's opacity isn't 255 or the blend mode requires it).
- if (T.BlendMode != blend_normal || _mm256_movemask_epi8(_mm256_cmp_ps(LayerAlpha, One, 2)))
+ if (T.BlendMode != blend_normal || _mm256_movemask_epi8(_mm256_cvtps_epi32(_mm256_cmp_ps(LayerAlpha, One, 2))))
{
__m256i DestPixel = _mm256_loadu_si256((const __m256i *)Pixel);
__m256 R_Dest = _mm256_mul_ps(_mm256_cvtepi32_ps(_mm256_and_si256( DestPixel, FF)), Norm255);
@@ -972,7 +972,7 @@ SSE2_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegion)
__m128 B_Blend = B_Col;
__m128 A_Blend = LayerAlpha;
- if (!_mm_movemask_epi8(_mm_cmpeq_ps(LayerAlpha, One)) || T.BlendMode != blend_normal)
+ if (!_mm_movemask_epi8(_mm_cvtps_epi32(_mm_cmpeq_ps(LayerAlpha, One))) || T.BlendMode != blend_normal)
{
__m128i DestPixel = _mm_loadu_si128((const __m128i *)Pixel);
__m128 R_Dest = _mm_mul_ps(_mm_cvtepi32_ps(_mm_and_si128( DestPixel, FF)), Norm255);