From 15a11d58c99384a836d9ca9d377e774e44447c4f Mon Sep 17 00:00:00 2001 From: xebra Date: Tue, 30 Jan 2018 18:17:54 +0900 Subject: [PATCH] Modify IndexConverter class to functor. --- GPU/Common/SplineCommon.cpp | 8 ++++---- GPU/Common/VertexDecoderCommon.h | 2 +- GPU/Software/TransformUnit.cpp | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/GPU/Common/SplineCommon.cpp b/GPU/Common/SplineCommon.cpp index 232b834746..1bd537da18 100644 --- a/GPU/Common/SplineCommon.cpp +++ b/GPU/Common/SplineCommon.cpp @@ -873,7 +873,7 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi u16 index_lower_bound = 0; u16 index_upper_bound = count_u * count_v - 1; - IndexConverter idxConv(vertType, indices); + IndexConverter ConvertIndex(vertType, indices); if (indices) GetIndexBounds(indices, count_u * count_v, vertType, &index_lower_bound, &index_upper_bound); @@ -897,7 +897,7 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi // Make an array of pointers to the control points, to get rid of indices. const SimpleVertex **points = (const SimpleVertex **)managedBuf.Allocate(sizeof(SimpleVertex *) * count_u * count_v); for (int idx = 0; idx < count_u * count_v; idx++) - points[idx] = simplified_control_points + (indices ? idxConv.convert(idx) : idx); + points[idx] = simplified_control_points + (indices ? ConvertIndex(idx) : idx); int count = 0; u8 *dest = splineBuffer; @@ -960,7 +960,7 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi u16 index_lower_bound = 0; u16 index_upper_bound = count_u * count_v - 1; - IndexConverter idxConv(vertType, indices); + IndexConverter ConvertIndex(vertType, indices); if (indices) GetIndexBounds(indices, count_u*count_v, vertType, &index_lower_bound, &index_upper_bound); @@ -989,7 +989,7 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi // Make an array of pointers to the control points, to get rid of indices. const SimpleVertex **points = (const SimpleVertex **)managedBuf.Allocate(sizeof(SimpleVertex *) * count_u * count_v); for (int idx = 0; idx < count_u * count_v; idx++) - points[idx] = simplified_control_points + (indices ? idxConv.convert(idx) : idx); + points[idx] = simplified_control_points + (indices ? ConvertIndex(idx) : idx); int count = 0; u8 *dest = splineBuffer; diff --git a/GPU/Common/VertexDecoderCommon.h b/GPU/Common/VertexDecoderCommon.h index 97ea633c1e..209186fd96 100644 --- a/GPU/Common/VertexDecoderCommon.h +++ b/GPU/Common/VertexDecoderCommon.h @@ -102,7 +102,7 @@ public: : indices(indices), indexType(vertType & GE_VTYPE_IDX_MASK) { } - inline u32 convert(u32 index) const { + u32 operator() (u32 index) const { switch (indexType) { case GE_VTYPE_IDX_8BIT: return indices8[index]; diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index e31d062de5..45fc87ccde 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -280,7 +280,7 @@ void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveTy u16 index_lower_bound = 0; u16 index_upper_bound = vertex_count - 1; - IndexConverter idxConv(vertex_type, indices); + IndexConverter ConvertIndex(vertex_type, indices); if (indices) GetIndexBounds(indices, vertex_count, vertex_type, &index_lower_bound, &index_upper_bound); @@ -321,7 +321,7 @@ void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveTy { for (int vtx = 0; vtx < vertex_count; ++vtx) { if (indices) { - vreader.Goto(idxConv.convert(vtx) - index_lower_bound); + vreader.Goto(ConvertIndex(vtx) - index_lower_bound); } else { vreader.Goto(vtx); } @@ -380,7 +380,7 @@ void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveTy int skip_count = data_index == 0 ? 1 : 0; for (int vtx = 0; vtx < vertex_count; ++vtx) { if (indices) { - vreader.Goto(idxConv.convert(vtx) - index_lower_bound); + vreader.Goto(ConvertIndex(vtx) - index_lower_bound); } else { vreader.Goto(vtx); } @@ -410,7 +410,7 @@ void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveTy for (int vtx = 0; vtx < vertex_count; ++vtx) { if (indices) { - vreader.Goto(idxConv.convert(vtx) - index_lower_bound); + vreader.Goto(ConvertIndex(vtx) - index_lower_bound); } else { vreader.Goto(vtx); } @@ -452,7 +452,7 @@ void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveTy // Only read the central vertex if we're not continuing. if (data_index == 0) { if (indices) { - vreader.Goto(idxConv.convert(0) - index_lower_bound); + vreader.Goto(ConvertIndex(0) - index_lower_bound); } else { vreader.Goto(0); } @@ -463,7 +463,7 @@ void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveTy for (int vtx = start_vtx; vtx < vertex_count; ++vtx) { if (indices) { - vreader.Goto(idxConv.convert(vtx) - index_lower_bound); + vreader.Goto(ConvertIndex(vtx) - index_lower_bound); } else { vreader.Goto(vtx); }