From 1392efa91dfb2d86d6a66697212aa078c2f1ddd8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 21 Aug 2016 23:02:37 -0400 Subject: [PATCH 1/2] VertexManagerBase: Get rid of static behavior --- Source/Core/VideoCommon/BPFunctions.cpp | 2 +- Source/Core/VideoCommon/Fifo.cpp | 2 +- .../Core/VideoCommon/VertexLoaderManager.cpp | 6 +- Source/Core/VideoCommon/VertexManagerBase.cpp | 65 ++++++++----------- Source/Core/VideoCommon/VertexManagerBase.h | 26 ++++---- .../Core/VideoCommon/VertexShaderManager.cpp | 4 +- Source/Core/VideoCommon/VideoState.cpp | 2 +- Source/Core/VideoCommon/XFStructs.cpp | 22 +++---- 8 files changed, 58 insertions(+), 71 deletions(-) diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp index d471de9e6f..fb7c22c2c8 100644 --- a/Source/Core/VideoCommon/BPFunctions.cpp +++ b/Source/Core/VideoCommon/BPFunctions.cpp @@ -23,7 +23,7 @@ namespace BPFunctions void FlushPipeline() { - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); } void SetGenerationMode() diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 48dcd9cf9b..0cd99f8011 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -390,7 +390,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. - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); } }, 100); diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index 7975ea1eb7..e9c4533244 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -196,7 +196,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) { - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); } s_current_vtx_fmt = loader->m_native_vertex_format; g_current_components = loader->m_native_components; @@ -206,14 +206,14 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo // slope. bool cullall = (bpmem.genMode.cullmode == GenMode::CULL_ALL && primitive < 5); - DataReader dst = VertexManagerBase::PrepareForAdditionalData( + DataReader dst = g_vertex_manager->PrepareForAdditionalData( primitive, count, loader->m_native_vtx_decl.stride, cullall); count = loader->RunVertices(src, dst, count); IndexGenerator::AddIndices(primitive, count); - VertexManagerBase::FlushData(count, loader->m_native_vtx_decl.stride); + g_vertex_manager->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 05e64eddb3..eda90fcd48 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -28,17 +28,6 @@ std::unique_ptr g_vertex_manager; -u8* VertexManagerBase::s_pCurBufferPointer; -u8* VertexManagerBase::s_pBaseBufferPointer; -u8* VertexManagerBase::s_pEndBufferPointer; - -PrimitiveType VertexManagerBase::current_primitive_type; - -Slope VertexManagerBase::s_zslope; - -bool VertexManagerBase::s_is_flushed; -bool VertexManagerBase::s_cull_all; - static const PrimitiveType primitive_from_gx[8] = { PRIMITIVE_TRIANGLES, // GX_DRAW_QUADS PRIMITIVE_TRIANGLES, // GX_DRAW_QUADS_2 @@ -52,17 +41,15 @@ static const PrimitiveType primitive_from_gx[8] = { VertexManagerBase::VertexManagerBase() { - s_is_flushed = true; - s_cull_all = false; } VertexManagerBase::~VertexManagerBase() { } -u32 VertexManagerBase::GetRemainingSize() +u32 VertexManagerBase::GetRemainingSize() const { - return (u32)(s_pEndBufferPointer - s_pCurBufferPointer); + return static_cast(m_end_buffer_pointer - m_cur_buffer_pointer); } DataReader VertexManagerBase::PrepareForAdditionalData(int primitive, u32 count, u32 stride, @@ -72,12 +59,12 @@ DataReader VertexManagerBase::PrepareForAdditionalData(int primitive, u32 count, u32 const needed_vertex_bytes = count * stride + 4; // We can't merge different kinds of primitives, so we have to flush here - if (current_primitive_type != primitive_from_gx[primitive]) + if (m_current_primitive_type != primitive_from_gx[primitive]) Flush(); - current_primitive_type = primitive_from_gx[primitive]; + m_current_primitive_type = primitive_from_gx[primitive]; // Check for size in buffer, if the buffer gets full, call Flush() - if (!s_is_flushed && + if (!m_is_flushed && (count > IndexGenerator::GetRemainingIndices() || count > GetRemainingIndices(primitive) || needed_vertex_bytes > GetRemainingSize())) { @@ -93,21 +80,21 @@ DataReader VertexManagerBase::PrepareForAdditionalData(int primitive, u32 count, "Increase MAXVBUFFERSIZE or we need primitive breaking after all."); } - s_cull_all = cullall; - + m_cull_all = cullall; + // need to alloc new buffer - if (s_is_flushed) + if (m_is_flushed) { g_vertex_manager->ResetBuffer(stride); - s_is_flushed = false; + m_is_flushed = false; } - return DataReader(s_pCurBufferPointer, s_pEndBufferPointer); + return DataReader(m_cur_buffer_pointer, m_end_buffer_pointer); } void VertexManagerBase::FlushData(u32 count, u32 stride) { - s_pCurBufferPointer += count * stride; + m_cur_buffer_pointer += count * stride; } u32 VertexManagerBase::GetRemainingIndices(int primitive) @@ -170,7 +157,7 @@ u32 VertexManagerBase::GetRemainingIndices(int primitive) void VertexManagerBase::Flush() { - if (s_is_flushed) + if (m_is_flushed) return; // loading a state will invalidate BP, so check for it @@ -215,7 +202,7 @@ void VertexManagerBase::Flush() // If the primitave is marked CullAll. All we need to do is update the vertex constants and // calculate the zfreeze refrence slope - if (!s_cull_all) + if (!m_cull_all) { BitSet32 usedtextures; for (u32 i = 0; i < bpmem.genMode.numtevstages + 1u; ++i) @@ -254,13 +241,13 @@ void VertexManagerBase::Flush() // Must be done after VertexShaderManager::SetConstants() CalculateZSlope(VertexLoaderManager::GetCurrentVertexFormat()); } - else if (s_zslope.dirty && !s_cull_all) // or apply any dirty ZSlopes + else if (m_zslope.dirty && !m_cull_all) // or apply any dirty ZSlopes { - PixelShaderManager::SetZSlope(s_zslope.dfdx, s_zslope.dfdy, s_zslope.f0); - s_zslope.dirty = false; + PixelShaderManager::SetZSlope(m_zslope.dfdx, m_zslope.dfdy, m_zslope.f0); + m_zslope.dirty = false; } - if (!s_cull_all) + if (!m_cull_all) { // set the rest of the global constants GeometryShaderManager::SetConstants(); @@ -283,13 +270,13 @@ void VertexManagerBase::Flush() "xf.numtexgens (%d) does not match bp.numtexgens (%d). Error in command stream.", xfmem.numTexGen.numTexGens, bpmem.genMode.numtexgens.Value()); - s_is_flushed = true; - s_cull_all = false; + m_is_flushed = true; + m_cull_all = false; } void VertexManagerBase::DoState(PointerWrap& p) { - p.Do(s_zslope); + p.Do(m_zslope); g_vertex_manager->vDoState(p); } @@ -299,7 +286,7 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format) float viewOffset[2] = {xfmem.viewport.xOrig - bpmem.scissorOffset.x * 2, xfmem.viewport.yOrig - bpmem.scissorOffset.y * 2}; - if (current_primitive_type != PRIMITIVE_TRIANGLES) + if (m_current_primitive_type != PRIMITIVE_TRIANGLES) return; // Global matrix ID. @@ -307,7 +294,7 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format) const PortableVertexDeclaration vert_decl = format->GetVertexDeclaration(); // Make sure the buffer contains at least 3 vertices. - if ((s_pCurBufferPointer - s_pBaseBufferPointer) < (vert_decl.stride * 3)) + if ((m_cur_buffer_pointer - m_base_buffer_pointer) < (vert_decl.stride * 3)) return; // Lookup vertices of the last rendered triangle and software-transform them @@ -348,8 +335,8 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format) if (c == 0) return; - s_zslope.dfdx = -a / c; - s_zslope.dfdy = -b / c; - s_zslope.f0 = out[2] - (out[0] * s_zslope.dfdx + out[1] * s_zslope.dfdy); - s_zslope.dirty = true; + m_zslope.dfdx = -a / c; + m_zslope.dfdy = -b / c; + m_zslope.f0 = out[2] - (out[0] * m_zslope.dfdx + out[1] * m_zslope.dfdy); + m_zslope.dirty = true; } diff --git a/Source/Core/VideoCommon/VertexManagerBase.h b/Source/Core/VideoCommon/VertexManagerBase.h index f99f7e15fc..36ffc30410 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.h +++ b/Source/Core/VideoCommon/VertexManagerBase.h @@ -50,36 +50,36 @@ public: // needs to be virtual for DX11's dtor virtual ~VertexManagerBase(); - static DataReader PrepareForAdditionalData(int primitive, u32 count, u32 stride, bool cullall); - static void FlushData(u32 count, u32 stride); + DataReader PrepareForAdditionalData(int primitive, u32 count, u32 stride, bool cullall); + void FlushData(u32 count, u32 stride); - static void Flush(); + void Flush(); virtual NativeVertexFormat* CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) = 0; - static void DoState(PointerWrap& p); + void DoState(PointerWrap& p); protected: virtual void vDoState(PointerWrap& p) {} - static PrimitiveType current_primitive_type; + PrimitiveType m_current_primitive_type = PrimitiveType::PRIMITIVE_POINTS; virtual void ResetBuffer(u32 stride) = 0; - static u8* s_pCurBufferPointer; - static u8* s_pBaseBufferPointer; - static u8* s_pEndBufferPointer; + u8* m_cur_buffer_pointer = nullptr; + u8* m_base_buffer_pointer = nullptr; + u8* m_end_buffer_pointer = nullptr; - static u32 GetRemainingSize(); + u32 GetRemainingSize() const; static u32 GetRemainingIndices(int primitive); - static Slope s_zslope; - static void CalculateZSlope(NativeVertexFormat* format); + Slope m_zslope = {}; + void CalculateZSlope(NativeVertexFormat* format); - static bool s_cull_all; + bool m_cull_all = false; private: - static bool s_is_flushed; + bool m_is_flushed = true; virtual void vFlush(bool useDstAlpha) = 0; diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 9b1c3437fe..5f9f4affdc 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -676,7 +676,7 @@ void VertexShaderManager::SetTexMatrixChangedA(u32 Value) { if (g_main_cp_state.matrix_index_a.Hex != Value) { - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); if (g_main_cp_state.matrix_index_a.PosNormalMtxIdx != (Value & 0x3f)) bPosNormalMatrixChanged = true; bTexMatricesChanged[0] = true; @@ -688,7 +688,7 @@ void VertexShaderManager::SetTexMatrixChangedB(u32 Value) { if (g_main_cp_state.matrix_index_b.Hex != Value) { - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); bTexMatricesChanged[1] = true; g_main_cp_state.matrix_index_b.Hex = Value; } diff --git a/Source/Core/VideoCommon/VideoState.cpp b/Source/Core/VideoCommon/VideoState.cpp index 3eed6b5de0..ab84e1b001 100644 --- a/Source/Core/VideoCommon/VideoState.cpp +++ b/Source/Core/VideoCommon/VideoState.cpp @@ -57,7 +57,7 @@ void VideoCommon_DoState(PointerWrap& p) GeometryShaderManager::DoState(p); p.DoMarker("GeometryShaderManager"); - VertexManagerBase::DoState(p); + g_vertex_manager->DoState(p); p.DoMarker("VertexManager"); BoundingBox::DoState(p); diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp index 3ade3ffbd2..a6b6c20358 100644 --- a/Source/Core/VideoCommon/XFStructs.cpp +++ b/Source/Core/VideoCommon/XFStructs.cpp @@ -17,7 +17,7 @@ static void XFMemWritten(u32 transferSize, u32 baseAddress) { - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); VertexShaderManager::InvalidateXFRange(baseAddress, baseAddress + transferSize); } @@ -53,7 +53,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) case XFMEM_SETNUMCHAN: if (xfmem.numChan.numColorChans != (newValue & 3)) - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); break; case XFMEM_SETCHAN0_AMBCOLOR: // Channel Ambient Color @@ -62,7 +62,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) u8 chan = address - XFMEM_SETCHAN0_AMBCOLOR; if (xfmem.ambColor[chan] != newValue) { - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); VertexShaderManager::SetMaterialColorChanged(chan); } break; @@ -74,7 +74,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src) u8 chan = address - XFMEM_SETCHAN0_MATCOLOR; if (xfmem.matColor[chan] != newValue) { - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); VertexShaderManager::SetMaterialColorChanged(chan + 2); } break; @@ -85,12 +85,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)) - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); break; case XFMEM_DUALTEX: if (xfmem.dualTexTrans.enabled != (newValue & 1)) - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); break; case XFMEM_SETMATRIXINDA: @@ -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: - VertexManagerBase::Flush(); + g_vertex_manager->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: - VertexManagerBase::Flush(); + g_vertex_manager->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)) - VertexManagerBase::Flush(); + g_vertex_manager->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: - VertexManagerBase::Flush(); + g_vertex_manager->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: - VertexManagerBase::Flush(); + g_vertex_manager->Flush(); nextAddress = XFMEM_SETPOSMTXINFO + 8; break; From 2bf05a544de9e737714c67ffe2247d661bc5e406 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 21 Aug 2016 23:46:52 -0400 Subject: [PATCH 2/2] VertexManager: Correct variable naming scheme Altered to indicate regular class members --- .../Core/VideoBackends/D3D/VertexManager.cpp | 16 +++++++-------- .../VideoBackends/D3D12/VertexManager.cpp | 18 ++++++++--------- .../Core/VideoBackends/Null/VertexManager.cpp | 10 +++++----- .../Core/VideoBackends/OGL/VertexManager.cpp | 20 +++++++++---------- .../VideoBackends/Software/SWVertexLoader.cpp | 6 +++--- Source/Core/VideoCommon/VertexManagerBase.cpp | 2 +- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/VertexManager.cpp b/Source/Core/VideoBackends/D3D/VertexManager.cpp index ddffc6653d..5b78a1101a 100644 --- a/Source/Core/VideoBackends/D3D/VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D/VertexManager.cpp @@ -61,8 +61,8 @@ VertexManager::VertexManager() { LocalVBuffer.resize(MAXVBUFFERSIZE); - s_pCurBufferPointer = s_pBaseBufferPointer = &LocalVBuffer[0]; - s_pEndBufferPointer = s_pBaseBufferPointer + LocalVBuffer.size(); + m_cur_buffer_pointer = m_base_buffer_pointer = &LocalVBuffer[0]; + m_end_buffer_pointer = m_base_buffer_pointer + LocalVBuffer.size(); LocalIBuffer.resize(MAXIBUFFERSIZE); @@ -78,7 +78,7 @@ void VertexManager::PrepareDrawBuffers(u32 stride) { D3D11_MAPPED_SUBRESOURCE map; - u32 vertexBufferSize = u32(s_pCurBufferPointer - s_pBaseBufferPointer); + u32 vertexBufferSize = u32(m_cur_buffer_pointer - m_base_buffer_pointer); u32 indexBufferSize = IndexGenerator::GetIndexLen() * sizeof(u16); u32 totalBufferSize = vertexBufferSize + indexBufferSize; @@ -103,7 +103,7 @@ void VertexManager::PrepareDrawBuffers(u32 stride) D3D::context->Map(m_buffers[m_currentBuffer], 0, MapType, 0, &map); u8* mappedData = reinterpret_cast(map.pData); - memcpy(mappedData + m_vertexDrawOffset, s_pBaseBufferPointer, vertexBufferSize); + memcpy(mappedData + m_vertexDrawOffset, m_base_buffer_pointer, vertexBufferSize); memcpy(mappedData + m_indexDrawOffset, GetIndexBuffer(), indexBufferSize); D3D::context->Unmap(m_buffers[m_currentBuffer], 0); @@ -123,7 +123,7 @@ void VertexManager::Draw(u32 stride) u32 baseVertex = m_vertexDrawOffset / stride; u32 startIndex = m_indexDrawOffset / sizeof(u16); - switch (current_primitive_type) + switch (m_current_primitive_type) { case PRIMITIVE_POINTS: D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); @@ -143,7 +143,7 @@ void VertexManager::Draw(u32 stride) INCSTAT(stats.thisFrame.numDrawCalls); - if (current_primitive_type != PRIMITIVE_TRIANGLES) + if (m_current_primitive_type != PRIMITIVE_TRIANGLES) static_cast(g_renderer.get())->RestoreCull(); } @@ -161,7 +161,7 @@ void VertexManager::vFlush(bool useDstAlpha) return; } - if (!GeometryShaderCache::SetShader(current_primitive_type)) + if (!GeometryShaderCache::SetShader(m_current_primitive_type)) { GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR, true, { printf("Fail to set pixel shader\n"); }); return; @@ -188,7 +188,7 @@ void VertexManager::vFlush(bool useDstAlpha) void VertexManager::ResetBuffer(u32 stride) { - s_pCurBufferPointer = s_pBaseBufferPointer; + m_cur_buffer_pointer = m_base_buffer_pointer; IndexGenerator::Start(GetIndexBuffer()); } diff --git a/Source/Core/VideoBackends/D3D12/VertexManager.cpp b/Source/Core/VideoBackends/D3D12/VertexManager.cpp index d6265ae725..a803a07e35 100644 --- a/Source/Core/VideoBackends/D3D12/VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D12/VertexManager.cpp @@ -111,7 +111,7 @@ void VertexManager::Draw(u32 stride) D3D_PRIMITIVE_TOPOLOGY d3d_primitive_topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; - switch (current_primitive_type) + switch (m_current_primitive_type) { case PRIMITIVE_POINTS: d3d_primitive_topology = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; @@ -138,7 +138,7 @@ void VertexManager::Draw(u32 stride) void VertexManager::vFlush(bool use_dst_alpha) { ShaderCache::LoadAndSetActiveShaders(use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, - current_primitive_type); + m_current_primitive_type); if (g_ActiveConfig.backend_info.bSupportsBBox && BoundingBox::active) BBox::Invalidate(); @@ -180,11 +180,11 @@ void VertexManager::vFlush(bool use_dst_alpha) void VertexManager::ResetBuffer(u32 stride) { - if (s_cull_all) + if (m_cull_all) { - s_pCurBufferPointer = m_vertex_cpu_buffer.data(); - s_pBaseBufferPointer = m_vertex_cpu_buffer.data(); - s_pEndBufferPointer = m_vertex_cpu_buffer.data() + MAXVBUFFERSIZE; + m_cur_buffer_pointer = m_vertex_cpu_buffer.data(); + m_base_buffer_pointer = m_vertex_cpu_buffer.data(); + m_end_buffer_pointer = m_vertex_cpu_buffer.data() + MAXVBUFFERSIZE; IndexGenerator::Start(reinterpret_cast(m_index_cpu_buffer.data())); return; @@ -198,9 +198,9 @@ void VertexManager::ResetBuffer(u32 stride) m_vertex_stream_buffer_reallocated = false; } - s_pBaseBufferPointer = static_cast(m_vertex_stream_buffer->GetBaseCPUAddress()); - s_pEndBufferPointer = s_pBaseBufferPointer + m_vertex_stream_buffer->GetSize(); - s_pCurBufferPointer = + m_base_buffer_pointer = static_cast(m_vertex_stream_buffer->GetBaseCPUAddress()); + m_end_buffer_pointer = m_base_buffer_pointer + m_vertex_stream_buffer->GetSize(); + m_cur_buffer_pointer = static_cast(m_vertex_stream_buffer->GetCPUAddressOfCurrentAllocation()); m_vertex_draw_offset = static_cast(m_vertex_stream_buffer->GetOffsetOfCurrentAllocation()); diff --git a/Source/Core/VideoBackends/Null/VertexManager.cpp b/Source/Core/VideoBackends/Null/VertexManager.cpp index d70876cb84..2596243f93 100644 --- a/Source/Core/VideoBackends/Null/VertexManager.cpp +++ b/Source/Core/VideoBackends/Null/VertexManager.cpp @@ -35,19 +35,19 @@ VertexManager::~VertexManager() void VertexManager::ResetBuffer(u32 stride) { - s_pCurBufferPointer = s_pBaseBufferPointer = m_local_v_buffer.data(); - s_pEndBufferPointer = s_pCurBufferPointer + m_local_v_buffer.size(); + m_cur_buffer_pointer = m_base_buffer_pointer = m_local_v_buffer.data(); + m_end_buffer_pointer = m_cur_buffer_pointer + m_local_v_buffer.size(); IndexGenerator::Start(&m_local_i_buffer[0]); } void VertexManager::vFlush(bool use_dst_alpha) { VertexShaderCache::s_instance->SetShader( - use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, current_primitive_type); + use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, m_current_primitive_type); GeometryShaderCache::s_instance->SetShader( - use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, current_primitive_type); + use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, m_current_primitive_type); PixelShaderCache::s_instance->SetShader( - use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, current_primitive_type); + use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, m_current_primitive_type); } } // namespace diff --git a/Source/Core/VideoBackends/OGL/VertexManager.cpp b/Source/Core/VideoBackends/OGL/VertexManager.cpp index 04b83dc893..bc763e914c 100644 --- a/Source/Core/VideoBackends/OGL/VertexManager.cpp +++ b/Source/Core/VideoBackends/OGL/VertexManager.cpp @@ -75,19 +75,19 @@ void VertexManager::PrepareDrawBuffers(u32 stride) void VertexManager::ResetBuffer(u32 stride) { - if (s_cull_all) + if (m_cull_all) { // This buffer isn't getting sent to the GPU. Just allocate it on the cpu. - s_pCurBufferPointer = s_pBaseBufferPointer = m_cpu_v_buffer.data(); - s_pEndBufferPointer = s_pBaseBufferPointer + m_cpu_v_buffer.size(); + m_cur_buffer_pointer = m_base_buffer_pointer = m_cpu_v_buffer.data(); + m_end_buffer_pointer = m_base_buffer_pointer + m_cpu_v_buffer.size(); IndexGenerator::Start((u16*)m_cpu_i_buffer.data()); } else { auto buffer = s_vertexBuffer->Map(MAXVBUFFERSIZE, stride); - s_pCurBufferPointer = s_pBaseBufferPointer = buffer.first; - s_pEndBufferPointer = buffer.first + MAXVBUFFERSIZE; + m_cur_buffer_pointer = m_base_buffer_pointer = buffer.first; + m_end_buffer_pointer = buffer.first + MAXVBUFFERSIZE; s_baseVertex = buffer.second / stride; buffer = s_indexBuffer->Map(MAXIBUFFERSIZE * sizeof(u16)); @@ -102,7 +102,7 @@ void VertexManager::Draw(u32 stride) u32 max_index = IndexGenerator::GetNumVerts(); GLenum primitive_mode = 0; - switch (current_primitive_type) + switch (m_current_primitive_type) { case PRIMITIVE_POINTS: primitive_mode = GL_POINTS; @@ -131,7 +131,7 @@ void VertexManager::Draw(u32 stride) INCSTAT(stats.thisFrame.numDrawCalls); - if (current_primitive_type != PRIMITIVE_TRIANGLES) + if (m_current_primitive_type != PRIMITIVE_TRIANGLES) static_cast(g_renderer.get())->SetGenerationMode(); } @@ -155,11 +155,11 @@ void VertexManager::vFlush(bool useDstAlpha) // the same pass as regular rendering. if (useDstAlpha && dualSourcePossible) { - ProgramShaderCache::SetShader(DSTALPHA_DUAL_SOURCE_BLEND, current_primitive_type); + ProgramShaderCache::SetShader(DSTALPHA_DUAL_SOURCE_BLEND, m_current_primitive_type); } else { - ProgramShaderCache::SetShader(DSTALPHA_NONE, current_primitive_type); + ProgramShaderCache::SetShader(DSTALPHA_NONE, m_current_primitive_type); } // upload global constants @@ -173,7 +173,7 @@ void VertexManager::vFlush(bool useDstAlpha) // run through vertex groups again to set alpha if (useDstAlpha && !dualSourcePossible) { - ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS, current_primitive_type); + ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS, m_current_primitive_type); // only update alpha glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp index ebbf628c1a..9993be1f9a 100644 --- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp +++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp @@ -54,8 +54,8 @@ SWVertexLoader::~SWVertexLoader() void SWVertexLoader::ResetBuffer(u32 stride) { - s_pCurBufferPointer = s_pBaseBufferPointer = LocalVBuffer.data(); - s_pEndBufferPointer = s_pCurBufferPointer + LocalVBuffer.size(); + m_cur_buffer_pointer = m_base_buffer_pointer = LocalVBuffer.data(); + m_end_buffer_pointer = m_cur_buffer_pointer + LocalVBuffer.size(); IndexGenerator::Start(GetIndexBuffer()); } @@ -64,7 +64,7 @@ void SWVertexLoader::vFlush(bool useDstAlpha) DebugUtil::OnObjectBegin(); u8 primitiveType = 0; - switch (current_primitive_type) + switch (m_current_primitive_type) { case PRIMITIVE_POINTS: primitiveType = GX_DRAW_POINTS; diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index eda90fcd48..8ac365a735 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -81,7 +81,7 @@ DataReader VertexManagerBase::PrepareForAdditionalData(int primitive, u32 count, } m_cull_all = cullall; - + // need to alloc new buffer if (m_is_flushed) {