Remove SSE detection duplication in Colors and ModelRenderer

- Rename macros to be more explicit
 - Move detection code to a separate file
 - Remove a lot of checks in ARB mode (ModelDef.cpp would check for sse
multiple times per frame)
 - Make explicit the SSE2 dependency for Windows

Comments by: @vladislavbelov @wraitii @OptimusShepard
Differential Revision: https://code.wildfiregames.com/D3212
This was SVN commit r24489.
This commit is contained in:
Stan
2020-12-31 15:37:28 +00:00
parent e009d322cc
commit d28d17e96c
10 changed files with 143 additions and 66 deletions
+27 -5
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2015 Wildfire Games.
/* Copyright (C) 2020 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -23,10 +23,11 @@
#include "ModelDef.h"
#include "graphics/SkeletonAnimDef.h"
#include "lib/sse.h"
#include "ps/FileIo.h"
#include "maths/Vector4D.h"
#if HAVE_SSE
#if COMPILER_HAS_SSE
# include <xmmintrin.h>
#endif
@@ -87,7 +88,16 @@ CVector3D CModelDef::SkinNormal(const SModelVertex& vtx,
return result;
}
void CModelDef::SkinPointsAndNormals(
void(*CModelDef::SkinPointsAndNormals)(
size_t numVertices,
const VertexArrayIterator<CVector3D>& Position,
const VertexArrayIterator<CVector3D>& Normal,
const SModelVertex* vertices,
const size_t* blendIndices,
const CMatrix3D newPoseMatrices[]) {};
static void SkinPointsAndNormalsFallback(
size_t numVertices,
const VertexArrayIterator<CVector3D>& Position,
const VertexArrayIterator<CVector3D>& Normal,
@@ -121,8 +131,8 @@ void CModelDef::SkinPointsAndNormals(
}
}
#if HAVE_SSE
void CModelDef::SkinPointsAndNormals_SSE(
#if COMPILER_HAS_SSE
static void SkinPointsAndNormalsSSE(
size_t numVertices,
const VertexArrayIterator<CVector3D>& Position,
const VertexArrayIterator<CVector3D>& Normal,
@@ -471,3 +481,15 @@ CModelDefRPrivate* CModelDef::GetRenderData(const void* key) const
return 0;
}
void ModelDefActivateFastImpl()
{
#if COMPILER_HAS_SSE
if (HostHasSSE())
{
CModelDef::SkinPointsAndNormals = SkinPointsAndNormalsSSE;
return;
}
#endif
CModelDef::SkinPointsAndNormals = SkinPointsAndNormalsFallback;
}