Skip to content

Commit

Permalink
Merge pull request #1713 from degasus/vertex-loader
Browse files Browse the repository at this point in the history
virtual vertex loader
  • Loading branch information
Sonicadvance1 committed Dec 22, 2014
2 parents a00aa1a + 1efd002 commit 5af426d
Show file tree
Hide file tree
Showing 24 changed files with 625 additions and 538 deletions.
1 change: 0 additions & 1 deletion Source/Core/VideoBackends/OGL/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/PixelEngine.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexShaderGen.h"
#include "VideoCommon/VertexShaderManager.h"
Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoBackends/OGL/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Make AA apply instantly during gameplay if possible
#include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/PixelEngine.h"
#include "VideoCommon/PixelShaderManager.h"
#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoConfig.h"
Expand Down
8 changes: 0 additions & 8 deletions Source/Core/VideoBackends/Software/NativeVertexFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
#include "Common/ChunkFile.h"
#include "VideoBackends/Software/Vec3.h"

#ifdef WIN32
#define LOADERDECL __cdecl
#else
#define LOADERDECL
#endif

typedef void (LOADERDECL *TPipelineFunction)();

struct Vec4
{
float x;
Expand Down
20 changes: 8 additions & 12 deletions Source/Core/VideoBackends/Software/SWVertexLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@
#include "VideoBackends/Software/TransformUnit.h"
#include "VideoBackends/Software/XFMemLoader.h"

#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoader_Color.h"
#include "VideoCommon/VertexLoader_Normal.h"
#include "VideoCommon/VertexLoader_Position.h"
#include "VideoCommon/VertexLoader_TextCoord.h"
#include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VertexLoaderBase.h"
#include "VideoCommon/VertexLoaderUtils.h"

SWVertexLoader::SWVertexLoader() :
m_VertexSize(0)
Expand All @@ -42,11 +38,11 @@ void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)

if (!m_CurrentLoader)
{
m_CurrentLoader = new VertexLoader(g_main_cp_state.vtx_desc, g_main_cp_state.vtx_attr[m_attributeIndex]);
m_VertexLoaderMap[uid] = std::unique_ptr<VertexLoader>(m_CurrentLoader);
m_CurrentLoader = VertexLoaderBase::CreateVertexLoader(g_main_cp_state.vtx_desc, g_main_cp_state.vtx_attr[m_attributeIndex]);
m_VertexLoaderMap[uid] = std::unique_ptr<VertexLoaderBase>(m_CurrentLoader);
}

m_VertexSize = m_CurrentLoader->GetVertexSize();
m_VertexSize = m_CurrentLoader->m_VertexSize;
m_CurrentVat = &g_main_cp_state.vtx_attr[m_attributeIndex];


Expand Down Expand Up @@ -168,19 +164,19 @@ 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);

// convert the vertex from the gc format to the videocommon (hardware optimized) format
u8* old = g_video_buffer_read_ptr;
m_CurrentLoader->RunVertices(
g_main_cp_state.vtx_attr[m_attributeIndex], m_primitiveType, 1,
m_primitiveType, 1,
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);
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/VideoBackends/Software/SWVertexLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "VideoBackends/Software/CPMemLoader.h"
#include "VideoBackends/Software/NativeVertexFormat.h"

#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoaderBase.h"

class PointerWrap;
class SetupUnit;
Expand All @@ -28,9 +28,9 @@ class SWVertexLoader

bool m_TexGenSpecialCase;

std::map<VertexLoaderUID, std::unique_ptr<VertexLoader>> m_VertexLoaderMap;
std::unordered_map<VertexLoaderUID, std::unique_ptr<VertexLoaderBase>> m_VertexLoaderMap;
std::vector<u8> m_LoadedVertices;
VertexLoader* m_CurrentLoader;
VertexLoaderBase* m_CurrentLoader;

u8 m_attributeIndex;
u8 m_primitiveType;
Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoCommon/BPStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/TextureDecoder.h"
#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h"
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/BoundingBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static TVtxDesc vertexDesc;
static PortableVertexDeclaration vertexDecl;

// Gets the pointer to the current buffer position
void LOADERDECL SetVertexBufferPosition()
void LOADERDECL SetVertexBufferPosition(VertexLoader* loader)
{
bufferPos = g_vertex_manager_write_ptr;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ void Prepare(const VAT & vat, int primitive, const TVtxDesc & vtxDesc, const Por
}

// Updates the bounding box
void LOADERDECL Update()
void LOADERDECL Update(VertexLoader* loader)
{
if (!active)
return;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/BoundingBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ extern u8 posMtxIdx;
// Texture matrix indexes
extern u8 texMtxIdx[8];

void LOADERDECL SetVertexBufferPosition();
void LOADERDECL Update();
void LOADERDECL SetVertexBufferPosition(VertexLoader* loader);
void LOADERDECL Update(VertexLoader* loader);
void Prepare(const VAT & vat, int primitive, const TVtxDesc & vtxDesc, const PortableVertexDeclaration & vtxDecl);

// Save state
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(SRCS BoundingBox.cpp
TextureConversionShader.cpp
TextureDecoder_Common.cpp
VertexLoader.cpp
VertexLoaderBase.cpp
VertexLoaderManager.cpp
VertexLoader_Color.cpp
VertexLoader_Normal.cpp
Expand Down
11 changes: 2 additions & 9 deletions Source/Core/VideoCommon/CPMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ enum
FORMAT_32B_8888 = 5,
};

enum
{
VAT_0_FRACBITS = 0x3e0001f0,
VAT_1_FRACBITS = 0x07c3e1f0,
VAT_2_FRACBITS = 0xf87c3e1f,
};

#pragma pack(4)
union TVtxDesc
{
Expand Down Expand Up @@ -239,7 +232,7 @@ struct VAT
UVAT_group2 g2;
};

class VertexLoader;
class VertexLoaderBase;

// STATE_TO_SAVE
struct CPState final
Expand All @@ -254,7 +247,7 @@ struct CPState final

// Attributes that actually belong to VertexLoaderManager:
BitSet32 attr_dirty;
VertexLoader* vertex_loaders[8];
VertexLoaderBase* vertex_loaders[8];
};

class PointerWrap;
Expand Down
8 changes: 0 additions & 8 deletions Source/Core/VideoCommon/NativeVertexFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ enum
VB_HAS_UVTEXMTXSHIFT=13,
};

#ifdef WIN32
#define LOADERDECL __cdecl
#else
#define LOADERDECL
#endif

typedef void (LOADERDECL *TPipelineFunction)();

enum VarType
{
VAR_UNSIGNED_BYTE, // GX_U8 = 0
Expand Down
Loading

0 comments on commit 5af426d

Please sign in to comment.