SDL: Relocate intrinsic modules to src/video/

From 735cf5a6f9301b19fff8b22006457a1f32421d54 Mon Sep 17 00:00:00 2001
From: Isaac Aronson <[EMAIL REDACTED]>
Date: Tue, 5 Sep 2023 23:48:52 -0500
Subject: [PATCH] Relocate intrinsic modules to src/video/

---
 CMakeLists.txt                                   | 11 ++++++++---
 VisualC-GDK/SDL/SDL.vcxproj                      |  8 ++++----
 VisualC-GDK/SDL/SDL.vcxproj.filters              |  8 ++++----
 VisualC/SDL/SDL.vcxproj                          |  6 ++++--
 VisualC/SDL/SDL.vcxproj.filters                  | 16 ++++++++--------
 src/video/SDL_blit_A.c                           |  4 ++--
 src/video/{intrin => }/SDL_blit_A_avx2.c         |  4 ++--
 src/video/{intrin => }/SDL_blit_A_avx2.h         |  0
 src/video/{intrin => }/SDL_blit_A_sse4_1.c       |  2 +-
 .../SDL_blit_A_sse4.1.h => SDL_blit_A_sse4_1.h}  |  0
 10 files changed, 33 insertions(+), 26 deletions(-)
 rename src/video/{intrin => }/SDL_blit_A_avx2.c (98%)
 rename src/video/{intrin => }/SDL_blit_A_avx2.h (100%)
 rename src/video/{intrin => }/SDL_blit_A_sse4_1.c (99%)
 rename src/video/{intrin/SDL_blit_A_sse4.1.h => SDL_blit_A_sse4_1.h} (100%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f5fa4e2c4d7c6..27223d7f66d10 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -498,7 +498,6 @@ sdl_glob_sources(
   "${SDL3_SOURCE_DIR}/src/thread/*.c"
   "${SDL3_SOURCE_DIR}/src/time/*.c"
   "${SDL3_SOURCE_DIR}/src/timer/*.c"
-  "${SDL3_SOURCE_DIR}/src/video/*.c"
   "${SDL3_SOURCE_DIR}/src/video/yuv2rgb/*.c"
 )
 if(MSVC AND TARGET SDL3-shared)
@@ -514,6 +513,12 @@ if(MSVC AND TARGET SDL3-shared)
   endif()
 endif()
 
+# Exclude intrinsinc modules from general builds
+file(GLOB video_sources "${SDL3_SOURCE_DIR}/src/video/*.c")
+list(FILTER video_sources EXCLUDE REGEX "SDL_blit_A_avx2.c$")
+list(FILTER video_sources EXCLUDE REGEX "SDL_blit_A_sse4_1.c$")
+sdl_glob_sources(${video_sources})
+
 if(USE_INTELCC)
   # warning #39: division by zero
   # warning #239: floating point underflow
@@ -739,7 +744,7 @@ if(SDL_ASSEMBLY)
     cmake_pop_check_state()
     if(COMPILER_SUPPORTS_SSE4_1)
       set(HAVE_SSE4_1 TRUE)
-      sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/intrin/SDL_blit_A_sse4_1.c")
+      sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/SDL_blit_A_sse4_1.c")
     endif()
   endif()
   if(SDL_SSE4_2)
@@ -803,7 +808,7 @@ if(SDL_ASSEMBLY)
         return 0;
       }" COMPILER_SUPPORTS_AVX2)
     cmake_pop_check_state()
-    sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/intrin/SDL_blit_A_*.c")
+    sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/SDL_blit_A_*.c")
     if(COMPILER_SUPPORTS_AVX2)
       set(HAVE_AVX2 TRUE)
     endif()
diff --git a/VisualC-GDK/SDL/SDL.vcxproj b/VisualC-GDK/SDL/SDL.vcxproj
index 6c47cbaf10f26..28c678bb5218f 100644
--- a/VisualC-GDK/SDL/SDL.vcxproj
+++ b/VisualC-GDK/SDL/SDL.vcxproj
@@ -529,8 +529,6 @@
     <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h" />
     <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h" />
     <ClInclude Include="..\..\src\video\gdk\SDL_gdktextinput.h" />
-    <ClInclude Include="..\..\src\video\intrin\SDL_blit_A_avx2.h" />
-    <ClInclude Include="..\..\src\video\intrin\SDL_blit_A_sse4.1.h" />
     <ClInclude Include="..\..\src\video\khronos\vulkan\vk_icd.h" />
     <ClInclude Include="..\..\src\video\khronos\vulkan\vk_layer.h" />
     <ClInclude Include="..\..\src\video\khronos\vulkan\vk_platform.h" />
@@ -553,6 +551,8 @@
     <ClInclude Include="..\..\src\video\khronos\vulkan\vulkan_xlib_xrandr.h" />
     <ClInclude Include="..\..\src\video\SDL_blit.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_auto.h" />
+    <ClInclude Include="..\..\src\video\SDL_blit_A_avx2.h" />
+    <ClInclude Include="..\..\src\video\SDL_blit_A_sse4_1.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
     <ClInclude Include="..\..\src\video\SDL_clipboard_c.h" />
@@ -819,13 +819,13 @@
       <PrecompiledHeaderOutputFile Condition="'$(Configuration)|$(Platform)'=='Debug|Gaming.Desktop.x64'">$(IntDir)$(TargetName)_cpp.pch</PrecompiledHeaderOutputFile>
       <PrecompiledHeaderOutputFile Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Desktop.x64'">$(IntDir)$(TargetName)_cpp.pch</PrecompiledHeaderOutputFile>
     </ClCompile>
-    <ClCompile Include="..\..\src\video\intrin\SDL_blit_A_avx2.c" />
-    <ClCompile Include="..\..\src\video\intrin\SDL_blit_A_sse4_1.c" />
     <ClCompile Include="..\..\src\video\SDL_blit.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_0.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_1.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_A.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_auto.c" />
+    <ClCompile Include="..\..\src\video\SDL_blit_A_avx2.c" />
+    <ClCompile Include="..\..\src\video\SDL_blit_A_sse4_1.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_copy.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_N.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_slow.c" />
diff --git a/VisualC-GDK/SDL/SDL.vcxproj.filters b/VisualC-GDK/SDL/SDL.vcxproj.filters
index 873aa2e51f38c..06543fe5df551 100644
--- a/VisualC-GDK/SDL/SDL.vcxproj.filters
+++ b/VisualC-GDK/SDL/SDL.vcxproj.filters
@@ -458,11 +458,11 @@
     <ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h" />
     <ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb_sse_func.h" />
     <ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb_std_func.h" />
-    <ClCompile Include="..\..\src\video\intrin\SDL_blit_A_avx2.c">
-      <Filter>video\intrin</Filter>
+    <ClCompile Include="..\..\src\video\SDL_blit_A_avx2.c">
+      <Filter>video</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\src\video\intrin\SDL_blit_A_sse4_1.c">
-      <Filter>video\intrin</Filter>
+    <ClCompile Include="..\..\src\video\SDL_blit_A_sse4_1.c">
+      <Filter>video</Filter>
     </ClCompile>
   </ItemGroup>
   <ItemGroup>
diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj
index 914895231d951..be171d4b3e3d2 100644
--- a/VisualC/SDL/SDL.vcxproj
+++ b/VisualC/SDL/SDL.vcxproj
@@ -429,8 +429,6 @@
     <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h" />
     <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h" />
     <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h" />
-    <ClInclude Include="..\..\src\video\intrin\SDL_blit_A_avx2.h" />
-    <ClInclude Include="..\..\src\video\intrin\SDL_blit_A_sse4.1.h" />
     <ClInclude Include="..\..\src\video\khronos\vulkan\vk_icd.h" />
     <ClInclude Include="..\..\src\video\khronos\vulkan\vk_layer.h" />
     <ClInclude Include="..\..\src\video\khronos\vulkan\vk_platform.h" />
@@ -459,6 +457,8 @@
     <ClInclude Include="..\..\src\video\offscreen\SDL_offscreenwindow.h" />
     <ClInclude Include="..\..\src\video\SDL_blit.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_auto.h" />
+    <ClInclude Include="..\..\src\video\SDL_blit_A_avx2.h" />
+    <ClInclude Include="..\..\src\video\SDL_blit_A_sse4_1.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
     <ClInclude Include="..\..\src\video\SDL_clipboard_c.h" />
@@ -684,6 +684,8 @@
     <ClCompile Include="..\..\src\video\SDL_blit_1.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_A.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_auto.c" />
+    <ClCompile Include="..\..\src\video\SDL_blit_A_avx2.c" />
+    <ClCompile Include="..\..\src\video\SDL_blit_A_sse4_1.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_copy.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_N.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_slow.c" />
diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters
index 82944ba417c0f..5d10b7e74f6c5 100644
--- a/VisualC/SDL/SDL.vcxproj.filters
+++ b/VisualC/SDL/SDL.vcxproj.filters
@@ -871,11 +871,11 @@
     </ClInclude>
     <ClInclude Include="..\..\src\hidapi\SDL_hidapi_c.h" />
     <ClInclude Include="..\..\src\thread\generic\SDL_sysrwlock_c.h" />
-    <ClInclude Include="..\..\src\video\intrin\SDL_blit_A_avx2.h">
-      <Filter>video\intrin</Filter>
+    <ClInclude Include="..\..\src\video\SDL_blit_A_avx2.h">
+      <Filter>video</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\video\intrin\SDL_blit_A_sse4.1.h">
-      <Filter>video\intrin</Filter>
+    <ClInclude Include="..\..\src\video\SDL_blit_A_sse4_1.h">
+      <Filter>video</Filter>
     </ClInclude>
     <ClInclude Include="..\..\src\thread\generic\SDL_sysrwlock_c.h" />
     <ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb_common.h" />
@@ -1525,11 +1525,11 @@
       <Filter>stdlib</Filter>
     </ClCompile>
     <ClCompile Include="..\..\src\thread\generic\SDL_sysrwlock.c" />
-    <ClCompile Include="..\..\src\video\intrin\SDL_blit_A_avx2.c">
-      <Filter>video\intrin</Filter>
+    <ClCompile Include="..\..\src\video\SDL_blit_A_avx2.c">
+      <Filter>video</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\src\video\intrin\SDL_blit_A_sse4_1.c">
-      <Filter>video\intrin</Filter>
+    <ClCompile Include="..\..\src\video\SDL_blit_A_sse4_1.c">
+      <Filter>video</Filter>
     </ClCompile>
     <ClCompile Include="..\..\src\thread\generic\SDL_sysrwlock.c" />
     <ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb_lsx.c" />
diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c
index 7a5757100e399..6fb762d7750a6 100644
--- a/src/video/SDL_blit_A.c
+++ b/src/video/SDL_blit_A.c
@@ -25,10 +25,10 @@
 #include "SDL_blit.h"
 
 #ifdef SDL_SSE4_1_INTRINSICS
-#include "intrin/SDL_blit_A_sse4.1.h"
+#include "SDL_blit_A_sse4_1.h"
 #endif
 #ifdef SDL_AVX2_INTRINSICS
-#include "intrin/SDL_blit_A_avx2.h"
+#include "SDL_blit_A_avx2.h"
 #endif
 #if defined(SDL_SSE4_1_INTRINSICS) || defined(SDL_AVX2_INTRINSICS)
 #include "SDL3/SDL_cpuinfo.h"
diff --git a/src/video/intrin/SDL_blit_A_avx2.c b/src/video/SDL_blit_A_avx2.c
similarity index 98%
rename from src/video/intrin/SDL_blit_A_avx2.c
rename to src/video/SDL_blit_A_avx2.c
index e9ebaa994ae99..ccb65f783e56e 100644
--- a/src/video/intrin/SDL_blit_A_avx2.c
+++ b/src/video/SDL_blit_A_avx2.c
@@ -4,8 +4,8 @@
 
 #ifdef SDL_AVX2_INTRINSICS
 
-#include "../SDL_blit.h"
-#include "SDL_blit_A_sse4.1.h"
+#include "SDL_blit.h"
+#include "SDL_blit_A_sse4_1.h"
 
 #if !defined(_MSC_VER) || (defined(_MSC_VER) && defined(__clang__))
 __attribute__((target("avx2")))
diff --git a/src/video/intrin/SDL_blit_A_avx2.h b/src/video/SDL_blit_A_avx2.h
similarity index 100%
rename from src/video/intrin/SDL_blit_A_avx2.h
rename to src/video/SDL_blit_A_avx2.h
diff --git a/src/video/intrin/SDL_blit_A_sse4_1.c b/src/video/SDL_blit_A_sse4_1.c
similarity index 99%
rename from src/video/intrin/SDL_blit_A_sse4_1.c
rename to src/video/SDL_blit_A_sse4_1.c
index 2e7d9139162da..3cc852e5da44a 100644
--- a/src/video/intrin/SDL_blit_A_sse4_1.c
+++ b/src/video/SDL_blit_A_sse4_1.c
@@ -4,7 +4,7 @@
 
 #ifdef SDL_SSE4_1_INTRINSICS
 
-#include "../SDL_blit.h"
+#include "SDL_blit.h"
 
 #if !defined(_MSC_VER) || (defined(_MSC_VER) && defined(__clang__))
 __attribute__((target("sse4.1")))
diff --git a/src/video/intrin/SDL_blit_A_sse4.1.h b/src/video/SDL_blit_A_sse4_1.h
similarity index 100%
rename from src/video/intrin/SDL_blit_A_sse4.1.h
rename to src/video/SDL_blit_A_sse4_1.h