Skip to content

Commit

Permalink
Modify IndexConverter class to functor.
Browse files Browse the repository at this point in the history
  • Loading branch information
xebra committed Oct 7, 2018
1 parent d8ccc1c commit 15a11d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions GPU/Common/SplineCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/VertexDecoderCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class IndexConverter {
: 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];
Expand Down
12 changes: 6 additions & 6 deletions GPU/Software/TransformUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 15a11d5

Please sign in to comment.