diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index 03f480dac8..a2825da1c7 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -19,6 +19,7 @@ #include "BPMemory.h" #include "DataReader.h" #include "VertexManagerBase.h" +#include "IndexGenerator.h" #include "VertexLoader_Position.h" #include "VertexLoader_Normal.h" @@ -836,7 +837,7 @@ void VertexLoader::WriteSetVariable(int bits, void *address, OpArg value) } #endif -int VertexLoader::SetupRunVertices(int vtx_attr_group, int primitive, int const count) +void VertexLoader::SetupRunVertices(int vtx_attr_group, int primitive, int const count) { m_numLoadedVertices += count; @@ -851,13 +852,6 @@ int VertexLoader::SetupRunVertices(int vtx_attr_group, int primitive, int const } 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 0; - } - // 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; @@ -881,17 +875,6 @@ int VertexLoader::SetupRunVertices(int vtx_attr_group, int primitive, int const s_bbox_primitive = primitive; s_bbox_currPoint = 0; s_bbox_loadedPoints = 0; - - VertexManager::PrepareForAdditionalData(primitive, count, native_stride); - - 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 ) @@ -915,6 +898,23 @@ void VertexLoader::ConvertVertices ( int count ) #endif } +void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int const count) +{ + if (bpmem.genMode.cullmode == 3 && primitive < 5) + { + // if cull mode is none, ignore triangles and quads + DataSkip(count * m_VertexSize); + return; + } + SetupRunVertices(vtx_attr_group, primitive, count); + VertexManager::PrepareForAdditionalData(primitive, count, native_stride); + ConvertVertices(count); + IndexGenerator::AddIndices(primitive, count); + + ADDSTAT(stats.thisFrame.numPrims, count); + INCSTAT(stats.thisFrame.numPrimitiveJoins); +} + void VertexLoader::SetVAT(u32 _group0, u32 _group1, u32 _group2) { VAT vat; diff --git a/Source/Core/VideoCommon/VertexLoader.h b/Source/Core/VideoCommon/VertexLoader.h index 0d950ef0e8..59f94774b8 100644 --- a/Source/Core/VideoCommon/VertexLoader.h +++ b/Source/Core/VideoCommon/VertexLoader.h @@ -95,7 +95,7 @@ public: int GetVertexSize() const {return m_VertexSize;} - int SetupRunVertices(int vtx_attr_group, int primitive, int const count); + void SetupRunVertices(int vtx_attr_group, int primitive, int const count); void RunVertices(int vtx_attr_group, int primitive, int count); // For debugging / profiling diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index de22d1aad6..d1f1acf9a4 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -96,7 +96,7 @@ void MarkAllDirty() s_attr_dirty = 0xff; } -static void RefreshLoader(int vtx_attr_group) +static VertexLoader* RefreshLoader(int vtx_attr_group) { if ((s_attr_dirty >> vtx_attr_group) & 1) { @@ -116,21 +116,27 @@ static void RefreshLoader(int vtx_attr_group) } } s_attr_dirty &= ~(1 << vtx_attr_group); + return g_VertexLoaders[vtx_attr_group]; } void RunVertices(int vtx_attr_group, int primitive, int count) { if (!count) return; + RefreshLoader(vtx_attr_group)->RunVertices(vtx_attr_group, primitive, count); +} - RefreshLoader(vtx_attr_group); - g_VertexLoaders[vtx_attr_group]->RunVertices(vtx_attr_group, primitive, count); +void SkipVertices(int vtx_attr_group, int count) +{ + if (!count) + return; + u32 stride = RefreshLoader(vtx_attr_group)->GetVertexSize(); + DataSkip(count * stride); } int GetVertexSize(int vtx_attr_group) { - RefreshLoader(vtx_attr_group); - return g_VertexLoaders[vtx_attr_group]->GetVertexSize(); + return RefreshLoader(vtx_attr_group)->GetVertexSize(); } } // namespace diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 18a6c81dd6..c4980ae190 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -140,17 +140,6 @@ u32 VertexManager::GetRemainingIndices(int primitive) } } -void VertexManager::AddVertices(int primitive, u32 numVertices) -{ - if (numVertices <= 0) - return; - - ADDSTAT(stats.thisFrame.numPrims, numVertices); - INCSTAT(stats.thisFrame.numPrimitiveJoins); - - IndexGenerator::AddIndices(primitive, numVertices); -} - void VertexManager::Flush() { if (IsFlushed) return; diff --git a/Source/Core/VideoCommon/VertexManagerBase.h b/Source/Core/VideoCommon/VertexManagerBase.h index 1acbfefdf1..83787e57a8 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.h +++ b/Source/Core/VideoCommon/VertexManagerBase.h @@ -32,8 +32,6 @@ public: // needs to be virtual for DX11's dtor virtual ~VertexManager(); - static void AddVertices(int _primitive, u32 _numVertices); - static u8 *s_pCurBufferPointer; static u8 *s_pBaseBufferPointer; static u8 *s_pEndBufferPointer;