From 0c62ae9c1a530acd255404f389c7859194d4a057 Mon Sep 17 00:00:00 2001 From: Jens Nyberg Date: Wed, 26 Mar 2014 22:54:40 +0100 Subject: [PATCH 1/3] VideoCommon/VertexLoader: Remove NRM enum --- Source/Core/VideoCommon/VertexLoader.cpp | 4 +--- Source/Core/VideoCommon/VertexLoader.h | 7 ------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index f751bd0896..e36c4d848c 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -613,10 +613,8 @@ void VertexLoader::CompileVertexTranslator() nat_offset += 12; } - int numNormals = (m_VtxAttr.NormalElements == 1) ? NRM_THREE : NRM_ONE; components |= VB_HAS_NRM0; - - if (numNormals == NRM_THREE) + if (m_VtxAttr.NormalElements == 1) components |= VB_HAS_NRM1 | VB_HAS_NRM2; } diff --git a/Source/Core/VideoCommon/VertexLoader.h b/Source/Core/VideoCommon/VertexLoader.h index 01c4bb0acd..de33e44a39 100644 --- a/Source/Core/VideoCommon/VertexLoader.h +++ b/Source/Core/VideoCommon/VertexLoader.h @@ -107,13 +107,6 @@ public: int GetNumLoadedVerts() const { return m_numLoadedVertices; } private: - enum - { - NRM_ZERO = 0, - NRM_ONE = 1, - NRM_THREE = 3, - }; - int m_VertexSize; // number of bytes of a raw GC vertex. Computed by CompileVertexTranslator. // GC vertex format From 478a27e0521fb59b0b0d06c59c9b664744c33900 Mon Sep 17 00:00:00 2001 From: Jens Nyberg Date: Thu, 27 Mar 2014 00:24:48 +0100 Subject: [PATCH 2/3] VideoCommon/VertexLoader: Remove duplicate point min and max calculation --- Source/Core/VideoCommon/VertexLoader.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index e36c4d848c..1956902df2 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -307,22 +307,18 @@ void LOADERDECL UpdateBoundingBox() // If the polygon is inside viewport, let's update the bounding box and be done with it if ((b0 == 3) && (b0 == b1) && (b0 == b2)) { - // Line - if (numPoints == 2) - { - left = (p0.x < p1.x) ? p0.x : p1.x; - top = (p0.y < p1.y) ? p0.y : p1.y; - right = (p0.x > p1.x) ? p0.x : p1.x; - bottom = (p0.y > p1.y) ? p0.y : p1.y; - } + left = std::min(p0.x, p1.x); + top = std::min(p0.y, p1.y); + right = std::max(p0.x, p1.x); + bottom = std::max(p0.y, p1.y); // Triangle - else + if (numPoints == 3) { - left = (p0.x < p1.x) ? (p0.x < p2.x) ? p0.x : p2.x : (p1.x < p2.x) ? p1.x : p2.x; - top = (p0.y < p1.y) ? (p0.y < p2.y) ? p0.y : p2.y : (p1.y < p2.y) ? p1.y : p2.y; - right = (p0.x > p1.x) ? (p0.x > p2.x) ? p0.x : p2.x : (p1.x > p2.x) ? p1.x : p2.x; - bottom = (p0.y > p1.y) ? (p0.y > p2.y) ? p0.y : p2.y : (p1.y > p2.y) ? p1.y : p2.y; + left = std::min(left, p2.x); + top = std::min(top, p2.y); + right = std::max(right, p2.x); + bottom = std::max(bottom, p2.y); } // Update bounding box From 73176d03335fd154717e308d51661c7f814ebfcd Mon Sep 17 00:00:00 2001 From: Jens Nyberg Date: Thu, 27 Mar 2014 00:28:01 +0100 Subject: [PATCH 3/3] VideoCommon/VertexLoader: Add more use of std::min and std::max --- Source/Core/VideoCommon/VertexLoader.cpp | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index 1956902df2..2edf89597b 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -352,19 +352,19 @@ void LOADERDECL UpdateBoundingBox() // Second point inside if (b1 == 3) { - left = (p1.x < left) ? p1.x : left; - top = (p1.y < top) ? p1.y : top; - right = (p1.x > right) ? p1.x : right; - bottom = (p1.y > bottom) ? p1.y : bottom; + left = std::min(p1.x, left); + top = std::min(p1.y, top); + right = std::max(p1.x, right); + bottom = std::max(p1.y, bottom); } // Third point inside if ((b2 == 3) && (numPoints == 3)) { - left = (p2.x < left) ? p2.x : left; - top = (p2.y < top) ? p2.y : top; - right = (p2.x > right) ? p2.x : right; - bottom = (p2.y > bottom) ? p2.y : bottom; + left = std::min(p2.x, left); + top = std::min(p2.y, top); + right = std::max(p2.x, right); + bottom = std::max(p2.y, bottom); } // Triangle equation vars @@ -382,10 +382,10 @@ void LOADERDECL UpdateBoundingBox() { m = (p1.x - p0.x) ? ((p1.y - p0.y) / (p1.x - p0.x)) : highNum; c = p0.y - (m * p0.x); - if (i0 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = (s < top) ? s : top; bottom = (s > bottom) ? s : bottom; } - if (i0 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = (s < left) ? s : left; right = (s > right) ? s : right; } - if (i0 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = (s < top) ? s : top; bottom = (s > bottom) ? s : bottom; } - if (i0 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = (s < left) ? s : left; right = (s > right) ? s : right; } + if (i0 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = std::min(s, top); bottom = std::max(s, bottom); } + if (i0 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = std::min(s, left); right = std::max(s, right); } + if (i0 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = std::min(s, top); bottom = std::max(s, bottom); } + if (i0 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = std::min(s, left); right = std::max(s, right); } } // Only check other lines if we are dealing with a triangle @@ -396,10 +396,10 @@ void LOADERDECL UpdateBoundingBox() { m = (p2.x - p1.x) ? ((p2.y - p1.y) / (p2.x - p1.x)) : highNum; c = p1.y - (m * p1.x); - if (i1 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = (s < top) ? s : top; bottom = (s > bottom) ? s : bottom; } - if (i1 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = (s < left) ? s : left; right = (s > right) ? s : right; } - if (i1 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = (s < top) ? s : top; bottom = (s > bottom) ? s : bottom; } - if (i1 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = (s < left) ? s : left; right = (s > right) ? s : right; } + if (i1 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = std::min(s, top); bottom = std::max(s, bottom); } + if (i1 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = std::min(s, left); right = std::max(s, right); } + if (i1 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = std::min(s, top); bottom = std::max(s, bottom); } + if (i1 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = std::min(s, left); right = std::max(s, right); } } // Third line intersects @@ -407,10 +407,10 @@ void LOADERDECL UpdateBoundingBox() { m = (p2.x - p0.x) ? ((p2.y - p0.y) / (p2.x - p0.x)) : highNum; c = p0.y - (m * p0.x); - if (i2 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = (s < top) ? s : top; bottom = (s > bottom) ? s : bottom; } - if (i2 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = (s < left) ? s : left; right = (s > right) ? s : right; } - if (i2 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = (s < top) ? s : top; bottom = (s > bottom) ? s : bottom; } - if (i2 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = (s < left) ? s : left; right = (s > right) ? s : right; } + if (i2 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = std::min(s, top); bottom = std::max(s, bottom); } + if (i2 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = std::min(s, left); right = std::max(s, right); } + if (i2 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = std::min(s, top); bottom = std::max(s, bottom); } + if (i2 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = std::min(s, left); right = std::max(s, right); } } }