mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merged identical VertexManager code from DX9/DX11/OGL plugins into VideoCommon. Still need to merge VertexManager::Flush (will be easier after TextureCache is merged). Purposely using a class/virtualfuncs rather than a namespace so multiple VertexManager can be in one plugin (VideoMergeNew? :p).
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6249 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -32,7 +32,7 @@
|
||||
#include "BPMemory.h"
|
||||
|
||||
#include "VertexLoaderManager.h"
|
||||
#include "NativeVertexWriter.h"
|
||||
#include "VertexManagerBase.h"
|
||||
#include "x64Emitter.h"
|
||||
#include "ABI.h"
|
||||
|
||||
|
@ -29,7 +29,7 @@ files = [
|
||||
'VertexLoader_TextCoord.cpp',
|
||||
'TextureConversionShader.cpp',
|
||||
'ImageWrite.cpp',
|
||||
'NativeVertexWriter.cpp',
|
||||
'VertexManagerBase.cpp',
|
||||
'Statistics.cpp',
|
||||
'Fifo.cpp',
|
||||
'VideoState.cpp',
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "VertexLoader.h"
|
||||
#include "BPMemory.h"
|
||||
#include "DataReader.h"
|
||||
#include "NativeVertexWriter.h"
|
||||
#include "VertexManagerBase.h"
|
||||
|
||||
#include "VertexLoader_Position.h"
|
||||
#include "VertexLoader_Normal.h"
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "LookUpTables.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "VertexLoader_Color.h"
|
||||
#include "NativeVertexWriter.h"
|
||||
#include "VertexManagerBase.h"
|
||||
|
||||
#define RSHIFT 0
|
||||
#define GSHIFT 8
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "VideoCommon.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "VertexLoader_Normal.h"
|
||||
#include "NativeVertexWriter.h"
|
||||
#include "VertexManagerBase.h"
|
||||
#include "CPUDetect.h"
|
||||
|
||||
#if _M_SSE >= 0x301 && !(defined __GNUC__ && !defined __SSSE3__)
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "VideoCommon.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "VertexLoader_Position.h"
|
||||
#include "NativeVertexWriter.h"
|
||||
#include "VertexManagerBase.h"
|
||||
#include "CPUDetect.h"
|
||||
|
||||
#if _M_SSE >= 0x301 && !(defined __GNUC__ && !defined __SSSE3__)
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "VideoCommon.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "VertexLoader_TextCoord.h"
|
||||
#include "NativeVertexWriter.h"
|
||||
#include "VertexManagerBase.h"
|
||||
#include "CPUDetect.h"
|
||||
|
||||
#if _M_SSE >= 0x401
|
||||
|
158
Source/Core/VideoCommon/Src/VertexManagerBase.cpp
Normal file
158
Source/Core/VideoCommon/Src/VertexManagerBase.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include "Statistics.h"
|
||||
#include "OpcodeDecoding.h"
|
||||
#include "IndexGenerator.h"
|
||||
|
||||
#include "VertexManagerBase.h"
|
||||
|
||||
VertexManager *g_vertex_manager;
|
||||
|
||||
u8 *VertexManager::s_pCurBufferPointer;
|
||||
u8 *VertexManager::s_pBaseBufferPointer;
|
||||
|
||||
u8 *VertexManager::LocalVBuffer;
|
||||
u16 *VertexManager::TIBuffer;
|
||||
u16 *VertexManager::LIBuffer;
|
||||
u16 *VertexManager::PIBuffer;
|
||||
|
||||
bool VertexManager::Flushed;
|
||||
|
||||
VertexManager::VertexManager()
|
||||
{
|
||||
Flushed = false;
|
||||
|
||||
LocalVBuffer = new u8[MAXVBUFFERSIZE];
|
||||
s_pCurBufferPointer = s_pBaseBufferPointer = LocalVBuffer;
|
||||
|
||||
TIBuffer = new u16[MAXIBUFFERSIZE];
|
||||
LIBuffer = new u16[MAXIBUFFERSIZE];
|
||||
PIBuffer = new u16[MAXIBUFFERSIZE];
|
||||
|
||||
IndexGenerator::Start(TIBuffer, LIBuffer, PIBuffer);
|
||||
}
|
||||
|
||||
void VertexManager::ResetBuffer()
|
||||
{
|
||||
s_pCurBufferPointer = LocalVBuffer;
|
||||
}
|
||||
|
||||
VertexManager::~VertexManager()
|
||||
{
|
||||
delete[] LocalVBuffer;
|
||||
|
||||
delete[] TIBuffer;
|
||||
delete[] LIBuffer;
|
||||
delete[] PIBuffer;
|
||||
|
||||
// TODO: necessary??
|
||||
ResetBuffer();
|
||||
}
|
||||
|
||||
void VertexManager::AddIndices(int primitive, int numVertices)
|
||||
{
|
||||
//switch (primitive)
|
||||
//{
|
||||
//case GX_DRAW_QUADS: IndexGenerator::AddQuads(numVertices); break;
|
||||
//case GX_DRAW_TRIANGLES: IndexGenerator::AddList(numVertices); break;
|
||||
//case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(numVertices); break;
|
||||
//case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(numVertices); break;
|
||||
//case GX_DRAW_LINES: IndexGenerator::AddLineList(numVertices); break;
|
||||
//case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(numVertices); break;
|
||||
//case GX_DRAW_POINTS: IndexGenerator::AddPoints(numVertices); break;
|
||||
//}
|
||||
|
||||
static void (*const primitive_table[])(int) =
|
||||
{
|
||||
IndexGenerator::AddQuads,
|
||||
NULL,
|
||||
IndexGenerator::AddList,
|
||||
IndexGenerator::AddStrip,
|
||||
IndexGenerator::AddFan,
|
||||
IndexGenerator::AddLineList,
|
||||
IndexGenerator::AddLineStrip,
|
||||
IndexGenerator::AddPoints,
|
||||
};
|
||||
|
||||
primitive_table[primitive](numVertices);
|
||||
}
|
||||
|
||||
int VertexManager::GetRemainingSize()
|
||||
{
|
||||
return MAXVBUFFERSIZE - (int)(s_pCurBufferPointer - LocalVBuffer);
|
||||
}
|
||||
|
||||
int VertexManager::GetRemainingVertices(int primitive)
|
||||
{
|
||||
switch (primitive)
|
||||
{
|
||||
case GX_DRAW_QUADS:
|
||||
case GX_DRAW_TRIANGLES:
|
||||
case GX_DRAW_TRIANGLE_STRIP:
|
||||
case GX_DRAW_TRIANGLE_FAN:
|
||||
return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 3;
|
||||
break;
|
||||
|
||||
case GX_DRAW_LINES:
|
||||
case GX_DRAW_LINE_STRIP:
|
||||
return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen()) / 2;
|
||||
break;
|
||||
|
||||
case GX_DRAW_POINTS:
|
||||
return (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen());
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void VertexManager::AddVertices(int primitive, int numVertices)
|
||||
{
|
||||
if (numVertices <= 0)
|
||||
return;
|
||||
|
||||
switch (primitive)
|
||||
{
|
||||
case GX_DRAW_QUADS:
|
||||
case GX_DRAW_TRIANGLES:
|
||||
case GX_DRAW_TRIANGLE_STRIP:
|
||||
case GX_DRAW_TRIANGLE_FAN:
|
||||
if (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen() < 3 * numVertices)
|
||||
Flush();
|
||||
break;
|
||||
|
||||
case GX_DRAW_LINES:
|
||||
case GX_DRAW_LINE_STRIP:
|
||||
if (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen() < 2 * numVertices)
|
||||
Flush();
|
||||
break;
|
||||
|
||||
case GX_DRAW_POINTS:
|
||||
if (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen() < numVertices)
|
||||
Flush();
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Flushed)
|
||||
{
|
||||
IndexGenerator::Start(TIBuffer, LIBuffer, PIBuffer);
|
||||
Flushed = false;
|
||||
}
|
||||
|
||||
ADDSTAT(stats.thisFrame.numPrims, numVertices);
|
||||
INCSTAT(stats.thisFrame.numPrimitiveJoins);
|
||||
AddIndices(primitive, numVertices);
|
||||
}
|
||||
|
||||
// TODO: merge this func, (need to merge TextureCache)
|
||||
void VertexManager::Flush()
|
||||
{
|
||||
g_vertex_manager->vFlush();
|
||||
}
|
57
Source/Core/VideoCommon/Src/VertexManagerBase.h
Normal file
57
Source/Core/VideoCommon/Src/VertexManagerBase.h
Normal file
@ -0,0 +1,57 @@
|
||||
|
||||
#ifndef _VERTEXMANAGERBASE_H
|
||||
#define _VERTEXMANAGERBASE_H
|
||||
|
||||
class VertexManager
|
||||
{
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
// values from OGL plugin
|
||||
//MAXVBUFFERSIZE = 0x1FFFF,
|
||||
//MAXIBUFFERSIZE = 0xFFFF,
|
||||
|
||||
// values from DX9 plugin
|
||||
//MAXVBUFFERSIZE = 0x50000,
|
||||
//MAXIBUFFERSIZE = 0xFFFF,
|
||||
|
||||
// values from DX11 plugin
|
||||
MAXVBUFFERSIZE = 0x50000,
|
||||
MAXIBUFFERSIZE = 0x10000,
|
||||
};
|
||||
|
||||
VertexManager();
|
||||
virtual ~VertexManager(); // needs to be virtual for DX11's dtor
|
||||
|
||||
static void AddVertices(int _primitive, int _numVertices);
|
||||
|
||||
// TODO: protected?
|
||||
static u8 *s_pCurBufferPointer;
|
||||
static u8 *s_pBaseBufferPointer;
|
||||
|
||||
static int GetRemainingSize();
|
||||
static int GetRemainingVertices(int primitive);
|
||||
|
||||
static void Flush();
|
||||
|
||||
protected:
|
||||
// TODO: make private after Flush() is merged
|
||||
static void ResetBuffer();
|
||||
|
||||
static u8 *LocalVBuffer;
|
||||
static u16 *TIBuffer;
|
||||
static u16 *LIBuffer;
|
||||
static u16 *PIBuffer;
|
||||
|
||||
static bool Flushed;
|
||||
|
||||
private:
|
||||
static void AddIndices(int primitive, int numVertices);
|
||||
// temporary
|
||||
virtual void vFlush() = 0;
|
||||
};
|
||||
|
||||
extern VertexManager *g_vertex_manager;
|
||||
|
||||
#endif
|
@ -30,12 +30,7 @@
|
||||
#include "CPMemory.h"
|
||||
#include "XFMemory.h"
|
||||
#include "VideoCommon.h"
|
||||
|
||||
// Temporary ugly declaration.
|
||||
namespace VertexManager
|
||||
{
|
||||
void Flush();
|
||||
}
|
||||
#include "VertexManagerBase.h"
|
||||
|
||||
static float GC_ALIGNED16(s_fMaterials[16]);
|
||||
float GC_ALIGNED16(g_fProjectionMatrix[16]);
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "VideoCommon.h"
|
||||
#include "XFMemory.h"
|
||||
#include "CPMemory.h"
|
||||
#include "NativeVertexWriter.h"
|
||||
#include "VertexManagerBase.h"
|
||||
#include "VertexShaderManager.h"
|
||||
#include "PixelShaderManager.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Version="9.00"
|
||||
Name="VideoCommon"
|
||||
ProjectGUID="{E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA}"
|
||||
RootNamespace="VideoCommon"
|
||||
@ -562,14 +562,6 @@
|
||||
RelativePath=".\Src\LookUpTables.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\NativeVertexWriter.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\NativeVertexWriter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\OnScreenDisplay.cpp"
|
||||
>
|
||||
@ -735,6 +727,18 @@
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Base"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Src\VertexManagerBase.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\VertexManagerBase.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\Src\CommandProcessor.cpp"
|
||||
>
|
||||
|
Reference in New Issue
Block a user