diff --git a/GPU/Common/VertexDecoderCommon.cpp b/GPU/Common/VertexDecoderCommon.cpp index 64ef34aa80..e8d3310eed 100644 --- a/GPU/Common/VertexDecoderCommon.cpp +++ b/GPU/Common/VertexDecoderCommon.cpp @@ -1264,6 +1264,8 @@ void VertexDecoder::SetVertexType(u32 fmt, const VertexDecoderOptions &options, ERROR_LOG_REPORT(G3D, "Vertices without position found: (%08x) %s", fmt_, temp); } + _assert_msg_(decFmt.posfmt == DEC_FLOAT_3, "Reader only supports float pos"); + // Attempt to JIT as well. But only do that if the main CPU JIT is enabled, in order to aid // debugging attempts - if the main JIT doesn't work, this one won't do any better, probably. if (jitCache && g_Config.bVertexDecoderJit && g_Config.iCpuCore == (int)CPUCore::JIT) { diff --git a/GPU/Common/VertexDecoderCommon.h b/GPU/Common/VertexDecoderCommon.h index 257e7751ba..a12eb250c4 100644 --- a/GPU/Common/VertexDecoderCommon.h +++ b/GPU/Common/VertexDecoderCommon.h @@ -121,100 +121,22 @@ public: VertexReader(u8 *base, const DecVtxFormat &decFmt, int vtype) : base_(base), data_(base), decFmt_(decFmt), vtype_(vtype) {} void ReadPos(float pos[3]) const { - switch (decFmt_.posfmt) { - case DEC_FLOAT_3: - { - const float *f = (const float *)(data_ + decFmt_.posoff); - pos[0] = f[0]; - pos[1] = f[1]; - if (!isThrough()) { - pos[2] = f[2]; - } else { - // Integer value passed in a float. Clamped to 0, 65535. - pos[2] = (int)f[2] * (1.0f / 65535.0f); - } - } - break; - case DEC_S16_3: - { - // X and Y are signed 16 bit, Z is unsigned 16 bit - const s16 *s = (const s16 *)(data_ + decFmt_.posoff); - const u16 *u = (const u16 *)(data_ + decFmt_.posoff); - if (isThrough()) { - for (int i = 0; i < 2; i++) - pos[i] = s[i]; - pos[2] = u[2] * (1.0f / 65535.0f); - } else { - for (int i = 0; i < 3; i++) - pos[i] = s[i] * (1.0f / 32768.0f); - } - } - break; - case DEC_S8_3: - { - // X and Y are signed 8 bit, Z is unsigned 8 bit - const s8 *b = (const s8 *)(data_ + decFmt_.posoff); - const u8 *u = (const u8 *)(data_ + decFmt_.posoff); - if (isThrough()) { - for (int i = 0; i < 2; i++) - pos[i] = b[i]; - pos[2] = u[2] * (1.0f / 255.0f); - } else { - for (int i = 0; i < 3; i++) - pos[i] = b[i] * (1.0f / 128.0f); - } - } - break; - default: - ERROR_LOG_REPORT_ONCE(fmtpos, G3D, "Reader: Unsupported Pos Format %d", decFmt_.posfmt); - memset(pos, 0, sizeof(float) * 3); - break; + // Only DEC_FLOAT_3 is supported. + const float *f = (const float *)(data_ + decFmt_.posoff); + pos[0] = f[0]; + pos[1] = f[1]; + if (!isThrough()) { + pos[2] = f[2]; + } else { + // Integer value passed in a float. Clamped to 0, 65535. + pos[2] = (int)f[2] * (1.0f / 65535.0f); } } void ReadPosThroughZ16(float pos[3]) const { - switch (decFmt_.posfmt) { - case DEC_FLOAT_3: - { - const float *f = (const float *)(data_ + decFmt_.posoff); - memcpy(pos, f, 12); - } - break; - case DEC_S16_3: - { - // X and Y are signed 16 bit, Z is unsigned 16 bit - const s16 *s = (const s16 *)(data_ + decFmt_.posoff); - const u16 *u = (const u16 *)(data_ + decFmt_.posoff); - if (isThrough()) { - for (int i = 0; i < 2; i++) - pos[i] = s[i]; - pos[2] = u[2]; - } else { - for (int i = 0; i < 3; i++) - pos[i] = s[i] * (1.0f / 32768.0f); - } - } - break; - case DEC_S8_3: - { - // X and Y are signed 8 bit, Z is unsigned 8 bit - const s8 *b = (const s8 *)(data_ + decFmt_.posoff); - const u8 *u = (const u8 *)(data_ + decFmt_.posoff); - if (isThrough()) { - for (int i = 0; i < 2; i++) - pos[i] = b[i]; - pos[2] = u[2]; - } else { - for (int i = 0; i < 3; i++) - pos[i] = b[i] * (1.0f / 128.0f); - } - } - break; - default: - ERROR_LOG_REPORT_ONCE(fmtz16, G3D, "Reader: Unsupported Pos Format %d", decFmt_.posfmt); - memset(pos, 0, sizeof(float) * 3); - break; - } + // Only DEC_FLOAT_3 is supported. + const float *f = (const float *)(data_ + decFmt_.posoff); + memcpy(pos, f, 12); } void ReadNrm(float nrm[3]) const {