Move copy-pasted code into function.
This commit is contained in:
parent
6b80e6f83c
commit
bf58c70e9b
|
@ -517,7 +517,7 @@ void VertexLoader::WriteSetVariable(int bits, void *address, OpArg value)
|
||||||
#endif
|
#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;
|
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
|
// if cull mode is none, ignore triangles and quads
|
||||||
DataSkip(count * m_VertexSize);
|
DataSkip(count * m_VertexSize);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_NativeFmt->EnableComponents(m_NativeFmt->m_components);
|
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;
|
colElements[i] = m_VtxAttr.color[i].Elements;
|
||||||
|
|
||||||
VertexManager::PrepareForAdditionalData(primitive, count, native_stride);
|
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 )
|
void VertexLoader::ConvertVertices ( int count )
|
||||||
|
@ -585,59 +592,15 @@ void VertexLoader::ConvertVertices ( int count )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void VertexLoader::RunCompiledVertices(int vtx_attr_group, int primitive, int const count, u8* Data)
|
void VertexLoader::RunCompiledVertices(int vtx_attr_group, int primitive, int const count, u8* Data)
|
||||||
{
|
{
|
||||||
m_numLoadedVertices += count;
|
auto const new_count = SetupRunVertices(vtx_attr_group, primitive, 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);
|
|
||||||
|
|
||||||
memcpy_gc(VertexManager::s_pCurBufferPointer, Data, native_stride * count);
|
memcpy_gc(VertexManager::s_pCurBufferPointer, Data, native_stride * new_count);
|
||||||
VertexManager::s_pCurBufferPointer += native_stride * count;
|
VertexManager::s_pCurBufferPointer += native_stride * new_count;
|
||||||
DataSkip(count * m_VertexSize);
|
DataSkip(new_count * m_VertexSize);
|
||||||
|
|
||||||
VertexManager::AddVertices(primitive, count);
|
VertexManager::AddVertices(primitive, new_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexLoader::SetVAT(u32 _group0, u32 _group1, u32 _group2)
|
void VertexLoader::SetVAT(u32 _group0, u32 _group1, u32 _group2)
|
||||||
|
|
|
@ -83,6 +83,8 @@ public:
|
||||||
~VertexLoader();
|
~VertexLoader();
|
||||||
|
|
||||||
int GetVertexSize() const {return m_VertexSize;}
|
int GetVertexSize() const {return m_VertexSize;}
|
||||||
|
|
||||||
|
int SetupRunVertices(int vtx_attr_group, int primitive, int const count);
|
||||||
void RunVertices(int vtx_attr_group, int primitive, int count);
|
void RunVertices(int vtx_attr_group, int primitive, int count);
|
||||||
void RunCompiledVertices(int vtx_attr_group, int primitive, int count, u8* Data);
|
void RunCompiledVertices(int vtx_attr_group, int primitive, int count, u8* Data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue