mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Pixel/LightingShaderGen: Fix code alignment issues.
Most of these weren't even introduced by me, but hey - I'm nice and love wasting my time :p
This commit is contained in:
parent
2067f88e0f
commit
c1016205d3
@ -59,8 +59,8 @@ static void GenerateLightShader(T& object, LightingUidData& uid_data, int index,
|
|||||||
case LIGHTDIF_CLAMP:
|
case LIGHTDIF_CLAMP:
|
||||||
object.Write("ldir = normalize(" LIGHT_POS".xyz - pos.xyz);\n", LIGHT_POS_PARAMS(lightsName, index));
|
object.Write("ldir = normalize(" LIGHT_POS".xyz - pos.xyz);\n", LIGHT_POS_PARAMS(lightsName, index));
|
||||||
object.Write("lacc.%s += int%s(round(%sdot(ldir, _norm0)) * float%s(" LIGHT_COL")));\n",
|
object.Write("lacc.%s += int%s(round(%sdot(ldir, _norm0)) * float%s(" LIGHT_COL")));\n",
|
||||||
swizzle, swizzle_components, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0," :"(",
|
swizzle, swizzle_components, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0," :"(",
|
||||||
swizzle_components, LIGHT_COL_PARAMS(lightsColName, index, swizzle));
|
swizzle_components, LIGHT_COL_PARAMS(lightsColName, index, swizzle));
|
||||||
break;
|
break;
|
||||||
default: _assert_(0);
|
default: _assert_(0);
|
||||||
}
|
}
|
||||||
@ -71,13 +71,13 @@ static void GenerateLightShader(T& object, LightingUidData& uid_data, int index,
|
|||||||
{ // spot
|
{ // spot
|
||||||
object.Write("ldir = " LIGHT_POS".xyz - pos.xyz;\n", LIGHT_POS_PARAMS(lightsName, index));
|
object.Write("ldir = " LIGHT_POS".xyz - pos.xyz;\n", LIGHT_POS_PARAMS(lightsName, index));
|
||||||
object.Write("dist2 = dot(ldir, ldir);\n"
|
object.Write("dist2 = dot(ldir, ldir);\n"
|
||||||
"dist = sqrt(dist2);\n"
|
"dist = sqrt(dist2);\n"
|
||||||
"ldir = ldir / dist;\n"
|
"ldir = ldir / dist;\n"
|
||||||
"attn = max(0.0, dot(ldir, " LIGHT_DIR".xyz));\n",
|
"attn = max(0.0, dot(ldir, " LIGHT_DIR".xyz));\n",
|
||||||
LIGHT_DIR_PARAMS(lightsName, index));
|
LIGHT_DIR_PARAMS(lightsName, index));
|
||||||
// attn*attn may overflow
|
// attn*attn may overflow
|
||||||
object.Write("attn = max(0.0, " LIGHT_COSATT".x + " LIGHT_COSATT".y*attn + " LIGHT_COSATT".z*attn*attn) / dot(" LIGHT_DISTATT".xyz, float3(1.0,dist,dist2));\n",
|
object.Write("attn = max(0.0, " LIGHT_COSATT".x + " LIGHT_COSATT".y*attn + " LIGHT_COSATT".z*attn*attn) / dot(" LIGHT_DISTATT".xyz, float3(1.0,dist,dist2));\n",
|
||||||
LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_DISTATT_PARAMS(lightsName, index));
|
LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_DISTATT_PARAMS(lightsName, index));
|
||||||
}
|
}
|
||||||
else if (chan.attnfunc == 1)
|
else if (chan.attnfunc == 1)
|
||||||
{ // specular
|
{ // specular
|
||||||
@ -85,23 +85,23 @@ static void GenerateLightShader(T& object, LightingUidData& uid_data, int index,
|
|||||||
object.Write("attn = (dot(_norm0,ldir) >= 0.0) ? max(0.0, dot(_norm0, " LIGHT_DIR".xyz)) : 0.0;\n", LIGHT_DIR_PARAMS(lightsName, index));
|
object.Write("attn = (dot(_norm0,ldir) >= 0.0) ? max(0.0, dot(_norm0, " LIGHT_DIR".xyz)) : 0.0;\n", LIGHT_DIR_PARAMS(lightsName, index));
|
||||||
// attn*attn may overflow
|
// attn*attn may overflow
|
||||||
object.Write("attn = max(0.0, " LIGHT_COSATT".x + " LIGHT_COSATT".y*attn + " LIGHT_COSATT".z*attn*attn) / (" LIGHT_DISTATT".x + " LIGHT_DISTATT".y*attn + " LIGHT_DISTATT".z*attn*attn);\n",
|
object.Write("attn = max(0.0, " LIGHT_COSATT".x + " LIGHT_COSATT".y*attn + " LIGHT_COSATT".z*attn*attn) / (" LIGHT_DISTATT".x + " LIGHT_DISTATT".y*attn + " LIGHT_DISTATT".z*attn*attn);\n",
|
||||||
LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index),
|
LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index),
|
||||||
LIGHT_DISTATT_PARAMS(lightsName, index), LIGHT_DISTATT_PARAMS(lightsName, index), LIGHT_DISTATT_PARAMS(lightsName, index));
|
LIGHT_DISTATT_PARAMS(lightsName, index), LIGHT_DISTATT_PARAMS(lightsName, index), LIGHT_DISTATT_PARAMS(lightsName, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (chan.diffusefunc)
|
switch (chan.diffusefunc)
|
||||||
{
|
{
|
||||||
case LIGHTDIF_NONE:
|
case LIGHTDIF_NONE:
|
||||||
object.Write("lacc.%s += int%s(round(attn * float%s(" LIGHT_COL")));\n",
|
object.Write("lacc.%s += int%s(round(attn * float%s(" LIGHT_COL")));\n",
|
||||||
swizzle, swizzle_components,
|
swizzle, swizzle_components,
|
||||||
swizzle_components, LIGHT_COL_PARAMS(lightsColName, index, swizzle));
|
swizzle_components, LIGHT_COL_PARAMS(lightsColName, index, swizzle));
|
||||||
break;
|
break;
|
||||||
case LIGHTDIF_SIGN:
|
case LIGHTDIF_SIGN:
|
||||||
case LIGHTDIF_CLAMP:
|
case LIGHTDIF_CLAMP:
|
||||||
object.Write("lacc.%s += int%s(round(attn * %sdot(ldir, _norm0)) * float%s(" LIGHT_COL")));\n",
|
object.Write("lacc.%s += int%s(round(attn * %sdot(ldir, _norm0)) * float%s(" LIGHT_COL")));\n",
|
||||||
swizzle, swizzle_components,
|
swizzle, swizzle_components,
|
||||||
chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0," :"(",
|
chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0," :"(",
|
||||||
swizzle_components, LIGHT_COL_PARAMS(lightsColName, index, swizzle));
|
swizzle_components, LIGHT_COL_PARAMS(lightsColName, index, swizzle));
|
||||||
break;
|
break;
|
||||||
default: _assert_(0);
|
default: _assert_(0);
|
||||||
}
|
}
|
||||||
|
@ -205,16 +205,16 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
|||||||
|
|
||||||
// dot product for integer vectors
|
// dot product for integer vectors
|
||||||
out.Write("int idot(int3 x, int3 y)\n"
|
out.Write("int idot(int3 x, int3 y)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"\tint3 tmp = x * y;\n"
|
"\tint3 tmp = x * y;\n"
|
||||||
"\treturn tmp.x + tmp.y + tmp.z;\n"
|
"\treturn tmp.x + tmp.y + tmp.z;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
|
|
||||||
out.Write("int idot(int4 x, int4 y)\n"
|
out.Write("int idot(int4 x, int4 y)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"\tint4 tmp = x * y;\n"
|
"\tint4 tmp = x * y;\n"
|
||||||
"\treturn tmp.x + tmp.y + tmp.z + tmp.w;\n"
|
"\treturn tmp.x + tmp.y + tmp.z + tmp.w;\n"
|
||||||
"}\n\n");
|
"}\n\n");
|
||||||
|
|
||||||
if (ApiType == API_OPENGL)
|
if (ApiType == API_OPENGL)
|
||||||
{
|
{
|
||||||
@ -339,11 +339,11 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
|||||||
}
|
}
|
||||||
|
|
||||||
out.Write("\tint4 c0 = " I_COLORS"[1], c1 = " I_COLORS"[2], c2 = " I_COLORS"[3], prev = " I_COLORS"[0];\n"
|
out.Write("\tint4 c0 = " I_COLORS"[1], c1 = " I_COLORS"[2], c2 = " I_COLORS"[3], prev = " I_COLORS"[0];\n"
|
||||||
"\tint4 rastemp = int4(0, 0, 0, 0), textemp = int4(0, 0, 0, 0), konsttemp = int4(0, 0, 0, 0);\n"
|
"\tint4 rastemp = int4(0, 0, 0, 0), textemp = int4(0, 0, 0, 0), konsttemp = int4(0, 0, 0, 0);\n"
|
||||||
"\tint3 comp16 = int3(1, 256, 0), comp24 = int3(1, 256, 256*256);\n"
|
"\tint3 comp16 = int3(1, 256, 0), comp24 = int3(1, 256, 256*256);\n"
|
||||||
"\tint alphabump=0;\n"
|
"\tint alphabump=0;\n"
|
||||||
"\tint3 tevcoord=int3(0, 0, 0);\n"
|
"\tint3 tevcoord=int3(0, 0, 0);\n"
|
||||||
"\tint2 wrappedcoord=int2(0,0), tempcoord=int2(0,0);\n\n");
|
"\tint2 wrappedcoord=int2(0,0), tempcoord=int2(0,0);\n\n");
|
||||||
|
|
||||||
if (ApiType == API_OPENGL)
|
if (ApiType == API_OPENGL)
|
||||||
{
|
{
|
||||||
@ -815,7 +815,7 @@ static inline void WriteStage(T& out, pixel_shader_uid_data& uid_data, int n, AP
|
|||||||
int mode = (cc.shift<<1)|cc.op;
|
int mode = (cc.shift<<1)|cc.op;
|
||||||
out.Write(" %s + ", tevCInputTable[cc.d]);
|
out.Write(" %s + ", tevCInputTable[cc.d]);
|
||||||
out.Write(function_table[mode], tevCInputTable[cc.a],
|
out.Write(function_table[mode], tevCInputTable[cc.a],
|
||||||
tevCInputTable[cc.b], tevCInputTable[cc.c]);
|
tevCInputTable[cc.b], tevCInputTable[cc.c]);
|
||||||
}
|
}
|
||||||
if (cc.clamp)
|
if (cc.clamp)
|
||||||
out.Write(", int3(0,0,0), int3(255,255,255))");
|
out.Write(", int3(0,0,0), int3(255,255,255))");
|
||||||
|
Loading…
Reference in New Issue
Block a user