diff --git a/Builds/MSVC/Installer/Product.wxs b/Builds/MSVC/Installer/Product.wxs index 7ce8000..03436ff 100644 --- a/Builds/MSVC/Installer/Product.wxs +++ b/Builds/MSVC/Installer/Product.wxs @@ -13,7 +13,7 @@ - + -/// Search the xforms, excluding final, to find which one's address matches the address of the specified xform. -/// -/// A pointer to the xform to find -/// The index of the matched xform if found, else -1. + /// + /// Search the xforms, excluding final, to find which one's address matches the address of the specified xform. + /// + /// A pointer to the xform to find + /// The index of the matched xform if found, else -1. intmax_t GetXformIndex(Xform* xform) const { intmax_t index = -1; diff --git a/Source/Ember/PaletteList.cpp b/Source/Ember/PaletteList.cpp index 0d6d994..3a8d85c 100644 --- a/Source/Ember/PaletteList.cpp +++ b/Source/Ember/PaletteList.cpp @@ -547,7 +547,7 @@ bool PaletteList::Save(const string& filename) os << " source_colors=\""; for (auto& sc : pal.m_SourceColors)//Need to clamp these each from 0 to 1. Use our custom clamp funcs.//TODO - os << sc.first << "," << sc.second.r << "," << sc.second.g << "," << sc.second.b << " "; + os << Clamp(sc.first, 0, 1) << "," << Clamp(sc.second.r, 0, 1) << "," << Clamp(sc.second.g, 0, 1) << "," << Clamp(sc.second.b, 0, 1) << " "; os << "\""; } diff --git a/Source/Ember/Renderer.cpp b/Source/Ember/Renderer.cpp index 3241e73..9d6cadd 100644 --- a/Source/Ember/Renderer.cpp +++ b/Source/Ember/Renderer.cpp @@ -12,6 +12,11 @@ Renderer::Renderer() //Use a very large number regardless of the size of the output pixels. This should be sufficient granularity, even though //it's technically less than the number of distinct values representable by a 32-bit float. m_Csa.resize(size_t(CURVES_LENGTH)); + //Ensure the renderer at least has sane values for the camera upon startup. + //This is needed because due to timing/threading disconnects, the GUI can use the camera + //values before the render has started, which will lead to corrupt values. + Ember ember; + SetEmber(ember, eProcessAction::NOTHING, true); } /// diff --git a/Source/Ember/Variations01.h b/Source/Ember/Variations01.h index c5d1ad6..eb73a98 100644 --- a/Source/Ember/Variations01.h +++ b/Source/Ember/Variations01.h @@ -160,8 +160,8 @@ public: << "\t\treal_t c1 = sin(precalcSumSquares);\n" << "\t\treal_t c2 = cos(precalcSumSquares);\n" << "\n" - << "\t\tvOut.x = " << weight << " * (c1 * vIn.x - c2 * vIn.y);\n" - << "\t\tvOut.y = " << weight << " * (c2 * vIn.x + c1 * vIn.y);\n" + << "\t\tvOut.x = " << weight << " * fma(c1, vIn.x, -(c2 * vIn.y));\n" + << "\t\tvOut.y = " << weight << " * fma(c2, vIn.x, c1 * vIn.y);\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t}\n"; return ss.str(); @@ -711,8 +711,8 @@ public: ss << "\t{\n" << "\t\treal_t c10 = xform->m_B;\n" << "\t\treal_t c11 = xform->m_E;\n" - << "\t\treal_t nx = vIn.x + c10 * sin(vIn.y * " << dx2 << ");\n" - << "\t\treal_t ny = vIn.y + c11 * sin(vIn.x * " << dy2 << ");\n" + << "\t\treal_t nx = fma(c10, sin(vIn.y * " << dx2 << "), vIn.x);\n" + << "\t\treal_t ny = fma(c11, sin(vIn.x * " << dy2 << "), vIn.y);\n" << "\n" << "\t\tvOut.x = (" << weight << " * nx);\n" << "\t\tvOut.y = (" << weight << " * ny);\n" @@ -824,8 +824,8 @@ public: ss << "\t{\n" << "\t\treal_t dx = tan(3 * vIn.y);\n" << "\t\treal_t dy = tan(3 * vIn.x);\n" - << "\t\treal_t nx = vIn.x + xform->m_C * sin(dx);\n" - << "\t\treal_t ny = vIn.y + xform->m_F * sin(dy);\n" + << "\t\treal_t nx = fma(xform->m_C, sin(dx), vIn.x);\n" + << "\t\treal_t ny = fma(xform->m_F, sin(dy), vIn.y);\n" << "\n" << "\t\tvOut.x = " << weight << " * nx;\n" << "\t\tvOut.y = " << weight << " * ny;\n" @@ -1003,7 +1003,7 @@ public: << "\t\treal_t dx = Zeps(xform->m_C * xform->m_C);\n" << "\t\treal_t r = precalcSqrtSumSquares;\n" << "\n" - << "\t\tr = " << weight << " * (fmod(r + dx, 2 * dx) - dx + r * (1 - dx));\n" + << "\t\tr = " << weight << " * (fmod(r + dx, 2 * dx) + fma(r, (1 - dx), -dx));\n" << "\t\tvOut.x = r * precalcCosa;\n" << "\t\tvOut.y = r * precalcSina;\n" << "\t\tvOut.z = " << DefaultZCl() @@ -1119,10 +1119,10 @@ public: string blobWaves = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string blobDiff = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t r = precalcSqrtSumSquares * (" << blobLow << " + " << blobDiff << " * ((real_t)(0.5) + (real_t)(0.5) * sin(" << blobWaves << " * precalcAtanxy)));\n" + << "\t\treal_t r = precalcSqrtSumSquares * fma(" << blobDiff << ", fma((real_t)(0.5), sin(" << blobWaves << " * precalcAtanxy), (real_t)(0.5)), " << blobLow << ");\n" << "\n" - << "\t\tvOut.x = (" << weight << " * precalcSina * r);\n" - << "\t\tvOut.y = (" << weight << " * precalcCosa * r);\n" + << "\t\tvOut.x = " << weight << " * precalcSina * r;\n" + << "\t\tvOut.y = " << weight << " * precalcCosa * r;\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -1389,7 +1389,8 @@ public: ss << "\t{\n" << "\t\treal_t r = precalcSqrtSumSquares;\n" << "\n" - << "\t\tr += -(real_t)(2.0) * " << rings2Val2 << " * (int)((r + " << rings2Val2 << ") / ((real_t)(2.0) * " << rings2Val2 << ")) + r * ((real_t)(1.0) - " << rings2Val2 << ");\n" + << "\t\tr += fma(-(real_t)(2.0) * " << rings2Val2 << ", (real_t)(int)((r + " << rings2Val2 << ") / ((real_t)(2.0) * " << rings2Val2 << ")), r * ((real_t)(1.0) - " << rings2Val2 << "));\n" + //<< "\t\tr += -(real_t)(2.0) * " << rings2Val2 << " * (int)((r + " << rings2Val2 << ") / ((real_t)(2.0) * " << rings2Val2 << ")) + r * ((real_t)(1.0) - " << rings2Val2 << ");\n" << "\t\tvOut.x = (" << weight << " * precalcSina * r);\n" << "\t\tvOut.y = (" << weight << " * precalcCosa * r);\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" @@ -1485,7 +1486,7 @@ public: string weight = WeightDefineString(); intmax_t varIndex = IndexInXform(); ss << "\t{\n" - << "\t\treal_t denom = (real_t)(0.25) * precalcSumSquares + 1;\n" + << "\t\treal_t denom = fma((real_t)(0.25), precalcSumSquares, (real_t)(1.0));\n" << "\t\treal_t r = " << weight << " / denom;\n" << "\n" << "\t\tvOut.x = r * vIn.x;\n" @@ -1681,13 +1682,13 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params. + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params. string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tint tRnd = (int)(" << rn << " * MwcNext01(mwc));\n" - << "\t\treal_t tempr = (precalcAtanyx + M_2PI * tRnd) / " << power << ";\n" + << "\t\treal_t tempr = fma(M_2PI, (real_t)tRnd, precalcAtanyx) / " << power << ";\n" << "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cn << ");\n" << "\n" << "\t\tvOut.x = r * cos(tempr);\n" @@ -1773,18 +1774,18 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params. + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params. string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tint rnd = (int)(" << rn << " * MwcNext01(mwc));\n" << "\t\treal_t tempr, r;\n" << "\n" << "\t\tif ((rnd & 1) == 0)\n" - << "\t\t tempr = (M_2PI * rnd + precalcAtanyx) / " << power << ";\n" + << "\t\t tempr = fma(M_2PI, (real_t)rnd, precalcAtanyx) / " << power << ";\n" << "\t\telse\n" - << "\t\t tempr = (M_2PI * rnd - precalcAtanyx) / " << power << ";\n" + << "\t\t tempr = fma(M_2PI, (real_t)rnd, -precalcAtanyx) / " << power << ";\n" << "\n" << "\t\tr = " << weight << " * pow(precalcSumSquares, " << cn << ");\n" << "\n" @@ -1958,11 +1959,11 @@ public: ss << "\t{\n" << "\t\treal_t rndG = " << weight << " * (MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) - (real_t)(2.0));\n" << "\t\treal_t ra = precalcSqrtSumSquares;\n" - << "\t\treal_t tempa = precalcAtanyx + " << spin << " * rndG;\n" - << "\t\treal_t rz = " << zoom << " * rndG - 1;\n" + << "\t\treal_t tempa = fma(" << spin << ", rndG, precalcAtanyx);\n" + << "\t\treal_t rz = fma(" << zoom << ", rndG, -1.0);\n" << "\n" - << "\t\tvOut.x = ra * cos(tempa) + rz * vIn.x;\n" - << "\t\tvOut.y = ra * sin(tempa) + rz * vIn.y;\n" + << "\t\tvOut.x = fma(ra, cos(tempa), rz * vIn.x);\n" + << "\t\tvOut.y = fma(ra, sin(tempa), rz * vIn.y);\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t}\n"; return ss.str(); @@ -2030,8 +2031,8 @@ public: string thickness = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string pi2Slices = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\tint sl = (int)(MwcNext01(mwc) * " << slices << " + (real_t)(0.5));\n" - << "\t\treal_t a = " << rotation << " + " << pi2Slices << " * (sl + " << thickness << " * MwcNext01(mwc));\n" + << "\t\tint sl = (int)(fma(MwcNext01(mwc), " << slices << ", (real_t)(0.5)));\n" + << "\t\treal_t a = fma(" << pi2Slices << ", fma(" << thickness << ", MwcNext01(mwc), sl), " << rotation << ");\n" << "\t\treal_t r = " << weight << " * MwcNext01(mwc);\n" << "\n" << "\t\tvOut.x = r * cos(a);\n" @@ -2112,13 +2113,13 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string sides = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string circle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string corners = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string csides = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sides = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string circle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string corners = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string csides = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string csidesinv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cpower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cpower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t rFactor;\n" << "\n" @@ -2132,7 +2133,7 @@ public: << "\t\tif (phi > (real_t)(0.5) * " << csides << ")\n" << "\t\t phi -= " << csides << ";\n" << "\n" - << "\t\treal_t amp = (" << corners << " * (1 / cos(phi) - 1) + " << circle << ") * " << weight << " * rFactor;\n" + << "\t\treal_t amp = fma(" << corners << ", (1 / cos(phi) - 1), " << circle << ") * " << weight << " * rFactor;\n" << "\n" << "\t\tvOut.x = amp * vIn.x;\n" << "\t\tvOut.y = amp * vIn.y;\n" @@ -2218,12 +2219,12 @@ public: string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c22 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t re = (real_t)(1.0) + " << c1 << " * vIn.x + " << c2 << " * (SQR(vIn.x) - SQR(vIn.y));\n" - << "\t\treal_t im = " << c1 << " * vIn.y + " << c22 << " * vIn.x * vIn.y;\n" - << "\t\treal_t r = " << weight << " / Zeps(SQR(re) + SQR(im));\n" + << "\t\treal_t re = (real_t)(1.0) + " << c1 << " * vIn.x + " << c2 << " * fma(vIn.x, vIn.x, -SQR(vIn.y));\n" + << "\t\treal_t im = fma(" << c1 << ", vIn.y, " << c22 << " * vIn.x * vIn.y);\n" + << "\t\treal_t r = " << weight << " / Zeps(fma(re, re, SQR(im)));\n" << "\n" - << "\t\tvOut.x = (vIn.x * re + vIn.y * im) * r;\n" - << "\t\tvOut.y = (vIn.y * re - vIn.x * im) * r;\n" + << "\t\tvOut.x = fma(vIn.x, re, vIn.y * im) * r;\n" + << "\t\tvOut.y = fma(vIn.y, re, -(vIn.x * im)) * r;\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -2303,12 +2304,12 @@ public: << "\t\tif (" << x << " == 0)\n" << "\t\t vOut.x = " << weight << " * vIn.x;\n" << "\t\telse\n" - << "\t\t vOut.x = (" << weight << " * ((2 * floor(vIn.x / " << x << ") + 1) * " << x << " - vIn.x));\n" + << "\t\t vOut.x = " << weight << " * fma(fma((real_t)(2.0), floor(vIn.x / " << x << "), 1), " << x << ", -vIn.x);\n" << "\n" << "\t\tif (" << y << " == 0)\n" << "\t\t vOut.y = " << weight << " * vIn.y;\n" << "\t\telse\n" - << "\t\t vOut.y = (" << weight << " * ((2 * floor(vIn.y / " << y << ") + 1) * " << y << " - vIn.y));\n" + << "\t\t vOut.y = " << weight << " * fma(fma((real_t)(2.0), floor(vIn.y / " << y << "), 1), " << y << ", -vIn.y);\n" << "\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t}\n"; @@ -2511,7 +2512,7 @@ public: string weight = WeightDefineString(); intmax_t varIndex = IndexInXform(); ss << "\t{\n" - << "\t\treal_t u = 1 / Zeps(tan(precalcSqrtSumSquares)) + (" << weight << " * SQR(M_2_PI));\n"; + << "\t\treal_t u = fma(" << weight << ", SQR(M_2_PI), 1 / Zeps(tan(precalcSqrtSumSquares)));\n"; if (m_VarType == eVariationType::VARTYPE_REG) ss << "\t\toutPoint->m_X = outPoint->m_Y = 0;\n"; @@ -2732,7 +2733,7 @@ public: T r = rand.Frand01() * m_Weight * helper.m_PrecalcSqrtSumSquares; T sinr, cosr, diff; sincos(r, &sinr, &cosr); - diff = std::log10(sinr * sinr) + cosr; + diff = std::log10(SQR(sinr)) + cosr; if (BadVal(diff)) diff = -30.0; @@ -2751,7 +2752,7 @@ public: << "\t\treal_t r = MwcNext01(mwc) * " << weight << " * precalcSqrtSumSquares;\n" << "\t\treal_t sinr = sin(r);\n" << "\t\treal_t cosr = cos(r);\n" - << "\t\treal_t diff = log10(sinr * sinr) + cosr;\n" + << "\t\treal_t diff = log10(SQR(sinr)) + cosr;\n" << "\n" << "\t\tif (BadVal(diff))\n" << "\t\t diff = -(real_t)(30.0);\n" @@ -2937,13 +2938,13 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string m = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params. - string n1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rnd = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string holes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string pm4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. + string m = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params. + string n1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rnd = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string holes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pm4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. string pNeg1N1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t theta = " << pm4 << " * precalcAtanyx + MPI4;\n" @@ -2951,7 +2952,7 @@ public: << "\t\tt1 = pow(t1, " << n2 << ");\n" << "\t\treal_t t2 = fabs(sin(theta));\n" << "\t\tt2 = pow(t2, " << n3 << ");\n" - << "\t\treal_t r = " << weight << " * ((" << rnd << " * MwcNext01(mwc) + ((real_t)(1.0) - " << rnd << ") * precalcSqrtSumSquares) - " << holes << ") * pow(t1 + t2, " << pNeg1N1 << ") / precalcSqrtSumSquares;\n" + << "\t\treal_t r = " << weight << " * (fma(" << rnd << ", MwcNext01(mwc), ((real_t)(1.0) - " << rnd << ") * precalcSqrtSumSquares) - " << holes << ") * pow(t1 + t2, " << pNeg1N1 << ") / precalcSqrtSumSquares;\n" << "\n" << "\t\tvOut.x = r * vIn.x;\n" << "\t\tvOut.y = r * vIn.y;\n" @@ -3102,7 +3103,7 @@ public: ss << "\t{\n" << "\t\treal_t z = Zeps(precalcSqrtSumSquares);\n" << "\t\treal_t ct = vIn.x / precalcSqrtSumSquares;\n" - << "\t\treal_t r = " << weight << " * (MwcNext01(mwc) - " << holes << ") * " << eccentricity << " / (1 + " << eccentricity << " * ct) / z;\n" + << "\t\treal_t r = " << weight << " * (MwcNext01(mwc) - " << holes << ") * " << eccentricity << " / fma(" << eccentricity << ", ct, 1) / z;\n" << "\n" << "\t\tvOut.x = r * vIn.x;\n" << "\t\tvOut.y = r * vIn.y;\n" @@ -3510,8 +3511,8 @@ public: << "\n" << "\t\tif (MwcNext01(mwc) >= (real_t)(0.75))\n" << "\t\t{\n" - << "\t\t vOut.x = " << weight << " * (offsetX * (real_t)(0.5) + roundX);\n" - << "\t\t vOut.y = " << weight << " * (offsetY * (real_t)(0.5) + roundY);\n" + << "\t\t vOut.x = " << weight << " * fma(offsetX, (real_t)(0.5), roundX);\n" + << "\t\t vOut.y = " << weight << " * fma(offsetY, (real_t)(0.5), roundY);\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" @@ -3519,26 +3520,26 @@ public: << "\t\t {\n" << "\t\t if (offsetX >= (real_t)(0.0))\n" << "\t\t {\n" - << "\t\t vOut.x = " << weight << " * (offsetX * (real_t)(0.5) + roundX + (real_t)(0.25));\n" - << "\t\t vOut.y = " << weight << " * (offsetY * (real_t)(0.5) + roundY + (real_t)(0.25) * offsetY / offsetX);\n" + << "\t\t vOut.x = " << weight << " * fma(offsetX, (real_t)(0.5), roundX + (real_t)(0.25));\n" + << "\t\t vOut.y = " << weight << " * (fma(offsetY, (real_t)(0.5), roundY) + (real_t)(0.25) * offsetY / offsetX);\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.x = " << weight << " * (offsetX * (real_t)(0.5) + roundX - (real_t)(0.25));\n" - << "\t\t vOut.y = " << weight << " * (offsetY * (real_t)(0.5) + roundY - (real_t)(0.25) * offsetY / offsetX);\n" + << "\t\t vOut.x = " << weight << " * fma(offsetX, (real_t)(0.5), roundX - (real_t)(0.25));\n" + << "\t\t vOut.y = " << weight << " * (fma(offsetY, (real_t)(0.5), roundY) - (real_t)(0.25) * offsetY / offsetX);\n" << "\t\t }\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" << "\t\t if (offsetY >= (real_t)(0.0))\n" << "\t\t {\n" - << "\t\t vOut.y = " << weight << " * (offsetY * (real_t)(0.5) + roundY + (real_t)(0.25));\n" - << "\t\t vOut.x = " << weight << " * (offsetX * (real_t)(0.5) + roundX + offsetX / offsetY * (real_t)(0.25));\n" + << "\t\t vOut.y = " << weight << " * fma(offsetY, (real_t)(0.5), roundY + (real_t)(0.25));\n" + << "\t\t vOut.x = " << weight << " * (fma(offsetX, (real_t)(0.5), roundX) + offsetX / offsetY * (real_t)(0.25));\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.y = " << weight << " * (offsetY * (real_t)(0.5) + roundY - (real_t)(0.25));\n" - << "\t\t vOut.x = " << weight << " * (offsetX * (real_t)(0.5) + roundX - offsetX / offsetY * (real_t)(0.25));\n" + << "\t\t vOut.y = " << weight << " * fma(offsetY, (real_t)(0.5), roundY - (real_t)(0.25));\n" + << "\t\t vOut.x = " << weight << " * (fma(offsetX, (real_t)(0.5), roundX) - offsetX / offsetY * (real_t)(0.25));\n" << "\t\t }\n" << "\t\t }\n" << "\t\t}\n" @@ -3578,7 +3579,7 @@ public: ss << "\t{\n" << "\t\treal_t wx = " << weight << " * (real_t)(1.3029400317411197908970256609023);\n" << "\t\treal_t y2 = vIn.y * (real_t)(2.0);\n" - << "\t\treal_t r = wx * sqrt(fabs(vIn.y * vIn.x) / Zeps(SQR(vIn.x) + SQR(y2)));\n" + << "\t\treal_t r = wx * sqrt(fabs(vIn.y * vIn.x) / Zeps(fma(vIn.x, vIn.x, SQR(y2))));\n" << "\n" << "\t\tvOut.x = r * vIn.x;\n" << "\t\tvOut.y = r * y2;\n" @@ -3684,25 +3685,25 @@ public: << "\t\t else\n" << "\t\t {\n" << "\t\t y *= 2;\n" - << "\t\t x = -(2 * x + 1);\n" + << "\t\t x = -fma((real_t)(2.0), x, (real_t)(1.0));\n" << "\t\t }\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t if (x >= 0)\n" << "\t\t {\n" - << "\t\t y = -(2 * y + 1);\n" + << "\t\t y = -fma((real_t)(2.0), y, (real_t)(1.0));\n" << "\t\t x *= 2;\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t y = -(2 * y + 1);\n" - << "\t\t x = -(2 * x + 1);\n" + << "\t\t y = -fma((real_t)(2.0), y, (real_t)(1.0));\n" + << "\t\t x = -fma((real_t)(2.0), x, (real_t)(1.0));\n" << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.x = " << weight << " * (dx + x * " << size << ");\n" - << "\t\tvOut.y = -(" << weight << " * (dy + y * " << size << "));\n" + << "\t\tvOut.x = " << weight << " * fma(x, " << size << ", dx);\n" + << "\t\tvOut.y = -(" << weight << " * fma(y, " << size << ", dy));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -3766,8 +3767,8 @@ public: ss << "\t{\n" << "\t\treal_t a = precalcAtanyx;\n" << "\t\treal_t lnr = (real_t)(0.5) * log(precalcSumSquares);\n" - << "\t\treal_t angle = " << c << " * a + " << d << " * lnr + " << ang << " * floor(" << power << " * MwcNext01(mwc));\n" - << "\t\treal_t m = " << weight << " * exp(" << c << " * lnr - " << d << " * a);\n" + << "\t\treal_t angle = fma(" << c << ", a, fma(" << d << ", lnr, " << ang << " * floor(" << power << " * MwcNext01(mwc))));\n" + << "\t\treal_t m = " << weight << " * exp(fma(" << c << ", lnr, -(" << d << " * a)));\n" << "\n" << "\t\tvOut.x = m * cos(angle);\n" << "\t\tvOut.y = m * sin(angle);\n" @@ -3839,18 +3840,18 @@ public: intmax_t i = 0, varIndex = IndexInXform(); ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - string weight = WeightDefineString(); - string xAmp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string yAmp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string xLength = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string yLength = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string xAmpV = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string yAmpV = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string weight = WeightDefineString(); + string xAmp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string yAmp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string xLength = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string yLength = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string xAmpV = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string yAmpV = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string xLengthV = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string yLengthV = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\tvOut.x = " << weight << " * vIn.x + " << xAmpV << " * exp(-vIn.y * vIn.y * " << xLengthV << ");\n" - << "\t\tvOut.y = " << weight << " * vIn.y + " << yAmpV << " * exp(-vIn.x * vIn.x * " << yLengthV << ");\n" + << "\t\tvOut.x = fma(" << weight << ", vIn.x, " << xAmpV << " * exp(-vIn.y * vIn.y * " << xLengthV << "));\n" + << "\t\tvOut.y = fma(" << weight << ", vIn.y, " << yAmpV << " * exp(-vIn.x * vIn.x * " << yLengthV << "));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -4147,13 +4148,13 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string beta = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t a = precalcAtanyx;\n" << "\t\treal_t lnr = (real_t)(0.5) * log(precalcSumSquares);\n" - << "\t\treal_t m = " << weight << " * exp(" << c << " * lnr - " << d << " * a);\n" - << "\t\treal_t n = " << c << " * a + " << d << " * lnr;\n" + << "\t\treal_t m = " << weight << " * exp(fma(" << c << ", lnr, -(" << d << " * a)));\n" + << "\t\treal_t n = fma(" << c << ", a, " << d << " * lnr);\n" << "\n" << "\t\tvOut.x = m * cos(n);\n" << "\t\tvOut.y = m * sin(n);\n" @@ -4295,29 +4296,29 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string spin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string spin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string space = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string twist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t x = vIn.x - " << x << ";\n" << "\t\treal_t y = vIn.y + " << y << ";\n" - << "\t\treal_t r = sqrt(x * x + y * y);\n" + << "\t\treal_t r = sqrt(fma(x, x, SQR(y)));\n" << "\n" << "\t\tif (r < " << weight << ")\n" << "\t\t{\n" - << "\t\t real_t a = atan2(y, x) + " << spin << " + " << twist << " * (" << weight << " - r);\n" + << "\t\t real_t a = fma(" << twist << ", " << weight << " - r, atan2(y, x) + " << spin << ");\n" << "\n" - << "\t\t vOut.x = " << weight << " * (r * cos(a) + " << x << ");\n" - << "\t\t vOut.y = " << weight << " * (r * sin(a) - " << y << ");\n" + << "\t\t vOut.x = " << weight << " * fma(r, cos(a), " << x << ");\n" + << "\t\t vOut.y = " << weight << " * fma(r, sin(a), -" << y << ");\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t r = (real_t)(1.0) + " << space << " / Zeps(r);\n" << "\n" - << "\t\t vOut.x = " << weight << " * (r * x + " << x << ");\n" - << "\t\t vOut.y = " << weight << " * (r * y - " << y << ");\n" + << "\t\t vOut.x = " << weight << " * fma(r, x, " << x << ");\n" + << "\t\t vOut.y = " << weight << " * fma(r, y, -" << y << ");\n" << "\t\t}\n" << "\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" @@ -4584,17 +4585,17 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string separation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string frequency = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string amplitude = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string damping = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string tpf = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string frequency = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string amplitude = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string damping = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string tpf = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t t;\n" << "\n" << "\t\tif (" << damping << " == (real_t)(0.0))\n" - << "\t\t t = " << amplitude << " * cos(" << tpf << " * vIn.x) + " << separation << ";\n" + << "\t\t t = fma(" << amplitude << ", cos(" << tpf << " * vIn.x), " << separation << ");\n" << "\t\telse\n" - << "\t\t t = " << amplitude << " * exp(-fabs(vIn.x) * " << damping << ") * cos(" << tpf << " * vIn.x) + " << separation << ";\n" + << "\t\t t = fma(" << amplitude << ", exp(-fabs(vIn.x) * " << damping << ") * cos(" << tpf << " * vIn.x), " << separation << ");\n" << "\n" << "\t\tif (fabs(vIn.y) <= t)\n" << "\t\t{\n" @@ -4735,8 +4736,8 @@ public: string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\tvOut.x = " << weight << " * (vIn.x + " << x << " * sin(tan(vIn.y * " << c << ")));\n" - << "\t\tvOut.y = " << weight << " * (vIn.y + " << y << " * sin(tan(vIn.x * " << c << ")));\n" + << "\t\tvOut.x = " << weight << " * fma(" << x << ", sin(tan(vIn.y * " << c << ")), vIn.x);\n" + << "\t\tvOut.y = " << weight << " * fma(" << y << ", sin(tan(vIn.x * " << c << ")), vIn.y);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -4868,22 +4869,22 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string xInside = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string yInside = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string xx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string yy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string xx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string yy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tif (vIn.x > (real_t)(0.0))\n" - << "\t\t vOut.x = " << weight << " * (sqrt(vIn.x * vIn.x + " << xx << ") - vIn.x * " << xInside << ");\n" + << "\t\t vOut.x = " << weight << " * (sqrt(fma(vIn.x, vIn.x, " << xx << ")) - vIn.x * " << xInside << ");\n" << "\t\telse\n" - << "\t\t vOut.x = -(" << weight << " * (sqrt(vIn.x * vIn.x + " << xx << ") + vIn.x * " << xInside << "));\n" + << "\t\t vOut.x = -(" << weight << " * fma(vIn.x, " << xInside << ", sqrt(fma(vIn.x, vIn.x, " << xx << "))));\n" << "\n" << "\t\tif (vIn.y > (real_t)(0.0))\n" - << "\t\t vOut.y = " << weight << " * (sqrt(vIn.y * vIn.y + " << yy << ") - vIn.y * " << yInside << ");\n" + << "\t\t vOut.y = " << weight << " * (sqrt(fma(vIn.y, vIn.y, " << yy << ")) - vIn.y * " << yInside << ");\n" << "\t\telse\n" - << "\t\t vOut.y = -(" << weight << " * (sqrt(vIn.y * vIn.y + " << yy << ") + vIn.y * " << yInside << "));\n" + << "\t\t vOut.y = -(" << weight << " * fma(vIn.y, " << yInside << ", sqrt(fma(vIn.y, vIn.y, " << yy << "))));\n" << "\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t}\n"; @@ -5122,8 +5123,8 @@ public: << "\t\treal_t roundx = (real_t)(int)(vIn.x >= 0 ? (vIn.x + (real_t)(0.5)) : (vIn.x - (real_t)(0.5)));\n" << "\t\treal_t offsetx = vIn.x - roundx;\n" << "\n" - << "\t\tvOut.x = " << weight << " * (offsetx * ((real_t)(1.0) - " << space << ") + roundx);\n" - << "\t\tvOut.y = " << weight << " * (vIn.y + offsetx * offsetx * " << warp << ");\n" + << "\t\tvOut.x = " << weight << " * fma(offsetx, (real_t)(1.0) - " << space << ", roundx);\n" + << "\t\tvOut.y = " << weight << " * fma(SQR(offsetx), " << warp << ", vIn.y);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -5182,17 +5183,17 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string count = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string swirl = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string count = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string swirl = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string compFac = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t r = precalcSqrtSumSquares;\n" - << "\t\treal_t a = precalcAtanyx + " << swirl << " * r;\n" - << "\t\treal_t c = floor((" << count << " * a + MPI) * M1PI * (real_t)(0.5));\n" + << "\t\treal_t a = fma(" << swirl << ", r, precalcAtanyx);\n" + << "\t\treal_t c = floor(fma(" << count << ", a, MPI) * M1PI * (real_t)(0.5));\n" << "\n" - << "\t\ta = a * " << compFac << " + c * " << angle << ";\n" + << "\t\ta = fma(a, " << compFac << ", c * " << angle << ");\n" << "\t\tr = " << weight << " * (r + " << hole << ");\n" << "\t\tvOut.x = r * cos(a);\n" << "\t\tvOut.y = r * sin(a);\n" @@ -5270,17 +5271,17 @@ public: string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params. string count = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cf = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cf = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cn << ");\n" << "\t\tint tRand = (int)(" << rn << " * MwcNext01(mwc));\n" - << "\t\treal_t a = (precalcAtanyx + M_2PI * tRand) / " << power << ";\n" - << "\t\treal_t c = floor((" << count << " * a + MPI) * M1PI * (real_t)(0.5));\n" + << "\t\treal_t a = fma(M_2PI, (real_t)tRand, precalcAtanyx) / " << power << ";\n" + << "\t\treal_t c = floor(fma(" << count << ", a, MPI) * M1PI * (real_t)(0.5));\n" << "\n" - << "\t\ta = a * " << cf << " + c * " << angle << ";\n" + << "\t\ta = fma(a, " << cf << ", c * " << angle << ");\n" << "\t\tvOut.x = r * cos(a);\n" << "\t\tvOut.y = r * sin(a);\n" << "\t\tvOut.z = " << DefaultZCl() @@ -5360,18 +5361,18 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string count = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string swirl = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c12pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string count = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string swirl = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c12pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string compfac = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t r = (real_t)(1.0) / Zeps(precalcSqrtSumSquares);\n" - << "\t\treal_t a = precalcAtanyx + " << swirl << " * r;\n" - << "\t\treal_t c = floor((" << count << " * a + MPI) * " << c12pi << "); \n" + << "\t\treal_t a = fma(" << swirl << ", r, precalcAtanyx);\n" + << "\t\treal_t c = floor(fma(" << count << ", a, MPI) * " << c12pi << "); \n" << "\n" - << "\t\ta = a * " << compfac << " + c * " << angle << ";\n" + << "\t\ta = fma(a, " << compfac << ", c * " << angle << ");\n" << "\t\treal_t temp = " << weight << " * (r + " << hole << ");\n" << "\t\tvOut.x = temp * cos(a);\n" << "\t\tvOut.y = temp * sin(a);\n" @@ -5527,16 +5528,16 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string freqX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scaleX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string freqY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scaleY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string freqZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scaleZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\tvOut.x = " << weight << " * (vIn.x + " << scaleX << " * sin(vIn.y * " << freqX << "));\n" - << "\t\tvOut.y = " << weight << " * (vIn.y + " << scaleY << " * sin(vIn.x * " << freqY << "));\n" - << "\t\tvOut.z = " << weight << " * (vIn.z + " << scaleZ << " * sin(precalcSqrtSumSquares * " << freqZ << "));\n" + << "\t\tvOut.x = " << weight << " * fma(" << scaleX << ", sin(vIn.y * " << freqX << "), vIn.x);\n" + << "\t\tvOut.y = " << weight << " * fma(" << scaleY << ", sin(vIn.x * " << freqY << "), vIn.y);\n" + << "\t\tvOut.z = " << weight << " * fma(" << scaleZ << ", sin(precalcSqrtSumSquares * " << freqZ << "), vIn.z);\n" << "\t}\n"; return ss.str(); } @@ -6235,10 +6236,10 @@ public: ss << "\t{\n" << "\t\treal_t s = sin(" << freq << " * vIn.x);\n" << "\t\treal_t t = sin(" << freq << " * vIn.y);\n" - << "\t\treal_t dy = vIn.y + " << augerWeight << " * (" << scale << " * s / Zeps((real_t)(2.0) + fabs(vIn.y) * s));\n" - << "\t\treal_t dx = vIn.x + " << augerWeight << " * (" << scale << " * t / Zeps((real_t)(2.0) + fabs(vIn.x) * t));\n" + << "\t\treal_t dy = fma(" << augerWeight << ", " << scale << " * s / Zeps(fma(fabs(vIn.y), s, (real_t)(2.0))), vIn.y);\n" + << "\t\treal_t dx = fma(" << augerWeight << ", " << scale << " * t / Zeps(fma(fabs(vIn.x), t, (real_t)(2.0))), vIn.x);\n" << "\n" - << "\t\tvOut.x = " << weight << " * (vIn.x + " << symmetry << " * (dx - vIn.x));\n" + << "\t\tvOut.x = " << weight << " * fma(" << symmetry << ", (dx - vIn.x), vIn.x);\n" << "\t\tvOut.y = " << weight << " * dy;\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t}\n"; @@ -6320,12 +6321,12 @@ public: << "\t\treal_t xpw = vIn.x + " << weight << ";\n" << "\t\treal_t xmw = vIn.x - " << weight << ";\n" << "\t\treal_t yy = SQR(vIn.y);\n" - << "\t\treal_t frac = sqrt(yy + SQR(xmw));\n" + << "\t\treal_t frac = sqrt(fma(xmw, xmw, yy));\n" << "\n" << "\t\tif (frac == (real_t)(0.0))\n" << "\t\t frac = (real_t)(1.0);\n" << "\n" - << "\t\treal_t avgr = " << weight << " * (" << spr << " * sqrt(sqrt(yy + SQR(xpw)) / frac));\n" + << "\t\treal_t avgr = " << weight << " * (" << spr << " * sqrt(sqrt(fma(xpw, xpw, yy)) / frac));\n" << "\t\treal_t avga = (atan2(vIn.y, xmw) - atan2(vIn.y, xpw)) * (real_t)(0.5);\n" << "\n" << "\t\tvOut.x = avgr * cos(avga);\n" diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h index a675dba..feb311e 100644 --- a/Source/Ember/Variations02.h +++ b/Source/Ember/Variations02.h @@ -214,17 +214,17 @@ public: << "\t\t lx *= " << g2 << ";\n" << "\t\t ly *= " << g2 << ";\n" << "\n" - << "\t\t real_t r = " << rfactor << " / Zeps((SQR(lx) + SQR(ly)) / 4 + 1);\n" + << "\t\t real_t r = " << rfactor << " / Zeps(fma(lx, lx, SQR(ly)) / 4 + 1);\n" << "\n" << "\t\t lx *= r;\n" << "\t\t ly *= r;\n" - << "\t\t r = (SQR(lx) + SQR(ly)) / " << r2 << ";\n" + << "\t\t r = fma(lx, lx, SQR(ly)) / " << r2 << ";\n" << "\n" - << "\t\t real_t theta = " << bwrapsInnerTwist << " * (1 - r) + " << bwrapsOuterTwist << " * r;\n" + << "\t\t real_t theta = fma(" << bwrapsInnerTwist << ", (1 - r), " << bwrapsOuterTwist << " * r);\n" << "\t\t real_t s = sin(theta);\n" << "\t\t real_t c = cos(theta);\n" << "\n" - << "\t\t vx = cx + c * lx + s * ly;\n" + << "\t\t vx = fma(s, ly, fma(c, lx, cx));\n" << "\t\t vy = cy - s * lx + c * ly;\n" << "\n" << "\t\t vOut.x = " << weight << " * vx;\n" @@ -344,8 +344,8 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); ss << "\t{\n" - << "\t\treal_t x = 2 * MwcNext01(mwc) - 1;\n" - << "\t\treal_t y = 2 * MwcNext01(mwc) - 1;\n" + << "\t\treal_t x = fma((real_t)(2.0), MwcNext01(mwc), -(real_t)(1.0));\n" + << "\t\treal_t y = fma((real_t)(2.0), MwcNext01(mwc), -(real_t)(1.0));\n" << "\t\treal_t absx = x;\n" << "\t\treal_t absy = y;\n" << "\t\treal_t side, perimeter;\n" @@ -361,16 +361,16 @@ public: << "\t\t if (x >= absy)\n" << "\t\t perimeter = absx + y;\n" << "\t\t else\n" - << "\t\t perimeter = 5 * absx - y;\n" + << "\t\t perimeter = fma((real_t)(5.0), absx, -y);\n" << "\n" << "\t\t side = absx;\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t if (y >= absx)\n" - << "\t\t perimeter = 3 * absy - x;\n" + << "\t\t perimeter = fma((real_t)(3.0), absy, -x);\n" << "\t\t else\n" - << "\t\t perimeter = 7 * absy + x;\n" + << "\t\t perimeter = fma((real_t)(7.0), absy, x);\n" << "\n" << "\t\t side = absy;\n" << "\t\t}\n" @@ -421,10 +421,10 @@ public: string blurZoomX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string blurZoomY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t z = 1 + " << blurZoomLength << " * MwcNext01(mwc);\n" + << "\t\treal_t z = fma(" << blurZoomLength << ", MwcNext01(mwc), 1);\n" << "\n" - << "\t\tvOut.x = " << weight << " * ((vIn.x - " << blurZoomX << ") * z + " << blurZoomX << ");\n" - << "\t\tvOut.y = " << weight << " * ((vIn.y - " << blurZoomY << ") * z - " << blurZoomY << ");\n" + << "\t\tvOut.x = " << weight << " * fma((vIn.x - " << blurZoomX << "), z, " << blurZoomX << ");\n" + << "\t\tvOut.y = " << weight << " * fma((vIn.y - " << blurZoomY << "), z, -" << blurZoomY << ");\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t}\n"; return ss.str(); @@ -484,8 +484,8 @@ public: << "\t\treal_t x = floor(vIn.x * " << invSize << ");\n" << "\t\treal_t y = floor(vIn.y * " << invSize << ");\n" << "\n" - << "\t\tvOut.x = " << v << " * (x + " << blurPixelizeScale << " * (MwcNext01(mwc) - (real_t)(0.5)) + (real_t)(0.5));\n" - << "\t\tvOut.y = " << v << " * (y + " << blurPixelizeScale << " * (MwcNext01(mwc) - (real_t)(0.5)) + (real_t)(0.5));\n" + << "\t\tvOut.x = " << v << " * fma(" << blurPixelizeScale << ", (MwcNext01(mwc) - (real_t)(0.5)), x + (real_t)(0.5));\n" + << "\t\tvOut.y = " << v << " * fma(" << blurPixelizeScale << ", (MwcNext01(mwc) - (real_t)(0.5)), y + (real_t)(0.5));\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t}\n"; return ss.str(); @@ -588,12 +588,12 @@ public: << "\t\telse\n" << "\t\t{\n" << "\t\t if (x < " << x0_ << ")\n" - << "\t\t x = " << x0_ << " + MwcNext01(mwc) * " << w << ";\n" + << "\t\t x = fma(MwcNext01(mwc), " << w << ", " << x0_ << ");\n" << "\t\t else if (x > " << x1_ << ")\n" << "\t\t x = " << x1_ << " - MwcNext01(mwc) * " << w << ";\n" << "\t\t\n" << "\t\t if (y < " << y0_ << ")\n" - << "\t\t y = " << y0_ << " + MwcNext01(mwc) * " << h << ";\n" + << "\t\t y = fma(MwcNext01(mwc), " << h << ", " << y0_ << ");\n" << "\t\t else if (y > " << y1_ << ")\n" << "\t\t y = " << y1_ << " - MwcNext01(mwc) * " << h << ";\n" << "\t\t}\n" @@ -727,7 +727,7 @@ public: << "\n" << "\t\treal_t x = vIn.x * " << scale << ";\n" << "\t\treal_t y = vIn.y * " << scale << ";\n" - << "\t\treal_t r = sqrt(SQR(x) + SQR(y));\n" + << "\t\treal_t r = sqrt(fma(x, x, SQR(y)));\n" << "\n" << "\t\tif (r <= 1)\n" << "\t\t{\n" @@ -739,7 +739,7 @@ public: << "\t\t if (" << bcbw << " != 0)\n" << "\t\t {\n" << "\t\t real_t ang = atan2(y, x);\n" - << "\t\t real_t omega = ((real_t)(0.2) * " << bcbw << " * MwcNext01(mwc)) + 1;\n" + << "\t\t real_t omega = fma((real_t)(0.2) * " << bcbw << ", MwcNext01(mwc), (real_t)(1.0));\n" << "\t\t real_t px = omega * cos(ang);\n" << "\t\t real_t py = omega * sin(ang);\n" << "\n" @@ -810,8 +810,8 @@ public: ss << "\t{\n" << "\t\treal_t r = " << blurLinearLength << " * MwcNext01(mwc);\n" << "\n" - << "\t\tvOut.x = " << weight << " * (vIn.x + r * " << c << ");\n" - << "\t\tvOut.y = " << weight << " * (vIn.y + r * " << s << ");\n" + << "\t\tvOut.x = " << weight << " * fma(r, " << c << ", vIn.x);\n" + << "\t\tvOut.y = " << weight << " * fma(r, " << s << ", vIn.y);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -1162,7 +1162,7 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t r2 = " << weight << " / Zeps(precalcSumSquares + SQR(vIn.z));\n" + << "\t\treal_t r2 = " << weight << " / Zeps(fma(vIn.z, vIn.z, precalcSumSquares));\n" << "\n" << "\t\tvOut.x = r2 * vIn.x;\n" << "\t\tvOut.y = r2 * vIn.y;\n" @@ -1215,12 +1215,12 @@ public: string c2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t r2 = precalcSumSquares + SQR(vIn.z);\n" + << "\t\treal_t r2 = fma(vIn.z, vIn.z, precalcSumSquares);\n" << "\t\treal_t r = " << weight << " / Zeps(r2 * " << c2 << " + " << c2x << " * vIn.x - " << c2y << " * vIn.y + " << c2z << " * vIn.z + (real_t)(1.0));\n" << "\n" - << "\t\tvOut.x = r * (vIn.x + " << cx << " * r2);\n" + << "\t\tvOut.x = r * fma(" << cx << ", r2, vIn.x);\n" << "\t\tvOut.y = r * (vIn.y - " << cy << " * r2);\n" - << "\t\tvOut.z = r * (vIn.z + " << cz << " * r2);\n" + << "\t\tvOut.z = r * fma(" << cz << ", r2, vIn.z);\n" << "\t}\n"; return ss.str(); } @@ -1407,8 +1407,8 @@ public: << "\n" << "\t\tif (MwcNext01(mwc) >= " << cr << ")\n" << "\t\t{\n" - << "\t\t vOut.x = " << weight << " * (offsetX * " << absc << " + roundX);\n" - << "\t\t vOut.y = " << weight << " * (offsetY * " << absc << " + roundY);\n" + << "\t\t vOut.x = " << weight << " * fma(offsetX, " << absc << ", roundX);\n" + << "\t\t vOut.y = " << weight << " * fma(offsetY, " << absc << ", roundY);\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" @@ -1416,26 +1416,26 @@ public: << "\t\t {\n" << "\t\t if (offsetX >= 0)\n" << "\t\t {\n" - << "\t\t vOut.x = " << weight << " * (offsetX * " << absc << " + roundX + " << cl << ");\n" - << "\t\t vOut.y = " << weight << " * (offsetY * " << absc << " + roundY + " << cl << " * offsetY / offsetX);\n" + << "\t\t vOut.x = " << weight << " * fma(offsetX, " << absc << ", roundX + " << cl << ");\n" + << "\t\t vOut.y = " << weight << " * (fma(offsetY, " << absc << ", roundY) + " << cl << " * offsetY / offsetX);\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.x = " << weight << " * (offsetX * " << absc << " + roundX - " << cl << ");\n" - << "\t\t vOut.y = " << weight << " * (offsetY * " << absc << " + roundY - " << cl << " * offsetY / offsetX);\n" + << "\t\t vOut.x = " << weight << " * fma(offsetX, " << absc << ", roundX - " << cl << ");\n" + << "\t\t vOut.y = " << weight << " * (fma(offsetY, " << absc << ", roundY) - " << cl << " * offsetY / offsetX);\n" << "\t\t }\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" << "\t\t if(offsetY >= 0)\n" << "\t\t {\n" - << "\t\t vOut.y = " << weight << " * (offsetY * " << absc << " + roundY + " << cl << ");\n" - << "\t\t vOut.x = " << weight << " * (offsetX * " << absc << " + roundX + offsetX / offsetY * " << cl << ");\n" + << "\t\t vOut.y = " << weight << " * fma(offsetY, " << absc << ", roundY + " << cl << ");\n" + << "\t\t vOut.x = " << weight << " * (fma(offsetX, " << absc << ", roundX) + offsetX / offsetY * " << cl << ");\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.y = " << weight << " * (offsetY * " << absc << " + roundY - " << cl << ");\n" - << "\t\t vOut.x = " << weight << " * (offsetX * " << absc << " + roundX - offsetX / offsetY * " << cl << ");\n" + << "\t\t vOut.y = " << weight << " * fma(offsetY, " << absc << ", roundY - " << cl << ");\n" + << "\t\t vOut.x = " << weight << " * (fma(offsetX, " << absc << ", roundX) - offsetX / offsetY * " << cl << ");\n" << "\t\t }\n" << "\t\t }\n" << "\t\t}\n" @@ -1717,21 +1717,21 @@ public: << "\t\t if (vIn.x >= absy)\n" << "\t\t perimeter = absx + vIn.y;\n" << "\t\t else\n" - << "\t\t perimeter = 5 * absx - vIn.y;\n" + << "\t\t perimeter = fma((real_t)(5.0), absx, -vIn.y);\n" << "\n" << "\t\t side = absx;\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t if (vIn.y >= absx)\n" - << "\t\t perimeter = 3 * absy - vIn.x;\n" + << "\t\t perimeter = fma((real_t)(3.0), absy, -vIn.x);\n" << "\t\t else\n" - << "\t\t perimeter = 7 * absy + vIn.x;\n" + << "\t\t perimeter = fma((real_t)(7.0), absy, vIn.x);\n" << "\n" << "\t\t side = absy;\n" << "\t\t}\n" << "\n" - << "\t\treal_t r = " << vvar4pi << " * side + " << hole << ";\n" + << "\t\treal_t r = fma(" << vvar4pi << ", side, " << hole << ");\n" << "\t\treal_t val = MPI4 * perimeter / side - MPI4;\n" << "\n" << "\t\tvOut.x = r * cos(val);\n" @@ -1826,16 +1826,16 @@ public: << "\t\t if (vIn.x >= absy)\n" << "\t\t perimeter = absx + vIn.y;\n" << "\t\t else\n" - << "\t\t perimeter = 5 * absx - vIn.y;\n" + << "\t\t perimeter = fma((real_t)(5.0), absx, -vIn.y);\n" << "\n" << "\t\t side = absx;\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t if (vIn.y >= absx)\n" - << "\t\t perimeter = 3 * absy - vIn.x;\n" + << "\t\t perimeter = fma((real_t)(3.0), absy, -vIn.x);\n" << "\t\t else\n" - << "\t\t perimeter = 7 * absy + vIn.x;\n" + << "\t\t perimeter = fma((real_t)(7.0), absy, vIn.x);\n" << "\n" << "\t\t side = absy;\n" << "\t\t}\n" @@ -1908,8 +1908,8 @@ public: string fr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vv2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t x = (real_t)(0.5) * vIn.x + (real_t)(0.5);\n" - << "\t\treal_t y = (real_t)(0.5) * vIn.y + (real_t)(0.5);\n" + << "\t\treal_t x = fma((real_t)(0.5), vIn.x, (real_t)(0.5));\n" + << "\t\treal_t y = fma((real_t)(0.5), vIn.y, (real_t)(0.5));\n" << "\t\treal_t bx = Fabsmod(" << fr << " * x);\n" << "\t\treal_t by = Fabsmod(" << fr << " * y);\n" << "\t\treal_t oscnapx = Foscn(" << amountX << ", " << px << ");\n" @@ -1986,7 +1986,7 @@ public: { T s, c; T avgr = m_Weight * (std::sqrt(SQR(helper.In.y) + SQR(helper.In.x + 1)) / std::sqrt(SQR(helper.In.y) + SQR(helper.In.x - 1))); - T avga = (atan2(helper.In.y, helper.In.x - 1) - std::atan2(helper.In.y, helper.In.x + 1)) / 2; + T avga = (std::atan2(helper.In.y, helper.In.x - 1) - std::atan2(helper.In.y, helper.In.x + 1)) / 2; sincos(avga, &s, &c); helper.Out.x = avgr * c; helper.Out.y = avgr * s; @@ -1999,8 +1999,10 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t avgr = " << weight << " * (sqrt(SQR(vIn.y) + SQR(vIn.x + 1)) / sqrt(SQR(vIn.y) + SQR(vIn.x - 1)));\n" - << "\t\treal_t avga = (atan2(vIn.y, vIn.x - 1) - atan2(vIn.y, vIn.x + 1)) / 2;\n" + << "\t\treal_t xp1 = vIn.x + (real_t)(1.0);\n" + << "\t\treal_t xm1 = vIn.x - (real_t)(1.0);\n" + << "\t\treal_t avgr = " << weight << " * (sqrt(fma(vIn.y, vIn.y, SQR(xp1))) / sqrt(fma(vIn.y, vIn.y, SQR(xm1))));\n" + << "\t\treal_t avga = (atan2(vIn.y, xm1) - atan2(vIn.y, xp1)) / 2;\n" << "\t\treal_t s = sin(avga);\n" << "\t\treal_t c = cos(avga);\n" << "\n" @@ -2049,8 +2051,8 @@ public: string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string t = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t expor = exp(vIn.x * " << k << " - vIn.y * " << t << ");\n" - << "\t\treal_t temp = vIn.x * " << t << " + vIn.y * " << k << ";\n" + << "\t\treal_t expor = exp(fma(vIn.x, " << k << ", -(vIn.y * " << t << ")));\n" + << "\t\treal_t temp = fma(vIn.x, " << t << ", (vIn.y * " << k << "));\n" << "\t\treal_t snv = sin(temp);\n" << "\t\treal_t csv = cos(temp);\n" << "\n" @@ -2199,7 +2201,7 @@ public: string weight = WeightDefineString(); ss << "\t{\n" << "\t\treal_t a = M_2PI / (precalcSqrtSumSquares + 1);\n" - << "\t\treal_t r = (precalcAtanyx * M1PI + 1) * (real_t)(0.5);\n" + << "\t\treal_t r = fma(precalcAtanyx, M1PI, (real_t)(1.0)) * (real_t)(0.5);\n" << "\t\treal_t s = sin(a);\n" << "\t\treal_t c = cos(a);\n" << "\n" @@ -2252,11 +2254,11 @@ public: << "\t\treal_t temp = vIn.y * " << natLog << ";\n" << "\t\treal_t snum1 = sin(temp);\n" << "\t\treal_t cnum1 = cos(temp);\n" - << "\t\ttemp = (vIn.x * MPI + vIn.y * " << natLog << ") * -(real_t)(1.0);\n" + << "\t\ttemp = fma(vIn.x, MPI, vIn.y * " << natLog << ") * -(real_t)(1.0);\n" << "\t\treal_t snum2 = sin(temp);\n" << "\t\treal_t cnum2 = cos(temp);\n" << "\t\treal_t eradius1 = exp(vIn.x * " << natLog << ");\n" - << "\t\treal_t eradius2 = exp((vIn.x * " << natLog << " - vIn.y * MPI) * -(real_t)(1.0));\n" + << "\t\treal_t eradius2 = exp(fma(vIn.x, " << natLog << ", -(vIn.y * MPI)) * -(real_t)(1.0));\n" << "\n" << "\t\tvOut.x = " << weight << " * (eradius1 * cnum1 - eradius2 * cnum2) * " << five << ";\n" << "\t\tvOut.y = " << weight << " * (eradius1 * snum1 - eradius2 * snum2) * " << five << ";\n" @@ -2328,14 +2330,14 @@ public: << "\t\treal_t temp = vIn.y * " << natLog << ";\n" << "\t\treal_t snum1 = sin(temp);\n" << "\t\treal_t cnum1 = cos(temp);\n" - << "\t\ttemp = (vIn.x * MPI + vIn.y * " << natLog << ") * -1;\n" + << "\t\ttemp = fma(vIn.x, MPI, vIn.y * " << natLog << ") * -1;\n" << "\t\treal_t snum2 = sin(temp);\n" << "\t\treal_t cnum2 = cos(temp);\n" << "\t\treal_t eradius1 = " << sc << " * exp(" << sc2 << " * (vIn.x * " << natLog << "));\n" - << "\t\treal_t eradius2 = " << sc << " * exp(" << sc2 << " * ((vIn.x * " << natLog << " - vIn.y * MPI) * -1));\n" + << "\t\treal_t eradius2 = " << sc << " * exp(" << sc2 << " * (fma(vIn.x, " << natLog << ", -(vIn.y * MPI)) * -1));\n" << "\n" - << "\t\tvOut.x = " << weight << " * (eradius1 * cnum1 - eradius2 * cnum2) * " << five << ";\n" - << "\t\tvOut.y = " << weight << " * (eradius1 * snum1 - eradius2 * snum2) * " << five << ";\n" + << "\t\tvOut.x = " << weight << " * fma(eradius1, cnum1, -(eradius2 * cnum2)) * " << five << ";\n" + << "\t\tvOut.y = " << weight << " * fma(eradius1, snum1, -(eradius2 * snum2)) * " << five << ";\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -2403,14 +2405,14 @@ public: { if (rand.Frand01() > T(0.5)) { - d = std::sqrt(r + helper.In.x); + d = Zeps(std::sqrt(r + helper.In.x)); helper.Out.x = -(m_V2 * d); helper.Out.y = -(m_V2 / d * helper.In.y); } else { d = r + helper.In.x; - r = m_Weight / std::sqrt(r * (SQR(helper.In.y) + SQR(d))); + r = m_Weight / Zeps(std::sqrt(r * (SQR(helper.In.y) + SQR(d)))); helper.Out.x = -(r * d); helper.Out.y = r * helper.In.y; } @@ -2441,7 +2443,7 @@ public: << "\t\t else\n" << "\t\t {\n" << "\t\t d = r + vIn.x;\n" - << "\t\t r = " << weight << " / sqrt(r * (SQR(vIn.y) + SQR(d)));\n" + << "\t\t r = " << weight << " / sqrt(r * fma(vIn.y, vIn.y, SQR(d)));\n" << "\t\t vOut.x = r * d;\n" << "\t\t vOut.y = r * vIn.y;\n" << "\t\t }\n" @@ -2457,7 +2459,7 @@ public: << "\t\t else\n" << "\t\t {\n" << "\t\t d = r + vIn.x;\n" - << "\t\t r = " << weight << " / sqrt(r * (SQR(vIn.y) + SQR(d)));\n" + << "\t\t r = " << weight << " / sqrt(r * fma(vIn.y, vIn.y, SQR(d)));\n" << "\t\t vOut.x = -(r * d);\n" << "\t\t vOut.y = r * vIn.y;\n" << "\t\t }\n" @@ -2473,6 +2475,11 @@ public: m_V2 = m_Weight * std::sqrt(T(2)) / 2; } + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Zeps" }; + } + protected: void Init() { @@ -2685,7 +2692,7 @@ public: << "\t\tif (" << inside << " != 0)\n" << "\t\t r = " << weight << " * delta / (precalcSqrtSumSquares + delta);\n" << "\t\telse\n" - << "\t\t r = " << weight << " * precalcSqrtSumSquares + delta;\n" + << "\t\t r = fma(" << weight << ", precalcSqrtSumSquares, delta);\n" << "\n" << "\t\tvOut.x = r * precalcCosa;\n" << "\t\tvOut.y = r * precalcSina;\n" @@ -2741,20 +2748,20 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string real = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string imag = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t a = vIn.x + " << real << ";\n" << "\t\treal_t b = vIn.y - " << imag << ";\n" - << "\t\treal_t c = " << real << " * vIn.x - " << imag << " * vIn.y + 1;\n" - << "\t\treal_t d = " << real << " * vIn.y + " << imag << " * vIn.x;\n" - << "\t\treal_t vr = " << weight << " / (SQR(c) + SQR(d));\n" + << "\t\treal_t c = fma(" << real << ", vIn.x, -(" << imag << " * vIn.y)) + 1;\n" + << "\t\treal_t d = fma(" << real << ", vIn.y, " << imag << " * vIn.x);\n" + << "\t\treal_t vr = " << weight << " / fma(c, c, SQR(d));\n" << "\n" - << "\t\tvOut.x = vr * (a * c + b * d);\n" - << "\t\tvOut.y = vr * (b * c - a * d);\n" + << "\t\tvOut.x = vr * fma(a, c, b * d);\n" + << "\t\tvOut.y = vr * fma(b, c, -(a * d));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -2834,10 +2841,10 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t temp = MwcNext(mwc) * " << pa << ";\n" << "\t\treal_t sina = sin(temp);\n" @@ -2846,12 +2853,12 @@ public: << "\t\treal_t im = " << r << " * sina;\n" << "\t\treal_t a = vIn.x + re;\n" << "\t\treal_t b = vIn.y - im;\n" - << "\t\treal_t c = re * vIn.x - im * vIn.y + 1;\n" - << "\t\treal_t d = re * vIn.y + im * vIn.x;\n" - << "\t\treal_t vr = " << weight << " / (SQR(c) + SQR(d));\n" + << "\t\treal_t c = fma(re, vIn.x, -(im * vIn.y)) + 1;\n" + << "\t\treal_t d = fma(re, vIn.y, im * vIn.x);\n" + << "\t\treal_t vr = " << weight << " / fma(c, c, SQR(d));\n" << "\n" - << "\t\tvOut.x = vr * (a * c + b * d);\n" - << "\t\tvOut.y = vr * (b * c - a * d);\n" + << "\t\tvOut.x = vr * fma(a, c, b * d);\n" + << "\t\tvOut.y = vr * fma(b, c, -(a * d));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -2935,15 +2942,15 @@ public: << "\t\treal_t b = vIn.y;\n" << "\t\treal_t c = " << r << " * vIn.x + 1;\n" << "\t\treal_t d = " << r << " * vIn.y;\n" - << "\t\treal_t x = (a * c + b * d);\n" - << "\t\treal_t y = (b * c - a * d);\n" - << "\t\treal_t vr = " << weight << " / (SQR(c) + SQR(d));\n" + << "\t\treal_t x = fma(a, c, b * d);\n" + << "\t\treal_t y = fma(b, c, -(a * d));\n" + << "\t\treal_t vr = " << weight << " / fma(c, c, SQR(d));\n" << "\t\treal_t temp = MwcNext(mwc) * " << pa << ";\n" << "\t\treal_t sina = sin(temp);\n" << "\t\treal_t cosa = cos(temp);\n" << "\n" - << "\t\tvOut.x = vr * (x * cosa + y * sina);\n" - << "\t\tvOut.y = vr * (y * cosa - x * sina);\n" + << "\t\tvOut.x = vr * fma(x, cosa, y * sina);\n" + << "\t\tvOut.y = vr * fma(y, cosa, -(x * sina));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -3012,27 +3019,27 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t r2 = precalcSumSquares + vIn.z;\n" << "\t\treal_t x2cx = " << c2x << " * vIn.x;\n" << "\t\treal_t y2cy = " << c2y << " * vIn.y;\n" - << "\t\treal_t d = " << weight << " / Zeps(" << c2 << " * r2 + x2cx - y2cy + 1);\n" + << "\t\treal_t d = " << weight << " / Zeps(fma(" << c2 << ", r2, (x2cx - y2cy) + 1));\n" << "\n" - << "\t\tvOut.x = d * (vIn.x * " << s2x << " - " << cx << "* ( y2cy - r2 - 1));\n" - << "\t\tvOut.y = d * (vIn.y * " << s2y << " + " << cy << "* (-x2cx - r2 - 1));\n" + << "\t\tvOut.x = d * fma(vIn.x, " << s2x << ", -(" << cx << " * (y2cy - r2 - 1)));\n" + << "\t\tvOut.y = d * fma(vIn.y, " << s2y << ", " << cy << " * (-x2cx - r2 - 1));\n" << "\t\tvOut.z = d * (vIn.z * " << s2z << ");\n" << "\t}\n"; return ss.str(); @@ -3138,25 +3145,25 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t temp = MwcNext(mwc) * " << pa << ";\n" << "\t\treal_t cx = " << r << " * cos(temp);\n" << "\t\treal_t cy = " << r << " * sin(temp);\n" - << "\t\treal_t s2x = 1 + SQR(cx) - SQR(cy);\n" - << "\t\treal_t s2y = 1 + SQR(cy) - SQR(cx);\n" + << "\t\treal_t s2x = fma(cx, cx, (real_t)(1.0)) - SQR(cy);\n" + << "\t\treal_t s2y = fma(cy, cy, (real_t)(1.0)) - SQR(cx);\n" << "\t\treal_t r2 = precalcSumSquares + SQR(vIn.z);\n" << "\t\treal_t x2cx = 2 * cx * vIn.x;\n" << "\t\treal_t y2cy = 2 * cy * vIn.x;\n" - << "\t\treal_t d = " << weight << " / Zeps(" << c2 << " * r2 + x2cx - y2cy + 1);\n" + << "\t\treal_t d = " << weight << " / Zeps(fma(" << c2 << ", r2, (x2cx - y2cy) + 1)); \n" << "\n" - << "\t\tvOut.x = d * (vIn.x * s2x - cx * ( y2cy - r2 - 1));\n" - << "\t\tvOut.y = d * (vIn.y * s2y + cy * (-x2cx - r2 - 1));\n" + << "\t\tvOut.x = d * fma(vIn.x, s2x, -(cx * (y2cy - r2 - 1)));\n" + << "\t\tvOut.y = d * fma(vIn.y, s2y, cy * (-x2cx - r2 - 1));\n" << "\t\tvOut.z = d * (vIn.z * " << s2z << ");\n" << "\t}\n"; return ss.str(); @@ -3242,11 +3249,11 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; @@ -3254,15 +3261,15 @@ public: ss << "\t{\n" << "\t\treal_t r2 = precalcSumSquares + SQR(vIn.z);\n" << "\t\treal_t x2cx = " << c2x << " * vIn.x;\n" - << "\t\treal_t x = vIn.x * " << s2x << " - " << cx << " * (-r2 - 1);\n" + << "\t\treal_t x = fma(vIn.x, " << s2x << ", -(" << cx << " * (-r2 - 1)));\n" << "\t\treal_t y = vIn.y * " << s2y << ";\n" - << "\t\treal_t vr = " << weight << " / (" << c2 << " * r2 + x2cx + 1);\n" + << "\t\treal_t vr = " << weight << " / fma(" << c2 << ", r2, x2cx + 1);\n" << "\t\treal_t temp = MwcNext(mwc) * " << pa << ";\n" << "\t\treal_t sina = sin(temp);\n" << "\t\treal_t cosa = cos(temp);\n" << "\n" - << "\t\tvOut.x = vr * (x * cosa + y * sina);\n" - << "\t\tvOut.y = vr * (y * cosa - x * sina);\n" + << "\t\tvOut.x = vr * fma(x, cosa, y * sina);\n" + << "\t\tvOut.y = vr * fma(y, cosa, -(x * sina));\n" << "\t\tvOut.z = vr * (vIn.z * " << s2z << ");\n" << "\t}\n"; return ss.str(); @@ -3397,7 +3404,7 @@ public: { T x = m_A * helper.In.x + m_B * helper.In.y + m_E; T y = m_C * helper.In.x + m_D * helper.In.y + m_F; - T angle = (atan2(y, x) + M_2PI * rand.Rand(int(m_AbsN))) / m_Power; + T angle = (std::atan2(y, x) + M_2PI * rand.Rand(int(m_AbsN))) / m_Power; T sina = std::sin(angle); T cosa = std::cos(angle); T r = m_Weight * std::pow(SQR(x) + SQR(y), m_Cn); @@ -3413,23 +3420,23 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string e = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string e = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t x = " << a << " * vIn.x + " << b << " * vIn.y + " << e << ";\n" - << "\t\treal_t y = " << c << " * vIn.x + " << d << " * vIn.y + " << f << ";\n" - << "\t\treal_t angle = (atan2(y, x) + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << power << ";\n" + << "\t\treal_t x = fma(" << a << ", vIn.x, fma(" << b << ", vIn.y, " << e << "));\n" + << "\t\treal_t y = fma(" << c << ", vIn.x, fma(" << d << ", vIn.y, " << f << "));\n" + << "\t\treal_t angle = fma(M_2PI, (real_t)MwcNextRange(mwc, (uint)" << absn << "), atan2(y, x)) / " << power << ";\n" << "\t\treal_t sina = sin(angle);\n" << "\t\treal_t cosa = cos(angle);\n" - << "\t\treal_t r = " << weight << " * pow(SQR(x) + SQR(y), " << cn << ");\n" + << "\t\treal_t r = " << weight << " * pow(fma(x, x, SQR(y)), " << cn << ");\n" << "\n" << "\t\tvOut.x = r * cosa;\n" << "\t\tvOut.y = r * sina;\n" @@ -3509,13 +3516,13 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string divisor = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string divisor = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string halfInvPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invPower2Pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invPower2Pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t a = precalcAtanyx * " << invPower << " + MwcNext(mwc) * " << invPower2Pi << ";\n" + << "\t\treal_t a = fma(precalcAtanyx, " << invPower << ", MwcNext(mwc) * " << invPower2Pi << ");\n" << "\t\treal_t sina = sin(a);\n" << "\t\treal_t cosa = cos(a);\n" << "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << halfInvPower << ");\n" @@ -3599,12 +3606,12 @@ public: << "\t\treal_t sina = sin(angle);\n" << "\t\treal_t cosa = cos(angle);\n" << "\t\treal_t r = " << cp << " * pow(precalcSumSquares, " << p2 << ");\n" - << "\t\treal_t re = r * cosa + 1;\n" + << "\t\treal_t re = fma(r, cosa, (real_t)(1.0));\n" << "\t\treal_t im = r * sina;\n" - << "\t\treal_t r1 = " << vp << " / (SQR(re) + SQR(im));\n" + << "\t\treal_t r1 = " << vp << " / fma(re, re, SQR(im));\n" << "\n" - << "\t\tvOut.x = r1 * (vIn.x * re + vIn.y * im);\n" - << "\t\tvOut.y = r1 * (vIn.y * re - vIn.x * im);\n" + << "\t\tvOut.x = r1 * fma(vIn.x, re, vIn.y * im);\n" + << "\t\tvOut.y = r1 * fma(vIn.y, re, -(vIn.x * im));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -3693,10 +3700,10 @@ public: << "\t\treal_t sina = sin(angle);\n" << "\t\treal_t cosa = cos(angle);\n" << "\t\treal_t r = " << c << " * pow(precalcSumSquares, " << p2 << ");\n" - << "\t\treal_t re = r * cosa + 1;\n" + << "\t\treal_t re = fma(r, cosa, (real_t)(1.0));\n" << "\t\treal_t im = r * sina;\n" << "\n" - << "\t\tr = pow(SQR(re) + SQR(im), " << invp << ");\n" + << "\t\tr = pow(fma(re, re, SQR(im)), " << invp << ");\n" << "\t\tangle = atan2(im, re) * " << invp2 << ";\n" << "\t\tsina = sin(angle);\n" << "\t\tcosa = cos(angle);\n" @@ -3705,8 +3712,8 @@ public: << "\n" << "\t\treal_t r1 = " << vp << " / SQR(r);\n" << "\n" - << "\t\tvOut.x = r1 * (vIn.x * re + vIn.y * im);\n" - << "\t\tvOut.y = r1 * (vIn.y * re - vIn.x * im);\n" + << "\t\tvOut.x = r1 * fma(vIn.x, re, vIn.y * im);\n" + << "\t\tvOut.y = r1 * fma(vIn.y, re, -(vIn.x * im));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -3783,22 +3790,22 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string parity = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string nnz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string vvar = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string vvar2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string isOdd = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string nnz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string vvar = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string vvar2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string isOdd = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t x = (" << isOdd << " != 0) ? vIn.x : " << vvar << " * precalcAtanxy;\n" << "\t\treal_t y = (" << isOdd << " != 0) ? vIn.y : " << vvar2 << " * log(precalcSumSquares);\n" - << "\t\treal_t angle = (atan2(y, x) + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << nnz << ";\n" - << "\t\treal_t r = " << weight << " * pow(SQR(x) + SQR(y), " << cn << ") * ((" << isOdd << " == 0) ? 1 : " << parity << ");\n" + << "\t\treal_t angle = fma(M_2PI, MwcNextRange(mwc, (uint)" << absn << "), atan2(y, x)) / " << nnz << ";\n" + << "\t\treal_t r = " << weight << " * pow(fma(x, x, SQR(y)), " << cn << ") * ((" << isOdd << " == 0) ? 1 : " << parity << ");\n" << "\t\treal_t sina = sin(angle) * r;\n" << "\t\treal_t cosa = cos(angle) * r;\n" << "\n" - << "\t\tx = (" << isOdd << " != 0) ? cosa : (" << vvar2 << " * log(SQR(cosa) + SQR(sina)));\n" + << "\t\tx = (" << isOdd << " != 0) ? cosa : (" << vvar2 << " * log(fma(cosa, cosa, SQR(sina))));\n" << "\t\ty = (" << isOdd << " != 0) ? sina : (" << vvar << " * atan2(cosa, sina));\n" << "\t\tvOut.x = x;\n" << "\t\tvOut.y = y;\n" @@ -3872,7 +3879,7 @@ public: if (helper.In.x >= 0) { xo = (r + 1) / Zeps(2 * helper.In.x); - ro = std::sqrt(SQR(helper.In.x - xo) + SQR(helper.In.y)); + ro = std::sqrt(Sqr(helper.In.x - xo) + SQR(helper.In.y)); theta = std::atan2(T(1), ro); a = fmod(m_In * theta + std::atan2(helper.In.y, xo - helper.In.x) + theta, 2 * theta) - theta; sincos(a, &s, &c); @@ -3882,7 +3889,7 @@ public: else { xo = -(r + 1) / (2 * helper.In.x); - ro = std::sqrt(SQR(-helper.In.x - xo) + SQR(helper.In.y)); + ro = std::sqrt(Sqr(-helper.In.x - xo) + SQR(helper.In.y)); theta = std::atan2(T(1), ro); a = fmod(m_In * theta + std::atan2(helper.In.y, xo + helper.In.x) + theta, 2 * theta) - theta; sincos(a, &s, &c); @@ -3901,7 +3908,7 @@ public: if (x >= 0) { xo = (SQR(x) + SQR(y) + 1) / Zeps(2 * x); - ro = std::sqrt(SQR(x - xo) + SQR(y)); + ro = std::sqrt(Sqr(x - xo) + SQR(y)); theta = std::atan2(T(1), ro); a = fmod(m_Out * theta + std::atan2(y, xo - x) + theta, 2 * theta) - theta; sincos(a, &s, &c); @@ -3916,7 +3923,7 @@ public: else { xo = -(SQR(x) + SQR(y) + 1) / (2 * x); - ro = std::sqrt(SQR(-x - xo) + SQR(y)); + ro = std::sqrt(Sqr(-x - xo) + SQR(y)); theta = std::atan2(T(1), ro); a = fmod(m_Out * theta + std::atan2(y, xo + x) + theta, 2 * theta) - theta; sincos(a, &s, &c); @@ -3954,12 +3961,14 @@ public: << "\n" << "\t\tif (r < 1)\n" << "\t\t{\n" + << "\t\t real_t y2 = SQR(vIn.y);\n" << "\t\t if (vIn.x >= 0)\n" << "\t\t {\n" << "\t\t xo = (r + 1) / Zeps(2 * vIn.x);\n" - << "\t\t ro = sqrt(SQR(vIn.x - xo) + SQR(vIn.y));\n" + << "\t\t real_t xmx = vIn.x - xo;\n" + << "\t\t ro = sqrt(fma(xmx, xmx, y2));\n" << "\t\t theta = atan2(1, ro);\n" - << "\t\t a = fmod(" << in << " * theta + atan2(vIn.y, xo - vIn.x) + theta, 2 * theta) - theta;\n" + << "\t\t a = fmod(fma(" << in << ", theta, atan2(vIn.y, xo - vIn.x) + theta), 2 * theta) - theta;\n" << "\t\t s = sin(a);\n" << "\t\t c = cos(a);\n" << "\n" @@ -3969,9 +3978,10 @@ public: << "\t\t else\n" << "\t\t {\n" << "\t\t xo = - (r + 1) / (2 * vIn.x);\n" - << "\t\t ro = sqrt(SQR(-vIn.x - xo) + SQR(vIn.y));\n" + << "\t\t real_t mxmx = -vIn.x - xo;\n" + << "\t\t ro = sqrt(fma(mxmx, mxmx, y2));\n" << "\t\t theta = atan2(1 , ro);\n" - << "\t\t a = fmod(" << in << " * theta + atan2(vIn.y, xo + vIn.x) + theta, 2 * theta) - theta;\n" + << "\t\t a = fmod(fma(" << in << ", theta, atan2(vIn.y, xo + vIn.x) + theta), 2 * theta) - theta;\n" << "\t\t s = sin(a);\n" << "\t\t c = cos(a);\n" << "\n" @@ -3986,13 +3996,17 @@ public: << "\t\t tc = cos(precalcAtanyx);\n" << "\t\t x = r * tc;\n" << "\t\t y = r * ts;\n" + << "\t\t real_t x2 = SQR(x);\n" + << "\t\t real_t y2 = SQR(y);\n" + << "\t\t real_t x2y2 = x2 + y2;\n" << "\n" << "\t\t if (x >= 0)\n" << "\t\t {\n" - << "\t\t xo = (SQR(x) + SQR(y) + 1) / Zeps(2 * x);\n" - << "\t\t ro = sqrt(SQR(x - xo) + SQR(y));\n" - << "\t\t theta = atan2(1 , ro);\n" - << "\t\t a = fmod(" << out << " * theta + atan2(y, xo - x) + theta, 2 * theta) - theta;\n" + << "\t\t xo = (x2y2 + 1) / Zeps(2 * x);\n" + << "\t\t real_t xmx = x - xo;\n" + << "\t\t ro = sqrt(fma(xmx, xmx, y2));\n" + << "\t\t theta = atan2(1, ro);\n" + << "\t\t a = fmod(fma(" << out << ", theta, atan2(y, xo - x) + theta), 2 * theta) - theta;\n" << "\t\t s = sin(a);\n" << "\t\t c = cos(a);\n" << "\n" @@ -4001,17 +4015,18 @@ public: << "\t\t theta = atan2(y, x);\n" << "\t\t ts = sin(theta);\n" << "\t\t tc = cos(theta);\n" - << "\t\t r = 1 / sqrt(SQR(x) + SQR(y));\n" + << "\t\t r = 1 / sqrt(fma(x, x, SQR(y)));\n" << "\n" << "\t\t vOut.x = " << weight << " * r * tc;\n" << "\t\t vOut.y = " << weight << " * r * ts;\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t xo = - (SQR(x) + SQR(y) + 1) / (2 * x);\n" - << "\t\t ro = sqrt(SQR(-x - xo) + SQR(y));\n" + << "\t\t xo = -(x2y2 + 1) / (2 * x);\n" + << "\t\t real_t mxmx = -x - xo;\n" + << "\t\t ro = sqrt(fma(mxmx, mxmx, y2));\n" << "\t\t theta = atan2(1 , ro);\n" - << "\t\t a = fmod(" << out << " * theta + atan2(y, xo + x) + theta, 2 * theta) - theta;\n" + << "\t\t a = fmod(fma(" << out << ", theta, atan2(y, xo + x) + theta), 2 * theta) - theta;\n" << "\t\t s = sin(a);\n" << "\t\t c = cos(a);\n" << "\n" @@ -4020,7 +4035,7 @@ public: << "\t\t theta = atan2(y, x);\n" << "\t\t ts = sin(theta);\n" << "\t\t tc = cos(theta);\n" - << "\t\t r = 1 / sqrt(SQR(x) + SQR(y));\n" + << "\t\t r = 1 / sqrt(fma(x, x, SQR(y)));\n" << "\n" << "\t\t vOut.x = -(" << weight << " * r * tc);\n" << "\t\t vOut.y = " << weight << " * r * ts;\n" @@ -4067,10 +4082,18 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T x = m_C1x + (SQR(m_C1r) * (helper.In.x - m_C1x)) / Zeps(Sqr(helper.In.x - m_C1x) + Sqr(helper.In.y - m_C1y)); - T y = m_C1y + (SQR(m_C1r) * (helper.In.y - m_C1y)) / Zeps(Sqr(helper.In.x - m_C1x) + Sqr(helper.In.y - m_C1y)); - helper.Out.x = m_C2x + (SQR(m_C2r) * (x - m_C2x)) / Zeps(Sqr(x - m_C2x) + Sqr(y - m_C2y)); - helper.Out.y = m_C2y + (SQR(m_C2r) * (y - m_C2y)) / Zeps(Sqr(x - m_C2x) + Sqr(y - m_C2y)); + T xmc1x = helper.In.x - m_C1x; + T ymc1y = helper.In.y - m_C1y; + T den = Zeps(SQR(xmc1x) + SQR(ymc1y)); + T c1r2 = SQR(m_C1r); + T x = m_C1x + (c1r2 * xmc1x) / den; + T y = m_C1y + (c1r2 * ymc1y) / den; + T xmc2x = x - m_C2x; + T ymc2y = y - m_C2y; + T c2r2 = SQR(m_C2r); + den = Zeps(SQR(xmc2x) + SQR(ymc2y)); + helper.Out.x = m_C2x + (c2r2 * xmc2x) / den; + helper.Out.y = m_C2y + (c2r2 * ymc2y) / den; helper.Out.z = DefaultZ(helper); } @@ -4092,11 +4115,19 @@ public: string c1d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t x = " << c1x << " + (SQR(" << c1r << ") * (vIn.x - " << c1x << ")) / Zeps(Sqr(vIn.x - " << c1x << ") + Sqr(vIn.y - " << c1y << "));\n" - << "\t\treal_t y = " << c1y << " + (SQR(" << c1r << ") * (vIn.y - " << c1y << ")) / Zeps(Sqr(vIn.x - " << c1x << ") + Sqr(vIn.y - " << c1y << "));\n" + << "\t\treal_t xmc1x = vIn.x - " << c1x << ";\n" + << "\t\treal_t ymc1y = vIn.y - " << c1y << ";\n" + << "\t\treal_t den = Zeps(fma(xmc1x, xmc1x, SQR(ymc1y)));\n" + << "\t\treal_t c1r2 = SQR(" << c1r << ");\n" + << "\t\treal_t x = " << c1x << " + (c1r2 * xmc1x) / den;\n" + << "\t\treal_t y = " << c1y << " + (c1r2 * ymc1y) / den;\n" << "\n" - << "\t\tvOut.x = " << c2x << " + (SQR(" << c2r << ") * (x - " << c2x << ")) / Zeps(Sqr(x - " << c2x << ") + Sqr(y - " << c2y << "));\n" - << "\t\tvOut.y = " << c2y << " + (SQR(" << c2r << ") * (y - " << c2y << ")) / Zeps(Sqr(x - " << c2x << ") + Sqr(y - " << c2y << "));\n" + << "\t\treal_t xmc2x = x - " << c2x << ";\n" + << "\t\treal_t ymc2y = y - " << c2y << ";\n" + << "\t\treal_t c2r2 = SQR(" << c2r << ");\n" + << "\t\tden = Zeps(fma(xmc2x, xmc2x, SQR(ymc2y)));\n" + << "\t\tvOut.x = " << c2x << " + (c2r2 * xmc2x) / den;\n" + << "\t\tvOut.y = " << c2y << " + (c2r2 * ymc2y) / den;\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -4181,13 +4212,13 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; @@ -4195,16 +4226,16 @@ public: string s2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t r2 = precalcSumSquares + SQR(vIn.z);\n" + << "\t\treal_t r2 = fma(vIn.z, vIn.z, precalcSumSquares);\n" << "\t\treal_t x2cx = " << c2x << " * vIn.x;\n" << "\t\treal_t y2cy = " << c2y << " * vIn.y;\n" << "\t\treal_t z2cz = " << c2z << " * vIn.z;\n" << "\t\treal_t val = Zeps(" << c2 << " * r2 - x2cx - y2cy - z2cz + (real_t)(1.0));\n" << "\t\treal_t d = " << weight << " / val;\n" << "\n" - << "\t\tvOut.x = d * (vIn.x * " << s2x << " + " << cx << " * (y2cy + z2cz - r2 - (real_t)(1.0)));\n" - << "\t\tvOut.y = d * (vIn.y * " << s2y << " + " << cy << " * (x2cx + z2cz - r2 - (real_t)(1.0)));\n" - << "\t\tvOut.z = d * (vIn.z * " << s2z << " + " << cz << " * (y2cy + x2cx - r2 - (real_t)(1.0)));\n" + << "\t\tvOut.x = d * fma(vIn.x, " << s2x << ", " << cx << " * (y2cy + z2cz - r2 - (real_t)(1.0)));\n" + << "\t\tvOut.y = d * fma(vIn.y, " << s2y << ", " << cy << " * (x2cx + z2cz - r2 - (real_t)(1.0)));\n" + << "\t\tvOut.z = d * fma(vIn.z, " << s2z << ", " << cz << " * (y2cy + x2cx - r2 - (real_t)(1.0)));\n" << "\t}\n"; return ss.str(); } @@ -4296,17 +4327,17 @@ public: string weight = WeightDefineString(); string powx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string powy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lcx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lcy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lcx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lcy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t xp = pow(fabs(" << weight << ") * fabs(vIn.x), " << powx << ");\n" << "\t\treal_t yp = pow(fabs(" << weight << ") * fabs(vIn.y), " << powy << ");\n" << "\t\treal_t zp = " << weight << " * vIn.z;\n" << "\n" - << "\t\tvOut.x = xp * Sign(vIn.x) + " << lcx << " * vIn.x + " << scx << ";\n" - << "\t\tvOut.y = yp * Sign(vIn.y) + " << lcy << " * vIn.y + " << scy << ";\n" + << "\t\tvOut.x = fma(xp, Sign(vIn.x), fma(" << lcx << ", vIn.x, " << scx << "));\n" + << "\t\tvOut.y = fma(yp, Sign(vIn.y), fma(" << lcy << ", vIn.y, " << scy << "));\n" << "\t\tvOut.z = zp;\n" << "\t}\n"; return ss.str(); @@ -4460,16 +4491,16 @@ public: << "\t\treal_t xcb = vIn.x * vIn.x * vIn.x;\n" << "\t\treal_t ycb = vIn.y * vIn.y * vIn.y;\n" << "\n" - << "\t\treal_t tr = " << t3 << " * (xcb - 3 * vIn.x * ysqr) + " << t2 << " * (xsqr - ysqr) + " << t1 << " * vIn.x + " << tc << ";\n" - << "\t\treal_t ti = " << t3 << " * (3 * xsqr * vIn.y - ycb) + " << t2 << " * 2 * vIn.x * vIn.y + " << t1 << " * vIn.y;\n" + << "\t\treal_t tr = fma(" << t3 << ", (xcb - 3 * vIn.x * ysqr), fma(" << t2 << ", (xsqr - ysqr), fma(" << t1 << ", vIn.x, " << tc << ")));\n" + << "\t\treal_t ti = fma(" << t3 << ", (3 * xsqr * vIn.y - ycb), fma(" << t2 << " * 2, vIn.x * vIn.y, " << t1 << " * vIn.y));\n" << "\n" - << "\t\treal_t br = " << b3 << " * (xcb - 3 * vIn.x * ysqr) + " << b2 << " * (xsqr - ysqr) + " << b1 << " * vIn.x + " << bc << ";\n" - << "\t\treal_t bi = " << b3 << " * (3 * xsqr * vIn.y - ycb) + " << b2 << " * 2 * vIn.x * vIn.y + " << b1 << " * vIn.y;\n" + << "\t\treal_t br = fma(" << b3 << ", (xcb - 3 * vIn.x * ysqr), fma(" << b2 << ", (xsqr - ysqr), fma(" << b1 << ", vIn.x, " << bc << ")));\n" + << "\t\treal_t bi = fma(" << b3 << ", (3 * xsqr * vIn.y - ycb), fma(" << b2 << ", 2 * vIn.x * vIn.y, " << b1 << " * vIn.y));\n" << "\n" - << "\t\treal_t r3den = 1 / Zeps(br * br + bi * bi);\n" + << "\t\treal_t r3den = 1 / Zeps(fma(br, br, bi * bi));\n" << "\n" - << "\t\tvOut.x = " << weight << " * (tr * br + ti * bi) * r3den;\n" - << "\t\tvOut.y = " << weight << " * (ti * br - tr * bi) * r3den;\n" + << "\t\tvOut.x = " << weight << " * fma(tr, br, ti * bi) * r3den;\n" + << "\t\tvOut.y = " << weight << " * fma(ti, br, -(tr * bi)) * r3den;\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -4556,38 +4587,38 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string frequency = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string velocity = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string velocity = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string amplitude = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centerx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centery = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string phase = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string is = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string vxp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string pxa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string pixa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centerx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centery = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string phase = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string is = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string vxp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pxa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pixa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t x = (vIn.x * " << s << ") - " << centerx << ";\n" - << "\t\treal_t y = (vIn.y * " << s << ") + " << centery << ";\n" + << "\t\treal_t x = fma(vIn.x, " << s << ", -" << centerx << ");\n" + << "\t\treal_t y = fma(vIn.y, " << s << ", " << centery << ");\n" << "\n" << "\t\treal_t d = max(EPS, sqrt(SQR(x) * SQR(y)));\n" << "\n" << "\t\treal_t nx = x / d;\n" << "\t\treal_t ny = y / d;\n" << "\n" - << "\t\treal_t wave = cos(" << f << " * d - " << vxp << ");\n" + << "\t\treal_t wave = cos(fma(" << f << ", d, -" << vxp << "));\n" << "\n" - << "\t\treal_t d1 = wave * " << pxa << " + d;\n" - << "\t\treal_t d2 = wave * " << pixa << " + d;\n" + << "\t\treal_t d1 = fma(wave, " << pxa << ", d);\n" + << "\t\treal_t d2 = fma(wave, " << pixa << ", d);\n" << "\n" - << "\t\treal_t u1 = " << centerx << " + nx * d1;\n" - << "\t\treal_t v1 = -" << centery << " + ny * d1;\n" - << "\t\treal_t u2 = " << centerx << " + nx * d2;\n" - << "\t\treal_t v2 = -" << centery << " + ny * d2;\n" + << "\t\treal_t u1 = fma(nx, d1, " << centerx << ");\n" + << "\t\treal_t v1 = fma(ny, d1, -" << centery << ");\n" + << "\t\treal_t u2 = fma(nx, d2, " << centerx << ");\n" + << "\t\treal_t v2 = fma(ny, d2, -" << centery << ");\n" << "\n" << "\t\tvOut.x = " << weight << " * Lerp(u1, u2, " << p << ") * " << is << ";\n" << "\t\tvOut.y = " << weight << " * Lerp(v1, v2, " << p << ") * " << is << ";\n" @@ -4932,8 +4963,8 @@ public: << "\n" << "\t\tresult /= divident;\n" << "\n" - << "\t\tvOut.x = " << weight << " * vIn.x + result;\n" - << "\t\tvOut.y = " << weight << " * vIn.y + result;\n" + << "\t\tvOut.x = fma(" << weight << ", vIn.x, result);\n" + << "\t\tvOut.y = fma(" << weight << ", vIn.y, result);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -5092,17 +5123,17 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string freqX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string freqY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scaleX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scaleY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string incX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string incY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string incX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string incY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t angle = (precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << power << ";\n" + << "\t\treal_t angle = fma(M_2PI, (real_t)MwcNextRange(mwc, (uint)" << absn << "), precalcAtanyx) / " << power << ";\n" << "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cn << ");\n" << "\t\treal_t sina = sin(angle);\n" << "\t\treal_t cosa = cos(angle);\n" @@ -5110,8 +5141,8 @@ public: << "\t\treal_t yn = r * sina;\n" << "\t\treal_t siny = sin(" << freqX << " * yn);\n" << "\t\treal_t sinx = sin(" << freqY << " * xn);\n" - << "\t\treal_t dx = xn + (real_t)(0.5) * (" << scaleX << " * siny + fabs(xn) * " << incX << " * siny);\n" - << "\t\treal_t dy = yn + (real_t)(0.5) * (" << scaleY << " * sinx + fabs(yn) * " << incY << " * sinx);\n" + << "\t\treal_t dx = fma((real_t)(0.5), fma(" << scaleX << ", siny, fabs(xn) * " << incX << " * siny), xn);\n" + << "\t\treal_t dy = fma((real_t)(0.5), fma(" << scaleY << ", sinx, fabs(yn) * " << incY << " * sinx), yn);\n" << "\n" << "\t\tvOut.x = " << weight << " * dx;\n" << "\t\tvOut.y = " << weight << " * dy;\n" @@ -5206,9 +5237,9 @@ public: string weight = WeightDefineString(); string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ratio = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rat = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rat = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t r2_4 = precalcSumSquares + 4;\n" << "\n" @@ -5217,8 +5248,10 @@ public: << "\n" << "\t\treal_t bx = 4 / r2_4;\n" << "\t\treal_t by = " << rat << " / r2_4;\n" - << "\t\treal_t x = " << cosa << " * (bx * vIn.x) - " << sina << " * (by * vIn.y);\n" - << "\t\treal_t y = " << sina << " * (bx * vIn.x) + " << cosa << " * (by * vIn.y);\n" + << "\t\treal_t bxx = bx * vIn.x;\n" + << "\t\treal_t byy = by * vIn.y;\n" + << "\t\treal_t x = fma(" << cosa << ", bxx, -(" << sina << " * byy));\n" + << "\t\treal_t y = fma(" << sina << ", bxx, " << cosa << " * byy);\n" << "\n" << "\t\tif (x > 0)\n" << "\t\t{\n" @@ -5311,16 +5344,16 @@ public: string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t dot00 = SQR(" << a << ") + SQR(" << b << ");\n" - << "\t\treal_t dot01 = " << a << " * " << c << " + " << b << " * " << d << ";\n" - << "\t\treal_t dot02 = " << a << " * vIn.x + " << b << " * vIn.y;\n" - << "\t\treal_t dot11 = SQR(" << c << ") + SQR(" << d << ");\n" - << "\t\treal_t dot12 = " << c << " * vIn.x + " << d << " * vIn.y;\n" - << "\t\treal_t invDenom = (real_t)(1.0) / Zeps(dot00 * dot11 - dot01 * dot01);\n" - << "\t\treal_t u = (dot11 * dot02 - dot01 * dot12) * invDenom;\n" - << "\t\treal_t v = (dot00 * dot12 - dot01 * dot02) * invDenom;\n" - << "\t\treal_t um = sqrt(SQR(u) + SQR(vIn.x)) * Sign(u);\n" - << "\t\treal_t vm = sqrt(SQR(v) + SQR(vIn.y)) * Sign(v);\n" + << "\t\treal_t dot00 = fma(" << a << ", " << a << ", SQR(" << b << "));\n" + << "\t\treal_t dot01 = fma(" << a << ", " << c << ", " << b << " * " << d << ");\n" + << "\t\treal_t dot02 = fma(" << a << ", vIn.x, " << b << " * vIn.y);\n" + << "\t\treal_t dot11 = fma(" << c << ", " << c << ", SQR(" << d << "));\n" + << "\t\treal_t dot12 = fma(" << c << ", vIn.x, " << d << " * vIn.y);\n" + << "\t\treal_t invDenom = (real_t)(1.0) / Zeps(fma(dot00, dot11, -(dot01 * dot01)));\n" + << "\t\treal_t u = fma(dot11, dot02, -(dot01 * dot12)) * invDenom;\n" + << "\t\treal_t v = fma(dot00, dot12, -(dot01 * dot02)) * invDenom;\n" + << "\t\treal_t um = sqrt(fma(u, u, SQR(vIn.x))) * Sign(u);\n" + << "\t\treal_t vm = sqrt(fma(v, v, SQR(vIn.y))) * Sign(v);\n" << "\n" << "\t\tvOut.x = " << weight << " * um;\n" << "\t\tvOut.y = " << weight << " * vm;\n" @@ -5566,8 +5599,8 @@ public: << "\t\t a -= " << fullSpread << ";\n" << "\n" << "\t\treal_t lnr2 = log(precalcSumSquares);\n" - << "\t\treal_t r = " << weight << " * exp(" << halfC << " * lnr2 - " << d << " * a);\n" - << "\t\treal_t temp = " << c << " * a + " << halfD << " * lnr2 + " << ang << " * MwcNext(mwc);\n" + << "\t\treal_t r = " << weight << " * exp(fma(" << halfC << ", lnr2, -(" << d << " * a)));\n" + << "\t\treal_t temp = fma(" << c << ", a, fma(" << halfD << ", lnr2, " << ang << " * MwcNext(mwc)));\n" << "\n" << "\t\tvOut.x = r * cos(temp);\n" << "\t\tvOut.y = r * sin(temp);\n" diff --git a/Source/Ember/Variations03.h b/Source/Ember/Variations03.h index 19a88f0..71a8393 100644 --- a/Source/Ember/Variations03.h +++ b/Source/Ember/Variations03.h @@ -35,7 +35,7 @@ public: string weight = WeightDefineString(); string effect = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t temp = 1 / Zeps(cos(vIn.y)) + " << effect << " * MPI;\n" + << "\t\treal_t temp = fma(" << effect << ", MPI, 1 / Zeps(cos(vIn.y)));\n" << "\n" << "\t\tvOut.x = " << weight << " * (tanh(vIn.x) * temp);\n" << "\t\tvOut.y = " << weight << " * (tanh(vIn.y) * temp);\n" @@ -204,7 +204,7 @@ public: string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t u = sqrt(ClampGte(Zeps(" << a << ") * SQR(vIn.x) + Zeps(" << b << ") * SQR(vIn.y), (real_t)(0.0)));\n" + << "\t\treal_t u = sqrt(ClampGte(fma(Zeps(" << a << "), SQR(vIn.x), Zeps(" << b << ") * SQR(vIn.y)), (real_t)(0.0)));\n" << "\n" << "\t\tvOut.x = cos(u) * tan(vIn.x) * " << weight << ";\n" << "\t\tvOut.y = sin(u) * tan(vIn.y) * " << weight << ";\n" @@ -245,8 +245,10 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - helper.Out.x = m_Weight * (helper.In.x - ((SQR(helper.In.x) * helper.In.x) / 3)) + helper.In.x * SQR(helper.In.y); - helper.Out.y = m_Weight * (helper.In.y - ((SQR(helper.In.y) * helper.In.y) / 3)) + helper.In.y * SQR(helper.In.x); + T inxsq = SQR(helper.In.x); + T inysq = SQR(helper.In.y); + helper.Out.x = m_Weight * (helper.In.x - ((inxsq * helper.In.x) / 3)) + helper.In.x * inysq; + helper.Out.y = m_Weight * (helper.In.y - ((inysq * helper.In.y) / 3)) + helper.In.y * inxsq; helper.Out.z = DefaultZ(helper); } @@ -256,8 +258,8 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\tvOut.x = " << weight << " * (vIn.x - ((SQR(vIn.x) * vIn.x) / 3)) + vIn.x * SQR(vIn.y);\n" - << "\t\tvOut.y = " << weight << " * (vIn.y - ((SQR(vIn.y) * vIn.y) / 3)) + vIn.y * SQR(vIn.x);\n" + << "\t\tvOut.x = fma(" << weight << ", (vIn.x - ((SQR(vIn.x) * vIn.x) / 3)), vIn.x * SQR(vIn.y));\n" + << "\t\tvOut.y = fma(" << weight << ", (vIn.y - ((SQR(vIn.y) * vIn.y) / 3)), vIn.y * SQR(vIn.x));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -298,11 +300,11 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t r = Zeps(pow(precalcSqrtSumSquares, " << dist << "));\n" << "\t\tint n = floor(" << power << " * MwcNext01(mwc));\n" - << "\t\treal_t alpha = precalcAtanyx + n * M_2PI / Zeps(floor(" << power << "));\n" + << "\t\treal_t alpha = fma(n, M_2PI / Zeps(floor(" << power << ")), precalcAtanyx);\n" << "\t\treal_t sina = sin(alpha);\n" << "\t\treal_t cosa = cos(alpha);\n" << "\n" @@ -368,21 +370,21 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string pull = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pull = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rotate = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string lineUp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t sin45 = sin(45 * DEG_2_RAD);\n" << "\t\treal_t cos45 = cos(45 * DEG_2_RAD);\n" << "\n" - << "\t\tvOut.x = ((" << rotate << " * vIn.x) * cos45 - vIn.y * sin45 + " << lineUp << ") + " << x << ";\n" + << "\t\tvOut.x = fma(" << rotate << " * vIn.x, cos45, -(vIn.y * sin45) + " << lineUp << ") + " << x << ";\n" << "\n" << "\t\tif (vIn.y > 0)\n" - << "\t\t vOut.y = ((" << rotate << " * vIn.y) * cos45 + vIn.x * sin45 + " << pull << " + " << lineUp << ") + " << y << ";\n" + << "\t\t vOut.y = fma(" << rotate << " * vIn.y, cos45, fma(vIn.x, sin45, " << pull << " + " << lineUp << ")) + " << y << ";\n" << "\t\telse\n" - << "\t\t vOut.y = (" << rotate << " * vIn.y) * cos45 + vIn.x * sin45 - " << pull << " - " << lineUp << ";\n" + << "\t\t vOut.y = fma(" << rotate << " * vIn.y, cos45, fma(vIn.x, sin45, -" << pull << " - " << lineUp << "));\n" << "\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; @@ -444,8 +446,9 @@ public: } else { - x = SQR(alpha) * helper.In.x; - y = SQR(alpha) * helper.In.y; + auto a2 = SQR(alpha); + x = a2 * helper.In.x; + y = a2 * helper.In.y; } z = Sqr(x - m_X1) + Sqr(y - m_Y1); @@ -473,14 +476,14 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string radius1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string phi1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string radius1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string phi1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string thickness = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string contrast = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string pow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string x1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string contrast = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t x, y, z;\n" << "\n" @@ -501,8 +504,9 @@ public: << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t x = SQR(alpha) * vIn.x;\n" - << "\t\t y = SQR(alpha) * vIn.y;\n" + << "\t\t real_t a2 = SQR(alpha);\n" + << "\t\t x = a2 * vIn.x;\n" + << "\t\t y = a2 * vIn.y;\n" << "\t\t }\n" << "\n" << "\t\t z = Sqr(x - " << x1 << ") + Sqr(y - " << y1 << ");\n" @@ -540,8 +544,8 @@ public: " real_t sinPhi = sin(phi);\n" " real_t cosPhi = cos(phi);\n" "\n" - " *x = r * cosPhi + *x1;\n" - " *y = r * sinPhi + *y1;\n" + " *x = fma(r, cosPhi, *x1);\n" + " *y = fma(r, sinPhi, *y1);\n" "}\n" "\n"; } @@ -693,7 +697,7 @@ public: "void GlynnSim2Circle(__constant real_t* radius, __constant real_t* thickness, __constant real_t* phi10, __constant real_t* delta, __constant real_t* gamma, uint2* mwc, real_t* x, real_t* y)\n" "{\n" " real_t r = *radius + *thickness - *gamma * MwcNext01(mwc);\n" - " real_t phi = *phi10 + *delta * MwcNext01(mwc);\n" + " real_t phi = fma(*delta, MwcNext01(mwc), *phi10);\n" " real_t sinPhi = sin(phi);\n" " real_t cosPhi = cos(phi);\n" "\n" @@ -956,10 +960,10 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string range = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string range = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string length = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t f = MwcNext01(mwc) * " << power << " * 2;\n" << "\t\treal_t angle = (real_t)(int)(f);\n" @@ -967,12 +971,12 @@ public: << "\t\tf -= angle;\n" << "\n" << "\t\treal_t x = f * " << length << ";\n" - << "\t\treal_t z = sqrt(1 + SQR(x) - 2 * x * cos(" << alpha << "));\n" + << "\t\treal_t z = sqrt(fma(x, x, (real_t)(1.0)) - 2 * x * cos(" << alpha << "));\n" << "\n" << "\t\tif (((int)angle) & 1)\n" - << "\t\t angle = M_2PI / " << power << " * (((int)angle) / 2) + asin(sin(" << alpha << ") * x / z);\n" + << "\t\t angle = fma(M_2PI / " << power << ", (real_t)(((int)angle) / 2), asin(sin(" << alpha << ") * x / z));\n" << "\t\telse\n" - << "\t\t angle = M_2PI / " << power << " * (((int)angle) / 2) - asin(sin(" << alpha << ") * x / z);\n" + << "\t\t angle = fma(M_2PI / " << power << ", (real_t)(((int)angle) / 2), -asin(sin(" << alpha << ") * x / z));\n" << "\n" << "\t\tz *= sqrt(MwcNext01(mwc));\n" << "\n" @@ -1145,9 +1149,9 @@ public: << "\t\tif (coeff != 0 && " << power << " != 1)\n" << "\t\t coeff = exp(log(coeff) * " << power << ");\n" << "\n" - << "\t\tvOut.x = " << weight << " * (transX + vIn.x * coeff);\n" - << "\t\tvOut.y = " << weight << " * (transY + vIn.y * coeff);\n" - << "\t\tvOut.z = " << weight << " * (transZ + vIn.z * coeff);\n" + << "\t\tvOut.x = " << weight << " * fma(vIn.x, coeff, transX);\n" + << "\t\tvOut.y = " << weight << " * fma(vIn.y, coeff, transY);\n" + << "\t\tvOut.z = " << weight << " * fma(vIn.z, coeff, transZ);\n" << "\t}\n"; return ss.str(); } @@ -1236,7 +1240,7 @@ public: << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t real_t rdc = xr + (MwcNext01(mwc) * (real_t)(0.5) * " << scatterDist << ");\n" + << "\t\t real_t rdc = fma(MwcNext01(mwc), (real_t)(0.5) * " << scatterDist << ", xr);\n" << "\n" << "\t\t vOut.x = " << weight << " * rdc * cos(precalcAtanyx);\n" << "\t\t vOut.y = " << weight << " * rdc * sin(precalcAtanyx);\n" @@ -1313,12 +1317,12 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t xang = (precalcAtanyx + M_3PI + " << alpha << " / 2) / " << alpha << ";\n" - << "\t\treal_t zang = ((xang - (int)xang) * " << width << " + (int)xang) * " << alpha << " - MPI - " << alpha << " / 2 * " << width << ";\n" + << "\t\treal_t zang = fma((xang - (int)xang) * " << width << " + (int)xang, " << alpha << ", -MPI) - " << alpha << " / 2 * " << width << ";\n" << "\n" << "\t\tvOut.x = " << weight << " * precalcSqrtSumSquares * cos(zang);\n" << "\t\tvOut.y = " << weight << " * precalcSqrtSumSquares * sin(zang);\n" @@ -1418,7 +1422,7 @@ public: << "\t\t else\n" << "\t\t delta = exp(" << prescale << " * log(delta * positive)) * " << postscale << " * positive;\n" << "\n" - << "\t\t real_t rad = " << radius << " + (precalcSqrtSumSquares - " << radius << ") * delta;\n" + << "\t\t real_t rad = fma(precalcSqrtSumSquares - " << radius << ", delta, " << radius << ");\n" << "\n" << "\t\t vOut.x = " << weight << " * rad * cos(precalcAtanyx);\n" << "\t\t vOut.y = " << weight << " * rad * sin(precalcAtanyx);\n" @@ -1492,14 +1496,14 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t z = vIn.z / " << absn << ";\n" - << "\t\treal_t r = " << weight << " * pow(precalcSumSquares + SQR(z), " << cn << ");\n" + << "\t\treal_t r = " << weight << " * pow(fma(z, z, precalcSumSquares), " << cn << ");\n" << "\t\treal_t tmp = r * precalcSqrtSumSquares;\n" - << "\t\treal_t ang = (precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << n << ";\n" + << "\t\treal_t ang = fma(M_2PI, (real_t)MwcNextRange(mwc, (uint)" << absn << "), precalcAtanyx) / " << n << ";\n" << "\n" << "\t\tvOut.x = tmp * cos(ang);\n" << "\t\tvOut.y = tmp * sin(ang);\n" @@ -1573,7 +1577,7 @@ public: string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cn << ");\n" - << "\t\treal_t temp = (precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << n << ";\n" + << "\t\treal_t temp = fma(M_2PI, (real_t)MwcNextRange(mwc, (uint)" << absn << "), precalcAtanyx) / " << n << ";\n" << "\n" << "\t\tvOut.x = r * cos(temp);\n" << "\t\tvOut.y = r * sin(temp);\n" @@ -1817,7 +1821,7 @@ public: string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t r = " << weight << " / Zeps(precalcSumSquares + SQR(vIn.z));\n" + << "\t\treal_t r = " << weight << " / Zeps(fma(vIn.z, vIn.z, precalcSumSquares));\n" << "\n" << "\t\tvOut.x = vIn.x * r * " << x << ";\n" << "\t\tvOut.y = vIn.y * r * " << y << ";\n" @@ -1865,8 +1869,10 @@ public: { T t = (m_TMax - m_TMin) * rand.Frand01() + m_TMin; T y = (m_YMax - m_YMin) * rand.Frand01() + m_YMin; - T x1 = (m_A + m_B) * std::cos(t) - m_C1 * std::cos((m_A + m_B) / m_B * t); - T y1 = (m_A + m_B) * std::sin(t) - m_C2 * std::sin((m_A + m_B) / m_B * t); + T ab = m_A + m_B; + T abdivbt = ab / m_B * t; + T x1 = ab * std::cos(t) - m_C1 * std::cos(abdivbt); + T y1 = ab * std::sin(t) - m_C2 * std::sin(abdivbt); helper.Out.x = m_Weight * (x1 + m_D * std::cos(t) + y); helper.Out.y = m_Weight * (y1 + m_D * std::sin(t) + y); helper.Out.z = DefaultZ(helper); @@ -1879,23 +1885,25 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string tmin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ymin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string tmax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ymax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t t = (" << tmax << " - " << tmin << ") * MwcNext01(mwc) + " << tmin << ";\n" - << "\t\treal_t y = (" << ymax << " - " << ymin << ") * MwcNext01(mwc) + " << ymin << ";\n" - << "\t\treal_t x1 = (" << a << " + " << b << ") * cos(t) - " << c1 << " * cos((" << a << " + " << b << ") / " << b << " * t);\n" - << "\t\treal_t y1 = (" << a << " + " << b << ") * sin(t) - " << c2 << " * sin((" << a << " + " << b << ") / " << b << " * t);\n" + << "\t\treal_t t = fma(" << tmax << " - " << tmin << ", MwcNext01(mwc), " << tmin << ");\n" + << "\t\treal_t y = fma(" << ymax << " - " << ymin << ", MwcNext01(mwc), " << ymin << ");\n" + << "\t\treal_t ab = " << a << " + " << b << ";\n" + << "\t\treal_t abdivbt = ab / " << b << " * t;\n" + << "\t\treal_t x1 = fma(ab, cos(t), -(" << c1 << " * cos(abdivbt)));\n" + << "\t\treal_t y1 = fma(ab, sin(t), -(" << c2 << " * sin(abdivbt)));\n" << "\n" - << "\t\tvOut.x = " << weight << " * (x1 + " << d << " * cos(t) + y);\n" - << "\t\tvOut.y = " << weight << " * (y1 + " << d << " * sin(t) + y);\n" + << "\t\tvOut.x = " << weight << " * fma(" << d << ", cos(t), x1 + y);\n" + << "\t\tvOut.y = " << weight << " * fma(" << d << ", sin(t), y1 + y);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -2003,7 +2011,7 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t e = 1 / precalcSumSquares + SQR(M2PI);\n" + << "\t\treal_t e = fma(M2PI, M2PI, 1 / precalcSumSquares);\n" << "\n" << "\t\tvOut.x = " << weight << " * (" << weight << " / precalcSumSquares * vIn.x / e);\n" << "\t\tvOut.y = " << weight << " * (" << weight << " / precalcSumSquares * vIn.y / e);\n" @@ -2011,6 +2019,11 @@ public: << "\t}\n"; return ss.str(); } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Zeps" }; + } }; /// @@ -2122,8 +2135,8 @@ public: ss << "\t\t}\n" << "\n" - << "\t\treal_t d = precalcSumSquares + SQR(tempTz);\n" - << "\t\treal_t e = 1 / d + SQR(M2PI);\n" + << "\t\treal_t d = fma(tempTz, tempTz, precalcSumSquares);\n" + << "\t\treal_t e = fma(M2PI, M2PI, 1 / d);\n" << "\n" << "\t\tvOut.x = " << weight << " * (" << weight << " / d * vIn.x / e);\n" << "\t\tvOut.y = " << weight << " * (" << weight << " / d * vIn.y / e);\n" @@ -2324,17 +2337,17 @@ public: << "\n" << "\t\tif (isXY & 1)\n" << "\t\t{\n" - << "\t\t dx = -" << x << " + " << rand << " * MwcNext01(mwc);\n" + << "\t\t dx = fma(" << rand << ", MwcNext01(mwc), -" << x << ");\n" << "\t\t dy = -" << y << ";\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t dx = " << x << ";\n" - << "\t\t dy = " << y << " + " << rand << " * MwcNext01(mwc);\n" + << "\t\t dy = fma(" << rand << ", MwcNext01(mwc), " << y << ");\n" << "\t\t}\n" << "\n" - << "\t\tvOut.x = " << weight << " * (sin(vIn.x) * r + dx);\n" - << "\t\tvOut.y = " << weight << " * (sin(vIn.y) * r + dy);\n" + << "\t\tvOut.x = " << weight << " * fma(sin(vIn.x), r, dx);\n" + << "\t\tvOut.y = " << weight << " * fma(sin(vIn.y), r, dy);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -2402,17 +2415,17 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string xDistort = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string yDistort = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string inv2PiN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string inv2PiN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t preX = vIn.x * (" << xDistort << " + 1);\n" << "\t\treal_t preY = vIn.y * (" << yDistort << " + 1);\n" - << "\t\treal_t temp = atan2(preY, preX) * " << invN << " + MwcNext(mwc) * " << inv2PiN << ";\n" + << "\t\treal_t temp = fma(atan2(preY, preX), " << invN << ", MwcNext(mwc) * " << inv2PiN << ");\n" << "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cN << ");\n" << "\n" << "\t\tvOut.x = r * cos(temp);\n" @@ -2496,14 +2509,14 @@ public: string reD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string imD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t uRe = " << reA << " * vIn.x - " << imA << " * vIn.y + " << reB << ";\n" - << "\t\treal_t uIm = " << reA << " * vIn.y + " << imA << " * vIn.x + " << imB << ";\n" - << "\t\treal_t vRe = " << reC << " * vIn.x - " << imC << " * vIn.y + " << reD << ";\n" - << "\t\treal_t vIm = " << reC << " * vIn.y + " << imC << " * vIn.x + " << imD << ";\n" - << "\t\treal_t vDenom = Zeps(vRe * vRe + vIm * vIm);\n" + << "\t\treal_t uRe = fma(" << reA << ", vIn.x, -(" << imA << " * vIn.y) + " << reB << ");\n" + << "\t\treal_t uIm = fma(" << reA << ", vIn.y, fma(" << imA << ", vIn.x, " << imB << "));\n" + << "\t\treal_t vRe = fma(" << reC << ", vIn.x, -(" << imC << " * vIn.y) + " << reD << ");\n" + << "\t\treal_t vIm = fma(" << reC << ", vIn.y, fma(" << imC << ", vIn.x, " << imD << "));\n" + << "\t\treal_t vDenom = Zeps(fma(vRe, vRe, SQR(vIm)));\n" << "\n" - << "\t\tvOut.x = " << weight << " * (uRe * vRe + uIm * vIm) / vDenom;\n" - << "\t\tvOut.y = " << weight << " * (uIm * vRe - uRe * vIm) / vDenom;\n" + << "\t\tvOut.x = " << weight << " * fma(uRe, vRe, uIm * vIm) / vDenom;\n" + << "\t\tvOut.y = " << weight << " * fma(uIm, vRe, -(uRe * vIm)) / vDenom;\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t}\n"; return ss.str(); @@ -2585,16 +2598,16 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string reA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string imA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string reB = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string imB = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string reC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string imC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string reD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string imD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string reA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string imA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string reB = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string imB = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string reC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string imC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string reD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string imD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tint n;\n" << "\n" @@ -2603,19 +2616,19 @@ public: << "\t\treal_t alpha = precalcAtanyx * " << power << ";\n" << "\t\treal_t x = r * cos(alpha);\n" << "\t\treal_t y = r * sin(alpha);\n" - << "\t\treal_t reU = " << reA << " * x - " << imA << " * y + " << reB << ";\n" - << "\t\treal_t imU = " << reA << " * y + " << imA << " * x + " << imB << ";\n" - << "\t\treal_t reV = " << reC << " * x - " << imC << " * y + " << reD << ";\n" - << "\t\treal_t imV = " << reC << " * y + " << imC << " * x + " << imD << ";\n" - << "\t\treal_t radV = reV * reV + imV * imV;\n" + << "\t\treal_t reU = fma(" << reA << ", x, -(" << imA << " * y) + " << reB << ");\n" + << "\t\treal_t imU = fma(" << reA << ", y, fma(" << imA << ", x, " << imB << "));\n" + << "\t\treal_t reV = fma(" << reC << ", x, -(" << imC << " * y) + " << reD << ");\n" + << "\t\treal_t imV = fma(" << reC << ", y, fma(" << imC << ", x, " << imD << "));\n" + << "\t\treal_t radV = fma(reV, reV, SQR(imV));\n" << "\n" - << "\t\tx = (reU * reV + imU * imV) / radV;\n" - << "\t\ty = (imU * reV - reU * imV) / radV;\n" + << "\t\tx = fma(reU, reV, imU * imV) / radV;\n" + << "\t\ty = fma(imU, reV, -(reU * imV)) / radV;\n" << "\n" << "\t\tz = (real_t)(1.0) / z;\n" - << "\t\tr = pow(sqrt(SQR(x) + SQR(y)), z);\n" + << "\t\tr = pow(sqrt(fma(x, x, SQR(y))), z);\n" << "\t\tn = (int)floor(" << power << " * MwcNext01(mwc));\n" - << "\t\talpha = (atan2(y, x) + n * M_2PI) / floor(" << power << ");\n" + << "\t\talpha = fma((real_t)n, M_2PI, atan2(y, x)) / floor(" << power << ");\n" << "\n" << "\t\tvOut.x = " << weight << " * r * cos(alpha);\n" << "\t\tvOut.y = " << weight << " * r * sin(alpha);\n" @@ -2733,10 +2746,10 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rectX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rectY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rectX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rectY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rotateX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rotateY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rotxSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; @@ -2770,20 +2783,20 @@ public: << "\t\t{\n" << "\t\t deltaS = (s + " << rectY << ") / (2 * " << rectY << ");\n" << "\t\t deltaS -= floor(deltaS);\n" - << "\t\t s = 2 * " << width << " * deltaS - " << width << ";\n" + << "\t\t s = fma((real_t)(2.0) * " << width << ", deltaS, -" << width << ");\n" << "\t\t}\n" << "\n" - << "\t\tmx = (" << radius << " + s * cos(t / 2)) * cos(t);\n" - << "\t\tmy = (" << radius << " + s * cos(t / 2)) * sin(t);\n" + << "\t\tmx = fma(s, cos(t / 2), " << radius << ") * cos(t);\n" + << "\t\tmy = fma(s, cos(t / 2), " << radius << ") * sin(t);\n" << "\t\tmz = s * sin(t / 2);\n" << "\n" << "\t\trx = mx;\n" - << "\t\try = my * " << rotyCos << " + mz * " << rotySin << ";\n" - << "\t\trz = mz * " << rotyCos << " - my * " << rotySin << ";\n" + << "\t\try = fma(my, " << rotyCos << ", mz * " << rotySin << ");\n" + << "\t\trz = fma(mz, " << rotyCos << ", -(my * " << rotySin << "));\n" << "\n" - << "\t\tmx = rx * " << rotxCos << " - rz * " << rotxSin << ";\n" + << "\t\tmx = fma(rx, " << rotxCos << ", -(rz * " << rotxSin << "));\n" << "\t\tmy = ry;\n" - << "\t\tmz = rz * " << rotxCos << " + rx * " << rotxSin << ";\n" + << "\t\tmz = fma(rz, " << rotxCos << ", rx * " << rotxSin << ");\n" << "\n" << "\t\tvOut.x = " << weight << " * mx;\n" << "\t\tvOut.y = " << weight << " * my;\n" @@ -2864,19 +2877,19 @@ public: string weight = WeightDefineString(); string min = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string max = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string e = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string e = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t t = (" << max << " - " << min << ") * MwcNext01(mwc) + " << min << ";\n" + << "\t\treal_t t = fma(" << max << " - " << min << ", MwcNext01(mwc), " << min << ");\n" << "\t\treal_t y = MwcNext01(mwc) - (real_t)(0.5);\n" - << "\t\treal_t x1 = sin(" << a << " * t + " << d << ");\n" + << "\t\treal_t x1 = sin(fma(" << a << ", t, " << d << "));\n" << "\t\treal_t y1 = sin(" << b << " * t);\n" << "\n" - << "\t\tvOut.x = " << weight << " * (x1 + " << c << " * t + " << e << " * y);\n" - << "\t\tvOut.y = " << weight << " * (y1 + " << c << " * t + " << e << " * y);\n" + << "\t\tvOut.x = " << weight << " * fma(" << c << ", t, fma(" << e << ", y, x1));\n" + << "\t\tvOut.y = " << weight << " * fma(" << c << ", t, fma(" << e << ", y, y1));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -3088,11 +3101,11 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string inv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sor = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invTimesR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string inv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sor = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invTimesR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string oneMinusInv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string oneMinusSor = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" @@ -3100,11 +3113,11 @@ public: << "\t\treal_t cx = cos(vIn.x);\n" << "\t\treal_t sy = sin(vIn.y);\n" << "\t\treal_t cy = cos(vIn.y);\n" - << "\t\treal_t ir = " << invTimesR << " + (" << oneMinusInv << " * (" << r << " * cos(" << n << " * vIn.x)));\n" + << "\t\treal_t ir = fma(" << oneMinusInv << ", " << r << " * cos(" << n << " * vIn.x), " << invTimesR << ");\n" << "\n" << "\t\tvOut.x = " << weight << " * (cx * (ir + sy));\n" << "\t\tvOut.y = " << weight << " * (sx * (ir + sy));\n" - << "\t\tvOut.z = " << weight << " * (" << sor << " * cy) + (" << oneMinusSor << " * vIn.y);\n" + << "\t\tvOut.z = fma(" << weight << ", " << sor << " * cy, " << oneMinusSor << " * vIn.y);\n" << "\t}\n"; return ss.str(); } @@ -3207,18 +3220,18 @@ public: << "\t\t alt = (int)(a * " << knpi << ");\n" << "\n" << "\t\t if ((alt & 1) == 0)\n" - << "\t\t a = alt * " << pikn << " + fmod(" << kakn << " + a, " << pikn << ");\n" + << "\t\t a = fma((real_t)alt, " << pikn << ", fmod(" << kakn << " + a, " << pikn << "));\n" << "\t\t else\n" - << "\t\t a = alt * " << pikn << " + fmod(-" << kakn << " + a, " << pikn << ");\n" + << "\t\t a = fma((real_t)alt, " << pikn << ", fmod(-" << kakn << " + a, " << pikn << "));\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t alt = (int)(-a * " << knpi << ");\n" << "\n" << "\t\t if ((alt & 1) == 1)\n" - << "\t\t a = -(alt * " << pikn << " + fmod(-" << kakn << " - a, " << pikn << "));\n" + << "\t\t a = -fma((real_t)alt, " << pikn << ", fmod(-" << kakn << " - a, " << pikn << "));\n" << "\t\t else\n" - << "\t\t a = -(alt * " << pikn << " + fmod(" << kakn << " - a, " << pikn << "));\n" + << "\t\t a = -fma((real_t)alt, " << pikn << ", fmod(" << kakn << " - a, " << pikn << "));\n" << "\t\t}\n" << "\n" << "\t\tvOut.x = r * cos(a);\n" @@ -3275,13 +3288,15 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T tau = T(0.5) * (std::log(Sqr(helper.In.x + 1) + SQR(helper.In.y)) - std::log(Sqr(helper.In.x - 1) + SQR(helper.In.y))); - T sigma = T(M_PI) - std::atan2(helper.In.y, helper.In.x + 1) - std::atan2(helper.In.y, 1 - helper.In.x); + T xp1 = helper.In.x + 1; + T inysq = SQR(helper.In.y); + T tau = T(0.5) * (std::log(SQR(xp1) + inysq) - std::log(Sqr(helper.In.x - 1) + inysq)); + T sigma = T(M_PI) - std::atan2(helper.In.y, xp1) - std::atan2(helper.In.y, 1 - helper.In.x); if (tau < m_Radius && -tau < m_Radius) tau = fmod(tau + m_Radius + m_Distance * m_Radius, 2 * m_Radius) - m_Radius; - T temp = std::cosh(tau) - std::cos(sigma); + T temp = Zeps(std::cosh(tau) - std::cos(sigma)); helper.Out.x = m_Weight * std::sinh(tau) / temp; helper.Out.y = m_Weight * std::sin(sigma) / temp; helper.Out.z = DefaultZ(helper); @@ -3295,15 +3310,18 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t tau = (real_t)(0.5) * (log(Sqr(vIn.x + (real_t)(1.0)) + SQR(vIn.y)) - log(Sqr(vIn.x - (real_t)(1.0)) + SQR(vIn.y)));\n" - << "\t\treal_t sigma = MPI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n" + << "\t\treal_t xp1 = vIn.x + (real_t)(1.0);\n" + << "\t\treal_t xm1 = vIn.x - (real_t)(1.0);\n" + << "\t\treal_t inysq = SQR(vIn.y);\n" + << "\t\treal_t tau = (real_t)(0.5) * (log(fma(xp1, xp1, inysq)) - log(fma(xm1, xm1, inysq)));\n" + << "\t\treal_t sigma = MPI - atan2(vIn.y, xp1) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n" << "\n" << "\t\tif (tau < " << radius << " && -tau < " << radius << ")\n" - << "\t\t tau = fmod(tau + " << radius << " + " << dist << " * " << radius << ", (real_t)(2.0) * " << radius << ") - " << radius << ";\n" + << "\t\t tau = fmod(fma(" << dist << ", " << radius << ", tau + " << radius << "), (real_t)(2.0) * " << radius << ") - " << radius << ";\n" << "\n" - << "\t\treal_t temp = cosh(tau) - cos(sigma);\n" + << "\t\treal_t temp = Zeps(cosh(tau) - cos(sigma));\n" << "\n" << "\t\tvOut.x = " << weight << " * sinh(tau) / temp;\n" << "\t\tvOut.y = " << weight << " * sin(sigma) / temp;\n" @@ -3314,7 +3332,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr" }; + return vector { "Sqr", "Zeps" }; } protected: @@ -3347,10 +3365,12 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T tau = T(0.5) * (std::log(Sqr(helper.In.x + 1) + SQR(helper.In.y)) - std::log(Sqr(helper.In.x - 1) + SQR(helper.In.y))); - T sigma = T(M_PI) - std::atan2(helper.In.y, helper.In.x + 1) - std::atan2(helper.In.y, 1 - helper.In.x); - sigma = sigma + tau * m_Out + m_In / tau; - T temp = std::cosh(tau) - std::cos(sigma); + T xp1 = helper.In.x + 1; + T inysq = SQR(helper.In.y); + T tau = T(0.5) * (std::log(SQR(xp1) + inysq) - std::log(Sqr(helper.In.x - 1) + inysq)); + T sigma = T(M_PI) - std::atan2(helper.In.y, xp1) - std::atan2(helper.In.y, 1 - helper.In.x); + sigma = sigma + tau * m_Out + m_In / Zeps(tau); + T temp = Zeps(std::cosh(tau) - std::cos(sigma)); helper.Out.x = m_Weight * std::sinh(tau) / temp; helper.Out.y = m_Weight * std::sin(sigma) / temp; helper.Out.z = DefaultZ(helper); @@ -3363,15 +3383,18 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string in = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string in = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string out = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t tau = (real_t)(0.5) * (log(Sqr(vIn.x + (real_t)(1.0)) + SQR(vIn.y)) - log(Sqr(vIn.x - (real_t)(1.0)) + SQR(vIn.y)));\n" - << "\t\treal_t sigma = MPI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n" + << "\t\treal_t xp1 = vIn.x + (real_t)(1.0);\n" + << "\t\treal_t xm1 = vIn.x - (real_t)(1.0);\n" + << "\t\treal_t inysq = SQR(vIn.y);\n" + << "\t\treal_t tau = (real_t)(0.5) * (log(fma(xp1, xp1, inysq)) - log(fma(xm1, xm1, inysq)));\n" + << "\t\treal_t sigma = MPI - atan2(vIn.y, xp1) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n" << "\n" - << "\t\tsigma = sigma + tau * " << out << " + " << in << " / tau;\n" + << "\t\tsigma = sigma + tau * " << out << " + " << in << " / Zeps(tau);\n" << "\n" - << "\t\treal_t temp = cosh(tau) - cos(sigma);\n" + << "\t\treal_t temp = Zeps(cosh(tau) - cos(sigma));\n" << "\n" << "\t\tvOut.x = " << weight << " * sinh(tau) / temp;\n" << "\t\tvOut.y = " << weight << " * sin(sigma) / temp;\n" @@ -3382,7 +3405,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr" }; + return vector { "Sqr", "Zeps" }; } protected: @@ -3415,8 +3438,10 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T tau = T(0.5) * (std::log(Sqr(helper.In.x + 1) + SQR(helper.In.y)) - std::log(Sqr(helper.In.x - 1) + SQR(helper.In.y))) / m_Power + m_Move; - T sigma = T(M_PI) - std::atan2(helper.In.y, helper.In.x + 1) - std::atan2(helper.In.y, 1 - helper.In.x) + m_Rotate; + T xp1 = helper.In.x + 1; + T inysq = SQR(helper.In.y); + T tau = T(0.5) * (std::log(Sqr(xp1) + inysq) - std::log(Sqr(helper.In.x - 1) + inysq)) / m_Power + m_Move; + T sigma = T(M_PI) - std::atan2(helper.In.y, xp1) - std::atan2(helper.In.y, 1 - helper.In.x) + m_Rotate; sigma = sigma / m_Power + M_2PI / m_Power * Floor(rand.Frand01() * m_Power); if (helper.In.x >= 0) @@ -3424,7 +3449,7 @@ public: else tau -= m_Split; - T temp = std::cosh(tau) - std::cos(sigma); + T temp = Zeps(std::cosh(tau) - std::cos(sigma)); helper.Out.x = m_Weight * std::sinh(tau) / temp; helper.Out.y = m_Weight * std::sin(sigma) / temp; helper.Out.z = DefaultZ(helper); @@ -3438,11 +3463,14 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string rotate = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string move = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string split = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string move = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string split = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t tau = (real_t)(0.5) * (log(Sqr(vIn.x + (real_t)(1.0)) + SQR(vIn.y)) - log(Sqr(vIn.x - (real_t)(1.0)) + SQR(vIn.y))) / " << power << " + " << move << ";\n" + << "\t\treal_t xp1 = vIn.x + (real_t)(1.0);\n" + << "\t\treal_t xm1 = vIn.x - (real_t)(1.0);\n" + << "\t\treal_t inysq = SQR(vIn.y);\n" + << "\t\treal_t tau = (real_t)(0.5) * (log(fma(xp1, xp1, inysq)) - log(fma(xm1, xm1, inysq))) / " << power << " + " << move << ";\n" << "\t\treal_t sigma = MPI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x) + " << rotate << ";\n" << "\n" << "\t\tsigma = sigma / " << power << " + M_2PI / " << power << " * floor(MwcNext01(mwc) * " << power << ");\n" @@ -3452,7 +3480,7 @@ public: << "\t\telse\n" << "\t\t tau -= " << split << ";\n" << "\n" - << "\t\treal_t temp = cosh(tau) - cos(sigma);\n" + << "\t\treal_t temp = Zeps(cosh(tau) - cos(sigma));\n" << "\n" << "\t\tvOut.x = " << weight << " * sinh(tau) / temp;\n" << "\t\tvOut.y = " << weight << " * sin(sigma) / temp;\n" @@ -3463,7 +3491,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr" }; + return vector { "Sqr", "Zeps" }; } protected: @@ -3500,8 +3528,10 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T tau = T(0.5) * (std::log(Sqr(helper.In.x + 1) + SQR(helper.In.y)) - std::log(Sqr(helper.In.x - 1) + SQR(helper.In.y))); - T sigma = T(M_PI) - std::atan2(helper.In.y, helper.In.x + 1) - std::atan2(helper.In.y, 1 - helper.In.x); + T xp1 = helper.In.x + 1; + T inysq = SQR(helper.In.y); + T tau = T(0.5) * (std::log(Sqr(xp1) + inysq) - std::log(Sqr(helper.In.x - 1) + inysq)); + T sigma = T(M_PI) - std::atan2(helper.In.y, xp1) - std::atan2(helper.In.y, 1 - helper.In.x); int alt = int(sigma * m_CnPi); if ((alt & 1) == 0) @@ -3509,7 +3539,7 @@ public: else sigma = alt * m_PiCn + fmod(sigma - m_CaCn, m_PiCn); - T temp = std::cosh(tau) - std::cos(sigma); + T temp = Zeps(std::cosh(tau) - std::cos(sigma)); helper.Out.x = m_Weight * std::sinh(tau) / temp; helper.Out.y = m_Weight * std::sin(sigma) / temp; helper.Out.z = DefaultZ(helper); @@ -3522,23 +3552,26 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string num = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ca = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string num = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ca = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cnPi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string caCn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string piCn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t tau = (real_t)(0.5) * (log(Sqr(vIn.x + (real_t)(1.0)) + SQR(vIn.y)) - log(Sqr(vIn.x - (real_t)(1.0)) + SQR(vIn.y)));\n" - << "\t\treal_t sigma = MPI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n" + << "\t\treal_t xp1 = vIn.x + (real_t)(1.0);\n" + << "\t\treal_t xm1 = vIn.x - (real_t)(1.0);\n" + << "\t\treal_t inysq = SQR(vIn.y);\n" + << "\t\treal_t tau = (real_t)(0.5) * (log(fma(xp1, xp1, inysq)) - log(fma(xm1, xm1, inysq)));\n" + << "\t\treal_t sigma = MPI - atan2(vIn.y, xp1) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n" << "\t\tint alt = (int)(sigma * " << cnPi << ");\n" << "\n" << "\t\tif ((alt & 1) == 0)\n" - << "\t\t sigma = alt * " << piCn << " + fmod(sigma + " << caCn << ", " << piCn << ");\n" + << "\t\t sigma = fma(alt, " << piCn << ", fmod(sigma + " << caCn << ", " << piCn << "));\n" << "\t\telse\n" - << "\t\t sigma = alt * " << piCn << " + fmod(sigma - " << caCn << ", " << piCn << ");\n" + << "\t\t sigma = fma(alt, " << piCn << ", fmod(sigma - " << caCn << ", " << piCn << "));\n" << "\n" - << "\t\treal_t temp = cosh(tau) - cos(sigma);\n" + << "\t\treal_t temp = Zeps(cosh(tau) - cos(sigma));\n" << "\n" << "\t\tvOut.x = " << weight << " * sinh(tau) / temp;\n" << "\t\tvOut.y = " << weight << " * sin(sigma) / temp;\n" @@ -3549,7 +3582,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr" }; + return vector { "Sqr", "Zeps" }; } virtual void Precalc() override @@ -3642,11 +3675,11 @@ public: << "\n" << "\t\tif (fabs(vIn.y) <= " << weight << ")\n" << "\t\t{\n" - << "\t\t c2 = sqrt(SQR(" << weight << ") - SQR(vIn.y));\n" + << "\t\t c2 = sqrt(fma(" << weight << ", " << weight << ", - SQR(vIn.y)));\n" << "\n" << "\t\t if (fabs(vIn.x) <= c2)\n" << "\t\t {\n" - << "\t\t x = vIn.x + " << shift << " * " << weight << ";\n" + << "\t\t x = fma(" << shift << ", " << weight << ", vIn.x);\n" << "\n" << "\t\t if (fabs(x) >= c2)\n" << "\t\t vOut.x = -(" << weight << " * vIn.x);\n" diff --git a/Source/Ember/Variations04.h b/Source/Ember/Variations04.h index a1ffc64..941533d 100644 --- a/Source/Ember/Variations04.h +++ b/Source/Ember/Variations04.h @@ -215,11 +215,11 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string spinIn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string spinIn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string spinOut = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string space = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string in4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string out4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string space = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string in4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string out4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t x = fabs(vIn.x);\n" << "\t\treal_t y = fabs(vIn.y);\n" @@ -234,18 +234,18 @@ public: << "\t\t s = x;\n" << "\n" << "\t\t if (vIn.x > 0)\n" - << "\t\t p = s + vIn.y + s * " << out4 << ";\n" + << "\t\t p = fma(s, " << out4 << ", s + vIn.y);\n" << "\t\t else\n" - << "\t\t p = 5 * s - vIn.y + s * " << out4 << ";\n" + << "\t\t p = fma((real_t)(5.0), s, fma(s, " << out4 << ", -vIn.y));\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" << "\t\t s = y;\n" << "\n" << "\t\t if (vIn.y > 0)\n" - << "\t\t p = 3 * s - vIn.x + s * " << out4 << ";\n" + << "\t\t p = fma((real_t)(3.0), s, fma(s, " << out4 << ", -vIn.x));\n" << "\t\t else\n" - << "\t\t p = 7 * s + vIn.x + s * " << out4 << ";\n" + << "\t\t p = fma((real_t)(7.0), s, fma(s, " << out4 << ", vIn.x));\n" << "\t\t }\n" << "\n" << "\t\t p = fmod(p, s * 8);\n" @@ -253,25 +253,25 @@ public: << "\t\t if (p <= 2 * s)\n" << "\t\t {\n" << "\t\t x2 = s + " << space << ";\n" - << "\t\t y2 = -(1 * s - p);\n" + << "\t\t y2 = -fma((real_t)(1.0), s, -p);\n" << "\t\t y2 = y2 + y2 / s * " << space << ";\n" << "\t\t }\n" << "\t\t else if (p <= 4 * s)\n" << "\t\t {\n" << "\t\t y2 = s + " << space << ";\n" - << "\t\t x2 = (3 * s - p);\n" + << "\t\t x2 = fma((real_t)(3.0), s, -p);\n" << "\t\t x2 = x2 + x2 / s * " << space << ";\n" << "\t\t }\n" << "\t\t else if (p <= 6 * s)\n" << "\t\t {\n" << "\t\t x2 = -(s + " << space << ");\n" - << "\t\t y2 = (5 * s - p);\n" + << "\t\t y2 = fma((real_t)(5.0), s, -p);\n" << "\t\t y2 = y2 + y2 / s * " << space << ";\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" << "\t\t y2 = -(s + " << space << ");\n" - << "\t\t x2 = -(7 * s - p);\n" + << "\t\t x2 = -fma((real_t)(7.0), s, -p);\n" << "\t\t x2 = x2 + x2 / s * " << space << ";\n" << "\t\t }\n" << "\n" @@ -285,18 +285,18 @@ public: << "\t\t s = x;\n" << "\n" << "\t\t if (vIn.x > 0)\n" - << "\t\t p = s + vIn.y + s * " << in4 << ";\n" + << "\t\t p = fma(s, " << in4 << ", s + vIn.y);\n" << "\t\t else\n" - << "\t\t p = 5 * s - vIn.y + s * " << in4 << ";\n" + << "\t\t p = fma((real_t)(5.0), s, fma(s, " << in4 << ", -vIn.y));\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" << "\t\t s = y;\n" << "\n" << "\t\t if (vIn.y > 0)\n" - << "\t\t p = 3 * s - vIn.x + s * " << in4 << ";\n" + << "\t\t p = fma((real_t)(3.0), s, fma(s, " << in4 << ", -vIn.x));\n" << "\t\t else\n" - << "\t\t p = 7 * s + vIn.x + s * " << in4 << ";\n" + << "\t\t p = fma((real_t)(7.0), s, fma(s, " << in4 << ", vIn.x));\n" << "\t\t }\n" << "\n" << "\t\t p = fmod(p, s * 8);\n" @@ -308,17 +308,17 @@ public: << "\t\t }\n" << "\t\t else if (p <= 4 * s)\n" << "\t\t {\n" - << "\t\t vOut.x = " << weight << " * (3 * s - p);\n" + << "\t\t vOut.x = " << weight << " * fma((real_t)(3.0), s, -p);\n" << "\t\t vOut.y = " << weight << " * s;\n" << "\t\t }\n" << "\t\t else if (p <= 6 * s)\n" << "\t\t {\n" << "\t\t vOut.x = -(" << weight << " * s);\n" - << "\t\t vOut.y = " << weight << " * (5 * s - p);\n" + << "\t\t vOut.y = " << weight << " * fma((real_t)(5.0), s, -p);\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.x = -(" << weight << " * (7 * s - p));\n" + << "\t\t vOut.x = -(" << weight << " * fma((real_t)(7.0), s, -p));\n" << "\t\t vOut.y = -(" << weight << " * s);\n" << "\t\t }\n" << "\t\t}\n" @@ -432,7 +432,7 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t x = fabs(vIn.x);\n" @@ -447,19 +447,19 @@ public: << "\t\t if (vIn.x > 0)\n" << "\t\t p = vIn.y;\n" << "\t\t else\n" - << "\t\t p = 4 * s - vIn.y;\n" + << "\t\t p = fma((real_t)(4.0), s, -vIn.y);\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t s = y;\n" << "\n" << "\t\t if (vIn.y > 0)\n" - << "\t\t p = 2 * s - vIn.x;\n" + << "\t\t p = fma((real_t)(2.0), s, -vIn.x);\n" << "\t\t else\n" - << "\t\t p = 6 * s + vIn.x;\n" + << "\t\t p = fma((real_t)(6.0), s, vIn.x);\n" << "\t\t}\n" << "\n" - << "\t\tp = " << invPower << " * (p + 8 * s * floor(" << power << " * MwcNext01(mwc)));\n" + << "\t\tp = " << invPower << " * fma((real_t)(8.0), s * floor(" << power << " * MwcNext01(mwc)), p);\n" << "\n" << "\t\tif (p <= s)\n" << "\t\t{\n" @@ -468,23 +468,23 @@ public: << "\t\t}\n" << "\t\telse if (p <= 3 * s)\n" << "\t\t{\n" - << "\t\t vOut.x = " << weight << " * (2 * s - p);\n" + << "\t\t vOut.x = " << weight << " * fma((real_t)(2.0), s, -p);\n" << "\t\t vOut.y = " << weight << " * s;\n" << "\t\t}\n" << "\t\telse if (p <= 5 * s)\n" << "\t\t{\n" << "\t\t vOut.x = -(" << weight << " * s);\n" - << "\t\t vOut.y = " << weight << " * (4 * s - p);\n" + << "\t\t vOut.y = " << weight << " * fma((real_t)(4.0), s, -p);\n" << "\t\t}\n" << "\t\telse if (p <= 7 * s)\n" << "\t\t{\n" - << "\t\t vOut.x = -(" << weight << " * (6 * s - p));\n" + << "\t\t vOut.x = -(" << weight << " * fma((real_t)(6.0), s, -p));\n" << "\t\t vOut.y = -(" << weight << " * s);\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t vOut.x = " << weight << " * s;\n" - << "\t\t vOut.y = -(" << weight << " * (8 * s - p));\n" + << "\t\t vOut.y = -(" << weight << " * fma((real_t)(8.0), s, -p));\n" << "\t\t}\n" << "\n" << "\t\tvOut.z = " << DefaultZCl() @@ -705,7 +705,7 @@ public: string rxSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string rxCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t z = " << rxCos << " * vIn.z - " << rxSin << " * vIn.y;\n" + << "\t\treal_t z = fma(" << rxCos << ", vIn.z, -(" << rxSin << " * vIn.y));\n" << "\n"; if (m_VarType == eVariationType::VARTYPE_REG) @@ -720,7 +720,7 @@ public: "\t\tvOut.x = vIn.x;\n"; } - ss << "\t\tvOut.y = " << rxSin << " * vIn.z + " << rxCos << " * vIn.y;\n" + ss << "\t\tvOut.y = fma(" << rxSin << ", vIn.z, " << rxCos << " * vIn.y);\n" << "\t\tvOut.z = z;\n" << "\t}\n"; return ss.str(); @@ -788,7 +788,7 @@ public: string rySin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string ryCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\tvOut.x = " << ryCos << " * vIn.x - " << rySin << " * vIn.z;\n"; + << "\t\tvOut.x = fma(" << ryCos << ", vIn.x, -(" << rySin << " * vIn.z));\n"; if (m_VarType == eVariationType::VARTYPE_REG) { @@ -802,7 +802,7 @@ public: "\t\tvOut.y = vIn.y;\n"; } - ss << "\t\tvOut.z = " << rySin << " * vIn.x + " << ryCos << " * vIn.z;\n" + ss << "\t\tvOut.z = fma(" << rySin << ", vIn.x, " << ryCos << " * vIn.z);\n" << "\t}\n"; return ss.str(); } @@ -868,8 +868,8 @@ public: string rzSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string rzCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\tvOut.x = " << rzSin << " * vIn.y + " << rzCos << " * vIn.x;\n" - << "\t\tvOut.y = " << rzCos << " * vIn.y - " << rzSin << " * vIn.x;\n"; + << "\t\tvOut.x = fma(" << rzSin << ", vIn.y, " << rzCos << " * vIn.x);\n" + << "\t\tvOut.y = fma(" << rzCos << ", vIn.y, -(" << rzSin << " * vIn.x));\n"; if (m_VarType == eVariationType::VARTYPE_REG) { @@ -1154,20 +1154,20 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string strength = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centerX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centerY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centerX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centerY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t sx = vIn.x - " << centerX << ";\n" << "\t\treal_t sy = vIn.y - " << centerY << ";\n" - << "\t\treal_t r = sqrt(SQR(sx) + SQR(sy)) - " << offset << ";\n" + << "\t\treal_t r = sqrt(fma(sx, sx, SQR(sy))) - " << offset << ";\n" << "\n" << "\t\tr = r < 0 ? 0 : r;\n" << "\t\tr *= " << s2 << ";\n" << "\n" - << "\t\tvOut.x = " << weight << " * (vIn.x + (MwcNext01(mwc) - (real_t)(0.5)) * r);\n" - << "\t\tvOut.y = " << weight << " * (vIn.y + (MwcNext01(mwc) - (real_t)(0.5)) * r);\n" + << "\t\tvOut.x = " << weight << " * fma(MwcNext01(mwc) - (real_t)(0.5), r, vIn.x);\n" + << "\t\tvOut.y = " << weight << " * fma(MwcNext01(mwc) - (real_t)(0.5), r, vIn.y);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -1232,20 +1232,20 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sep = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sep = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string absN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t jun = Zeps(fabs(" << n << "));\n" << "\n" - << "\t\treal_t a = (atan2(vIn.y, pow(fabs(vIn.x), " << sep << ")) + M_2PI * floor(MwcNext01(mwc) * " << absN << ")) / jun;\n" + << "\t\treal_t a = fma(M_2PI, floor(MwcNext01(mwc) * " << absN << "), atan2(vIn.y, pow(fabs(vIn.x), " << sep << "))) / jun;\n" << "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cn << " * " << a << ");\n" << "\n" - << "\t\tvOut.x = r * cos(a) + " << b << ";\n" - << "\t\tvOut.y = r * sin(a) + " << b << ";\n" + << "\t\tvOut.x = fma(r, cos(a), " << b << ");\n" + << "\t\tvOut.y = fma(r, sin(a), " << b << ");\n" << "\t\tvOut.z = vIn.z;\n"; if (m_VarType == eVariationType::VARTYPE_REG) @@ -1436,7 +1436,7 @@ public: << "\t\t y = (real_t)(VoronDiscreteNoise((int)(l + 21 * m1 + 33 * n1 + " << ySeed << ")) + n1) * " << step << ";\n" << "\t\t offsetX = vIn.x - x;\n" << "\t\t offsetY = vIn.y - y;\n" - << "\t\t r = sqrt(SQR(offsetX) + SQR(offsetY));\n" + << "\t\t r = sqrt(fma(offsetX, offsetX, SQR(offsetY)));\n" << "\n" << "\t\t if (r < rMin)\n" << "\t\t {\n" @@ -1448,8 +1448,8 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.x = " << weight << " * (" << m_k << " * (vIn.x - x0) + x0);\n" - << "\t\tvOut.y = " << weight << " * (" << m_k << " * (vIn.y - y0) + y0);\n" + << "\t\tvOut.x = " << weight << " * fma(" << m_k << ", (vIn.x - x0), x0);\n" + << "\t\tvOut.y = " << weight << " * fma(" << m_k << ", (vIn.y - y0), y0);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -1558,12 +1558,12 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string slices = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string slices = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string xThickness = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string yThickness = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sinr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cosr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sinr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cosr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t a = 0, r = 0;\n" << "\n" @@ -1583,16 +1583,16 @@ public: << "\t\t break;\n" << "\t\t case 3:\n" << "\t\t a = MwcNext01(mwc);\n" - << "\t\t r = (MwcNextRange(mwc, (int)" << slices << ") + " << yThickness << " + MwcNext01(mwc) * (1 - " << yThickness << ")) / " << slices << ";\n" + << "\t\t r = fma(MwcNext01(mwc), 1 - " << yThickness << ", MwcNextRange(mwc, (int)" << slices << ") + " << yThickness << ") / " << slices << ";\n" << "\t\t break;\n" << "\t\t case 4:\n" - << "\t\t a = (MwcNextRange(mwc, (int)" << slices << ") + " << xThickness << " + MwcNext01(mwc) * (1 - " << xThickness << ")) / " << slices << ";\n" + << "\t\t a = fma(MwcNext01(mwc), (1 - " << xThickness << "), MwcNextRange(mwc, (int)" << slices << ") + " << xThickness << ") / " << slices << ";\n" << "\t\t r = MwcNext01(mwc);\n" << "\t\t break;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.x = " << cosr << " * a + " << sinr << " * r;\n" - << "\t\tvOut.y = -" << sinr << " * a + " << cosr << " * r;\n" + << "\t\tvOut.x = fma(" << cosr << ", a, " << sinr << " * r);\n" + << "\t\tvOut.y = -fma(" << sinr << ", a, " << cosr << " * r);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -1717,30 +1717,30 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string rho = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string phi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string m1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string m2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n1_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n1_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n2_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n2_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n3_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n3_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rho = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string phi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string m1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string m2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n1_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n1_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n2_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n2_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n3_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n3_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string spiral = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string toroid = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n1n_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string n1n_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string an2_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string an2_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string bn3_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string bn3_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string m4_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string m4_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n1n_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n1n_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string an2_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string an2_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string bn3_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string bn3_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string m4_1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string m4_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rho2pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string phi2pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" @@ -1766,15 +1766,15 @@ public: << "\t\tmsinp = sin(temp);\n" << "\t\tmcosp = cos(temp);\n" << "\n" - << "\t\tpr1 = " << an2_1 << " * pow(fabs(mcosr), " << n2_1 << ") + " << bn3_1 << " * pow(fabs(msinr), " << n3_1 << ");\n" - << "\t\tpr2 = " << an2_2 << " * pow(fabs(mcosp), " << n2_2 << ") + " << bn3_2 << " * pow(fabs(msinp), " << n3_2 << ");\n" - << "\t\tr1 = pow(fabs(pr1), " << n1_1 << ") + " << spiral << " * rho1;\n" + << "\t\tpr1 = fma(" << an2_1 << ", pow(fabs(mcosr), " << n2_1 << "), " << bn3_1 << " * pow(fabs(msinr), " << n3_1 << "));\n" + << "\t\tpr2 = fma(" << an2_2 << ", pow(fabs(mcosp), " << n2_2 << "), " << bn3_2 << " * pow(fabs(msinp), " << n3_2 << "));\n" + << "\t\tr1 = fma(" << spiral << ", rho1, pow(fabs(pr1), " << n1_1 << "));\n" << "\t\tr2 = pow(fabs(pr2), " << n1_2 << ");\n" << "\n" << "\t\tif ((int)" << toroid << " == 1)\n" << "\t\t{\n" - << "\t\t vOut.x = " << weight << " * cosr * (r1 + r2 * cosp);\n" - << "\t\t vOut.y = " << weight << " * sinr * (r1 + r2 * cosp);\n" + << "\t\t vOut.x = " << weight << " * cosr * fma(r2, cosp, r1);\n" + << "\t\t vOut.y = " << weight << " * sinr * fma(r2, cosp, r1);\n" << "\t\t vOut.z = " << weight << " * r2 * sinp;\n" << "\t\t}\n" << "\t\telse\n" @@ -1908,7 +1908,7 @@ public: ss << "\t{\n" << "\t\treal_t t, rX, rY, rZ;\n" << "\n" - << "\t\tt = Zeps(precalcSumSquares + SQR(vIn.z));\n" + << "\t\tt = Zeps(fma(vIn.z, vIn.z, precalcSumSquares));\n" << "\t\trX = " << weight << " / pow(t, " << stretchX << ");\n" << "\t\trY = " << weight << " / pow(t, " << stretchY << ");\n" << "\n" @@ -2044,7 +2044,7 @@ public: ss << "\t\tconst real_t rad = sqrt(SQR(xi) + SQR(yi));\n" << "\t\tconst real_t ang = atan2(yi, xi);\n" - << "\t\tconst real_t rdc = " << radius << " + (MwcNext01(mwc) * (real_t)(0.5) * " << ca << "); \n" + << "\t\tconst real_t rdc = fma(MwcNext01(mwc) * (real_t)(0.5), " << ca << ", " << radius << ");\n" << "\t\tconst real_t s = sin(ang);\n" << "\t\tconst real_t c = cos(ang);\n" << "\n" @@ -2062,18 +2062,18 @@ public: << "\t\t}\n" << "\t\telse if (cr0 && !esc)\n" << "\t\t{\n" - << "\t\t vOut.x = " << weight << " * xi + " << x << ";\n" - << "\t\t vOut.y = " << weight << " * yi + " << y << ";\n" + << "\t\t vOut.x = fma(" << weight << ", xi, " << x << ");\n" + << "\t\t vOut.y = fma(" << weight << ", yi, " << y << ");\n" << "\t\t}\n" << "\t\telse if (!cr0 && esc)\n" << "\t\t{\n" - << "\t\t vOut.x = " << weight << " * rdc * c + " << x << ";\n" - << "\t\t vOut.y = " << weight << " * rdc * s + " << y << ";\n" + << "\t\t vOut.x = fma(" << weight << ", rdc * c, " << x << ");\n" + << "\t\t vOut.y = fma(" << weight << ", rdc * s, " << y << ");\n" << "\t\t}\n" << "\t\telse if (!cr0 && !esc)\n" << "\t\t{\n" - << "\t\t vOut.x = " << weight << " * xi + " << x << ";\n" - << "\t\t vOut.y = " << weight << " * yi + " << y << ";\n" + << "\t\t vOut.x = fma(" << weight << ", xi, " << x << ");\n" + << "\t\t vOut.y = fma(" << weight << ", yi, " << y << ");\n" << "\t\t}\n" << "\t}\n"; return ss.str(); @@ -2142,22 +2142,22 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string e = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string e = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tconst real_t z = vIn.z / " << absn << ";\n" - << "\t\tconst real_t radiusOut = " << weight << " * pow(precalcSumSquares + z * z, " << cn << ");\n" - << "\t\tconst real_t x = " << a << " * vIn.x + " << b << " * vIn.y + " << e << ";\n" - << "\t\tconst real_t y = " << c << " * vIn.x + " << d << " * vIn.y + " << f << ";\n" + << "\t\tconst real_t radiusOut = " << weight << " * pow(fma(z, z, precalcSumSquares), " << cn << ");\n" + << "\t\tconst real_t x = fma(" << a << ", vIn.x, fma(" << b << ", vIn.y, " << e << "));\n" + << "\t\tconst real_t y = fma(" << c << ", vIn.x, fma(" << d << ", vIn.y, " << f << "));\n" << "\t\tconst real_t rand = (int)(MwcNext01(mwc) * " << absn << ");\n" - << "\t\tconst real_t alpha = (atan2(y, x) + M_2PI * rand) / " << power << ";\n" + << "\t\tconst real_t alpha = fma(M_2PI, rand, atan2(y, x)) / " << power << ";\n" << "\t\tconst real_t gamma = radiusOut * precalcSqrtSumSquares;\n" << "\n" << "\t\tvOut.x = gamma * cos(alpha);\n" @@ -2277,11 +2277,11 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string spin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string space = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string twist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string spin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string space = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string twist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string sqrWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tif (vIn.x > 0 && vIn.y > 0)\n" @@ -2312,21 +2312,21 @@ public: << "\t\t{\n" << "\t\t real_t x = vIn.x - " << x << ";\n" << "\t\t real_t y = vIn.y + " << y << ";\n" - << "\t\t real_t r = sqrt(SQR(x) + SQR(y));\n" + << "\t\t real_t r = sqrt(fma(x, x, SQR(y)));\n" << "\n" << "\t\t if (r < " << weight << ")\n" << "\t\t {\n" - << "\t\t real_t a = atan2(y, x) + " << spin << " + " << twist << " * (" << weight << " - r);\n" + << "\t\t real_t a = fma(" << twist << ", " << weight << " - r, atan2(y, x) + " << spin << ");\n" << "\n" << "\t\t r *= " << weight << ";\n" - << "\t\t vOut.x = r * cos(a) + " << x << ";\n" - << "\t\t vOut.y = r * sin(a) - " << y << ";\n" + << "\t\t vOut.x = fma(r, cos(a), " << x << ");\n" + << "\t\t vOut.y = fma(r, sin(a), -" << y << ");\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" << "\t\t r = " << weight << " * (1 + " << space << " / Zeps(r));\n" - << "\t\t vOut.x = r * x + " << x << ";\n" - << "\t\t vOut.y = r * y - " << y << ";\n" + << "\t\t vOut.x = fma(r, x, " << x << ");\n" + << "\t\t vOut.y = fma(r, y, -" << y << ");\n" << "\t\t }\n" << "\t\t}\n" << "\t\telse\n" @@ -2465,19 +2465,19 @@ public: << "\t\tconst real_t z4 = " << cz << ";\n" << "\t\tconst real_t z5 = " << dz << ";\n" << "\n" - << "\t\treal_t nt = t1 * t2 - x1 * x2 - y1 * y2 + t3;\n" - << "\t\treal_t nx = t1 * x2 + x1 * t2 - z1 * y2 + x3;\n" - << "\t\treal_t ny = t1 * y2 + y1 * t2 + z1 * x2 + y3;\n" - << "\t\treal_t nz = z1 * t2 + x1 * y2 - y1 * x2 + z3;\n" - << "\t\treal_t dt = t4 * t2 - x4 * x2 - y4 * y2 + t5;\n" - << "\t\treal_t dx = t4 * x2 + x4 * t2 - z4 * y2 + x5;\n" - << "\t\treal_t dy = t4 * y2 + y4 * t2 + z4 * x2 + y5;\n" - << "\t\treal_t dz = z4 * t2 + x4 * y2 - y4 * x2 + z5;\n" - << "\t\treal_t ni = " << weight << " / (SQR(dt) + SQR(dx) + SQR(dy) + SQR(dz));\n" + << "\t\treal_t nt = fma(t1, t2, -(x1 * x2)) - y1 * y2 + t3;\n" + << "\t\treal_t nx = fma(t1, x2, x1 * t2) - z1 * y2 + x3;\n" + << "\t\treal_t ny = fma(t1, y2, fma(y1, t2, fma(z1, x2, y3)));\n" + << "\t\treal_t nz = fma(z1, t2, x1 * y2) - y1 * x2 + z3;\n" + << "\t\treal_t dt = fma(t4, t2, -(x4 * x2)) - y4 * y2 + t5;\n" + << "\t\treal_t dx = fma(t4, x2, x4 * t2) - z4 * y2 + x5;\n" + << "\t\treal_t dy = fma(t4, y2, fma(y4, t2, fma(z4, x2, y5)));\n" + << "\t\treal_t dz = fma(z4, t2, x4 * y2) - y4 * x2 + z5;\n" + << "\t\treal_t ni = " << weight << " / fma(dt, dt, fma(dx, dx, fma(dy, dy, SQR(dz))));\n" << "\n" - << "\t\tvOut.x = (nt * dt + nx * dx + ny * dy + nz * dz) * ni;\n" - << "\t\tvOut.y = (nx * dt - nt * dx - ny * dz + nz * dy) * ni;\n" - << "\t\tvOut.z = (ny * dt - nt * dy - nz * dx + nx * dz) * ni;\n" + << "\t\tvOut.x = fma(nt, dt, fma(nx, dx, fma(ny, dy, nz * dz))) * ni;\n" + << "\t\tvOut.y = (fma(nx, dt, -(nt * dx)) - ny * dz + nz * dy) * ni;\n" + << "\t\tvOut.z = (fma(ny, dt, -(nt * dy)) - nz * dx + nx * dz) * ni;\n" << "\t}\n"; return ss.str(); } @@ -2625,17 +2625,18 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string xOrigin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string yOrigin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string zOrigin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t r = " << weight << " * (Sqr(vIn.x - " << xOrigin << ") + \n" - << "\t\t Sqr(vIn.y - " << yOrigin << ") + \n" - << "\t\t Sqr(vIn.z - " << zOrigin << ")) *\n" - << "\t\t (MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) - 2);\n" + << "\t\treal_t xmx = vIn.x - " << xOrigin << ";\n" + << "\t\treal_t ymy = vIn.y - " << yOrigin << ";\n" + << "\t\treal_t zmz = vIn.z - " << zOrigin << ";\n" + << "\t\treal_t r = " << weight << " * (fma(xmx, xmx, fma(ymy, ymy, SQR(zmz))))\n" + << "\t\t * (MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) - 2);\n" << "\t\treal_t u = MwcNext01(mwc) * M_2PI;\n" << "\t\treal_t su = sin(u);\n" << "\t\treal_t cu = cos(u);\n" @@ -2727,17 +2728,17 @@ public: << "\t\tconst real_t x = Powq4c(vIn.x, " << power << ");\n" << "\t\tconst real_t y = Powq4c(vIn.y, " << power << ");\n" << "\t\tconst real_t z = Powq4c(vIn.z, " << power << ");\n" - << "\t\tconst real_t d = SQR(x) - SQR(y);\n" - << "\t\tconst real_t re = Spread(" << c1 << " * x + " << c2 << " * d, " << sx << ") + (real_t)(1.0);\n" - << "\t\tconst real_t im = Spread(" << c1 << " * y + " << c2x2 << " * x * y, " << sy << ");\n" - << "\t\treal_t c = Zeps(Powq4c(SQR(re) + SQR(im), " << powerInv << "));\n" + << "\t\tconst real_t d = fma(x, x, -SQR(y));\n" + << "\t\tconst real_t re = Spread(fma(" << c1 << ", x, " << c2 << " * d), " << sx << ") + (real_t)(1.0);\n" + << "\t\tconst real_t im = Spread(fma(" << c1 << ", y, " << c2x2 << " * x * y), " << sy << ");\n" + << "\t\treal_t c = Zeps(Powq4c(fma(re, re, SQR(im)), " << powerInv << "));\n" << "\n" << "\t\tconst real_t r = " << weight << " / c;\n" << "\n" - << "\t\tvOut.x = (x * re + y * im) * r;\n" - << "\t\tvOut.y = (y * re - x * im) * r;\n" + << "\t\tvOut.x = fma(x, re, y * im) * r;\n" + << "\t\tvOut.y = fma(y, re, -(x * im)) * r;\n" << "\t\tvOut.z = (z * " << weight << ") / c;\n" - << "\t\toutPoint->m_ColorX = clamp(outPoint->m_ColorX + " << dcAdjust << " * c, (real_t)(0.0), (real_t)(1.0));\n" + << "\t\toutPoint->m_ColorX = clamp(fma(" << dcAdjust << ", c, outPoint->m_ColorX), (real_t)(0.0), (real_t)(1.0));\n" << "\t}\n"; return ss.str(); } @@ -3074,17 +3075,17 @@ public: return "real_t Interference2Sine(real_t a, real_t b, real_t c, real_t p, real_t x)\n" "{\n" - " return a * pow(fabs(sin(b * x + c)), p);\n" + " return a * pow(fabs(sin(fma(b, x, c))), p);\n" "}\n" "\n" "real_t Interference2Tri(real_t a, real_t b, real_t c, real_t p, real_t x)\n" "{\n" - " return a * 2 * pow(fabs(asin(cos(b * x + c - MPI2))) * M1PI, p);\n" + " return a * 2 * pow(fabs(asin(cos(fma(b, x, c - MPI2)))) * M1PI, p);\n" "}\n" "\n" "real_t Interference2Squ(real_t a, real_t b, real_t c, real_t p, real_t x)\n" "{\n" - " return a * pow(sin(b * x + c) < 0 ? EPS : 1, p);\n" + " return a * pow(sin(fma(b, x, c)) < 0 ? EPS : 1, p);\n" "}\n" "\n"; } @@ -3266,7 +3267,7 @@ public: string weight = WeightDefineString(); ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" - << "\t\treal_t ni = " << weight << " / Zeps(precalcSumSquares + SQR(vIn.z));\n" + << "\t\treal_t ni = " << weight << " / Zeps(fma(vIn.z, vIn.z, precalcSumSquares));\n" << "\t\treal_t s = sin(-vIn.x);\n" << "\t\treal_t c = cos(-vIn.x);\n" << "\t\treal_t sh = sinh(absV);\n" @@ -3318,7 +3319,7 @@ public: string weight = WeightDefineString(); ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" - << "\t\treal_t ni = " << weight << " / Zeps(precalcSumSquares + SQR(vIn.z));\n" + << "\t\treal_t ni = " << weight << " / Zeps(fma(vIn.z, vIn.z, precalcSumSquares));\n" << "\t\treal_t s = sin(absV);\n" << "\t\treal_t c = cos(absV);\n" << "\t\treal_t sh = sinh(vIn.x);\n" @@ -3374,9 +3375,9 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n" + << "\t\treal_t sysz = fma(vIn.y, vIn.y, SQR(vIn.z));\n" << "\t\treal_t absV = sqrt(sysz);\n" - << "\t\treal_t ni = " << weight << " / Zeps(SQR(vIn.x) + sysz);\n" + << "\t\treal_t ni = " << weight << " / Zeps(fma(vIn.x, vIn.x, sysz));\n" << "\t\treal_t s = sin(vIn.x);\n" << "\t\treal_t c = cos(vIn.x);\n" << "\t\treal_t sh = sinh(absV);\n" @@ -3387,9 +3388,9 @@ public: << "\t\treal_t nstcv = -stcv;\n" << "\t\treal_t ctcv = c * ch;\n" << "\n" - << "\t\tvOut.x = (stcv * ctcv + d * b * sysz) * ni;\n" - << "\t\tvOut.y = (nstcv * b * vIn.y + d * vIn.y * ctcv) * ni;\n" - << "\t\tvOut.z = (nstcv * b * vIn.z + d * vIn.z * ctcv) * ni;\n" + << "\t\tvOut.x = fma(stcv, ctcv, d * b * sysz) * ni;\n" + << "\t\tvOut.y = fma(nstcv, b * vIn.y, d * vIn.y * ctcv) * ni;\n" + << "\t\tvOut.z = fma(nstcv, b * vIn.z, d * vIn.z * ctcv) * ni;\n" << "\t}\n"; return ss.str(); } @@ -3436,9 +3437,9 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n" + << "\t\treal_t sysz = fma(vIn.y, vIn.y, SQR(vIn.z));\n" << "\t\treal_t absV = sqrt(sysz);\n" - << "\t\treal_t ni = " << weight << " / Zeps(SQR(vIn.x) + sysz);\n" + << "\t\treal_t ni = " << weight << " / Zeps(fma(vIn.x, vIn.x, sysz));\n" << "\t\treal_t s = sin(absV);\n" << "\t\treal_t c = cos(absV);\n" << "\t\treal_t sh = sinh(vIn.x);\n" @@ -3449,9 +3450,9 @@ public: << "\t\treal_t nstcv = -stcv;\n" << "\t\treal_t ctcv = c * ch;\n" << "\n" - << "\t\tvOut.x = (stcv * ctcv + d * b * sysz) * ni;\n" - << "\t\tvOut.y = (nstcv * b * vIn.y + d * vIn.y * ctcv) * ni;\n" - << "\t\tvOut.z = (nstcv * b * vIn.z + d * vIn.z * ctcv) * ni;\n" + << "\t\tvOut.x = fma(stcv, ctcv, d * b * sysz) * ni;\n" + << "\t\tvOut.y = fma(nstcv, b * vIn.y, d * vIn.y * ctcv) * ni;\n" + << "\t\tvOut.z = fma(nstcv, b * vIn.z, d * vIn.z * ctcv) * ni;\n" << "\t}\n"; return ss.str(); } @@ -3598,9 +3599,9 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n" + << "\t\treal_t sysz = fma(vIn.y, vIn.y, SQR(vIn.z));\n" << "\t\treal_t absV = sqrt(sysz);\n" - << "\t\treal_t ni = " << weight << " / Zeps(SQR(vIn.x) + sysz);\n" + << "\t\treal_t ni = " << weight << " / Zeps(fma(vIn.x, vIn.x, sysz));\n" << "\t\treal_t s = sin(vIn.x);\n" << "\t\treal_t c = cos(vIn.x);\n" << "\t\treal_t sh = sinh(absV);\n" @@ -3611,9 +3612,9 @@ public: << "\t\treal_t nstcv = -stcv;\n" << "\t\treal_t ctcv = c * ch;\n" << "\n" - << "\t\tvOut.x = (stcv * ctcv + d * b * sysz) * ni;\n" - << "\t\tvOut.y = -(nstcv * b * vIn.y + d * vIn.y * ctcv) * ni;\n" - << "\t\tvOut.z = -(nstcv * b * vIn.z + d * vIn.z * ctcv) * ni;\n" + << "\t\tvOut.x = fma(stcv, ctcv, d * b * sysz) * ni;\n" + << "\t\tvOut.y = -fma(nstcv * b, vIn.y, d * vIn.y * ctcv) * ni;\n" + << "\t\tvOut.z = -fma(nstcv * b, vIn.z, d * vIn.z * ctcv) * ni;\n" << "\t}\n"; return ss.str(); } @@ -3660,9 +3661,9 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n" + << "\t\treal_t sysz = fma(vIn.y, vIn.y, SQR(vIn.z));\n" << "\t\treal_t absV = sqrt(sysz);\n" - << "\t\treal_t ni = " << weight << " / Zeps(Sqr(SQR(vIn.x) + sysz));\n" + << "\t\treal_t ni = " << weight << " / Zeps(Sqr(fma(vIn.x, vIn.x, sysz)));\n" << "\t\treal_t s = sin(absV);\n" << "\t\treal_t c = cos(absV);\n" << "\t\treal_t sh = sinh(vIn.x);\n" @@ -3673,9 +3674,9 @@ public: << "\t\treal_t nstcv = -stcv;\n" << "\t\treal_t ctcv = ch * c;\n" << "\n" - << "\t\tvOut.x = (stcv * ctcv + d * b * sysz) * ni;\n" - << "\t\tvOut.y = (nstcv * b * vIn.y + d * vIn.y * ctcv) * ni;\n" - << "\t\tvOut.z = (nstcv * b * vIn.z + d * vIn.z * ctcv) * ni;\n" + << "\t\tvOut.x = fma(stcv, ctcv, d * b * sysz) * ni;\n" + << "\t\tvOut.y = fma(nstcv * b, vIn.y, d * vIn.y * ctcv) * ni;\n" + << "\t\tvOut.z = fma(nstcv * b, vIn.z, d * vIn.z * ctcv) * ni;\n" << "\t}\n"; return ss.str(); } @@ -3718,7 +3719,7 @@ public: string weight = WeightDefineString(); ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" - << "\t\treal_t ni = " << weight << " / Zeps(precalcSumSquares + SQR(vIn.z));\n" + << "\t\treal_t ni = " << weight << " / Zeps(fma(vIn.z, vIn.z, precalcSumSquares));\n" << "\t\treal_t s = sin(vIn.x);\n" << "\t\treal_t c = cos(vIn.x);\n" << "\t\treal_t sh = sinh(absV);\n" @@ -3770,7 +3771,7 @@ public: string weight = WeightDefineString(); ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" - << "\t\treal_t ni = " << weight << " / Zeps(precalcSumSquares + SQR(vIn.z));\n" + << "\t\treal_t ni = " << weight << " / Zeps(fma(vIn.z, vIn.z, precalcSumSquares));\n" << "\t\treal_t s = sin(absV);\n" << "\t\treal_t c = cos(absV);\n" << "\t\treal_t sh = sinh(vIn.x);\n" @@ -3868,13 +3869,13 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string base = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string base = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string denom = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t c = " << weight << " * atan2(absV, vIn.x) / Zeps(absV);\n" << "\n" - << "\t\tvOut.x = log(SQR(vIn.x) + SQR(absV)) * " << denom << ";\n" + << "\t\tvOut.x = log(fma(vIn.x, vIn.x, SQR(absV))) * " << denom << ";\n" << "\t\tvOut.y = c * vIn.y;\n" << "\t\tvOut.z = c * vIn.z;\n" << "\t}\n"; @@ -3992,10 +3993,10 @@ public: << "\t\treal_t sqy = SQR(vIn.y);\n" << "\t\treal_t xy = vIn.x * vIn.y;\n" << "\n" - << "\t\tvOut.x = (" << q01 << " + " << weight << " * " << q02 << " * vIn.x + " << q03 << " * sqx) + \n" - << "\t\t (" << q04 << " * xy + " << q05 << " * vIn.y + " << q06 << " * sqy);\n" - << "\t\tvOut.y = (" << q07 << " + " << q08 << " * vIn.x + " << q09 << " * sqx) + \n" - << "\t\t (" << q10 << " * xy + " << weight << " * " << q11 << " * vIn.y + " << q12 << " * sqy);\n" + << "\t\tvOut.x = (" << q01 << " + fma(" << weight << ", " << q02 << " * vIn.x, " << q03 << " * sqx)) + \n" + << "\t\t fma(" << q04 << ", xy, fma(" << q05 << ", vIn.y, " << q06 << " * sqy));\n" + << "\t\tvOut.y = (" << q07 << " + fma(" << q08 << ", vIn.x, " << q09 << " * sqx)) + \n" + << "\t\t fma(" << q10 << ", xy, fma(" << weight << ", " << q11 << " * vIn.y, " << q12 << " * sqy));\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -4273,17 +4274,17 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string extended = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string exponent = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string arcWidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string size = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string oneOverEx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absSeed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string seed2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string extended = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string exponent = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string arcWidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string size = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string oneOverEx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absSeed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string seed2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string oneOverRmax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tint extended = (int)" << extended << ";\n" << "\t\treal_t seed = " << absSeed << ";\n" @@ -4329,9 +4330,9 @@ public: << "\n" << "\t\t xrand = xrand * " << seed2 << ";\n" << "\t\t yrand = yrand * " << seed2 << ";\n" - << "\t\t niter = xrand + yrand + xrand * yrand;\n" + << "\t\t niter = fma(xrand, yrand, xrand + yrand);\n" << "\t\t randInt = (niter + seed) * " << seed2 << " / 2;\n" - << "\t\t randInt = fmod((randInt * multiplier + offset), modBase);\n" + << "\t\t randInt = fmod(fma(randInt, multiplier, offset), modBase);\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" @@ -4546,7 +4547,7 @@ public: "inline real_t GdoffsFclp(real_t a) { return ((a < 0) ? -(fmod(fabs(a), 1)) : fmod(fabs(a), 1)); }\n" "inline real_t GdoffsFscl(real_t a) { return GdoffsFclp((a + 1) / 2); }\n" "inline real_t GdoffsFosc(real_t p, real_t a) { return GdoffsFscl(-1 * cos(p * a * M_2PI)); }\n" - "inline real_t GdoffsFlip(real_t a, real_t b, real_t c) { return (c * (b - a) + a); }\n" + "inline real_t GdoffsFlip(real_t a, real_t b, real_t c) { return fma(c, (b - a), a); }\n" "\n"; } @@ -4626,7 +4627,10 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T r = m_Weight / Zeps((SQR(SQR(helper.In.x)) + SQR(helper.In.z) + SQR(SQR(helper.In.y)) + SQR(helper.In.z))); + T x2 = SQR(helper.In.x); + T y2 = SQR(helper.In.y); + T z2 = SQR(helper.In.z); + T r = m_Weight / Zeps(SQR(x2) + z2 + SQR(y2) + z2); if (r < 2) { @@ -4639,7 +4643,7 @@ public: helper.Out.x = m_Weight * helper.In.x; helper.Out.y = m_Weight * helper.In.y; helper.Out.z = m_Weight * helper.In.z; - T t = m_Weight / Zeps((std::sqrt(SQR(helper.In.x)) + std::sqrt(helper.In.z) + std::sqrt(SQR(helper.In.y)) + std::sqrt(helper.In.z))); + T t = m_Weight / Zeps(std::sqrt(SQR(helper.In.x)) + std::sqrt(helper.In.z) + std::sqrt(SQR(helper.In.y)) + std::sqrt(helper.In.z)); if (r >= 0) { @@ -4682,7 +4686,10 @@ public: string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t r = " << weight << " / Zeps((SQR(SQR(vIn.x)) + SQR(vIn.z) + SQR(SQR(vIn.y)) + SQR(vIn.z)));\n" + << "\t\treal_t x2 = SQR(vIn.x);\n" + << "\t\treal_t y2 = SQR(vIn.y);\n" + << "\t\treal_t z2 = SQR(vIn.z);\n" + << "\t\treal_t r = " << weight << " / Zeps(fma(x2, x2, z2) + fma(y2, y2, z2));\n" << "\n" << "\t\tif (r < 2)\n" << "\t\t{\n" @@ -4696,7 +4703,7 @@ public: << "\t\t vOut.y = " << weight << " * vIn.y;\n" << "\t\t vOut.z = " << weight << " * vIn.z;\n" << "\n" - << "\t\t real_t t = " << weight << " / Zeps((sqrt(SQR(vIn.x)) + sqrt(vIn.z) + sqrt(SQR(vIn.y)) + sqrt(vIn.z)));\n" + << "\t\t real_t t = " << weight << " / Zeps(sqrt(SQR(vIn.x)) + sqrt(vIn.z) + sqrt(SQR(vIn.y)) + sqrt(vIn.z));\n" << "\n" << "\t\t if (r >= 0)\n" << "\t\t {\n" @@ -4828,14 +4835,14 @@ public: << "\t\tif (vIn.x > 0)\n" << "\t\t{\n" << "\t\t c1mx = " << c1 << " - vIn.x;\n" - << "\t\t r = sqrt(SQR(c1mx) + SQR(vIn.y));\n" + << "\t\t r = sqrt(fma(c1mx, c1mx, SQR(vIn.y)));\n" << "\n" << "\t\t if (r <= " << r1 << ")\n" << "\t\t {\n" << "\t\t r *= " << r2 << " / " << r1 << ";\n" << "\t\t temp = atan2(vIn.y, c1mx);\n" << "\n" - << "\t\t vOut.x = " << weight << " * (r * cos(temp) - " << c2 << ");\n" + << "\t\t vOut.x = " << weight << " * fma(r, cos(temp), -" << c2 << ");\n" << "\t\t vOut.y = " << weight << " * r * sin(temp);\n" << "\t\t }\n" << "\t\t else\n" @@ -4847,14 +4854,14 @@ public: << "\t\telse\n" << "\t\t{\n" << "\t\t c1mx = -" << c2 << " - vIn.x;\n" - << "\t\t r = sqrt(SQR(c1mx) + SQR(vIn.y));\n" + << "\t\t r = sqrt(fma(c1mx, c1mx, SQR(vIn.y)));\n" << "\n" << "\t\t if (r <= " << r2 << ")\n" << "\t\t {\n" << "\t\t r *= " << r1 << " / " << r2 << ";\n" << "\t\t temp = atan2(vIn.y, c1mx);\n" << "\n" - << "\t\t vOut.x = " << weight << " * (r * cos(temp) + " << c1 << ");\n" + << "\t\t vOut.x = " << weight << " * fma(r, cos(temp), " << c1 << ");\n" << "\t\t vOut.y = " << weight << " * r * sin(temp);\n" << "\t\t }\n" << "\t\t else\n" @@ -4929,16 +4936,16 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string re = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string im = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string re = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string im = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string reInv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string im100 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t arg = precalcAtanyx + fmod((real_t)MwcNext(mwc), (real_t)(1 / " << reInv << ")) * M_2PI;\n" + << "\t\treal_t arg = fma(fmod((real_t)MwcNext(mwc), (real_t)(1 / " << reInv << ")), M_2PI, precalcAtanyx);\n" << "\t\treal_t lnmod = " << dist << " * (real_t)(0.5) * log(precalcSumSquares);\n" - << "\t\treal_t temp = arg * " << reInv << " + lnmod * " << im100 << ";\n" - << "\t\treal_t mod2 = exp(lnmod * " << reInv << " - arg * " << im100 << ");\n" + << "\t\treal_t temp = fma(arg, " << reInv << ", lnmod * " << im100 << ");\n" + << "\t\treal_t mod2 = exp(fma(lnmod, " << reInv << ", -(arg * " << im100 << ")));\n" << "\n" << "\t\tvOut.x = " << weight << " * mod2 * cos(temp);\n" << "\t\tvOut.y = " << weight << " * mod2 * sin(temp);\n" @@ -5041,12 +5048,12 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string blobLow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string blobHigh = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string blobLow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string blobHigh = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string blobWaves = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string blobDiff = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string blobDiff = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t r = precalcSqrtSumSquares * (" << blobLow << " + " << blobDiff << " * ((real_t)(0.5) + (real_t)(0.5) * sin(" << blobWaves << " * precalcAtanxy)));\n" + << "\t\treal_t r = precalcSqrtSumSquares * fma(" << blobDiff << ", fma((real_t)(0.5), sin(" << blobWaves << " * precalcAtanxy), (real_t)(0.5)), " << blobLow << ");\n" << "\n" << "\t\tvOut.x = " << weight << " * (precalcSina * r);\n" << "\t\tvOut.y = " << weight << " * (precalcCosa * r);\n" diff --git a/Source/Ember/Variations05.h b/Source/Ember/Variations05.h index ac7f677..197fa9f 100644 --- a/Source/Ember/Variations05.h +++ b/Source/Ember/Variations05.h @@ -20,7 +20,7 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T t = T(0.25) * (helper.m_PrecalcSumSquares + SQR(helper.In.z)) + 1; + T t = Zeps(T(0.25) * (helper.m_PrecalcSumSquares + SQR(helper.In.z)) + 1); T r = m_Weight / t; helper.Out.x = helper.In.x * r * m_X; helper.Out.y = helper.In.y * r * m_Y; @@ -44,7 +44,7 @@ public: string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t t = (real_t)(0.25) * (precalcSumSquares + SQR(vIn.z)) + 1;\n" + << "\t\treal_t t = Zeps(fma((real_t)(0.25), fma(vIn.z, vIn.z, precalcSumSquares), (real_t)(1.0)));\n" << "\t\treal_t r = " << weight << " / t;\n" << "\n" << "\t\tvOut.x = vIn.x * r * " << x << ";\n" @@ -60,6 +60,11 @@ public: return ss.str(); } + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Zeps" }; + } + protected: void Init() { @@ -94,8 +99,10 @@ public: { int m = int(Floor(T(0.5) * helper.In.x / m_Sc)); int n = int(Floor(T(0.5) * helper.In.y / m_Sc)); - T x = helper.In.x - (m * 2 + 1) * m_Sc; - T y = helper.In.y - (n * 2 + 1) * m_Sc; + int m21 = m * 2 + 1; + int n21 = n * 2 + 1; + T x = helper.In.x - m21 * m_Sc; + T y = helper.In.y - n21 * m_Sc; T u = Zeps(VarFuncs::Hypot(x, y)); T v = (T(0.3) + T(0.7) * DiscreteNoise2(m + 10, n + 3)) * m_Sc; T z1 = DiscreteNoise2(int(m + m_Seed), n); @@ -132,8 +139,8 @@ public: } } - helper.Out.x = m_Weight * (x + (m * 2 + 1) * m_Sc); - helper.Out.y = m_Weight * (y + (n * 2 + 1) * m_Sc); + helper.Out.x = m_Weight * (x + m21 * m_Sc); + helper.Out.y = m_Weight * (y + n21 * m_Sc); helper.Out.z = DefaultZ(helper); } @@ -144,21 +151,23 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string sc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dens1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dens2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dens1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dens2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string reverse = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tint m = (int)floor((real_t)(0.5) * vIn.x / " << sc << ");\n" << "\t\tint n = (int)floor((real_t)(0.5) * vIn.y / " << sc << ");\n" - << "\t\treal_t x = vIn.x - (m * 2 + 1) * " << sc << ";\n" - << "\t\treal_t y = vIn.y - (n * 2 + 1) * " << sc << ";\n" + << "\t\tint m21 = m * 2 + 1;\n" + << "\t\tint n21 = n * 2 + 1;\n" + << "\t\treal_t x = vIn.x - m21 * " << sc << ";\n" + << "\t\treal_t y = vIn.y - n21 * " << sc << ";\n" << "\t\treal_t u = Zeps(Hypot(x, y));\n" - << "\t\treal_t v = ((real_t)(0.3) + (real_t)(0.7) * CircleLinearDiscreteNoise2(m + 10, n + 3)) * " << sc << ";\n" + << "\t\treal_t v = fma(CircleLinearDiscreteNoise2(m + 10, n + 3), (real_t)(0.7), (real_t)(0.3)) * " << sc << ";\n" << "\t\treal_t z1 = CircleLinearDiscreteNoise2((int)(m + " << seed << "), n);\n" << "\n" << "\t\tif ((z1 < " << dens1 << ") && (u < v))\n" @@ -172,7 +181,7 @@ public: << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t real_t z = v / u * (1 - " << k << ") + " << k << ";\n" + << "\t\t real_t z = fma(v / u, (1 - " << k << "), " << k << ");\n" << "\n" << "\t\t x *= z;\n" << "\t\t y *= z;\n" @@ -187,7 +196,7 @@ public: << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t real_t z = v / u * (1 - " << k << ") + " << k << ";\n" + << "\t\t real_t z = fma(v / u, (1 - " << k << "), " << k << ");\n" << "\n" << "\t\t x *= z;\n" << "\t\t y *= z;\n" @@ -195,8 +204,8 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.x = " << weight << " * (x + (m * 2 + 1) * " << sc << ");\n" - << "\t\tvOut.y = " << weight << " * (y + (n * 2 + 1) * " << sc << ");\n" + << "\t\tvOut.x = " << weight << " * fma((real_t)m21, " << sc << ", x);\n" + << "\t\tvOut.y = " << weight << " * fma((real_t)n21, " << sc << ", y);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -326,10 +335,10 @@ public: << "\t\t if (++iters > 10)\n" << "\t\t break;\n" << "\t\t}\n" - << "\t\twhile ((CircleRandDiscreteNoise2((int)(m + " << seed << "), n) > " << dens << ") || (u > ((real_t)(0.3) + (real_t)(0.7) * CircleRandDiscreteNoise2(m + 10, n + 3)) * " << sc << "));\n" + << "\t\twhile ((CircleRandDiscreteNoise2((int)(m + " << seed << "), n) > " << dens << ") || (u > fma(CircleRandDiscreteNoise2(m + 10, n + 3), (real_t)(0.7), (real_t)(0.3)) * " << sc << "));\n" << "\n" - << "\t\tvOut.x = " << weight << " * (x + (m * 2 + 1) * " << sc << ");\n" - << "\t\tvOut.y = " << weight << " * (y + (n * 2 + 1) * " << sc << ");\n" + << "\t\tvOut.x = " << weight << " * fma((real_t)(m * 2 + 1), " << sc << ", x);\n" + << "\t\tvOut.y = " << weight << " * fma((real_t)(n * 2 + 1), " << sc << ", y);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -448,7 +457,7 @@ public: << "\t\ty = uy - (n * 2 + 1) * " << sc << ";\n" << "\t\tu = Hypot(x, y);\n" << "\n" - << "\t\tif ((CircleTrans1DiscreteNoise2((int)(m + " << seed << "), n) > " << dens << ") || (u > ((real_t)(0.3) + (real_t)(0.7) * CircleTrans1DiscreteNoise2(m + 10, n + 3)) * " << sc << "))\n" + << "\t\tif ((CircleTrans1DiscreteNoise2((int)(m + " << seed << "), n) > " << dens << ") || (u > fma(CircleTrans1DiscreteNoise2(m + 10, n + 3), (real_t)(0.7), (real_t)(0.3)) * " << sc << "))\n" << "\t\t{\n" << "\t\t ux = ux;\n" << "\t\t uy = uy;\n" @@ -480,8 +489,8 @@ public: "\n" "void CircleTrans1Trans(real_t a, real_t b, real_t x, real_t y, real_t* x1, real_t* y1)\n" "{\n" - " *x1 = (x - a) * (real_t)(0.5) + a;\n" - " *y1 = (y - b) * (real_t)(0.5) + b;\n" + " *x1 = fma((x - a), (real_t)(0.5), a);\n" + " *y1 = fma((y - b), (real_t)(0.5), b);\n" "}\n" "\n" "void CircleTrans1CircleR(real_t mx, real_t my, real_t sc, real_t seed, real_t dens, real_t* ux, real_t* vy, uint2* mwc)\n" @@ -496,7 +505,7 @@ public: " m = (int)floor((real_t)(0.5) * x / sc);\n" " n = (int)floor((real_t)(0.5) * y / sc);\n" " alpha = M_2PI * MwcNext01(mwc);\n" - " u = (real_t)(0.3) + (real_t)(0.7) * CircleTrans1DiscreteNoise2(m + 10, n + 3);\n" + " u = fma(CircleTrans1DiscreteNoise2(m + 10, n + 3), (real_t)(0.7), (real_t)(0.3));\n" " x = u * cos(alpha);\n" " y = u * sin(alpha);\n" "\n" @@ -505,8 +514,8 @@ public: " }\n" " while (CircleTrans1DiscreteNoise2((int)(m + seed), n) > dens);\n" "\n" - " *ux = x + (m * 2 + 1) * sc;\n" - " *vy = y + (n * 2 + 1) * sc;\n" + " *ux = fma((real_t)(m * 2 + 1), sc, x);\n" + " *vy = fma((real_t)(n * 2 + 1), sc, y);\n" "}\n" "\n"; } @@ -960,44 +969,44 @@ public: << "\t\tswitch (useNode)\n" << "\t\t{\n" << "\t\t case 0 :\n" - << "\t\t vOut.x = pxtx * " << fill << " * exnze + lattd;\n" - << "\t\t vOut.y = pyty * " << fill << " * wynze + lattd;\n" - << "\t\t vOut.z = pztz * " << fill << " * znxy + lattd;\n" + << "\t\t vOut.x = fma(pxtx, " << fill << " * exnze, lattd);\n" + << "\t\t vOut.y = fma(pyty, " << fill << " * wynze, lattd);\n" + << "\t\t vOut.z = fma(pztz, " << fill << " * znxy , lattd);\n" << "\t\t break;\n" << "\t\t case 1 :\n" - << "\t\t vOut.x = pxtx * " << fill << " * exnze + lattd;\n" - << "\t\t vOut.y = pyty * " << fill << " * wynze - lattd;\n" - << "\t\t vOut.z = pztz * " << fill << " * znxy + lattd;\n" + << "\t\t vOut.x = fma(pxtx, " << fill << " * exnze, lattd);\n" + << "\t\t vOut.y = fma(pyty, " << fill << " * wynze, -lattd);\n" + << "\t\t vOut.z = fma(pztz, " << fill << " * znxy, lattd);\n" << "\t\t break;\n" << "\t\t case 2 :\n" - << "\t\t vOut.x = pxtx * " << fill << " * exnze + lattd;\n" - << "\t\t vOut.y = pyty * " << fill << " * wynze + lattd;\n" - << "\t\t vOut.z = pztz * " << fill << " * znxy - lattd;\n" + << "\t\t vOut.x = fma(pxtx, " << fill << " * exnze, lattd);\n" + << "\t\t vOut.y = fma(pyty, " << fill << " * wynze, lattd);\n" + << "\t\t vOut.z = fma(pztz, " << fill << " * znxy, -lattd);\n" << "\t\t break;\n" << "\t\t case 3 :\n" - << "\t\t vOut.x = pxtx * " << fill << " * exnze + lattd;\n" - << "\t\t vOut.y = pyty * " << fill << " * wynze - lattd;\n" - << "\t\t vOut.z = pztz * " << fill << " * znxy - lattd;\n" + << "\t\t vOut.x = fma(pxtx, " << fill << " * exnze, lattd);\n" + << "\t\t vOut.y = fma(pyty, " << fill << " * wynze, -lattd);\n" + << "\t\t vOut.z = fma(pztz, " << fill << " * znxy, -lattd);\n" << "\t\t break;\n" << "\t\t case 4 :\n" - << "\t\t vOut.x = pxtx * " << fill << " * exnze - lattd;\n" - << "\t\t vOut.y = pyty * " << fill << " * wynze + lattd;\n" - << "\t\t vOut.z = pztz * " << fill << " * znxy + lattd;\n" + << "\t\t vOut.x = fma(pxtx, " << fill << " * exnze, -lattd);\n" + << "\t\t vOut.y = fma(pyty, " << fill << " * wynze, lattd);\n" + << "\t\t vOut.z = fma(pztz, " << fill << " * znxy, lattd);\n" << "\t\t break;\n" << "\t\t case 5 :\n" - << "\t\t vOut.x = pxtx * " << fill << " * exnze - lattd;\n" - << "\t\t vOut.y = pyty * " << fill << " * wynze - lattd;\n" - << "\t\t vOut.z = pztz * " << fill << " * znxy + lattd;\n" + << "\t\t vOut.x = fma(pxtx, " << fill << " * exnze, -lattd);\n" + << "\t\t vOut.y = fma(pyty, " << fill << " * wynze, -lattd);\n" + << "\t\t vOut.z = fma(pztz, " << fill << " * znxy, lattd);\n" << "\t\t break;\n" << "\t\t case 6 :\n" - << "\t\t vOut.x = pxtx * " << fill << " * exnze - lattd;\n" - << "\t\t vOut.y = pyty * " << fill << " * wynze + lattd;\n" - << "\t\t vOut.z = pztz * " << fill << " * znxy - lattd;\n" + << "\t\t vOut.x = fma(pxtx, " << fill << " * exnze, -lattd);\n" + << "\t\t vOut.y = fma(pyty, " << fill << " * wynze, lattd);\n" + << "\t\t vOut.z = fma(pztz, " << fill << " * znxy, -lattd);\n" << "\t\t break;\n" << "\t\t case 7 :\n" - << "\t\t vOut.x = pxtx * " << fill << " * exnze - lattd;\n" - << "\t\t vOut.y = pyty * " << fill << " * wynze - lattd;\n" - << "\t\t vOut.z = pztz * " << fill << " * znxy - lattd;\n" + << "\t\t vOut.x = fma(pxtx, " << fill << " * exnze, -lattd);\n" + << "\t\t vOut.y = fma(pyty, " << fill << " * wynze, -lattd);\n" + << "\t\t vOut.z = fma(pztz, " << fill << " * znxy, -lattd);\n" << "\t\t break;\n" << "\t\t}\n" << "\t}\n"; @@ -1131,9 +1140,9 @@ public: << "\t\treal_t cv = cos(vIn.y);\n" << "\t\treal_t cucv = cu * cv;\n" << "\t\treal_t sucv = su * cv;\n" - << "\t\treal_t x = pow(fabs(cucv), " << xpow << ") + (cucv * " << xpow << ") + ((real_t)(0.25) * atOmegaX);\n" - << "\t\treal_t y = pow(fabs(sucv), " << ypow << ") + (sucv * " << ypow << ") + ((real_t)(0.25) * atOmegaY);\n" - << "\t\treal_t z = pow(fabs(sv), " << zpow << ") + sv * " << zpow << ";\n" + << "\t\treal_t x = pow(fabs(cucv), " << xpow << ") + fma(cucv, " << xpow << ", (real_t)(0.25) * atOmegaX);\n" + << "\t\treal_t y = pow(fabs(sucv), " << ypow << ") + fma(sucv, " << ypow << ", (real_t)(0.25) * atOmegaY);\n" + << "\t\treal_t z = fma(sv, " << zpow << ", pow(fabs(sv), " << zpow << "));\n" << "\n" << "\t\tvOut.x = " << weight << " * x;\n" << "\t\tvOut.y = " << weight << " * y;\n" @@ -1193,19 +1202,19 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string divisor = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absInvPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string divisor = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absInvPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string halfInvPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invPower2pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invPower2pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t temp = precalcAtanyx * " << invPower << " + MwcNext(mwc) * " << invPower2pi << ";\n" + << "\t\treal_t temp = fma(precalcAtanyx, " << invPower << ", MwcNext(mwc) * " << invPower2pi << ");\n" << "\t\treal_t sina = sin(temp);\n" << "\t\treal_t cosa = cos(temp);\n" << "\t\treal_t z = vIn.z * " << absInvPower << ";\n" << "\t\treal_t r2d = precalcSumSquares;\n" - << "\t\treal_t r = " << weight << " * pow(r2d + SQR(z), " << halfInvPower << ");\n" + << "\t\treal_t r = " << weight << " * pow(fma(z, z, r2d), " << halfInvPower << ");\n" << "\t\treal_t rsss = r * precalcSqrtSumSquares;\n" << "\n" << "\t\tvOut.x = rsss * cosa;\n" @@ -1386,32 +1395,32 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string weight = WeightDefineString(); string index = ss2.str(); - string sides = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sides = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string circle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string w2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sins = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string coss = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sinc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cosc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string w2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sins = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string coss = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sinc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cosc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tint i;\n" << "\t\treal_t xrt = vIn.x, yrt = vIn.y, swp;\n" - << "\t\treal_t r2 = xrt * " << coss << " + fabs(yrt) * " << sins << ";\n" + << "\t\treal_t r2 = fma(xrt, " << coss << ", fabs(yrt) * " << sins << ");\n" << "\t\treal_t circle = precalcSqrtSumSquares;\n" << "\n" << "\t\tfor (i = 0; i < " << sides << " - 1; i++)\n" << "\t\t{\n" - << "\t\t swp = xrt * " << cosa << " - yrt * " << sina << ";\n" - << "\t\t yrt = xrt * " << sina << " + yrt * " << cosa << ";\n" + << "\t\t swp = fma(xrt, " << cosa << ", -(yrt * " << sina << "));\n" + << "\t\t yrt = fma(xrt, " << sina << ", yrt * " << cosa << ");\n" << "\t\t xrt = swp;\n" << "\n" - << "\t\t r2 = max(r2, xrt * " << coss << " + fabs(yrt) * " << sins << ");\n" + << "\t\t r2 = max(r2, fma(xrt, " << coss << ", fabs(yrt) * " << sins << "));\n" << "\t\t}\n" << "\n" - << "\t\tr2 = r2 * " << cosc << " + circle * " << sinc << ";\n" + << "\t\tr2 = fma(r2, " << cosc << ", circle * " << sinc << ");\n" << "\n" << "\t\tif (i > 1)\n" << "\t\t r2 = SQR(r2);\n" @@ -1619,7 +1628,7 @@ public: ss << "\t{\n" << "\t\treal_t kikr = precalcAtanyx;\n" << "\t\treal_t efTez = vIn.z == 0 ? kikr : vIn.z;\n" - << "\t\treal_t r2 = precalcSumSquares + SQR(efTez);\n" + << "\t\treal_t r2 = fma(efTez, efTez, precalcSumSquares);\n" << "\n" << "\t\tif (r2 < " << vv << ")\n" << "\t\t{\n" @@ -1693,7 +1702,7 @@ public: string twist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string tilt = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t t = precalcSumSquares * (real_t)(0.25) + 1;\n" + << "\t\treal_t t = fma(precalcSumSquares, (real_t)(0.25), (real_t)(1.0));\n" << "\t\treal_t r = " << weight << " / t;\n" << "\n" << "\t\tvOut.x = vIn.x * r * " << x << ";\n" @@ -1760,9 +1769,9 @@ public: ss << "\t{\n" << "\t\treal_t avgxy = (vIn.x + vIn.y) * (real_t)(0.5);\n" << "\n" - << "\t\tvOut.x = " << weight << " * (vIn.x + " << scale << " * sin(vIn.y * " << freq << "));\n" - << "\t\tvOut.y = " << weight << " * (vIn.y + " << scale << " * sin(vIn.x * " << freq << "));\n" - << "\t\tvOut.z = " << weight << " * (vIn.z + " << scale << " * sin(avgxy * " << freq << "));\n" + << "\t\tvOut.x = " << weight << " * fma(" << scale << ", sin(vIn.y * " << freq << "), vIn.x);\n" + << "\t\tvOut.y = " << weight << " * fma(" << scale << ", sin(vIn.x * " << freq << "), vIn.y);\n" + << "\t\tvOut.z = " << weight << " * fma(" << scale << ", sin(avgxy * " << freq << "), vIn.z);\n" << "\t}\n"; return ss.str(); } @@ -1812,12 +1821,12 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string slices = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string slices = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string thickness = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\tint sl = (int)(MwcNext01(mwc) * " << slices << " + (real_t)(0.5));\n" - << "\t\treal_t a = " << rotation << " + M_2PI * (sl + MwcNext01(mwc) * " << thickness << ") / " << slices << ";\n" + << "\t\tint sl = (int)fma(MwcNext01(mwc), " << slices << ", (real_t)(0.5));\n" + << "\t\treal_t a = fma(M_2PI, fma(MwcNext01(mwc), " << thickness << ", (real_t)(sl)) / " << slices << ", " << rotation << ");\n" << "\t\treal_t r = " << weight << " * MwcNext01(mwc);\n" << "\n" << "\t\tvOut.x = r * cos(a);\n" @@ -1889,13 +1898,13 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string stc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t otherZ, tempPZ = 0;\n" << "\t\treal_t tempTZ = vIn.z == 0 ? " << vv << " * " << stc << " * precalcAtanyx : vIn.z;\n"; @@ -1908,9 +1917,9 @@ public: ss << "\t\tif (otherZ == 0)\n" << "\t\t tempPZ = " << vv << " * " << stc << " * precalcAtanyx;\n" << "\n" - << "\t\tvOut.x = " << hw << " * (vIn.x + " << x << " * sin(tan(" << c << " * vIn.y)));\n" - << "\t\tvOut.y = " << hw << " * (vIn.y + " << y << " * sin(tan(" << c << " * vIn.x)));\n" - << "\t\tvOut.z = tempPZ + " << vv << " * (" << z << " * " << stc << " * tempTZ);\n" + << "\t\tvOut.x = " << hw << " * fma(" << x << ", sin(tan(" << c << " * vIn.y)), vIn.x);\n" + << "\t\tvOut.y = " << hw << " * fma(" << y << ", sin(tan(" << c << " * vIn.x)), vIn.y);\n" + << "\t\tvOut.z = fma(" << vv << ", (" << z << " * " << stc << " * tempTZ), tempPZ);\n" << "\t}\n"; return ss.str(); } @@ -2028,7 +2037,7 @@ public: string weight = WeightDefineString(); string invWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t t = precalcSumSquares + SQR(vIn.z);\n" + << "\t\treal_t t = fma(vIn.z, vIn.z, precalcSumSquares);\n" << "\t\treal_t r = 1 / Zeps(sqrt(t) * (t + " << invWeight << "));\n" << "\t\treal_t z = vIn.z == 0 ? precalcAtanyx : vIn.z;\n" << "\n" @@ -2093,22 +2102,22 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string xdist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string xdist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string xwidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ydist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ydist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ywidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string xw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string yw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string onemx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string onemy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string xw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string yw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string onemx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string onemy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tconst int xpos = vIn.x < 0;\n" << "\t\tconst int ypos = vIn.y < 0;\n" << "\t\tconst real_t xrng = vIn.x / " << xdist << ";\n" << "\t\tconst real_t yrng = vIn.y / " << ydist << ";\n" << "\n" - << "\t\tvOut.x = " << xw << " * ((xrng - (int)xrng) * " << xwidth << " + (int)xrng + ((real_t)(0.5) - xpos) * " << onemx << ");\n" - << "\t\tvOut.y = " << yw << " * ((yrng - (int)yrng) * " << ywidth << " + (int)yrng + ((real_t)(0.5) - ypos) * " << onemy << ");\n" + << "\t\tvOut.x = " << xw << " * fma((xrng - (int)xrng), " << xwidth << ", (int)xrng + ((real_t)(0.5) - xpos) * " << onemx << ");\n" + << "\t\tvOut.y = " << yw << " * fma((yrng - (int)yrng), " << ywidth << ", (int)yrng + ((real_t)(0.5) - ypos) * " << onemy << ");\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t}\n"; return ss.str(); @@ -2219,12 +2228,12 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string px = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string py = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t b = " << weight << " / (precalcSumSquares * (real_t)(0.25) + 1);\n" + << "\t\treal_t b = " << weight << " / fma(precalcSumSquares, (real_t)(0.25), (real_t)(1.0));\n" << "\t\treal_t roundX = rint(vIn.x);\n" << "\t\treal_t roundY = rint(vIn.y);\n" << "\t\treal_t offsetX = vIn.x - roundX;\n" @@ -2235,8 +2244,8 @@ public: << "\n" << "\t\tif (MwcNext01(mwc) >= (real_t)(0.75))\n" << "\t\t{\n" - << "\t\t vOut.x += " << weight << " * (offsetX * (real_t)(0.5) + roundX);\n" - << "\t\t vOut.y += " << weight << " * (offsetY * (real_t)(0.5) + roundY);\n" + << "\t\t vOut.x += " << weight << " * fma(offsetX, (real_t)(0.5), roundX);\n" + << "\t\t vOut.y += " << weight << " * fma(offsetY, (real_t)(0.5), roundY);\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" @@ -2244,26 +2253,26 @@ public: << "\t\t {\n" << "\t\t if (offsetX >= 0)\n" << "\t\t {\n" - << "\t\t vOut.x += " << weight << " * (offsetX * (real_t)(0.5) + roundX + " << x << ");\n" - << "\t\t vOut.y += " << weight << " * (offsetY * (real_t)(0.5) + roundY + " << y << " * offsetY / Zeps(offsetX));\n" + << "\t\t vOut.x += " << weight << " * fma(offsetX, (real_t)(0.5), roundX + " << x << ");\n" + << "\t\t vOut.y += " << weight << " * fma(offsetY, (real_t)(0.5), fma(" << y << ", offsetY / Zeps(offsetX), roundY));\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.x += " << weight << " * (offsetX * (real_t)(0.5) + roundX - " << y << ");\n" - << "\t\t vOut.y += " << weight << " * (offsetY * (real_t)(0.5) + roundY - " << y << " * offsetY / Zeps(offsetX));\n" + << "\t\t vOut.x += " << weight << " * fma(offsetX, (real_t)(0.5), roundX - " << y << ");\n" + << "\t\t vOut.y += " << weight << " * fma(offsetY, (real_t)(0.5), roundY - " << y << " * offsetY / Zeps(offsetX));\n" << "\t\t }\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" << "\t\t if (offsetY >= 0)\n" << "\t\t {\n" - << "\t\t vOut.y += " << weight << " * (offsetY * (real_t)(0.5) + roundY + " << y << ");\n" - << "\t\t vOut.x += " << weight << " * (offsetX * (real_t)(0.5) + roundX + offsetX / Zeps(offsetY) * " << y << ");\n" + << "\t\t vOut.y += " << weight << " * fma(offsetY, (real_t)(0.5), roundY + " << y << ");\n" + << "\t\t vOut.x += " << weight << " * fma(offsetX, (real_t)(0.5), roundX + offsetX / Zeps(offsetY) * " << y << ");\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.y += " << weight << " * (offsetY * (real_t)(0.5) + roundY - " << y << ");\n" - << "\t\t vOut.x += " << weight << " * (offsetX * (real_t)(0.5) + roundX - offsetX / Zeps(offsetY) * " << x << ");\n" + << "\t\t vOut.y += " << weight << " * fma(offsetY, (real_t)(0.5), roundY - " << y << ");\n" + << "\t\t vOut.x += " << weight << " * fma(offsetX, (real_t)(0.5), roundX - offsetX / Zeps(offsetY) * " << x << ");\n" << "\t\t }\n" << "\t\t }\n" << "\t\t}\n" @@ -2376,9 +2385,9 @@ public: break; case 1://Radial. - sigma = std::asin(r == 0 ? 0 : helper.In.z / r) + m_MulZ * az * rs; - phi = helper.m_PrecalcAtanyx + m_MulY * ay * rs; rad = r + m_MulX * ax * rs; + phi = helper.m_PrecalcAtanyx + m_MulY * ay * rs; + sigma = std::asin(r == 0 ? 0 : helper.In.z / r) + m_MulZ * az * rs; sigmas = std::sin(sigma); sigmac = std::cos(sigma); phis = std::sin(phi); @@ -2406,23 +2415,26 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string scatter = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string minDist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string x0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string z0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invert = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string type = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string boxPow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scatter = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string minDist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string z0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invert = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string type = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string boxPow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string internalScatter = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tconst real_t ax = MwcNext0505(mwc);\n" << "\t\tconst real_t ay = MwcNext0505(mwc);\n" << "\t\tconst real_t az = MwcNext0505(mwc);\n" - << "\t\tconst real_t r = sqrt(Sqr(vIn.x - " << x0 << ") + Sqr(vIn.y - " << y0 << ") + Sqr(vIn.z - " << z0 << "));\n" + << "\t\tconst real_t xmx = vIn.x - " << x0 << ";\n" + << "\t\tconst real_t ymy = vIn.y - " << y0 << ";\n" + << "\t\tconst real_t zmz = vIn.z - " << z0 << ";\n" + << "\t\tconst real_t r = sqrt(fma(xmx, xmx, fma(ymy, ymy, SQR(zmz))));\n" << "\t\tconst real_t rc = ((" << invert << " != 0 ? max(1 - r, (real_t)(0.0)) : max(r, (real_t)(0.0))) - " << minDist << ") * " << internalScatter << ";\n" << "\t\tconst real_t rs = max(rc, (real_t)(0.0));\n" << "\n" @@ -2432,14 +2444,14 @@ public: << "\t\tswitch ((int)" << type << ")\n" << "\t\t{\n" << "\t\t case 0:\n" - << "\t\t vOut.x = " << weight << " * (vIn.x + " << mulX << " * ax * rs);\n" - << "\t\t vOut.y = " << weight << " * (vIn.y + " << mulY << " * ay * rs);\n" - << "\t\t vOut.z = " << weight << " * (vIn.z + " << mulZ << " * az * rs);\n" + << "\t\t vOut.x = " << weight << " * fma(" << mulX << ", ax * rs, vIn.x);\n" + << "\t\t vOut.y = " << weight << " * fma(" << mulY << ", ay * rs, vIn.y);\n" + << "\t\t vOut.z = " << weight << " * fma(" << mulZ << ", az * rs, vIn.z);\n" << "\t\t break;\n" << "\t\t case 1:\n" - << "\t\t sigma = asin(r == 0 ? 0 : vIn.z / r) + " << mulZ << " * az * rs;\n" - << "\t\t phi = precalcAtanyx + " << mulY << " * ay * rs;\n" - << "\t\t rad = r + " << mulX << " * ax * rs;\n" + << "\t\t rad = fma(" << mulX << ", ax * rs, r);\n" + << "\t\t phi = fma(" << mulY << ", ay * rs, precalcAtanyx);\n" + << "\t\t sigma = fma(" << mulZ << ", az * rs, asin(r == 0 ? 0 : vIn.z / r));\n" << "\n" << "\t\t sigmas = sin(sigma);\n" << "\t\t sigmac = cos(sigma);\n" @@ -2453,9 +2465,9 @@ public: << "\t\t case 2:\n" << "\t\t scale = clamp(rs, (real_t)(0.0), (real_t)(0.9)) + (real_t)(0.1);\n" << "\t\t denom = 1 / scale;\n" - << "\t\t vOut.x = " << weight << " * Lerp(vIn.x, floor(vIn.x * denom) + scale * ax, " << mulX << " * rs) + " << mulX << " * pow(ax, " << boxPow << ") * rs * denom;\n" - << "\t\t vOut.y = " << weight << " * Lerp(vIn.y, floor(vIn.y * denom) + scale * ay, " << mulY << " * rs) + " << mulY << " * pow(ay, " << boxPow << ") * rs * denom;\n" - << "\t\t vOut.z = " << weight << " * Lerp(vIn.z, floor(vIn.z * denom) + scale * az, " << mulZ << " * rs) + " << mulZ << " * pow(az, " << boxPow << ") * rs * denom;\n" + << "\t\t vOut.x = fma(" << weight << ", Lerp(vIn.x, fma(scale, ax, floor(vIn.x * denom)), " << mulX << " * rs), " << mulX << " * pow(ax, " << boxPow << ") * rs * denom);\n" + << "\t\t vOut.y = fma(" << weight << ", Lerp(vIn.y, fma(scale, ay, floor(vIn.y * denom)), " << mulY << " * rs), " << mulY << " * pow(ay, " << boxPow << ") * rs * denom);\n" + << "\t\t vOut.z = fma(" << weight << ", Lerp(vIn.z, fma(scale, az, floor(vIn.z * denom)), " << mulZ << " * rs), " << mulZ << " * pow(az, " << boxPow << ") * rs * denom);\n" << "\t\t break;\n" << "\t\t}\n" << "\t}\n"; @@ -2547,10 +2559,10 @@ public: } else { - const T rIn = std::sqrt(helper.m_PrecalcSumSquares + SQR(helper.In.z)); - const T sigma = std::asin(helper.In.z / rIn) + m_MulZ * random.z * dist; - const T phi = helper.m_PrecalcAtanyx + m_MulY * random.y * dist; + const T rIn = Zeps(std::sqrt(helper.m_PrecalcSumSquares + SQR(helper.In.z))); const T r = rIn + m_MulX * random.x * dist; + const T phi = helper.m_PrecalcAtanyx + m_MulY * random.y * dist; + const T sigma = std::asin(helper.In.z / rIn) + m_MulZ * random.z * dist; const T sigmas = std::sin(sigma); const T sigmac = std::cos(sigma); const T phis = std::sin(phi); @@ -2591,32 +2603,35 @@ public: string weight = WeightDefineString(); string scatter = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string minDist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string x0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string y0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string z0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invert = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string type = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rMax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string y0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string z0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invert = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string type = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rMax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tconst real_t randx = MwcNext0505(mwc);\n" << "\t\tconst real_t randy = MwcNext0505(mwc);\n" << "\t\tconst real_t randz = MwcNext0505(mwc);\n" << "\t\tconst real_t randc = MwcNext0505(mwc);\n" - << "\t\tconst real_t distA = sqrt(Sqr(vIn.x - " << x0 << ") + Sqr(vIn.y - " << y0 << ") + Sqr(vIn.z - " << z0 << "));\n" + << "\t\tconst real_t xmx = vIn.x - " << x0 << ";\n" + << "\t\tconst real_t ymy = vIn.y - " << y0 << ";\n" + << "\t\tconst real_t zmz = vIn.z - " << z0 << ";\n" + << "\t\tconst real_t distA = sqrt(fma(xmx, xmx, fma(ymy, ymy, SQR(zmz))));\n" << "\t\tconst real_t distB = " << invert << " != 0 ? max(1 - distA, (real_t)(0.0)) : max(distA, (real_t)(0.0));\n" << "\t\tconst real_t dist = max((distB - " << minDist << ") * " << rMax << ", (real_t)(0.0));\n" << "\n" << "\t\tswitch ((int)" << type << ")\n" << "\t\t{\n" << "\t\t case 0:\n" - << "\t\t vOut.x = vIn.x + " << mulX << " * randx * dist;\n" - << "\t\t vOut.y = vIn.y + " << mulY << " * randy * dist;\n" - << "\t\t vOut.z = vIn.z + " << mulZ << " * randz * dist;\n" - << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + " << mulC << " * randc * dist, (real_t)(1.0)));\n" + << "\t\t vOut.x = fma(" << mulX << ", randx * dist, vIn.x);\n" + << "\t\t vOut.y = fma(" << mulY << ", randy * dist, vIn.y);\n" + << "\t\t vOut.z = fma(" << mulZ << ", randz * dist, vIn.z);\n" + << "\t\t outPoint->m_ColorX = fabs(fmod(fma(" << mulC << ", randc * dist, outPoint->m_ColorX), (real_t)(1.0)));\n" << "\t\t break;\n" << "\t\t case 1:\n" << "\t\t if (vIn.x == 0 && vIn.y == 0 && vIn.z == 0)\n" @@ -2627,10 +2642,10 @@ public: << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t real_t rIn = sqrt(precalcSumSquares + SQR(vIn.z));\n" - << "\t\t real_t sigma = asin(vIn.z / rIn) + " << mulZ << " * randz * dist;\n" - << "\t\t real_t phi = precalcAtanyx + " << mulY << " * randy * dist;\n" - << "\t\t real_t r = rIn + " << mulX << " * randx * dist;\n" + << "\t\t real_t rIn = Zeps(sqrt(fma(vIn.z, vIn.z, precalcSumSquares)));\n" + << "\t\t real_t r = fma(" << mulX << ", randx * dist, rIn);\n" + << "\t\t real_t phi = fma(" << mulY << ", randy * dist, precalcAtanyx);\n" + << "\t\t real_t sigma = fma(" << mulZ << ", randz * dist, asin(vIn.z / rIn));\n" << "\t\t real_t sigmas = sin(sigma);\n" << "\t\t real_t sigmac = cos(sigma);\n" << "\t\t real_t phis = sin(phi);\n" @@ -2639,7 +2654,7 @@ public: << "\t\t vOut.x = r * sigmac * phic;\n" << "\t\t vOut.y = r * sigmac * phis;\n" << "\t\t vOut.z = r * sigmas;\n" - << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + " << mulC << " * randc * dist, (real_t)(1.0)));\n" + << "\t\t outPoint->m_ColorX = fabs(fmod(fma(" << mulC << ", randc * dist, outPoint->m_ColorX), (real_t)(1.0)));\n" << "\t\t }\n" << "\t\t break;\n" << "\t\t case 2:\n" @@ -2652,10 +2667,10 @@ public: << "\t\t real_t phis = sin(phi);\n" << "\t\t real_t phic = cos(phi);\n" << "\n" - << "\t\t vOut.x = vIn.x + " << mulX << " * rad * sigmac * phic;\n" - << "\t\t vOut.y = vIn.y + " << mulY << " * rad * sigmac * phis;\n" - << "\t\t vOut.z = vIn.z + " << mulZ << " * rad * sigmas;\n" - << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + " << mulC << " * randc * dist, (real_t)(1.0)));\n" + << "\t\t vOut.x = fma(" << mulX << " * rad, sigmac * phic, vIn.x);\n" + << "\t\t vOut.y = fma(" << mulY << " * rad, sigmac * phis, vIn.y);\n" + << "\t\t vOut.z = fma(" << mulZ << " * rad, sigmas, vIn.z);\n" + << "\t\t outPoint->m_ColorX = fabs(fmod(fma(" << mulC << ", randc * dist, outPoint->m_ColorX), (real_t)(1.0)));\n" << "\t\t break;\n" << "\t\t }\n" << "\t\t}\n" @@ -2665,7 +2680,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr" }; + return vector { "Sqr", "Zeps" }; } virtual void Precalc() override @@ -2768,9 +2783,9 @@ public: else { const T rIn = std::sqrt(helper.m_PrecalcSumSquares + SQR(helper.In.z)); - const T sigma = std::asin(helper.In.z / rIn) + m_MulZ * random.z * dist; - const T phi = helper.m_PrecalcAtanyx + m_MulY * random.y * dist; const T r = rIn + m_MulX * random.x * dist; + const T phi = helper.m_PrecalcAtanyx + m_MulY * random.y * dist; + const T sigma = std::asin(helper.In.z / rIn) + m_MulZ * random.z * dist; const T sigmas = std::sin(sigma); const T sigmac = std::cos(sigma); const T phis = std::sin(phi); @@ -2803,34 +2818,37 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string blurType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string blurShape = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string blurType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string blurShape = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string blurStrength = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string minDist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invertDist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string mulC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centerX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centerY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centerZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rMax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string minDist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invertDist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mulC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centerX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centerY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centerZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rMax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tconst real_t randx = MwcNext0505(mwc);\n" << "\t\tconst real_t randy = MwcNext0505(mwc);\n" << "\t\tconst real_t randz = MwcNext0505(mwc);\n" << "\t\tconst real_t randc = MwcNext0505(mwc);\n" + << "\t\tconst real_t xmx = vIn.x - " << centerX << ";\n" + << "\t\tconst real_t ymy = vIn.y - " << centerY << ";\n" + << "\t\tconst real_t zmz = vIn.z - " << centerZ << ";\n" << "\t\treal_t radius;\n" << "\n" << "\t\tswitch ((int)" << blurShape << ")\n" << "\t\t{\n" << "\t\t case 0:\n" - << "\t\t radius = sqrt(Sqr(vIn.x - " << centerX << ") + Sqr(vIn.y - " << centerY << ") + Sqr(vIn.z - " << centerZ << "));\n" + << "\t\t radius = sqrt(fma(xmx, xmx, fma(ymy, ymy, SQR(zmz))));\n" << "\t\t break;\n" << "\t\t case 1:\n" - << "\t\t radius = max(fabs(vIn.x - " << centerX << "), max(fabs(vIn.y - " << centerY << "), (fabs(vIn.z - " << centerZ << "))));\n" + << "\t\t radius = max(fabs(xmx), max(fabs(ymy), (fabs(zmz))));\n" << "\t\t break;\n" << "\t\t}\n" << "\n" @@ -2848,10 +2866,10 @@ public: << "\t\t real_t phis = sin(phi);\n" << "\t\t real_t phic = cos(phi);\n" << "\n" - << "\t\t vOut.x = vIn.x + " << mulX << " * rad * sigmac * phic;\n" - << "\t\t vOut.y = vIn.y + " << mulY << " * rad * sigmac * phis;\n" - << "\t\t vOut.z = vIn.z + " << mulZ << " * rad * sigmas;\n" - << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + " << mulC << " * randc * dist, (real_t)(1.0)));\n" + << "\t\t vOut.x = fma(" << mulX << " * rad, sigmac * phic, vIn.x);\n" + << "\t\t vOut.y = fma(" << mulY << " * rad, sigmac * phis, vIn.y);\n" + << "\t\t vOut.z = fma(" << mulZ << " * rad, sigmas, vIn.z);\n" + << "\t\t outPoint->m_ColorX = fabs(fmod(fma(" << mulC << ", randc * dist, outPoint->m_ColorX), (real_t)(1.0)));\n" << "\t\t }\n" << "\t\t break;\n" << "\t\tcase 1:\n" @@ -2863,10 +2881,10 @@ public: << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t real_t rIn = sqrt(precalcSumSquares + SQR(vIn.z));\n" - << "\t\t real_t sigma = asin(vIn.z / rIn) + " << mulZ << " * randz * dist;\n" - << "\t\t real_t phi = precalcAtanyx + " << mulY << " * randy * dist;\n" - << "\t\t real_t r = rIn + " << mulX << " * randx * dist;\n" + << "\t\t real_t rIn = Zeps(sqrt(fma(vIn.z, vIn.z, precalcSumSquares)));\n" + << "\t\t real_t r = fma(" << mulX << ", randx * dist, rIn);\n" + << "\t\t real_t phi = fma(" << mulY << ", randy * dist, precalcAtanyx);\n" + << "\t\t real_t sigma = fma(" << mulZ << ", randz * dist, asin(vIn.z / rIn));\n" << "\t\t real_t sigmas = sin(sigma);\n" << "\t\t real_t sigmac = cos(sigma);\n" << "\t\t real_t phis = sin(phi);\n" @@ -2875,17 +2893,17 @@ public: << "\t\t vOut.x = r * sigmac * phic;\n" << "\t\t vOut.y = r * sigmac * phis;\n" << "\t\t vOut.z = r * sigmas;\n" - << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + " << mulC << " * randc * dist, (real_t)(1.0)));\n" + << "\t\t outPoint->m_ColorX = fabs(fmod(fma(" << mulC << ", randc * dist, outPoint->m_ColorX), (real_t)(1.0)));\n" << "\t\t }\n" << "\t\t break;\n" << "\t\tcase 2:\n" << "\t\t {\n" - << "\t\t real_t coeff = " << rMax << " <= EPS ? dist : dist + " << alpha << " * (LogMap(dist) - dist);\n" + << "\t\t real_t coeff = " << rMax << " <= EPS ? dist : fma(" << alpha << ", (LogMap(dist) - dist), dist);\n" << "\n" - << "\t\t vOut.x = vIn.x + LogMap(" << mulX << ") * LogScale(randx) * coeff;\n" - << "\t\t vOut.y = vIn.y + LogMap(" << mulY << ") * LogScale(randy) * coeff;\n" - << "\t\t vOut.z = vIn.z + LogMap(" << mulZ << ") * LogScale(randz) * coeff;\n" - << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + LogMap(" << mulC << ") * LogScale(randc) * coeff, (real_t)(1.0)));\n" + << "\t\t vOut.x = fma(LogMap(" << mulX << "), LogScale(randx) * coeff, vIn.x);\n" + << "\t\t vOut.y = fma(LogMap(" << mulY << "), LogScale(randy) * coeff, vIn.y);\n" + << "\t\t vOut.z = fma(LogMap(" << mulZ << "), LogScale(randz) * coeff, vIn.z);\n" + << "\t\t outPoint->m_ColorX = fabs(fmod(fma(LogMap(" << mulC << "), LogScale(randc) * coeff, outPoint->m_ColorX), (real_t)(1.0)));\n" << "\t\t }\n" << "\t\t break;\n" << "\t\t}\n" @@ -2895,7 +2913,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "SignNz", "LogMap", "LogScale", "Sqr" }; + return vector { "SignNz", "LogMap", "LogScale", "Sqr", "Zeps" }; } virtual void Precalc() override @@ -2994,50 +3012,50 @@ public: ostringstream ss, ss2; intmax_t i = 0, varIndex = IndexInXform(); ss2 << "_" << XformIndexInEmber() << "]"; - string index = ss2.str(); + string index = ss2.str(); string weight = WeightDefineString(); - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sinC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cosC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hb = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ab = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ac = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ba = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string bc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ca = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cb = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s2a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s2b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s2c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s2ab = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s2ac = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s2bc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sinC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cosC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hb = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ab = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ac = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ba = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string bc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ca = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cb = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s2a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s2b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s2c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s2ab = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s2ac = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s2bc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string width1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string width2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string width3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tint m, n;\n" << "\t\treal_t alpha, beta, offsetAl, offsetBe, offsetGa, x, y;\n" << "\n" << "\t\t{\n"//DirectTrilinear function extracted out here. << "\t\t alpha = vIn.y + " << radius << ";\n" - << "\t\t beta = vIn.x * " << sinC << " - vIn.y * " << cosC << " + " << radius << ";\n" + << "\t\t beta = fma(vIn.x, " << sinC << ", fma(-vIn.y, " << cosC << ", " << radius << "));\n" << "\t\t}\n" << "\n" << "\t\tm = floor(alpha / " << s2a << ");\n" << "\t\toffsetAl = alpha - m * " << s2a << ";\n" << "\t\tn = floor(beta / " << s2b << ");\n" << "\t\toffsetBe = beta - n * " << s2b << ";\n" - << "\t\toffsetGa = " << s2c << " - " << ac << " * offsetAl - " << bc << " * offsetBe;\n" + << "\t\toffsetGa = " << s2c << " + fma(-" << ac << ", offsetAl, -" << bc << " * offsetBe);\n" << "\n" << "\t\tif (offsetGa > 0)\n" << "\t\t{\n" @@ -3097,10 +3115,10 @@ public: << "\t\tbeta += n * " << s2b << ";\n" << "\n" << "\t\t{\n"//InverseTrilinear function extracted out here. - << "\t\t real_t inx = (beta - " << radius << " + (alpha - " << radius << ") * " << cosC << ") / " << sinC << ";\n" + << "\t\t real_t inx = fma(alpha - " << radius << ", " << cosC << ", beta - " << radius << ") / " << sinC << ";\n" << "\t\t real_t iny = alpha - " << radius << ";\n" - << "\t\t real_t angle = (atan2(iny, inx) + M_2PI * MwcNextRange(mwc, (int)" << absN << ")) / " << power << ";\n" - << "\t\t real_t r = " << weight << " * pow(SQR(inx) + SQR(iny), " << cn << ");\n" + << "\t\t real_t angle = fma(M_2PI, (real_t)MwcNextRange(mwc, (int)" << absN << "), atan2(iny, inx)) / " << power << ";\n" + << "\t\t real_t r = " << weight << " * pow(fma(inx, inx, SQR(iny)), " << cn << ");\n" << "\n" << "\t\t x = r * cos(angle);\n" << "\t\t y = r * sin(angle);\n" @@ -3150,11 +3168,11 @@ public: " }\n" " else\n" " {\n" - " ga1 = width1 * ga + width2 * hc * ga / be;\n" - " de1 = width1 * be + width2 * s2ab * (3 - ga / be);\n" + " ga1 = fma(width1, ga, width2 * hc * ga / be);\n" + " de1 = fma(width1, be, width2 * s2ab * (3 - ga / be));\n" " }\n" "\n" - " *al1 = s2a - ba * de1 - ca * ga1;\n" + " *al1 = s2a + fma(-ba, de1, - ca * ga1);\n" " *be1 = de1;\n" " }\n" " else\n" @@ -3168,11 +3186,11 @@ public: " }\n" " else\n" " {\n" - " de1 = width1 * be + width2 * hb * be / ga;\n" - " ga1 = width1 * ga + width2 * s2ac * (3 - be / ga);\n" + " de1 = fma(width1, be, width2 * hb * be / ga);\n" + " ga1 = fma(width1, ga, width2 * s2ac * (3 - be / ga));\n" " }\n" "\n" - " *al1 = s2a - ba * de1 - ca * ga1;\n" + " *al1 = s2a + fma(-ba, de1, -ca * ga1);\n" " *be1 = de1;\n" " }\n" " else\n" @@ -3184,8 +3202,8 @@ public: " }\n" " else\n" " {\n" - " *be1 = width1 * be + width2 * hb * be / al;\n" - " *al1 = width1 * al + width2 * s2ac * (3 - be / al);\n" + " *be1 = fma(width1, be, width2 * hb * be / al);\n" + " *al1 = fma(width1, al, width2 * s2ac * (3 - be / al));\n" " }\n" " }\n" " }\n" @@ -3201,11 +3219,11 @@ public: " }\n" " else\n" " {\n" - " ga1 = width1 * ga + width2 * hc * ga / al;\n" - " de1 = width1 * al + width2 * s2ab * (3 - ga / al);\n" + " ga1 = fma(width1, ga, width2 * hc * ga / al);\n" + " de1 = fma(width1, al, width2 * s2ab * (3 - ga / al));\n" " }\n" "\n" - " *be1 = s2b - ab * de1 - cb * ga1;\n" + " *be1 = s2b + fma(-ab, de1, -cb * ga1);\n" " *al1 = de1;\n" " }\n" " else\n" @@ -3219,11 +3237,11 @@ public: " }\n" " else\n" " {\n" - " de1 = width1 * al + width2 * ha * al / ga;\n" - " ga1 = width1 * ga + width2 * s2bc * (3 - al / ga);\n" + " de1 = fma(width1, al, width2 * ha * al / ga);\n" + " ga1 = fma(width1, ga, width2 * s2bc * (3 - al / ga));\n" " }\n" "\n" - " *be1 = s2b - ab * de1 - cb * ga1;\n" + " *be1 = s2b + fma(-ab, de1, -cb * ga1);\n" " *al1 = de1;\n" " }\n" " else\n" @@ -3235,8 +3253,8 @@ public: " }\n" " else\n" " {\n" - " *al1 = width1 * al + width2 * ha * al / be;\n" - " *be1 = width1 * be + width2 * s2bc * (3 - al / be);\n" + " *al1 = fma(width1, al, width2 * ha * al / be);\n" + " *be1 = fma(width1, be, width2 * s2bc * (3 - al / be));\n" " }\n" " }\n" " }\n" @@ -3335,7 +3353,7 @@ private: { T inx = (be - m_Radius + (al - m_Radius) * m_CosC) / m_SinC; T iny = al - m_Radius; - T angle = (atan2(iny, inx) + M_2PI * (rand.Rand(int(m_AbsN)))) / m_Power; + T angle = (std::atan2(iny, inx) + M_2PI * (rand.Rand(int(m_AbsN)))) / m_Power; T r = m_Weight * std::pow(SQR(inx) + SQR(iny), m_Cn); x = r * std::cos(angle); y = r * std::sin(angle); @@ -3580,17 +3598,17 @@ public: string weight = WeightDefineString(); string index = ss2.str() + "]"; string stateIndex = ss2.str(); - string majp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string zlift = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string seg60xStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6;//Precalc. - string seg60yStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6; + string majp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string zlift = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string seg60xStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6;//Precalc. + string seg60yStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6; string seg120xStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 3; string seg120yStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 3; - string halfScale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rswtch = "varState->" + m_Params[i++].Name() + stateIndex;//State. - string fcycle = "varState->" + m_Params[i++].Name() + stateIndex; - string bcycle = "varState->" + m_Params[i++].Name() + stateIndex; + string halfScale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rswtch = "varState->" + m_Params[i++].Name() + stateIndex;//State. + string fcycle = "varState->" + m_Params[i++].Name() + stateIndex; + string bcycle = "varState->" + m_Params[i++].Name() + stateIndex; ss << "\t{\n" << "\t\tif (" << fcycle << " > 5)\n" << "\t\t{\n" @@ -3645,7 +3663,7 @@ public: << "\t\t}\n" << "\n" << "\t\tif (majplane == 2)\n" - << "\t\t vOut.z = vIn.z * 0.5 * " << zlift << " + (posNeg * boost);\n" + << "\t\t vOut.z = fma(vIn.z * 0.5, " << zlift << ", (posNeg * boost));\n" << "\t\telse\n" << "\t\t vOut.z = vIn.z * 0.5 * " << zlift << ";\n" << "\n" @@ -3664,8 +3682,8 @@ public: << "\t\t " << bcycle << " = " << bcycle << " + 1;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.x = ((sumX + vIn.x) * " << halfScale << ") + (lrmaj * tempx);\n" - << "\t\tvOut.y = ((sumY + vIn.y) * " << halfScale << ") + (lrmaj * tempy);\n" + << "\t\tvOut.x = fma((sumX + vIn.x), " << halfScale << ", (lrmaj * tempx));\n" + << "\t\tvOut.y = fma((sumY + vIn.y), " << halfScale << ", (lrmaj * tempy));\n" << "\t}\n"; return ss.str(); } @@ -3759,7 +3777,7 @@ private: /// /// hexnix3D. /// This uses state and the OpenCL version looks different and better than the CPU. -/// It takes care of doing either a sum or produce of the output variables internally, +/// It takes care of doing either a sum or product of the output variables internally, /// rather than relying on the calling code of Xform::Apply() to do it. /// This is because different paths do different things to helper.Out.z /// @@ -3911,17 +3929,17 @@ public: string weight = WeightDefineString(); string index = ss2.str() + "]"; string stateIndex = ss2.str(); - string majp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string zlift = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string side3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string seg60xStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6;//Precalc. - string seg60yStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6; + string majp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string zlift = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string side3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string seg60xStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6;//Precalc. + string seg60yStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6; string seg120xStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 3; string seg120yStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 3; - string rswtch = "varState->" + m_Params[i++].Name() + stateIndex;//State. - string fcycle = "varState->" + m_Params[i++].Name() + stateIndex; - string bcycle = "varState->" + m_Params[i++].Name() + stateIndex; + string rswtch = "varState->" + m_Params[i++].Name() + stateIndex;//State. + string fcycle = "varState->" + m_Params[i++].Name() + stateIndex; + string bcycle = "varState->" + m_Params[i++].Name() + stateIndex; ss << "\t{\n" << "\t\tif (" << fcycle << " > 5)\n" << "\t\t{\n" @@ -4016,11 +4034,11 @@ public: << "\t\t{\n" << "\t\t if (posNeg > 0)\n" << "\t\t {\n" - << "\t\t vOut.z = (smooth * (vIn.z * scale * " << zlift << " + boost));\n" + << "\t\t vOut.z = (smooth * fma(vIn.z * scale, " << zlift << ", boost));\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.z = (sumZ - (2 * smooth * sumZ)) + (smooth * posNeg * (vIn.z * scale * " << zlift << " + boost));\n"; + << "\t\t vOut.z = fma(smooth * posNeg, fma(vIn.z * scale, " << zlift << ", boost), sumZ - (2 * smooth * sumZ));\n"; if (m_VarType == eVariationType::VARTYPE_REG) ss << "\t\t outPoint->m_Z = 0;\n"; @@ -4030,7 +4048,7 @@ public: << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" - << "\t\t vOut.z = smooth * (vIn.z * scale * " << zlift << " + (posNeg * boost));\n" + << "\t\t vOut.z = smooth * fma(vIn.z * scale, " << zlift << ", (posNeg * boost));\n" << "\t\t}\n" << "\n" << "\t\tif (" << rswtch << " <= 1)\n" @@ -4050,12 +4068,12 @@ public: << "\t\t " << bcycle << " = " << bcycle << " + 1;\n" << "\t\t}\n" << "\n" - << "\t\tsmRotxFP = (smooth * scale * sumX * tempx) - (smooth * scale * sumY * tempy);\n" - << "\t\tsmRotyFP = (smooth * scale * sumY * tempx) + (smooth * scale * sumX * tempy);\n" - << "\t\tsmRotxFT = (vIn.x * smooth * scale * tempx) - (vIn.y * smooth * scale * tempy);\n" - << "\t\tsmRotyFT = (vIn.y * smooth * scale * tempx) + (vIn.x * smooth * scale * tempy);\n" - << "\t\tvOut.x = sumX * (1 - smooth) + smRotxFP + smRotxFT + smooth * lrmaj * scale3 * tempx;\n" - << "\t\tvOut.y = sumY * (1 - smooth) + smRotyFP + smRotyFT + smooth * lrmaj * scale3 * tempy;\n" + << "\t\tsmRotxFP = fma(smooth * scale, sumX * tempx, -(smooth * scale * sumY * tempy));\n" + << "\t\tsmRotyFP = fma(smooth * scale, sumY * tempx, (smooth * scale * sumX * tempy));\n" + << "\t\tsmRotxFT = fma(vIn.x * smooth, scale * tempx, -(vIn.y * smooth * scale * tempy));\n" + << "\t\tsmRotyFT = fma(vIn.y * smooth, scale * tempx, (vIn.x * smooth * scale * tempy));\n" + << "\t\tvOut.x = fma(sumX, (1 - smooth), fma(smooth * lrmaj, scale3 * tempx, smRotxFP + smRotxFT));\n" + << "\t\tvOut.y = fma(sumY, (1 - smooth), fma(smooth * lrmaj, scale3 * tempy, smRotyFP + smRotyFT));\n" << "\t}\n"; return ss.str(); } @@ -4068,6 +4086,7 @@ public: string prefix = Prefix(); //CPU sets fycle and bcycle to 0 at the beginning in Precalc(). //Set to random in OpenCL since a value can't be set once and kept between kernel launches without writing it back to an OpenCL buffer. + //This doesn't seem to make a difference from setting them to 0, but do it anyway because it seems more correct. ss << "\n\tvarState." << prefix << "hexnix3D_rswtch" << stateIndex << " = trunc(MwcNext01(&mwc) * 3.0);"; ss << "\n\tvarState." << prefix << "hexnix3D_fcycle" << stateIndex << " = trunc(MwcNext01(&mwc) * 5.0);"; ss << "\n\tvarState." << prefix << "hexnix3D_bcycle" << stateIndex << " = trunc(MwcNext01(&mwc) * 2.0);"; @@ -4231,8 +4250,8 @@ public: if (m_VarType == eVariationType::VARTYPE_REG) { ss - << "\t\tvOut.x = c != 0 ? outPoint->m_X + i.x * " << weight << " : " << dropoff << ";\n" - << "\t\tvOut.y = c != 0 ? outPoint->m_Y + i.y * " << weight << " : " << dropoff << ";\n" + << "\t\tvOut.x = c != 0 ? fma(i.x, " << weight << ", outPoint->m_X) : " << dropoff << ";\n" + << "\t\tvOut.y = c != 0 ? fma(i.y, " << weight << ", outPoint->m_Y) : " << dropoff << ";\n" << "\t\toutPoint->m_X = 0;\n" << "\t\toutPoint->m_Y = 0;\n"; } diff --git a/Source/Ember/Variations06.h b/Source/Ember/Variations06.h index f53458d..c01a9eb 100644 --- a/Source/Ember/Variations06.h +++ b/Source/Ember/Variations06.h @@ -145,11 +145,11 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string cellsize = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rotate = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rotsin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rotcos = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rotate = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rotsin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rotcos = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tint i, j;\n" << "\t\treal_t di, dj;\n" @@ -170,15 +170,15 @@ public: << "\t\tU.x = vIn.x;\n" << "\t\tU.y = vIn.y;\n" << "\n" - << "\t\tXCh = floor((AXhXo * U.x + AXhYo * U.y) / s);\n" - << "\t\tYCh = floor((AYhXo * U.x + AYhYo * U.y) / s);\n" + << "\t\tXCh = floor(fma(AXhXo, U.x, AXhYo * U.y) / s);\n" + << "\t\tYCh = floor(fma(AYhXo, U.x, AYhYo * U.y) / s);\n" << "\n" << "\t\tfor (i = 0, di = XCh; i < 2; di += 1, i++)\n" << "\t\t{\n" << "\t\t for (j = 0, dj = YCh; j < 2; dj += 1, j++)\n" << "\t\t {\n" - << "\t\t P[(i * 2) + j].x = (AXoXh * di + AXoYh * dj) * s;\n" - << "\t\t P[(i * 2) + j].y = (AYoXh * di + AYoYh * dj) * s;\n" + << "\t\t P[(i * 2) + j].x = fma(AXoXh, di, AXoYh * dj) * s;\n" + << "\t\t P[(i * 2) + j].y = fma(AYoXh, di, AYoYh * dj) * s;\n" << "\t\t }\n" << "\t\t}\n" << "\n" @@ -187,8 +187,8 @@ public: << "\t\tXCh += offset[q].x;\n" << "\t\tYCh += offset[q].y;\n" << "\n" - << "\t\tXCo = (AXoXh * XCh + AXoYh * YCh) * s;\n" - << "\t\tYCo = (AYoXh * XCh + AYoYh * YCh) * s;\n" + << "\t\tXCo = fma(AXoXh, XCh, AXoYh * YCh) * s;\n" + << "\t\tYCo = fma(AYoXh, XCh, AYoYh * YCh) * s;\n" << "\t\tP[0].x = XCo;\n" << "\t\tP[0].y = YCo;\n" << "\n" @@ -212,8 +212,8 @@ public: << "\n" << "\t\ttrgL = pow(fabs(L1), " << power << ") * " << scale << ";\n" << "\n" - << "\t\tVx = DXo * " << rotcos << " + DYo * " << rotsin << ";\n" - << "\t\tVy = -DXo * " << rotsin << " + DYo * " << rotcos << ";\n" + << "\t\tVx = fma( DXo, " << rotcos << ", DYo * " << rotsin << ");\n" + << "\t\tVy = fma(-DXo, " << rotsin << ", DYo * " << rotcos << ");\n" << "\n" << "\t\tU.x = Vx + P[0].x;\n" << "\t\tU.y = Vy + P[0].y;\n" @@ -229,7 +229,7 @@ public: << "\t\t if (L > 0.8)\n" << "\t\t R = trgL / L2;\n" << "\t\t else\n" - << "\t\t R = ((trgL / L1) * (0.8 - L) + (trgL / L2) * (L - 0.5)) / 0.3;\n" + << "\t\t R = fma(trgL / L1, (real_t)(0.8) - L, (trgL / L2) * (L - 0.5)) / 0.3;\n" << "\t\t}\n" << "\n" << "\t\tVx *= R;\n" @@ -383,31 +383,31 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string numEdges = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string numStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ratioStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ratioHole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string circumCircle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string adjustToLinear = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string equalBlur = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string exactCalc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string highlightEdges = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string numEdges = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string numStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ratioStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ratioHole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string circumCircle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string adjustToLinear = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string equalBlur = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string exactCalc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string highlightEdges = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ratioComplement = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. - string midAngle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string angStart = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string angStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hasStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string negStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string maxStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string tan90M2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string arcTan1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string arcTan2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string speedCalc1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string speedCalc2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string adjustedWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string midAngle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angStart = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hasStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string negStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string maxStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string tan90M2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string arcTan1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string arcTan2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string speedCalc1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string speedCalc2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string adjustedWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t xTmp, yTmp;\n" << "\t\tRandXyParams params;\n" @@ -444,8 +444,8 @@ public: << "\t\txTmp = params.X;\n" << "\t\tyTmp = params.Y;\n" << "\n" - << "\t\tparams.X = " << cosa << " * xTmp - " << sina << " * yTmp;\n" - << "\t\tparams.Y = " << sina << " * xTmp + " << cosa << " * yTmp;\n" + << "\t\tparams.X = fma(" << cosa << ", xTmp, -(" << sina << " * yTmp));\n" + << "\t\tparams.Y = fma(" << sina << ", xTmp, " << cosa << " * yTmp);\n" << "\n" << "\t\tvOut.x = " << adjustedWeight << " * params.X;\n" << "\t\tvOut.y = " << adjustedWeight << " * params.Y;\n" @@ -686,7 +686,7 @@ public: "\n" " xTmp = params->Tan90M2 / (params->Tan90M2 - tan(angXY));\n" " yTmp = xTmp * tan(angXY);\n" - " params->LenOuterEdges = sqrt(SQR(xTmp) + SQR(yTmp));\n" + " params->LenOuterEdges = sqrt(fma(xTmp, xTmp, SQR(yTmp)));\n" "\n" " if (params->ExactCalc == 1)\n" " {\n" @@ -722,23 +722,23 @@ public: " if (params->CircumCircle == 1)\n" " {\n" " if (params->EqualBlur == 1)\n" - " ranTmp = params->LenInnerEdges + sqrt(MwcNext01(mwc)) * (1 - params->LenInnerEdges + EPS);\n" + " ranTmp = fma(sqrt(MwcNext01(mwc)), (1 - params->LenInnerEdges + EPS), params->LenInnerEdges);\n" " else\n" - " ranTmp = params->LenInnerEdges + MwcNext01(mwc) * (1 - params->LenInnerEdges + EPS);\n" + " ranTmp = fma(MwcNext01(mwc), (1 - params->LenInnerEdges + EPS), params->LenInnerEdges);\n" " }\n" " else\n" " {\n" " if (params->EqualBlur == 1)\n" - " ranTmp = params->LenInnerEdges + sqrt(MwcNext01(mwc)) * (params->LenOuterEdges - params->LenInnerEdges);\n" + " ranTmp = fma(sqrt(MwcNext01(mwc)), (params->LenOuterEdges - params->LenInnerEdges), params->LenInnerEdges);\n" " else\n" - " ranTmp = params->LenInnerEdges + MwcNext01(mwc) * (params->LenOuterEdges - params->LenInnerEdges);\n" + " ranTmp = fma(MwcNext01(mwc), (params->LenOuterEdges - params->LenInnerEdges), params->LenInnerEdges);\n" " }\n" " }\n" " }\n" "\n" " params->X *= ranTmp;\n" " params->Y *= ranTmp;\n" - " params->LenXY = sqrt(SQR(params->X) + SQR(params->Y));\n" + " params->LenXY = sqrt(fma(params->X, params->X, SQR(params->Y)));\n" "}\n\n" ; } @@ -1207,13 +1207,13 @@ public: string index = ss2.str() + "]"; string stateIndex = ss2.str(); string polarweight = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string t = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string tempRad = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string abss = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string abst = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string st = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string t = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string tempRad = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string abss = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string abst = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string st = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string axStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 2; string bxStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 2; string cxStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 2; @@ -1289,8 +1289,8 @@ public: ss << "\t\t}\n" << "\n" - << "\t\tvOut.x = tempOut.x + (" << weight << " * x);\n" - << "\t\tvOut.y = tempOut.y + (" << weight << " * y);\n" + << "\t\tvOut.x = fma(" << weight << ", x, tempOut.x);\n" + << "\t\tvOut.y = fma(" << weight << ", y, tempOut.y);\n" << "\t\tvOut.z = " << weight << " * z;\n" << "\t}\n"; return ss.str(); @@ -1319,7 +1319,7 @@ public: " if (radius == 0)\n" " return 1;\n" "\n" - " *r = sqrt(SQR((*p).x) + SQR((*p).y));\n" + " *r = sqrt(fma((*p).x, (*p).x, SQR((*p).y)));\n" " return (*r <= radius);\n" "}\n" "\n" @@ -1333,12 +1333,12 @@ public: " real_t d02 = dot(v0, v2);\n" " real_t d11 = dot(v1, v1);\n" " real_t d12 = dot(v1, v2);\n" - " real_t denom = (d00 * d11 - d01 * d01);\n" + " real_t denom = fma(d00, d11, -(d01 * d01));\n" "\n" " if (denom != 0)\n" " {\n" - " *u = (d11 * d02 - d01 * d12) / denom;\n" - " *v = (d00 * d12 - d01 * d02) / denom;\n" + " *u = fma(d11, d02, -(d01 * d12)) / denom;\n" + " *v = fma(d00, d12, -(d01 * d02)) / denom;\n" " }\n" " else\n" " *u = *v = 0;\n" @@ -1610,7 +1610,7 @@ public: << "\t\t {\n" << "\t\t do\n" << "\t\t {\n" - << "\t\t yTmp = " << top << " + MwcNext01(mwc) * " << yInt2 << ";\n" + << "\t\t yTmp = fma(MwcNext01(mwc), " << yInt2 << ", " << top << ");\n" << "\t\t xTmp = " << right << " - pow(MwcNext01(mwc), " << directBlur << ") * " << ratioBlur << " * " << minInt2 << ";\n" << "\t\t } while ((yTmp - " << y0c << ") / Zeps(xTmp - " << x0c << ") < -1);\n" << "\n" @@ -2004,22 +2004,22 @@ public: ss2 << "_" << XformIndexInEmber(); string weight = WeightDefineString(); string index = ss2.str() + "]"; - string numberStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ratioStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string angleHole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string exponentZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string symmetryZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string modusBlur = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string numberStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ratioStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angleHole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string exponentZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string symmetryZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string modusBlur = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string absNumberStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string angHoleTemp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string angStrip = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string angStrip1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string angStrip2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string angHoleComp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invHole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angHoleTemp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angStrip = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angStrip1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angStrip2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angHoleComp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invHole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" "\t\treal_t x = vIn.x, y = vIn.y, z = vIn.z;\n" "\t\treal_t xTmp, yTmp, angTmp, angRot, fac;\n" @@ -2052,8 +2052,8 @@ public: "\t\t {\n" "\t\t if (" << ratioStripes << " == 1)\n" "\t\t {\n" - "\t\t xTmp = " << c << " * x - " << s << " * y;\n" - "\t\t yTmp = " << s << " * x + " << c << " * y;\n" + "\t\t xTmp = fma(" << c << ", x, -(" << s << " * y));\n" + "\t\t yTmp = fma(" << s << ", x, " << c << " * y);\n" "\t\t x = xTmp;\n" "\t\t y = yTmp;\n" "\t\t }\n" @@ -2062,8 +2062,8 @@ public: "\t\t angRot = (angXY - " << angStrip1 << ") / Zeps(" << angStrip2 << " - " << angStrip1 << ");\n" "\t\t angRot = angXY - angRot * " << angStrip1 << ";\n" "\t\t s = sincos(angRot, &c);\n" - "\t\t xTmp = c * x - s * y;\n" - "\t\t yTmp = s * x + c * y;\n" + "\t\t xTmp = fma(c, x, -(s * y));\n" + "\t\t yTmp = fma(s, x, c * y);\n" "\t\t x = xTmp;\n" "\t\t y = yTmp;\n" "\t\t }\n" @@ -2083,8 +2083,8 @@ public: "\t\t {\n" "\t\t if (" << absNumberStripes << " == 1)\n" "\t\t {\n" - "\t\t xTmp = " << c << " * x - " << s << " * y;\n" - "\t\t yTmp = " << s << " * x + " << c << " * y;\n" + "\t\t xTmp = fma(" << c << ", x, -(" << s << " * y));\n" + "\t\t yTmp = fma(" << s << ", x, " << c << " * y);\n" "\t\t x = xTmp;\n" "\t\t y = yTmp;\n" "\t\t }\n" @@ -2093,8 +2093,8 @@ public: "\t\t angRot = (angXY - " << angStrip1 << ") / " << angStrip1 << ";\n" "\t\t angRot = angXY - angRot * (" << angStrip2 << " - " << angStrip1 << ");\n" "\t\t s = sincos(angRot, &c);\n" - "\t\t xTmp = c * x - s * y;\n" - "\t\t yTmp = s * x + c * y;\n" + "\t\t xTmp = fma(c, x, -(s * y));\n" + "\t\t yTmp = fma(s, x, c * y);\n" "\t\t x = xTmp;\n" "\t\t y = yTmp;\n" "\t\t }\n" @@ -2111,9 +2111,9 @@ public: "\t\t z = 2 / pow(rad, " << exponentZ << ") - 1;\n" "\t\t\n" "\t\t if (" << exponentZ << " <= 2)\n" - "\t\t angZ = MPI - acos((z / (SQR(x) + SQR(y) + SQR(z))));\n" + "\t\t angZ = MPI - acos((z / fma(x, x, fma(y, y, SQR(z)))));\n" "\t\t else\n" - "\t\t angZ = MPI - atan2(Sqr(SQR(x) + SQR(y)), z);\n" + "\t\t angZ = MPI - atan2(Sqr(fma(x, x, SQR(y))), z);\n" "\t\t}\n" "\t\telse\n" "\t\t{\n" @@ -2135,7 +2135,7 @@ public: "\t\t }\n" "\t\t else\n" "\t\t {\n" - "\t\t angTmp = (MPI - angZ) / Zeps(" << angHoleComp << " * " << angHoleTemp << " - MPI2);\n" + "\t\t angTmp = (MPI - angZ) / Zeps(fma(" << angHoleComp << ", " << angHoleTemp << ", -MPI2));\n" "\t\t angZ -= MPI2;\n" "\t\t fac = cos(angTmp) / cos(angZ);\n" "\t\t x *= fac;\n" @@ -2156,7 +2156,7 @@ public: "\t\t }\n" "\t\t else\n" "\t\t {\n" - "\t\t angTmp = MPI - angZ / Zeps(" << angHoleComp << " * " << angHoleTemp << " - MPI2);\n" + "\t\t angTmp = MPI - angZ / Zeps(fma(" << angHoleComp << ", " << angHoleTemp << ", -MPI2));\n" "\t\t angZ -= MPI2;\n" "\t\t fac = cos(angTmp) / cos(angZ);\n" "\t\t x *= fac;\n" @@ -2757,40 +2757,40 @@ public: ss2 << "_" << XformIndexInEmber(); string weight = WeightDefineString(); string index = ss2.str() + "]"; - string synthA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthMode = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthMix = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthMode = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthMix = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string synthSmooth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthB = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthBType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthBSkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthBFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthBPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthB = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthBType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthBSkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthBFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthBPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string synthBLayer = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthCType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthCSkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthCFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthCPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthC = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthCType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthCSkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthCFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthCPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string synthCLayer = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthDType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthDSkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthDFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthDPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthDType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthDSkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthDFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthDPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string synthDLayer = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthE = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthEType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthESkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthEFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthEPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthE = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthEType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthESkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthEFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthEPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string synthELayer = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthF = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthFType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthFSkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthFFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string synthFPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthF = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthFType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthFSkew = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthFFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string synthFPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string synthFLayer = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t Vx, Vy, radius, theta;\n" @@ -2860,8 +2860,8 @@ public: << "\t\t break;\n" << "\n" << "\t\tcase MODE_BLUR_LEGACY:\n" - << "\t\t radius = (MwcNext01(mwc) + MwcNext01(mwc) + 0.002 * MwcNext01(mwc)) / 2.002;\n" - << "\t\t theta = M_2PI * MwcNext01(mwc) - MPI;\n" + << "\t\t radius = fma((real_t)(0.002), MwcNext01(mwc), MwcNext01(mwc) + MwcNext01(mwc)) / 2.002;\n" + << "\t\t theta = fma(M_2PI, MwcNext01(mwc), -MPI);\n" << "\t\t Vx = radius * sin(theta);\n" << "\t\t Vy = radius * cos(theta);\n" << "\t\t radius = pow(Zeps(radius * radius), " << synthPower << " / 2);\n" @@ -2873,7 +2873,7 @@ public: << "\n" << "\t\tcase MODE_BLUR_NEW:\n" << "\t\t radius = 0.5 * (MwcNext01(mwc) + MwcNext01(mwc));\n" - << "\t\t theta = M_2PI * MwcNext01(mwc) - MPI;\n" + << "\t\t theta = fma(M_2PI, MwcNext01(mwc), -MPI);\n" << "\t\t radius = pow(Zeps(SQR(radius)), -" << synthPower << " / 2);\n" << "\t\t thetaFactor = SynthValue(&synth, theta);\n" << "\t\t radius = Interpolate(radius, thetaFactor, synthSmooth);\n" @@ -2883,7 +2883,7 @@ public: << "\t\t break;\n" << "\n" << "\t\tcase MODE_BLUR_ZIGZAG:\n" - << "\t\t Vy = 1 + 0.1 * (MwcNext01(mwc) + MwcNext01(mwc) - 1) * " << synthPower << ";\n" + << "\t\t Vy = fma((real_t)(0.1), (MwcNext01(mwc) + MwcNext01(mwc) - 1) * " << synthPower << ", (real_t)(1.0));\n" << "\t\t theta = 2 * asin((MwcNext01(mwc) - 0.5) * 2);\n" << "\t\t thetaFactor = SynthValue(&synth, theta);\n" << "\t\t Vy = Interpolate(Vy, thetaFactor, synthSmooth);\n" @@ -2950,8 +2950,8 @@ public: << "\t\tcase MODE_SINUSOIDAL:\n" << "\t\t Vx = vIn.x;\n" << "\t\t Vy = vIn.y;\n" - << "\t\t vOut.x = " << weight << " * (SynthValue(&synth, Vx) - 1 + (1 - " << synthMix << ") * sin(Vx));\n" - << "\t\t vOut.y = " << weight << " * (SynthValue(&synth, Vy) - 1 + (1 - " << synthMix << ") * sin(Vy));\n" + << "\t\t vOut.x = " << weight << " * fma((real_t)(1.0) - " << synthMix << ", sin(Vx), SynthValue(&synth, Vx) - (real_t)(1.0));\n" + << "\t\t vOut.y = " << weight << " * fma((real_t)(1.0) - " << synthMix << ", sin(Vy), SynthValue(&synth, Vy) - (real_t)(1.0));\n" << "\t\t break;\n" << "\n" << "\t\tcase MODE_SWIRL:\n" @@ -2959,8 +2959,8 @@ public: << "\t\t Vy = vIn.y;\n" << "\t\t radius = pow(Zeps(precalcSumSquares), " << synthPower << " / 2);\n" << "\t\t SynthSinCos(&synth, radius, &s, &c, synthSmooth);\n" - << "\t\t vOut.x = " << weight << " * (s * Vx - c * Vy);\n" - << "\t\t vOut.y = " << weight << " * (c * Vx + s * Vy);\n" + << "\t\t vOut.x = " << weight << " * fma(s, Vx, -(c * Vy));\n" + << "\t\t vOut.y = " << weight << " * fma(c, Vx, s * Vy);\n" << "\t\t break;\n" << "\n" << "\t\tcase MODE_HYPERBOLIC:\n" @@ -3003,7 +3003,7 @@ public: << "\t\t radius = precalcSqrtSumSquares;\n" << "\t\t theta = precalcAtanxy;\n" << "\t\t mu = Zeps(SQR(" << synthPower << "));\n" - << "\t\t radius += -2 * mu * (int)((radius + mu) / (2 * mu)) + radius * (1 - mu);\n" + << "\t\t radius += fma((real_t)(-2.0) * mu, (real_t)(int)((radius + mu) / (2 * mu)), radius * ((real_t)(1.0) - mu));\n" << "\t\t SynthSinCos(&synth, radius, &s, &c, synthSmooth);\n" << "\t\t vOut.x = " << weight << " * s * theta;\n" << "\t\t vOut.y = " << weight << " * c * theta;\n" @@ -3019,7 +3019,7 @@ public: << "\t\t break;\n" << "\n" << "\t\tcase MODE_BLUR_RING:\n" - << "\t\t radius = 1 + 0.1 * (MwcNext01(mwc) + MwcNext01(mwc) - 1) * " << synthPower << ";\n" + << "\t\t radius = fma((real_t)(0.1) * " << synthPower << ", MwcNext01(mwc) + MwcNext01(mwc) - (real_t)(1.0), (real_t)(1.0));\n" << "\t\t theta = M_2PI * MwcNext01(mwc) - MPI;\n" << "\t\t thetaFactor = SynthValue(&synth, theta);\n" << "\t\t radius = Interpolate(radius, thetaFactor, synthSmooth);\n" @@ -3029,9 +3029,9 @@ public: << "\t\t break;\n" << "\n" << "\t\tcase MODE_BLUR_RING2:\n" - << "\t\t theta = M_2PI * MwcNext01(mwc) - MPI;\n" + << "\t\t theta = fma(M_2PI, MwcNext01(mwc), -MPI);\n" << "\t\t radius = pow(Zeps(MwcNext01(mwc)), " << synthPower << ");\n" - << "\t\t radius = SynthValue(&synth, theta) + 0.1 * radius;\n" + << "\t\t radius = fma((real_t)(0.1), radius, SynthValue(&synth, theta));\n" << "\t\t s = sincos(theta, &c);\n" << "\t\t vOut.x = " << weight << " * radius * s;\n" << "\t\t vOut.y = " << weight << " * radius * c;\n" @@ -3072,7 +3072,7 @@ public: << "\t\t Vx = vIn.x;\n" << "\t\t Vy = vIn.y;\n" << "\t\t mu = SynthValue(&synth, Vx) - 1;\n" - << "\t\t Vy = 2 * mu - Vy;\n" + << "\t\t Vy = fma((real_t)(2.0), mu, -Vy);\n" << "\t\t vOut.x = " << weight << " * Vx;\n" << "\t\t vOut.y = " << weight << " * Vy;\n" << "\t\t break;\n" @@ -3082,8 +3082,8 @@ public: << "\t\t Vy = vIn.y;\n" << "\t\t mu = SynthValue(&synth, Vx) - 1;\n" << "\t\t radius = SynthValue(&synth, Vy) - 1;\n" - << "\t\t Vy = 2 * mu - Vy;\n" - << "\t\t Vx = 2 * radius - Vx;\n" + << "\t\t Vy = fma((real_t)(2.0), mu, -Vy);\n" + << "\t\t Vx = fma((real_t)(2.0), radius, -Vx);\n" << "\t\t vOut.x = " << weight << " * Vx;\n" << "\t\t vOut.y = " << weight << " * Vy;\n" << "\t\t break;\n" @@ -3110,7 +3110,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps" }; + return vector { "Zeps", "Sqr" }; } virtual string OpenCLFuncsString() const override @@ -3201,16 +3201,16 @@ public: "{\n" " if (*synth != 0)\n" " {\n" - " *z = *phs + theta * *frq;\n" + " *z = fma(theta, *frq, *phs);\n" " *y = *z / M_2PI;\n" " *y -= floor(*y);\n" "\n" " if (*skew != 0)\n" " {\n" - " *z = 0.5 + 0.5 * *skew;\n" + " *z = fma(0.5, *skew, 0.5);\n" "\n" " if (*y > *z)\n" - " *y = 0.5 + 0.5 * (*y - *z) / Zeps(1 - *z);\n" + " *y = fma((real_t)(0.5), (*y - *z) / Zeps(1 - *z), (real_t)(0.5));\n" " else\n" " *y = 0.5 - 0.5 * (*z - *y) / Zeps(*z);\n" " }\n" @@ -3230,13 +3230,13 @@ public: " *x = 1 - 2 * *y;\n" " break;\n" " case WAVE_TRIANGLE:\n" - " *x = *y > 0.5 ? 3 - 4 * *y : 2 * *y - 1;\n" + " *x = *y > 0.5 ? 3 - 4 * *y : fma((real_t)(2.0), *y, -1);\n" " break;\n" " case WAVE_CONCAVE:\n" - " *x = 8 * (*y - 0.5) * (*y - 0.5) - 1;\n" + " *x = fma((real_t)(8.0), Sqr(*y - 0.5), (real_t)(-1.0));\n" " break;\n" " case WAVE_CONVEX:\n" - " *x = 2 * sqrt(*y) - 1;\n" + " *x = fma((real_t)(2.0), sqrt(*y), (real_t)(-1.0));\n" " break;\n" " case WAVE_NGON:\n" " *y -= 0.5;\n" @@ -3257,14 +3257,14 @@ public: " *thetaFactor += *synth * *x;\n" " break;\n" " case LAYER_MULT:\n" - " *thetaFactor *= (1 + *synth * *x);\n" + " *thetaFactor *= fma(*synth, *x, (real_t)(1.0));\n" " break;\n" " case LAYER_MAX:\n" - " *z = *synthA + *synth * *x;\n" + " *z = fma(*synth, *x, *synthA);\n" " *thetaFactor = (*thetaFactor > *z ? *thetaFactor : *z);\n" " break;\n" " case LAYER_MIN:\n" - " *z = *synthA + *synth * *x;\n" + " *z = fma(*synth, *x, *synthA);\n" " *thetaFactor = (*thetaFactor < *z ? *thetaFactor : *z);\n" " break;\n" " }\n" @@ -3282,7 +3282,7 @@ public: " SynthValueProc(&(s->SynthA), &thetaFactor, theta, &(s->SynthE), &(s->SynthEPhs), &(s->SynthEFrq), &(s->SynthESkew), &x, &y, &z, &(s->SynthEType), &(s->SynthELayer));\n" " SynthValueProc(&(s->SynthA), &thetaFactor, theta, &(s->SynthF), &(s->SynthFPhs), &(s->SynthFFrq), &(s->SynthFSkew), &x, &y, &z, &(s->SynthFType), &(s->SynthFLayer));\n" "\n" - " return thetaFactor * s->SynthMix + (1 - s->SynthMix);\n" + " return fma(thetaFactor, s->SynthMix, (1 - s->SynthMix));\n" "}\n" "\n" "static real_t BezierQuadMap(real_t x, real_t m)\n" @@ -3308,9 +3308,9 @@ public: " t = x;\n" "\n" " if (fabs(m - 0.5) > 1e-10)\n" - " t = (-1 * m + sqrt(m * m + (1 - 2 * m) * x)) / (1 - 2 * m);\n" + " t = fma((real_t)(-1.0), m, sqrt(fma(m, m, (1 - 2 * m) * x))) / (1 - 2 * m);\n" "\n" - " return a * (x + (m - 1) * t * t);\n" + " return a * fma(m - (real_t)(1.0), SQR(t), x);\n" " }\n" "\n" " if ((1 < m) && (x <= 1))\n" @@ -3318,19 +3318,19 @@ public: " t = x;\n" "\n" " if (fabs(m - 2) > 1e-10)\n" - " t = (-1 * iM + sqrt(iM * iM + (1 - 2 * iM) * x)) / (1 - 2 * iM);\n" + " t = fma((real_t)(-1.0), iM, sqrt(fma(iM, iM, (1 - 2 * iM) * x))) / (1 - 2 * iM);\n" "\n" - " return a * (x + (m - 1) * t * t);\n" + " return a * fma(m - (real_t)(1.0), SQR(t), x);\n" " }\n" "\n" " if (m < 1)\n" " {\n" " t = sqrt((x - 1) / (L - 1));\n" - " return a * (x + (m - 1) * t * t + 2 * (1 - m) * t + (m - 1));\n" + " return a * fma((m - 1), t * t, x + fma((real_t)(2.0), (1 - m) * t, (m - 1)));\n" " }\n" "\n" - " t = (1 - m) + sqrt((m - 1) * (m - 1) + (x - 1));\n" - " return a * (x + (m - 1) * t * t - 2 * (m - 1) * t + (m - 1));\n" + " t = (1 - m) + sqrt(fma((m - 1), (m - 1), (x - 1)));\n" + " return a * fma((m - 1), t * t, x - fma((real_t)(2.0), (m - 1) * t, (m - 1)));\n" "}\n" "\n" "static real_t Interpolate(real_t x, real_t m, int lerpType)\n" @@ -3357,8 +3357,8 @@ public: " *c = *c * SynthValue(synth, theta + MPI / 2);\n" " break;\n" " case SINCOS_MIXIN:\n" - " *s = (1 - synth->SynthMix) * *s + (SynthValue(synth, theta) - 1);\n" - " *c = (1 - synth->SynthMix) * *c + (SynthValue(synth, theta + MPI / 2) - 1);\n" + " *s = fma(((real_t)(1.0) - synth->SynthMix), *s, (SynthValue(synth, theta) - 1));\n" + " *c = fma(((real_t)(1.0) - synth->SynthMix), *c, (SynthValue(synth, theta + MPI / 2) - 1));\n" " break;\n" " }\n" "\n" @@ -3789,11 +3789,11 @@ public: " e.x = x * 2.5;\n" " e.y = y * 2.5;\n" " e.z = z * 2.5;\n" - " f.x = y * 2.5 + 30.2;\n" - " f.y = x * 2.5 - 12.1;\n" - " f.z = z * 2.5 + 19.8;\n" - " (*v).x = (x + d * SimplexNoise3D(&e, p, grad)) * s;\n" - " (*v).y = (y + d * SimplexNoise3D(&f, p, grad)) * s;\n" + " f.x = fma((real_t)y, (real_t)(2.5), (real_t)( 30.2));\n" + " f.y = fma((real_t)x, (real_t)(2.5), (real_t)(-12.1));\n" + " f.z = fma(z, (real_t)(2.5), (real_t)(19.8));\n" + " (*v).x = fma(d, SimplexNoise3D(&e, p, grad), (real_t)y) * s;\n" + " (*v).y = fma(d, SimplexNoise3D(&f, p, grad), (real_t)x) * s;\n" " }\n" "}\n" "\n"; @@ -4492,7 +4492,7 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t r2 = Sqr(sqrt(precalcSumSquares + SQR(vIn.z)));\n" + << "\t\treal_t r2 = Sqr(sqrt(fma(vIn.z, vIn.z, precalcSumSquares)));\n" << "\t\tvOut.x = " << weight << " * (fabs(vIn.x) >= 2 ? vIn.x / r2 : erf(vIn.x));\n" << "\t\tvOut.y = " << weight << " * (fabs(vIn.y) >= 2 ? vIn.y / r2 : erf(vIn.y));\n" << "\t\tvOut.z = " << weight << " * (fabs(vIn.z) >= 2 ? vIn.z / r2 : erf(vIn.z));\n" @@ -4623,24 +4623,24 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc - string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc + string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string oneOverSuperN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t a = precalcAtanyx;\n" @@ -4669,14 +4669,14 @@ public: << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(fma(" << hypergonD << ", " << hypergonD << ", -temp2))) / sqrt(temp2);\n" << "\t\t }\n" << "\t\t}\n" << "\n" << "\t\tif (" << star << "!= 0)\n" << "\t\t{\n" << "\t\t temp1 = tan(fabs(fmod(fabs(a), (real_t)M_2PI / " << starN << ") - MPI / " << starN << "));\n" - << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * fma(temp1, temp1, (real_t)(1.0)) / Sqr(temp1 + " << tanStarSlope << "));\n" << "\t\t}\n" << "\n" << "\t\tif (" << lituus << " != 0)\n" @@ -4696,7 +4696,8 @@ public: << "\t\t if (" << hypergon << " != 0.0)\n" << "\t\t {\n" << "\t\t temp1 = fmod(fabs(a2), (real_t)M_2PI / " << hypergonN << ") - MPI / " << hypergonN << ";\n" - << "\t\t temp2 = Sqr(tan(temp1)) + 1;\n" + << "\t\t real_t tantemp = tan(temp1);\n" + << "\t\t temp2 = fma(tantemp, tantemp, (real_t)(1.0));\n" << "\n" << "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n" << "\t\t {\n" @@ -4704,14 +4705,14 @@ public: << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t total2 += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t total2 += " << hypergon << " * (" << hypergonD << " - sqrt(fma(" << hypergonD << ", " << hypergonD << ", -temp2))) / sqrt(temp2);\n" << "\t\t }\n" << "\t\t }\n" << "\n" << "\t\t if (" << star << " != 0)\n" << "\t\t {\n" << "\t\t temp1 = tan(fabs(fmod(fabs(a2), (real_t)M_2PI / " << starN << ") - MPI / " << starN << "));\n" - << "\t\t total2 += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t total2 += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * fma(temp1, temp1, (real_t)(1.0)) / Sqr(temp1 + " << tanStarSlope << "));\n" << "\t\t }\n" << "\n" << "\t\t if (" << lituus << " != 0)\n" @@ -4875,23 +4876,23 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc - string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc + string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string oneOverSuperN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t a = precalcAtanyx;\n" @@ -4903,7 +4904,8 @@ public: << "\t\tif (" << hypergon << " != 0)\n" << "\t\t{\n" << "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - MPI / " << hypergonN << ";\n" - << "\t\t temp2 = Sqr(tan(temp1)) + 1;\n" + << "\t\treal_t tantemp = tan(temp1);\n" + << "\t\t temp2 = fma(tantemp, tantemp, (real_t)(1.0));\n" << "\n" << "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n" << "\t\t {\n" @@ -4911,14 +4913,14 @@ public: << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(fma(" << hypergonD << ", " << hypergonD << ", -temp2))) / sqrt(temp2);\n" << "\t\t }\n" << "\t\t}\n" << "\n" << "\t\tif (" << star << " != 0)\n" << "\t\t{\n" << "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - MPI / " << starN << "));\n" - << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * fma(temp1, temp1, (real_t)(1.0)) / Sqr(temp1 + " << tanStarSlope << "));\n" << "\t\t}\n" << "\n" << "\t\tif (" << lituus << " != 0)\n" @@ -4933,7 +4935,7 @@ public: << "\t\t total += " << super << " * pow(pow(fabs(c), " << superN2 << ") + pow(fabs(s), " << superN3 << "), " << oneOverSuperN1 << ");\n" << "\t\t}\n" << "\n" - << "\t\tr = " << weight << " * sqrt(precalcSumSquares + Sqr(total));\n" + << "\t\tr = " << weight << " * sqrt(fma(total, total, precalcSumSquares));\n" << "\t\ts = sincos(a, &c);\n" << "\t\tvOut.x = r * c;\n" << "\t\tvOut.y = r * s;\n" @@ -5030,14 +5032,15 @@ public: { temp1 = fmod(std::abs(a), M_2PI / m_HypergonN) - T(M_PI) / m_HypergonN; temp2 = Sqr(std::tan(temp1)) + 1; + auto hd2 = SQR(m_HypergonD); - if (temp2 >= Sqr(m_HypergonD)) + if (temp2 >= hd2) { total += m_Hypergon; } else { - total += m_Hypergon * (m_HypergonD - std::sqrt(Sqr(m_HypergonD) - temp2)) / std::sqrt(temp2); + total += m_Hypergon * (m_HypergonD - std::sqrt(hd2 - temp2)) / std::sqrt(temp2); } } @@ -5073,23 +5076,23 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc - string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc + string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string oneOverSuperN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t a = precalcAtanyx;\n" @@ -5102,21 +5105,22 @@ public: << "\t\t{\n" << "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - MPI / " << hypergonN << ";\n" << "\t\t temp2 = Sqr(tan(temp1)) + 1;\n" + << "\t\t real_t hd2 = SQR(" << hypergonD << ");\n" << "\n" - << "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n" + << "\t\t if (temp2 >= hd2)\n" << "\t\t {\n" << "\t\t total += " << hypergon << ";\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(hd2 - temp2)) / sqrt(temp2);\n" << "\t\t }\n" << "\t\t}\n" << "\n" << "\t\tif (" << star << " != 0)\n" << "\t\t{\n" << "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - MPI / " << starN << "));\n" - << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * fma(temp1, temp1, (real_t)(1.0)) / Sqr(temp1 + " << tanStarSlope << "));\n" << "\t\t}\n" << "\n" << "\t\tif (" << lituus << " != 0)\n" @@ -5228,14 +5232,15 @@ public: { temp1 = fmod(std::abs(a), M_2PI / m_HypergonN) - T(M_PI) / m_HypergonN; temp2 = Sqr(std::tan(temp1)) + 1; + auto hd2 = SQR(m_HypergonD); - if (temp2 >= Sqr(m_HypergonD)) + if (temp2 >= hd2) { total += m_Hypergon; } else { - total += m_Hypergon * (m_HypergonD - std::sqrt(Sqr(m_HypergonD) - temp2)) / std::sqrt(temp2); + total += m_Hypergon * (m_HypergonD - std::sqrt(hd2 - temp2)) / std::sqrt(temp2); } } @@ -5271,23 +5276,23 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc - string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc + string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string oneOverSuperN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t a = precalcAtanyx;\n" @@ -5301,21 +5306,22 @@ public: << "\t\t{\n" << "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - MPI / " << hypergonN << ";\n" << "\t\t temp2 = Sqr(tan(temp1)) + 1;\n" + << "\t\t real_t hd2 = SQR(" << hypergonD << ");\n" << "\n" - << "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n" + << "\t\t if (temp2 >= hd2)\n" << "\t\t {\n" << "\t\t total += " << hypergon << ";\n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(hd2 - temp2)) / sqrt(temp2);\n" << "\t\t }\n" << "\t\t}\n" << "\n" << "\t\tif (" << star << " != 0)\n" << "\t\t{\n" << "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - MPI / " << starN << "));\n" - << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * fma(temp1, temp1, (real_t)(1.0)) / Sqr(temp1 + " << tanStarSlope << "));\n" << "\t\t}\n" << "\n" << "\t\tif (" << lituus << " != 0)\n" diff --git a/Source/Ember/Variations07.h b/Source/Ember/Variations07.h index 5b02e19..93238af 100644 --- a/Source/Ember/Variations07.h +++ b/Source/Ember/Variations07.h @@ -154,46 +154,46 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string freqx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string freqy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string pwx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string pwy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scalex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pwx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pwy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scalex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scaleinfx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scaley = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaley = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scaleinfy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string unity = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string jacok = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string six = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. - string siy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string unity = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string jacok = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string six = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. + string siy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t CsX = 1;\n" << "\t\treal_t CsY = 1;\n" << "\t\treal_t jcbSn = 0, jcbCn, jcbDn;\n" - << "\t\tCsX = SafeDivInv(" << unity << ", (" << unity << " + Sqr(vIn.x)));\n" - << "\t\tCsX = CsX * " << six << " + " << scaleinfx << ";\n" - << "\t\tCsY = SafeDivInv(" << unity << ", (" << unity << " + Sqr(vIn.y)));\n" - << "\t\tCsY = CsY * " << siy << " + " << scaleinfy << ";\n" + << "\t\tCsX = SafeDivInv(" << unity << ", fma(vIn.x, vIn.x, " << unity << "));\n" + << "\t\tCsX = fma(CsX, " << six << ", " << scaleinfx << ");\n" + << "\t\tCsY = SafeDivInv(" << unity << ", fma(vIn.y, vIn.y, " << unity << "));\n" + << "\t\tCsY = fma(CsY, " << siy << ", " << scaleinfy << ");\n" << "\n" << "\t\tif (" << pwx << " >= 0 && " << pwx << " < 1e-4)\n" << "\t\t{\n" << "\t\t JacobiElliptic(vIn.y * " << freqx << ", " << jacok << ", &jcbSn, &jcbCn, &jcbDn);\n" - << "\t\t vOut.x = " << weight << " * (vIn.x + CsX * jcbSn);\n" + << "\t\t vOut.x = " << weight << " * fma(CsX, jcbSn, vIn.x);\n" << "\t\t}\n" //<< "\t\telse if (" << pwx << " < 0 && " << pwx << " > -1e-4)\n" //<< "\t\t vOut.x = " << weight << " * (vIn.x + CsX * _j1(vIn.y * " << freqx << "));\n"//This is not implemented in OpenCL. << "\t\telse\n" - << "\t\t vOut.x = " << weight << " * (vIn.x + CsX * sin(SignNz(vIn.y) * pow(Zeps(fabs(vIn.y)), " << pwx << ") * " << freqx << "));\n" + << "\t\t vOut.x = " << weight << " * fma(CsX, sin(SignNz(vIn.y) * pow(Zeps(fabs(vIn.y)), " << pwx << ") * " << freqx << "), vIn.x);\n" << "\n" << "\t\tif (" << pwy << " >= 0 && " << pwy << " < 1e-4)\n" << "\t\t{\n" << "\t\t JacobiElliptic(vIn.x * " << freqy << ", " << jacok << ", &jcbSn, &jcbCn, &jcbDn);\n" - << "\t\t vOut.y = " << weight << " * (vIn.y + CsY * jcbSn);\n" + << "\t\t vOut.y = " << weight << " * fma(CsY, jcbSn, vIn.y);\n" << "\t\t}\n" //<< "\t\telse if (" << pwy << " < 0 && " << pwy << " > -1e-4)\n" //<< "\t\t vOut.y = " << weight << " * (vIn.y + CsY * _j1(vIn.x * " << freqy << "));\n"//This is not implemented in OpenCL. << "\t\telse\n" - << "\t\t vOut.y = " << weight << " * (vIn.y + CsY * sin(SignNz(vIn.x) * pow(Zeps(fabs(vIn.x)), " << pwy << ") * " << freqy << "));\n" + << "\t\t vOut.y = " << weight << " * fma(CsY, sin(SignNz(vIn.x) * pow(Zeps(fabs(vIn.x)), " << pwy << ") * " << freqy << "), vIn.y);\n" << "\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; @@ -291,7 +291,7 @@ public: << "\t\tJacobiElliptic(vIn.y, 1 - " << k << ", &sny, &cny, &dny);\n" << "\t\tnumX = cnx * cny;\n" << "\t\tnumY = -dnx * snx * dny * sny;\n" - << "\t\tdenom = SQR(snx) * SQR(sny) * " << k << " + SQR(cny);\n" + << "\t\tdenom = fma(SQR(snx) * SQR(sny), " << k << ", SQR(cny));\n" << "\t\tdenom = " << weight << " / Zeps(denom);\n" << "\t\tvOut.x = denom * numX;\n" << "\t\tvOut.y = denom * numY;\n" @@ -363,7 +363,7 @@ public: << "\t\tJacobiElliptic(vIn.y, 1 - " << k << ", &sny, &cny, &dny);\n" << "\t\tnumX = dnx * cny * dny;\n" << "\t\tnumY = -cnx * snx * sny * " << k << ";\n" - << "\t\tdenom = SQR(snx) * SQR(sny) * " << k << " + SQR(cny);\n" + << "\t\tdenom = fma(SQR(snx) * SQR(sny), " << k << ", SQR(cny));\n" << "\t\tdenom = " << weight << " / Zeps(denom);\n" << "\t\tvOut.x = denom * numX;\n" << "\t\tvOut.y = denom * numY;\n" @@ -435,7 +435,7 @@ public: << "\t\tJacobiElliptic(vIn.y, 1 - " << k << ", &sny, &cny, &dny);\n" << "\t\tnumX = snx * dny;\n" << "\t\tnumY = cnx * dnx * cny * sny;\n" - << "\t\tdenom = SQR(snx) * SQR(sny) * " << k << " + SQR(cny);\n" + << "\t\tdenom = fma(SQR(snx) * SQR(sny), " << k << ", SQR(cny));\n" << "\t\tdenom = " << weight << " / Zeps(denom);\n" << "\t\tvOut.x = denom * numX;\n" << "\t\tvOut.y = denom * numY;\n" @@ -492,8 +492,8 @@ public: string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\tvOut.x = " << weight << " * (vIn.x + (1 / Zeps(" << x << " * M_2PI)) * sin(" << x << " * M_2PI * vIn.x));\n" - << "\t\tvOut.y = " << weight << " * (vIn.y + (1 / Zeps(" << y << " * M_2PI)) * sin(" << y << " * M_2PI * vIn.y));\n" + << "\t\tvOut.x = " << weight << " * fma((1 / Zeps(" << x << " * M_2PI)), sin(" << x << " * M_2PI * vIn.x), vIn.x);\n" + << "\t\tvOut.y = " << weight << " * fma((1 / Zeps(" << y << " * M_2PI)), sin(" << y << " * M_2PI * vIn.y), vIn.y);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -651,33 +651,33 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string l = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string z1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string z2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string refSc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string opt = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string optSc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string opt3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string transp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string wagsc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string crvsc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string wigsc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cycle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. - string optDir = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string l = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string z1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string z2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string refSc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string opt = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string optSc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string opt3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string transp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string wagsc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string crvsc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string wigsc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cycle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. + string optDir = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string petalsSign = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string numPetals = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absOptSc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string smooth12 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string smooth3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string antiOpt1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ghost = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string freq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string wigScale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string numPetals = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absOptSc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string smooth12 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string smooth3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string antiOpt1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ghost = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string wigScale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\tint posNeg = 1;\n" << "\t\treal_t th = 0;\n" @@ -694,61 +694,64 @@ public: << "\t\t posNeg = -1;\n" << "\n" << "\t\tpang = th / Zeps(" << cycle << ");\n" - << "\t\twig = pang * " << freq << " * 0.5 + " << offset << " * " << cycle << ";\n" + << "\t\twig = fma(pang, " << freq << " * 0.5, " << offset << " * " << cycle << ");\n" + << "\t\treal_t rad04 = (real_t)(0.4) * rad;\n" << "\n" << "\t\tif (" << optDir << " < 0)\n" << "\t\t{\n" - << "\t\t wag = sin(curve1 * MPI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (sin(curveTwo * MPI));\n" - << "\t\t wag3 = sin(curve4 * MPI * " << absOptSc << ") + " << wagsc << " * SQR(rad) * 0.4 + " << crvsc << " * 0.5 * (cos(curve3 * MPI));\n" + << "\t\t wag = sin(curve1* MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * 0.5 * sin(curveTwo * MPI)); \n" + << "\t\t wag3 = sin(curve4* MPI * " << absOptSc << ") + fma(" << wagsc << ", SQR(rad) * (real_t)(0.4), " << crvsc << " * 0.5 * cos(curve3 * MPI)); \n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" - << "\t\t wag = sin(curve1 * MPI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (cos(curve3 * MPI));\n" - << "\t\t wag3 = sin(curve4 * MPI * " << absOptSc << ") + " << wagsc << " * SQR(rad) * 0.4 + " << crvsc << " * 0.5 * (sin(curveTwo * MPI));\n" + << "\t\t wag = sin(curve1* MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * 0.5 * cos(curve3 * MPI)); \n" + << "\t\t wag3 = sin(curve4* MPI * " << absOptSc << ") + fma(" << wagsc << ", SQR(rad) * (real_t)(0.4), " << crvsc << " * 0.5 * sin(curveTwo * MPI)); \n" << "\t\t}\n" << "\n" - << "\t\twag2 = sin(curveTwo * MPI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (cos(curve3 * MPI));\n" + << "\t\twag2 = sin(curveTwo * MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * 0.5 * cos(curve3 * MPI)); \n" << "\n" << "\t\tif (" << smooth12 << " <= 1)\n" - << "\t\t wag12 = wag;\n" + << "\t\t wag12 = wag; \n" << "\t\telse if (" << smooth12 << " <= 2 && " << smooth12 << " > 1)\n" - << "\t\t wag12 = wag2 * (1 - " << antiOpt1 << ") + wag * " << antiOpt1 << ";\n" + << "\t\t wag12 = fma(wag2, (1 - " << antiOpt1 << "), wag * " << antiOpt1 << "); \n" << "\t\telse if (" << smooth12 << " > 2)\n" - << "\t\t wag12 = wag2;\n" + << "\t\t wag12 = wag2; \n" << "\n" << "\t\tif (" << smooth3 << " == 0)\n" - << "\t\t waggle = wag12;\n" + << "\t\t waggle = wag12; \n" << "\t\telse if (" << smooth3 << " > 0)\n" - << "\t\t waggle = wag12 * (1 - " << smooth3 << ") + wag3 * " << smooth3 << ";\n" + << "\t\t waggle = fma(wag12, (1 - " << smooth3 << "), wag3 * " << smooth3 << "); \n" + << "\n" + << "\t\treal_t cospetthcl = " << weight << " * (real_t)(0.5) * " << "cos(fma(" << numPetals << ", th, " << c << ")) * " << l << "; \n" << "\n" << "\t\tif (MwcNext01(mwc) < " << ghost << ")\n" << "\t\t{\n" << "\t\t if (posNeg < 0)\n" << "\t\t {\n" - << "\t\t vOut.x = " << weight << " * 0.5 * " << refSc << " * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * cth;\n" - << "\t\t vOut.y = " << weight << " * 0.5 * " << refSc << " * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * sth;\n" - << "\t\t vOut.z = " << weight << " * -0.5 * ((" << z2 << " * waggle + Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << ");\n" + << "\t\t vOut.x = " << refSc << "* cospetthcl * cth; \n" + << "\t\t vOut.y = " << refSc << "* cospetthcl * sth; \n" + << "\t\t vOut.z = " << weight << " * -0.5 * (fma(" << z2 << ", waggle, Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << "); \n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.x = " << weight << " * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * cth;\n" - << "\t\t vOut.y = " << weight << " * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * sth;\n" - << "\t\t vOut.z = " << weight << " * 0.5 * ((" << z1 << " * waggle + Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << ");\n" + << "\t\t vOut.x = cospetthcl * cth; \n" + << "\t\t vOut.y = cospetthcl * sth; \n" + << "\t\t vOut.z = " << weight << " * 0.5 * (fma(" << z1 << ", waggle, Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << "); \n" << "\t\t }\n" << "\t\t}\n" << "\t\telse\n" << "\t\t{\n" << "\t\t if (posNeg < 0)\n" << "\t\t {\n" - << "\t\t vOut.x = " << weight << " * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * cth;\n" - << "\t\t vOut.y = " << weight << " * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * sth;\n" - << "\t\t vOut.z = " << weight << " * 0.5 * ((" << z1 << " * waggle + Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << ");\n" + << "\t\t vOut.x = cospetthcl * cth; \n" + << "\t\t vOut.y = cospetthcl * sth; \n" + << "\t\t vOut.z = " << weight << " * 0.5 * (fma(" << z1 << ", waggle, Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << "); \n" << "\t\t }\n" << "\t\t else\n" << "\t\t {\n" - << "\t\t vOut.x = " << weight << " * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * cth;\n" - << "\t\t vOut.y = " << weight << " * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * sth;\n" - << "\t\t vOut.z = " << weight << " * 0.5 * ((" << z1 << " * waggle + Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << ");\n" + << "\t\t vOut.x = cospetthcl * cth; \n" + << "\t\t vOut.y = cospetthcl * sth; \n" + << "\t\t vOut.z = " << weight << " * 0.5 * (fma(" << z1 << ", waggle, Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << "); \n" << "\t\t }\n" << "\t\t}\n" << "\t}\n"; @@ -1067,7 +1070,7 @@ public: string weight = WeightDefineString(); ss << "\t{\n" << "\n" - << "\t\tvOut.x = " << weight << " * (vIn.x / Zeps(sqrt(SQR(vIn.x) + (real_t)1.0)));\n" + << "\t\tvOut.x = " << weight << " * (vIn.x / Zeps(sqrt(fma(vIn.x, vIn.x, (real_t)1.0))));\n" << "\t\tvOut.y = " << weight << " * vIn.y;\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; @@ -1248,15 +1251,15 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string exponent = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string arcWidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string exponent = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string arcWidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string finalexponent = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string oneOverEx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string seed2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rmax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string oneOverEx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string seed2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rmax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t modbase = 65535;\n" << "\t\treal_t multiplier = 32747;\n" @@ -1297,10 +1300,10 @@ public: << "\t\t\t\txrand = Round(fabs(xrand)) * " << seed2 << ";\n" << "\t\t\t\tyrand = Round(fabs(yrand)) * " << seed2 << ";\n" << "\n" - << "\t\t\t\treal_t niter = xrand + yrand + (xrand * yrand);\n" + << "\t\t\t\treal_t niter = fma(xrand, yrand, xrand + yrand);\n" << "\t\t\t\treal_t randint = (" << seed << " + niter) * " << seed2 << " * ((real_t) 0.5);\n" << "\n" - << "\t\t\t\trandint = fmod((randint * multiplier + offset), modbase);\n" + << "\t\t\t\trandint = fmod(fma(randint, multiplier, offset), modbase);\n" << "\t\t\t\ttiletype = fmod(randint, 2);\n" << "\t\t\t}\n" << "\t\t}\n" @@ -1428,11 +1431,11 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string freqX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scaleX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string freqY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scaleY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string nullVar = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaleX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaleY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string nullVar = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string distance = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t x0 = vIn.x;\n" @@ -1442,8 +1445,8 @@ public: << "\t\treal_t factor = (dist < " << distance << ") ? (dist - " << nullVar << ") / Zeps(" << distance << "-" << nullVar << ") : (real_t)(1.0);\n" << "\t\tfactor = (dist < " << nullVar << ") ? (real_t) 0.0 : factor;\n" << "\n" - << "\t\tvOut.x = " << weight << " * (x0 + factor * sin(y0 * " << freqX << ") * " << scaleX << ");\n" - << "\t\tvOut.y = " << weight << " * (y0 + factor * sin(x0 * " << freqY << ") * " << scaleY << ");\n" + << "\t\tvOut.x = " << weight << " * fma(factor * " << scaleX << ", sin(y0 * " << freqX << "), x0);\n" + << "\t\tvOut.y = " << weight << " * fma(factor * " << scaleY << ", sin(x0 * " << freqY << "), y0);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -1494,7 +1497,7 @@ public: T aux = 1 / std::sqrt(helper.m_PrecalcSumSquares + 1); T x1 = helper.m_TransX * aux; T y1 = helper.m_TransY * aux; - aux = std::sqrt(x1 * x1 + y1 * y1); + aux = std::sqrt(x1 * x1 + SQR(y1)); helper.Out.x = m_Weight * std::atan2(x1, y1) * T(M_1_PI); helper.Out.y = m_Weight * (aux - T(0.5)); helper.Out.z = DefaultZ(helper); @@ -1511,7 +1514,7 @@ public: << "\t\treal_t aux = 1.0 / sqrt(precalcSumSquares + 1);\n" << "\t\treal_t x1 = transX * aux;\n" << "\t\treal_t y1 = transY * aux;\n" - << "\t\taux = sqrt(x1 * x1 + y1 * y1);\n" + << "\t\taux = sqrt(fma(x1, x1, SQR(y1)));\n" << "\t\tvOut.x = " << weight << " * atan2(x1, y1) * M1PI;\n" << "\t\tvOut.y = " << weight << " * (aux - 0.5);\n" << "\t\tvOut.z = " << DefaultZCl() @@ -1538,7 +1541,7 @@ public: T aux = 1 / (helper.m_PrecalcSqrtSumSquares + 1); T x1 = helper.m_TransX * aux; T y1 = helper.m_TransY * aux; - aux = std::sqrt(x1 * x1 + y1 * y1); + aux = std::sqrt(x1 * x1 + SQR(y1)); helper.Out.x = m_Weight * std::atan2(x1, y1) * T(M_1_PI); helper.Out.y = m_Weight * (aux - T(0.5)); helper.Out.z = DefaultZ(helper); @@ -1555,7 +1558,7 @@ public: << "\t\treal_t aux = 1.0 / (precalcSqrtSumSquares + 1);\n" << "\t\treal_t x1 = transX * aux;\n" << "\t\treal_t y1 = transY * aux;\n" - << "\t\taux = sqrt(x1 * x1 + y1 * y1);\n" + << "\t\taux = sqrt(fma(x1, x1, SQR(y1)));\n" << "\t\tvOut.x = " << weight << " * atan2(x1, y1) * M1PI;\n" << "\t\tvOut.y = " << weight << " * (aux - 0.5);\n" << "\t\tvOut.z = " << DefaultZCl() @@ -1641,10 +1644,10 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string freq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string freq2pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t temp = vIn.z * " << freq2pi << " + precalcAtanyx;\n" + << "\t\treal_t temp = fma(vIn.z, " << freq2pi << ", precalcAtanyx);\n" << "\t\treal_t weightXdist = " << weight << " * precalcSqrtSumSquares;\n" << "\t\tvOut.x = weightXdist * cos(temp);\n" << "\t\tvOut.y = weightXdist * sin(temp);\n" @@ -1701,13 +1704,13 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight = WeightDefineString(); - string freq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string freq2pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t temp = vIn.z * " << freq2pi << ";\n" - << "\t\tvOut.x = " << weight << " * (vIn.x + cos(temp) * " << width << ");\n" - << "\t\tvOut.y = " << weight << " * (vIn.y + sin(temp) * " << width << ");\n" + << "\t\tvOut.x = " << weight << " * (fma(cos(temp), " << width << ", vIn.x));\n" + << "\t\tvOut.y = " << weight << " * (fma(sin(temp), " << width << ", vIn.y));\n" << "\t\tvOut.z = " << weight << " * vIn.z ;\n" << "\t}\n"; return ss.str(); @@ -1862,8 +1865,8 @@ public: << "\n" << "\t\ta += ((MwcNext(mwc) & 1) ? M_2PI : -M_2PI) * round(log(MwcNext01(mwc)) * " << coeff << ");\n" << "\t\treal_t lnr2 = log(precalcSumSquares);\n" - << "\t\treal_t r = " << weight << " * exp(" << halfc << " * lnr2 - " << precalcd << " * a);\n" - << "\t\treal_t temp = " << precalcc << " * a + " << halfd << " * lnr2 + " << ang << " * MwcNext(mwc);\n" + << "\t\treal_t r = " << weight << " * exp(fma(" << halfc << ", lnr2, -(" << precalcd << " * a)));\n" + << "\t\treal_t temp = fma(" << precalcc << ", a, fma(" << halfd << ", lnr2, " << ang << " * MwcNext(mwc)));\n" << "\t\tvOut.x = r * cos(temp);\n" << "\t\tvOut.y = r * sin(temp);\n" << "\t\tvOut.z = " << DefaultZCl() @@ -1969,7 +1972,7 @@ public: << "\t\treal_t randr = lvl * " << radius << ";\n" << "\n" << "\t\tif (" << rblur << " != 0)\n" - << "\t\t\trandr += (sqrt(MwcNext01(mwc)) * 2.0 - 1.0) * " << rblur << ";\n"; + << "\t\t\trandr += fma(sqrt(MwcNext01(mwc)), (real_t)(2.0), (real_t)(-1.0)) * " << rblur << ";\n"; if (m_VarType == eVariationType::VARTYPE_REG) { @@ -1983,7 +1986,7 @@ public: << "\t\treal_t zb = 0;\n" << "\n" << "\t\tif (" << zblur << " != 0)\n" - << "\t\t\tzb = (MwcNext01(mwc) * 2.0 - 1.0) * " << zblur << ";\n" + << "\t\t\tzb = fma(sqrt(MwcNext01(mwc)), (real_t)(2.0), (real_t)(-1.0)) * " << zblur << ";\n" << "\n" << "\t\tvOut.z = (-lvl + zb) * " << weight << ";\n" << "\t}\n"; @@ -2091,8 +2094,10 @@ public: << "\t\treal_t angle = floor(precalcAtanyx * " << coeff << ") / " << coeff << " + M_PI / " << n << ";\n" << "\t\treal_t x0 = cos(angle) * len;\n" << "\t\treal_t y0 = sin(angle) * len;\n" + << "\t\treal_t xmx = vIn.x - x0;\n" + << "\t\treal_t ymy = vIn.y - y0;\n" << "\n" - << "\t\tif (sqrt(Sqr(vIn.x - x0) + Sqr(vIn.y - y0)) < d)\n" + << "\t\tif (sqrt(fma(xmx, xmx, SQR(ymy))) < d)\n" << "\t\t{\n" << "\t\t if (" << zero << " > 1.5)\n" << "\t\t {\n" @@ -2111,8 +2116,8 @@ public: << "\t\t else\n" << "\t\t {\n" << "\t\t real_t rangle = atan2(vIn.y - y0, vIn.x - x0);\n" - << "\t\t fx = x0 + cos(rangle) * d;\n" - << "\t\t fy = y0 + sin(rangle) * d;\n" + << "\t\t fx = fma(cos(rangle), d, x0);\n" + << "\t\t fy = fma(sin(rangle), d, y0);\n" << "\t\t fz = 0;\n" << "\t\t }\n" << "\t\t }\n" @@ -2205,12 +2210,12 @@ public: ss << "\t{\n" << "\t\treal_t fx = vIn.x * " << scale2 << ";\n" << "\t\treal_t fy = vIn.y * " << scale2 << ";\n" - << "\t\treal_t rad = 1 / Zeps(fx * fx + fy * fy);\n" + << "\t\treal_t rad = 1 / Zeps(fma(fx, fx, SQR(fy)));\n" << "\t\treal_t x = rad * fx + " << shift << ";\n" << "\t\treal_t y = rad * fy;\n" - << "\t\trad = " << weight << " * " << shift << " / Zeps(x * x + y * y);\n" + << "\t\trad = " << weight << " * " << shift << " / Zeps(fma(x, x, SQR(y)));\n" << "\t\treal_t angle = ((MwcNext(mwc) % (int)" << p << ") * 2 + 1) * M_PI / " << p << ";\n" - << "\t\treal_t X = rad * x + " << shift << ";\n" + << "\t\treal_t X = fma(rad, x, " << shift << ");\n" << "\t\treal_t Y = rad * y;\n" << "\t\treal_t cosa = cos(angle);\n" << "\t\treal_t sina = sin(angle);\n"; @@ -2218,8 +2223,8 @@ public: if (m_VarType == eVariationType::VARTYPE_REG) ss << "\t\toutPoint->m_X = outPoint->m_Y = outPoint->m_Z = 0;\n"; - ss << "\t\tvOut.x = cosa * X - sina * Y;\n" - << "\t\tvOut.y = sina * X + cosa * Y;\n" + ss << "\t\tvOut.x = fma(cosa, X, -(sina * Y));\n" + << "\t\tvOut.y = fma(sina, X, cosa * Y);\n" << "\t\tvOut.z = vIn.z * rad;\n" << "\t}\n"; return ss.str(); diff --git a/Source/Ember/VariationsDC.h b/Source/Ember/VariationsDC.h index 3b86c9b..9ce3cd0 100644 --- a/Source/Ember/VariationsDC.h +++ b/Source/Ember/VariationsDC.h @@ -1509,7 +1509,7 @@ public: ss << "\t{\n" << "\t\treal_t blockx = floor(log(MwcNext01(mwc)) * ((MwcNext(mwc) & 1) ? " << spread << " : -" << spread << "));\n" << "\t\treal_t blocky = floor(log(MwcNext01(mwc)) * ((MwcNext(mwc) & 1) ? " << spread << " : -" << spread << "));\n" - << "\t\treal_t z = Hash(blockx * " << seed << ") + Hash(blockx + blocky * " << seed << ");\n"; + << "\t\treal_t z = Hash(blockx * " << seed << ") + Hash(fma(blocky, " << seed << ", blockx));\n"; if (m_VarType == eVariationType::VARTYPE_REG) { @@ -1518,8 +1518,8 @@ public: << "\t\toutPoint->m_Z = 0;\n"; } - ss << "\t\tvOut.x = (blockx * " << density << " + MwcNext01(mwc)) * " << blocksize << ";\n" - << "\t\tvOut.y = (blocky * " << density << " + MwcNext01(mwc)) * " << blocksize << ";\n" + ss << "\t\tvOut.x = fma(blockx, " << density << ", MwcNext01(mwc)) * " << blocksize << ";\n" + << "\t\tvOut.y = fma(blocky, " << density << ", MwcNext01(mwc)) * " << blocksize << ";\n" << "\t\tvOut.z = " << blockheight << " * z * pow(MwcNext01(mwc), 0.125);\n" << "\t\toutPoint->m_ColorX = z / 2;\n" << "\t}\n"; @@ -1592,19 +1592,19 @@ public: string index = ss2.str(); string weight = WeightDefineString(); string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string len = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string len = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string dc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rad = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rad = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t xl, yl;\n" << "\t\txl = sincos(" << rad << ", &yl);\n" << "\t\tint blockx = (int)floor(vIn.x * " << width << ");\n" - << "\t\tblockx += (int)(2 - 4 * Hash((int)(blockx * " << seed << " + 1)));\n" + << "\t\tblockx += (int)(2 - 4 * Hash((int)(blockx * (int)" << seed << " + 1)));\n" << "\t\tint blocky = (int)floor(vIn.y * " << width << ");\n" - << "\t\tblocky += (int)(2 - 4 * Hash((int)(blocky * " << seed << " + 1)));\n" - << "\t\treal_t fLen = (Hash((int)(blocky + blockx * -" << seed << ")) + Hash((int)(blockx + blocky * " << seed << " * (real_t)0.5))) * (real_t)0.5;\n" + << "\t\tblocky += (int)(2 - 4 * Hash((int)(blocky * (int)" << seed << " + 1)));\n" + << "\t\treal_t fLen = (Hash((int)(blocky + blockx * -(int)" << seed << ")) + Hash((int)(blockx + blocky * (int)" << seed << " * (real_t)0.5))) * (real_t)0.5;\n" << "\t\treal_t r01 = MwcNext01(mwc);\n" << "\t\treal_t fade = fLen * r01 * r01 * r01 * r01;\n" << "\t\tvOut.x = " << weight << " * " << len << " * xl * fade;\n" diff --git a/Source/EmberCL/FunctionMapper.cpp b/Source/EmberCL/FunctionMapper.cpp index dfdbf89..9a62a76 100644 --- a/Source/EmberCL/FunctionMapper.cpp +++ b/Source/EmberCL/FunctionMapper.cpp @@ -59,7 +59,7 @@ FunctionMapper::FunctionMapper() s_GlobalMap["Hypot"] = "inline real_t Hypot(real_t x, real_t y)\n" "{\n" - " return sqrt(SQR(x) + SQR(y));\n" + " return sqrt(fma(x, x, SQR(y)));\n" "}\n"; s_GlobalMap["Spread"] = "inline real_t Spread(real_t x, real_t y)\n" @@ -79,12 +79,12 @@ FunctionMapper::FunctionMapper() s_GlobalMap["Zeps"] = "inline real_t Zeps(real_t x)\n" "{\n" - " return x == 0.0 ? EPS : x;\n" + " return x != 0.0 ? x : EPS;\n" "}\n"; s_GlobalMap["Lerp"] = "inline real_t Lerp(real_t a, real_t b, real_t p)\n" "{\n" - " return a + (b - a) * p;\n" + " return fma(p, (b - a), a);\n" "}\n"; s_GlobalMap["Fabsmod"] = "inline real_t Fabsmod(real_t v)\n" @@ -96,7 +96,7 @@ FunctionMapper::FunctionMapper() s_GlobalMap["Fosc"] = "inline real_t Fosc(real_t p, real_t amp, real_t ph)\n" "{\n" - " return 0.5 - cos(p * amp + ph) * 0.5;\n" + " return 0.5 - cos(fma(p, amp, ph)) * 0.5;\n" "}\n"; s_GlobalMap["Foscn"] = "inline real_t Foscn(real_t p, real_t ph)\n" @@ -154,7 +154,8 @@ FunctionMapper::FunctionMapper() "\n" " for (i = 0; i < n; i++)\n" " {\n" - " d2 = Sqr(p[i].x - (*u).x) + Sqr(p[i].y - (*u).y);\n" + " real_t pxmx = p[i].x - (*u).x;\n" + " d2 = fma(pxmx, pxmx, Sqr(p[i].y - (*u).y));\n" "\n" " if (d2 < d2min)\n" " {\n" @@ -357,7 +358,7 @@ FunctionMapper::FunctionMapper() " a = c / b;\n" " }\n" "\n" - " a = 1 / sqrt(c * c + 1);\n" + " a = 1 / sqrt(fma(c, c, (real_t)(1.0)));\n" "\n" " if (*sn < 0)\n" " *sn = -a;\n" diff --git a/Source/EmberCL/IterOpenCLKernelCreator.cpp b/Source/EmberCL/IterOpenCLKernelCreator.cpp index 80dcb62..2e1bf78 100644 --- a/Source/EmberCL/IterOpenCLKernelCreator.cpp +++ b/Source/EmberCL/IterOpenCLKernelCreator.cpp @@ -102,9 +102,19 @@ string IterOpenCLKernelCreator::CreateIterKernelString(const Ember& ember, } else { + /* if (xform->m_Affine.IsID()) + { + xformFuncs << + " transX = inPoint->m_X;\n" << + " transY = inPoint->m_Y;\n"; + } + else*/ + { + xformFuncs << + " transX = fma(xform->m_A, inPoint->m_X, fma(xform->m_B, inPoint->m_Y, xform->m_C));\n" << + " transY = fma(xform->m_D, inPoint->m_X, fma(xform->m_E, inPoint->m_Y, xform->m_F));\n"; + } xformFuncs << - " transX = (xform->m_A * inPoint->m_X) + (xform->m_B * inPoint->m_Y) + xform->m_C;\n" << - " transY = (xform->m_D * inPoint->m_X) + (xform->m_E * inPoint->m_Y) + xform->m_F;\n" << " transZ = inPoint->m_Z;\n"; varCount = xform->PreVariationCount(); @@ -198,8 +208,8 @@ string IterOpenCLKernelCreator::CreateIterKernelString(const Ember& ember, "\n\t//Apply post affine transform.\n" "\treal_t tempX = outPoint->m_X;\n" "\n" - "\toutPoint->m_X = (xform->m_PostA * tempX) + (xform->m_PostB * outPoint->m_Y) + xform->m_PostC;\n" << - "\toutPoint->m_Y = (xform->m_PostD * tempX) + (xform->m_PostE * outPoint->m_Y) + xform->m_PostF;\n"; + "\toutPoint->m_X = fma(xform->m_PostA, tempX, fma(xform->m_PostB, outPoint->m_Y, xform->m_PostC));\n" << + "\toutPoint->m_Y = fma(xform->m_PostD, tempX, fma(xform->m_PostE, outPoint->m_Y, xform->m_PostF));\n"; } xformFuncs << "\toutPoint->m_ColorX = tempColor + xform->m_DirectColor * (outPoint->m_ColorX - tempColor);\n"; @@ -440,8 +450,8 @@ string IterOpenCLKernelCreator::CreateIterKernelString(const Ember& ember, os << " p00 = secondPoint.m_X - ember->m_CenterX;\n" " p01 = secondPoint.m_Y - ember->m_CenterY;\n" - " tempPoint.m_X = (p00 * ember->m_RotA) + (p01 * ember->m_RotB) + ember->m_CenterX;\n" - " tempPoint.m_Y = (p00 * ember->m_RotD) + (p01 * ember->m_RotE) + ember->m_CenterY;\n" + " tempPoint.m_X = fma(p00, ember->m_RotA, fma(p01, ember->m_RotB, ember->m_CenterX));\n" + " tempPoint.m_Y = fma(p00, ember->m_RotD, fma(p01, ember->m_RotE, ember->m_CenterY));\n" "\n" //Add this point to the appropriate location in the histogram. " if (CarToRasInBounds(carToRas, &tempPoint))\n" @@ -481,7 +491,7 @@ string IterOpenCLKernelCreator::CreateIterKernelString(const Ember& ember, " palColor1 = read_imagef(palette, paletteSampler, iPaletteCoord);\n" " iPaletteCoord.x += 1;\n" " palColor2 = read_imagef(palette, paletteSampler, iPaletteCoord);\n" - " palColor1 = (palColor1 * (1.0f - (float)colorIndexFrac)) + (palColor2 * (float)colorIndexFrac);\n";//The 1.0f here *must* have the 'f' suffix at the end to compile. + " palColor1 = fma(palColor2, (float)colorIndexFrac, palColor1 * (1.0f - (float)colorIndexFrac));\n";//The 1.0f here *must* have the 'f' suffix at the end to compile. } else if (ember.m_PaletteMode == ePaletteMode::PALETTE_STEP) { @@ -820,6 +830,9 @@ bool IterOpenCLKernelCreator::IsBuildRequired(const Ember& ember1, const E auto xform2 = ember2.GetTotalXform(i); auto varCount = xform1->TotalVariationCount(); + //if (xform1->m_Affine.IsID() != xform2->m_Affine.IsID()) + // return true; + if (xform1->HasPost() != xform2->HasPost()) return true; @@ -912,10 +925,10 @@ string IterOpenCLKernelCreator::CreateProjectionString(const Ember& ember) " real_t dsin, dcos;\n" " real_t t = MwcNext01(&mwc) * M_2PI;\n" " real_t z = secondPoint.m_Z - ember->m_CamZPos;\n" - " real_t x = ember->m_C00 * secondPoint.m_X + ember->m_C10 * secondPoint.m_Y;\n" - " real_t y = ember->m_C01 * secondPoint.m_X + ember->m_C11 * secondPoint.m_Y + ember->m_C21 * z;\n" + " real_t x = fma(ember->m_C00, secondPoint.m_X, ember->m_C10 * secondPoint.m_Y);\n" + " real_t y = fma(ember->m_C01, secondPoint.m_X, fma(ember->m_C11, secondPoint.m_Y, ember->m_C21 * z));\n" "\n" - " z = ember->m_C02 * secondPoint.m_X + ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z;\n" + " z = fma(ember->m_C02, secondPoint.m_X, fma(ember->m_C12, secondPoint.m_Y, ember->m_C22 * z));\n" "\n" " real_t zr = Zeps(1 - ember->m_CamPerspective * z);\n" " real_t dr = MwcNext01(&mwc) * ember->m_BlurCoef * z;\n" @@ -923,8 +936,8 @@ string IterOpenCLKernelCreator::CreateProjectionString(const Ember& ember) " dsin = sin(t);\n" " dcos = cos(t);\n" "\n" - " secondPoint.m_X = (x + dr * dcos) / zr;\n" - " secondPoint.m_Y = (y + dr * dsin) / zr;\n" + " secondPoint.m_X = fma(dr, dcos, x) / zr;\n" + " secondPoint.m_Y = fma(dr, dsin, y) / zr;\n" " secondPoint.m_Z -= ember->m_CamZPos;\n"; } else @@ -935,8 +948,8 @@ string IterOpenCLKernelCreator::CreateProjectionString(const Ember& ember) " real_t t = MwcNext01(&mwc) * M_2PI;\n" "\n" " z = secondPoint.m_Z - ember->m_CamZPos;\n" - " y = ember->m_C11 * secondPoint.m_Y + ember->m_C21 * z;\n" - " z = ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z;\n" + " y = fma(ember->m_C11, secondPoint.m_Y, ember->m_C21 * z);\n" + " z = fma(ember->m_C12, secondPoint.m_Y, ember->m_C22 * z);\n" " zr = Zeps(1 - ember->m_CamPerspective * z);\n" "\n" " dsin = sin(t);\n" @@ -944,8 +957,8 @@ string IterOpenCLKernelCreator::CreateProjectionString(const Ember& ember) "\n" " real_t dr = MwcNext01(&mwc) * ember->m_BlurCoef * z;\n" "\n" - " secondPoint.m_X = (secondPoint.m_X + dr * dcos) / zr;\n" - " secondPoint.m_Y = (y + dr * dsin) / zr;\n" + " secondPoint.m_X = fma(dr, dcos, secondPoint.m_X) / zr;\n" + " secondPoint.m_Y = fma(dr, dsin, y) / zr;\n" " secondPoint.m_Z -= ember->m_CamZPos;\n"; } } @@ -955,9 +968,9 @@ string IterOpenCLKernelCreator::CreateProjectionString(const Ember& ember) { os << " real_t z = secondPoint.m_Z - ember->m_CamZPos;\n" - " real_t x = ember->m_C00 * secondPoint.m_X + ember->m_C10 * secondPoint.m_Y;\n" - " real_t y = ember->m_C01 * secondPoint.m_X + ember->m_C11 * secondPoint.m_Y + ember->m_C21 * z;\n" - " real_t zr = Zeps(1 - ember->m_CamPerspective * (ember->m_C02 * secondPoint.m_X + ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z));\n" + " real_t x = fma(ember->m_C00, secondPoint.m_X, ember->m_C10 * secondPoint.m_Y);\n" + " real_t y = fma(ember->m_C01, secondPoint.m_X, fma(ember->m_C11, secondPoint.m_Y, ember->m_C21 * z));\n" + " real_t zr = Zeps(1 - ember->m_CamPerspective * fma(ember->m_C02, secondPoint.m_X, fma(ember->m_C12, secondPoint.m_Y, ember->m_C22 * z)));\n" "\n" " secondPoint.m_X = x / zr;\n" " secondPoint.m_Y = y / zr;\n" @@ -967,8 +980,8 @@ string IterOpenCLKernelCreator::CreateProjectionString(const Ember& ember) { os << " real_t z = secondPoint.m_Z - ember->m_CamZPos;\n" - " real_t y = ember->m_C11 * secondPoint.m_Y + ember->m_C21 * z;\n" - " real_t zr = Zeps(1 - ember->m_CamPerspective * (ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z));\n" + " real_t y = fma(ember->m_C11, secondPoint.m_Y, ember->m_C21 * z);\n" + " real_t zr = Zeps(1 - ember->m_CamPerspective * fma(ember->m_C12, secondPoint.m_Y, ember->m_C22 * z));\n" "\n" " secondPoint.m_X /= zr;\n" " secondPoint.m_Y = y / zr;\n" diff --git a/Source/EmberTester/EmberTester.cpp b/Source/EmberTester/EmberTester.cpp index 657980d..316b88b 100644 --- a/Source/EmberTester/EmberTester.cpp +++ b/Source/EmberTester/EmberTester.cpp @@ -1058,6 +1058,42 @@ bool TestVarAssignVals() return success; } +void FindFmaCandidates() +{ + auto vlf(VariationList::Instance()); + + for (size_t i = 0; i < vlf->Size(); i++) + { + auto var = vlf->GetVariation(i); + auto cl = var->OpenCLFuncsString() + "\n" + var->StateInitOpenCLString() + "\n" + var->OpenCLString(); + auto splits = Split(cl, '\n'); + + for (auto& split : splits) + { + if ((split.find("*") != string::npos || split.find("SQR(") != string::npos || split.find("Sqr(") != string::npos) && split.find("+") != string::npos) + cout << "Variation " << var->Name() << " is a potential fma() candidate because of line:\n\t" << split << endl; + } + } +} + +void FindFmaImplemented() +{ + auto vlf(VariationList::Instance()); + + for (size_t i = 0; i < vlf->Size(); i++) + { + auto var = vlf->GetVariation(i); + auto cl = var->OpenCLFuncsString() + "\n" + var->StateInitOpenCLString() + "\n" + var->OpenCLString(); + auto splits = Split(cl, '\n'); + + for (auto& split : splits) + { + if ((split.find("fma(") != string::npos)) + cout << "Variation " << var->Name() << " has been implemented with fma():\n\t" << split << endl; + } + } +} + bool TestZepsFloor() { bool success = true; @@ -2041,25 +2077,25 @@ int _tmain(int argc, _TCHAR* argv[]) //int i; bool b = true; Timing t(4); - vector> fv; - vector> dv; - list> fl; - list> dl; - int w = 1000, h = 1000; - string filename = ".\\testexr.exr"; - vector pixels; - pixels.resize(w * h); + /* vector> fv; + vector> dv; + list> fl; + list> dl; + int w = 1000, h = 1000; + string filename = ".\\testexr.exr"; + vector pixels; + pixels.resize(w * h); - for (auto& pix : pixels) - { + for (auto& pix : pixels) + { pix.r = 1.0; pix.b = 0.0; pix.a = 1.0; //pix.r = std::numeric_limits::max(); - } + } - writeRgba1(filename.c_str(), pixels.data(), w, h); - /* TestFuncs(); + writeRgba1(filename.c_str(), pixels.data(), w, h); + TestFuncs(); string line = "title=\"cj_aerie\" smooth=no", delim = " =\""; auto vec = Split(line, delim, true); @@ -2086,6 +2122,11 @@ int _tmain(int argc, _TCHAR* argv[]) return 1; */ //MakeTestAllVarsRegPrePostComboFile("testallvarsout.flame"); + //cout << (10.0 / 2.0 * 5.0) << endl; + FindFmaCandidates(); + //FindFmaImplemented(); + //cout << 5 * 3 + 2 << endl; + //cout << 2 + 5 * 3 << endl; return 0; /* TestThreadedKernel(); diff --git a/Source/Fractorium/Fractorium.cpp b/Source/Fractorium/Fractorium.cpp index 6a967d7..2c3360b 100644 --- a/Source/Fractorium/Fractorium.cpp +++ b/Source/Fractorium/Fractorium.cpp @@ -873,7 +873,9 @@ void Fractorium::SetTabOrders() w = SetTabOrder(this, w, m_PreO1Spin); w = SetTabOrder(this, w, m_PreO2Spin); w = SetTabOrder(this, w, ui.PreFlipVerticalButton); + w = SetTabOrder(this, w, ui.PreCopyButton); w = SetTabOrder(this, w, ui.PreResetButton); + w = SetTabOrder(this, w, ui.PrePasteButton); w = SetTabOrder(this, w, ui.PreFlipHorizontalButton); w = SetTabOrder(this, w, ui.PreRotate90CcButton); w = SetTabOrder(this, w, ui.PreRotateCcButton); @@ -899,7 +901,9 @@ void Fractorium::SetTabOrders() w = SetTabOrder(this, w, m_PostO1Spin); w = SetTabOrder(this, w, m_PostO2Spin); w = SetTabOrder(this, w, ui.PostFlipVerticalButton); + w = SetTabOrder(this, w, ui.PostCopyButton); w = SetTabOrder(this, w, ui.PostResetButton); + w = SetTabOrder(this, w, ui.PostPasteButton); w = SetTabOrder(this, w, ui.PostFlipHorizontalButton); w = SetTabOrder(this, w, ui.PostRotate90CcButton); w = SetTabOrder(this, w, ui.PostRotateCcButton); diff --git a/Source/Fractorium/Fractorium.h b/Source/Fractorium/Fractorium.h index f93804c..a7f4faf 100644 --- a/Source/Fractorium/Fractorium.h +++ b/Source/Fractorium/Fractorium.h @@ -114,7 +114,11 @@ public: void CurrentXform(uint i); //Xforms Affine. + bool DrawCurrentPre(); + bool DrawSelectedPre(); bool DrawAllPre(); + bool DrawCurrentPost(); + bool DrawSelectedPost(); bool DrawAllPost(); bool LocalPivot(); @@ -279,6 +283,8 @@ public slots: void OnScaleDownButtonClicked(bool checked); void OnScaleUpButtonClicked(bool checked); void OnResetAffineButtonClicked(bool checked); + void OnCopyAffineButtonClicked(bool checked); + void OnPasteAffineButtonClicked(bool checked); void OnRandomAffineButtonClicked(bool checked); void OnAffineGroupBoxToggled(bool on); diff --git a/Source/Fractorium/Fractorium.ui b/Source/Fractorium/Fractorium.ui index 19b738b..8762e33 100644 --- a/Source/Fractorium/Fractorium.ui +++ b/Source/Fractorium/Fractorium.ui @@ -3233,7 +3233,7 @@ QTabWidget::Triangular - 3 + 2 @@ -4572,6 +4572,50 @@ + + + + + 0 + 24 + + + + + 41 + 24 + + + + <html><head/><body><p>Copy the pre affine values, which can then be pasted into other pre/post affines</p></body></html> + + + Copy + + + + + + + + 0 + 24 + + + + + 41 + 24 + + + + <html><head/><body><p>Paste the pre/post affine values which were previously copied</p></body></html> + + + Paste + + + @@ -4617,6 +4661,13 @@ + + + + Selected + + + @@ -5402,6 +5453,50 @@ + + + + + 0 + 24 + + + + + 41 + 24 + + + + <html><head/><body><p>Copy the post affine values, which can then be pasted into other pre/post affines</p></body></html> + + + Copy + + + + + + + + 0 + 24 + + + + + 41 + 24 + + + + <html><head/><body><p>Paste the pre/post affine values which were previously copied</p></body></html> + + + Paste + + + @@ -5444,6 +5539,13 @@ + + + + Selected + + + @@ -5675,7 +5777,7 @@ false - 2 + 3 70 @@ -5702,6 +5804,14 @@ Weight + + + Type + + + <html><head/><body><p>Red: Uses non-standard assignment which means direct assignment for regular variations, sum for pre/post.</p><p>Green: Uses direct color.</p><p>Blue: Uses an internal variation state.</p></body></html> + + Spherical diff --git a/Source/Fractorium/FractoriumEmberController.h b/Source/Fractorium/FractoriumEmberController.h index c88f314..e979326 100644 --- a/Source/Fractorium/FractoriumEmberController.h +++ b/Source/Fractorium/FractoriumEmberController.h @@ -194,6 +194,8 @@ public: virtual void MoveXforms(double x, double y, bool pre) { } virtual void ScaleXforms(double scale, bool pre) { } virtual void ResetXformsAffine(bool pre) { } + virtual void CopyXformsAffine(bool pre) { } + virtual void PasteXformsAffine(bool pre) { } virtual void RandomXformsAffine(bool pre) { } virtual void FillBothAffines() { } double LockedScale() { return m_LockedScale; } @@ -223,6 +225,7 @@ public: virtual void FillVariationTreeWithCurrentXform() { } //Xforms Selection. + virtual QString MakeXformCaption(size_t i) { return ""; } //Xaos. virtual void FillXaos() { } @@ -265,12 +268,12 @@ public: vector* FinalImage() { return &(m_FinalImage); } vector* PreviewFinalImage() { return &m_PreviewFinalImage; } EmberStats Stats() { return m_Stats; } + eProcessState ProcessState() { return m_Renderer.get() ? m_Renderer->ProcessState() : eProcessState::NONE; } protected: //Rendering/progress. void AddProcessAction(eProcessAction action); eProcessAction CondenseAndClearProcessActions(); - eProcessState ProcessState() { return m_Renderer.get() ? m_Renderer->ProcessState() : eProcessState::NONE; } //Non-templated members. bool m_Rendering = false; @@ -468,6 +471,8 @@ public: virtual void MoveXforms(double x, double y, bool pre) override; virtual void ScaleXforms(double scale, bool pre) override; virtual void ResetXformsAffine(bool pre) override; + virtual void CopyXformsAffine(bool pre) override; + virtual void PasteXformsAffine(bool pre) override; virtual void RandomXformsAffine(bool pre) override; virtual void FillBothAffines() override; virtual void InitLockedScale() override; @@ -506,6 +511,7 @@ public: virtual void AddLayer(int xforms) override; //Xforms Selection. + virtual QString MakeXformCaption(size_t i) override; bool XformCheckboxAt(int i, std::function func); bool XformCheckboxAt(Xform* xform, std::function func); @@ -545,9 +551,6 @@ private: //Xforms Color. void FillCurvesControl(); - //Xforms Selection. - QString MakeXformCaption(size_t i); - //Palette. void UpdateAdjustedPaletteGUI(Palette& palette); @@ -567,6 +570,7 @@ private: deque> m_UndoList; vector> m_CopiedXforms; Xform m_CopiedFinalXform; + Affine2D m_CopiedAffine; shared_ptr> m_VariationList; unique_ptr> m_SheepTools; unique_ptr> m_GLController; diff --git a/Source/Fractorium/FractoriumParams.cpp b/Source/Fractorium/FractoriumParams.cpp index c9211d0..eaeddf6 100644 --- a/Source/Fractorium/FractoriumParams.cpp +++ b/Source/Fractorium/FractoriumParams.cpp @@ -645,7 +645,7 @@ void FractoriumEmberController::InterpTypeChanged(int i) { eInterp interp; - if (i == 0)//Need to make this work like animate flag where it sets the value but doesn't trigger and update.//TODO + if (i == 0) interp = eInterp::EMBER_INTERP_LINEAR; else if (i == 1) interp = eInterp::EMBER_INTERP_SMOOTH; diff --git a/Source/Fractorium/FractoriumRender.cpp b/Source/Fractorium/FractoriumRender.cpp index 80bf81b..6f68f6b 100644 --- a/Source/Fractorium/FractoriumRender.cpp +++ b/Source/Fractorium/FractoriumRender.cpp @@ -159,13 +159,13 @@ void FractoriumEmberControllerBase::SaveCurrentRender(const QString& filename, c { vector rgba8Image(size * 4); Rgba32ToRgba8(data, rgba8Image.data(), width, height, transparency); - b = WritePng(s.c_str(), rgba8Image.data(), width, height, 1, true, comments, id, url, nick);//Put an opt here for 1 or 2 bytes.//TODO + b = WritePng(s.c_str(), rgba8Image.data(), width, height, 1, true, comments, id, url, nick); } else { vector rgba16Image(size * 4); Rgba32ToRgba16(data, rgba16Image.data(), width, height, transparency); - b = WritePng(s.c_str(), (byte*)rgba16Image.data(), width, height, 2, true, comments, id, url, nick);//Put an opt here for 1 or 2 bytes.//TODO + b = WritePng(s.c_str(), (byte*)rgba16Image.data(), width, height, 2, true, comments, id, url, nick); } } else if (suffix.endsWith("exr", Qt::CaseInsensitive)) diff --git a/Source/Fractorium/FractoriumSettings.cpp b/Source/Fractorium/FractoriumSettings.cpp index 7262b2d..becf893 100644 --- a/Source/Fractorium/FractoriumSettings.cpp +++ b/Source/Fractorium/FractoriumSettings.cpp @@ -173,6 +173,9 @@ void FractoriumSettings::OpenClQuality(uint i) { setValue(OPEN bool FractoriumSettings::LoadLast() { return value(LOADLAST).toBool(); } void FractoriumSettings::LoadLast(bool b) { setValue(LOADLAST, b); } +bool FractoriumSettings::RotateAndScale() { return value(ROTSCALE).toBool(); } +void FractoriumSettings::RotateAndScale(bool b) { setValue(ROTSCALE, b); } + /// /// Sequence generation settings. /// diff --git a/Source/Fractorium/FractoriumSettings.h b/Source/Fractorium/FractoriumSettings.h index 880d5bd..438cd0d 100644 --- a/Source/Fractorium/FractoriumSettings.h +++ b/Source/Fractorium/FractoriumSettings.h @@ -28,6 +28,7 @@ #define CPUQUALITY "render/cpuquality" #define OPENCLQUALITY "render/openclquality" #define LOADLAST "render/loadlastonstart" +#define ROTSCALE "render/rotateandscale" #define STAGGER "sequence/stagger" #define STAGGERMAX "sequence/staggermax" @@ -171,6 +172,9 @@ public: bool LoadLast(); void LoadLast(bool b); + bool RotateAndScale(); + void RotateAndScale(bool b); + double Stagger(); void Stagger(double i); diff --git a/Source/Fractorium/FractoriumXaos.cpp b/Source/Fractorium/FractoriumXaos.cpp index 2b1967e..f04be8c 100644 --- a/Source/Fractorium/FractoriumXaos.cpp +++ b/Source/Fractorium/FractoriumXaos.cpp @@ -92,7 +92,7 @@ void Fractorium::FillXaosTable() { int count = int(m_Controller->XformCount()); QStringList hl, vl; - auto oldModel = m_XaosTableModel; + auto oldModel = std::make_unique(m_XaosTableModel); hl.reserve(count); vl.reserve(count); m_XaosTableModel = new QStandardItemModel(count, count, this); @@ -101,7 +101,7 @@ void Fractorium::FillXaosTable() for (int i = 0; i < count; i++) { - auto s = QString::number(i + 1); + auto s = m_Controller->MakeXformCaption(i); hl.push_back("F" + s); vl.push_back("T" + s); } @@ -113,10 +113,6 @@ void Fractorium::FillXaosTable() SetTabOrder(this, ui.ClearXaosButton, ui.RandomXaosButton); m_Controller->FillXaos(); ui.XaosTableView->blockSignals(false); - - if (oldModel) - delete oldModel; - //Needed to get the dark stylesheet to correctly color the top left corner button. auto widgetList = ui.XaosTableView->findChildren(); diff --git a/Source/Fractorium/FractoriumXforms.cpp b/Source/Fractorium/FractoriumXforms.cpp index 8913a9a..c5a7396 100644 --- a/Source/Fractorium/FractoriumXforms.cpp +++ b/Source/Fractorium/FractoriumXforms.cpp @@ -412,6 +412,7 @@ void FractoriumEmberController::XformNameChanged(int row, int col) XformCheckboxAt(int(xfindex), [&](QCheckBox * checkbox) { checkbox->setText(MakeXformCaption(xfindex)); }); }, eXformUpdate::UPDATE_CURRENT, false); FillSummary();//Manually update because this does not trigger a render, which is where this would normally be called. + m_Fractorium->FillXaosTable(); } void Fractorium::OnXformNameChanged(int row, int col) @@ -570,6 +571,7 @@ void FractoriumEmberController::FillXforms(int index) if (UseFinalXform()) { auto cb = new QCheckBox(MakeXformCaption(i), m_Fractorium); + QObject::connect(cb, &QCheckBox::stateChanged, [&](int state) { m_Fractorium->ui.GLDisplay->update(); }); m_Fractorium->m_XformSelections.push_back(cb); m_Fractorium->m_XformsSelectionLayout->addRow(cb, new QWidget(m_Fractorium)); combo->addItem("Final"); @@ -600,7 +602,6 @@ void FractoriumEmberController::FillXforms(int index) /// Update the text in xforms combo box to show the name of Xform. /// /// The index of the Xform to update. -/// template void FractoriumEmberController::UpdateXformName(int index) { diff --git a/Source/Fractorium/FractoriumXformsAffine.cpp b/Source/Fractorium/FractoriumXformsAffine.cpp index 23c5f65..b4bb07a 100644 --- a/Source/Fractorium/FractoriumXformsAffine.cpp +++ b/Source/Fractorium/FractoriumXformsAffine.cpp @@ -61,41 +61,47 @@ void Fractorium::InitXformsAffineUI() moveList.append(ToString(0.01)); ui.PreMoveCombo->addItems(moveList); ui.PostMoveCombo->addItems(moveList); - connect(ui.PreFlipHorizontalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipHorizontalButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreFlipVerticalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipVerticalButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreRotate90CButton, SIGNAL(clicked(bool)), this, SLOT(OnRotate90CButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreRotate90CcButton, SIGNAL(clicked(bool)), this, SLOT(OnRotate90CcButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreRotateCButton, SIGNAL(clicked(bool)), this, SLOT(OnRotateCButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreRotateCcButton, SIGNAL(clicked(bool)), this, SLOT(OnRotateCcButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreMoveUpButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveUpButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreMoveDownButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveDownButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreMoveLeftButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveLeftButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreMoveRightButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveRightButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreScaleDownButton, SIGNAL(clicked(bool)), this, SLOT(OnScaleDownButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreScaleUpButton, SIGNAL(clicked(bool)), this, SLOT(OnScaleUpButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreResetButton, SIGNAL(clicked(bool)), this, SLOT(OnResetAffineButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreRandomButton, SIGNAL(clicked(bool)), this, SLOT(OnRandomAffineButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostFlipHorizontalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipHorizontalButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostFlipVerticalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipVerticalButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostRotate90CcButton, SIGNAL(clicked(bool)), this, SLOT(OnRotate90CcButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostRotateCcButton, SIGNAL(clicked(bool)), this, SLOT(OnRotateCcButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostRotateCButton, SIGNAL(clicked(bool)), this, SLOT(OnRotateCButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostRotate90CButton, SIGNAL(clicked(bool)), this, SLOT(OnRotate90CButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostMoveUpButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveUpButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostMoveDownButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveDownButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostMoveLeftButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveLeftButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostMoveRightButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveRightButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostScaleDownButton, SIGNAL(clicked(bool)), this, SLOT(OnScaleDownButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostScaleUpButton, SIGNAL(clicked(bool)), this, SLOT(OnScaleUpButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostResetButton, SIGNAL(clicked(bool)), this, SLOT(OnResetAffineButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PostRandomButton, SIGNAL(clicked(bool)), this, SLOT(OnRandomAffineButtonClicked(bool)), Qt::QueuedConnection); - connect(ui.PreAffineGroupBox, SIGNAL(toggled(bool)), this, SLOT(OnAffineGroupBoxToggled(bool)), Qt::QueuedConnection); - connect(ui.PostAffineGroupBox, SIGNAL(toggled(bool)), this, SLOT(OnAffineGroupBoxToggled(bool)), Qt::QueuedConnection); - connect(ui.ShowPreAffineAllRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); - connect(ui.ShowPreAffineCurrentRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); - connect(ui.ShowPostAffineAllRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); - connect(ui.ShowPostAffineCurrentRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); - connect(ui.PolarAffineCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnPolarAffineCheckBoxStateChanged(int)), Qt::QueuedConnection); + connect(ui.PreFlipHorizontalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipHorizontalButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreFlipVerticalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipVerticalButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreRotate90CButton, SIGNAL(clicked(bool)), this, SLOT(OnRotate90CButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreRotate90CcButton, SIGNAL(clicked(bool)), this, SLOT(OnRotate90CcButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreRotateCButton, SIGNAL(clicked(bool)), this, SLOT(OnRotateCButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreRotateCcButton, SIGNAL(clicked(bool)), this, SLOT(OnRotateCcButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreMoveUpButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveUpButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreMoveDownButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveDownButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreMoveLeftButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveLeftButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreMoveRightButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveRightButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreScaleDownButton, SIGNAL(clicked(bool)), this, SLOT(OnScaleDownButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreScaleUpButton, SIGNAL(clicked(bool)), this, SLOT(OnScaleUpButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreResetButton, SIGNAL(clicked(bool)), this, SLOT(OnResetAffineButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreCopyButton, SIGNAL(clicked(bool)), this, SLOT(OnCopyAffineButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PrePasteButton, SIGNAL(clicked(bool)), this, SLOT(OnPasteAffineButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreRandomButton, SIGNAL(clicked(bool)), this, SLOT(OnRandomAffineButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostFlipHorizontalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipHorizontalButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostFlipVerticalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipVerticalButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostRotate90CcButton, SIGNAL(clicked(bool)), this, SLOT(OnRotate90CcButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostRotateCcButton, SIGNAL(clicked(bool)), this, SLOT(OnRotateCcButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostRotateCButton, SIGNAL(clicked(bool)), this, SLOT(OnRotateCButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostRotate90CButton, SIGNAL(clicked(bool)), this, SLOT(OnRotate90CButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostMoveUpButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveUpButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostMoveDownButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveDownButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostMoveLeftButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveLeftButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostMoveRightButton, SIGNAL(clicked(bool)), this, SLOT(OnMoveRightButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostScaleDownButton, SIGNAL(clicked(bool)), this, SLOT(OnScaleDownButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostScaleUpButton, SIGNAL(clicked(bool)), this, SLOT(OnScaleUpButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostResetButton, SIGNAL(clicked(bool)), this, SLOT(OnResetAffineButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostCopyButton, SIGNAL(clicked(bool)), this, SLOT(OnCopyAffineButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostPasteButton, SIGNAL(clicked(bool)), this, SLOT(OnPasteAffineButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PostRandomButton, SIGNAL(clicked(bool)), this, SLOT(OnRandomAffineButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.PreAffineGroupBox, SIGNAL(toggled(bool)), this, SLOT(OnAffineGroupBoxToggled(bool)), Qt::QueuedConnection); + connect(ui.PostAffineGroupBox, SIGNAL(toggled(bool)), this, SLOT(OnAffineGroupBoxToggled(bool)), Qt::QueuedConnection); + connect(ui.ShowPreAffineAllRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); + connect(ui.ShowPreAffineCurrentRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); + connect(ui.ShowPreAffineSelectedRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); + connect(ui.ShowPostAffineAllRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); + connect(ui.ShowPostAffineCurrentRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); + connect(ui.ShowPostAffineSelectedRadio, SIGNAL(toggled(bool)), this, SLOT(OnAffineDrawAllCurrentRadioButtonToggled(bool)), Qt::QueuedConnection); + connect(ui.PolarAffineCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnPolarAffineCheckBoxStateChanged(int)), Qt::QueuedConnection); #ifndef _WIN32 //For some reason linux makes these 24x24, even though the designer explicitly says 16x16. //Also, in order to get 4 pixels of spacing between elements in the grid layout, 0 must be specified. @@ -564,6 +570,7 @@ void Fractorium::OnScaleUpButtonClicked(bool checked) /// Called when reset pre/post affine buttons are clicked. /// Resets the rendering process. /// +/// True for pre affine, false for post. template void FractoriumEmberController::ResetXformsAffine(bool pre) { @@ -577,6 +584,42 @@ void FractoriumEmberController::ResetXformsAffine(bool pre) void Fractorium::OnResetAffineButtonClicked(bool checked) { m_Controller->ResetXformsAffine(sender() == ui.PreResetButton); } +/// +/// Copy the pre or post affine transform values from the current xform. +/// +/// True for pre affine, false for post. +template +void FractoriumEmberController::CopyXformsAffine(bool pre) +{ + if (auto xform = CurrentXform()) + m_CopiedAffine = pre ? xform->m_Affine : xform->m_Post; +} + +void Fractorium::OnCopyAffineButtonClicked(bool checked) +{ + m_Controller->CopyXformsAffine(sender() == ui.PreCopyButton); +} + +/// +/// Paste the last copied affine transform values to the pre or post affine values in the current xform. +/// +/// True for pre affine, false for post. +template +void FractoriumEmberController::PasteXformsAffine(bool pre) +{ + UpdateXform([&](Xform* xform, size_t xfindex, size_t selIndex) + { + auto& affine = pre ? xform->m_Affine : xform->m_Post; + affine = m_CopiedAffine; + }, eXformUpdate::UPDATE_CURRENT); + FillAffineWithXform(CurrentXform(), pre); +} + +void Fractorium::OnPasteAffineButtonClicked(bool checked) +{ + m_Controller->PasteXformsAffine(sender() == ui.PrePasteButton); +} + /// /// Randomize all values in selected pre/post affines to a range of -1 to 1. /// Called when random pre/post affine buttons are clicked. @@ -731,7 +774,11 @@ void Fractorium::SetupAffineSpinner(QTableWidget* table, const QObject* receiver /// GUI wrapper functions, getters only. /// +bool Fractorium::DrawCurrentPre() { return !DrawAllPre() && !DrawSelectedPre(); } +bool Fractorium::DrawSelectedPre() { return ui.ShowPreAffineSelectedRadio->isChecked(); } bool Fractorium::DrawAllPre() { return ui.ShowPreAffineAllRadio->isChecked(); } +bool Fractorium::DrawCurrentPost() { return !DrawAllPost() && !DrawSelectedPost(); } +bool Fractorium::DrawSelectedPost() { return ui.ShowPostAffineSelectedRadio->isChecked(); } bool Fractorium::DrawAllPost() { return ui.ShowPostAffineAllRadio->isChecked(); } bool Fractorium::LocalPivot() { return ui.LocalPivotRadio->isChecked(); } diff --git a/Source/Fractorium/FractoriumXformsVariations.cpp b/Source/Fractorium/FractoriumXformsVariations.cpp index ca8826c..508aba6 100644 --- a/Source/Fractorium/FractoriumXformsVariations.cpp +++ b/Source/Fractorium/FractoriumXformsVariations.cpp @@ -14,8 +14,9 @@ void Fractorium::InitXformsVariationsUI() connect(ui.VariationsFilterClearButton, SIGNAL(clicked(bool)), this, SLOT(OnVariationsFilterClearButtonClicked(bool))); connect(ui.ActionVariationsDialog, SIGNAL(triggered(bool)), this, SLOT(OnActionVariationsDialog(bool)), Qt::QueuedConnection); //Setting dimensions in the designer with a layout is futile, so must hard code here. - tree->setColumnWidth(0, 160); - tree->setColumnWidth(1, 23); + tree->setColumnWidth(0, 170); + tree->setColumnWidth(1, 80); + tree->setColumnWidth(2, 20); //Set Default variation tree text and background colors for zero and non zero cases. m_VariationTreeColorNonZero = Qt::black; m_VariationTreeColorZero = Qt::black; @@ -106,11 +107,16 @@ void FractoriumEmberController::SetupVariationsTree() { T fMin = TLOW; T fMax = TMAX; - QSize hint0(75, 16); - QSize hint1(30, 16); + QSize hint0(170, 16); + QSize hint1(80, 16); + QSize hint2(20, 16); + static vector dc{ "m_ColorX" }; + static vector assign{ "outPoint->m_X =", "outPoint->m_Y =", "outPoint->m_Z =", + "outPoint->m_X=", "outPoint->m_Y=", "outPoint->m_Z=" }; auto tree = m_Fractorium->ui.VariationsTree; tree->clear(); tree->blockSignals(true); + int iconSize_ = 20; for (size_t i = 0; i < m_VariationList->Size(); i++) { @@ -122,6 +128,34 @@ void FractoriumEmberController::SetupVariationsTree() item->setText(0, QString::fromStdString(var->Name())); item->setSizeHint(0, hint0); item->setSizeHint(1, hint1); + item->setSizeHint(2, hint2); + QPixmap pixmap(iconSize_ * 3, iconSize_); + auto mask = pixmap.createMaskFromColor(QColor("transparent"), Qt::MaskOutColor); + pixmap.setMask(mask); + QPainter paint(&pixmap); + paint.fillRect(QRect(0, 0, iconSize_ * 3, iconSize_), QColor(0, 0, 0, 0)); + + if (var->VarType() == eVariationType::VARTYPE_REG) + { + if (SearchVar(var, assign, false)) + paint.fillRect(QRect(0, 0, iconSize_, iconSize_), QColor(255, 0, 0)); + } + else if (var->VarType() == eVariationType::VARTYPE_PRE || var->VarType() == eVariationType::VARTYPE_POST) + { + if (var->AssignType() == eVariationAssignType::ASSIGNTYPE_SUM) + paint.fillRect(QRect(0, 0, iconSize_, iconSize_), QColor(255, 0, 0)); + } + + bool isDc = SearchVar(var, dc, false); + + if (isDc) + paint.fillRect(QRect(iconSize_, 0, iconSize_, iconSize_), QColor(0, 255, 0)); + + if (!var->StateOpenCLString().empty()) + paint.fillRect(QRect(iconSize_ * 2, 0, iconSize_, iconSize_), QColor(0, 0, 255)); + + QIcon qi(pixmap); + item->setIcon(2, qi); spinBox->setRange(fMin, fMax); spinBox->DoubleClick(true); spinBox->DoubleClickZero(1); @@ -358,11 +392,14 @@ void FractoriumEmberController::FillVariationTreeWithXform(Xform* xform) /// Column index of the header clicked. Sort by name if 0, sort by weight if 1. void Fractorium::OnTreeHeaderSectionClicked(int logicalIndex) { - m_VarSortMode = logicalIndex; - ui.VariationsTree->sortItems(m_VarSortMode, m_VarSortMode == 0 ? Qt::AscendingOrder : Qt::DescendingOrder); + if (logicalIndex <= 1) + { + m_VarSortMode = logicalIndex; + ui.VariationsTree->sortItems(m_VarSortMode, m_VarSortMode == 0 ? Qt::AscendingOrder : Qt::DescendingOrder); - if (m_VarSortMode == 1) - ui.VariationsTree->scrollToTop(); + if (m_VarSortMode == 1) + ui.VariationsTree->scrollToTop(); + } } /// diff --git a/Source/Fractorium/GLEmberController.cpp b/Source/Fractorium/GLEmberController.cpp index b44036c..280a16a 100644 --- a/Source/Fractorium/GLEmberController.cpp +++ b/Source/Fractorium/GLEmberController.cpp @@ -175,7 +175,7 @@ typename v3T GLEmberController::SnapToNormalizedAngle(v3T& vec, uint division { T rsq, theta; T bestRsq = numeric_limits::max(); - v3T c, best; + v3T c(0, 0, 0), best; best.x = 1; best.y = 0; diff --git a/Source/Fractorium/GLEmberController.h b/Source/Fractorium/GLEmberController.h index 8588c75..b27a237 100644 --- a/Source/Fractorium/GLEmberController.h +++ b/Source/Fractorium/GLEmberController.h @@ -118,7 +118,7 @@ public: void CalcDragTranslation(); void SetSelectedXform(Xform* xform); void DrawGrid(); - void DrawAffine(Xform* xform, bool pre, bool selected); + void DrawAffine(Xform* xform, bool pre, bool selected, bool hovered); int UpdateHover(v3T& glCoords); bool CheckXformHover(Xform* xform, v3T& glCoords, T& bestDist, bool pre, bool post); diff --git a/Source/Fractorium/GLWidget.cpp b/Source/Fractorium/GLWidget.cpp index 0dc7bf2..bb3528c 100644 --- a/Source/Fractorium/GLWidget.cpp +++ b/Source/Fractorium/GLWidget.cpp @@ -390,10 +390,9 @@ void GLEmberController::SetSelectedXform(Xform* xform) { //By doing this check, it prevents triggering unnecessary events when selecting an xform on this window with the mouse, //which will set the combo box on the main window, which will trigger this call. However, if the xform has been selected - //here with the mouse, the window has already repainted, so there's no need to do it again. - if (m_SelectedXform != xform || m_HoverXform != xform) + //here with the mouse, the window has already been repainted, so there's no need to do it again. + if (m_SelectedXform != xform) { - m_HoverXform = xform; m_SelectedXform = xform; if (m_GL->m_Init) @@ -513,7 +512,7 @@ void GLWidget::initializeGL() this->glEnable(GL_PROGRAM_POINT_SIZE); this->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_MaxTexSize); this->glDisable(GL_TEXTURE_2D); - m_Fractorium->m_WidthSpin->setMaximum(m_MaxTexSize);//This should also apply to the final render dialog.//TODO + m_Fractorium->m_WidthSpin->setMaximum(m_MaxTexSize); m_Fractorium->m_HeightSpin->setMaximum(m_MaxTexSize); } } @@ -535,9 +534,18 @@ void GLWidget::paintGL() auto controller = m_Fractorium->m_Controller.get(); //Ensure there is a renderer and that it's supposed to be drawing, signified by the running timer. - if (controller && controller->Renderer()) + if (controller && controller->Renderer()/* && controller->ProcessState() != eProcessState::NONE*/)//Need a way to determine if at leat one successful render has happened. { auto renderer = controller->Renderer(); + float unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f; + float unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f; + + if (unitX > 100000 || unitY > 100000)//Need a better way to do this.//TODO + { + qDebug() << unitX << " " << unitY; + //return; + } + m_Drawing = true; if (m_Fractorium->DrawImage()) @@ -553,8 +561,6 @@ void GLWidget::paintGL() //Affine drawing. bool pre = m_Fractorium->ui.PreAffineGroupBox->isChecked(); bool post = m_Fractorium->ui.PostAffineGroupBox->isChecked(); - float unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f; - float unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f; this->glEnable(GL_BLEND); this->glEnable(GL_LINE_SMOOTH); this->glEnable(GL_POINT_SMOOTH); @@ -635,7 +641,6 @@ void GLEmberController::DrawAffines(bool pre, bool post) { auto dprf = m_GL->devicePixelRatioF(); auto world = ScrolledCenter(true); - m_GL->glLineWidth(1.0f * dprf); GLfloat vertices[] = { @@ -654,7 +659,7 @@ void GLEmberController::DrawAffines(bool pre, bool post) if (!m_Fractorium->m_Settings->ShowAllXforms() && dragging) { if (m_SelectedXform) - DrawAffine(m_SelectedXform, m_AffineType == eAffineType::AffinePre, true); + DrawAffine(m_SelectedXform, m_AffineType == eAffineType::AffinePre, true, false); } else//Show all while dragging, or not dragging just hovering/mouse move. { @@ -664,13 +669,30 @@ void GLEmberController::DrawAffines(bool pre, bool post) while (auto xform = ember->GetTotalXform(i, forceFinal)) { - bool selected = m_Fractorium->IsXformSelected(i++) || (dragging ? (m_SelectedXform == xform) : (m_HoverXform == xform)); - DrawAffine(xform, true, selected); + bool selected = m_Fractorium->IsXformSelected(i++) || m_SelectedXform == xform; + DrawAffine(xform, true, selected, !dragging && (m_HoverXform == xform)); } } - else if (pre && m_HoverXform)//Only draw current pre affine. + else if (pre && m_Fractorium->DrawSelectedPre())//Only draw selected pre affine, and if none are selected, draw current. All are considered "selected", so circles are drawn around them. { - DrawAffine(m_HoverXform, true, true); + size_t i = 0; + bool any = false; + + while (auto xform = ember->GetTotalXform(i, forceFinal)) + { + if (m_Fractorium->IsXformSelected(i++)) + { + DrawAffine(xform, true, true, !dragging && (m_HoverXform == xform)); + any = true; + } + } + + if (!any) + DrawAffine(m_FractoriumEmberController->CurrentXform(), true, true, !dragging && (m_HoverXform == m_FractoriumEmberController->CurrentXform())); + } + else if (pre)//Only draw current pre affine. + { + DrawAffine(m_SelectedXform, true, true, !dragging && (m_HoverXform == m_FractoriumEmberController->CurrentXform())); } if (post && m_Fractorium->DrawAllPost())//Draw all post affine if specified. @@ -679,13 +701,30 @@ void GLEmberController::DrawAffines(bool pre, bool post) while (auto xform = ember->GetTotalXform(i, forceFinal)) { - bool selected = m_Fractorium->IsXformSelected(i++) || (dragging ? (m_SelectedXform == xform) : (m_HoverXform == xform)); - DrawAffine(xform, false, selected); + bool selected = m_Fractorium->IsXformSelected(i++) || m_SelectedXform == xform; + DrawAffine(xform, false, selected, !dragging && (m_HoverXform == xform)); } } - else if (post && m_HoverXform)//Only draw current post affine. + else if (post && m_Fractorium->DrawSelectedPost())//Only draw selected post, and if none are selected, draw current. All are considered "selected", so circles are drawn around them. { - DrawAffine(m_HoverXform, false, true); + size_t i = 0; + bool any = false; + + while (auto xform = ember->GetTotalXform(i, forceFinal)) + { + if (m_Fractorium->IsXformSelected(i++)) + { + DrawAffine(xform, false, true, !dragging && (m_HoverXform == xform)); + any = true; + } + } + + if (!any) + DrawAffine(m_FractoriumEmberController->CurrentXform(), false, true, !dragging && (m_HoverXform == m_FractoriumEmberController->CurrentXform())); + } + else if (post)//Only draw current post affine. + { + DrawAffine(m_SelectedXform, false, true, !dragging && (m_HoverXform == m_FractoriumEmberController->CurrentXform())); } } @@ -1032,7 +1071,9 @@ void GLEmberController::MouseMove(QMouseEvent* e) //Check if they weren't dragging and weren't hovering over any affine. //In that case, nothing needs to be done. if (UpdateHover(mouseFlipped) == -1) - draw = false; + { + m_HoverXform = nullptr; + } } //Only update if the user was dragging or hovered over a point. @@ -1128,7 +1169,7 @@ void GLWidget::DrawPointOrLine(const QVector4D& col, const GLfloat* vertices, in { #ifdef USE_GLSL - if (dashed && drawType == GL_LINES) + if (dashed && (drawType == GL_LINES || drawType == GL_LINE_LOOP)) { glLineStipple(1, 0XFF00); glEnable(GL_LINE_STIPPLE); @@ -1143,7 +1184,7 @@ void GLWidget::DrawPointOrLine(const QVector4D& col, const GLfloat* vertices, in this->glDrawArrays(drawType, 0, size); this->glDisableVertexAttribArray(0); - if (dashed && drawType == GL_LINES) + if (dashed && (drawType == GL_LINES || drawType == GL_LINE_LOOP)) glDisable(GL_LINE_STIPPLE); #endif @@ -1370,7 +1411,13 @@ void GLEmberController::DrawGrid() //qDebug() << renderer->UpperRightX(false) << " " << renderer->LowerLeftX(false) << " " << renderer->UpperRightY(false) << " " << renderer->LowerLeftY(false); float unitX = (std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f) / scale; float unitY = (std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f) / scale; - //qDebug() << unitX << " " << unitY; + + if (unitX > 100000 || unitY > 100000)//Need a better way to do this.//TODO + { + qDebug() << unitX << " " << unitY; + //return; + } + float xLow = std::floor(-unitX); float xHigh = std::ceil(unitX); float yLow = std::floor(-unitY); @@ -1479,8 +1526,9 @@ void GLEmberController::DrawGrid() /// A pointer to the xform whose affine will be drawn /// True for pre affine, else false for post. /// True if selected (draw enclosing circle), else false (only draw axes). +/// True if the xform is being hovered over (draw tansparent disc), else false (no disc). template -void GLEmberController::DrawAffine(Xform* xform, bool pre, bool selected) +void GLEmberController::DrawAffine(Xform* xform, bool pre, bool selected, bool hovered) { auto ember = m_FractoriumEmberController->CurrentEmber(); auto final = ember->IsFinalXform(xform); @@ -1498,9 +1546,9 @@ void GLEmberController::DrawAffine(Xform* xform, bool pre, bool selected) MultMatrix(mat); //QueryMatrices(true); m_GL->glLineWidth(3.0f * m_GL->devicePixelRatioF());//One 3px wide, colored black, except green on x axis for post affine. - m_GL->DrawAffineHelper(index, selected, pre, final, true); + m_GL->DrawAffineHelper(index, selected, hovered, pre, final, true); m_GL->glLineWidth(1.0f * m_GL->devicePixelRatioF());//Again 1px wide, colored white, to give a white middle with black outline effect. - m_GL->DrawAffineHelper(index, selected, pre, final, false); + m_GL->DrawAffineHelper(index, selected, hovered, pre, final, false); m_GL->glPointSize(5.0f * m_GL->devicePixelRatioF());//Three black points, one in the center and two on the circle. Drawn big 5px first to give a black outline. m_GL->glBegin(GL_POINTS); m_GL->glColor4f(0.0f, 0.0f, 0.0f, selected ? 1.0f : 0.5f); @@ -1528,9 +1576,9 @@ void GLEmberController::DrawAffine(Xform* xform, bool pre, bool selected) glm::tmat4x4 tempmat4 = mat; m_GL->m_ModelViewMatrix = QMatrix4x4(glm::value_ptr(tempmat4)); m_GL->glLineWidth(3.0f * m_GL->devicePixelRatioF());//One 3px wide, colored black, except green on x axis for post affine. - m_GL->DrawAffineHelper(index, selected, pre, final, true); + m_GL->DrawAffineHelper(index, selected, hovered, pre, final, true); m_GL->glLineWidth(1.0f * m_GL->devicePixelRatioF());//Again 1px wide, colored white, to give a white middle with black outline effect. - m_GL->DrawAffineHelper(index, selected, pre, final, false); + m_GL->DrawAffineHelper(index, selected, hovered, pre, final, false); QVector4D col(0.0f, 0.0f, 0.0f, selected ? 1.0f : 0.5f); m_Verts.clear(); m_Verts.push_back(0.0f); @@ -1577,10 +1625,11 @@ void GLEmberController::DrawAffine(Xform* xform, bool pre, bool selected) /// /// /// True if selected (draw enclosing circle), else false (only draw axes). +/// True if the xform is being hovered over (draw tansparent disc), else false (no disc). /// /// /// -void GLWidget::DrawAffineHelper(int index, bool selected, bool pre, bool final, bool background) +void GLWidget::DrawAffineHelper(int index, bool selected, bool hovered, bool pre, bool final, bool background) { float px = 1.0f; float py = 0.0f; @@ -1641,32 +1690,28 @@ void GLWidget::DrawAffineHelper(int index, bool selected, bool pre, bool final, //Circle part. if (!background) { - color = QVector4D(col.redF(), col.greenF(), col.blueF(), 1.0f);//Draw pre affine transform with white. + color = QVector4D(col.redF(), col.greenF(), col.blueF(), hovered ? 0.25f : 1.0f);//Draw pre affine transform with white. } else { - color = QVector4D(0.0f, 0.0f, 0.0f, 1.0f);//Draw pre affine transform outline with white. + color = QVector4D(0.0f, 0.0f, 0.0f, hovered ? 0.25f : 1.0f);//Draw pre affine transform outline with white. } m_Verts.clear(); - if (selected) + if (selected || hovered) { for (size_t i = 1; i <= 64; i++)//The circle. { float theta = float(M_PI) * 2.0f * float(i % 64) / 64.0f; float fx = std::cos(theta); float fy = std::sin(theta); - m_Verts.push_back(px); - m_Verts.push_back(py); m_Verts.push_back(fx); m_Verts.push_back(fy); - px = fx; - py = fy; } - } - DrawPointOrLine(color, m_Verts, GL_LINES, !pre); + DrawPointOrLine(color, m_Verts, hovered ? GL_TRIANGLE_FAN : GL_LINE_LOOP, !pre); + } //Lines from center to circle. if (!background) @@ -1712,8 +1757,6 @@ int GLEmberController::UpdateHover(v3T& glCoords) { bool pre = m_Fractorium->ui.PreAffineGroupBox->isChecked(); bool post = m_Fractorium->ui.PostAffineGroupBox->isChecked(); - bool preAll = pre && m_Fractorium->DrawAllPre(); - bool postAll = post && m_Fractorium->DrawAllPost(); int i = 0, bestIndex = -1; T bestDist = 10; auto ember = m_FractoriumEmberController->CurrentEmber(); @@ -1729,10 +1772,11 @@ int GLEmberController::UpdateHover(v3T& glCoords) //These checks prevent highlighting the pre/post selected xform circle, when one is set to show all, and the other //is set to show current, and the user hovers over another xform, but doesn't select it, then moves the mouse //back over the hidden circle for the pre/post that was set to only show current. - bool checkSelPre = preAll || (pre && m_HoverXform == m_SelectedXform); - bool checkSelPost = postAll || (post && m_HoverXform == m_SelectedXform); + bool isSel = m_Fractorium->IsXformSelected(ember->GetTotalXformIndex(m_SelectedXform)); + bool checkPre = pre && (m_Fractorium->DrawAllPre() || (m_Fractorium->DrawSelectedPre() && isSel) || m_Fractorium->DrawCurrentPre()); + bool checkPost = post && (m_Fractorium->DrawAllPost() || (m_Fractorium->DrawSelectedPost() && isSel) || m_Fractorium->DrawCurrentPost()); - if (CheckXformHover(m_SelectedXform, glCoords, bestDist, checkSelPre, checkSelPost)) + if (CheckXformHover(m_SelectedXform, glCoords, bestDist, checkPre, checkPost)) { m_HoverXform = m_SelectedXform; bestIndex = int(ember->GetTotalXformIndex(m_SelectedXform, forceFinal)); @@ -1740,24 +1784,35 @@ int GLEmberController::UpdateHover(v3T& glCoords) } //Check all xforms. - while (auto xform = ember->GetTotalXform(i, forceFinal)) { - if (preAll || (pre && m_HoverXform == xform))//Only check pre affine if they are shown. + bool isSel = m_Fractorium->IsXformSelected(i); + + if (pre) { - if (CheckXformHover(xform, glCoords, bestDist, true, false)) + bool checkPre = m_Fractorium->DrawAllPre() || (m_Fractorium->DrawSelectedPre() && isSel) || (m_SelectedXform == xform); + + if (checkPre)//Only check pre affine if they are shown. { - m_HoverXform = xform; - bestIndex = i; + if (CheckXformHover(xform, glCoords, bestDist, true, false)) + { + m_HoverXform = xform; + bestIndex = i; + } } } - if (postAll || (post && m_HoverXform == xform))//Only check post affine if they are shown. + if (post) { - if (CheckXformHover(xform, glCoords, bestDist, false, true)) + bool checkPost = m_Fractorium->DrawAllPost() || (m_Fractorium->DrawSelectedPost() && isSel) || (m_SelectedXform == xform); + + if (checkPost) { - m_HoverXform = xform; - bestIndex = i; + if (CheckXformHover(xform, glCoords, bestDist, false, true)) + { + m_HoverXform = xform; + bestIndex = i; + } } } @@ -1885,15 +1940,15 @@ bool GLEmberController::CheckXformHover(Xform* xform, v3T& glCoords, T& be /// /// Calculate the new affine transform when dragging with the x axis with the left mouse button. /// The value returned will depend on whether any modifier keys were held down. -/// None: Rotate and scale only. +/// None: Rotate only. /// Local Pivot: -/// Shift: Rotate only about affine center. -/// Alt: Free transform. -/// Shift + Alt: Rotate single axis about affine center. -/// Control: Rotate and scale, snapping to grid. -/// Control + Shift: Rotate only, snapping to grid. -/// Control + Alt: Free transform, snapping to grid. -/// Control + Shift + Alt: Rotate single axis about affine center, snapping to grid. +/// Shift: Scale and optionally Rotate about affine center. +/// Alt: Rotate single axis about affine center. +/// Shift + Alt: Free transform. +/// Control: Rotate, snapping to grid. +/// Control + Shift: Scale and optionally Rotate, snapping to grid. +/// Control + Alt: Rotate single axis about affine center, snapping to grid. +/// Control + Shift + Alt: Free transform, snapping to grid. /// World Pivot: /// Shift + Alt: Rotate single axis about world center. /// Control + Shift + Alt: Rotate single axis about world center, snapping to grid. @@ -1907,61 +1962,18 @@ void GLEmberController::CalcDragXAxis() auto worldToAffineScale = m_FractoriumEmberController->AffineScaleCurrentToLocked(); bool pre = m_AffineType == eAffineType::AffinePre; bool worldPivotShiftAlt = !m_Fractorium->LocalPivot() && GetShift() && GetAlt(); - auto startDiff = (v2T(m_HoverHandlePos) * affineToWorldScale) - m_DragSrcTransform.O(); - T startAngle = std::atan2(startDiff.y, startDiff.x); + auto worldRelAxisStartScaled = (v2T(m_HoverHandlePos) * affineToWorldScale) - m_DragSrcTransform.O();//World axis start position, relative, scaled by the zoom. + T startAngle = std::atan2(worldRelAxisStartScaled.y, worldRelAxisStartScaled.x); + v3T relScaled = (m_MouseWorldPos * affineToWorldScale) - v3T(m_DragSrcTransform.O(), 0); - if (GetShift()) + if (!GetShift()) { - v3T snapped = GetControl() ? SnapToNormalizedAngle(m_MouseWorldPos, 24u) : m_MouseWorldPos; - auto endDiff = (v2T(snapped) * affineToWorldScale) - m_DragSrcTransform.O(); - T endAngle = std::atan2(endDiff.y, endDiff.x); - T angle = startAngle - endAngle; - m_FractoriumEmberController->UpdateXform([&](Xform* xform, size_t xfindex, size_t selIndex) - { - auto& affine = pre ? xform->m_Affine : xform->m_Post; - auto srcRotated = m_DragSrcTransforms[selIndex]; - - if (worldPivotShiftAlt) - { - srcRotated.X(srcRotated.O() + srcRotated.X()); - srcRotated.O(v2T(0)); - srcRotated.Rotate(angle); - affine.X(srcRotated.X() - affine.O()); - } - else if (GetAlt()) - { - srcRotated.Rotate(angle); - affine.X(srcRotated.X()); - } - else - { - srcRotated.Rotate(angle); - affine = srcRotated; - } - - if (xform == m_FractoriumEmberController->CurrentXform()) - m_DragHandlePos = v3T((affine.O() + affine.X()) * worldToAffineScale, 0); - }, eXformUpdate::UPDATE_CURRENT_AND_SELECTED, false);//Calling code will update renderer. - } - else - { - v3T diff = m_MouseWorldPos - m_MouseDownWorldPos; - auto diffscale = diff * affineToWorldScale; - auto origmag = Zeps(glm::length(m_DragSrcTransform.X())); - auto origXPlusOff = v3T(m_DragSrcTransform.X(), 0) + diffscale; - if (GetControl()) { - auto o3 = v3T(m_DragSrcTransform.O(), 0); - auto o3x = origXPlusOff + o3; - origXPlusOff = SnapToGrid(o3x); - origXPlusOff -= o3; + relScaled = SnapToNormalizedAngle(relScaled, 24u);//relScaled is using the relative scaled position of the axis. } - auto newmag = glm::length(origXPlusOff); - auto newprc = newmag / origmag; - auto endDiff = (v2T(origXPlusOff) * affineToWorldScale); - T endAngle = std::atan2(endDiff.y, endDiff.x); + T endAngle = std::atan2(relScaled.y, relScaled.x); T angle = startAngle - endAngle; m_FractoriumEmberController->UpdateXform([&](Xform* xform, size_t xfindex, size_t selIndex) { @@ -1970,12 +1982,55 @@ void GLEmberController::CalcDragXAxis() if (GetAlt()) { - affine.X(v2T(origXPlusOff));//Absolute, not ratio. + src.Rotate(angle); + affine.X(src.X()); + } + else + { + src.Rotate(angle); + affine = src; + } + + if (xform == m_FractoriumEmberController->CurrentXform()) + m_DragHandlePos = v3T((affine.O() + affine.X()) * worldToAffineScale, 0); + }, eXformUpdate::UPDATE_CURRENT_AND_SELECTED, false);//Calling code will update renderer. + } + else + { + auto origmag = Zeps(glm::length(m_DragSrcTransform.X()));//Magnitude of original dragged axis before it was dragged. + + if (GetControl()) + { + relScaled = SnapToGrid(relScaled); + } + + auto newmag = glm::length(relScaled); + auto newprc = newmag / origmag; + T endAngle = std::atan2(relScaled.y, relScaled.x); + T angle = startAngle - endAngle; + m_FractoriumEmberController->UpdateXform([&](Xform* xform, size_t xfindex, size_t selIndex) + { + auto& affine = pre ? xform->m_Affine : xform->m_Post; + auto src = m_DragSrcTransforms[selIndex]; + + if (worldPivotShiftAlt) + { + src.X(src.O() + src.X()); + src.O(v2T(0)); + src.Rotate(angle); + affine.X(src.X() - affine.O()); + } + else if (GetAlt()) + { + affine.X(v2T(relScaled));//Absolute, not ratio. } else { src.ScaleXY(newprc); - src.Rotate(angle); + + if (m_Fractorium->m_Settings->RotateAndScale()) + src.Rotate(angle); + affine = src; } @@ -1988,15 +2043,15 @@ void GLEmberController::CalcDragXAxis() /// /// Calculate the new affine transform when dragging with the y axis with the left mouse button. /// The value returned will depend on whether any modifier keys were held down. -/// None: Rotate and scale only. +/// None: Rotate only. /// Local Pivot: -/// Shift: Rotate only about affine center. -/// Alt: Free transform. -/// Shift + Alt: Rotate single axis about affine center. -/// Control: Rotate and scale, snapping to grid. -/// Control + Shift: Rotate only, snapping to grid. -/// Control + Alt: Free transform, snapping to grid. -/// Control + Shift + Alt: Rotate single axis about affine center, snapping to grid. +/// Shift: Scale and optionally Rotate about affine center. +/// Alt: Rotate single axis about affine center. +/// Shift + Alt: Free transform. +/// Control: Rotate, snapping to grid. +/// Control + Shift: Scale and optionally Rotate, snapping to grid. +/// Control + Alt: Rotate single axis about affine center, snapping to grid. +/// Control + Shift + Alt: Free transform, snapping to grid. /// World Pivot: /// Shift + Alt: Rotate single axis about world center. /// Control + Shift + Alt: Rotate single axis about world center, snapping to grid. @@ -2010,61 +2065,18 @@ void GLEmberController::CalcDragYAxis() auto worldToAffineScale = m_FractoriumEmberController->AffineScaleCurrentToLocked(); bool pre = m_AffineType == eAffineType::AffinePre; bool worldPivotShiftAlt = !m_Fractorium->LocalPivot() && GetShift() && GetAlt(); - auto startDiff = (v2T(m_HoverHandlePos) * affineToWorldScale) - m_DragSrcTransform.O(); - T startAngle = std::atan2(startDiff.y, startDiff.x); + auto worldRelAxisStartScaled = (v2T(m_HoverHandlePos) * affineToWorldScale) - m_DragSrcTransform.O();//World axis start position, relative, scaled by the zoom. + T startAngle = std::atan2(worldRelAxisStartScaled.y, worldRelAxisStartScaled.x); + v3T relScaled = (m_MouseWorldPos * affineToWorldScale) - v3T(m_DragSrcTransform.O(), 0); - if (GetShift()) + if (!GetShift()) { - v3T snapped = GetControl() ? SnapToNormalizedAngle(m_MouseWorldPos, 24u) : m_MouseWorldPos; - auto endDiff = (v2T(snapped) * affineToWorldScale) - m_DragSrcTransform.O(); - T endAngle = std::atan2(endDiff.y, endDiff.x); - T angle = startAngle - endAngle; - m_FractoriumEmberController->UpdateXform([&](Xform* xform, size_t xfindex, size_t selIndex) - { - auto& affine = pre ? xform->m_Affine : xform->m_Post; - auto srcRotated = m_DragSrcTransforms[selIndex]; - - if (worldPivotShiftAlt) - { - srcRotated.Y(srcRotated.O() + srcRotated.Y()); - srcRotated.O(v2T(0)); - srcRotated.Rotate(angle); - affine.Y(srcRotated.Y() - affine.O()); - } - else if (GetAlt()) - { - srcRotated.Rotate(angle); - affine.Y(srcRotated.Y()); - } - else - { - srcRotated.Rotate(angle); - affine = srcRotated; - } - - if (xform == m_FractoriumEmberController->CurrentXform()) - m_DragHandlePos = v3T((affine.O() + affine.Y()) * worldToAffineScale, 0); - }, eXformUpdate::UPDATE_CURRENT_AND_SELECTED, false);//Calling code will update renderer. - } - else - { - v3T diff = m_MouseWorldPos - m_MouseDownWorldPos; - auto diffscale = diff * affineToWorldScale; - auto origmag = Zeps(glm::length(m_DragSrcTransform.Y())); - auto origYPlusOff = v3T(m_DragSrcTransform.Y(), 0) + diffscale; - if (GetControl()) { - auto o3 = v3T(m_DragSrcTransform.O(), 0); - auto o3y = origYPlusOff + o3; - origYPlusOff = SnapToGrid(o3y); - origYPlusOff -= o3; + relScaled = SnapToNormalizedAngle(relScaled, 24u);//relScaled is using the relative scaled position of the axis. } - auto newmag = glm::length(origYPlusOff); - auto newprc = newmag / origmag; - auto endDiff = (v2T(origYPlusOff) * affineToWorldScale); - T endAngle = std::atan2(endDiff.y, endDiff.x); + T endAngle = std::atan2(relScaled.y, relScaled.x); T angle = startAngle - endAngle; m_FractoriumEmberController->UpdateXform([&](Xform* xform, size_t xfindex, size_t selIndex) { @@ -2073,12 +2085,55 @@ void GLEmberController::CalcDragYAxis() if (GetAlt()) { - affine.Y(v2T(origYPlusOff));//Absolute, not ratio. + src.Rotate(angle); + affine.Y(src.Y()); + } + else + { + src.Rotate(angle); + affine = src; + } + + if (xform == m_FractoriumEmberController->CurrentXform()) + m_DragHandlePos = v3T((affine.O() + affine.Y()) * worldToAffineScale, 0); + }, eXformUpdate::UPDATE_CURRENT_AND_SELECTED, false);//Calling code will update renderer. + } + else + { + auto origmag = Zeps(glm::length(m_DragSrcTransform.Y()));//Magnitude of original dragged axis before it was dragged. + + if (GetControl()) + { + relScaled = SnapToGrid(relScaled); + } + + auto newmag = glm::length(relScaled); + auto newprc = newmag / origmag; + T endAngle = std::atan2(relScaled.y, relScaled.x); + T angle = startAngle - endAngle; + m_FractoriumEmberController->UpdateXform([&](Xform* xform, size_t xfindex, size_t selIndex) + { + auto& affine = pre ? xform->m_Affine : xform->m_Post; + auto src = m_DragSrcTransforms[selIndex]; + + if (worldPivotShiftAlt) + { + src.Y(src.O() + src.Y()); + src.O(v2T(0)); + src.Rotate(angle); + affine.Y(src.Y() - affine.O()); + } + else if (GetAlt()) + { + affine.Y(v2T(relScaled));//Absolute, not ratio. } else { src.ScaleXY(newprc); - src.Rotate(angle); + + if (m_Fractorium->m_Settings->RotateAndScale()) + src.Rotate(angle); + affine = src; } diff --git a/Source/Fractorium/GLWidget.h b/Source/Fractorium/GLWidget.h index cfcc0a7..e30245a 100644 --- a/Source/Fractorium/GLWidget.h +++ b/Source/Fractorium/GLWidget.h @@ -77,7 +77,7 @@ private: bool Deallocate(); void SetViewport(); void DrawUnitSquare(); - void DrawAffineHelper(int index, bool selected, bool pre, bool final, bool background); + void DrawAffineHelper(int index, bool selected, bool hovered, bool pre, bool final, bool background); GLEmberControllerBase* GLController(); bool m_Init = false; diff --git a/Source/Fractorium/OptionsDialog.cpp b/Source/Fractorium/OptionsDialog.cpp index fd4c0c1..b52c33e 100644 --- a/Source/Fractorium/OptionsDialog.cpp +++ b/Source/Fractorium/OptionsDialog.cpp @@ -76,6 +76,7 @@ bool FractoriumOptionsDialog::ToggleType() { return ui.ToggleTypeCheckBox->isChe bool FractoriumOptionsDialog::Png16Bit() { return ui.Png16BitCheckBox->isChecked(); } bool FractoriumOptionsDialog::AutoUnique() { return ui.AutoUniqueCheckBox->isChecked(); } bool FractoriumOptionsDialog::LoadLast() { return ui.LoadLastOnStartCheckBox->isChecked(); } +bool FractoriumOptionsDialog::RotateAndScale() { return ui.RotateAndScaleCheckBox->isChecked(); } uint FractoriumOptionsDialog::ThreadCount() { return ui.ThreadCountSpin->value(); } uint FractoriumOptionsDialog::RandomCount() { return ui.RandomCountSpin->value(); } uint FractoriumOptionsDialog::CpuQuality() { return ui.CpuQualitySpin->value(); } @@ -192,6 +193,7 @@ void FractoriumOptionsDialog::GuiToData() m_Settings->ThreadCount(ThreadCount()); m_Settings->RandomCount(RandomCount()); m_Settings->LoadLast(LoadLast()); + m_Settings->RotateAndScale(RotateAndScale()); m_Settings->CpuQuality(CpuQuality()); m_Settings->OpenClQuality(OpenClQuality()); m_Settings->CpuSubBatch(ui.CpuSubBatchSpin->value()); @@ -230,6 +232,7 @@ void FractoriumOptionsDialog::DataToGui() ui.ThreadCountSpin->setValue(m_Settings->ThreadCount()); ui.RandomCountSpin->setValue(m_Settings->RandomCount()); ui.LoadLastOnStartCheckBox->setChecked(m_Settings->LoadLast()); + ui.RotateAndScaleCheckBox->setChecked(m_Settings->RotateAndScale()); ui.CpuQualitySpin->setValue(m_Settings->CpuQuality()); ui.OpenCLQualitySpin->setValue(m_Settings->OpenClQuality()); ui.CpuSubBatchSpin->setValue(m_Settings->CpuSubBatch()); diff --git a/Source/Fractorium/OptionsDialog.h b/Source/Fractorium/OptionsDialog.h index ca5fc3d..c8d3842 100644 --- a/Source/Fractorium/OptionsDialog.h +++ b/Source/Fractorium/OptionsDialog.h @@ -37,6 +37,7 @@ public: bool Png16Bit(); bool AutoUnique(); bool LoadLast(); + bool RotateAndScale(); uint ThreadCount(); uint RandomCount(); uint CpuQuality(); diff --git a/Source/Fractorium/OptionsDialog.ui b/Source/Fractorium/OptionsDialog.ui index 573addf..9f6d7ce 100644 --- a/Source/Fractorium/OptionsDialog.ui +++ b/Source/Fractorium/OptionsDialog.ui @@ -6,8 +6,8 @@ 0 0 - 541 - 475 + 546 + 490 @@ -496,6 +496,16 @@ in interactive mode for each mouse movement + + + + <html><head/><body><p>Checked: scale and rotate when dragging affines while holding shift.</p><p>Unchecked: only scale when dragging affines while holding shift.</p></body></html> + + + Scale and Rotate With Shift + + + @@ -913,9 +923,15 @@ in interactive mode for each mouse movement EarlyClipCheckBox OpenCLCheckBox + YAxisUpCheckBox + SharedTextureCheckBox + TransparencyCheckBox DoublePrecisionCheckBox + ContinuousUpdateCheckBox ShowAllXformsCheckBox + Png16BitCheckBox ToggleTypeCheckBox + RotateAndScaleCheckBox LoadLastOnStartCheckBox ThreadCountSpin CpuSubBatchSpin