VideoCommon: small VertexLoader(Manager)? refactoring

This commit is contained in:
degasus 2014-01-30 14:48:23 +01:00
parent 010a0d481a
commit 3437c7f060
5 changed files with 31 additions and 38 deletions

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;