VideoCommon: Eliminate static state in Renderer

This commit is contained in:
Stenzek 2017-03-04 16:39:50 +10:00
parent de230f3ebe
commit 277829d842
23 changed files with 99 additions and 136 deletions

View File

@ -738,7 +738,7 @@ void SaveScreenShot()
SetState(State::Paused); SetState(State::Paused);
Renderer::SetScreenshot(GenerateScreenshotName()); g_renderer->SetScreenshot(GenerateScreenshotName());
if (!bPaused) if (!bPaused)
SetState(State::Running); SetState(State::Running);
@ -752,7 +752,7 @@ void SaveScreenShot(const std::string& name)
std::string filePath = GenerateScreenshotFolderPath() + name + ".png"; std::string filePath = GenerateScreenshotFolderPath() + name + ".png";
Renderer::SetScreenshot(filePath); g_renderer->SetScreenshot(filePath);
if (!bPaused) if (!bPaused)
SetState(State::Running); SetState(State::Running);

View File

@ -100,8 +100,8 @@ D3DTexture2D*& FramebufferManager::GetResolvedEFBDepthTexture()
FramebufferManager::FramebufferManager() FramebufferManager::FramebufferManager()
{ {
m_target_width = Renderer::GetTargetWidth(); m_target_width = g_renderer->GetTargetWidth();
m_target_height = Renderer::GetTargetHeight(); m_target_height = g_renderer->GetTargetHeight();
if (m_target_height < 1) if (m_target_height < 1)
{ {
m_target_height = 1; m_target_height = 1;
@ -318,8 +318,8 @@ void XFBSource::CopyEFB(float Gamma)
D3D::SetPointCopySampler(); D3D::SetPointCopySampler();
D3D::drawShadedTexQuad( D3D::drawShadedTexQuad(
FramebufferManager::GetEFBColorTexture()->GetSRV(), &rect, Renderer::GetTargetWidth(), FramebufferManager::GetEFBColorTexture()->GetSRV(), &rect, g_renderer->GetTargetWidth(),
Renderer::GetTargetHeight(), PixelShaderCache::GetColorCopyProgram(true), g_renderer->GetTargetHeight(), PixelShaderCache::GetColorCopyProgram(true),
VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout(), VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout(),
GeometryShaderCache::GetCopyGeometryShader(), Gamma); GeometryShaderCache::GetCopyGeometryShader(), Gamma);

View File

@ -137,7 +137,7 @@ void PSTextureEncoder::Encode(u8* dst, u32 format, u32 native_width, u32 bytes_p
D3D::SetPointCopySampler(); D3D::SetPointCopySampler();
D3D::drawShadedTexQuad( 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), SetStaticShader(format, is_depth_copy, isIntensity, scaleByHalf),
VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout()); VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout());

View File

@ -324,8 +324,7 @@ bool Renderer::CheckForResize()
int client_height = rcWindow.bottom - rcWindow.top; int client_height = rcWindow.bottom - rcWindow.top;
// Sanity check // Sanity check
if ((client_width != Renderer::GetBackbufferWidth() || if ((client_width != GetBackbufferWidth() || client_height != GetBackbufferHeight()) &&
client_height != Renderer::GetBackbufferHeight()) &&
client_width >= 4 && client_height >= 4) client_width >= 4 && client_height >= 4)
{ {
return true; return true;

View File

@ -60,7 +60,7 @@ public:
void ReinterpretPixelData(unsigned int convtype) override; void ReinterpretPixelData(unsigned int convtype) override;
static bool CheckForResize(); bool CheckForResize();
u32 GetMaxTextureSize() override; u32 GetMaxTextureSize() override;

View File

@ -240,7 +240,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(bool is_depth_copy, const EFBRe
// Create texture copy // Create texture copy
D3D::drawShadedTexQuad( D3D::drawShadedTexQuad(
efbTexSRV, &sourcerect, Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), efbTexSRV, &sourcerect, g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight(),
is_depth_copy ? PixelShaderCache::GetDepthMatrixProgram(multisampled) : is_depth_copy ? PixelShaderCache::GetDepthMatrixProgram(multisampled) :
PixelShaderCache::GetColorMatrixProgram(multisampled), PixelShaderCache::GetColorMatrixProgram(multisampled),
VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout(), VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout(),

View File

@ -86,8 +86,8 @@ D3DTexture2D*& FramebufferManager::GetResolvedEFBDepthTexture()
FramebufferManager::FramebufferManager() FramebufferManager::FramebufferManager()
{ {
m_target_width = std::max(Renderer::GetTargetWidth(), 1); m_target_width = std::max(g_renderer->GetTargetWidth(), 1);
m_target_height = std::max(Renderer::GetTargetHeight(), 1); m_target_height = std::max(g_renderer->GetTargetHeight(), 1);
DXGI_SAMPLE_DESC sample_desc; DXGI_SAMPLE_DESC sample_desc;
sample_desc.Count = g_ActiveConfig.iMultisamples; sample_desc.Count = g_ActiveConfig.iMultisamples;
@ -525,7 +525,7 @@ void XFBSource::CopyEFB(float gamma)
D3D::SetPointCopySampler(); D3D::SetPointCopySampler();
D3D::DrawShadedTexQuad(FramebufferManager::GetEFBColorTexture(), &rect, D3D::DrawShadedTexQuad(FramebufferManager::GetEFBColorTexture(), &rect,
Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight(),
StaticShaderCache::GetColorCopyPixelShader(true), StaticShaderCache::GetColorCopyPixelShader(true),
StaticShaderCache::GetSimpleVertexShader(), StaticShaderCache::GetSimpleVertexShader(),
StaticShaderCache::GetSimpleVertexShaderInputLayout(), StaticShaderCache::GetSimpleVertexShaderInputLayout(),

View File

@ -166,7 +166,7 @@ void PSTextureEncoder::Encode(u8* dst, u32 format, u32 native_width, u32 bytes_p
D3D::SetPointCopySampler(); D3D::SetPointCopySampler();
D3D::DrawShadedTexQuad( 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), SetStaticShader(format, is_depth_copy, is_intensity, scale_by_half),
StaticShaderCache::GetSimpleVertexShader(), StaticShaderCache::GetSimpleVertexShader(),
StaticShaderCache::GetSimpleVertexShaderInputLayout(), D3D12_SHADER_BYTECODE(), 1.0f, 0, StaticShaderCache::GetSimpleVertexShaderInputLayout(), D3D12_SHADER_BYTECODE(), 1.0f, 0,

View File

@ -308,7 +308,7 @@ TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
// With D3D, we have to resize the backbuffer if the window changed // With D3D, we have to resize the backbuffer if the window changed
// size. // size.
__declspec(noinline) bool Renderer::CheckForResize() bool Renderer::CheckForResize()
{ {
RECT rc_window; RECT rc_window;
GetClientRect(D3D::hWnd, &rc_window); GetClientRect(D3D::hWnd, &rc_window);

View File

@ -59,7 +59,7 @@ public:
void ReinterpretPixelData(unsigned int conv_type) override; void ReinterpretPixelData(unsigned int conv_type) override;
static bool CheckForResize(); bool CheckForResize();
u32 GetMaxTextureSize() override; u32 GetMaxTextureSize() override;

View File

@ -288,7 +288,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(bool is_depth_copy, const EFBRe
// Create texture copy // Create texture copy
D3D::DrawShadedTexQuad( D3D::DrawShadedTexQuad(
efb_tex, &sourcerect, Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), efb_tex, &sourcerect, g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight(),
is_depth_copy ? StaticShaderCache::GetDepthMatrixPixelShader(multisampled) : is_depth_copy ? StaticShaderCache::GetDepthMatrixPixelShader(multisampled) :
StaticShaderCache::GetColorMatrixPixelShader(multisampled), StaticShaderCache::GetColorMatrixPixelShader(multisampled),
StaticShaderCache::GetSimpleVertexShader(), StaticShaderCache::GetSimpleVertexShader(),

View File

@ -71,8 +71,8 @@ public:
Renderer(); Renderer();
~Renderer(); ~Renderer();
static void Init(); void Init();
static void Shutdown(); void Shutdown();
void SetBlendMode(bool forceUpdate) override; void SetBlendMode(bool forceUpdate) override;
void SetScissorRect(const EFBRectangle& rc) override; void SetScissorRect(const EFBRectangle& rc) override;

View File

@ -149,7 +149,7 @@ void VideoBackend::Video_Prepare()
ProgramShaderCache::Init(); ProgramShaderCache::Init();
g_texture_cache = std::make_unique<TextureCache>(); g_texture_cache = std::make_unique<TextureCache>();
g_sampler_cache = std::make_unique<SamplerCache>(); g_sampler_cache = std::make_unique<SamplerCache>();
Renderer::Init(); static_cast<Renderer*>(g_renderer.get())->Init();
TextureConverter::Init(); TextureConverter::Init();
BoundingBox::Init(); BoundingBox::Init();
} }
@ -166,7 +166,7 @@ void VideoBackend::Video_Cleanup()
// The following calls are NOT Thread Safe // The following calls are NOT Thread Safe
// And need to be called from the video thread // And need to be called from the video thread
CleanupShared(); CleanupShared();
Renderer::Shutdown(); static_cast<Renderer*>(g_renderer.get())->Shutdown();
BoundingBox::Shutdown(); BoundingBox::Shutdown();
TextureConverter::Shutdown(); TextureConverter::Shutdown();
g_sampler_cache.reset(); g_sampler_cache.reset();

View File

@ -226,8 +226,8 @@ void FramebufferManager::DestroyEFBRenderPass()
bool FramebufferManager::CreateEFBFramebuffer() bool FramebufferManager::CreateEFBFramebuffer()
{ {
m_efb_width = static_cast<u32>(std::max(Renderer::GetTargetWidth(), 1)); m_efb_width = static_cast<u32>(std::max(g_renderer->GetTargetWidth(), 1));
m_efb_height = static_cast<u32>(std::max(Renderer::GetTargetHeight(), 1)); m_efb_height = static_cast<u32>(std::max(g_renderer->GetTargetHeight(), 1));
m_efb_layers = (g_ActiveConfig.iStereoMode != STEREO_OFF) ? 2 : 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); INFO_LOG(VIDEO, "EFB size: %ux%ux%u", m_efb_width, m_efb_height, m_efb_layers);

View File

@ -136,8 +136,8 @@ void AsyncRequests::HandleEvent(const AsyncRequests::Event& e)
break; break;
case Event::SWAP_EVENT: case Event::SWAP_EVENT:
Renderer::Swap(e.swap_event.xfbAddr, e.swap_event.fbWidth, e.swap_event.fbStride, g_renderer->Swap(e.swap_event.xfbAddr, e.swap_event.fbWidth, e.swap_event.fbStride,
e.swap_event.fbHeight, rc, e.time); e.swap_event.fbHeight, rc, e.time);
break; break;
case Event::BBOX_READ: case Event::BBOX_READ:

View File

@ -156,7 +156,7 @@ void OnPixelFormatChange()
if (!g_ActiveConfig.bEFBEmulateFormatChanges) if (!g_ActiveConfig.bEFBEmulateFormatChanges)
return; return;
auto old_format = Renderer::GetPrevPixelFormat(); auto old_format = g_renderer->GetPrevPixelFormat();
auto new_format = bpmem.zcontrol.pixel_format; auto new_format = bpmem.zcontrol.pixel_format;
// no need to reinterpret pixel data in these cases // no need to reinterpret pixel data in these cases
@ -209,7 +209,7 @@ skip:
DEBUG_LOG(VIDEO, "pixelfmt: pixel=%d, zc=%d", static_cast<int>(new_format), DEBUG_LOG(VIDEO, "pixelfmt: pixel=%d, zc=%d", static_cast<int>(new_format),
static_cast<int>(bpmem.zcontrol.zformat)); static_cast<int>(bpmem.zcontrol.zformat));
Renderer::StorePixelFormat(new_format); g_renderer->StorePixelFormat(new_format);
} }
void SetInterlacingMode(const BPCmd& bp) void SetInterlacingMode(const BPCmd& bp)

View File

@ -261,7 +261,7 @@ static void BPWritten(const BPCmd& bp)
"fbStride: %u | fbHeight: %u", "fbStride: %u | fbHeight: %u",
destAddr, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, destAddr, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom,
bpmem.copyTexSrcWH.x + 1, destStride, height); 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. // Clear the rectangular region after copying it.

View File

@ -253,8 +253,8 @@ int FramebufferManagerBase::ScaleToVirtualXfbWidth(int x)
if (g_ActiveConfig.RealXFBEnabled()) if (g_ActiveConfig.RealXFBEnabled())
return x; return x;
return x * (int)Renderer::GetTargetRectangle().GetWidth() / return x * static_cast<int>(g_renderer->GetTargetRectangle().GetWidth()) /
(int)FramebufferManagerBase::LastXfbWidth(); static_cast<int>(FramebufferManagerBase::LastXfbWidth());
} }
int FramebufferManagerBase::ScaleToVirtualXfbHeight(int y) int FramebufferManagerBase::ScaleToVirtualXfbHeight(int y)
@ -262,6 +262,6 @@ int FramebufferManagerBase::ScaleToVirtualXfbHeight(int y)
if (g_ActiveConfig.RealXFBEnabled()) if (g_ActiveConfig.RealXFBEnabled())
return y; return y;
return y * (int)Renderer::GetTargetRectangle().GetHeight() / return y * static_cast<int>(g_renderer->GetTargetRectangle().GetHeight()) /
(int)FramebufferManagerBase::LastXfbHeight(); static_cast<int>(FramebufferManagerBase::LastXfbHeight());
} }

View File

@ -27,7 +27,6 @@ void PixelShaderManager::Init()
s_bFogRangeAdjustChanged = true; s_bFogRangeAdjustChanged = true;
s_bViewPortChanged = false; s_bViewPortChanged = false;
SetEfbScaleChanged();
SetIndMatrixChanged(0); SetIndMatrixChanged(0);
SetIndMatrixChanged(1); SetIndMatrixChanged(1);
SetIndMatrixChanged(2); 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 // so to simplify I use the hi coefficient as K in the shader taking 256 as the scale
// TODO: Shouldn't this be EFBToScaledXf? // TODO: Shouldn't this be EFBToScaledXf?
constants.fogf[0][0] = ScreenSpaceCenter; constants.fogf[0][0] = ScreenSpaceCenter;
constants.fogf[0][1] = (float)Renderer::EFBToScaledX((int)(2.0f * xfmem.viewport.wd)); constants.fogf[0][1] =
static_cast<float>(g_renderer->EFBToScaledX(static_cast<int>(2.0f * xfmem.viewport.wd)));
constants.fogf[0][2] = bpmem.fogRange.K[4].HI / 256.0f; constants.fogf[0][2] = bpmem.fogRange.K[4].HI / 256.0f;
} }
else else
@ -161,8 +161,8 @@ void PixelShaderManager::SetViewportChanged()
void PixelShaderManager::SetEfbScaleChanged() void PixelShaderManager::SetEfbScaleChanged()
{ {
constants.efbscale[0] = 1.0f / Renderer::EFBToScaledXf(1); constants.efbscale[0] = 1.0f / g_renderer->EFBToScaledXf(1);
constants.efbscale[1] = 1.0f / Renderer::EFBToScaledYf(1); constants.efbscale[1] = 1.0f / g_renderer->EFBToScaledYf(1);
dirty = true; dirty = true;
} }

View File

@ -64,39 +64,6 @@ static int OSDTime;
std::unique_ptr<Renderer> g_renderer; std::unique_ptr<Renderer> 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<PostProcessingShaderImplementation> 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. // 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 // 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 // floating-point round-trip errors. However the console GPU doesn't ever write a value
@ -118,11 +85,6 @@ Renderer::Renderer()
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(); ShutdownFrameDumping();
if (m_frame_dump_thread.joinable()) if (m_frame_dump_thread.joinable())
m_frame_dump_thread.join(); m_frame_dump_thread.join();

View File

@ -81,46 +81,46 @@ public:
virtual void RestoreAPIState() {} virtual void RestoreAPIState() {}
// Ideal internal resolution - determined by display resolution (automatic scaling) and/or a // Ideal internal resolution - determined by display resolution (automatic scaling) and/or a
// multiple of the native EFB resolution // multiple of the native EFB resolution
static int GetTargetWidth() { return s_target_width; } int GetTargetWidth() { return s_target_width; }
static int GetTargetHeight() { return s_target_height; } int GetTargetHeight() { return s_target_height; }
// Display resolution // Display resolution
static int GetBackbufferWidth() { return s_backbuffer_width; } int GetBackbufferWidth() { return s_backbuffer_width; }
static int GetBackbufferHeight() { return s_backbuffer_height; } int GetBackbufferHeight() { return s_backbuffer_height; }
static void SetWindowSize(int width, int height); void SetWindowSize(int width, int height);
// EFB coordinate conversion functions // EFB coordinate conversion functions
// Use this to convert a whole native EFB rect to backbuffer coordinates // Use this to convert a whole native EFB rect to backbuffer coordinates
virtual TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) = 0; virtual TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) = 0;
static const TargetRectangle& GetTargetRectangle() { return target_rc; } const TargetRectangle& GetTargetRectangle() { return target_rc; }
static float CalculateDrawAspectRatio(int target_width, int target_height); float CalculateDrawAspectRatio(int target_width, int target_height);
static std::tuple<float, float> ScaleToDisplayAspectRatio(int width, int height); std::tuple<float, float> ScaleToDisplayAspectRatio(int width, int height);
static TargetRectangle CalculateFrameDumpDrawRectangle(); TargetRectangle CalculateFrameDumpDrawRectangle();
static void UpdateDrawRectangle(); void UpdateDrawRectangle();
// Use this to convert a single target rectangle to two stereo rectangles // Use this to convert a single target rectangle to two stereo rectangles
static void ConvertStereoRectangle(const TargetRectangle& rc, TargetRectangle& leftRc, void ConvertStereoRectangle(const TargetRectangle& rc, TargetRectangle& leftRc,
TargetRectangle& rightRc); TargetRectangle& rightRc);
// Use this to upscale native EFB coordinates to IDEAL internal resolution // Use this to upscale native EFB coordinates to IDEAL internal resolution
static int EFBToScaledX(int x); int EFBToScaledX(int x);
static int EFBToScaledY(int y); int EFBToScaledY(int y);
// Floating point versions of the above - only use them if really necessary // Floating point versions of the above - only use them if really necessary
static float EFBToScaledXf(float x) { return x * ((float)GetTargetWidth() / (float)EFB_WIDTH); } float EFBToScaledXf(float x) { return x * ((float)GetTargetWidth() / (float)EFB_WIDTH); }
static float EFBToScaledYf(float y) { return y * ((float)GetTargetHeight() / (float)EFB_HEIGHT); } float EFBToScaledYf(float y) { return y * ((float)GetTargetHeight() / (float)EFB_HEIGHT); }
// Random utilities // Random utilities
static void SetScreenshot(const std::string& filename); void SetScreenshot(const std::string& filename);
static void DrawDebugText(); void DrawDebugText();
virtual void RenderText(const std::string& text, int left, int top, u32 color) = 0; 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, virtual void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
u32 color, u32 z) = 0; u32 color, u32 z) = 0;
virtual void ReinterpretPixelData(unsigned int convtype) = 0; virtual void ReinterpretPixelData(unsigned int convtype) = 0;
static void RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbStride, u32 fbHeight, void RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbStride, u32 fbHeight,
float Gamma = 1.0f); float Gamma = 1.0f);
virtual u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) = 0; 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; 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; virtual void BBoxWrite(int index, u16 value) = 0;
// Finish up the current frame, print some stats // Finish up the current frame, print some stats
static void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, u64 ticks,
u64 ticks, float Gamma = 1.0f); float Gamma = 1.0f);
virtual void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, virtual void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
const EFBRectangle& rc, u64 ticks, float Gamma = 1.0f) = 0; const EFBRectangle& rc, u64 ticks, float Gamma = 1.0f) = 0;
static PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; } PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; }
static void StorePixelFormat(PEControl::PixelFormat new_format) { prev_efb_format = new_format; } void StorePixelFormat(PEControl::PixelFormat new_format) { prev_efb_format = new_format; }
PostProcessingShaderImplementation* GetPostProcessor() { return m_post_processor.get(); } PostProcessingShaderImplementation* GetPostProcessor() { return m_post_processor.get(); }
// Max height/width // Max height/width
virtual u32 GetMaxTextureSize() = 0; virtual u32 GetMaxTextureSize() = 0;
static Common::Event s_screenshotCompleted; Common::Event s_screenshotCompleted;
// Final surface changing // Final surface changing
// This is called when the surface is resized (WX) or the window changes (Android). // This is called when the surface is resized (WX) or the window changes (Android).
virtual void ChangeSurface(void* new_surface_handle) {} virtual void ChangeSurface(void* new_surface_handle) {}
protected: protected:
static void CalculateTargetScale(int x, int y, int* scaledX, int* scaledY); void CalculateTargetScale(int x, int y, int* scaledX, int* scaledY);
bool CalculateTargetSize(); bool CalculateTargetSize();
static void CheckFifoRecording(); void CheckFifoRecording();
static void RecordVideoMemory(); void RecordVideoMemory();
bool IsFrameDumping(); bool IsFrameDumping();
void DumpFrameData(const u8* data, int w, int h, int stride, const AVIDump::Frame& state, void DumpFrameData(const u8* data, int w, int h, int stride, const AVIDump::Frame& state,
bool swap_upside_down = false); bool swap_upside_down = false);
void FinishFrameData(); void FinishFrameData();
static Common::Flag s_screenshot; Common::Flag s_screenshot;
static std::mutex s_criticalScreenshot; std::mutex s_criticalScreenshot;
static std::string s_sScreenshotName; std::string s_sScreenshotName;
// The framebuffer size // The framebuffer size
static int s_target_width; int s_target_width = 0;
static int s_target_height; int s_target_height = 0;
// TODO: Add functionality to reinit all the render targets when the window is resized. // TODO: Add functionality to reinit all the render targets when the window is resized.
static int s_backbuffer_width; int s_backbuffer_width = 0;
static int s_backbuffer_height; int s_backbuffer_height = 0;
static TargetRectangle target_rc; TargetRectangle target_rc;
// TODO: Can probably eliminate this static var. // 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; FPSCounter m_fps_counter;
static std::unique_ptr<PostProcessingShaderImplementation> m_post_processor; std::unique_ptr<PostProcessingShaderImplementation> m_post_processor;
static const float GX_MAX_DEPTH; static const float GX_MAX_DEPTH;
static Common::Flag s_surface_needs_change; Common::Flag s_surface_needs_change;
static Common::Event s_surface_changed; Common::Event s_surface_changed;
static void* s_new_surface_handle; void* s_new_surface_handle = nullptr;
private: private:
void RunFrameDumps(); void RunFrameDumps();
void ShutdownFrameDumping(); void ShutdownFrameDumping();
static PEControl::PixelFormat prev_efb_format; PEControl::PixelFormat prev_efb_format = PEControl::INVALID_FMT;
static unsigned int efb_scale_numeratorX; unsigned int efb_scale_numeratorX = 1;
static unsigned int efb_scale_numeratorY; unsigned int efb_scale_numeratorY = 1;
static unsigned int efb_scale_denominatorX; unsigned int efb_scale_denominatorX = 1;
static unsigned int efb_scale_denominatorY; unsigned int efb_scale_denominatorY = 1;
// frame dumping // frame dumping
std::thread m_frame_dump_thread; std::thread m_frame_dump_thread;

View File

@ -385,17 +385,17 @@ TextureCacheBase::DoPartialTextureUpdates(TCacheEntryBase* entry_to_update, u8*
entry->native_height != entry->config.height) entry->native_height != entry->config.height)
{ {
ScaleTextureCacheEntryTo(&entry_to_update, ScaleTextureCacheEntryTo(&entry_to_update,
Renderer::EFBToScaledX(entry_to_update->native_width), g_renderer->EFBToScaledX(entry_to_update->native_width),
Renderer::EFBToScaledY(entry_to_update->native_height)); g_renderer->EFBToScaledY(entry_to_update->native_height));
ScaleTextureCacheEntryTo(&entry, Renderer::EFBToScaledX(entry->native_width), ScaleTextureCacheEntryTo(&entry, g_renderer->EFBToScaledX(entry->native_width),
Renderer::EFBToScaledY(entry->native_height)); g_renderer->EFBToScaledY(entry->native_height));
src_x = Renderer::EFBToScaledX(src_x); src_x = g_renderer->EFBToScaledX(src_x);
src_y = Renderer::EFBToScaledY(src_y); src_y = g_renderer->EFBToScaledY(src_y);
dst_x = Renderer::EFBToScaledX(dst_x); dst_x = g_renderer->EFBToScaledX(dst_x);
dst_y = Renderer::EFBToScaledY(dst_y); dst_y = g_renderer->EFBToScaledY(dst_y);
copy_width = Renderer::EFBToScaledX(copy_width); copy_width = g_renderer->EFBToScaledX(copy_width);
copy_height = Renderer::EFBToScaledY(copy_height); copy_height = g_renderer->EFBToScaledY(copy_height);
} }
MathUtil::Rectangle<int> srcrect, dstrect; MathUtil::Rectangle<int> 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_w = scaleByHalf ? srcRect.GetWidth() / 2 : srcRect.GetWidth();
const unsigned int tex_h = scaleByHalf ? srcRect.GetHeight() / 2 : srcRect.GetHeight(); 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_w =
unsigned int scaled_tex_h = g_ActiveConfig.bCopyEFBScaled ? Renderer::EFBToScaledY(tex_h) : tex_h; 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 // 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 // It's not possible to have two EFB copies at the same address, this makes sure any old efb

View File

@ -382,8 +382,8 @@ void VertexShaderManager::SetConstants()
// NOTE: If we ever emulate antialiasing, the sample locations set by // NOTE: If we ever emulate antialiasing, the sample locations set by
// BP registers 0x01-0x04 need to be considered here. // BP registers 0x01-0x04 need to be considered here.
const float pixel_center_correction = 7.0f / 12.0f - 0.5f; 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_x = 2.f / g_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_y = 2.f / g_renderer->EFBToScaledXf(2.f * xfmem.viewport.ht);
constants.pixelcentercorrection[0] = pixel_center_correction * pixel_size_x; constants.pixelcentercorrection[0] = pixel_center_correction * pixel_size_x;
constants.pixelcentercorrection[1] = pixel_center_correction * pixel_size_y; constants.pixelcentercorrection[1] = pixel_center_correction * pixel_size_y;