summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoader_Normal.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2023-01-12 15:00:51 -0800
committerPokechu22 <Pokechu022@gmail.com>2023-01-13 15:38:00 -0800
commit16c0593a52ddaf3a5bde17a2f56f46b9618e5928 (patch)
tree4cc958068f8aa8df62d2521d5c9967c5897da273 /Source/Core/VideoCommon/VertexLoader_Normal.cpp
parent2d53b7364363b8d32f62905dbdbff01531ebe06d (diff)
VertexLoader: Fix loading tangent/binormal caches with NormalIndex3
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoader_Normal.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoader_Normal.cpp15
1 files changed, 8 insertions, 7 deletions
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 <typename T, u32 N>
+template <typename T, u32 N, u32 Offset>
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 <typename T, u32 N>
void Normal_ReadDirect(VertexLoader* loader)
{
const auto source = reinterpret_cast<const T*>(DataGetPosition());
- ReadIndirect<T, N * 3>(loader, source);
+ ReadIndirect<T, N * 3, 0>(loader, source);
DataSkip<N * 3 * sizeof(T)>();
}
@@ -73,10 +74,10 @@ void Normal_ReadIndex_Offset(VertexLoader* loader)
static_assert(std::is_unsigned_v<I>, "Only unsigned I is sane!");
const auto index = DataRead<I>();
- const auto data = reinterpret_cast<const T*>(
- VertexLoaderManager::cached_arraybases[CPArray::Normal] +
- (index * g_main_cp_state.array_strides[CPArray::Normal]) + sizeof(T) * 3 * Offset);
- ReadIndirect<T, N * 3>(loader, data);
+ const auto data =
+ reinterpret_cast<const T*>(VertexLoaderManager::cached_arraybases[CPArray::Normal] +
+ (index * g_main_cp_state.array_strides[CPArray::Normal]));
+ ReadIndirect<T, N * 3, Offset * 3>(loader, data);
}
template <typename I, typename T, u32 N>