From 0c9680446ebfd48ffce5038ba8b4bb7bb518366a Mon Sep 17 00:00:00 2001 From: xebra Date: Wed, 31 Jan 2018 20:25:07 +0900 Subject: [PATCH] [spline/bezier]minor fix --- GPU/Common/SplineCommon.cpp | 64 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/GPU/Common/SplineCommon.cpp b/GPU/Common/SplineCommon.cpp index 4ce467430b..91219e759e 100644 --- a/GPU/Common/SplineCommon.cpp +++ b/GPU/Common/SplineCommon.cpp @@ -109,6 +109,38 @@ struct KnotDiv { float _3_2 = 1.0f; // Always 1 }; +// knot should be an array sized n + 5 (n + 1 + 1 + degree (cubic)) +static void spline_knot(int n, int type, float *knots, KnotDiv *divs) { + // Basic theory (-2 to +3), optimized with KnotDiv (-2 to +0) +// for (int i = 0; i < n + 5; ++i) { + for (int i = 0; i < n + 2; ++i) { + knots[i] = (float)i - 2; + } + + // The first edge is open + if ((type & 1) != 0) { + knots[0] = 0; + knots[1] = 0; + + divs[0]._3_0 = 1.0f; + divs[0]._4_1 = 1.0f / 2.0f; + divs[0]._3_1 = 1.0f; + if (n > 1) + divs[1]._3_0 = 1.0f / 2.0f; + } + // The last edge is open + if ((type & 2) != 0) { + // knots[n + 2] = (float)n; // Got rid of this line optimized with KnotDiv + // knots[n + 3] = (float)n; // Got rid of this line optimized with KnotDiv + // knots[n + 4] = (float)n; // Got rid of this line optimized with KnotDiv + divs[n - 1]._4_1 = 1.0f / 2.0f; + divs[n - 1]._5_2 = 1.0f; + divs[n - 1]._4_2 = 1.0f; + if (n > 1) + divs[n - 2]._5_2 = 1.0f / 2.0f; + } +} + static void spline_n_4(float t, float *knot, const KnotDiv &div, float *splineVal, float *derivs) { #ifdef _M_SSE const __m128 knot012 = _mm_loadu_ps(knot); @@ -173,38 +205,6 @@ static void spline_n_4(float t, float *knot, const KnotDiv &div, float *splineVa derivs[3] = 3 * (f352 - 0); } -// knot should be an array sized n + 5 (n + 1 + 1 + degree (cubic)) -static void spline_knot(int n, int type, float *knots, KnotDiv *divs) { - // Basic theory (-2 to +3), optimized with KnotDiv (-2 to +0) -// for (int i = 0; i < n + 5; ++i) { - for (int i = 0; i < n + 2; ++i) { - knots[i] = (float)i - 2; - } - - // The first edge is open - if ((type & 1) != 0) { - knots[0] = 0; - knots[1] = 0; - - divs[0]._3_0 = 1.0f; - divs[0]._4_1 = 1.0f / 2.0f; - divs[0]._3_1 = 1.0f; - if (n > 1) - divs[1]._3_0 = 1.0f / 2.0f; - } - // The last edge is open - if ((type & 2) != 0) { - // knots[n + 2] = (float)n; // Got rid of this line optimized with KnotDiv - // knots[n + 3] = (float)n; // Got rid of this line optimized with KnotDiv - // knots[n + 4] = (float)n; // Got rid of this line optimized with KnotDiv - divs[n - 1]._4_1 = 1.0f / 2.0f; - divs[n - 1]._5_2 = 1.0f; - divs[n - 1]._4_2 = 1.0f; - if (n > 1) - divs[n - 2]._5_2 = 1.0f / 2.0f; - } -} - bool CanUseHardwareTessellation(GEPatchPrimType prim) { if (g_Config.bHardwareTessellation && !g_Config.bSoftwareRendering) { return CanUseHardwareTransform(PatchPrimToPrim(prim));