Change a bunch of reference function arguments to pointers.

Per the coding style and sanity.
This commit is contained in:
comex
2014-10-02 02:20:46 -04:00
parent c98a3f62be
commit 7f6284c2fc
15 changed files with 333 additions and 330 deletions

View File

@ -113,10 +113,9 @@ namespace Clipper
return cmask;
}
static inline void AddInterpolatedVertex(float t, int out, int in, int& numVertices)
static inline void AddInterpolatedVertex(float t, int out, int in, int* numVertices)
{
Vertices[numVertices]->Lerp(t, Vertices[out], Vertices[in]);
numVertices++;
Vertices[(*numVertices)++]->Lerp(t, Vertices[out], Vertices[in]);
}
#define DIFFERENT_SIGNS(x,y) ((x <= 0 && y > 0) || (x > 0 && y <= 0))
@ -142,10 +141,10 @@ namespace Clipper
if (DIFFERENT_SIGNS(dp, dpPrev)) { \
if (dp < 0) { \
float t = dp / (dp - dpPrev); \
AddInterpolatedVertex(t, idx, idxPrev, numVertices); \
AddInterpolatedVertex(t, idx, idxPrev, &numVertices); \
} else { \
float t = dpPrev / (dpPrev - dp); \
AddInterpolatedVertex(t, idxPrev, idx, numVertices); \
AddInterpolatedVertex(t, idxPrev, idx, &numVertices); \
} \
outlist[outcount++] = numVertices - 1; \
} \
@ -187,7 +186,7 @@ namespace Clipper
} \
}
static void ClipTriangle(int *indices, int &numIndices)
static void ClipTriangle(int *indices, int* numIndices)
{
int mask = 0;
@ -229,9 +228,9 @@ namespace Clipper
indices[2] = inlist[2];
for (int j = 3; j < n; ++j)
{
indices[numIndices++] = inlist[0];
indices[numIndices++] = inlist[j - 1];
indices[numIndices++] = inlist[j];
indices[(*numIndices)++] = inlist[0];
indices[(*numIndices)++] = inlist[j - 1];
indices[(*numIndices)++] = inlist[j];
}
}
}
@ -276,13 +275,13 @@ namespace Clipper
if (clip_mask[0])
{
indices[0] = numVertices;
AddInterpolatedVertex(t0, 0, 1, numVertices);
AddInterpolatedVertex(t0, 0, 1, &numVertices);
}
if (clip_mask[1])
{
indices[1] = numVertices;
AddInterpolatedVertex(t1, 1, 0, numVertices);
AddInterpolatedVertex(t1, 1, 0, &numVertices);
}
}
@ -315,7 +314,7 @@ namespace Clipper
Vertices[2] = v2;
}
ClipTriangle(indices, numIndices);
ClipTriangle(indices, &numIndices);
for (int i = 0; i+3 <= numIndices; i+=3)
{

View File

@ -334,57 +334,57 @@ namespace EfbInterface
}
}
static void LogicBlend(u32 srcClr, u32 &dstClr, BlendMode::LogicOp op)
static void LogicBlend(u32 srcClr, u32* dstClr, BlendMode::LogicOp op)
{
switch (op)
{
case BlendMode::CLEAR:
dstClr = 0;
*dstClr = 0;
break;
case BlendMode::AND:
dstClr = srcClr & dstClr;
*dstClr = srcClr & *dstClr;
break;
case BlendMode::AND_REVERSE:
dstClr = srcClr & (~dstClr);
*dstClr = srcClr & (~*dstClr);
break;
case BlendMode::COPY:
dstClr = srcClr;
*dstClr = srcClr;
break;
case BlendMode::AND_INVERTED:
dstClr = (~srcClr) & dstClr;
*dstClr = (~srcClr) & *dstClr;
break;
case BlendMode::NOOP:
// Do nothing
break;
case BlendMode::XOR:
dstClr = srcClr ^ dstClr;
*dstClr = srcClr ^ *dstClr;
break;
case BlendMode::OR:
dstClr = srcClr | dstClr;
*dstClr = srcClr | *dstClr;
break;
case BlendMode::NOR:
dstClr = ~(srcClr | dstClr);
*dstClr = ~(srcClr | *dstClr);
break;
case BlendMode::EQUIV:
dstClr = ~(srcClr ^ dstClr);
*dstClr = ~(srcClr ^ *dstClr);
break;
case BlendMode::INVERT:
dstClr = ~dstClr;
*dstClr = ~*dstClr;
break;
case BlendMode::OR_REVERSE:
dstClr = srcClr | (~dstClr);
*dstClr = srcClr | (~*dstClr);
break;
case BlendMode::COPY_INVERTED:
dstClr = ~srcClr;
*dstClr = ~srcClr;
break;
case BlendMode::OR_INVERTED:
dstClr = (~srcClr) | dstClr;
*dstClr = (~srcClr) | *dstClr;
break;
case BlendMode::NAND:
dstClr = ~(srcClr & dstClr);
*dstClr = ~(srcClr & *dstClr);
break;
case BlendMode::SET:
dstClr = 0xffffffff;
*dstClr = 0xffffffff;
break;
}
}
@ -416,7 +416,7 @@ namespace EfbInterface
}
else if (bpmem.blendmode.logicopenable)
{
LogicBlend(*((u32*)color), dstClr, bpmem.blendmode.logicmode);
LogicBlend(*((u32*)color), &dstClr, bpmem.blendmode.logicmode);
}
else
{

View File

@ -210,7 +210,7 @@ static void InitSlope(Slope *slope, float f1, float f2, float f3, float DX31, fl
slope->f0 = f1;
}
static inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord)
static inline void CalculateLOD(s32* lodp, bool* linear, u32 texmap, u32 texcoord)
{
FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1];
u8 subTexmap = texmap & 3;
@ -240,20 +240,21 @@ static inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord
}
// get LOD in s28.4
lod = FixedLog2(std::max(sDelta, tDelta));
s32 lod = FixedLog2(std::max(sDelta, tDelta));
// bias is s2.5
int bias = tm0.lod_bias;
bias >>= 1;
lod += bias;
linear = ((lod > 0 && (tm0.min_filter & 4)) || (lod <= 0 && tm0.mag_filter));
*linear = ((lod > 0 && (tm0.min_filter & 4)) || (lod <= 0 && tm0.mag_filter));
// order of checks matters
// should be:
// if lod > max then max
// else if lod < min then min
lod = CLAMP(lod, (s32)tm1.min_lod, (s32)tm1.max_lod);
*lodp = lod;
}
static void BuildBlock(s32 blockX, s32 blockY)
@ -295,7 +296,7 @@ static void BuildBlock(s32 blockX, s32 blockY)
u32 texcoord = indref & 3;
indref >>= 3;
CalculateLOD(rasterBlock.IndirectLod[i], rasterBlock.IndirectLinear[i], texmap, texcoord);
CalculateLOD(&rasterBlock.IndirectLod[i], &rasterBlock.IndirectLinear[i], texmap, texcoord);
}
for (unsigned int i = 0; i <= bpmem.genMode.numtevstages; i++)
@ -307,7 +308,7 @@ static void BuildBlock(s32 blockX, s32 blockY)
u32 texmap = order.getTexMap(stageOdd);
u32 texcoord = order.getTexCoord(stageOdd);
CalculateLOD(rasterBlock.TextureLod[i], rasterBlock.TextureLinear[i], texmap, texcoord);
CalculateLOD(&rasterBlock.TextureLod[i], &rasterBlock.TextureLinear[i], texmap, texcoord);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -16,8 +16,9 @@
namespace TextureSampler
{
static inline void WrapCoord(int &coord, int wrapMode, int imageSize)
static inline void WrapCoord(int* coordp, int wrapMode, int imageSize)
{
int coord = *coordp;
switch (wrapMode)
{
case 0: // clamp
@ -37,6 +38,7 @@ static inline void WrapCoord(int &coord, int wrapMode, int imageSize)
}
break;
}
*coordp = coord;
}
static inline void SetTexel(u8 *inTexel, u32 *outTexel, u32 fract)
@ -177,10 +179,10 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample)
u8 sampledTex[4];
u32 texel[4];
WrapCoord(imageS, tm0.wrap_s, imageWidth);
WrapCoord(imageT, tm0.wrap_t, imageHeight);
WrapCoord(imageSPlus1, tm0.wrap_s, imageWidth);
WrapCoord(imageTPlus1, tm0.wrap_t, imageHeight);
WrapCoord(&imageS, tm0.wrap_s, imageWidth);
WrapCoord(&imageT, tm0.wrap_t, imageHeight);
WrapCoord(&imageSPlus1, tm0.wrap_s, imageWidth);
WrapCoord(&imageTPlus1, tm0.wrap_t, imageHeight);
if (!(ti0.format == GX_TF_RGBA8 && texUnit.texImage1[subTexmap].image_type))
{
@ -223,8 +225,8 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample)
int imageT = t >> 7;
// nearest neighbor sampling
WrapCoord(imageS, tm0.wrap_s, imageWidth);
WrapCoord(imageT, tm0.wrap_t, imageHeight);
WrapCoord(&imageS, tm0.wrap_s, imageWidth);
WrapCoord(&imageT, tm0.wrap_t, imageHeight);
if (!(ti0.format == GX_TF_RGBA8 && texUnit.texImage1[subTexmap].image_type))
TexDecoder_DecodeTexel(sample, imageSrc, imageS, imageT, imageWidth, ti0.format, tlut, tlutfmt);