diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index d48d67a237..98699a784f 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -738,7 +738,7 @@ void SaveScreenShot() SetState(State::Paused); - Renderer::SetScreenshot(GenerateScreenshotName()); + g_renderer->SetScreenshot(GenerateScreenshotName()); if (!bPaused) SetState(State::Running); @@ -752,7 +752,7 @@ void SaveScreenShot(const std::string& name) std::string filePath = GenerateScreenshotFolderPath() + name + ".png"; - Renderer::SetScreenshot(filePath); + g_renderer->SetScreenshot(filePath); if (!bPaused) SetState(State::Running); diff --git a/Source/Core/VideoBackends/D3D/FramebufferManager.cpp b/Source/Core/VideoBackends/D3D/FramebufferManager.cpp index 20e90d20f7..46554bdfaf 100644 --- a/Source/Core/VideoBackends/D3D/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/D3D/FramebufferManager.cpp @@ -100,8 +100,8 @@ D3DTexture2D*& FramebufferManager::GetResolvedEFBDepthTexture() FramebufferManager::FramebufferManager() { - m_target_width = Renderer::GetTargetWidth(); - m_target_height = Renderer::GetTargetHeight(); + m_target_width = g_renderer->GetTargetWidth(); + m_target_height = g_renderer->GetTargetHeight(); if (m_target_height < 1) { m_target_height = 1; @@ -318,8 +318,8 @@ void XFBSource::CopyEFB(float Gamma) D3D::SetPointCopySampler(); D3D::drawShadedTexQuad( - FramebufferManager::GetEFBColorTexture()->GetSRV(), &rect, Renderer::GetTargetWidth(), - Renderer::GetTargetHeight(), PixelShaderCache::GetColorCopyProgram(true), + FramebufferManager::GetEFBColorTexture()->GetSRV(), &rect, g_renderer->GetTargetWidth(), + g_renderer->GetTargetHeight(), PixelShaderCache::GetColorCopyProgram(true), VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout(), GeometryShaderCache::GetCopyGeometryShader(), Gamma); diff --git a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp index dd47479b37..7b9bfaeaa3 100644 --- a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp +++ b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp @@ -137,7 +137,7 @@ void PSTextureEncoder::Encode(u8* dst, u32 format, u32 native_width, u32 bytes_p D3D::SetPointCopySampler(); D3D::drawShadedTexQuad( - pEFB, targetRect.AsRECT(), Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), + pEFB, targetRect.AsRECT(), g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight(), SetStaticShader(format, is_depth_copy, isIntensity, scaleByHalf), VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout()); diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index bf1500ab0f..7e74177da8 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -324,8 +324,7 @@ bool Renderer::CheckForResize() int client_height = rcWindow.bottom - rcWindow.top; // Sanity check - if ((client_width != Renderer::GetBackbufferWidth() || - client_height != Renderer::GetBackbufferHeight()) && + if ((client_width != GetBackbufferWidth() || client_height != GetBackbufferHeight()) && client_width >= 4 && client_height >= 4) { return true; diff --git a/Source/Core/VideoBackends/D3D/Render.h b/Source/Core/VideoBackends/D3D/Render.h index a9b59d1265..4fdc85afcb 100644 --- a/Source/Core/VideoBackends/D3D/Render.h +++ b/Source/Core/VideoBackends/D3D/Render.h @@ -60,7 +60,7 @@ public: void ReinterpretPixelData(unsigned int convtype) override; - static bool CheckForResize(); + bool CheckForResize(); u32 GetMaxTextureSize() override; diff --git a/Source/Core/VideoBackends/D3D/TextureCache.cpp b/Source/Core/VideoBackends/D3D/TextureCache.cpp index 116d849f41..438c210726 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.cpp +++ b/Source/Core/VideoBackends/D3D/TextureCache.cpp @@ -240,7 +240,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(bool is_depth_copy, const EFBRe // Create texture copy D3D::drawShadedTexQuad( - efbTexSRV, &sourcerect, Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), + efbTexSRV, &sourcerect, g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight(), is_depth_copy ? PixelShaderCache::GetDepthMatrixProgram(multisampled) : PixelShaderCache::GetColorMatrixProgram(multisampled), VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout(), diff --git a/Source/Core/VideoBackends/D3D12/FramebufferManager.cpp b/Source/Core/VideoBackends/D3D12/FramebufferManager.cpp index f257448b88..3229980b29 100644 --- a/Source/Core/VideoBackends/D3D12/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/D3D12/FramebufferManager.cpp @@ -86,8 +86,8 @@ D3DTexture2D*& FramebufferManager::GetResolvedEFBDepthTexture() FramebufferManager::FramebufferManager() { - m_target_width = std::max(Renderer::GetTargetWidth(), 1); - m_target_height = std::max(Renderer::GetTargetHeight(), 1); + m_target_width = std::max(g_renderer->GetTargetWidth(), 1); + m_target_height = std::max(g_renderer->GetTargetHeight(), 1); DXGI_SAMPLE_DESC sample_desc; sample_desc.Count = g_ActiveConfig.iMultisamples; @@ -525,7 +525,7 @@ void XFBSource::CopyEFB(float gamma) D3D::SetPointCopySampler(); D3D::DrawShadedTexQuad(FramebufferManager::GetEFBColorTexture(), &rect, - Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), + g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight(), StaticShaderCache::GetColorCopyPixelShader(true), StaticShaderCache::GetSimpleVertexShader(), StaticShaderCache::GetSimpleVertexShaderInputLayout(), diff --git a/Source/Core/VideoBackends/D3D12/PSTextureEncoder.cpp b/Source/Core/VideoBackends/D3D12/PSTextureEncoder.cpp index d582d5a414..8e70540d94 100644 --- a/Source/Core/VideoBackends/D3D12/PSTextureEncoder.cpp +++ b/Source/Core/VideoBackends/D3D12/PSTextureEncoder.cpp @@ -166,7 +166,7 @@ void PSTextureEncoder::Encode(u8* dst, u32 format, u32 native_width, u32 bytes_p D3D::SetPointCopySampler(); D3D::DrawShadedTexQuad( - efb_source, target_rect.AsRECT(), Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), + efb_source, target_rect.AsRECT(), g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight(), SetStaticShader(format, is_depth_copy, is_intensity, scale_by_half), StaticShaderCache::GetSimpleVertexShader(), StaticShaderCache::GetSimpleVertexShaderInputLayout(), D3D12_SHADER_BYTECODE(), 1.0f, 0, diff --git a/Source/Core/VideoBackends/D3D12/Render.cpp b/Source/Core/VideoBackends/D3D12/Render.cpp index 812a0adf11..c9e8c618c1 100644 --- a/Source/Core/VideoBackends/D3D12/Render.cpp +++ b/Source/Core/VideoBackends/D3D12/Render.cpp @@ -308,7 +308,7 @@ TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc) // With D3D, we have to resize the backbuffer if the window changed // size. -__declspec(noinline) bool Renderer::CheckForResize() +bool Renderer::CheckForResize() { RECT rc_window; GetClientRect(D3D::hWnd, &rc_window); diff --git a/Source/Core/VideoBackends/D3D12/Render.h b/Source/Core/VideoBackends/D3D12/Render.h index 140fd69b83..bb40e689eb 100644 --- a/Source/Core/VideoBackends/D3D12/Render.h +++ b/Source/Core/VideoBackends/D3D12/Render.h @@ -59,7 +59,7 @@ public: void ReinterpretPixelData(unsigned int conv_type) override; - static bool CheckForResize(); + bool CheckForResize(); u32 GetMaxTextureSize() override; diff --git a/Source/Core/VideoBackends/D3D12/TextureCache.cpp b/Source/Core/VideoBackends/D3D12/TextureCache.cpp index 59198dca8d..3fe7e77e4f 100644 --- a/Source/Core/VideoBackends/D3D12/TextureCache.cpp +++ b/Source/Core/VideoBackends/D3D12/TextureCache.cpp @@ -288,7 +288,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(bool is_depth_copy, const EFBRe // Create texture copy D3D::DrawShadedTexQuad( - efb_tex, &sourcerect, Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), + efb_tex, &sourcerect, g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight(), is_depth_copy ? StaticShaderCache::GetDepthMatrixPixelShader(multisampled) : StaticShaderCache::GetColorMatrixPixelShader(multisampled), StaticShaderCache::GetSimpleVertexShader(), diff --git a/Source/Core/VideoBackends/OGL/Render.h b/Source/Core/VideoBackends/OGL/Render.h index 696a9dcb36..5ae65f1395 100644 --- a/Source/Core/VideoBackends/OGL/Render.h +++ b/Source/Core/VideoBackends/OGL/Render.h @@ -71,8 +71,8 @@ public: Renderer(); ~Renderer(); - static void Init(); - static void Shutdown(); + void Init(); + void Shutdown(); void SetBlendMode(bool forceUpdate) override; void SetScissorRect(const EFBRectangle& rc) override; diff --git a/Source/Core/VideoBackends/OGL/main.cpp b/Source/Core/VideoBackends/OGL/main.cpp index 0d46982cca..7b070aac5b 100644 --- a/Source/Core/VideoBackends/OGL/main.cpp +++ b/Source/Core/VideoBackends/OGL/main.cpp @@ -149,7 +149,7 @@ void VideoBackend::Video_Prepare() ProgramShaderCache::Init(); g_texture_cache = std::make_unique(); g_sampler_cache = std::make_unique(); - Renderer::Init(); + static_cast(g_renderer.get())->Init(); TextureConverter::Init(); BoundingBox::Init(); } @@ -166,7 +166,7 @@ void VideoBackend::Video_Cleanup() // The following calls are NOT Thread Safe // And need to be called from the video thread CleanupShared(); - Renderer::Shutdown(); + static_cast(g_renderer.get())->Shutdown(); BoundingBox::Shutdown(); TextureConverter::Shutdown(); g_sampler_cache.reset(); diff --git a/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp b/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp index 57b6183e77..9b07f8645e 100644 --- a/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp @@ -226,8 +226,8 @@ void FramebufferManager::DestroyEFBRenderPass() bool FramebufferManager::CreateEFBFramebuffer() { - m_efb_width = static_cast(std::max(Renderer::GetTargetWidth(), 1)); - m_efb_height = static_cast(std::max(Renderer::GetTargetHeight(), 1)); + m_efb_width = static_cast(std::max(g_renderer->GetTargetWidth(), 1)); + m_efb_height = static_cast(std::max(g_renderer->GetTargetHeight(), 1)); m_efb_layers = (g_ActiveConfig.iStereoMode != STEREO_OFF) ? 2 : 1; INFO_LOG(VIDEO, "EFB size: %ux%ux%u", m_efb_width, m_efb_height, m_efb_layers); diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp index fc6af84f27..f41354730d 100644 --- a/Source/Core/VideoCommon/AsyncRequests.cpp +++ b/Source/Core/VideoCommon/AsyncRequests.cpp @@ -136,8 +136,8 @@ void AsyncRequests::HandleEvent(const AsyncRequests::Event& e) break; case Event::SWAP_EVENT: - Renderer::Swap(e.swap_event.xfbAddr, e.swap_event.fbWidth, e.swap_event.fbStride, - e.swap_event.fbHeight, rc, e.time); + g_renderer->Swap(e.swap_event.xfbAddr, e.swap_event.fbWidth, e.swap_event.fbStride, + e.swap_event.fbHeight, rc, e.time); break; case Event::BBOX_READ: diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp index af114006b5..0bb2844a62 100644 --- a/Source/Core/VideoCommon/BPFunctions.cpp +++ b/Source/Core/VideoCommon/BPFunctions.cpp @@ -156,7 +156,7 @@ void OnPixelFormatChange() if (!g_ActiveConfig.bEFBEmulateFormatChanges) return; - auto old_format = Renderer::GetPrevPixelFormat(); + auto old_format = g_renderer->GetPrevPixelFormat(); auto new_format = bpmem.zcontrol.pixel_format; // no need to reinterpret pixel data in these cases @@ -209,7 +209,7 @@ skip: DEBUG_LOG(VIDEO, "pixelfmt: pixel=%d, zc=%d", static_cast(new_format), static_cast(bpmem.zcontrol.zformat)); - Renderer::StorePixelFormat(new_format); + g_renderer->StorePixelFormat(new_format); } void SetInterlacingMode(const BPCmd& bp) diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 128969af52..8384080099 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -261,7 +261,7 @@ static void BPWritten(const BPCmd& bp) "fbStride: %u | fbHeight: %u", destAddr, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, bpmem.copyTexSrcWH.x + 1, destStride, height); - Renderer::RenderToXFB(destAddr, srcRect, destStride, height, s_gammaLUT[PE_copy.gamma]); + g_renderer->RenderToXFB(destAddr, srcRect, destStride, height, s_gammaLUT[PE_copy.gamma]); } // Clear the rectangular region after copying it. diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.cpp b/Source/Core/VideoCommon/FramebufferManagerBase.cpp index 33c8015f76..0fc65a5443 100644 --- a/Source/Core/VideoCommon/FramebufferManagerBase.cpp +++ b/Source/Core/VideoCommon/FramebufferManagerBase.cpp @@ -253,8 +253,8 @@ int FramebufferManagerBase::ScaleToVirtualXfbWidth(int x) if (g_ActiveConfig.RealXFBEnabled()) return x; - return x * (int)Renderer::GetTargetRectangle().GetWidth() / - (int)FramebufferManagerBase::LastXfbWidth(); + return x * static_cast(g_renderer->GetTargetRectangle().GetWidth()) / + static_cast(FramebufferManagerBase::LastXfbWidth()); } int FramebufferManagerBase::ScaleToVirtualXfbHeight(int y) @@ -262,6 +262,6 @@ int FramebufferManagerBase::ScaleToVirtualXfbHeight(int y) if (g_ActiveConfig.RealXFBEnabled()) return y; - return y * (int)Renderer::GetTargetRectangle().GetHeight() / - (int)FramebufferManagerBase::LastXfbHeight(); + return y * static_cast(g_renderer->GetTargetRectangle().GetHeight()) / + static_cast(FramebufferManagerBase::LastXfbHeight()); } diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp index f029751363..c9e102ab5b 100644 --- a/Source/Core/VideoCommon/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/PixelShaderManager.cpp @@ -27,7 +27,6 @@ void PixelShaderManager::Init() s_bFogRangeAdjustChanged = true; s_bViewPortChanged = false; - SetEfbScaleChanged(); SetIndMatrixChanged(0); SetIndMatrixChanged(1); SetIndMatrixChanged(2); @@ -78,7 +77,8 @@ void PixelShaderManager::SetConstants() // so to simplify I use the hi coefficient as K in the shader taking 256 as the scale // TODO: Shouldn't this be EFBToScaledXf? constants.fogf[0][0] = ScreenSpaceCenter; - constants.fogf[0][1] = (float)Renderer::EFBToScaledX((int)(2.0f * xfmem.viewport.wd)); + constants.fogf[0][1] = + static_cast(g_renderer->EFBToScaledX(static_cast(2.0f * xfmem.viewport.wd))); constants.fogf[0][2] = bpmem.fogRange.K[4].HI / 256.0f; } else @@ -161,8 +161,8 @@ void PixelShaderManager::SetViewportChanged() void PixelShaderManager::SetEfbScaleChanged() { - constants.efbscale[0] = 1.0f / Renderer::EFBToScaledXf(1); - constants.efbscale[1] = 1.0f / Renderer::EFBToScaledYf(1); + constants.efbscale[0] = 1.0f / g_renderer->EFBToScaledXf(1); + constants.efbscale[1] = 1.0f / g_renderer->EFBToScaledYf(1); dirty = true; } diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index f47288ea4e..6f61a84d94 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -64,39 +64,6 @@ static int OSDTime; std::unique_ptr g_renderer; -std::mutex Renderer::s_criticalScreenshot; -std::string Renderer::s_sScreenshotName; - -Common::Event Renderer::s_screenshotCompleted; -Common::Flag Renderer::s_screenshot; - -// The framebuffer size -int Renderer::s_target_width; -int Renderer::s_target_height; - -// TODO: Add functionality to reinit all the render targets when the window is resized. -int Renderer::s_backbuffer_width; -int Renderer::s_backbuffer_height; - -std::unique_ptr Renderer::m_post_processor; - -// Final surface changing -Common::Flag Renderer::s_surface_needs_change; -Common::Event Renderer::s_surface_changed; -void* Renderer::s_new_surface_handle; - -TargetRectangle Renderer::target_rc; - -int Renderer::s_last_efb_scale; - -bool Renderer::XFBWrited; - -PEControl::PixelFormat Renderer::prev_efb_format = PEControl::INVALID_FMT; -unsigned int Renderer::efb_scale_numeratorX = 1; -unsigned int Renderer::efb_scale_numeratorY = 1; -unsigned int Renderer::efb_scale_denominatorX = 1; -unsigned int Renderer::efb_scale_denominatorY = 1; - // The maximum depth that is written to the depth buffer should never exceed this value. // This is necessary because we use a 2^24 divisor for all our depth values to prevent // floating-point round-trip errors. However the console GPU doesn't ever write a value @@ -118,11 +85,6 @@ Renderer::Renderer() Renderer::~Renderer() { - // invalidate previous efb format - prev_efb_format = PEControl::INVALID_FMT; - - efb_scale_numeratorX = efb_scale_numeratorY = efb_scale_denominatorX = efb_scale_denominatorY = 1; - ShutdownFrameDumping(); if (m_frame_dump_thread.joinable()) m_frame_dump_thread.join(); diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 46c01afb78..ba855a1d11 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -81,46 +81,46 @@ public: virtual void RestoreAPIState() {} // Ideal internal resolution - determined by display resolution (automatic scaling) and/or a // multiple of the native EFB resolution - static int GetTargetWidth() { return s_target_width; } - static int GetTargetHeight() { return s_target_height; } + int GetTargetWidth() { return s_target_width; } + int GetTargetHeight() { return s_target_height; } // Display resolution - static int GetBackbufferWidth() { return s_backbuffer_width; } - static int GetBackbufferHeight() { return s_backbuffer_height; } - static void SetWindowSize(int width, int height); + int GetBackbufferWidth() { return s_backbuffer_width; } + int GetBackbufferHeight() { return s_backbuffer_height; } + void SetWindowSize(int width, int height); // EFB coordinate conversion functions // Use this to convert a whole native EFB rect to backbuffer coordinates virtual TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) = 0; - static const TargetRectangle& GetTargetRectangle() { return target_rc; } - static float CalculateDrawAspectRatio(int target_width, int target_height); - static std::tuple ScaleToDisplayAspectRatio(int width, int height); - static TargetRectangle CalculateFrameDumpDrawRectangle(); - static void UpdateDrawRectangle(); + const TargetRectangle& GetTargetRectangle() { return target_rc; } + float CalculateDrawAspectRatio(int target_width, int target_height); + std::tuple ScaleToDisplayAspectRatio(int width, int height); + TargetRectangle CalculateFrameDumpDrawRectangle(); + void UpdateDrawRectangle(); // Use this to convert a single target rectangle to two stereo rectangles - static void ConvertStereoRectangle(const TargetRectangle& rc, TargetRectangle& leftRc, - TargetRectangle& rightRc); + void ConvertStereoRectangle(const TargetRectangle& rc, TargetRectangle& leftRc, + TargetRectangle& rightRc); // Use this to upscale native EFB coordinates to IDEAL internal resolution - static int EFBToScaledX(int x); - static int EFBToScaledY(int y); + int EFBToScaledX(int x); + int EFBToScaledY(int y); // Floating point versions of the above - only use them if really necessary - static float EFBToScaledXf(float x) { return x * ((float)GetTargetWidth() / (float)EFB_WIDTH); } - static float EFBToScaledYf(float y) { return y * ((float)GetTargetHeight() / (float)EFB_HEIGHT); } + float EFBToScaledXf(float x) { return x * ((float)GetTargetWidth() / (float)EFB_WIDTH); } + float EFBToScaledYf(float y) { return y * ((float)GetTargetHeight() / (float)EFB_HEIGHT); } // Random utilities - static void SetScreenshot(const std::string& filename); - static void DrawDebugText(); + void SetScreenshot(const std::string& filename); + void DrawDebugText(); virtual void RenderText(const std::string& text, int left, int top, u32 color) = 0; virtual void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) = 0; virtual void ReinterpretPixelData(unsigned int convtype) = 0; - static void RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbStride, u32 fbHeight, - float Gamma = 1.0f); + void RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbStride, u32 fbHeight, + float Gamma = 1.0f); virtual u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) = 0; virtual void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points) = 0; @@ -129,72 +129,72 @@ public: virtual void BBoxWrite(int index, u16 value) = 0; // Finish up the current frame, print some stats - static void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, - u64 ticks, float Gamma = 1.0f); + void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, u64 ticks, + float Gamma = 1.0f); virtual void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, u64 ticks, float Gamma = 1.0f) = 0; - static PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; } - static void StorePixelFormat(PEControl::PixelFormat new_format) { prev_efb_format = new_format; } + PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; } + void StorePixelFormat(PEControl::PixelFormat new_format) { prev_efb_format = new_format; } PostProcessingShaderImplementation* GetPostProcessor() { return m_post_processor.get(); } // Max height/width virtual u32 GetMaxTextureSize() = 0; - static Common::Event s_screenshotCompleted; + Common::Event s_screenshotCompleted; // Final surface changing // This is called when the surface is resized (WX) or the window changes (Android). virtual void ChangeSurface(void* new_surface_handle) {} protected: - static void CalculateTargetScale(int x, int y, int* scaledX, int* scaledY); + void CalculateTargetScale(int x, int y, int* scaledX, int* scaledY); bool CalculateTargetSize(); - static void CheckFifoRecording(); - static void RecordVideoMemory(); + void CheckFifoRecording(); + void RecordVideoMemory(); bool IsFrameDumping(); void DumpFrameData(const u8* data, int w, int h, int stride, const AVIDump::Frame& state, bool swap_upside_down = false); void FinishFrameData(); - static Common::Flag s_screenshot; - static std::mutex s_criticalScreenshot; - static std::string s_sScreenshotName; + Common::Flag s_screenshot; + std::mutex s_criticalScreenshot; + std::string s_sScreenshotName; // The framebuffer size - static int s_target_width; - static int s_target_height; + int s_target_width = 0; + int s_target_height = 0; // TODO: Add functionality to reinit all the render targets when the window is resized. - static int s_backbuffer_width; - static int s_backbuffer_height; + int s_backbuffer_width = 0; + int s_backbuffer_height = 0; - static TargetRectangle target_rc; + TargetRectangle target_rc; // TODO: Can probably eliminate this static var. - static int s_last_efb_scale; + int s_last_efb_scale = 0; - static bool XFBWrited; + bool XFBWrited = false; FPSCounter m_fps_counter; - static std::unique_ptr m_post_processor; + std::unique_ptr m_post_processor; static const float GX_MAX_DEPTH; - static Common::Flag s_surface_needs_change; - static Common::Event s_surface_changed; - static void* s_new_surface_handle; + Common::Flag s_surface_needs_change; + Common::Event s_surface_changed; + void* s_new_surface_handle = nullptr; private: void RunFrameDumps(); void ShutdownFrameDumping(); - static PEControl::PixelFormat prev_efb_format; - static unsigned int efb_scale_numeratorX; - static unsigned int efb_scale_numeratorY; - static unsigned int efb_scale_denominatorX; - static unsigned int efb_scale_denominatorY; + PEControl::PixelFormat prev_efb_format = PEControl::INVALID_FMT; + unsigned int efb_scale_numeratorX = 1; + unsigned int efb_scale_numeratorY = 1; + unsigned int efb_scale_denominatorX = 1; + unsigned int efb_scale_denominatorY = 1; // frame dumping std::thread m_frame_dump_thread; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 755602f19a..0ad86e82c5 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -385,17 +385,17 @@ TextureCacheBase::DoPartialTextureUpdates(TCacheEntryBase* entry_to_update, u8* entry->native_height != entry->config.height) { ScaleTextureCacheEntryTo(&entry_to_update, - Renderer::EFBToScaledX(entry_to_update->native_width), - Renderer::EFBToScaledY(entry_to_update->native_height)); - ScaleTextureCacheEntryTo(&entry, Renderer::EFBToScaledX(entry->native_width), - Renderer::EFBToScaledY(entry->native_height)); + g_renderer->EFBToScaledX(entry_to_update->native_width), + g_renderer->EFBToScaledY(entry_to_update->native_height)); + ScaleTextureCacheEntryTo(&entry, g_renderer->EFBToScaledX(entry->native_width), + g_renderer->EFBToScaledY(entry->native_height)); - src_x = Renderer::EFBToScaledX(src_x); - src_y = Renderer::EFBToScaledY(src_y); - dst_x = Renderer::EFBToScaledX(dst_x); - dst_y = Renderer::EFBToScaledY(dst_y); - copy_width = Renderer::EFBToScaledX(copy_width); - copy_height = Renderer::EFBToScaledY(copy_height); + src_x = g_renderer->EFBToScaledX(src_x); + src_y = g_renderer->EFBToScaledY(src_y); + dst_x = g_renderer->EFBToScaledX(dst_x); + dst_y = g_renderer->EFBToScaledY(dst_y); + copy_width = g_renderer->EFBToScaledX(copy_width); + copy_height = g_renderer->EFBToScaledY(copy_height); } MathUtil::Rectangle srcrect, dstrect; @@ -1197,8 +1197,10 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo const unsigned int tex_w = scaleByHalf ? srcRect.GetWidth() / 2 : srcRect.GetWidth(); const unsigned int tex_h = scaleByHalf ? srcRect.GetHeight() / 2 : srcRect.GetHeight(); - unsigned int scaled_tex_w = g_ActiveConfig.bCopyEFBScaled ? Renderer::EFBToScaledX(tex_w) : tex_w; - unsigned int scaled_tex_h = g_ActiveConfig.bCopyEFBScaled ? Renderer::EFBToScaledY(tex_h) : tex_h; + unsigned int scaled_tex_w = + g_ActiveConfig.bCopyEFBScaled ? g_renderer->EFBToScaledX(tex_w) : tex_w; + unsigned int scaled_tex_h = + g_ActiveConfig.bCopyEFBScaled ? g_renderer->EFBToScaledY(tex_h) : tex_h; // Remove all texture cache entries at dstAddr // It's not possible to have two EFB copies at the same address, this makes sure any old efb diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 2befde1552..4c3959d92d 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -382,8 +382,8 @@ void VertexShaderManager::SetConstants() // NOTE: If we ever emulate antialiasing, the sample locations set by // BP registers 0x01-0x04 need to be considered here. const float pixel_center_correction = 7.0f / 12.0f - 0.5f; - const float pixel_size_x = 2.f / Renderer::EFBToScaledXf(2.f * xfmem.viewport.wd); - const float pixel_size_y = 2.f / Renderer::EFBToScaledXf(2.f * xfmem.viewport.ht); + const float pixel_size_x = 2.f / g_renderer->EFBToScaledXf(2.f * xfmem.viewport.wd); + const float pixel_size_y = 2.f / g_renderer->EFBToScaledXf(2.f * xfmem.viewport.ht); constants.pixelcentercorrection[0] = pixel_center_correction * pixel_size_x; constants.pixelcentercorrection[1] = pixel_center_correction * pixel_size_y;