From c1194dcb523396211368fa1d005abadae010d2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 16 Sep 2020 09:21:42 +0200 Subject: [PATCH] Help the compiler out a little bit in IndexGenerator::AddStrip. The generated code wasn't good - this helps break long register dependency chains. Speed boost is measurable but small on x86, but might be bigger on simpler CPUs. --- GPU/Common/IndexGenerator.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/GPU/Common/IndexGenerator.cpp b/GPU/Common/IndexGenerator.cpp index d339fb4790..c80a866b48 100644 --- a/GPU/Common/IndexGenerator.cpp +++ b/GPU/Common/IndexGenerator.cpp @@ -88,12 +88,22 @@ void IndexGenerator::AddStrip(int numVerts, bool clockwise) { const int numTris = numVerts - 2; u16 *outInds = inds_; int ibase = index_; - for (int i = 0; i < numTris; i++) { + size_t numPairs = numTris / 2; + while (numPairs > 0) { + *outInds++ = ibase; + *outInds++ = ibase + wind; + *outInds++ = ibase + (wind ^ 3); + *outInds++ = ibase + 1; + *outInds++ = ibase + 1 + (wind ^ 3); + *outInds++ = ibase + 1 + wind; + ibase += 2; + numPairs--; + } + if (numTris & 1) { *outInds++ = ibase; *outInds++ = ibase + wind; wind ^= 3; // toggle between 1 and 2 *outInds++ = ibase + wind; - ibase++; } inds_ = outInds; index_ += numVerts;