diff --git a/GPU/Common/VertexDecoderCommon.cpp b/GPU/Common/VertexDecoderCommon.cpp index d6e37cf0ad1a..c31a5f1d581b 100644 --- a/GPU/Common/VertexDecoderCommon.cpp +++ b/GPU/Common/VertexDecoderCommon.cpp @@ -108,28 +108,36 @@ void DecVtxFormat::InitializeFromID(uint32_t id) { void GetIndexBounds(const void *inds, int count, u32 vertType, u16 *indexLowerBound, u16 *indexUpperBound) { // Find index bounds. Could cache this in display lists. // Also, this could be greatly sped up with SSE2/NEON, although rarely a bottleneck. - int lowerBound = 0x7FFFFFFF; - int upperBound = 0; u32 idx = vertType & GE_VTYPE_IDX_MASK; - if (idx == GE_VTYPE_IDX_8BIT) { - const u8 *ind8 = (const u8 *)inds; + if (idx == GE_VTYPE_IDX_16BIT) { + uint16_t upperBound = 0; + uint16_t lowerBound = 0xFFFF; + const u16_le *ind16 = (const u16_le *)inds; for (int i = 0; i < count; i++) { - u8 value = ind8[i]; + u16 value = ind16[i]; if (value > upperBound) upperBound = value; if (value < lowerBound) lowerBound = value; } - } else if (idx == GE_VTYPE_IDX_16BIT) { - const u16_le *ind16 = (const u16_le *)inds; + *indexLowerBound = lowerBound; + *indexUpperBound = upperBound; + } else if (idx == GE_VTYPE_IDX_8BIT) { + uint8_t upperBound = 0; + uint8_t lowerBound = 0xFF; + const u8 *ind8 = (const u8 *)inds; for (int i = 0; i < count; i++) { - u16 value = ind16[i]; + u8 value = ind8[i]; if (value > upperBound) upperBound = value; if (value < lowerBound) lowerBound = value; } + *indexLowerBound = lowerBound; + *indexUpperBound = upperBound; } else if (idx == GE_VTYPE_IDX_32BIT) { + int lowerBound = 0x7FFFFFFF; + int upperBound = 0; WARN_LOG_REPORT_ONCE(indexBounds32, G3D, "GetIndexBounds: Decoding 32-bit indexes"); const u32_le *ind32 = (const u32_le *)inds; for (int i = 0; i < count; i++) { @@ -143,12 +151,12 @@ void GetIndexBounds(const void *inds, int count, u32 vertType, u16 *indexLowerBo if (value < lowerBound) lowerBound = value; } + *indexLowerBound = (u16)lowerBound; + *indexUpperBound = (u16)upperBound; } else { - lowerBound = 0; - upperBound = count - 1; + *indexLowerBound = 0; + *indexUpperBound = count - 1; } - *indexLowerBound = (u16)lowerBound; - *indexUpperBound = (u16)upperBound; } void PrintDecodedVertex(const VertexReader &vtx) {