VideoCommon: VertexManager -> VertexManagerBase

It may be a bit weird to see calls to static functions in
VertexManagerBase now, but at least it's easier to see what's going on.
This commit is contained in:
Tillmann Karras 2015-11-01 22:54:41 +01:00
parent 89f6451513
commit c52c73f762
10 changed files with 43 additions and 43 deletions

View File

@ -9,7 +9,7 @@
namespace DX11 namespace DX11
{ {
class VertexManager : public ::VertexManager class VertexManager : public VertexManagerBase
{ {
public: public:
VertexManager(); VertexManager();

View File

@ -26,7 +26,7 @@ namespace OGL
// Handles the OpenGL details of drawing lots of vertices quickly. // Handles the OpenGL details of drawing lots of vertices quickly.
// Other functionality is moving out. // Other functionality is moving out.
class VertexManager : public ::VertexManager class VertexManager : public VertexManagerBase
{ {
public: public:
VertexManager(); VertexManager();

View File

@ -23,7 +23,7 @@ namespace BPFunctions
void FlushPipeline() void FlushPipeline()
{ {
VertexManager::Flush(); VertexManagerBase::Flush();
} }
void SetGenerationMode() void SetGenerationMode()

View File

@ -367,7 +367,7 @@ void RunGpuLoop()
// The fifo is empty and it's unlikely we will get any more work in the near future. // The fifo is empty and it's unlikely we will get any more work in the near future.
// Make sure VertexManager finishes drawing any primitives it has stored in it's buffer. // Make sure VertexManager finishes drawing any primitives it has stored in it's buffer.
VertexManager::Flush(); VertexManagerBase::Flush();
} }
}, 100); }, 100);

View File

@ -188,7 +188,7 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
if (loader->m_native_vertex_format != s_current_vtx_fmt || if (loader->m_native_vertex_format != s_current_vtx_fmt ||
loader->m_native_components != g_current_components) loader->m_native_components != g_current_components)
{ {
VertexManager::Flush(); VertexManagerBase::Flush();
} }
s_current_vtx_fmt = loader->m_native_vertex_format; s_current_vtx_fmt = loader->m_native_vertex_format;
g_current_components = loader->m_native_components; g_current_components = loader->m_native_components;
@ -197,14 +197,14 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
// They still need to go through vertex loading, because we need to calculate a zfreeze refrence slope. // They still need to go through vertex loading, because we need to calculate a zfreeze refrence slope.
bool cullall = (bpmem.genMode.cullmode == GenMode::CULL_ALL && primitive < 5); bool cullall = (bpmem.genMode.cullmode == GenMode::CULL_ALL && primitive < 5);
DataReader dst = VertexManager::PrepareForAdditionalData(primitive, count, DataReader dst = VertexManagerBase::PrepareForAdditionalData(primitive, count,
loader->m_native_vtx_decl.stride, cullall); loader->m_native_vtx_decl.stride, cullall);
count = loader->RunVertices(src, dst, count); count = loader->RunVertices(src, dst, count);
IndexGenerator::AddIndices(primitive, count); IndexGenerator::AddIndices(primitive, count);
VertexManager::FlushData(count, loader->m_native_vtx_decl.stride); VertexManagerBase::FlushData(count, loader->m_native_vtx_decl.stride);
ADDSTAT(stats.thisFrame.numPrims, count); ADDSTAT(stats.thisFrame.numPrims, count);
INCSTAT(stats.thisFrame.numPrimitiveJoins); INCSTAT(stats.thisFrame.numPrimitiveJoins);

View File

@ -22,18 +22,18 @@
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
#include "VideoCommon/XFMemory.h" #include "VideoCommon/XFMemory.h"
VertexManager *g_vertex_manager; VertexManagerBase* g_vertex_manager;
u8 *VertexManager::s_pCurBufferPointer; u8* VertexManagerBase::s_pCurBufferPointer;
u8 *VertexManager::s_pBaseBufferPointer; u8* VertexManagerBase::s_pBaseBufferPointer;
u8 *VertexManager::s_pEndBufferPointer; u8* VertexManagerBase::s_pEndBufferPointer;
PrimitiveType VertexManager::current_primitive_type; PrimitiveType VertexManagerBase::current_primitive_type;
Slope VertexManager::s_zslope; Slope VertexManagerBase::s_zslope;
bool VertexManager::s_is_flushed; bool VertexManagerBase::s_is_flushed;
bool VertexManager::s_cull_all; bool VertexManagerBase::s_cull_all;
static const PrimitiveType primitive_from_gx[8] = { static const PrimitiveType primitive_from_gx[8] = {
PRIMITIVE_TRIANGLES, // GX_DRAW_QUADS PRIMITIVE_TRIANGLES, // GX_DRAW_QUADS
@ -46,22 +46,22 @@ static const PrimitiveType primitive_from_gx[8] = {
PRIMITIVE_POINTS, // GX_DRAW_POINTS PRIMITIVE_POINTS, // GX_DRAW_POINTS
}; };
VertexManager::VertexManager() VertexManagerBase::VertexManagerBase()
{ {
s_is_flushed = true; s_is_flushed = true;
s_cull_all = false; s_cull_all = false;
} }
VertexManager::~VertexManager() VertexManagerBase::~VertexManagerBase()
{ {
} }
u32 VertexManager::GetRemainingSize() u32 VertexManagerBase::GetRemainingSize()
{ {
return (u32)(s_pEndBufferPointer - s_pCurBufferPointer); return (u32)(s_pEndBufferPointer - s_pCurBufferPointer);
} }
DataReader VertexManager::PrepareForAdditionalData(int primitive, u32 count, u32 stride, bool cullall) DataReader VertexManagerBase::PrepareForAdditionalData(int primitive, u32 count, u32 stride, bool cullall)
{ {
// The SSE vertex loader can write up to 4 bytes past the end // The SSE vertex loader can write up to 4 bytes past the end
u32 const needed_vertex_bytes = count * stride + 4; u32 const needed_vertex_bytes = count * stride + 4;
@ -99,12 +99,12 @@ DataReader VertexManager::PrepareForAdditionalData(int primitive, u32 count, u32
return DataReader(s_pCurBufferPointer, s_pEndBufferPointer); return DataReader(s_pCurBufferPointer, s_pEndBufferPointer);
} }
void VertexManager::FlushData(u32 count, u32 stride) void VertexManagerBase::FlushData(u32 count, u32 stride)
{ {
s_pCurBufferPointer += count * stride; s_pCurBufferPointer += count * stride;
} }
u32 VertexManager::GetRemainingIndices(int primitive) u32 VertexManagerBase::GetRemainingIndices(int primitive)
{ {
u32 index_len = MAXIBUFFERSIZE - IndexGenerator::GetIndexLen(); u32 index_len = MAXIBUFFERSIZE - IndexGenerator::GetIndexLen();
@ -162,7 +162,7 @@ u32 VertexManager::GetRemainingIndices(int primitive)
} }
} }
void VertexManager::Flush() void VertexManagerBase::Flush()
{ {
if (s_is_flushed) if (s_is_flushed)
return; return;
@ -270,13 +270,13 @@ void VertexManager::Flush()
s_cull_all = false; s_cull_all = false;
} }
void VertexManager::DoState(PointerWrap& p) void VertexManagerBase::DoState(PointerWrap& p)
{ {
p.Do(s_zslope); p.Do(s_zslope);
g_vertex_manager->vDoState(p); g_vertex_manager->vDoState(p);
} }
void VertexManager::CalculateZSlope(NativeVertexFormat* format) void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format)
{ {
float out[12]; float out[12];
float viewOffset[2] = { xfmem.viewport.xOrig - bpmem.scissorOffset.x * 2, float viewOffset[2] = { xfmem.viewport.xOrig - bpmem.scissorOffset.x * 2,

View File

@ -27,7 +27,7 @@ struct Slope
bool dirty; bool dirty;
}; };
class VertexManager class VertexManagerBase
{ {
private: private:
static const u32 SMALLEST_POSSIBLE_VERTEX = sizeof(float)*3; // 3 pos static const u32 SMALLEST_POSSIBLE_VERTEX = sizeof(float)*3; // 3 pos
@ -41,9 +41,9 @@ public:
// We may convert triangle-fans to triangle-lists, almost 3x as many indices. // We may convert triangle-fans to triangle-lists, almost 3x as many indices.
static const u32 MAXIBUFFERSIZE = ROUND_UP_POW2(MAX_PRIMITIVES_PER_COMMAND * 3); static const u32 MAXIBUFFERSIZE = ROUND_UP_POW2(MAX_PRIMITIVES_PER_COMMAND * 3);
VertexManager(); VertexManagerBase();
// needs to be virtual for DX11's dtor // needs to be virtual for DX11's dtor
virtual ~VertexManager(); virtual ~VertexManagerBase();
static DataReader PrepareForAdditionalData(int primitive, u32 count, u32 stride, bool cullall); static DataReader PrepareForAdditionalData(int primitive, u32 count, u32 stride, bool cullall);
static void FlushData(u32 count, u32 stride); static void FlushData(u32 count, u32 stride);
@ -82,4 +82,4 @@ private:
virtual void DestroyDeviceObjects() {} virtual void DestroyDeviceObjects() {}
}; };
extern VertexManager *g_vertex_manager; extern VertexManagerBase* g_vertex_manager;

View File

@ -657,7 +657,7 @@ void VertexShaderManager::SetTexMatrixChangedA(u32 Value)
{ {
if (g_main_cp_state.matrix_index_a.Hex != Value) if (g_main_cp_state.matrix_index_a.Hex != Value)
{ {
VertexManager::Flush(); VertexManagerBase::Flush();
if (g_main_cp_state.matrix_index_a.PosNormalMtxIdx != (Value & 0x3f)) if (g_main_cp_state.matrix_index_a.PosNormalMtxIdx != (Value & 0x3f))
bPosNormalMatrixChanged = true; bPosNormalMatrixChanged = true;
bTexMatricesChanged[0] = true; bTexMatricesChanged[0] = true;
@ -669,7 +669,7 @@ void VertexShaderManager::SetTexMatrixChangedB(u32 Value)
{ {
if (g_main_cp_state.matrix_index_b.Hex != Value) if (g_main_cp_state.matrix_index_b.Hex != Value)
{ {
VertexManager::Flush(); VertexManagerBase::Flush();
bTexMatricesChanged[1] = true; bTexMatricesChanged[1] = true;
g_main_cp_state.matrix_index_b.Hex = Value; g_main_cp_state.matrix_index_b.Hex = Value;
} }
@ -738,7 +738,7 @@ void VertexShaderManager::TransformToClipSpace(const float* data, float* out, u3
// We use the projection matrix calculated by VertexShaderManager, because it // We use the projection matrix calculated by VertexShaderManager, because it
// includes any free look transformations. // includes any free look transformations.
// Make sure VertexManager::SetConstants() has been called first. // Make sure VertexShaderManager::SetConstants() has been called first.
const float* proj_matrix = &g_fProjectionMatrix[0]; const float* proj_matrix = &g_fProjectionMatrix[0];
const float t[3] = { const float t[3] = {

View File

@ -54,7 +54,7 @@ static void DoState(PointerWrap &p)
GeometryShaderManager::DoState(p); GeometryShaderManager::DoState(p);
p.DoMarker("GeometryShaderManager"); p.DoMarker("GeometryShaderManager");
VertexManager::DoState(p); VertexManagerBase::DoState(p);
p.DoMarker("VertexManager"); p.DoMarker("VertexManager");
BoundingBox::DoState(p); BoundingBox::DoState(p);

View File

@ -16,7 +16,7 @@
static void XFMemWritten(u32 transferSize, u32 baseAddress) static void XFMemWritten(u32 transferSize, u32 baseAddress)
{ {
VertexManager::Flush(); VertexManagerBase::Flush();
VertexShaderManager::InvalidateXFRange(baseAddress, baseAddress + transferSize); VertexShaderManager::InvalidateXFRange(baseAddress, baseAddress + transferSize);
} }
@ -52,7 +52,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case XFMEM_SETNUMCHAN: case XFMEM_SETNUMCHAN:
if (xfmem.numChan.numColorChans != (newValue & 3)) if (xfmem.numChan.numColorChans != (newValue & 3))
VertexManager::Flush(); VertexManagerBase::Flush();
break; break;
case XFMEM_SETCHAN0_AMBCOLOR: // Channel Ambient Color case XFMEM_SETCHAN0_AMBCOLOR: // Channel Ambient Color
@ -61,7 +61,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
u8 chan = address - XFMEM_SETCHAN0_AMBCOLOR; u8 chan = address - XFMEM_SETCHAN0_AMBCOLOR;
if (xfmem.ambColor[chan] != newValue) if (xfmem.ambColor[chan] != newValue)
{ {
VertexManager::Flush(); VertexManagerBase::Flush();
VertexShaderManager::SetMaterialColorChanged(chan); VertexShaderManager::SetMaterialColorChanged(chan);
} }
break; break;
@ -73,7 +73,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
u8 chan = address - XFMEM_SETCHAN0_MATCOLOR; u8 chan = address - XFMEM_SETCHAN0_MATCOLOR;
if (xfmem.matColor[chan] != newValue) if (xfmem.matColor[chan] != newValue)
{ {
VertexManager::Flush(); VertexManagerBase::Flush();
VertexShaderManager::SetMaterialColorChanged(chan + 2); VertexShaderManager::SetMaterialColorChanged(chan + 2);
} }
break; break;
@ -84,12 +84,12 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case XFMEM_SETCHAN0_ALPHA: // Channel Alpha case XFMEM_SETCHAN0_ALPHA: // Channel Alpha
case XFMEM_SETCHAN1_ALPHA: case XFMEM_SETCHAN1_ALPHA:
if (((u32*)&xfmem)[address] != (newValue & 0x7fff)) if (((u32*)&xfmem)[address] != (newValue & 0x7fff))
VertexManager::Flush(); VertexManagerBase::Flush();
break; break;
case XFMEM_DUALTEX: case XFMEM_DUALTEX:
if (xfmem.dualTexTrans.enabled != (newValue & 1)) if (xfmem.dualTexTrans.enabled != (newValue & 1))
VertexManager::Flush(); VertexManagerBase::Flush();
break; break;
@ -108,7 +108,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case XFMEM_SETVIEWPORT+3: case XFMEM_SETVIEWPORT+3:
case XFMEM_SETVIEWPORT+4: case XFMEM_SETVIEWPORT+4:
case XFMEM_SETVIEWPORT+5: case XFMEM_SETVIEWPORT+5:
VertexManager::Flush(); VertexManagerBase::Flush();
VertexShaderManager::SetViewportChanged(); VertexShaderManager::SetViewportChanged();
PixelShaderManager::SetViewportChanged(); PixelShaderManager::SetViewportChanged();
GeometryShaderManager::SetViewportChanged(); GeometryShaderManager::SetViewportChanged();
@ -123,7 +123,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case XFMEM_SETPROJECTION+4: case XFMEM_SETPROJECTION+4:
case XFMEM_SETPROJECTION+5: case XFMEM_SETPROJECTION+5:
case XFMEM_SETPROJECTION+6: case XFMEM_SETPROJECTION+6:
VertexManager::Flush(); VertexManagerBase::Flush();
VertexShaderManager::SetProjectionChanged(); VertexShaderManager::SetProjectionChanged();
GeometryShaderManager::SetProjectionChanged(); GeometryShaderManager::SetProjectionChanged();
@ -132,7 +132,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case XFMEM_SETNUMTEXGENS: // GXSetNumTexGens case XFMEM_SETNUMTEXGENS: // GXSetNumTexGens
if (xfmem.numTexGen.numTexGens != (newValue & 15)) if (xfmem.numTexGen.numTexGens != (newValue & 15))
VertexManager::Flush(); VertexManagerBase::Flush();
break; break;
case XFMEM_SETTEXMTXINFO: case XFMEM_SETTEXMTXINFO:
@ -143,7 +143,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case XFMEM_SETTEXMTXINFO+5: case XFMEM_SETTEXMTXINFO+5:
case XFMEM_SETTEXMTXINFO+6: case XFMEM_SETTEXMTXINFO+6:
case XFMEM_SETTEXMTXINFO+7: case XFMEM_SETTEXMTXINFO+7:
VertexManager::Flush(); VertexManagerBase::Flush();
nextAddress = XFMEM_SETTEXMTXINFO + 8; nextAddress = XFMEM_SETTEXMTXINFO + 8;
break; break;
@ -156,7 +156,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case XFMEM_SETPOSMTXINFO+5: case XFMEM_SETPOSMTXINFO+5:
case XFMEM_SETPOSMTXINFO+6: case XFMEM_SETPOSMTXINFO+6:
case XFMEM_SETPOSMTXINFO+7: case XFMEM_SETPOSMTXINFO+7:
VertexManager::Flush(); VertexManagerBase::Flush();
nextAddress = XFMEM_SETPOSMTXINFO + 8; nextAddress = XFMEM_SETPOSMTXINFO + 8;
break; break;