From b05065732236200ed3dfee3f13ad3dc70d6c713e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Aug 2014 20:48:28 -0400 Subject: [PATCH 1/9] Software: Make constants char_width and char_height private in RasterFont --- Source/Core/VideoBackends/Software/RasterFont.cpp | 8 ++++---- Source/Core/VideoBackends/Software/RasterFont.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Core/VideoBackends/Software/RasterFont.cpp b/Source/Core/VideoBackends/Software/RasterFont.cpp index 7876ac458513..8aefd89599fc 100644 --- a/Source/Core/VideoBackends/Software/RasterFont.cpp +++ b/Source/Core/VideoBackends/Software/RasterFont.cpp @@ -161,7 +161,7 @@ void RasterFont::printString(const char *s, double x, double y, double z) void RasterFont::printCenteredString(const char *s, double y, int screen_width, double z) { int length = (int)strlen(s); - int x = (int)(screen_width/2.0 - (length/2.0)*char_width); + int x = (int)(screen_width/2.0 - (length/2.0) * CHAR_WIDTH); printString(s, x, y, z); } @@ -177,7 +177,7 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta { *t = 0; printString(temp, x, y, z); - y -= char_height * 2.0f / bbHeight; + y -= CHAR_HEIGHT * 2.0f / bbHeight; x = start_x; t = temp; } @@ -187,12 +187,12 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta } else if (*text == '\t') { - //todo: add tabs every something like 4*char_width + //todo: add tabs every something like 4 * CHAR_WIDTH *t = 0; int cpos = (int)strlen(temp); int newpos = (cpos + 4) & (~3); printString(temp, x, y, z); - x = start_x + (char_width*newpos) * 2.0f / bbWidth; + x = start_x + (CHAR_WIDTH * newpos) * 2.0f / bbWidth; t = temp; *t++ = ' '; } diff --git a/Source/Core/VideoBackends/Software/RasterFont.h b/Source/Core/VideoBackends/Software/RasterFont.h index 009b5aecc750..e922c4bb3fdb 100644 --- a/Source/Core/VideoBackends/Software/RasterFont.h +++ b/Source/Core/VideoBackends/Software/RasterFont.h @@ -11,17 +11,17 @@ class RasterFont ~RasterFont(void); static int debug; - // some useful constants - enum {char_width = 10}; - enum {char_height = 15}; - // and the happy helper functions void printString(const char *s, double x, double y, double z=0.0); void printCenteredString(const char *s, double y, int screen_width, double z=0.0); void printMultilineText(const char *text, double x, double y, double z, int bbWidth, int bbHeight); + private: int fontOffset; char *temp_buffer; - enum {TEMP_BUFFER_SIZE = 64 * 1024}; + + static const int TEMP_BUFFER_SIZE = 64 * 1024; + static const int CHAR_WIDTH = 10; + static const int CHAR_HEIGHT = 15; }; From b95d9b43dee5fa5d1e4f658b1cd3328261fd5c8b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Aug 2014 20:51:10 -0400 Subject: [PATCH 2/9] Software: Make an enum into a static constant in DebugUtil.cpp --- .../Core/VideoBackends/Software/DebugUtil.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Core/VideoBackends/Software/DebugUtil.cpp b/Source/Core/VideoBackends/Software/DebugUtil.cpp index c1a7980aa21a..0a37d50e8404 100644 --- a/Source/Core/VideoBackends/Software/DebugUtil.cpp +++ b/Source/Core/VideoBackends/Software/DebugUtil.cpp @@ -25,18 +25,18 @@ namespace DebugUtil static bool drawingHwTriangles = false; -enum { NumObjectBuffers = 40}; +static const int NUM_OBJECT_BUFFERS = 40; -static u32 *ObjectBuffer[NumObjectBuffers]; -static u32 TempBuffer[NumObjectBuffers]; +static u32 *ObjectBuffer[NUM_OBJECT_BUFFERS]; +static u32 TempBuffer[NUM_OBJECT_BUFFERS]; -static bool DrawnToBuffer[NumObjectBuffers]; -static const char* ObjectBufferName[NumObjectBuffers]; -static int BufferBase[NumObjectBuffers]; +static bool DrawnToBuffer[NUM_OBJECT_BUFFERS]; +static const char* ObjectBufferName[NUM_OBJECT_BUFFERS]; +static int BufferBase[NUM_OBJECT_BUFFERS]; void Init() { - for (int i = 0; i < NumObjectBuffers; i++) + for (int i = 0; i < NUM_OBJECT_BUFFERS; i++) { ObjectBuffer[i] = new u32[EFB_WIDTH*EFB_HEIGHT](); DrawnToBuffer[i] = false; @@ -47,7 +47,7 @@ void Init() void Shutdown() { - for (int i = 0; i < NumObjectBuffers; i++) + for (int i = 0; i < NUM_OBJECT_BUFFERS; i++) { delete[] ObjectBuffer[i]; } @@ -229,7 +229,7 @@ void OnObjectEnd() drawingHwTriangles = false; } - for (int i = 0; i < NumObjectBuffers; i++) + for (int i = 0; i < NUM_OBJECT_BUFFERS; i++) { if (DrawnToBuffer[i]) { From 6625d9cba5604d29454a6e3b540916a451cf1bf7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Aug 2014 21:18:38 -0400 Subject: [PATCH 3/9] Software: Fix various brace styling errors --- .../Core/VideoBackends/Software/Clipper.cpp | 20 +++++++++++++------ .../VideoBackends/Software/EfbInterface.cpp | 12 +++++++---- .../VideoBackends/Software/EfbInterface.h | 8 +++++++- .../Software/NativeVertexFormat.h | 8 +++++++- .../VideoBackends/Software/SWRenderer.cpp | 12 +++++++---- Source/Core/VideoBackends/Software/Tev.cpp | 4 +++- Source/Core/VideoBackends/Software/Tev.h | 10 ++++++++-- .../VideoBackends/Software/TextureSampler.h | 8 +++++++- 8 files changed, 62 insertions(+), 20 deletions(-) diff --git a/Source/Core/VideoBackends/Software/Clipper.cpp b/Source/Core/VideoBackends/Software/Clipper.cpp index 5e0398f54012..1efec0c99548 100644 --- a/Source/Core/VideoBackends/Software/Clipper.cpp +++ b/Source/Core/VideoBackends/Software/Clipper.cpp @@ -45,7 +45,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Clipper { - enum { NUM_CLIPPED_VERTICES = 33, NUM_INDICES = NUM_CLIPPED_VERTICES + 3 }; + enum + { + NUM_CLIPPED_VERTICES = 33, + NUM_INDICES = NUM_CLIPPED_VERTICES + 3 + }; static float m_ViewOffset[2]; @@ -72,7 +76,8 @@ namespace Clipper } - enum { + enum + { SKIP_FLAG = -1, CLIP_POS_X_BIT = 0x01, CLIP_NEG_X_BIT = 0x02, @@ -209,7 +214,8 @@ namespace Clipper indices[0] = inlist[0]; indices[1] = inlist[1]; indices[2] = inlist[2]; - for (int j = 3; j < n; ++j) { + for (int j = 3; j < n; ++j) + { indices[numIndices++] = inlist[0]; indices[numIndices++] = inlist[j - 1]; indices[numIndices++] = inlist[j]; @@ -276,9 +282,11 @@ namespace Clipper if (!CullTest(v0, v1, v2, backface)) return; - int indices[NUM_INDICES] = { 0, 1, 2, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, - SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, - SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG }; + int indices[NUM_INDICES] = { + 0, 1, 2, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, + SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, + SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG + }; int numIndices = 3; if (backface) diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index bf405860bf35..cc0469193a91 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -498,7 +498,8 @@ namespace EfbInterface return &efb[GetColorOffset(x, y)]; } - void CopyToXFB(yuv422_packed* xfb_in_ram, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, float Gamma) { + void CopyToXFB(yuv422_packed* xfb_in_ram, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, float Gamma) + { // FIXME: We should do Gamma correction if (!xfb_in_ram) @@ -512,7 +513,8 @@ namespace EfbInterface // this assumes copies will always start on an even (YU) pixel and the // copy always has an even width, which might not be true. - if (left & 1 || right & 1) { + if (left & 1 || right & 1) + { WARN_LOG(VIDEO, "Trying to copy XFB to from unaligned EFB source"); // this will show up as wrongly encoded } @@ -557,8 +559,10 @@ namespace EfbInterface } // Like CopyToXFB, but we copy directly into the opengl colour texture without going via GameCube main memory or doing a yuyv conversion - void BypassXFB(u8* texture, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, float Gamma) { - if (fbWidth*fbHeight > MAX_XFB_WIDTH*MAX_XFB_HEIGHT) { + void BypassXFB(u8* texture, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, float Gamma) + { + if (fbWidth*fbHeight > MAX_XFB_WIDTH*MAX_XFB_HEIGHT) + { ERROR_LOG(VIDEO, "Framebuffer is too large: %ix%i", fbWidth, fbHeight); return; } diff --git a/Source/Core/VideoBackends/Software/EfbInterface.h b/Source/Core/VideoBackends/Software/EfbInterface.h index d09f71333c3f..c04eee3e7e2c 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.h +++ b/Source/Core/VideoBackends/Software/EfbInterface.h @@ -27,7 +27,13 @@ namespace EfbInterface s8 V; }; - enum { ALP_C, BLU_C, GRN_C, RED_C }; + enum + { + ALP_C, + BLU_C, + GRN_C, + RED_C + }; // color order is ABGR in order to emulate RGBA on little-endian hardware diff --git a/Source/Core/VideoBackends/Software/NativeVertexFormat.h b/Source/Core/VideoBackends/Software/NativeVertexFormat.h index fe6d336609e6..ad71e2caf9f7 100644 --- a/Source/Core/VideoBackends/Software/NativeVertexFormat.h +++ b/Source/Core/VideoBackends/Software/NativeVertexFormat.h @@ -37,7 +37,13 @@ struct InputVertexData struct OutputVertexData { // components in color channels - enum { RED_C, GRN_C, BLU_C, ALP_C }; + enum + { + RED_C, + GRN_C, + BLU_C, + ALP_C + }; Vec3 mvPosition; Vec4 projectedPosition; diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index c94e19a31f1c..e098c5a2f42f 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -153,21 +153,25 @@ void SWRenderer::DrawDebugText() SWRenderer::RenderText(debugtext.c_str(), 20, 20, 0xFFFFFF00); } -u8* SWRenderer::getNextColorTexture() { +u8* SWRenderer::getNextColorTexture() +{ return s_xfbColorTexture[!s_currentColorTexture]; } -u8* SWRenderer::getCurrentColorTexture() { +u8* SWRenderer::getCurrentColorTexture() +{ return s_xfbColorTexture[s_currentColorTexture]; } -void SWRenderer::swapColorTexture() { +void SWRenderer::swapColorTexture() +{ s_currentColorTexture = !s_currentColorTexture; } void SWRenderer::UpdateColorTexture(EfbInterface::yuv422_packed *xfb, u32 fbWidth, u32 fbHeight) { - if (fbWidth*fbHeight > MAX_XFB_WIDTH*MAX_XFB_HEIGHT) { + if (fbWidth*fbHeight > MAX_XFB_WIDTH*MAX_XFB_HEIGHT) + { ERROR_LOG(VIDEO, "Framebuffer is too large: %ix%i", fbWidth, fbHeight); return; } diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index 33fcca219c20..8dd048f53b92 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -336,7 +336,8 @@ void Tev::DrawAlphaCompare(TevStageCombiner::AlphaCombiner& ac, const InputRegTy static bool AlphaCompare(int alpha, int ref, AlphaTest::CompareMode comp) { - switch (comp) { + switch (comp) + { case AlphaTest::ALWAYS: return true; case AlphaTest::NEVER: return false; case AlphaTest::LEQUAL: return alpha <= ref; @@ -346,6 +347,7 @@ static bool AlphaCompare(int alpha, int ref, AlphaTest::CompareMode comp) case AlphaTest::EQUAL: return alpha == ref; case AlphaTest::NEQUAL: return alpha != ref; } + return true; } diff --git a/Source/Core/VideoBackends/Software/Tev.h b/Source/Core/VideoBackends/Software/Tev.h index 7ecb2852f051..11a8539cce56 100644 --- a/Source/Core/VideoBackends/Software/Tev.h +++ b/Source/Core/VideoBackends/Software/Tev.h @@ -77,13 +77,19 @@ class Tev s32 TextureLod[16]; bool TextureLinear[16]; + enum + { + ALP_C, + BLU_C, + GRN_C, + RED_C + }; + void Init(); void Draw(); void SetRegColor(int reg, int comp, bool konst, s16 color); - enum { ALP_C, BLU_C, GRN_C, RED_C }; - void DoState(PointerWrap &p); }; diff --git a/Source/Core/VideoBackends/Software/TextureSampler.h b/Source/Core/VideoBackends/Software/TextureSampler.h index d821ace25e31..97a916c8c0c6 100644 --- a/Source/Core/VideoBackends/Software/TextureSampler.h +++ b/Source/Core/VideoBackends/Software/TextureSampler.h @@ -12,5 +12,11 @@ namespace TextureSampler void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample); - enum { RED_SMP, GRN_SMP, BLU_SMP, ALP_SMP }; + enum + { + RED_SMP, + GRN_SMP, + BLU_SMP, + ALP_SMP + }; } From 2918f46d8bcc033a0d89dc46bbdeb4fa893b3ed2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Aug 2014 21:34:34 -0400 Subject: [PATCH 4/9] Software: Fix the formatting and function casing in Vec3.h --- .../VideoBackends/Software/TransformUnit.cpp | 20 +-- Source/Core/VideoBackends/Software/Vec3.h | 156 ++++++++++++------ 2 files changed, 119 insertions(+), 57 deletions(-) diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index e0907d75433e..bb2b50ad41ba 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -95,12 +95,12 @@ void TransformNormal(const InputVertexData *src, bool nbt, OutputVertexData *dst MultiplyVec3Mat33(src->normal[0], mat, dst->normal[0]); MultiplyVec3Mat33(src->normal[1], mat, dst->normal[1]); MultiplyVec3Mat33(src->normal[2], mat, dst->normal[2]); - dst->normal[0].normalize(); + dst->normal[0].Normalize(); } else { MultiplyVec3Mat33(src->normal[0], mat, dst->normal[0]); - dst->normal[0].normalize(); + dst->normal[0].Normalize(); } } @@ -170,7 +170,7 @@ static void TransformTexCoordRegular(const TexMtxInfo &texinfo, int coordNum, bo else { if (postInfo.normalize) - tempCoord = dst->normalized(); + tempCoord = dst->Normalized(); else tempCoord = *dst; @@ -222,14 +222,14 @@ static void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const L break; case LIGHTDIF_SIGN: { - Vec3 ldir = (light->pos - pos).normalized(); + Vec3 ldir = (light->pos - pos).Normalized(); float diffuse = ldir * normal; AddScaledIntegerColor(light->color, diffuse, lightCol); } break; case LIGHTDIF_CLAMP: { - Vec3 ldir = (light->pos - pos).normalized(); + Vec3 ldir = (light->pos - pos).Normalized(); float diffuse = std::max(0.0f, ldir * normal); AddScaledIntegerColor(light->color, diffuse, lightCol); } @@ -245,7 +245,7 @@ static void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const L if (chan.attnfunc == 3) // spot { - float dist2 = ldir.length2(); + float dist2 = ldir.Length2(); float dist = sqrtf(dist2); ldir = ldir / dist; attn = std::max(0.0f, ldir * light->dir); @@ -307,14 +307,14 @@ static void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const L break; case LIGHTDIF_SIGN: { - Vec3 ldir = (light->pos - pos).normalized(); + Vec3 ldir = (light->pos - pos).Normalized(); float diffuse = ldir * normal; lightCol += light->color[0] * diffuse; } break; case LIGHTDIF_CLAMP: { - Vec3 ldir = (light->pos - pos).normalized(); + Vec3 ldir = (light->pos - pos).Normalized(); float diffuse = std::max(0.0f, ldir * normal); lightCol += light->color[0] * diffuse; } @@ -329,7 +329,7 @@ static void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const L if (chan.attnfunc == 3) // spot { - float dist2 = ldir.length2(); + float dist2 = ldir.Length2(); float dist = sqrtf(dist2); ldir = ldir / dist; attn = std::max(0.0f, ldir * light->dir); @@ -478,7 +478,7 @@ void TransformTexCoord(const InputVertexData *src, OutputVertexData *dst, bool s { const LightPointer *light = (const LightPointer*)&xfmem.lights[texinfo.embosslightshift]; - Vec3 ldir = (light->pos - dst->mvPosition).normalized(); + Vec3 ldir = (light->pos - dst->mvPosition).Normalized(); float d1 = ldir * dst->normal[1]; float d2 = ldir * dst->normal[2]; diff --git a/Source/Core/VideoBackends/Software/Vec3.h b/Source/Core/VideoBackends/Software/Vec3.h index 192355cf7d7c..af1bbfd91e75 100644 --- a/Source/Core/VideoBackends/Software/Vec3.h +++ b/Source/Core/VideoBackends/Software/Vec3.h @@ -12,93 +12,155 @@ class Vec3 { public: - float x,y,z; - Vec3() { } - explicit Vec3(float f) {x=y=z=f;} - explicit Vec3(const float *f) {x=f[0]; y=f[1]; z=f[2];} - Vec3(const float _x, const float _y, const float _z) { - x=_x; y=_y; z=_z; + float x, y, z; + + Vec3() + { } - void set(const float _x, const float _y, const float _z) { - x=_x; y=_y; z=_z; + + explicit Vec3(float f) + { + x = y = z = f; } - Vec3 operator + (const Vec3 &other) const { - return Vec3(x+other.x, y+other.y, z+other.z); + + explicit Vec3(const float *f) + { + x = f[0]; + y = f[1]; + z = f[2]; } - void operator += (const Vec3 &other) { - x+=other.x; y+=other.y; z+=other.z; + + Vec3(const float _x, const float _y, const float _z) + { + x = _x; + y = _y; + z = _z; } - Vec3 operator -(const Vec3 &v) const { - return Vec3(x-v.x,y-v.y,z-v.z); + + void set(const float _x, const float _y, const float _z) + { + x = _x; + y = _y; + z = _z; } - void operator -= (const Vec3 &other) + + Vec3 operator+(const Vec3 &other) const { - x-=other.x; y-=other.y; z-=other.z; + return Vec3(x + other.x, y + other.y, z + other.z); } - Vec3 operator -() const { - return Vec3(-x,-y,-z); + + void operator+=(const Vec3 &other) + { + x += other.x; + y += other.y; + z += other.z; + } + + Vec3 operator-(const Vec3 &v) const + { + return Vec3(x - v.x, y - v.y, z - v.z); } - Vec3 operator * (const float f) const { - return Vec3(x*f,y*f,z*f); + void operator-=(const Vec3 &other) + { + x -= other.x; + y -= other.y; + z -= other.z; + } + + Vec3 operator-() const + { + return Vec3(-x, -y, -z); + } + + Vec3 operator*(const float f) const + { + return Vec3(x * f, y * f, z * f); } - Vec3 operator / (const float f) const { - float invf = (1.0f/f); - return Vec3(x*invf,y*invf,z*invf); + + Vec3 operator/(const float f) const + { + float invf = (1.0f / f); + return Vec3(x * invf, y * invf, z * invf); } - void operator /= (const float f) + + void operator/=(const float f) { *this = *this / f; } - float operator * (const Vec3 &other) const { - return x*other.x + y*other.y + z*other.z; + + float operator*(const Vec3 &other) const + { + return (x * other.x) + + (y * other.y) + + (z * other.z); } - void operator *= (const float f) { + + void operator*=(const float f) + { *this = *this * f; } - Vec3 scaled_by(const Vec3 &other) const { - return Vec3(x*other.x, y*other.y, z*other.z); + + Vec3 ScaledBy(const Vec3 &other) const + { + return Vec3(x * other.x, y * other.y, z * other.z); } - Vec3 operator %(const Vec3 &v) const { - return Vec3(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x); + Vec3 operator%(const Vec3 &v) const + { + return Vec3((y * v.z) - (z * v.y), + (z * v.x) - (x * v.z), + (x * v.y) - (y * v.x)); } - float length2() const { - return x*x+y*y+z*z; + + float Length2() const + { + return (x * x) + (y * y) + (z * z); } - float length() const { - return sqrtf(length2()); + + float Length() const + { + return sqrtf(Length2()); } - float distance2_to(Vec3 &other) + + float Distance2To(Vec3 &other) { - return (other-(*this)).length2(); + return (other - (*this)).Length2(); } - Vec3 normalized() const { - return (*this) / length(); + Vec3 Normalized() const + { + return (*this) / Length(); } - void normalize() { - (*this) /= length(); + + void Normalize() + { + (*this) /= Length(); } - float &operator [] (int i) + + float &operator[](int i) { return *((&x) + i); } - float operator [] (const int i) const + + float operator[](const int i) const { return *((&x) + i); } - bool operator == (const Vec3 &other) const + + bool operator==(const Vec3 &other) const { - if (x==other.x && y==other.y && z==other.z) + if (x == other.x && y == other.y && z == other.z) return true; else return false; } - void setZero() + + void SetZero() { - memset((void *)this,0,sizeof(float)*3); + memset((void*)this, 0, sizeof(float) * 3); } + void DoState(PointerWrap &p) { p.Do(x); From 568bdec5983a419dd06e9e497ec43d04677bc2df Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Aug 2014 21:41:04 -0400 Subject: [PATCH 5/9] Software: Fix function casing in TextureEncoder --- .../VideoBackends/Software/TextureEncoder.cpp | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/Source/Core/VideoBackends/Software/TextureEncoder.cpp b/Source/Core/VideoBackends/Software/TextureEncoder.cpp index 8351d39a2930..a1b567048063 100644 --- a/Source/Core/VideoBackends/Software/TextureEncoder.cpp +++ b/Source/Core/VideoBackends/Software/TextureEncoder.cpp @@ -40,7 +40,7 @@ inline u8 RGB8_to_I(u8 r, u8 g, u8 b) // box filter sampling averages 4 samples with the source texel being the top left of the box // components are scaled to the range 0-255 after all samples are taken -inline void boxfilterRGBA_to_RGBA8(u8 *src, u8 &r, u8 &g, u8 &b, u8 &a) +inline void BoxfilterRGBA_to_RGBA8(u8 *src, u8 &r, u8 &g, u8 &b, u8 &a) { u16 r16 = 0, g16 = 0, b16 = 0, a16 = 0; @@ -66,7 +66,7 @@ inline void boxfilterRGBA_to_RGBA8(u8 *src, u8 &r, u8 &g, u8 &b, u8 &a) a = a16 + (a16 >> 6); } -inline void boxfilterRGBA_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) +inline void BoxfilterRGBA_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) { u16 r16 = 0, g16 = 0, b16 = 0; @@ -90,7 +90,7 @@ inline void boxfilterRGBA_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) b = b16 + (b16 >> 6); } -inline void boxfilterRGBA_to_x8(u8 *src, u8 &x8, int shift) +inline void BoxfilterRGBA_to_x8(u8 *src, u8 &x8, int shift) { u16 x16 = 0; @@ -110,7 +110,7 @@ inline void boxfilterRGBA_to_x8(u8 *src, u8 &x8, int shift) x8 = x16 + (x16 >> 6); } -inline void boxfilterRGBA_to_xx8(u8 *src, u8 &x1, u8 &x2, int shift1, int shift2) +inline void BoxfilterRGBA_to_xx8(u8 *src, u8 &x1, u8 &x2, int shift1, int shift2) { u16 x16_1 = 0; u16 x16_2 = 0; @@ -133,7 +133,7 @@ inline void boxfilterRGBA_to_xx8(u8 *src, u8 &x1, u8 &x2, int shift1, int shift2 x2 = x16_2 + (x16_2 >> 6); } -inline void boxfilterRGB_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) +inline void BoxfilterRGB_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) { u16 r16 = 0, g16 = 0, b16 = 0; @@ -155,7 +155,7 @@ inline void boxfilterRGB_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) b = b16 >> 2; } -inline void boxfilterRGB_to_x8(u8 *src, u8 &x8, int comp) +inline void BoxfilterRGB_to_x8(u8 *src, u8 &x8, int comp) { u16 x16 = 0; @@ -174,7 +174,7 @@ inline void boxfilterRGB_to_x8(u8 *src, u8 &x8, int comp) x8 = x16 >> 2; } -inline void boxfilterRGB_to_xx8(u8 *src, u8 &x1, u8 &x2, int comp1, int comp2) +inline void BoxfilterRGB_to_xx8(u8 *src, u8 &x1, u8 &x2, int comp1, int comp2) { u16 x16_1 = 0; u16 x16_2 = 0; @@ -506,11 +506,11 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) sBlkSize /= 2; ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_RGB8(src, r, g, b); + BoxfilterRGBA_to_RGB8(src, r, g, b); src += readStride; *dst = RGB8_to_I(r, g, b) & 0xf0; - boxfilterRGBA_to_RGB8(src, r, g, b); + BoxfilterRGBA_to_RGB8(src, r, g, b); src += readStride; *dst |= RGB8_to_I(r, g, b) >> 4; dst++; @@ -523,7 +523,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_RGB8(src, r, g, b); + BoxfilterRGBA_to_RGB8(src, r, g, b); src += readStride; *dst++ = RGB8_to_I(r, g, b); } @@ -535,7 +535,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_RGBA8(src, r, g, b, a); + BoxfilterRGBA_to_RGBA8(src, r, g, b, a); src += readStride; *dst++ = (a & 0xf0) | (RGB8_to_I(r, g, b) >> 4); } @@ -547,7 +547,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_RGBA8(src, r, g, b, a); + BoxfilterRGBA_to_RGBA8(src, r, g, b, a); src += readStride; *dst++ = a; *dst++ = RGB8_to_I(r, g, b); @@ -560,7 +560,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_RGB8(src, r, g, b); + BoxfilterRGBA_to_RGB8(src, r, g, b); src += readStride; u16 val = ((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | ((b >> 3) & 0x001e); @@ -575,7 +575,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_RGBA8(src, r, g, b, a); + BoxfilterRGBA_to_RGBA8(src, r, g, b, a); src += readStride; u16 val; @@ -595,7 +595,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_RGBA8(src, dst[1], dst[32], dst[33], dst[0]); + BoxfilterRGBA_to_RGBA8(src, dst[1], dst[32], dst[33], dst[0]); src += readStride; dst += 2; } @@ -608,11 +608,11 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) sBlkSize /= 2; ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_x8(src, r, 18); + BoxfilterRGBA_to_x8(src, r, 18); src += readStride; *dst = r & 0xf0; - boxfilterRGBA_to_x8(src, r, 18); + BoxfilterRGBA_to_x8(src, r, 18); src += readStride; *dst |= r >> 4; dst++; @@ -625,7 +625,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_xx8(src, r, a, 18, 0); + BoxfilterRGBA_to_xx8(src, r, a, 18, 0); src += readStride; *dst++ = (a & 0xf0) | (r >> 4); } @@ -637,7 +637,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_xx8(src, r, a, 18, 0); + BoxfilterRGBA_to_xx8(src, r, a, 18, 0); src += readStride; *dst++ = a; *dst++ = r; @@ -650,7 +650,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_x8(src, a, 0); + BoxfilterRGBA_to_x8(src, a, 0); *dst++ = a; src += readStride; } @@ -662,7 +662,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_x8(src, r, 18); + BoxfilterRGBA_to_x8(src, r, 18); *dst++ = r; src += readStride; } @@ -674,7 +674,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_x8(src, g, 12); + BoxfilterRGBA_to_x8(src, g, 12); *dst++ = g; src += readStride; } @@ -686,7 +686,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_x8(src, b, 6); + BoxfilterRGBA_to_x8(src, b, 6); *dst++ = b; src += readStride; } @@ -698,7 +698,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_xx8(src, r, g, 18, 12); + BoxfilterRGBA_to_xx8(src, r, g, 18, 12); src += readStride; *dst++ = g; *dst++ = r; @@ -711,7 +711,7 @@ static void EncodeRGBA6halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGBA_to_xx8(src, g, b, 12, 6); + BoxfilterRGBA_to_xx8(src, g, b, 12, 6); src += readStride; *dst++ = b; *dst++ = g; @@ -955,11 +955,11 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) sBlkSize /= 2; ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_RGB8(src, r, g, b); + BoxfilterRGB_to_RGB8(src, r, g, b); *dst = RGB8_to_I(r, g, b) & 0xf0; src += readStride; - boxfilterRGB_to_RGB8(src, r, g, b); + BoxfilterRGB_to_RGB8(src, r, g, b); *dst |= RGB8_to_I(r, g, b) >> 4; src += readStride; dst++; @@ -972,7 +972,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_RGB8(src, r, g, b); + BoxfilterRGB_to_RGB8(src, r, g, b); *dst++ = RGB8_to_I(r, g, b); src += readStride; } @@ -984,7 +984,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_RGB8(src, r, g, b); + BoxfilterRGB_to_RGB8(src, r, g, b); *dst++ = 0xf0 | (RGB8_to_I(r, g, b) >> 4); src += readStride; } @@ -996,7 +996,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_RGB8(src, r, g, b); + BoxfilterRGB_to_RGB8(src, r, g, b); *dst++ = 0xff; *dst++ = RGB8_to_I(r, g, b); src += readStride; @@ -1009,7 +1009,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_RGB8(src, r, g, b); + BoxfilterRGB_to_RGB8(src, r, g, b); u16 val = ((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | ((b >> 3) & 0x001e); *(u16*)dst = Common::swap16(val); src += readStride; @@ -1023,7 +1023,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_RGB8(src, r, g, b); + BoxfilterRGB_to_RGB8(src, r, g, b); u16 val = 0x8000 | ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3) & 0x001e); *(u16*)dst = Common::swap16(val); src += readStride; @@ -1037,7 +1037,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_RGB8(src, r, g, b); + BoxfilterRGB_to_RGB8(src, r, g, b); dst[0] = 0xff; dst[1] = r; dst[32] = g; @@ -1054,11 +1054,11 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) sBlkSize /= 2; ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, r, 2); + BoxfilterRGB_to_x8(src, r, 2); *dst = r & 0xf0; src += readStride; - boxfilterRGB_to_x8(src, r, 2); + BoxfilterRGB_to_x8(src, r, 2); *dst |= r >> 4; src += readStride; @@ -1072,7 +1072,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, r, 2); + BoxfilterRGB_to_x8(src, r, 2); *dst++ = 0xf0 | (r >> 4); src += readStride; } @@ -1084,7 +1084,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, r, 2); + BoxfilterRGB_to_x8(src, r, 2); *dst++ = 0xff; *dst++ = r; src += readStride; @@ -1107,7 +1107,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, r, 2); + BoxfilterRGB_to_x8(src, r, 2); *dst++ = r; src += readStride; } @@ -1119,7 +1119,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, g, 1); + BoxfilterRGB_to_x8(src, g, 1); *dst++ = g; src += readStride; } @@ -1131,7 +1131,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, b, 0); + BoxfilterRGB_to_x8(src, b, 0); *dst++ = b; src += readStride; } @@ -1143,7 +1143,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_xx8(src, r, g, 2, 1); + BoxfilterRGB_to_xx8(src, r, g, 2, 1); *dst++ = g; *dst++ = r; src += readStride; @@ -1156,7 +1156,7 @@ static void EncodeRGB8halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_xx8(src, g, b, 1, 0); + BoxfilterRGB_to_xx8(src, g, b, 1, 0); *dst++ = b; *dst++ = g; src += readStride; @@ -1289,7 +1289,7 @@ static void EncodeZ24halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, b, 2); + BoxfilterRGB_to_x8(src, b, 2); *dst++ = b; src += readStride; } @@ -1301,7 +1301,7 @@ static void EncodeZ24halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_xx8(src, g, b, 1, 2); + BoxfilterRGB_to_xx8(src, g, b, 1, 2); *dst++ = b; *dst++ = g; src += readStride; @@ -1314,7 +1314,7 @@ static void EncodeZ24halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_RGB8(src, dst[33], dst[32], dst[1]); + BoxfilterRGB_to_RGB8(src, dst[33], dst[32], dst[1]); dst[0] = 255; src += readStride; dst += 2; @@ -1328,11 +1328,11 @@ static void EncodeZ24halfscale(u8 *dst, u8 *src, u32 format) sBlkSize /= 2; ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, b, 2); + BoxfilterRGB_to_x8(src, b, 2); *dst = b & 0xf0; src += readStride; - boxfilterRGB_to_x8(src, b, 2); + BoxfilterRGB_to_x8(src, b, 2); *dst |= b >> 4; src += readStride; @@ -1346,7 +1346,7 @@ static void EncodeZ24halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, g, 1); + BoxfilterRGB_to_x8(src, g, 1); *dst++ = g; src += readStride; } @@ -1358,7 +1358,7 @@ static void EncodeZ24halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_x8(src, r, 0); + BoxfilterRGB_to_x8(src, r, 0); *dst++ = r; src += readStride; } @@ -1370,7 +1370,7 @@ static void EncodeZ24halfscale(u8 *dst, u8 *src, u32 format) SetSpans(sBlkSize, tBlkSize, tSpan, sBlkSpan, tBlkSpan, writeStride); ENCODE_LOOP_BLOCKS { - boxfilterRGB_to_xx8(src, r, g, 0, 1); + BoxfilterRGB_to_xx8(src, r, g, 0, 1); *dst++ = g; *dst++ = r; src += readStride; From 4129cdeb4d1e3969aba64cf2dad25b3864eedccb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Aug 2014 21:51:05 -0400 Subject: [PATCH 6/9] Software: Apply static to some functions --- .../VideoBackends/Software/EfbInterface.cpp | 4 ++-- .../VideoBackends/Software/Rasterizer.cpp | 8 +++---- .../Software/SWCommandProcessor.cpp | 23 ++++++++++++++----- Source/Core/VideoBackends/Software/Tev.cpp | 6 ++--- .../VideoBackends/Software/TextureEncoder.cpp | 20 ++++++++-------- .../VideoBackends/Software/TextureSampler.cpp | 6 ++--- .../VideoBackends/Software/TransformUnit.cpp | 6 ++--- 7 files changed, 41 insertions(+), 32 deletions(-) diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index cc0469193a91..cd1092298175 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -20,12 +20,12 @@ namespace EfbInterface { u32 perf_values[PQ_NUM_MEMBERS]; - inline u32 GetColorOffset(u16 x, u16 y) + static inline u32 GetColorOffset(u16 x, u16 y) { return (x + y * EFB_WIDTH) * 3; } - inline u32 GetDepthOffset(u16 x, u16 y) + static inline u32 GetDepthOffset(u16 x, u16 y) { return (x + y * EFB_WIDTH) * 3 + DEPTH_BUFFER_START; } diff --git a/Source/Core/VideoBackends/Software/Rasterizer.cpp b/Source/Core/VideoBackends/Software/Rasterizer.cpp index cfe038b0eae2..5b764fcc7ab0 100644 --- a/Source/Core/VideoBackends/Software/Rasterizer.cpp +++ b/Source/Core/VideoBackends/Software/Rasterizer.cpp @@ -83,11 +83,9 @@ void Init() ZSlope.f0 = 1.f; } -inline int iround(float x) +static inline int iround(float x) { - int t; - - t = (int)x; + int t = (int)x; if ((x - t) >= 0.5) return t + 1; @@ -208,7 +206,7 @@ static void InitSlope(Slope *slope, float f1, float f2, float f3, float DX31, fl slope->f0 = f1; } -inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord) +static inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord) { FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1]; u8 subTexmap = texmap & 3; diff --git a/Source/Core/VideoBackends/Software/SWCommandProcessor.cpp b/Source/Core/VideoBackends/Software/SWCommandProcessor.cpp index 4f4790ed7217..32bc5de486c8 100644 --- a/Source/Core/VideoBackends/Software/SWCommandProcessor.cpp +++ b/Source/Core/VideoBackends/Software/SWCommandProcessor.cpp @@ -61,19 +61,30 @@ void DoState(PointerWrap &p) } // does it matter that there is no synchronization between threads during writes? -inline void WriteLow (u32& _reg, u16 lowbits) {_reg = (_reg & 0xFFFF0000) | lowbits;} -inline void WriteHigh(u32& _reg, u16 highbits) {_reg = (_reg & 0x0000FFFF) | ((u32)highbits << 16);} - -inline u16 ReadLow (u32 _reg) {return (u16)(_reg & 0xFFFF);} -inline u16 ReadHigh (u32 _reg) {return (u16)(_reg >> 16);} +static inline void WriteLow (u32& _reg, u16 lowbits) +{ + _reg = (_reg & 0xFFFF0000) | lowbits; +} +static inline void WriteHigh(u32& _reg, u16 highbits) +{ + _reg = (_reg & 0x0000FFFF) | ((u32)highbits << 16); +} +static inline u16 ReadLow(u32 _reg) +{ + return (u16)(_reg & 0xFFFF); +} +static inline u16 ReadHigh(u32 _reg) +{ + return (u16)(_reg >> 16); +} static void UpdateInterrupts_Wrapper(u64 userdata, int cyclesLate) { UpdateInterrupts(userdata); } -inline bool AtBreakpoint() +static inline bool AtBreakpoint() { return cpreg.ctrl.BPEnable && (cpreg.readptr == cpreg.breakpt); } diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index 8dd048f53b92..35e6c302fea0 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -123,12 +123,12 @@ void Tev::Init() m_ScaleRShiftLUT[3] = 1; } -inline s16 Clamp255(s16 in) +static inline s16 Clamp255(s16 in) { return in>255?255:(in<0?0:in); } -inline s16 Clamp1024(s16 in) +static inline s16 Clamp1024(s16 in) { return in>1023?1023:(in<-1024?-1024:in); } @@ -366,7 +366,7 @@ static bool TevAlphaTest(int alpha) return true; } -inline s32 WrapIndirectCoord(s32 coord, int wrapMode) +static inline s32 WrapIndirectCoord(s32 coord, int wrapMode) { switch (wrapMode) { diff --git a/Source/Core/VideoBackends/Software/TextureEncoder.cpp b/Source/Core/VideoBackends/Software/TextureEncoder.cpp index a1b567048063..0fe7214d2af8 100644 --- a/Source/Core/VideoBackends/Software/TextureEncoder.cpp +++ b/Source/Core/VideoBackends/Software/TextureEncoder.cpp @@ -13,7 +13,7 @@ namespace TextureEncoder { -inline void RGBA_to_RGBA8(u8 *src, u8 &r, u8 &g, u8 &b, u8 &a) +static inline void RGBA_to_RGBA8(u8 *src, u8 &r, u8 &g, u8 &b, u8 &a) { u32 srcColor = *(u32*)src; a = Convert6To8(srcColor & 0x3f); @@ -22,7 +22,7 @@ inline void RGBA_to_RGBA8(u8 *src, u8 &r, u8 &g, u8 &b, u8 &a) r = Convert6To8((srcColor >> 18)& 0x3f); } -inline void RGBA_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) +static inline void RGBA_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) { u32 srcColor = *(u32*)src; b = Convert6To8((srcColor >> 6) & 0x3f); @@ -30,7 +30,7 @@ inline void RGBA_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) r = Convert6To8((srcColor >> 18)& 0x3f); } -inline u8 RGB8_to_I(u8 r, u8 g, u8 b) +static inline u8 RGB8_to_I(u8 r, u8 g, u8 b) { // values multiplied by 256 to keep math integer u16 val = 4096 + 66 * r + 129 * g + 25 * b; @@ -40,7 +40,7 @@ inline u8 RGB8_to_I(u8 r, u8 g, u8 b) // box filter sampling averages 4 samples with the source texel being the top left of the box // components are scaled to the range 0-255 after all samples are taken -inline void BoxfilterRGBA_to_RGBA8(u8 *src, u8 &r, u8 &g, u8 &b, u8 &a) +static inline void BoxfilterRGBA_to_RGBA8(u8 *src, u8 &r, u8 &g, u8 &b, u8 &a) { u16 r16 = 0, g16 = 0, b16 = 0, a16 = 0; @@ -66,7 +66,7 @@ inline void BoxfilterRGBA_to_RGBA8(u8 *src, u8 &r, u8 &g, u8 &b, u8 &a) a = a16 + (a16 >> 6); } -inline void BoxfilterRGBA_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) +static inline void BoxfilterRGBA_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) { u16 r16 = 0, g16 = 0, b16 = 0; @@ -90,7 +90,7 @@ inline void BoxfilterRGBA_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) b = b16 + (b16 >> 6); } -inline void BoxfilterRGBA_to_x8(u8 *src, u8 &x8, int shift) +static inline void BoxfilterRGBA_to_x8(u8 *src, u8 &x8, int shift) { u16 x16 = 0; @@ -110,7 +110,7 @@ inline void BoxfilterRGBA_to_x8(u8 *src, u8 &x8, int shift) x8 = x16 + (x16 >> 6); } -inline void BoxfilterRGBA_to_xx8(u8 *src, u8 &x1, u8 &x2, int shift1, int shift2) +static inline void BoxfilterRGBA_to_xx8(u8 *src, u8 &x1, u8 &x2, int shift1, int shift2) { u16 x16_1 = 0; u16 x16_2 = 0; @@ -133,7 +133,7 @@ inline void BoxfilterRGBA_to_xx8(u8 *src, u8 &x1, u8 &x2, int shift1, int shift2 x2 = x16_2 + (x16_2 >> 6); } -inline void BoxfilterRGB_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) +static inline void BoxfilterRGB_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) { u16 r16 = 0, g16 = 0, b16 = 0; @@ -155,7 +155,7 @@ inline void BoxfilterRGB_to_RGB8(u8 *src, u8 &r, u8 &g, u8 &b) b = b16 >> 2; } -inline void BoxfilterRGB_to_x8(u8 *src, u8 &x8, int comp) +static inline void BoxfilterRGB_to_x8(u8 *src, u8 &x8, int comp) { u16 x16 = 0; @@ -174,7 +174,7 @@ inline void BoxfilterRGB_to_x8(u8 *src, u8 &x8, int comp) x8 = x16 >> 2; } -inline void BoxfilterRGB_to_xx8(u8 *src, u8 &x1, u8 &x2, int comp1, int comp2) +static inline void BoxfilterRGB_to_xx8(u8 *src, u8 &x1, u8 &x2, int comp1, int comp2) { u16 x16_1 = 0; u16 x16_2 = 0; diff --git a/Source/Core/VideoBackends/Software/TextureSampler.cpp b/Source/Core/VideoBackends/Software/TextureSampler.cpp index d5a7f891b9e9..60cd2da97214 100644 --- a/Source/Core/VideoBackends/Software/TextureSampler.cpp +++ b/Source/Core/VideoBackends/Software/TextureSampler.cpp @@ -15,7 +15,7 @@ namespace TextureSampler { -inline void WrapCoord(int &coord, int wrapMode, int imageSize) +static inline void WrapCoord(int &coord, int wrapMode, int imageSize) { switch (wrapMode) { @@ -38,7 +38,7 @@ inline void WrapCoord(int &coord, int wrapMode, int imageSize) } } -inline void SetTexel(u8 *inTexel, u32 *outTexel, u32 fract) +static inline void SetTexel(u8 *inTexel, u32 *outTexel, u32 fract) { outTexel[0] = inTexel[0] * fract; outTexel[1] = inTexel[1] * fract; @@ -46,7 +46,7 @@ inline void SetTexel(u8 *inTexel, u32 *outTexel, u32 fract) outTexel[3] = inTexel[3] * fract; } -inline void AddTexel(u8 *inTexel, u32 *outTexel, u32 fract) +static inline void AddTexel(u8 *inTexel, u32 *outTexel, u32 fract) { outTexel[0] += inTexel[0] * fract; outTexel[1] += inTexel[1] * fract; diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index bb2b50ad41ba..0c667313bc42 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -189,21 +189,21 @@ struct LightPointer Vec3 dir; }; -inline void AddIntegerColor(const u8 *src, Vec3 &dst) +static inline void AddIntegerColor(const u8 *src, Vec3 &dst) { dst.x += src[1]; dst.y += src[2]; dst.z += src[3]; } -inline void AddScaledIntegerColor(const u8 *src, float scale, Vec3 &dst) +static inline void AddScaledIntegerColor(const u8 *src, float scale, Vec3 &dst) { dst.x += src[1] * scale; dst.y += src[2] * scale; dst.z += src[3] * scale; } -inline float SafeDivide(float n, float d) +static inline float SafeDivide(float n, float d) { return (d==0) ? (n>0?1:0) : n/d; } From 34eb0c6e1c4a0adce1fc4f2b2125eab5591a5d27 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Aug 2014 21:51:55 -0400 Subject: [PATCH 7/9] Software: Fix over-indentation of SetupQuad() --- Source/Core/VideoBackends/Software/SetupUnit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoBackends/Software/SetupUnit.cpp b/Source/Core/VideoBackends/Software/SetupUnit.cpp index 37e45f9f2851..dfa8e5e4230d 100644 --- a/Source/Core/VideoBackends/Software/SetupUnit.cpp +++ b/Source/Core/VideoBackends/Software/SetupUnit.cpp @@ -54,8 +54,8 @@ void SetupUnit::SetupVertex() } - void SetupUnit::SetupQuad() - { +void SetupUnit::SetupQuad() +{ if (m_VertexCounter < 2) { m_VertexCounter++; From f9f46f33d6a12f5e57e0c0a4b6d66ed3c22952e1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Aug 2014 21:55:30 -0400 Subject: [PATCH 8/9] Software: Fix some if-statement body placements --- .../Core/VideoBackends/Software/Clipper.cpp | 25 ++++++++++++++----- .../VideoBackends/Software/Rasterizer.cpp | 12 ++++++--- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Source/Core/VideoBackends/Software/Clipper.cpp b/Source/Core/VideoBackends/Software/Clipper.cpp index 1efec0c99548..f0ef19cd4ea5 100644 --- a/Source/Core/VideoBackends/Software/Clipper.cpp +++ b/Source/Core/VideoBackends/Software/Clipper.cpp @@ -91,12 +91,25 @@ namespace Clipper { int cmask = 0; Vec4 pos = v->projectedPosition; - if (pos.w - pos.x < 0) cmask |= CLIP_POS_X_BIT; - if (pos.x + pos.w < 0) cmask |= CLIP_NEG_X_BIT; - if (pos.w - pos.y < 0) cmask |= CLIP_POS_Y_BIT; - if (pos.y + pos.w < 0) cmask |= CLIP_NEG_Y_BIT; - if (pos.w * pos.z > 0) cmask |= CLIP_POS_Z_BIT; - if (pos.z + pos.w < 0) cmask |= CLIP_NEG_Z_BIT; + + if (pos.w - pos.x < 0) + cmask |= CLIP_POS_X_BIT; + + if (pos.x + pos.w < 0) + cmask |= CLIP_NEG_X_BIT; + + if (pos.w - pos.y < 0) + cmask |= CLIP_POS_Y_BIT; + + if (pos.y + pos.w < 0) + cmask |= CLIP_NEG_Y_BIT; + + if (pos.w * pos.z > 0) + cmask |= CLIP_POS_Z_BIT; + + if (pos.z + pos.w < 0) + cmask |= CLIP_NEG_Z_BIT; + return cmask; } diff --git a/Source/Core/VideoBackends/Software/Rasterizer.cpp b/Source/Core/VideoBackends/Software/Rasterizer.cpp index 5b764fcc7ab0..3d002da810d3 100644 --- a/Source/Core/VideoBackends/Software/Rasterizer.cpp +++ b/Source/Core/VideoBackends/Software/Rasterizer.cpp @@ -98,16 +98,20 @@ void SetScissor() int yoff = bpmem.scissorOffset.y * 2 - 342; scissorLeft = bpmem.scissorTL.x - xoff - 342; - if (scissorLeft < 0) scissorLeft = 0; + if (scissorLeft < 0) + scissorLeft = 0; scissorTop = bpmem.scissorTL.y - yoff - 342; - if (scissorTop < 0) scissorTop = 0; + if (scissorTop < 0) + scissorTop = 0; scissorRight = bpmem.scissorBR.x - xoff - 341; - if (scissorRight > EFB_WIDTH) scissorRight = EFB_WIDTH; + if (scissorRight > EFB_WIDTH) + scissorRight = EFB_WIDTH; scissorBottom = bpmem.scissorBR.y - yoff - 341; - if (scissorBottom > EFB_HEIGHT) scissorBottom = EFB_HEIGHT; + if (scissorBottom > EFB_HEIGHT) + scissorBottom = EFB_HEIGHT; } void SetTevReg(int reg, int comp, bool konst, s16 color) From bcd10bfda657d6af2d43c22de20b1d924e482b98 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Aug 2014 22:01:42 -0400 Subject: [PATCH 9/9] Software: Fix function casing in SWRenderer --- Source/Core/VideoBackends/Software/DebugUtil.cpp | 2 +- Source/Core/VideoBackends/Software/EfbCopy.cpp | 4 ++-- Source/Core/VideoBackends/Software/SWRenderer.cpp | 12 ++++++------ Source/Core/VideoBackends/Software/SWRenderer.h | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/Core/VideoBackends/Software/DebugUtil.cpp b/Source/Core/VideoBackends/Software/DebugUtil.cpp index 0a37d50e8404..1d1dfe0c1a80 100644 --- a/Source/Core/VideoBackends/Software/DebugUtil.cpp +++ b/Source/Core/VideoBackends/Software/DebugUtil.cpp @@ -159,7 +159,7 @@ static void DumpEfb(const std::string& filename) static void DumpColorTexture(const std::string& filename, u32 width, u32 height) { - TextureToPng(SWRenderer::getCurrentColorTexture(), width * 4, filename, width, height, true); + TextureToPng(SWRenderer::GetCurrentColorTexture(), width * 4, filename, width, height, true); } void DrawObjectBuffer(s16 x, s16 y, u8 *color, int bufferBase, int subBuffer, const char *name) diff --git a/Source/Core/VideoBackends/Software/EfbCopy.cpp b/Source/Core/VideoBackends/Software/EfbCopy.cpp index 5c4e1e24c36c..6a5e3a7abea6 100644 --- a/Source/Core/VideoBackends/Software/EfbCopy.cpp +++ b/Source/Core/VideoBackends/Software/EfbCopy.cpp @@ -45,12 +45,12 @@ namespace EfbCopy else { // Ask SWRenderer for the next color texture - u8 *colorTexture = SWRenderer::getNextColorTexture(); + u8 *colorTexture = SWRenderer::GetNextColorTexture(); EfbInterface::BypassXFB(colorTexture, fbWidth, fbHeight, sourceRc, Gamma); // Tell SWRenderer we are now finished with it. - SWRenderer::swapColorTexture(); + SWRenderer::SwapColorTexture(); // FifoPlayer is broken and never calls BeginFrame/EndFrame. // Hence, we manually force a swap now. This emulates the behavior diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index e098c5a2f42f..e8d2477f4c6c 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -153,17 +153,17 @@ void SWRenderer::DrawDebugText() SWRenderer::RenderText(debugtext.c_str(), 20, 20, 0xFFFFFF00); } -u8* SWRenderer::getNextColorTexture() +u8* SWRenderer::GetNextColorTexture() { return s_xfbColorTexture[!s_currentColorTexture]; } -u8* SWRenderer::getCurrentColorTexture() +u8* SWRenderer::GetCurrentColorTexture() { return s_xfbColorTexture[s_currentColorTexture]; } -void SWRenderer::swapColorTexture() +void SWRenderer::SwapColorTexture() { s_currentColorTexture = !s_currentColorTexture; } @@ -177,7 +177,7 @@ void SWRenderer::UpdateColorTexture(EfbInterface::yuv422_packed *xfb, u32 fbWidt } u32 offset = 0; - u8 *TexturePointer = getNextColorTexture(); + u8 *TexturePointer = GetNextColorTexture(); for (u16 y = 0; y < fbHeight; y++) { @@ -203,7 +203,7 @@ void SWRenderer::UpdateColorTexture(EfbInterface::yuv422_packed *xfb, u32 fbWidt } xfb += fbWidth; } - swapColorTexture(); + SwapColorTexture(); } // Called on the GPU thread @@ -211,7 +211,7 @@ void SWRenderer::Swap(u32 fbWidth, u32 fbHeight) { GLInterface->Update(); // just updates the render window position and the backbuffer size if (!g_SWVideoConfig.bHwRasterizer) - SWRenderer::DrawTexture(getCurrentColorTexture(), fbWidth, fbHeight); + SWRenderer::DrawTexture(GetCurrentColorTexture(), fbWidth, fbHeight); swstats.frameCount++; SWRenderer::SwapBuffer(); diff --git a/Source/Core/VideoBackends/Software/SWRenderer.h b/Source/Core/VideoBackends/Software/SWRenderer.h index e9ac11c96761..08abc1fa7406 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.h +++ b/Source/Core/VideoBackends/Software/SWRenderer.h @@ -18,9 +18,9 @@ namespace SWRenderer void RenderText(const char* pstr, int left, int top, u32 color); void DrawDebugText(); - u8* getNextColorTexture(); - u8* getCurrentColorTexture(); - void swapColorTexture(); + u8* GetNextColorTexture(); + u8* GetCurrentColorTexture(); + void SwapColorTexture(); void UpdateColorTexture(EfbInterface::yuv422_packed *xfb, u32 fbWidth, u32 fbHeight); void DrawTexture(u8 *texture, int width, int height);