Render3D: Demote some functions and classes to only require AVX instead of AVX2 where appropriate.

This commit is contained in:
rogerman 2019-03-21 22:43:09 -07:00
parent 96df0343f7
commit 331cfa3596
7 changed files with 28 additions and 24 deletions

View File

@ -670,8 +670,8 @@ public:
void SetUpscalingBuffer(void *upscaleBuffer); void SetUpscalingBuffer(void *upscaleBuffer);
}; };
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
class OpenGLRenderer : public Render3D_AVX2 class OpenGLRenderer : public Render3D_AVX
#elif defined(ENABLE_SSE2) #elif defined(ENABLE_SSE2)
class OpenGLRenderer : public Render3D_SSE2 class OpenGLRenderer : public Render3D_SSE2
#elif defined(ENABLE_ALTIVEC) #elif defined(ENABLE_ALTIVEC)

View File

@ -34,7 +34,11 @@
#endif #endif
#ifdef ENABLE_SSE4_1 #ifdef ENABLE_SSE4_1
#include "smmintrin.h" #include <smmintrin.h>
#endif
#ifdef ENABLE_AVX
#include <immintrin.h>
#endif #endif
enum MatrixMode enum MatrixMode
@ -155,7 +159,7 @@ FORCEINLINE s32 sfx32_shiftdown(const s64 a)
// SIMD Functions // SIMD Functions
//------------- //-------------
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
static void memset_u16(void *dst, const u16 val, const size_t elementCount) static void memset_u16(void *dst, const u16 val, const size_t elementCount)
{ {

View File

@ -1419,8 +1419,8 @@ static void* SoftRasterizer_RunClearUsingValues(void *arg)
static Render3D* SoftRasterizerRendererCreate() static Render3D* SoftRasterizerRendererCreate()
{ {
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
return new SoftRasterizerRenderer_AVX2; return new SoftRasterizerRenderer_AVX;
#elif defined(ENABLE_SSE2) #elif defined(ENABLE_SSE2)
return new SoftRasterizerRenderer_SSE2; return new SoftRasterizerRenderer_SSE2;
#elif defined(ENABLE_ALTIVEC) #elif defined(ENABLE_ALTIVEC)
@ -1434,8 +1434,8 @@ static void SoftRasterizerRendererDestroy()
{ {
if (CurrentRenderer != BaseRenderer) if (CurrentRenderer != BaseRenderer)
{ {
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
SoftRasterizerRenderer_AVX2 *oldRenderer = (SoftRasterizerRenderer_AVX2 *)CurrentRenderer; SoftRasterizerRenderer_AVX *oldRenderer = (SoftRasterizerRenderer_AVX *)CurrentRenderer;
#elif defined(ENABLE_SSE2) #elif defined(ENABLE_SSE2)
SoftRasterizerRenderer_SSE2 *oldRenderer = (SoftRasterizerRenderer_SSE2 *)CurrentRenderer; SoftRasterizerRenderer_SSE2 *oldRenderer = (SoftRasterizerRenderer_SSE2 *)CurrentRenderer;
#elif defined(ENABLE_ALTIVEC) #elif defined(ENABLE_ALTIVEC)
@ -2492,7 +2492,7 @@ Render3DError SoftRasterizerRenderer::SetFramebufferSize(size_t w, size_t h)
return RENDER3DERROR_NOERR; return RENDER3DERROR_NOERR;
} }
#if defined(ENABLE_AVX2) || defined(ENABLE_SSE2) || defined(ENABLE_ALTIVEC) #if defined(ENABLE_AVX) || defined(ENABLE_SSE2) || defined(ENABLE_ALTIVEC)
template <size_t SIMDBYTES> template <size_t SIMDBYTES>
SoftRasterizer_SIMD<SIMDBYTES>::SoftRasterizer_SIMD() SoftRasterizer_SIMD<SIMDBYTES>::SoftRasterizer_SIMD()
@ -2604,9 +2604,9 @@ Render3DError SoftRasterizer_SIMD<SIMDBYTES>::SetFramebufferSize(size_t w, size_
#endif #endif
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
void SoftRasterizerRenderer_AVX2::LoadClearValues(const FragmentColor &clearColor6665, const FragmentAttributes &clearAttributes) void SoftRasterizerRenderer_AVX::LoadClearValues(const FragmentColor &clearColor6665, const FragmentAttributes &clearAttributes)
{ {
this->_clearColor_v256u32 = _mm256_set1_epi32(clearColor6665.color); this->_clearColor_v256u32 = _mm256_set1_epi32(clearColor6665.color);
this->_clearDepth_v256u32 = _mm256_set1_epi32(clearAttributes.depth); this->_clearDepth_v256u32 = _mm256_set1_epi32(clearAttributes.depth);
@ -2618,7 +2618,7 @@ void SoftRasterizerRenderer_AVX2::LoadClearValues(const FragmentColor &clearColo
this->_clearAttrPolyFacing_v256u8 = _mm256_set1_epi8(clearAttributes.polyFacing); this->_clearAttrPolyFacing_v256u8 = _mm256_set1_epi8(clearAttributes.polyFacing);
} }
void SoftRasterizerRenderer_AVX2::ClearUsingValues_Execute(const size_t startPixel, const size_t endPixel) void SoftRasterizerRenderer_AVX::ClearUsingValues_Execute(const size_t startPixel, const size_t endPixel)
{ {
for (size_t i = startPixel; i < endPixel; i+=32) for (size_t i = startPixel; i < endPixel; i+=32)
{ {

View File

@ -134,8 +134,8 @@ public:
template<bool SLI, bool USELINEHACK> FORCEINLINE void Render(); template<bool SLI, bool USELINEHACK> FORCEINLINE void Render();
}; };
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
class SoftRasterizerRenderer : public Render3D_AVX2 class SoftRasterizerRenderer : public Render3D_AVX
#elif defined(ENABLE_SSE2) #elif defined(ENABLE_SSE2)
class SoftRasterizerRenderer : public Render3D_SSE2 class SoftRasterizerRenderer : public Render3D_SSE2
#elif defined(ENABLE_ALTIVEC) #elif defined(ENABLE_ALTIVEC)
@ -218,7 +218,7 @@ template <size_t SIMDBYTES>
class SoftRasterizer_SIMD : public SoftRasterizerRenderer class SoftRasterizer_SIMD : public SoftRasterizerRenderer
{ {
protected: protected:
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
v256u32 _clearColor_v256u32; v256u32 _clearColor_v256u32;
v256u32 _clearDepth_v256u32; v256u32 _clearDepth_v256u32;
v256u8 _clearAttrOpaquePolyID_v256u8; v256u8 _clearAttrOpaquePolyID_v256u8;
@ -247,8 +247,8 @@ public:
virtual Render3DError SetFramebufferSize(size_t w, size_t h); virtual Render3DError SetFramebufferSize(size_t w, size_t h);
}; };
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
class SoftRasterizerRenderer_AVX2 : public SoftRasterizer_SIMD<32> class SoftRasterizerRenderer_AVX : public SoftRasterizer_SIMD<32>
{ {
protected: protected:
virtual void LoadClearValues(const FragmentColor &clearColor6665, const FragmentAttributes &clearAttributes); virtual void LoadClearValues(const FragmentColor &clearColor6665, const FragmentAttributes &clearAttributes);

View File

@ -773,10 +773,10 @@ Render3DError Render3D_SIMD<SIMDBYTES>::SetFramebufferSize(size_t w, size_t h)
return error; return error;
} }
#if defined(ENABLE_AVX2) || defined(ENABLE_SSE2) #if defined(ENABLE_AVX) || defined(ENABLE_SSE2)
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
Render3DError Render3D_AVX2::ClearFramebuffer(const GFX3D_State &renderState) Render3DError Render3D_AVX::ClearFramebuffer(const GFX3D_State &renderState)
#elif defined(ENABLE_SSE2) #elif defined(ENABLE_SSE2)
Render3DError Render3D_SSE2::ClearFramebuffer(const GFX3D_State &renderState) Render3DError Render3D_SSE2::ClearFramebuffer(const GFX3D_State &renderState)
#endif #endif
@ -974,7 +974,7 @@ Render3DError Render3D_SSE2::ClearFramebuffer(const GFX3D_State &renderState)
return error; return error;
} }
#endif // defined(ENABLE_AVX2) || defined(ENABLE_SSE2) #endif // defined(ENABLE_AVX) || defined(ENABLE_SSE2)
template Render3D_SIMD<16>::Render3D_SIMD(); template Render3D_SIMD<16>::Render3D_SIMD();
template Render3D_SIMD<32>::Render3D_SIMD(); template Render3D_SIMD<32>::Render3D_SIMD();

View File

@ -281,9 +281,9 @@ public:
virtual Render3DError SetFramebufferSize(size_t w, size_t h); virtual Render3DError SetFramebufferSize(size_t w, size_t h);
}; };
#if defined(ENABLE_AVX2) #if defined(ENABLE_AVX)
class Render3D_AVX2 : public Render3D_SIMD<32> class Render3D_AVX : public Render3D_SIMD<32>
{ {
public: public:
virtual Render3DError ClearFramebuffer(const GFX3D_State &renderState); virtual Render3DError ClearFramebuffer(const GFX3D_State &renderState);

View File

@ -245,7 +245,7 @@ typedef __m128i v128u32;
typedef __m128i v128s32; typedef __m128i v128s32;
#endif #endif
#ifdef ENABLE_AVX2 #ifdef ENABLE_AVX
#include <immintrin.h> #include <immintrin.h>
typedef __m256i v256u8; typedef __m256i v256u8;
typedef __m256i v256s8; typedef __m256i v256s8;