VertexLoader: remove inlined getters
They just blow up the code.
This commit is contained in:
parent
6e3b2712d2
commit
a71c8158d9
|
@ -46,7 +46,7 @@ void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
|
|||
m_VertexLoaderMap[uid] = std::unique_ptr<VertexLoader>(m_CurrentLoader);
|
||||
}
|
||||
|
||||
m_VertexSize = m_CurrentLoader->GetVertexSize();
|
||||
m_VertexSize = m_CurrentLoader->m_VertexSize;
|
||||
m_CurrentVat = &g_main_cp_state.vtx_attr[m_attributeIndex];
|
||||
|
||||
|
||||
|
@ -168,7 +168,7 @@ void SWVertexLoader::ParseVertex(const PortableVertexDeclaration& vdec)
|
|||
|
||||
void SWVertexLoader::LoadVertex()
|
||||
{
|
||||
const PortableVertexDeclaration& vdec = m_CurrentLoader->GetNativeVertexDeclaration();
|
||||
const PortableVertexDeclaration& vdec = m_CurrentLoader->m_native_vtx_decl;
|
||||
|
||||
// reserve memory for the destination of the vertex loader
|
||||
m_LoadedVertices.resize(vdec.stride + 4);
|
||||
|
@ -180,7 +180,7 @@ void SWVertexLoader::LoadVertex()
|
|||
DataReader(g_video_buffer_read_ptr, nullptr), // src
|
||||
DataReader(m_LoadedVertices.data(), m_LoadedVertices.data() + m_LoadedVertices.size()) // dst
|
||||
);
|
||||
g_video_buffer_read_ptr = old + m_CurrentLoader->GetVertexSize();
|
||||
g_video_buffer_read_ptr = old + m_CurrentLoader->m_VertexSize;
|
||||
|
||||
// parse the videocommon format to our own struct format (m_Vertex)
|
||||
ParseVertex(vdec);
|
||||
|
|
|
@ -102,32 +102,27 @@ public:
|
|||
VertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr);
|
||||
~VertexLoader();
|
||||
|
||||
int GetVertexSize() const {return m_VertexSize;}
|
||||
u32 GetNativeComponents() const { return m_native_components; }
|
||||
const PortableVertexDeclaration& GetNativeVertexDeclaration() const
|
||||
{ return m_native_vtx_decl; }
|
||||
|
||||
void SetupRunVertices(int primitive, int const count);
|
||||
int RunVertices(int primitive, int count, DataReader src, DataReader dst);
|
||||
|
||||
// For debugging / profiling
|
||||
void AppendToString(std::string *dest) const;
|
||||
int GetNumLoadedVerts() const { return m_numLoadedVertices; }
|
||||
|
||||
NativeVertexFormat* m_native_vertex_format; // used by VertexLoaderManager to cache the NativeVertexFormat objects
|
||||
// per loader public state
|
||||
int m_VertexSize; // number of bytes of a raw GC vertex
|
||||
PortableVertexDeclaration m_native_vtx_decl;
|
||||
u32 m_native_components;
|
||||
|
||||
// used by VertexLoaderManager
|
||||
NativeVertexFormat* m_native_vertex_format;
|
||||
int m_numLoadedVertices;
|
||||
|
||||
private:
|
||||
int m_VertexSize; // number of bytes of a raw GC vertex. Computed by CompileVertexTranslator.
|
||||
|
||||
// GC vertex format
|
||||
TVtxAttr m_VtxAttr; // VAT decoded into easy format
|
||||
TVtxDesc m_VtxDesc; // Not really used currently - or well it is, but could be easily avoided.
|
||||
VAT m_vat;
|
||||
|
||||
// PC vertex format
|
||||
u32 m_native_components;
|
||||
PortableVertexDeclaration m_native_vtx_decl;
|
||||
|
||||
#ifndef USE_VERTEX_LOADER_JIT
|
||||
// Pipeline.
|
||||
TPipelineFunction m_PipelineStages[64]; // TODO - figure out real max. it's lower.
|
||||
|
@ -136,9 +131,6 @@ private:
|
|||
|
||||
const u8 *m_compiledCode;
|
||||
|
||||
int m_numLoadedVertices;
|
||||
|
||||
|
||||
void SetVAT(const VAT& vat);
|
||||
|
||||
void CompileVertexTranslator();
|
||||
|
|
|
@ -75,7 +75,7 @@ void AppendListToString(std::string *dest)
|
|||
{
|
||||
entry e;
|
||||
map_entry.second->AppendToString(&e.text);
|
||||
e.num_verts = map_entry.second->GetNumLoadedVerts();
|
||||
e.num_verts = map_entry.second->m_numLoadedVertices;
|
||||
entries.push_back(e);
|
||||
total_size += e.text.size() + 1;
|
||||
}
|
||||
|
@ -111,14 +111,14 @@ static VertexLoader* RefreshLoader(int vtx_attr_group, CPState* state)
|
|||
s_vertex_loader_map[uid] = std::unique_ptr<VertexLoader>(loader);
|
||||
|
||||
// search for a cached native vertex format
|
||||
const PortableVertexDeclaration& format = loader->GetNativeVertexDeclaration();
|
||||
const PortableVertexDeclaration& format = loader->m_native_vtx_decl;
|
||||
auto& native = s_native_vertex_map[format];
|
||||
if (!native)
|
||||
{
|
||||
auto raw_pointer = g_vertex_manager->CreateNativeVertexFormat();
|
||||
native = std::unique_ptr<NativeVertexFormat>(raw_pointer);
|
||||
native->Initialize(format);
|
||||
native->m_components = loader->GetNativeComponents();
|
||||
native->m_components = loader->m_native_components;
|
||||
}
|
||||
loader->m_native_vertex_format = native.get();
|
||||
|
||||
|
@ -141,7 +141,7 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
|
|||
|
||||
VertexLoader* loader = RefreshLoader(vtx_attr_group, state);
|
||||
|
||||
int size = count * loader->GetVertexSize();
|
||||
int size = count * loader->m_VertexSize;
|
||||
if ((int)src.size() < size)
|
||||
return -1;
|
||||
|
||||
|
@ -157,13 +157,13 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
|
|||
s_current_vtx_fmt = loader->m_native_vertex_format;
|
||||
|
||||
DataReader dst = VertexManager::PrepareForAdditionalData(primitive, count,
|
||||
loader->GetNativeVertexDeclaration().stride);
|
||||
loader->m_native_vtx_decl.stride);
|
||||
|
||||
count = loader->RunVertices(primitive, count, src, dst);
|
||||
|
||||
IndexGenerator::AddIndices(primitive, count);
|
||||
|
||||
VertexManager::FlushData(count, loader->GetNativeVertexDeclaration().stride);
|
||||
VertexManager::FlushData(count, loader->m_native_vtx_decl.stride);
|
||||
|
||||
ADDSTAT(stats.thisFrame.numPrims, count);
|
||||
INCSTAT(stats.thisFrame.numPrimitiveJoins);
|
||||
|
@ -172,7 +172,7 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
|
|||
|
||||
int GetVertexSize(int vtx_attr_group, bool preprocess)
|
||||
{
|
||||
return RefreshLoader(vtx_attr_group, preprocess ? &g_preprocess_cp_state : &g_main_cp_state)->GetVertexSize();
|
||||
return RefreshLoader(vtx_attr_group, preprocess ? &g_preprocess_cp_state : &g_main_cp_state)->m_VertexSize;
|
||||
}
|
||||
|
||||
NativeVertexFormat* GetCurrentVertexFormat()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <set>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "VideoCommon/DataReader.h"
|
||||
|
@ -10,7 +10,7 @@
|
|||
|
||||
TEST(VertexLoaderUID, UniqueEnough)
|
||||
{
|
||||
std::set<VertexLoaderUID> uids;
|
||||
std::unordered_set<VertexLoaderUID> uids;
|
||||
|
||||
TVtxDesc vtx_desc;
|
||||
memset(&vtx_desc, 0, sizeof (vtx_desc));
|
||||
|
@ -95,8 +95,8 @@ TEST_F(VertexLoaderTest, PositionDirectFloatXYZ)
|
|||
|
||||
VertexLoader* loader = new VertexLoader(m_vtx_desc, m_vtx_attr);
|
||||
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader->GetNativeVertexDeclaration().stride);
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader->GetVertexSize());
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader->m_native_vtx_decl.stride);
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader->m_VertexSize);
|
||||
|
||||
// Write some vertices.
|
||||
Input(0.0f); Input(0.0f); Input(0.0f);
|
||||
|
@ -106,8 +106,8 @@ TEST_F(VertexLoaderTest, PositionDirectFloatXYZ)
|
|||
|
||||
// Convert 4 points. "7" -> primitive are points.
|
||||
int count = loader->RunVertices(7, 4, src, dst);
|
||||
src.Skip(4 * loader->GetVertexSize());
|
||||
dst.Skip(count * loader->GetNativeVertexDeclaration().stride);
|
||||
src.Skip(4 * loader->m_VertexSize);
|
||||
dst.Skip(count * loader->m_native_vtx_decl.stride);
|
||||
delete loader;
|
||||
|
||||
ExpectOut(0.0f); ExpectOut(0.0f); ExpectOut(0.0f);
|
||||
|
@ -120,8 +120,8 @@ TEST_F(VertexLoaderTest, PositionDirectFloatXYZ)
|
|||
m_vtx_attr.g0.PosFrac = 1;
|
||||
loader = new VertexLoader(m_vtx_desc, m_vtx_attr);
|
||||
count = loader->RunVertices(7, 1, src, dst);
|
||||
src.Skip(1 * loader->GetVertexSize());
|
||||
dst.Skip(count * loader->GetNativeVertexDeclaration().stride);
|
||||
src.Skip(1 * loader->m_VertexSize);
|
||||
dst.Skip(count * loader->m_native_vtx_decl.stride);
|
||||
ExpectOut(1.0f); ExpectOut(2.0f); ExpectOut(4.0f);
|
||||
delete loader;
|
||||
}
|
||||
|
@ -134,8 +134,8 @@ TEST_F(VertexLoaderTest, PositionDirectU16XY)
|
|||
|
||||
VertexLoader* loader = new VertexLoader(m_vtx_desc, m_vtx_attr);
|
||||
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader->GetNativeVertexDeclaration().stride);
|
||||
ASSERT_EQ(2 * sizeof (u16), (u32)loader->GetVertexSize());
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader->m_native_vtx_decl.stride);
|
||||
ASSERT_EQ(2 * sizeof (u16), (u32)loader->m_VertexSize);
|
||||
|
||||
// Write some vertices.
|
||||
Input<u16>(0); Input<u16>(0);
|
||||
|
@ -146,8 +146,8 @@ TEST_F(VertexLoaderTest, PositionDirectU16XY)
|
|||
|
||||
// Convert 5 points. "7" -> primitive are points.
|
||||
int count = loader->RunVertices(7, 5, src, dst);
|
||||
src.Skip(5 * loader->GetVertexSize());
|
||||
dst.Skip(count * loader->GetNativeVertexDeclaration().stride);
|
||||
src.Skip(5 * loader->m_VertexSize);
|
||||
dst.Skip(count * loader->m_native_vtx_decl.stride);
|
||||
delete loader;
|
||||
|
||||
ExpectOut(0.0f); ExpectOut(0.0f); ExpectOut(0.0f);
|
||||
|
@ -161,8 +161,8 @@ TEST_F(VertexLoaderTest, PositionDirectU16XY)
|
|||
m_vtx_attr.g0.PosFrac = 1;
|
||||
loader = new VertexLoader(m_vtx_desc, m_vtx_attr);
|
||||
count = loader->RunVertices(7, 1, src, dst);
|
||||
src.Skip(1 * loader->GetVertexSize());
|
||||
dst.Skip(count * loader->GetNativeVertexDeclaration().stride);
|
||||
src.Skip(1 * loader->m_VertexSize);
|
||||
dst.Skip(count * loader->m_native_vtx_decl.stride);
|
||||
ExpectOut(21.0f); ExpectOut(12.0f); ExpectOut(0.0f);
|
||||
delete loader;
|
||||
}
|
||||
|
@ -175,15 +175,15 @@ TEST_F(VertexLoaderTest, PositionDirectFloatXYZSpeed)
|
|||
|
||||
VertexLoader loader(m_vtx_desc, m_vtx_attr);
|
||||
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader.GetNativeVertexDeclaration().stride);
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader.GetVertexSize());
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader.m_native_vtx_decl.stride);
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader.m_VertexSize);
|
||||
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
ResetPointers();
|
||||
int count = loader.RunVertices(7, 100000, src, dst);
|
||||
src.Skip(100000 * loader.GetVertexSize());
|
||||
dst.Skip(count * loader.GetNativeVertexDeclaration().stride);
|
||||
src.Skip(100000 * loader.m_VertexSize);
|
||||
dst.Skip(count * loader.m_native_vtx_decl.stride);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,15 +195,15 @@ TEST_F(VertexLoaderTest, PositionDirectU16XYSpeed)
|
|||
|
||||
VertexLoader loader(m_vtx_desc, m_vtx_attr);
|
||||
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader.GetNativeVertexDeclaration().stride);
|
||||
ASSERT_EQ(2 * sizeof (u16), (u32)loader.GetVertexSize());
|
||||
ASSERT_EQ(3 * sizeof (float), (u32)loader.m_native_vtx_decl.stride);
|
||||
ASSERT_EQ(2 * sizeof (u16), (u32)loader.m_VertexSize);
|
||||
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
ResetPointers();
|
||||
int count = loader.RunVertices(7, 100000, src, dst);
|
||||
src.Skip(100000 * loader.GetVertexSize());
|
||||
dst.Skip(count * loader.GetNativeVertexDeclaration().stride);
|
||||
src.Skip(100000 * loader.m_VertexSize);
|
||||
dst.Skip(count * loader.m_native_vtx_decl.stride);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ TEST_F(VertexLoaderTest, LargeFloatVertexSpeed)
|
|||
{
|
||||
ResetPointers();
|
||||
int count = loader.RunVertices(7, 100000, src, dst);
|
||||
src.Skip(100000 * loader.GetVertexSize());
|
||||
dst.Skip(count * loader.GetNativeVertexDeclaration().stride);
|
||||
src.Skip(100000 * loader.m_VertexSize);
|
||||
dst.Skip(count * loader.m_native_vtx_decl.stride);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue