summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/VertexLoader.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2013-03-04 15:24:39 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2013-03-04 15:35:29 -0600
commitbf58c70e9b5a16c56113fe5114a845f8000d4a9d (patch)
treeb6900b7b9d3dd049a4cf48298d7fddfef1806b75 /Source/Core/VideoCommon/Src/VertexLoader.cpp
parent6b80e6f83cf4557eff89402484c1d5b2f5606a5f (diff)
Move copy-pasted code into function.
Diffstat (limited to 'Source/Core/VideoCommon/Src/VertexLoader.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoader.cpp69
1 files changed, 16 insertions, 53 deletions
diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp
index ca128b4f86..bbee1c0411 100644
--- a/Source/Core/VideoCommon/Src/VertexLoader.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp
@@ -517,7 +517,7 @@ void VertexLoader::WriteSetVariable(int bits, void *address, OpArg value)
#endif
}
-void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int const count)
+int VertexLoader::SetupRunVertices(int vtx_attr_group, int primitive, int const count)
{
m_numLoadedVertices += count;
@@ -536,7 +536,7 @@ void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int const coun
{
// if cull mode is none, ignore triangles and quads
DataSkip(count * m_VertexSize);
- return;
+ return 0;
}
m_NativeFmt->EnableComponents(m_NativeFmt->m_components);
@@ -561,8 +561,15 @@ void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int const coun
colElements[i] = m_VtxAttr.color[i].Elements;
VertexManager::PrepareForAdditionalData(primitive, count, native_stride);
- ConvertVertices(count);
- VertexManager::AddVertices(primitive, count);
+
+ return count;
+}
+
+void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int const count)
+{
+ auto const new_count = SetupRunVertices(vtx_attr_group, primitive, count);
+ ConvertVertices(new_count);
+ VertexManager::AddVertices(primitive, new_count);
}
void VertexLoader::ConvertVertices ( int count )
@@ -585,59 +592,15 @@ void VertexLoader::ConvertVertices ( int count )
#endif
}
-
-
-
void VertexLoader::RunCompiledVertices(int vtx_attr_group, int primitive, int const count, u8* Data)
{
- m_numLoadedVertices += count;
-
- // Flush if our vertex format is different from the currently set.
- if (g_nativeVertexFmt != NULL && g_nativeVertexFmt != m_NativeFmt)
- {
- // We really must flush here. It's possible that the native representations
- // of the two vtx formats are the same, but we have no way to easily check that
- // now.
- VertexManager::Flush();
- // Also move the Set() here?
- }
- g_nativeVertexFmt = m_NativeFmt;
-
- if (bpmem.genMode.cullmode == 3 && primitive < 5)
- {
- // if cull mode is none, ignore triangles and quads
- DataSkip(count * m_VertexSize);
- return;
- }
-
- m_NativeFmt->EnableComponents(m_NativeFmt->m_components);
-
- // Load position and texcoord scale factors.
- m_VtxAttr.PosFrac = g_VtxAttr[vtx_attr_group].g0.PosFrac;
- m_VtxAttr.texCoord[0].Frac = g_VtxAttr[vtx_attr_group].g0.Tex0Frac;
- m_VtxAttr.texCoord[1].Frac = g_VtxAttr[vtx_attr_group].g1.Tex1Frac;
- m_VtxAttr.texCoord[2].Frac = g_VtxAttr[vtx_attr_group].g1.Tex2Frac;
- m_VtxAttr.texCoord[3].Frac = g_VtxAttr[vtx_attr_group].g1.Tex3Frac;
- m_VtxAttr.texCoord[4].Frac = g_VtxAttr[vtx_attr_group].g2.Tex4Frac;
- m_VtxAttr.texCoord[5].Frac = g_VtxAttr[vtx_attr_group].g2.Tex5Frac;
- m_VtxAttr.texCoord[6].Frac = g_VtxAttr[vtx_attr_group].g2.Tex6Frac;
- m_VtxAttr.texCoord[7].Frac = g_VtxAttr[vtx_attr_group].g2.Tex7Frac;
-
- pVtxAttr = &m_VtxAttr;
- posScale = fractionTable[m_VtxAttr.PosFrac];
- if (m_NativeFmt->m_components & VB_HAS_UVALL)
- for (int i = 0; i < 8; i++)
- tcScale[i] = fractionTable[m_VtxAttr.texCoord[i].Frac];
- for (int i = 0; i < 2; i++)
- colElements[i] = m_VtxAttr.color[i].Elements;
-
- VertexManager::PrepareForAdditionalData(primitive, count, native_stride);
+ auto const new_count = SetupRunVertices(vtx_attr_group, primitive, count);
- memcpy_gc(VertexManager::s_pCurBufferPointer, Data, native_stride * count);
- VertexManager::s_pCurBufferPointer += native_stride * count;
- DataSkip(count * m_VertexSize);
+ memcpy_gc(VertexManager::s_pCurBufferPointer, Data, native_stride * new_count);
+ VertexManager::s_pCurBufferPointer += native_stride * new_count;
+ DataSkip(new_count * m_VertexSize);
- VertexManager::AddVertices(primitive, count);
+ VertexManager::AddVertices(primitive, new_count);
}
void VertexLoader::SetVAT(u32 _group0, u32 _group1, u32 _group2)