Permalink
Browse files

[spline/bezier]Extract an if-check in the hot loops to the template p…

…arameter.
  • Loading branch information...
xebra committed Jul 21, 2018
1 parent 3216a83 commit 98ddefbd5a8f52f56041266313eff1cf51c82653
Showing with 4 additions and 3 deletions.
  1. +4 −3 GPU/Common/SplineCommon.cpp
@@ -340,7 +340,7 @@ class SubdivisionSurface {
defcolor = points[0]->color_32;
}
template <bool sampleNrm, bool sampleCol, bool sampleTex, bool useSSE4>
template <bool sampleNrm, bool sampleCol, bool sampleTex, bool useSSE4, bool patchFacing>
void Tessellate(SimpleVertex *vertices, u16 *indices, int &count) {
const float inv_u = 1.0f / (float)patch.tess_u;
const float inv_v = 1.0f / (float)patch.tess_v;
@@ -396,7 +396,7 @@ class SubdivisionSurface {
const Vec3f derivV = tess_pos.SampleV(wv.deriv);
vert.nrm = Cross(derivU, derivV).Normalized(useSSE4);
if (patch.patchFacing)
if (patchFacing)
vert.nrm *= -1.0f;
} else {
vert.nrm.SetZero();
@@ -414,14 +414,15 @@ class SubdivisionSurface {
void Tessellate(SimpleVertex *vertices, u16 *indices, int &count, u32 origVertType) {
using TessFunc = void(SubdivisionSurface::*)(SimpleVertex *, u16 *, int &);
constexpr int NumParams = 4;
constexpr int NumParams = 5;
static TemplateParameterDispatcherTess<TessFunc, NumParams> dispatcher; // Initialize only once
const bool params[NumParams] = {
(origVertType & GE_VTYPE_NRM_MASK) != 0,
(origVertType & GE_VTYPE_COL_MASK) != 0,
(origVertType & GE_VTYPE_TC_MASK) != 0,
cpu_info.bSSE4_1,
patch.patchFacing,
};
TessFunc func = dispatcher.GetFunc(params);
(this->*func)(vertices, indices, count);

0 comments on commit 98ddefb

Please sign in to comment.