summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoader.cpp
diff options
context:
space:
mode:
authorTilka <tilkax@gmail.com>2023-12-04 13:06:19 +0000
committerGitHub <noreply@github.com>2023-12-04 13:06:19 +0000
commit7dfea144b9eaa4d6cce1b8ed8d48f51816812687 (patch)
treeb866d77ae82d55261e22496bad82d5e88d407090 /Source/Core/VideoCommon/VertexLoader.cpp
parentb7ba3f56318f95d3bf13464bdf6f3ed916b3793f (diff)
parent69cf8b3470d4c7009b8f1bfc2014d2b853e08be0 (diff)
Merge pull request #12324 from Pokechu22/vertex-loader-dummy-tex-coords
VertexLoader: Fixes and cleanup related to skipped components
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoader.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoader.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp
index c2d3c1bd29..402a5efaf8 100644
--- a/Source/Core/VideoCommon/VertexLoader.cpp
+++ b/Source/Core/VideoCommon/VertexLoader.cpp
@@ -77,9 +77,6 @@ VertexLoader::VertexLoader(const TVtxDesc& vtx_desc, const VAT& vtx_attr)
void VertexLoader::CompileVertexTranslator()
{
- // Reset pipeline
- m_numPipelineStages = 0;
-
// Position in pc vertex format.
int nat_offset = 0;
@@ -149,9 +146,16 @@ void VertexLoader::CompileVertexTranslator()
VertexLoader_Color::GetFunction(m_VtxDesc.low.Color[i], m_VtxAttr.GetColorFormat(i));
if (pFunc != nullptr)
+ {
WriteCall(pFunc);
+ }
else
+ {
ASSERT(m_VtxDesc.low.Color[i] == VertexComponentFormat::NotPresent);
+ // Keep colIndex in sync if color 0 is absent but color 1 is present
+ if (i == 0 && m_VtxDesc.low.Color[1] != VertexComponentFormat::NotPresent)
+ WriteCall(VertexLoader_Color::GetDummyFunction());
+ }
if (m_VtxDesc.low.Color[i] != VertexComponentFormat::NotPresent)
{
@@ -213,12 +217,13 @@ void VertexLoader::CompileVertexTranslator()
{
// if there's more tex coords later, have to write a dummy call
bool has_more = false;
- for (size_t j = 0; j < m_VtxDesc.high.TexCoord.Size(); ++j)
+ for (size_t j = i + 1; j < m_VtxDesc.high.TexCoord.Size(); ++j)
{
if (m_VtxDesc.high.TexCoord[j] != VertexComponentFormat::NotPresent)
{
has_more = true;
- WriteCall(VertexLoader_TextCoord::GetDummyFunction()); // important to get indices right!
+ // Keep tcIndex in sync so that the correct array is used later
+ WriteCall(VertexLoader_TextCoord::GetDummyFunction());
break;
}
else if (m_VtxDesc.low.TexMatIdx[j])
@@ -245,7 +250,7 @@ void VertexLoader::CompileVertexTranslator()
void VertexLoader::WriteCall(TPipelineFunction func)
{
- m_PipelineStages[m_numPipelineStages++] = func;
+ m_PipelineStages.push_back(func);
}
int VertexLoader::RunVertices(const u8* src, u8* dst, int count)
@@ -261,8 +266,8 @@ int VertexLoader::RunVertices(const u8* src, u8* dst, int count)
m_tcIndex = 0;
m_colIndex = 0;
m_texmtxwrite = m_texmtxread = 0;
- for (int i = 0; i < m_numPipelineStages; i++)
- m_PipelineStages[i](this);
+ for (TPipelineFunction& func : m_PipelineStages)
+ func(this);
PRIM_LOG("\n");
}