--Bug fixes

-Ensure all OpenCL functions that take multiple arguments cast literal values to real_t.
This commit is contained in:
Person 2019-05-23 19:44:27 -07:00
parent 9724b4d936
commit 95f29d8f7c
8 changed files with 81 additions and 81 deletions

View File

@ -1154,7 +1154,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) + fma(r, (1 - dx), -dx));\n"
<< "\t\tr = " << weight << " * (fmod(r + dx, 2 * dx) + fma(r, ((real_t)(1.0) - dx), -dx));\n"
<< "\t\tvOut.x = r * precalcCosa;\n"
<< "\t\tvOut.y = r * precalcSina;\n"
<< "\t\tvOut.z = " << DefaultZCl()
@ -1540,7 +1540,7 @@ public:
ss << "\t{\n"
<< "\t\treal_t r = precalcSqrtSumSquares;\n"
<< "\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 += 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"
@ -2148,7 +2148,7 @@ public:
<< "\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 = fma(" << spin << ", rndG, precalcAtanyx);\n"
<< "\t\treal_t rz = fma(" << zoom << ", rndG, -1.0);\n"
<< "\t\treal_t rz = fma(" << zoom << ", rndG, (real_t)(-1.0));\n"
<< "\n"
<< "\t\tvOut.x = fma(ra, cos(tempa), rz * vIn.x);\n"
<< "\t\tvOut.y = fma(ra, sin(tempa), rz * vIn.y);\n"

View File

@ -396,7 +396,7 @@ public:
<< "\t\t if (mb > 2)\n"
<< "\t\t max_bubble = 1;\n"
<< "\t\t else\n"
<< "\t\t max_bubble = mb / fma(SQR(mb), 0.25, 1.0);\n"
<< "\t\t max_bubble = mb / fma(SQR(mb), (real_t)(0.25), (real_t)(1.0));\n"
<< "\n"
<< "\t\t real_t r2 = SQR(radius);\n"
<< "\n"
@ -410,7 +410,7 @@ public:
<< "\t\t real_t rfactor = radius / Zeps(max_bubble);\n"
<< "\t\t real_t Lx2 = Lx * " << g2 << ";\n"
<< "\t\t real_t Ly2 = Ly * " << g2 << ";\n"
<< "\t\t real_t r = rfactor / fma(fma(Lx2, Lx2, SQR(Ly2)), 0.25, 1.0);\n"
<< "\t\t real_t r = rfactor / fma(fma(Lx2, Lx2, SQR(Ly2)), (real_t)(0.25), (real_t)(1.0));\n"
<< "\t\t real_t Lx3 = Lx2 * r;\n"
<< "\t\t real_t Ly3 = Ly2 * r;\n"
<< "\t\t real_t r_2 = fma(Lx3, Lx3, SQR(Ly3)) / Zeps(r2);\n"
@ -533,8 +533,8 @@ public:
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
ss << "\t{\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 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"
@ -2443,11 +2443,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 = fma(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(fma(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"
@ -2523,7 +2523,7 @@ public:
<< "\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 << " * (fma(vIn.x, " << natLog << ", -(vIn.y * MPI)) * -1));\n"
<< "\t\treal_t eradius2 = " << sc << " * exp(" << sc2 << " * (fma(vIn.x, " << natLog << ", -(vIn.y * MPI)) * (real_t)(-1.0)));\n"
<< "\n"
<< "\t\tvOut.x = " << weight << " * fma(eradius1, cnum1, -(eradius2 * cnum2)) * " << five << ";\n"
<< "\t\tvOut.y = " << weight << " * fma(eradius1, snum1, -(eradius2 * snum2)) * " << five << ";\n"
@ -3576,9 +3576,9 @@ 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 = fma(vIn.x, " << s2x << ", -(" << cx << " * (-r2 - 1)));\n"
<< "\t\treal_t x = fma(vIn.x, " << s2x << ", -(" << cx << " * (-r2 - (real_t)(1.0))));\n"
<< "\t\treal_t y = vIn.y * " << s2y << ";\n"
<< "\t\treal_t vr = " << weight << " / fma(" << c2 << ", r2, x2cx + 1);\n"
<< "\t\treal_t vr = " << weight << " / fma(" << c2 << ", r2, x2cx + (real_t)(1.0));\n"
<< "\t\treal_t temp = MwcNext(mwc) * " << pa << ";\n"
<< "\t\treal_t sina = sin(temp);\n"
<< "\t\treal_t cosa = cos(temp);\n"
@ -4806,11 +4806,11 @@ 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 = 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"
<< "\t\treal_t tr = fma(" << t3 << ", (xcb - (real_t)(3.0) * vIn.x * ysqr), fma(" << t2 << ", (xsqr - ysqr), fma(" << t1 << ", vIn.x, " << tc << ")));\n"
<< "\t\treal_t ti = fma(" << t3 << ", ((real_t)(3.0) * xsqr * vIn.y - ycb), fma(" << t2 << " * (real_t)(2.0), vIn.x * vIn.y, " << t1 << " * vIn.y));\n"
<< "\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"
<< "\t\treal_t br = fma(" << b3 << ", (xcb - (real_t)(3.0) * vIn.x * ysqr), fma(" << b2 << ", (xsqr - ysqr), fma(" << b1 << ", vIn.x, " << bc << ")));\n"
<< "\t\treal_t bi = fma(" << b3 << ", ((real_t)(3.0) * xsqr * vIn.y - ycb), fma(" << b2 << ", (real_t)(2.0) * vIn.x * vIn.y, " << b1 << " * vIn.y));\n"
<< "\n"
<< "\t\treal_t r3den = 1 / Zeps(fma(br, br, bi * bi));\n"
<< "\n"

View File

@ -35,7 +35,7 @@ public:
string weight = WeightDefineString();
string effect = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t temp = fma(" << effect << ", MPI, 1 / Zeps(cos(vIn.y)));\n"
<< "\t\treal_t temp = fma(" << effect << ", MPI, (real_t)(1.0) / Zeps(cos(vIn.y)));\n"
<< "\n"
<< "\t\tvOut.x = " << weight << " * (tanh(vIn.x) * temp);\n"
<< "\t\tvOut.y = " << weight << " * (tanh(vIn.y) * temp);\n"
@ -258,8 +258,8 @@ public:
intmax_t varIndex = IndexInXform();
string weight = WeightDefineString();
ss << "\t{\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.x = fma(" << weight << ", (vIn.x - ((SQR(vIn.x) * vIn.x) / (real_t)(3.0))), vIn.x * SQR(vIn.y));\n"
<< "\t\tvOut.y = fma(" << weight << ", (vIn.y - ((SQR(vIn.y) * vIn.y) / (real_t)(3.0))), vIn.y * SQR(vIn.x));\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
@ -1184,12 +1184,12 @@ public:
<< "\t\tf -= angle;\n"
<< "\n"
<< "\t\treal_t x = f * " << length << ";\n"
<< "\t\treal_t z = sqrt(fma(x, x, (real_t)(1.0)) - 2 * x * cos(" << alpha << "));\n"
<< "\t\treal_t z = sqrt(fma(x, x, (real_t)(1.0)) - (real_t)(2.0) * x * cos(" << alpha << "));\n"
<< "\n"
<< "\t\tif (((int)angle) & 1)\n"
<< "\t\t angle = fma(M_2PI / " << power << ", (real_t)(((int)angle) / 2), asin(sin(" << alpha << ") * x / z));\n"
<< "\t\t angle = fma(M_2PI / " << power << ", (real_t)(((int)angle) / (real_t)(2.0)), asin(sin(" << alpha << ") * x / z));\n"
<< "\t\telse\n"
<< "\t\t angle = fma(M_2PI / " << power << ", (real_t)(((int)angle) / 2), -asin(sin(" << alpha << ") * x / z));\n"
<< "\t\t angle = fma(M_2PI / " << power << ", (real_t)(((int)angle) / (real_t)(2.0)), -asin(sin(" << alpha << ") * x / z));\n"
<< "\n"
<< "\t\tz *= sqrt(MwcNext01(mwc));\n"
<< "\n"
@ -3075,8 +3075,8 @@ public:
<< "\t\t s = fma((real_t)(2.0) * " << width << ", deltaS, -" << width << ");\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tmx = fma(s, cos(t / 2), " << radius << ") * cos(t);\n"
<< "\t\tmy = fma(s, cos(t / 2), " << radius << ") * sin(t);\n"
<< "\t\tmx = fma(s, cos(t / (real_t)(2.0)), " << radius << ") * cos(t);\n"
<< "\t\tmy = fma(s, cos(t / (real_t)(2.0)), " << radius << ") * sin(t);\n"
<< "\t\tmz = s * sin(t / 2);\n"
<< "\n"
<< "\t\trx = mx;\n"

View File

@ -3151,7 +3151,7 @@ public:
<< "\t\treal_t st = sin(temp);\n"
<< "\t\treal_t ct = cos(temp);\n"
<< "\n"
<< "\t\ttemp = fma(" << ap << ", sin(fma(" << bp << ", r, " << cp << ")), acos(clamp(vIn.z / r, -(real_t)(1.0), (real_t)(1.0))));\n"
<< "\t\ttemp = fma(" << ap << ", sin(fma(" << bp << ", r, " << cp << ")), acos(clamp(vIn.z / r, (real_t)(-1.0), (real_t)(1.0))));\n"
<< "\n"
<< "\t\treal_t sp = sin(temp);\n"
<< "\t\treal_t cp = cos(temp);\n"
@ -4800,7 +4800,7 @@ public:
<< "\t\treal_t cellx = floor(vIn.x);\n"
<< "\t\treal_t celly = floor(vIn.y);\n"
<< "\t\treal_t xy0x = (MwcNext01(mwc) - 0.5) * wd;\n"
<< "\t\treal_t xy0y = fma(MwcNext01(mwc), 2.0, -1.0) * (1.0 - space - wd * 0.5);\n"
<< "\t\treal_t xy0y = fma(MwcNext01(mwc), (real_t)(2.0), (real_t)(-1.0)) * (1.0 - space - wd * 0.5);\n"
<< "\t\treal_t dir0 = fabs(cellx + celly);\n"
<< "\t\treal_t dir1 = dir0 - 2.0 * floor(dir0 / 2.0);\n"
<< "\t\treal_t xyx, xyy;\n"
@ -5313,7 +5313,7 @@ public:
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 = fma(fmod((real_t)MwcNext(mwc), (real_t)(1 / " << reInv << ")), M_2PI, precalcAtanyx);\n"
<< "\t\treal_t arg = fma(fmod((real_t)MwcNext(mwc), (real_t)((real_t)(1.0) / " << reInv << ")), M_2PI, precalcAtanyx);\n"
<< "\t\treal_t lnmod = " << dist << " * (real_t)(0.5) * log(precalcSumSquares);\n"
<< "\t\treal_t temp = fma(arg, " << reInv << ", lnmod * " << im100 << ");\n"
<< "\t\treal_t mod2 = exp(fma(lnmod, " << reInv << ", -(arg * " << im100 << ")));\n"

View File

@ -2517,7 +2517,7 @@ public:
<< "\t\t case 1:\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"
<< "\t\t sigma = fma(" << mulZ << ", az * rs, asin(r == 0 ? (real_t)(0.0) : vIn.z / r));\n"
<< "\n"
<< "\t\t sigmas = sin(sigma);\n"
<< "\t\t sigmac = cos(sigma);\n"
@ -3235,7 +3235,7 @@ public:
" else\n"
" {\n"
" ga1 = fma(width1, ga, width2 * hc * ga / be);\n"
" de1 = fma(width1, be, width2 * s2ab * (3 - ga / be));\n"
" de1 = fma(width1, be, width2 * s2ab * ((real_t)(3.0) - ga / be));\n"
" }\n"
"\n"
" *al1 = s2a + fma(-ba, de1, - ca * ga1);\n"
@ -3253,7 +3253,7 @@ public:
" else\n"
" {\n"
" de1 = fma(width1, be, width2 * hb * be / ga);\n"
" ga1 = fma(width1, ga, width2 * s2ac * (3 - be / ga));\n"
" ga1 = fma(width1, ga, width2 * s2ac * ((real_t)(3.0) - be / ga));\n"
" }\n"
"\n"
" *al1 = s2a + fma(-ba, de1, -ca * ga1);\n"
@ -3269,7 +3269,7 @@ public:
" else\n"
" {\n"
" *be1 = fma(width1, be, width2 * hb * be / al);\n"
" *al1 = fma(width1, al, width2 * s2ac * (3 - be / al));\n"
" *al1 = fma(width1, al, width2 * s2ac * ((real_t)(3.0) - be / al));\n"
" }\n"
" }\n"
" }\n"
@ -3286,7 +3286,7 @@ public:
" else\n"
" {\n"
" ga1 = fma(width1, ga, width2 * hc * ga / al);\n"
" de1 = fma(width1, al, width2 * s2ab * (3 - ga / al));\n"
" de1 = fma(width1, al, width2 * s2ab * ((real_t)(3.0) - ga / al));\n"
" }\n"
"\n"
" *be1 = s2b + fma(-ab, de1, -cb * ga1);\n"
@ -3304,7 +3304,7 @@ public:
" else\n"
" {\n"
" de1 = fma(width1, al, width2 * ha * al / ga);\n"
" ga1 = fma(width1, ga, width2 * s2bc * (3 - al / ga));\n"
" ga1 = fma(width1, ga, width2 * s2bc * ((real_t)(3.0) - al / ga));\n"
" }\n"
"\n"
" *be1 = s2b + fma(-ab, de1, -cb * ga1);\n"
@ -3320,7 +3320,7 @@ public:
" else\n"
" {\n"
" *al1 = fma(width1, al, width2 * ha * al / be);\n"
" *be1 = fma(width1, be, width2 * s2bc * (3 - al / be));\n"
" *be1 = fma(width1, be, width2 * s2bc * ((real_t)(3.0) - al / be));\n"
" }\n"
" }\n"
" }\n"
@ -3729,7 +3729,7 @@ public:
<< "\t\t}\n"
<< "\n"
<< "\t\tif (majplane == 2)\n"
<< "\t\t vOut.z = fma(vIn.z * 0.5, " << zlift << ", (posNeg * boost));\n"
<< "\t\t vOut.z = fma(vIn.z * (real_t)(0.5), " << zlift << ", (posNeg * boost));\n"
<< "\t\telse\n"
<< "\t\t vOut.z = vIn.z * 0.5 * " << zlift << ";\n"
<< "\n"
@ -4104,7 +4104,7 @@ public:
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\n"
<< "\t\t vOut.z = fma(smooth * posNeg, fma(vIn.z * scale, " << zlift << ", boost), sumZ - (2 * smooth * sumZ));\n";
<< "\t\t vOut.z = fma(smooth * posNeg, fma(vIn.z * scale, " << zlift << ", boost), sumZ - ((real_t)(2.0) * smooth * sumZ));\n";
if (m_VarType == eVariationType::VARTYPE_REG)
ss << "\t\t outPoint->m_Z = 0;\n";
@ -4153,9 +4153,9 @@ public:
//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);";
ss << "\n\tvarState." << prefix << "hexnix3D_rswtch" << stateIndex << " = trunc(MwcNext01(&mwc) * (real_t)(3.0));";
ss << "\n\tvarState." << prefix << "hexnix3D_fcycle" << stateIndex << " = trunc(MwcNext01(&mwc) * (real_t)(5.0));";
ss << "\n\tvarState." << prefix << "hexnix3D_bcycle" << stateIndex << " = trunc(MwcNext01(&mwc) * (real_t)(2.0));";
return ss.str();
}

View File

@ -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 = fma(trgL / L1, (real_t)(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 - (real_t)(0.5))) / 0.3;\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tVx *= R;\n"
@ -3207,7 +3207,7 @@ public:
"\n"
" if (*skew != 0)\n"
" {\n"
" *z = fma(0.5, *skew, 0.5);\n"
" *z = fma((real_t)(0.5), *skew, (real_t)(0.5));\n"
"\n"
" if (*y > *z)\n"
" *y = fma((real_t)(0.5), (*y - *z) / Zeps(1 - *z), (real_t)(0.5));\n"
@ -3230,7 +3230,7 @@ public:
" *x = 1 - 2 * *y;\n"
" break;\n"
" case WAVE_TRIANGLE:\n"
" *x = *y > 0.5 ? 3 - 4 * *y : fma((real_t)(2.0), *y, -1);\n"
" *x = *y > 0.5 ? 3 - 4 * *y : fma((real_t)(2.0), *y, (real_t)(-1.0));\n"
" break;\n"
" case WAVE_CONCAVE:\n"
" *x = fma((real_t)(8.0), Sqr(*y - 0.5), (real_t)(-1.0));\n"
@ -3308,7 +3308,7 @@ public:
" t = x;\n"
"\n"
" if (fabs(m - 0.5) > 1e-10)\n"
" t = fma((real_t)(-1.0), m, sqrt(fma(m, m, (1 - 2 * m) * x))) / (1 - 2 * m);\n"
" t = fma((real_t)(-1.0), m, sqrt(fma(m, m, ((real_t)(1.0) - (real_t)(2.0) * m) * x))) / ((real_t)(1.0) - (real_t)(2.0) * m);\n"
"\n"
" return a * fma(m - (real_t)(1.0), SQR(t), x);\n"
" }\n"
@ -3318,7 +3318,7 @@ public:
" t = x;\n"
"\n"
" if (fabs(m - 2) > 1e-10)\n"
" t = fma((real_t)(-1.0), iM, sqrt(fma(iM, iM, (1 - 2 * iM) * x))) / (1 - 2 * iM);\n"
" t = fma((real_t)(-1.0), iM, sqrt(fma(iM, iM, ((real_t)(1.0) - (real_t)(2.0) * iM) * x))) / ((real_t)(1.0) - (real_t)(2.0) * iM);\n"
"\n"
" return a * fma(m - (real_t)(1.0), SQR(t), x);\n"
" }\n"
@ -3326,11 +3326,11 @@ public:
" if (m < 1)\n"
" {\n"
" t = sqrt((x - 1) / (L - 1));\n"
" return a * fma((m - 1), t * t, x + fma((real_t)(2.0), (1 - m) * t, (m - 1)));\n"
" return a * fma((m - 1), t * t, x + fma((real_t)(2.0), ((real_t)(1.0) - m) * t, (m - 1)));\n"
" }\n"
"\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"
" t = (1 - m) + sqrt(fma((m - (real_t)(1.0)), (m - (real_t)(1.0)), (x - (real_t)(1.0))));\n"
" return a * fma((m - (real_t)(1.0)), t * t, x - fma((real_t)(2.0), (m - (real_t)(1.0)) * t, (m - (real_t)(1.0))));\n"
"}\n"
"\n"
"static real_t Interpolate(real_t x, real_t m, int lerpType)\n"
@ -3354,11 +3354,11 @@ public:
" {\n"
" case SINCOS_MULTIPLY:\n"
" *s = *s * SynthValue(synth, theta);\n"
" *c = *c * SynthValue(synth, theta + MPI / 2);\n"
" *c = *c * SynthValue(synth, theta + MPI / (real_t)(2.0));\n"
" break;\n"
" case SINCOS_MIXIN:\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"
" *s = fma(((real_t)(1.0) - synth->SynthMix), *s, (SynthValue(synth, theta) - (real_t)(1.0)));\n"
" *c = fma(((real_t)(1.0) - synth->SynthMix), *c, (SynthValue(synth, theta + MPI / (real_t)(2.0)) - (real_t)(1.0)));\n"
" break;\n"
" }\n"
"\n"

View File

@ -497,8 +497,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 << " * 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.x = " << weight << " * fma(((real_t)(1.0) / Zeps(" << x << " * M_2PI)), sin(" << x << " * M_2PI * vIn.x), vIn.x);\n"
<< "\t\tvOut.y = " << weight << " * fma(((real_t)(1.0) / Zeps(" << y << " * M_2PI)), sin(" << y << " * M_2PI * vIn.y), vIn.y);\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
@ -699,33 +699,33 @@ public:
<< "\t\t posNeg = -1;\n"
<< "\n"
<< "\t\tpang = th / Zeps(" << cycle << ");\n"
<< "\t\twig = fma(pang, " << freq << " * 0.5, " << offset << " * " << cycle << ");\n"
<< "\t\twig = fma(pang, " << freq << " * (real_t)(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 << ") + 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 wag = sin(curve1* MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * (real_t)(0.5) * sin(curveTwo * MPI)); \n"
<< "\t\t wag3 = sin(curve4* MPI * " << absOptSc << ") + fma(" << wagsc << ", SQR(rad) * (real_t)(0.4), " << crvsc << " * (real_t)(0.5) * cos(curve3 * MPI)); \n"
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\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 wag = sin(curve1* MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * (real_t)(0.5) * cos(curve3 * MPI)); \n"
<< "\t\t wag3 = sin(curve4* MPI * " << absOptSc << ") + fma(" << wagsc << ", SQR(rad) * (real_t)(0.4), " << crvsc << " * (real_t)(0.5) * sin(curveTwo * MPI)); \n"
<< "\t\t}\n"
<< "\n"
<< "\t\twag2 = sin(curveTwo * MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * 0.5 * cos(curve3 * MPI)); \n"
<< "\t\twag2 = sin(curveTwo * MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * (real_t)(0.5) * cos(curve3 * MPI)); \n"
<< "\n"
<< "\t\tif (" << smooth12 << " <= 1)\n"
<< "\t\t wag12 = wag; \n"
<< "\t\telse if (" << smooth12 << " <= 2 && " << smooth12 << " > 1)\n"
<< "\t\t wag12 = fma(wag2, (1 - " << antiOpt1 << "), wag * " << antiOpt1 << "); \n"
<< "\t\t wag12 = fma(wag2, ((real_t)(1.0) - " << antiOpt1 << "), wag * " << antiOpt1 << "); \n"
<< "\t\telse if (" << smooth12 << " > 2)\n"
<< "\t\t wag12 = wag2; \n"
<< "\n"
<< "\t\tif (" << smooth3 << " == 0)\n"
<< "\t\t waggle = wag12; \n"
<< "\t\telse if (" << smooth3 << " > 0)\n"
<< "\t\t waggle = fma(wag12, (1 - " << smooth3 << "), wag3 * " << smooth3 << "); \n"
<< "\t\t waggle = fma(wag12, ((real_t)(1.0) - " << smooth3 << "), wag3 * " << smooth3 << "); \n"
<< "\n"
<< "\t\treal_t cospetthcl = " << weight << " * (real_t)(0.5) * " << "cos(fma(" << numPetals << ", th, " << c << ")) * " << l << "; \n"
<< "\n"
@ -735,13 +735,13 @@ public:
<< "\t\t {\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 vOut.z = " << weight << " * (real_t)(-0.5) * (fma(" << z2 << ", waggle, Sqr(rad * (real_t)(0.5)) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\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 vOut.z = " << weight << " * (real_t)(0.5) * (fma(" << z1 << ", waggle, Sqr(rad * (real_t)(0.5)) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
<< "\t\t }\n"
<< "\t\t}\n"
<< "\t\telse\n"
@ -750,13 +750,13 @@ public:
<< "\t\t {\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 vOut.z = " << weight << " * (real_t)(0.5) * (fma(" << z1 << ", waggle, Sqr(rad * (real_t)(0.5)) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\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 vOut.z = " << weight << " * (real_t)(0.5) * (fma(" << z1 << ", waggle, Sqr(rad * (real_t)(0.5)) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
<< "\t\t }\n"
<< "\t\t}\n"
<< "\t}\n";
@ -3319,7 +3319,7 @@ public:
<< "\t\tif (rad > " << radius << ")\n"
<< "\t\t{\n"
<< "\t\t real_t ang = MwcNext01(mwc) * M_2PI;\n"
<< "\t\t real_t r = (" << power << " == 1 ? acos(fma(MwcNext01(mwc), 2, -1.0)) / MPI : acos(exp(log(1 - MwcNext01(mwc)) * " << power << ") * 2 - 1) / MPI);\n"
<< "\t\t real_t r = (" << power << " == 1 ? acos(fma(MwcNext01(mwc), (real_t)(2.0), (real_t)(-1.0))) / MPI : acos(exp(log((real_t)(1.0) - MwcNext01(mwc)) * " << power << ") * (real_t)(2.0) - (real_t)(1.0)) / MPI);\n"
<< "\t\t real_t aux = r * " << blurover10 << " * (rad - " << radius << ");\n"
<< "\t\t bx = aux * cos(ang);\n"
<< "\t\t by = aux * sin(ang);\n"
@ -3416,7 +3416,7 @@ public:
<< "\t\tif (rad > " << radius << ")\n"
<< "\t\t{\n"
<< "\t\t real_t ang = MwcNext01(mwc) * M_2PI;\n"
<< "\t\t real_t r = (" << power << " == 1 ? acos(fma(MwcNext01(mwc), 2, -1.0)) / MPI : acos(exp(log(1 - MwcNext01(mwc)) * " << power << ") * 2 - 1) / MPI);\n"
<< "\t\t real_t r = (" << power << " == 1 ? acos(fma(MwcNext01(mwc), 2, (real_t)(-1.0))) / MPI : acos(exp(log(1 - MwcNext01(mwc)) * " << power << ") * 2 - 1) / MPI);\n"
<< "\t\t real_t aux = r * " << blurover10 << " * exp(log(rad - " << radius << ") * " << exp << ");\n"
<< "\t\t bx = aux * cos(ang);\n"
<< "\t\t by = aux * sin(ang);\n"
@ -3574,8 +3574,8 @@ public:
ss << "\t{\n"
<< "\t\treal_t X = fmod(floor(vIn.x), " << zdens << ") / " << zdens << ";\n"
<< "\t\treal_t Y = fmod(floor(vIn.y), " << zdens << ") / " << zdens << ";\n"
<< "\t\treal_t random_x = HashShadertoy(X, Y, 0.0);\n"
<< "\t\treal_t random_y = HashShadertoy(Y, X, 0.0);\n"
<< "\t\treal_t random_x = HashShadertoy(X, Y, (real_t)(0.0));\n"
<< "\t\treal_t random_y = HashShadertoy(Y, X, (real_t)(0.0));\n"
<< "\t\treal_t a = fma(random_x, " << dist << ", X) * M_2PI;\n"
<< "\t\treal_t r = exp(log(fma(random_y, " << dist << ", Y)) * " << power << ");\n"
<< "\t\tvOut.x = " << weight << " * cos(a) * r;\n"
@ -5808,26 +5808,26 @@ public:
<< "\t\t real_t xrand = floor(fabs(vIn.x) + 0.5);\n"
<< "\t\t real_t yrand = floor(fabs(vIn.y) + 0.5);\n"
<< "\t\t real_t randint0 = HashShadertoy(xrand, yrand, " << seed << ");\n"
<< "\t\t real_t randint = fmod(fma(randint0, 32747.0, 12345.0), 65535.0);\n"
<< "\t\t real_t randint = fmod(fma(randint0, (real_t)(32747.0), (real_t)(12345.0)), (real_t)(65535.0));\n"
<< "\t\t tiletype = fmod(randint, 2.0);\n"
<< "\t\t}\n"
<< "\n"
<< "\t\treal_t xval1 = tiletype < 1 ? x : x - 1;\n"
<< "\t\treal_t xval2 = tiletype < 1 ? x - 1 : x;\n"
<< "\t\treal2 R = (real2)(pow(pow(fabs(xval1), " << n << ") + pow(fabs(y), " << n << "), " << onen << "), pow(pow(fabs(xval2), " << n << ") + pow(fabs(y - 1), " << n << "), " << onen << "));\n"
<< "\t\treal_t r00 = fabs(R.x - 0.5) / " << rmax << ";\n"
<< "\t\treal_t r11 = fabs(R.y - 0.5) / " << rmax << ";\n"
<< "\t\treal_t r00 = fabs(R.x - (real_t)(0.5)) / " << rmax << ";\n"
<< "\t\treal_t r11 = fabs(R.y - (real_t)(0.5)) / " << rmax << ";\n"
<< "\t\treal2 xy;\n"
<< "\n"
<< "\t\tif (r00 < 1)\n"
<< "\t\t xy = (real2)(fma(floor(vIn.x), 2.0, x), fma(floor(vIn.y), 2.0, y));\n"
<< "\t\t xy = (real2)(fma(floor(vIn.x), (real_t)(2.0), x), fma(floor(vIn.y), (real_t)(2.0), y));\n"
<< "\t\telse\n"
<< "\t\t xy = (real2)(0.0, 0.0);\n"
<< "\n"
<< "\t\treal_t cost = cos(" << rads << ");\n"
<< "\t\treal_t sint = sin(" << rads << ");\n"
<< "\t\treal_t roundx = (floor(vIn.x / " << amp << ") + 0.5) * " << amp << ";\n"
<< "\t\treal_t roundy = (floor(vIn.y / " << amp << ") + 0.5) * " << amp << ";\n"
<< "\t\treal_t roundx = (floor(vIn.x / " << amp << ") + (real_t)(0.5)) * " << amp << ";\n"
<< "\t\treal_t roundy = (floor(vIn.y / " << amp << ") + (real_t)(0.5)) * " << amp << ";\n"
<< "\t\treal_t vx = vIn.x - roundx;\n"
<< "\t\treal_t vy = vIn.y - roundy;\n"
<< "\t\treal_t newx = fma(cost, vx, sint * vy);\n"
@ -5837,8 +5837,8 @@ public:
<< "\t\t{\n"
<< "\t\t if (r11 < 1)\n"
<< "\t\t {\n"
<< "\t\t vOut.x = xy.x + fma(floor(vIn.x), 2.0, x) - vIn.x;\n"
<< "\t\t vOut.y = xy.y + fma(floor(vIn.y), 2.0, y) - vIn.y;\n"
<< "\t\t vOut.x = xy.x + fma(floor(vIn.x), (real_t)(2.0), x) - vIn.x;\n"
<< "\t\t vOut.y = xy.y + fma(floor(vIn.y), (real_t)(2.0), y) - vIn.y;\n"
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\n"
@ -6015,7 +6015,7 @@ public:
<< "\t\treal_t yrand = floor(vIn.y + 0.5) * " << seed2 << ";\n"
<< "\t\treal_t niter = xrand + yrand + xrand * yrand;\n"
<< "\t\treal_t randint0 = (niter + " << seed << ") * " << seed2half << ";\n"
<< "\t\treal_t randint = fmod(fma(randint0, 32747.0, 12345.0), 65535.0);\n"
<< "\t\treal_t randint = fmod(fma(randint0, (real_t)(32747.0), (real_t)(12345.0)), (real_t)(65535.0));\n"
<< "\t\t tiletype = fmod(randint, 2.0);\n"
<< "\t\t}\n"
<< "\n"
@ -6744,7 +6744,7 @@ public:
<< "\t\treal_t ax = floor(vIn.y * " << freqx << " / M_2PI);\n"
<< "\t\tax = sin(ax * (real_t)(12.9898) + ax * (real_t)(78.233) + (real_t)(1.0) + vIn.y * " << yfact001 << ") * (real_t)(43758.5453);\n"
<< "\t\tax = ax - (int) ax;\n"
<< "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : 0.0;\n"
<< "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : (real_t)(0.0);\n"
<< "\n"
<< "\t\tvOut.x = " << weight << " * fma(sin(vIn.y * " << freqx << "), ax * ax * " << scalex << ", vIn.x);\n"
<< "\t\tvOut.y = " << weight << " * fma(sin(vIn.x * " << freqy << "), " << scaley << ", vIn.y);\n"
@ -7035,7 +7035,7 @@ public:
<< "\t\treal_t ax = floor(vIn.y * " << freqx2 << ");\n"
<< "\t\tax = sin(ax * (real_t)(12.9898) + ax * (real_t)(78.233) + (real_t)(1.0) + vIn.y * " << yfact001 << ") * (real_t)(43758.5453);\n"
<< "\t\tax = ax - (int) ax;\n"
<< "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : 0.0;\n"
<< "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : (real_t)(0.0);\n"
<< "\n"
<< "\t\tvOut.x = " << weight << " * fma(sin(vIn.y * " << freqx << "), ax * ax * " << scalex << ", vIn.x);\n"
<< "\t\tvOut.y = " << weight << " * fma(sin(vIn.x * " << freqy << "), " << scaley << ", vIn.y);\n"

View File

@ -165,7 +165,7 @@ public:
<< "\t\tvOut.x = " << weight << " * (xform->m_A * x + xform->m_B * y + xform->m_E);\n"
<< "\t\tvOut.y = " << weight << " * (xform->m_C * x + xform->m_D * y + xform->m_F);\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t\toutPoint->m_ColorX = fmod(fabs(outPoint->m_ColorX * (real_t)(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * (real_t)(0.5)), (real_t)(1.0));\n"
<< "\t\toutPoint->m_ColorX = fmod(fabs(outPoint->m_ColorX * (real_t)(0.5) * (real_t)(1 + h) + x0_xor_y0 * (real_t)(1 - h) * (real_t)(0.5)), (real_t)(1.0));\n"
<< "\t}\n";
return ss.str();
}
@ -1520,7 +1520,7 @@ public:
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\tvOut.z = " << blockheight << " * z * pow(MwcNext01(mwc), (real_t)(0.125));\n"
<< "\t\toutPoint->m_ColorX = z / 2;\n"
<< "\t}\n";
return ss.str();