diff --git a/Source/Core/Core/System.cpp b/Source/Core/Core/System.cpp index ec07ce8bc2..79c25592eb 100644 --- a/Source/Core/Core/System.cpp +++ b/Source/Core/Core/System.cpp @@ -21,6 +21,7 @@ #include "VideoCommon/CommandProcessor.h" #include "VideoCommon/Fifo.h" #include "VideoCommon/PixelEngine.h" +#include "VideoCommon/PixelShaderManager.h" namespace Core { @@ -41,6 +42,7 @@ struct System::Impl Memory::MemoryManager m_memory; MemoryInterface::MemoryInterfaceState m_memory_interface_state; PixelEngine::PixelEngineManager m_pixel_engine; + PixelShaderManager m_pixel_shader_manager; SerialInterface::SerialInterfaceState m_serial_interface_state; Sram m_sram; VideoInterface::VideoInterfaceState m_video_interface_state; @@ -144,6 +146,11 @@ PixelEngine::PixelEngineManager& System::GetPixelEngine() const return m_impl->m_pixel_engine; } +PixelShaderManager& System::GetPixelShaderManager() const +{ + return m_impl->m_pixel_shader_manager; +} + SerialInterface::SerialInterfaceState& System::GetSerialInterfaceState() const { return m_impl->m_serial_interface_state; diff --git a/Source/Core/Core/System.h b/Source/Core/Core/System.h index 8051f76750..f92e57291e 100644 --- a/Source/Core/Core/System.h +++ b/Source/Core/Core/System.h @@ -5,6 +5,7 @@ #include +class PixelShaderManager; class SoundStream; struct Sram; @@ -106,6 +107,7 @@ public: Memory::MemoryManager& GetMemory() const; MemoryInterface::MemoryInterfaceState& GetMemoryInterfaceState() const; PixelEngine::PixelEngineManager& GetPixelEngine() const; + PixelShaderManager& GetPixelShaderManager() const; SerialInterface::SerialInterfaceState& GetSerialInterfaceState() const; Sram& GetSRAM() const; VideoInterface::VideoInterfaceState& GetVideoInterfaceState() const; diff --git a/Source/Core/VideoBackends/D3D/D3DVertexManager.cpp b/Source/Core/VideoBackends/D3D/D3DVertexManager.cpp index 318559affa..b3c7012d8b 100644 --- a/Source/Core/VideoBackends/D3D/D3DVertexManager.cpp +++ b/Source/Core/VideoBackends/D3D/D3DVertexManager.cpp @@ -9,6 +9,8 @@ #include "Common/Assert.h" #include "Common/CommonTypes.h" +#include "Core/System.h" + #include "VideoBackends/D3D/D3DBase.h" #include "VideoBackends/D3D/D3DBoundingBox.h" #include "VideoBackends/D3D/D3DRender.h" @@ -260,6 +262,8 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in void VertexManager::UploadUniforms() { + auto& system = Core::System::GetInstance(); + if (VertexShaderManager::dirty) { UpdateConstantBuffer(m_vertex_constant_buffer.Get(), &VertexShaderManager::constants, @@ -272,11 +276,13 @@ void VertexManager::UploadUniforms() sizeof(GeometryShaderConstants)); GeometryShaderManager::dirty = false; } - if (PixelShaderManager::dirty) + + auto& pixel_shader_manager = system.GetPixelShaderManager(); + if (pixel_shader_manager.dirty) { - UpdateConstantBuffer(m_pixel_constant_buffer.Get(), &PixelShaderManager::constants, + UpdateConstantBuffer(m_pixel_constant_buffer.Get(), &pixel_shader_manager.constants, sizeof(PixelShaderConstants)); - PixelShaderManager::dirty = false; + pixel_shader_manager.dirty = false; } D3D::stateman->SetPixelConstants( diff --git a/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp b/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp index 5a9efc0d6c..3d95c076cc 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp @@ -8,6 +8,8 @@ #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" +#include "Core/System.h" + #include "VideoBackends/D3D12/D3D12Renderer.h" #include "VideoBackends/D3D12/D3D12StreamBuffer.h" #include "VideoBackends/D3D12/DX12Context.h" @@ -169,15 +171,18 @@ void VertexManager::UpdateGeometryShaderConstants() void VertexManager::UpdatePixelShaderConstants() { - if (!PixelShaderManager::dirty || !ReserveConstantStorage()) + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + + if (!pixel_shader_manager.dirty || !ReserveConstantStorage()) return; Renderer::GetInstance()->SetConstantBuffer(0, m_uniform_stream_buffer.GetCurrentGPUPointer()); - std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer(), &PixelShaderManager::constants, + std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer(), &pixel_shader_manager.constants, sizeof(PixelShaderConstants)); m_uniform_stream_buffer.CommitMemory(sizeof(PixelShaderConstants)); ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(PixelShaderConstants)); - PixelShaderManager::dirty = false; + pixel_shader_manager.dirty = false; } bool VertexManager::ReserveConstantStorage() @@ -230,9 +235,12 @@ void VertexManager::UploadAllConstants() Renderer::GetInstance()->SetConstantBuffer(2, m_uniform_stream_buffer.GetCurrentGPUPointer() + geometry_constants_offset); + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + // Copy the actual data in std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer() + pixel_constants_offset, - &PixelShaderManager::constants, sizeof(PixelShaderConstants)); + &pixel_shader_manager.constants, sizeof(PixelShaderConstants)); std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer() + vertex_constants_offset, &VertexShaderManager::constants, sizeof(VertexShaderConstants)); std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer() + geometry_constants_offset, @@ -245,7 +253,7 @@ void VertexManager::UploadAllConstants() // Clear dirty flags VertexShaderManager::dirty = false; GeometryShaderManager::dirty = false; - PixelShaderManager::dirty = false; + pixel_shader_manager.dirty = false; } void VertexManager::UploadUtilityUniforms(const void* data, u32 data_size) diff --git a/Source/Core/VideoBackends/Metal/MTLStateTracker.mm b/Source/Core/VideoBackends/Metal/MTLStateTracker.mm index a2e2a2a8f3..60c7dd19df 100644 --- a/Source/Core/VideoBackends/Metal/MTLStateTracker.mm +++ b/Source/Core/VideoBackends/Metal/MTLStateTracker.mm @@ -9,6 +9,8 @@ #include "Common/Assert.h" +#include "Core/System.h" + #include "VideoBackends/Metal/MTLObjectCache.h" #include "VideoBackends/Metal/MTLPerfQuery.h" #include "VideoBackends/Metal/MTLPipeline.h" @@ -853,7 +855,9 @@ void Metal::StateTracker::PrepareRender() { m_flags.has_gx_ps_uniform = true; Map map = Allocate(UploadBuffer::Uniform, sizeof(PixelShaderConstants), AlignMask::Uniform); - memcpy(map.cpu_buffer, &PixelShaderManager::constants, sizeof(PixelShaderConstants)); + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + memcpy(map.cpu_buffer, &pixel_shader_manager.constants, sizeof(PixelShaderConstants)); SetFragmentBufferNow(0, map.gpu_buffer, map.gpu_offset); ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, Align(sizeof(PixelShaderConstants), AlignMask::Uniform)); diff --git a/Source/Core/VideoBackends/Metal/MTLVertexManager.mm b/Source/Core/VideoBackends/Metal/MTLVertexManager.mm index 6cfad2d2f8..df86461ae3 100644 --- a/Source/Core/VideoBackends/Metal/MTLVertexManager.mm +++ b/Source/Core/VideoBackends/Metal/MTLVertexManager.mm @@ -3,6 +3,8 @@ #include "VideoBackends/Metal/MTLVertexManager.h" +#include "Core/System.h" + #include "VideoBackends/Metal/MTLStateTracker.h" #include "VideoCommon/GeometryShaderManager.h" @@ -89,9 +91,11 @@ void Metal::VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 void Metal::VertexManager::UploadUniforms() { + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); g_state_tracker->InvalidateUniforms(VertexShaderManager::dirty, GeometryShaderManager::dirty, - PixelShaderManager::dirty); + pixel_shader_manager.dirty); VertexShaderManager::dirty = false; GeometryShaderManager::dirty = false; - PixelShaderManager::dirty = false; + pixel_shader_manager.dirty = false; } diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index bd96f3be04..485d718723 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -20,6 +20,7 @@ #include "Common/Version.h" #include "Core/ConfigManager.h" +#include "Core/System.h" #include "VideoBackends/OGL/OGLRender.h" #include "VideoBackends/OGL/OGLShader.h" @@ -220,11 +221,13 @@ u32 ProgramShaderCache::GetUniformBufferAlignment() void ProgramShaderCache::UploadConstants() { - if (PixelShaderManager::dirty || VertexShaderManager::dirty || GeometryShaderManager::dirty) + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + if (pixel_shader_manager.dirty || VertexShaderManager::dirty || GeometryShaderManager::dirty) { auto buffer = s_buffer->Map(s_ubo_buffer_size, s_ubo_align); - memcpy(buffer.first, &PixelShaderManager::constants, sizeof(PixelShaderConstants)); + memcpy(buffer.first, &pixel_shader_manager.constants, sizeof(PixelShaderConstants)); memcpy(buffer.first + Common::AlignUp(sizeof(PixelShaderConstants), s_ubo_align), &VertexShaderManager::constants, sizeof(VertexShaderConstants)); @@ -244,7 +247,7 @@ void ProgramShaderCache::UploadConstants() Common::AlignUp(sizeof(VertexShaderConstants), s_ubo_align), sizeof(GeometryShaderConstants)); - PixelShaderManager::dirty = false; + pixel_shader_manager.dirty = false; VertexShaderManager::dirty = false; GeometryShaderManager::dirty = false; diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index f2f903ccfc..9b74684ccf 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -9,6 +9,9 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" + +#include "Core/System.h" + #include "VideoBackends/Software/EfbInterface.h" #include "VideoBackends/Software/SWBoundingBox.h" #include "VideoBackends/Software/TextureSampler.h" @@ -396,13 +399,16 @@ void Tev::Draw() INCSTAT(g_stats.this_frame.tev_pixels_in); + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + // initial color values for (int i = 0; i < 4; i++) { - Reg[static_cast(i)].r = PixelShaderManager::constants.colors[i][0]; - Reg[static_cast(i)].g = PixelShaderManager::constants.colors[i][1]; - Reg[static_cast(i)].b = PixelShaderManager::constants.colors[i][2]; - Reg[static_cast(i)].a = PixelShaderManager::constants.colors[i][3]; + Reg[static_cast(i)].r = pixel_shader_manager.constants.colors[i][0]; + Reg[static_cast(i)].g = pixel_shader_manager.constants.colors[i][1]; + Reg[static_cast(i)].b = pixel_shader_manager.constants.colors[i][2]; + Reg[static_cast(i)].a = pixel_shader_manager.constants.colors[i][3]; } for (unsigned int stageNum = 0; stageNum < bpmem.genMode.numindstages; stageNum++) @@ -694,11 +700,14 @@ void Tev::Draw() void Tev::SetKonstColors() { + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + for (int i = 0; i < 4; i++) { - KonstantColors[i].r = PixelShaderManager::constants.kcolors[i][0]; - KonstantColors[i].g = PixelShaderManager::constants.kcolors[i][1]; - KonstantColors[i].b = PixelShaderManager::constants.kcolors[i][2]; - KonstantColors[i].a = PixelShaderManager::constants.kcolors[i][3]; + KonstantColors[i].r = pixel_shader_manager.constants.kcolors[i][0]; + KonstantColors[i].g = pixel_shader_manager.constants.kcolors[i][1]; + KonstantColors[i].b = pixel_shader_manager.constants.kcolors[i][2]; + KonstantColors[i].a = pixel_shader_manager.constants.kcolors[i][3]; } } diff --git a/Source/Core/VideoBackends/Vulkan/VKVertexManager.cpp b/Source/Core/VideoBackends/Vulkan/VKVertexManager.cpp index be9e22d4d5..c01335d85a 100644 --- a/Source/Core/VideoBackends/Vulkan/VKVertexManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKVertexManager.cpp @@ -10,6 +10,8 @@ #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" +#include "Core/System.h" + #include "VideoBackends/Vulkan/CommandBufferManager.h" #include "VideoBackends/Vulkan/StateTracker.h" #include "VideoBackends/Vulkan/VKRenderer.h" @@ -232,17 +234,20 @@ void VertexManager::UpdateGeometryShaderConstants() void VertexManager::UpdatePixelShaderConstants() { - if (!PixelShaderManager::dirty || !ReserveConstantStorage()) + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + + if (!pixel_shader_manager.dirty || !ReserveConstantStorage()) return; StateTracker::GetInstance()->SetGXUniformBuffer( UBO_DESCRIPTOR_SET_BINDING_PS, m_uniform_stream_buffer->GetBuffer(), m_uniform_stream_buffer->GetCurrentOffset(), sizeof(PixelShaderConstants)); - std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer(), &PixelShaderManager::constants, + std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer(), &pixel_shader_manager.constants, sizeof(PixelShaderConstants)); m_uniform_stream_buffer->CommitMemory(sizeof(PixelShaderConstants)); ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(PixelShaderConstants)); - PixelShaderManager::dirty = false; + pixel_shader_manager.dirty = false; } bool VertexManager::ReserveConstantStorage() @@ -282,6 +287,9 @@ void VertexManager::UploadAllConstants() return; } + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + // Update bindings StateTracker::GetInstance()->SetGXUniformBuffer( UBO_DESCRIPTOR_SET_BINDING_PS, m_uniform_stream_buffer->GetBuffer(), @@ -298,7 +306,7 @@ void VertexManager::UploadAllConstants() // Copy the actual data in std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer() + pixel_constants_offset, - &PixelShaderManager::constants, sizeof(PixelShaderConstants)); + &pixel_shader_manager.constants, sizeof(PixelShaderConstants)); std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer() + vertex_constants_offset, &VertexShaderManager::constants, sizeof(VertexShaderConstants)); std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer() + geometry_constants_offset, @@ -311,7 +319,7 @@ void VertexManager::UploadAllConstants() // Clear dirty flags VertexShaderManager::dirty = false; GeometryShaderManager::dirty = false; - PixelShaderManager::dirty = false; + pixel_shader_manager.dirty = false; } void VertexManager::UploadUtilityUniforms(const void* data, u32 data_size) diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index b155f6b3c3..e7c2c640ff 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -54,7 +54,8 @@ void BPInit() bpmem.bpMask = 0xFFFFFF; } -static void BPWritten(const BPCmd& bp, int cycles_into_future) +static void BPWritten(PixelShaderManager& pixel_shader_manager, const BPCmd& bp, + int cycles_into_future) { /* ---------------------------------------------------------------------------------------------------------------- @@ -103,7 +104,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) bpmem.genMode.zfreeze); if (bp.changes) - PixelShaderManager::SetGenModeChanged(); + pixel_shader_manager.SetGenModeChanged(); // Only call SetGenerationMode when cull mode changes. if (bp.changes & 0xC000) @@ -119,15 +120,15 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) case BPMEM_IND_MTXB + 6: case BPMEM_IND_MTXC + 6: if (bp.changes) - PixelShaderManager::SetIndMatrixChanged((bp.address - BPMEM_IND_MTXA) / 3); + pixel_shader_manager.SetIndMatrixChanged((bp.address - BPMEM_IND_MTXA) / 3); return; case BPMEM_RAS1_SS0: // Index Texture Coordinate Scale 0 if (bp.changes) - PixelShaderManager::SetIndTexScaleChanged(false); + pixel_shader_manager.SetIndTexScaleChanged(false); return; case BPMEM_RAS1_SS1: // Index Texture Coordinate Scale 1 if (bp.changes) - PixelShaderManager::SetIndTexScaleChanged(true); + pixel_shader_manager.SetIndTexScaleChanged(true); return; // ---------------- // Scissor Control @@ -145,7 +146,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) PRIM_LOG("zmode: test={}, func={}, upd={}", bpmem.zmode.testenable, bpmem.zmode.func, bpmem.zmode.updateenable); SetDepthMode(); - PixelShaderManager::SetZModeControl(); + pixel_shader_manager.SetZModeControl(); return; case BPMEM_BLENDMODE: // Blending Control if (bp.changes & 0xFFFF) @@ -157,15 +158,15 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) SetBlendMode(); - PixelShaderManager::SetBlendModeChanged(); + pixel_shader_manager.SetBlendModeChanged(); } return; case BPMEM_CONSTANTALPHA: // Set Destination Alpha PRIM_LOG("constalpha: alp={}, en={}", bpmem.dstalpha.alpha, bpmem.dstalpha.enable); if (bp.changes) { - PixelShaderManager::SetAlpha(); - PixelShaderManager::SetDestAlphaChanged(); + pixel_shader_manager.SetAlpha(); + pixel_shader_manager.SetDestAlphaChanged(); } if (bp.changes & 0x100) SetBlendMode(); @@ -279,7 +280,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) if (PE_copy.copy_to_xfb == 1) { // Make sure we disable Bounding box to match the side effects of the non-failure path - g_renderer->BBoxDisable(); + g_renderer->BBoxDisable(pixel_shader_manager); } return; @@ -310,7 +311,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) // We should be able to get away with deactivating the current bbox tracking // here. Not sure if there's a better spot to put this. // the number of lines copied is determined by the y scale * source efb height - g_renderer->BBoxDisable(); + g_renderer->BBoxDisable(pixel_shader_manager); float yScale; if (PE_copy.scale_invert) @@ -390,42 +391,42 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) case BPMEM_FOGRANGE + 4: case BPMEM_FOGRANGE + 5: if (bp.changes) - PixelShaderManager::SetFogRangeAdjustChanged(); + pixel_shader_manager.SetFogRangeAdjustChanged(); return; case BPMEM_FOGPARAM0: case BPMEM_FOGBMAGNITUDE: case BPMEM_FOGBEXPONENT: case BPMEM_FOGPARAM3: if (bp.changes) - PixelShaderManager::SetFogParamChanged(); + pixel_shader_manager.SetFogParamChanged(); return; case BPMEM_FOGCOLOR: // Fog Color if (bp.changes) - PixelShaderManager::SetFogColorChanged(); + pixel_shader_manager.SetFogColorChanged(); return; case BPMEM_ALPHACOMPARE: // Compare Alpha Values PRIM_LOG("alphacmp: ref0={}, ref1={}, comp0={}, comp1={}, logic={}", bpmem.alpha_test.ref0, bpmem.alpha_test.ref1, bpmem.alpha_test.comp0, bpmem.alpha_test.comp1, bpmem.alpha_test.logic); if (bp.changes & 0xFFFF) - PixelShaderManager::SetAlpha(); + pixel_shader_manager.SetAlpha(); if (bp.changes) { - PixelShaderManager::SetAlphaTestChanged(); + pixel_shader_manager.SetAlphaTestChanged(); SetBlendMode(); } return; case BPMEM_BIAS: // BIAS PRIM_LOG("ztex bias={:#x}", bpmem.ztex1.bias); if (bp.changes) - PixelShaderManager::SetZTextureBias(); + pixel_shader_manager.SetZTextureBias(); return; case BPMEM_ZTEX2: // Z Texture type { if (bp.changes & 3) - PixelShaderManager::SetZTextureTypeChanged(); + pixel_shader_manager.SetZTextureTypeChanged(); if (bp.changes & 12) - PixelShaderManager::SetZTextureOpChanged(); + pixel_shader_manager.SetZTextureOpChanged(); PRIM_LOG("ztex op={}, type={}", bpmem.ztex2.op, bpmem.ztex2.type); } return; @@ -478,7 +479,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) case BPMEM_CLEARBBOX2: { const u8 offset = bp.address & 2; - g_renderer->BBoxEnable(); + g_renderer->BBoxEnable(pixel_shader_manager); g_renderer->BBoxWrite(offset, bp.newvalue & 0x3ff); g_renderer->BBoxWrite(offset + 1, bp.newvalue >> 10); @@ -492,7 +493,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) OnPixelFormatChange(); if (bp.changes & 7) SetBlendMode(); // dual source could be activated by changing to PIXELFMT_RGBA6_Z24 - PixelShaderManager::SetZModeControl(); + pixel_shader_manager.SetZModeControl(); return; case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel @@ -510,7 +511,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) case BPMEM_IREF: { if (bp.changes) - PixelShaderManager::SetTevIndirectChanged(); + pixel_shader_manager.SetTevIndirectChanged(); return; } @@ -522,7 +523,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) case BPMEM_TEV_KSEL + 5: // Texture Environment Swap Mode Table 5 case BPMEM_TEV_KSEL + 6: // Texture Environment Swap Mode Table 6 case BPMEM_TEV_KSEL + 7: // Texture Environment Swap Mode Table 7 - PixelShaderManager::SetTevKSel(bp.address - BPMEM_TEV_KSEL, bp.newvalue); + pixel_shader_manager.SetTevKSel(bp.address - BPMEM_TEV_KSEL, bp.newvalue); return; /* This Register can be used to limit to which bits of BP registers is @@ -619,13 +620,13 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) int num = (bp.address >> 1) & 0x3; if (bpmem.tevregs[num].ra.type == TevRegType::Constant) { - PixelShaderManager::SetTevKonstColor(num, 0, bpmem.tevregs[num].ra.red); - PixelShaderManager::SetTevKonstColor(num, 3, bpmem.tevregs[num].ra.alpha); + pixel_shader_manager.SetTevKonstColor(num, 0, bpmem.tevregs[num].ra.red); + pixel_shader_manager.SetTevKonstColor(num, 3, bpmem.tevregs[num].ra.alpha); } else { - PixelShaderManager::SetTevColor(num, 0, bpmem.tevregs[num].ra.red); - PixelShaderManager::SetTevColor(num, 3, bpmem.tevregs[num].ra.alpha); + pixel_shader_manager.SetTevColor(num, 0, bpmem.tevregs[num].ra.red); + pixel_shader_manager.SetTevColor(num, 3, bpmem.tevregs[num].ra.alpha); } return; } @@ -638,13 +639,13 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) int num = (bp.address >> 1) & 0x3; if (bpmem.tevregs[num].bg.type == TevRegType::Constant) { - PixelShaderManager::SetTevKonstColor(num, 1, bpmem.tevregs[num].bg.green); - PixelShaderManager::SetTevKonstColor(num, 2, bpmem.tevregs[num].bg.blue); + pixel_shader_manager.SetTevKonstColor(num, 1, bpmem.tevregs[num].bg.green); + pixel_shader_manager.SetTevKonstColor(num, 2, bpmem.tevregs[num].bg.blue); } else { - PixelShaderManager::SetTevColor(num, 1, bpmem.tevregs[num].bg.green); - PixelShaderManager::SetTevColor(num, 2, bpmem.tevregs[num].bg.blue); + pixel_shader_manager.SetTevColor(num, 1, bpmem.tevregs[num].bg.green); + pixel_shader_manager.SetTevColor(num, 2, bpmem.tevregs[num].bg.blue); } return; } @@ -660,7 +661,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) // ------------------------- case BPMEM_TREF: case BPMEM_TREF + 4: - PixelShaderManager::SetTevOrder(bp.address - BPMEM_TREF, bp.newvalue); + pixel_shader_manager.SetTevOrder(bp.address - BPMEM_TREF, bp.newvalue); return; // ---------------------- // Set wrap size @@ -671,7 +672,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) case BPMEM_SU_SSIZE + 12: if (bp.changes) { - PixelShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1); + pixel_shader_manager.SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1); GeometryShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1); } return; @@ -725,7 +726,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) // Indirect Tev // -------------- case BPMEM_IND_CMD: - PixelShaderManager::SetTevIndirectChanged(); + pixel_shader_manager.SetTevIndirectChanged(); return; // -------------------------------------------------- // Set Color/Alpha of a Tev @@ -734,8 +735,8 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) // -------------------------------------------------- case BPMEM_TEV_COLOR_ENV: // Texture Environment 1 case BPMEM_TEV_COLOR_ENV + 16: - PixelShaderManager::SetTevCombiner((bp.address - BPMEM_TEV_COLOR_ENV) >> 1, - (bp.address - BPMEM_TEV_COLOR_ENV) & 1, bp.newvalue); + pixel_shader_manager.SetTevCombiner((bp.address - BPMEM_TEV_COLOR_ENV) >> 1, + (bp.address - BPMEM_TEV_COLOR_ENV) & 1, bp.newvalue); return; default: break; @@ -749,6 +750,8 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) // Call browser: OpcodeDecoding.cpp RunCallback::OnBP() void LoadBPReg(u8 reg, u32 value, int cycles_into_future) { + auto& system = Core::System::GetInstance(); + int oldval = ((u32*)&bpmem)[reg]; int newval = (oldval & ~bpmem.bpMask) | (value & bpmem.bpMask); int changes = (oldval ^ newval) & 0xFFFFFF; @@ -759,7 +762,7 @@ void LoadBPReg(u8 reg, u32 value, int cycles_into_future) if (reg != BPMEM_BP_MASK) bpmem.bpMask = 0xFFFFFF; - BPWritten(bp, cycles_into_future); + BPWritten(system.GetPixelShaderManager(), bp, cycles_into_future); } void LoadBPRegPreprocess(u8 reg, u32 value, int cycles_into_future) diff --git a/Source/Core/VideoCommon/BoundingBox.cpp b/Source/Core/VideoCommon/BoundingBox.cpp index f5ecc8478b..af0961aab6 100644 --- a/Source/Core/VideoCommon/BoundingBox.cpp +++ b/Source/Core/VideoCommon/BoundingBox.cpp @@ -13,16 +13,16 @@ #include -void BoundingBox::Enable() +void BoundingBox::Enable(PixelShaderManager& pixel_shader_manager) { m_is_active = true; - PixelShaderManager::SetBoundingBoxActive(m_is_active); + pixel_shader_manager.SetBoundingBoxActive(m_is_active); } -void BoundingBox::Disable() +void BoundingBox::Disable(PixelShaderManager& pixel_shader_manager) { m_is_active = false; - PixelShaderManager::SetBoundingBoxActive(m_is_active); + pixel_shader_manager.SetBoundingBoxActive(m_is_active); } void BoundingBox::Flush() diff --git a/Source/Core/VideoCommon/BoundingBox.h b/Source/Core/VideoCommon/BoundingBox.h index 8583986a36..bf8ceeb818 100644 --- a/Source/Core/VideoCommon/BoundingBox.h +++ b/Source/Core/VideoCommon/BoundingBox.h @@ -8,6 +8,7 @@ #include "Common/CommonTypes.h" +class PixelShaderManager; class PointerWrap; using BBoxType = s32; @@ -20,8 +21,8 @@ public: virtual ~BoundingBox() = default; bool IsEnabled() const { return m_is_active; } - void Enable(); - void Disable(); + void Enable(PixelShaderManager& pixel_shader_manager); + void Disable(PixelShaderManager& pixel_shader_manager); void Flush(); diff --git a/Source/Core/VideoCommon/PixelEngine.cpp b/Source/Core/VideoCommon/PixelEngine.cpp index b1ede079d0..6cc9c05c02 100644 --- a/Source/Core/VideoCommon/PixelEngine.cpp +++ b/Source/Core/VideoCommon/PixelEngine.cpp @@ -146,8 +146,9 @@ void PixelEngineManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base) // BBOX registers, readonly and need to update a flag. for (int i = 0; i < 4; ++i) { - mmio->Register(base | (PE_BBOX_LEFT + 2 * i), MMIO::ComplexRead([i](Core::System&, u32) { - g_renderer->BBoxDisable(); + mmio->Register(base | (PE_BBOX_LEFT + 2 * i), + MMIO::ComplexRead([i](Core::System& system, u32) { + g_renderer->BBoxDisable(system.GetPixelShaderManager()); return g_video_backend->Video_GetBoundingBox(i); }), MMIO::InvalidWrite()); diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp index b0319e1f0e..35db2c6684 100644 --- a/Source/Core/VideoCommon/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/PixelShaderManager.cpp @@ -12,21 +12,13 @@ #include "VideoCommon/VideoConfig.h" #include "VideoCommon/XFMemory.h" -bool PixelShaderManager::s_bFogRangeAdjustChanged; -bool PixelShaderManager::s_bViewPortChanged; -bool PixelShaderManager::s_bIndirectDirty; -bool PixelShaderManager::s_bDestAlphaDirty; - -PixelShaderConstants PixelShaderManager::constants; -bool PixelShaderManager::dirty; - void PixelShaderManager::Init() { constants = {}; // Init any intial constants which aren't zero when bpmem is zero. - s_bFogRangeAdjustChanged = true; - s_bViewPortChanged = false; + m_fog_range_adjusted_changed = true; + m_viewport_changed = false; SetIndMatrixChanged(0); SetIndMatrixChanged(1); @@ -80,7 +72,7 @@ void PixelShaderManager::Dirty() { // This function is called after a savestate is loaded. // Any constants that can changed based on settings should be re-calculated - s_bFogRangeAdjustChanged = true; + m_fog_range_adjusted_changed = true; SetEfbScaleChanged(g_renderer->EFBToScaledXf(1), g_renderer->EFBToScaledYf(1)); SetFogParamChanged(); @@ -90,7 +82,7 @@ void PixelShaderManager::Dirty() void PixelShaderManager::SetConstants() { - if (s_bFogRangeAdjustChanged) + if (m_fog_range_adjusted_changed) { // set by two components, so keep changed flag here // TODO: try to split both registers and move this logic to the shader @@ -129,18 +121,18 @@ void PixelShaderManager::SetConstants() } dirty = true; - s_bFogRangeAdjustChanged = false; + m_fog_range_adjusted_changed = false; } - if (s_bViewPortChanged) + if (m_viewport_changed) { constants.zbias[1][0] = (s32)xfmem.viewport.farZ; constants.zbias[1][1] = (s32)xfmem.viewport.zRange; dirty = true; - s_bViewPortChanged = false; + m_viewport_changed = false; } - if (s_bIndirectDirty) + if (m_indirect_dirty) { for (int i = 0; i < 4; i++) constants.pack1[i][3] = 0; @@ -162,10 +154,10 @@ void PixelShaderManager::SetConstants() } dirty = true; - s_bIndirectDirty = false; + m_indirect_dirty = false; } - if (s_bDestAlphaDirty) + if (m_dest_alpha_dirty) { // Destination alpha is only enabled if alpha writes are enabled. Force entire uniform to zero // when disabled. @@ -240,7 +232,7 @@ void PixelShaderManager::SetTevCombiner(int index, int alpha, u32 combiner) void PixelShaderManager::SetTevIndirectChanged() { - s_bIndirectDirty = true; + m_indirect_dirty = true; } void PixelShaderManager::SetAlpha() @@ -268,7 +260,7 @@ void PixelShaderManager::SetAlphaTestChanged() void PixelShaderManager::SetDestAlphaChanged() { - s_bDestAlphaDirty = true; + m_dest_alpha_dirty = true; } void PixelShaderManager::SetTexDims(int texmapid, u32 width, u32 height) @@ -299,8 +291,8 @@ void PixelShaderManager::SetZTextureBias() void PixelShaderManager::SetViewportChanged() { - s_bViewPortChanged = true; - s_bFogRangeAdjustChanged = + m_viewport_changed = true; + m_fog_range_adjusted_changed = true; // TODO: Shouldn't be necessary with an accurate fog range adjust implementation } @@ -430,7 +422,7 @@ void PixelShaderManager::SetFogRangeAdjustChanged() if (g_ActiveConfig.bDisableFog) return; - s_bFogRangeAdjustChanged = true; + m_fog_range_adjusted_changed = true; if (constants.fogRangeBase != bpmem.fogRange.Base.hex) { @@ -442,7 +434,7 @@ void PixelShaderManager::SetFogRangeAdjustChanged() void PixelShaderManager::SetGenModeChanged() { constants.genmode = bpmem.genMode.hex; - s_bIndirectDirty = true; + m_indirect_dirty = true; dirty = true; } @@ -462,7 +454,7 @@ void PixelShaderManager::SetZModeControl() constants.dither = dither; dirty = true; } - s_bDestAlphaDirty = true; + m_dest_alpha_dirty = true; } void PixelShaderManager::SetBlendModeChanged() @@ -520,7 +512,7 @@ void PixelShaderManager::SetBlendModeChanged() constants.logic_op_mode = state.logicmode; dirty = true; } - s_bDestAlphaDirty = true; + m_dest_alpha_dirty = true; } void PixelShaderManager::SetBoundingBoxActive(bool active) @@ -535,10 +527,10 @@ void PixelShaderManager::SetBoundingBoxActive(bool active) void PixelShaderManager::DoState(PointerWrap& p) { - p.Do(s_bFogRangeAdjustChanged); - p.Do(s_bViewPortChanged); - p.Do(s_bIndirectDirty); - p.Do(s_bDestAlphaDirty); + p.Do(m_fog_range_adjusted_changed); + p.Do(m_viewport_changed); + p.Do(m_indirect_dirty); + p.Do(m_dest_alpha_dirty); p.Do(constants); diff --git a/Source/Core/VideoCommon/PixelShaderManager.h b/Source/Core/VideoCommon/PixelShaderManager.h index 614504998e..f0c8b5774f 100644 --- a/Source/Core/VideoCommon/PixelShaderManager.h +++ b/Source/Core/VideoCommon/PixelShaderManager.h @@ -9,51 +9,52 @@ class PointerWrap; // The non-API dependent parts. -class PixelShaderManager +class PixelShaderManager final { public: - static void Init(); - static void Dirty(); - static void DoState(PointerWrap& p); + void Init(); + void Dirty(); + void DoState(PointerWrap& p); - static void SetConstants(); // sets pixel shader constants + void SetConstants(); // sets pixel shader constants // constant management // Some of these functions grab the constant values from global state, // so make sure to call them after memory is committed - static void SetTevColor(int index, int component, s32 value); - static void SetTevKonstColor(int index, int component, s32 value); - static void SetTevOrder(int index, u32 order); - static void SetTevKSel(int index, u32 ksel); - static void SetTevCombiner(int index, int alpha, u32 combiner); - static void SetAlpha(); - static void SetAlphaTestChanged(); - static void SetDestAlphaChanged(); - static void SetTexDims(int texmapid, u32 width, u32 height); - static void SetSamplerState(int texmapid, u32 tm0, u32 tm1); - static void SetZTextureBias(); - static void SetViewportChanged(); - static void SetEfbScaleChanged(float scalex, float scaley); - static void SetZSlope(float dfdx, float dfdy, float f0); - static void SetIndMatrixChanged(int matrixidx); - static void SetTevIndirectChanged(); - static void SetZTextureTypeChanged(); - static void SetZTextureOpChanged(); - static void SetIndTexScaleChanged(bool high); - static void SetTexCoordChanged(u8 texmapid); - static void SetFogColorChanged(); - static void SetFogParamChanged(); - static void SetFogRangeAdjustChanged(); - static void SetGenModeChanged(); - static void SetZModeControl(); - static void SetBlendModeChanged(); - static void SetBoundingBoxActive(bool active); + void SetTevColor(int index, int component, s32 value); + void SetTevKonstColor(int index, int component, s32 value); + void SetTevOrder(int index, u32 order); + void SetTevKSel(int index, u32 ksel); + void SetTevCombiner(int index, int alpha, u32 combiner); + void SetAlpha(); + void SetAlphaTestChanged(); + void SetDestAlphaChanged(); + void SetTexDims(int texmapid, u32 width, u32 height); + void SetSamplerState(int texmapid, u32 tm0, u32 tm1); + void SetZTextureBias(); + void SetViewportChanged(); + void SetEfbScaleChanged(float scalex, float scaley); + void SetZSlope(float dfdx, float dfdy, float f0); + void SetIndMatrixChanged(int matrixidx); + void SetTevIndirectChanged(); + void SetZTextureTypeChanged(); + void SetZTextureOpChanged(); + void SetIndTexScaleChanged(bool high); + void SetTexCoordChanged(u8 texmapid); + void SetFogColorChanged(); + void SetFogParamChanged(); + void SetFogRangeAdjustChanged(); + void SetGenModeChanged(); + void SetZModeControl(); + void SetBlendModeChanged(); + void SetBoundingBoxActive(bool active); - static PixelShaderConstants constants; - static bool dirty; + PixelShaderConstants constants{}; + bool dirty = false; - static bool s_bFogRangeAdjustChanged; - static bool s_bViewPortChanged; - static bool s_bIndirectDirty; - static bool s_bDestAlphaDirty; +private: + bool m_fog_range_adjusted_changed = false; + bool m_viewport_changed = false; + bool m_indirect_dirty = false; + bool m_dest_alpha_dirty = false; }; diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 43e7de5e10..b4a40195c7 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -218,14 +218,14 @@ bool Renderer::IsBBoxEnabled() const return m_bounding_box->IsEnabled(); } -void Renderer::BBoxEnable() +void Renderer::BBoxEnable(PixelShaderManager& pixel_shader_manager) { - m_bounding_box->Enable(); + m_bounding_box->Enable(pixel_shader_manager); } -void Renderer::BBoxDisable() +void Renderer::BBoxDisable(PixelShaderManager& pixel_shader_manager) { - m_bounding_box->Disable(); + m_bounding_box->Disable(pixel_shader_manager); } u16 Renderer::BBoxRead(u32 index) @@ -421,7 +421,9 @@ bool Renderer::CalculateTargetSize() { m_target_width = new_efb_width; m_target_height = new_efb_height; - PixelShaderManager::SetEfbScaleChanged(EFBToScaledXf(1), EFBToScaledYf(1)); + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + pixel_shader_manager.SetEfbScaleChanged(EFBToScaledXf(1), EFBToScaledYf(1)); return true; } return false; diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index e45cc244c1..853a840f39 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -42,6 +42,7 @@ class AbstractStagingTexture; class BoundingBox; class NativeVertexFormat; class NetPlayChatUI; +class PixelShaderManager; class PointerWrap; struct TextureConfig; struct ComputePipelineConfig; @@ -216,8 +217,8 @@ public: virtual void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points); bool IsBBoxEnabled() const; - void BBoxEnable(); - void BBoxDisable(); + void BBoxEnable(PixelShaderManager& pixel_shader_manager); + void BBoxDisable(PixelShaderManager& pixel_shader_manager); u16 BBoxRead(u32 index); void BBoxWrite(u32 index, u16 value); void BBoxFlush(); diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index e6fa4f6fbe..14cf207034 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1054,18 +1054,22 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex, } g_renderer->SetSamplerState(index, state); - PixelShaderManager::SetSamplerState(index, state.tm0.hex, state.tm1.hex); + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + pixel_shader_manager.SetSamplerState(index, state.tm0.hex, state.tm1.hex); } void TextureCacheBase::BindTextures(BitSet32 used_textures) { + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); for (u32 i = 0; i < bound_textures.size(); i++) { const TCacheEntry* tentry = bound_textures[i]; if (used_textures[i] && tentry) { g_renderer->SetTexture(i, tentry->texture.get()); - PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height); + pixel_shader_manager.SetTexDims(i, tentry->native_width, tentry->native_height); const float custom_tex_scale = tentry->GetWidth() / float(tentry->native_width); SetSamplerState(i, custom_tex_scale, tentry->is_custom_tex, tentry->has_arbitrary_mips); diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 273f67c746..1c5998862c 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -15,6 +15,7 @@ #include "Core/ConfigManager.h" #include "Core/DolphinAnalytics.h" +#include "Core/System.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/BoundingBox.h" @@ -317,9 +318,11 @@ void VertexManagerBase::UploadUniforms() void VertexManagerBase::InvalidateConstants() { + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); VertexShaderManager::dirty = true; GeometryShaderManager::dirty = true; - PixelShaderManager::dirty = true; + pixel_shader_manager.dirty = true; } void VertexManagerBase::UploadUtilityUniforms(const void* uniforms, u32 uniforms_size) @@ -481,6 +484,9 @@ void VertexManagerBase::Flush() } } + auto& system = Core::System::GetInstance(); + auto& pixel_shader_manager = system.GetPixelShaderManager(); + CalculateBinormals(VertexLoaderManager::GetCurrentVertexFormat()); // Calculate ZSlope for zfreeze const auto used_textures = UsedTextures(); @@ -514,7 +520,7 @@ void VertexManagerBase::Flush() } else if (m_zslope.dirty && !m_cull_all) // or apply any dirty ZSlopes { - PixelShaderManager::SetZSlope(m_zslope.dfdx, m_zslope.dfdy, m_zslope.f0); + pixel_shader_manager.SetZSlope(m_zslope.dfdx, m_zslope.dfdy, m_zslope.f0); m_zslope.dirty = false; } @@ -559,7 +565,7 @@ void VertexManagerBase::Flush() // Now we can upload uniforms, as nothing else will override them. GeometryShaderManager::SetConstants(m_current_primitive_type); - PixelShaderManager::SetConstants(); + pixel_shader_manager.SetConstants(); UploadUniforms(); // Update the pipeline, or compile one if needed. diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index 41ae126693..18ab088fbb 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -330,7 +330,7 @@ void VideoBackendBase::InitializeShared() VertexLoaderManager::Init(); VertexShaderManager::Init(); GeometryShaderManager::Init(); - PixelShaderManager::Init(); + system.GetPixelShaderManager().Init(); TMEM::Init(); g_Config.VerifyValidity(); diff --git a/Source/Core/VideoCommon/VideoState.cpp b/Source/Core/VideoCommon/VideoState.cpp index 2f2c7a256e..20af9c9f2b 100644 --- a/Source/Core/VideoCommon/VideoState.cpp +++ b/Source/Core/VideoCommon/VideoState.cpp @@ -73,7 +73,7 @@ void VideoCommon_DoState(PointerWrap& p) // the old way of replaying current bpmem as writes to push side effects to pixel shader manager // doesn't really work. - PixelShaderManager::DoState(p); + system.GetPixelShaderManager().DoState(p); p.DoMarker("PixelShaderManager"); VertexShaderManager::DoState(p); diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp index 96ab0cd444..dd88572716 100644 --- a/Source/Core/VideoCommon/XFStructs.cpp +++ b/Source/Core/VideoCommon/XFStructs.cpp @@ -118,11 +118,14 @@ static void XFRegWritten(u32 address, u32 value) case XFMEM_SETVIEWPORT + 3: case XFMEM_SETVIEWPORT + 4: case XFMEM_SETVIEWPORT + 5: + { + auto& system = Core::System::GetInstance(); g_vertex_manager->Flush(); VertexShaderManager::SetViewportChanged(); - PixelShaderManager::SetViewportChanged(); + system.GetPixelShaderManager().SetViewportChanged(); GeometryShaderManager::SetViewportChanged(); break; + } case XFMEM_SETPROJECTION: case XFMEM_SETPROJECTION + 1: