REVIEWED: Make sure SSE is being used when compiling with MSVC

Added log info and some formatting for visibility
This commit is contained in:
Ray
2025-10-29 11:12:04 +01:00
parent cbff0fa22c
commit f16d5ce1dd

65
src/external/rlsw.h vendored
View File

@@ -94,11 +94,9 @@
#ifndef SW_MALLOC
#define SW_MALLOC(sz) malloc(sz)
#endif
#ifndef SW_REALLOC
#define SW_REALLOC(ptr, newSz) realloc(ptr, newSz)
#endif
#ifndef SW_FREE
#define SW_FREE(ptr) free(ptr)
#endif
@@ -152,12 +150,6 @@
#define SW_CLIP_EPSILON 1e-4f
#endif
#ifdef __cplusplus
#define CURLY_INIT(name) name
#else
#define CURLY_INIT(name) (name)
#endif
//----------------------------------------------------------------------------------
// OpenGL Compatibility Types
//----------------------------------------------------------------------------------
@@ -610,9 +602,19 @@ SWAPI void swBindTexture(uint32_t id);
#define RLSW_IMPLEMENTATION
#if defined(RLSW_IMPLEMENTATION)
#include <stdlib.h>
#include <stddef.h>
#include <math.h> // Required for: floorf(), fabsf()
#include <stdlib.h> // Required for: malloc(), free()
#include <stddef.h> // Required for: NULL, size_t, uint8_t, uint16_t, uint32_t...
#include <math.h> // Required for: sinf(), cosf(), floorf(), fabsf(), sqrtf(), roundf()
// Simple log system to avoid printf() calls if required
// NOTE: Avoiding those calls, also avoids const strings memory usage
#define SW_SUPPORT_LOG_INFO
#if defined(SW_SUPPORT_LOG_INFO) //&& defined(_DEBUG) // WARNING: LOG() output required for this tool
#include <stdio.h>
#define SW_LOG(...) printf(__VA_ARGS__)
#else
#define SW_LOG(...)
#endif
#if defined(_MSC_VER)
#define SW_ALIGN(x) __declspec(align(x))
@@ -634,56 +636,47 @@ SWAPI void swBindTexture(uint32_t id);
#define SW_ARCH_RISCV
#endif
// Check for SIMD vector instructions
#if defined(__FMA__) && defined(__AVX2__)
#define SW_HAS_FMA_AVX2
#include <immintrin.h>
#endif
#if defined(__FMA__) && defined(__AVX__)
#define SW_HAS_FMA_AVX
#include <immintrin.h>
#endif
#if defined(__AVX2__)
#define SW_HAS_AVX2
#include <immintrin.h>
#endif
#if defined(__AVX__)
#define SW_HAS_AVX
#include <immintrin.h>
#endif
#if defined(__SSE4_2__)
#define SW_HAS_SSE42
#include <nmmintrin.h>
#endif
#if defined(__SSE4_1__)
#define SW_HAS_SSE41
#include <smmintrin.h>
#endif
#if defined(__SSSE3__)
#define SW_HAS_SSSE3
#include <tmmintrin.h>
#endif
#if defined(__SSE3__)
#define SW_HAS_SSE3
#include <pmmintrin.h>
#endif
#if defined(__SSE2__)
#if defined(__SSE2__) || (defined(_M_AMD64) || defined(_M_X64)) // SSE2 x64
#define SW_HAS_SSE2
#include <emmintrin.h>
#endif
#if defined(__SSE__)
#define SW_HAS_SSE
#include <xmmintrin.h>
#endif
#if defined(__ARM_NEON) || defined(__aarch64__)
#if defined(__ARM_FEATURE_FMA)
#define SW_HAS_NEON_FMA
@@ -692,12 +685,17 @@ SWAPI void swBindTexture(uint32_t id);
#endif
#include <arm_neon.h>
#endif
#ifdef __riscv_vector
#if defined(__riscv_vector)
#define SW_HAS_RVV
#include <riscv_vector.h>
#endif
#ifdef __cplusplus
#define SW_CURLY_INIT(name) name
#else
#define SW_CURLY_INIT(name) (name)
#endif
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
@@ -3608,6 +3606,23 @@ bool swInit(int w, int h)
RLSW.loadedTextureCount = 1;
SW_LOG("INFO: RLSW: Software renderer initialized successfully\n");
#if defined(SW_HAS_FMA_AVX) && defined(SW_HAS_FMA_AVX2)
SW_LOG("INFO: RLSW: Using SIMD instructions: FMA AVX\n");
#endif
#if defined(SW_HAS_AVX) || defined(SW_HAS_AVX2)
SW_LOG("INFO: RLSW: Using SIMD instructions: AVX\n");
#endif
#if defined(SW_HAS_SSE) || defined(SW_HAS_SSE2) || defined(SW_HAS_SSE3) || defined(SW_HAS_SSE41) || defined(SW_HAS_SSE42)
SW_LOG("INFO: RLSW: Using SIMD instructions: SSE\n");
#endif
#if defined(SW_HAS_NEON_FMA) || defined(SW_HAS_NEON)
SW_LOG("INFO: RLSW: Using SIMD instructions: NEON\n");
#endif
#if defined(SW_HAS_RVV)
SW_LOG("INFO: RLSW: Using SIMD instructions: RVV\n");
#endif
return true;
}
@@ -3626,7 +3641,7 @@ void swClose(void)
SW_FREE(RLSW.loadedTextures);
SW_FREE(RLSW.freeTextureIds);
RLSW = CURLY_INIT(sw_context_t) { 0 };
RLSW = SW_CURLY_INIT(sw_context_t) { 0 };
}
bool swResizeFramebuffer(int w, int h)