diff --git a/Source/Core/VideoCommon/VertexLoader_Normal.cpp b/Source/Core/VideoCommon/VertexLoader_Normal.cpp index c713e4c9c6..abb6d27da7 100644 --- a/Source/Core/VideoCommon/VertexLoader_Normal.cpp +++ b/Source/Core/VideoCommon/VertexLoader_Normal.cpp @@ -38,12 +38,13 @@ constexpr float FracAdjust(float val) return val; } -template +template void ReadIndirect(VertexLoader* loader, const T* data) { static_assert(3 == N || 9 == N, "N is only sane as 3 or 9!"); + static_assert(!(Offset != 0 && 9 == N), "N == 9 only makes sense if offset == 0"); - for (u32 i = 0; i < N; ++i) + for (u32 i = Offset; i < N + Offset; ++i) { const float value = FracAdjust(Common::FromBigEndian(data[i])); if (loader->m_remaining == 0) @@ -63,7 +64,7 @@ template void Normal_ReadDirect(VertexLoader* loader) { const auto source = reinterpret_cast(DataGetPosition()); - ReadIndirect(loader, source); + ReadIndirect(loader, source); DataSkip(); } @@ -73,10 +74,10 @@ void Normal_ReadIndex_Offset(VertexLoader* loader) static_assert(std::is_unsigned_v, "Only unsigned I is sane!"); const auto index = DataRead(); - const auto data = reinterpret_cast( - VertexLoaderManager::cached_arraybases[CPArray::Normal] + - (index * g_main_cp_state.array_strides[CPArray::Normal]) + sizeof(T) * 3 * Offset); - ReadIndirect(loader, data); + const auto data = + reinterpret_cast(VertexLoaderManager::cached_arraybases[CPArray::Normal] + + (index * g_main_cp_state.array_strides[CPArray::Normal])); + ReadIndirect(loader, data); } template