From c52c73f7622c4d4b4cbe7506e62c195c940fd61e Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sun, 1 Nov 2015 22:54:41 +0100 Subject: [PATCH 1/2] 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. --- Source/Core/VideoBackends/D3D/VertexManager.h | 2 +- Source/Core/VideoBackends/OGL/VertexManager.h | 2 +- Source/Core/VideoCommon/BPFunctions.cpp | 2 +- Source/Core/VideoCommon/Fifo.cpp | 2 +- .../Core/VideoCommon/VertexLoaderManager.cpp | 6 ++-- Source/Core/VideoCommon/VertexManagerBase.cpp | 34 +++++++++---------- Source/Core/VideoCommon/VertexManagerBase.h | 8 ++--- .../Core/VideoCommon/VertexShaderManager.cpp | 6 ++-- Source/Core/VideoCommon/VideoState.cpp | 2 +- Source/Core/VideoCommon/XFStructs.cpp | 22 ++++++------ 10 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/VertexManager.h b/Source/Core/VideoBackends/D3D/VertexManager.h index 4b54a138bb..d963f81266 100644 --- a/Source/Core/VideoBackends/D3D/VertexManager.h +++ b/Source/Core/VideoBackends/D3D/VertexManager.h @@ -9,7 +9,7 @@ namespace DX11 { -class VertexManager : public ::VertexManager +class VertexManager : public VertexManagerBase { public: VertexManager(); diff --git a/Source/Core/VideoBackends/OGL/VertexManager.h b/Source/Core/VideoBackends/OGL/VertexManager.h index 0d6a1c00c6..11d7e69e48 100644 --- a/Source/Core/VideoBackends/OGL/VertexManager.h +++ b/Source/Core/VideoBackends/OGL/VertexManager.h @@ -26,7 +26,7 @@ namespace OGL // Handles the OpenGL details of drawing lots of vertices quickly. // Other functionality is moving out. -class VertexManager : public ::VertexManager +class VertexManager : public VertexManagerBase { public: VertexManager(); diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp index e4b5f54901..61aa91e63e 100644 --- a/Source/Core/VideoCommon/BPFunctions.cpp +++ b/Source/Core/VideoCommon/BPFunctions.cpp @@ -23,7 +23,7 @@ namespace BPFunctions void FlushPipeline() { - VertexManager::Flush(); + VertexManagerBase::Flush(); } void SetGenerationMode() diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 2395d2b324..21888c0514 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -367,7 +367,7 @@ void RunGpuLoop() // 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. - VertexManager::Flush(); + VertexManagerBase::Flush(); } }, 100); diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index bc4f136500..50f50cb78e 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -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 || loader->m_native_components != g_current_components) { - VertexManager::Flush(); + VertexManagerBase::Flush(); } s_current_vtx_fmt = loader->m_native_vertex_format; 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. 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); count = loader->RunVertices(src, dst, 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); INCSTAT(stats.thisFrame.numPrimitiveJoins); diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 6358ed371c..708462565e 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -22,18 +22,18 @@ #include "VideoCommon/VideoConfig.h" #include "VideoCommon/XFMemory.h" -VertexManager *g_vertex_manager; +VertexManagerBase* g_vertex_manager; -u8 *VertexManager::s_pCurBufferPointer; -u8 *VertexManager::s_pBaseBufferPointer; -u8 *VertexManager::s_pEndBufferPointer; +u8* VertexManagerBase::s_pCurBufferPointer; +u8* VertexManagerBase::s_pBaseBufferPointer; +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 VertexManager::s_cull_all; +bool VertexManagerBase::s_is_flushed; +bool VertexManagerBase::s_cull_all; static const PrimitiveType primitive_from_gx[8] = { PRIMITIVE_TRIANGLES, // GX_DRAW_QUADS @@ -46,22 +46,22 @@ static const PrimitiveType primitive_from_gx[8] = { PRIMITIVE_POINTS, // GX_DRAW_POINTS }; -VertexManager::VertexManager() +VertexManagerBase::VertexManagerBase() { s_is_flushed = true; s_cull_all = false; } -VertexManager::~VertexManager() +VertexManagerBase::~VertexManagerBase() { } -u32 VertexManager::GetRemainingSize() +u32 VertexManagerBase::GetRemainingSize() { 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 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); } -void VertexManager::FlushData(u32 count, u32 stride) +void VertexManagerBase::FlushData(u32 count, u32 stride) { s_pCurBufferPointer += count * stride; } -u32 VertexManager::GetRemainingIndices(int primitive) +u32 VertexManagerBase::GetRemainingIndices(int primitive) { 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) return; @@ -270,13 +270,13 @@ void VertexManager::Flush() s_cull_all = false; } -void VertexManager::DoState(PointerWrap& p) +void VertexManagerBase::DoState(PointerWrap& p) { p.Do(s_zslope); g_vertex_manager->vDoState(p); } -void VertexManager::CalculateZSlope(NativeVertexFormat* format) +void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format) { float out[12]; float viewOffset[2] = { xfmem.viewport.xOrig - bpmem.scissorOffset.x * 2, diff --git a/Source/Core/VideoCommon/VertexManagerBase.h b/Source/Core/VideoCommon/VertexManagerBase.h index 29a9dec5e1..316bcd4123 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.h +++ b/Source/Core/VideoCommon/VertexManagerBase.h @@ -27,7 +27,7 @@ struct Slope bool dirty; }; -class VertexManager +class VertexManagerBase { private: 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. static const u32 MAXIBUFFERSIZE = ROUND_UP_POW2(MAX_PRIMITIVES_PER_COMMAND * 3); - VertexManager(); + VertexManagerBase(); // needs to be virtual for DX11's dtor - virtual ~VertexManager(); + virtual ~VertexManagerBase(); static DataReader PrepareForAdditionalData(int primitive, u32 count, u32 stride, bool cullall); static void FlushData(u32 count, u32 stride); @@ -82,4 +82,4 @@ private: virtual void DestroyDeviceObjects() {} }; -extern VertexManager *g_vertex_manager; +extern VertexManagerBase* g_vertex_manager; diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 8c8f08b154..20b41e194c 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -657,7 +657,7 @@ void VertexShaderManager::SetTexMatrixChangedA(u32 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)) bPosNormalMatrixChanged = true; bTexMatricesChanged[0] = true; @@ -669,7 +669,7 @@ void VertexShaderManager::SetTexMatrixChangedB(u32 Value) { if (g_main_cp_state.matrix_index_b.Hex != Value) { - VertexManager::Flush(); + VertexManagerBase::Flush(); bTexMatricesChanged[1] = true; 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 // 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 t[3] = { diff --git a/Source/Core/VideoCommon/VideoState.cpp b/Source/Core/VideoCommon/VideoState.cpp index 5922bb3905..9f2b11f31c 100644 --- a/Source/Core/VideoCommon/VideoState.cpp +++ b/Source/Core/VideoCommon/VideoState.cpp @@ -54,7 +54,7 @@ static void DoState(PointerWrap &p) GeometryShaderManager::DoState(p); p.DoMarker("GeometryShaderManager"); - VertexManager::DoState(p); + VertexManagerBase::DoState(p); p.DoMarker("VertexManager"); BoundingBox::DoState(p); diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp index 6a517dc0ab..fac5a89053 100644 --- a/Source/Core/VideoCommon/XFStructs.cpp +++ b/Source/Core/VideoCommon/XFStructs.cpp @@ -16,7 +16,7 @@ static void XFMemWritten(u32 transferSize, u32 baseAddress) { - VertexManager::Flush(); + VertexManagerBase::Flush(); VertexShaderManager::InvalidateXFRange(baseAddress, baseAddress + transferSize); } @@ -52,7 +52,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) case XFMEM_SETNUMCHAN: if (xfmem.numChan.numColorChans != (newValue & 3)) - VertexManager::Flush(); + VertexManagerBase::Flush(); break; 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; if (xfmem.ambColor[chan] != newValue) { - VertexManager::Flush(); + VertexManagerBase::Flush(); VertexShaderManager::SetMaterialColorChanged(chan); } break; @@ -73,7 +73,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) u8 chan = address - XFMEM_SETCHAN0_MATCOLOR; if (xfmem.matColor[chan] != newValue) { - VertexManager::Flush(); + VertexManagerBase::Flush(); VertexShaderManager::SetMaterialColorChanged(chan + 2); } break; @@ -84,12 +84,12 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) case XFMEM_SETCHAN0_ALPHA: // Channel Alpha case XFMEM_SETCHAN1_ALPHA: if (((u32*)&xfmem)[address] != (newValue & 0x7fff)) - VertexManager::Flush(); + VertexManagerBase::Flush(); break; case XFMEM_DUALTEX: if (xfmem.dualTexTrans.enabled != (newValue & 1)) - VertexManager::Flush(); + VertexManagerBase::Flush(); break; @@ -108,7 +108,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) case XFMEM_SETVIEWPORT+3: case XFMEM_SETVIEWPORT+4: case XFMEM_SETVIEWPORT+5: - VertexManager::Flush(); + VertexManagerBase::Flush(); VertexShaderManager::SetViewportChanged(); PixelShaderManager::SetViewportChanged(); GeometryShaderManager::SetViewportChanged(); @@ -123,7 +123,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) case XFMEM_SETPROJECTION+4: case XFMEM_SETPROJECTION+5: case XFMEM_SETPROJECTION+6: - VertexManager::Flush(); + VertexManagerBase::Flush(); VertexShaderManager::SetProjectionChanged(); GeometryShaderManager::SetProjectionChanged(); @@ -132,7 +132,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) case XFMEM_SETNUMTEXGENS: // GXSetNumTexGens if (xfmem.numTexGen.numTexGens != (newValue & 15)) - VertexManager::Flush(); + VertexManagerBase::Flush(); break; case XFMEM_SETTEXMTXINFO: @@ -143,7 +143,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) case XFMEM_SETTEXMTXINFO+5: case XFMEM_SETTEXMTXINFO+6: case XFMEM_SETTEXMTXINFO+7: - VertexManager::Flush(); + VertexManagerBase::Flush(); nextAddress = XFMEM_SETTEXMTXINFO + 8; break; @@ -156,7 +156,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) case XFMEM_SETPOSMTXINFO+5: case XFMEM_SETPOSMTXINFO+6: case XFMEM_SETPOSMTXINFO+7: - VertexManager::Flush(); + VertexManagerBase::Flush(); nextAddress = XFMEM_SETPOSMTXINFO + 8; break; From a656c05be29f22d39013d42ea4b06c944db15cea Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Mon, 2 Nov 2015 11:42:22 +0100 Subject: [PATCH 2/2] VertexManagerBase: fix indentation --- Source/Core/VideoCommon/VertexManagerBase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 708462565e..973e93e9b4 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -251,8 +251,8 @@ void VertexManagerBase::Flush() PixelShaderManager::SetConstants(); bool useDstAlpha = bpmem.dstalpha.enable && - bpmem.blendmode.alphaupdate && - bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24; + bpmem.blendmode.alphaupdate && + bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24; if (PerfQueryBase::ShouldEmulate()) g_perf_query->EnableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP);