VideoCommon: Rename Renderer s_ prefixes to m_

This commit is contained in:
Stenzek 2017-03-04 16:42:21 +10:00
parent 238a70b006
commit afc25fdca0
7 changed files with 163 additions and 169 deletions

View File

@ -485,7 +485,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulatio
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SaveScreenShot("thumb");
Renderer::s_screenshotCompleted.WaitFor(std::chrono::seconds(2));
g_renderer->s_screenshot_completed.WaitFor(std::chrono::seconds(2));
Core::Stop();
updateMainFrameEvent.Set(); // Kick the waiting event
}

View File

@ -239,7 +239,7 @@ Renderer::Renderer() : ::Renderer(D3D::GetBackBufferWidth(), D3D::GetBackBufferH
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
g_framebuffer_manager = std::make_unique<FramebufferManager>(s_target_width, s_target_height);
g_framebuffer_manager = std::make_unique<FramebufferManager>(m_target_width, m_target_height);
SetupDeviceObjects();
// Setup GX pipeline state
@ -268,7 +268,7 @@ Renderer::Renderer() : ::Renderer(D3D::GetBackBufferWidth(), D3D::GetBackBufferH
D3D::context->ClearDepthStencilView(FramebufferManager::GetEFBDepthTexture()->GetDSV(),
D3D11_CLEAR_DEPTH, 0.f, 0);
D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, (float)s_target_width, (float)s_target_height);
D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, (float)m_target_width, (float)m_target_height);
D3D::context->RSSetViewports(1, &vp);
D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(),
FramebufferManager::GetEFBDepthTexture()->GetDSV());
@ -711,7 +711,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
const EFBRectangle& rc, u64 ticks, float Gamma)
{
if ((!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight)
if ((!m_xfb_written && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight)
{
Core::Callback_VideoCopiedToXFB(false);
return;
@ -865,7 +865,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
// Resize the back buffers NOW to avoid flickering
if (CalculateTargetSize() || xfbchanged || windowResized ||
s_last_efb_scale != g_ActiveConfig.iEFBScale ||
m_last_efb_scale != g_ActiveConfig.iEFBScale ||
s_last_multisamples != g_ActiveConfig.iMultisamples ||
s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
{
@ -879,13 +879,13 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
D3D::Reset();
SAFE_RELEASE(s_screenshot_texture);
SAFE_RELEASE(s_3d_vision_texture);
s_backbuffer_width = D3D::GetBackBufferWidth();
s_backbuffer_height = D3D::GetBackBufferHeight();
m_backbuffer_width = D3D::GetBackBufferWidth();
m_backbuffer_height = D3D::GetBackBufferHeight();
}
UpdateDrawRectangle();
s_last_efb_scale = g_ActiveConfig.iEFBScale;
m_last_efb_scale = g_ActiveConfig.iEFBScale;
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
PixelShaderManager::SetEfbScaleChanged();
@ -893,7 +893,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), nullptr);
g_framebuffer_manager.reset();
g_framebuffer_manager = std::make_unique<FramebufferManager>(s_target_width, s_target_height);
g_framebuffer_manager = std::make_unique<FramebufferManager>(m_target_width, m_target_height);
float clear_col[4] = {0.f, 0.f, 0.f, 1.f};
D3D::context->ClearRenderTargetView(FramebufferManager::GetEFBColorTexture()->GetRTV(),
clear_col);
@ -1147,12 +1147,12 @@ u16 Renderer::BBoxRead(int index)
if (index < 2)
{
// left/right
value = value * EFB_WIDTH / s_target_width;
value = value * EFB_WIDTH / m_target_width;
}
else
{
// up/down
value = value * EFB_HEIGHT / s_target_height;
value = value * EFB_HEIGHT / m_target_height;
}
if (index & 1)
value++; // fix max values to describe the outer border
@ -1167,11 +1167,11 @@ void Renderer::BBoxWrite(int index, u16 _value)
value--;
if (index < 2)
{
value = value * s_target_width / EFB_WIDTH;
value = value * m_target_width / EFB_WIDTH;
}
else
{
value = value * s_target_height / EFB_HEIGHT;
value = value * m_target_height / EFB_HEIGHT;
}
BBox::Set(index, value);
@ -1205,11 +1205,11 @@ void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, D3DTexture2D
else if (g_ActiveConfig.iStereoMode == STEREO_3DVISION)
{
if (!s_3d_vision_texture)
Create3DVisionTexture(s_backbuffer_width, s_backbuffer_height);
Create3DVisionTexture(m_backbuffer_width, m_backbuffer_height);
D3D11_VIEWPORT leftVp = CD3D11_VIEWPORT((float)dst.left, (float)dst.top, (float)dst.GetWidth(),
(float)dst.GetHeight());
D3D11_VIEWPORT rightVp = CD3D11_VIEWPORT((float)(dst.left + s_backbuffer_width), (float)dst.top,
D3D11_VIEWPORT rightVp = CD3D11_VIEWPORT((float)(dst.left + m_backbuffer_width), (float)dst.top,
(float)dst.GetWidth(), (float)dst.GetHeight());
// Render to staging texture which is double the width of the backbuffer
@ -1229,7 +1229,7 @@ void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, D3DTexture2D
// Copy the left eye to the backbuffer, if Nvidia 3D Vision is enabled it should
// recognize the signature and automatically include the right eye frame.
D3D11_BOX box = CD3D11_BOX(0, 0, 0, s_backbuffer_width, s_backbuffer_height, 1);
D3D11_BOX box = CD3D11_BOX(0, 0, 0, m_backbuffer_width, m_backbuffer_height, 1);
D3D::context->CopySubresourceRegion(D3D::GetBackBuffer()->GetTex(), 0, 0, 0, 0,
s_3d_vision_texture->GetTex(), 0, &box);

View File

@ -221,7 +221,7 @@ Renderer::Renderer() : ::Renderer(D3D::GetBackBufferWidth(), D3D::GetBackBufferH
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
g_framebuffer_manager = std::make_unique<FramebufferManager>(s_target_width, s_target_height);
g_framebuffer_manager = std::make_unique<FramebufferManager>(m_target_width, m_target_height);
SetupDeviceObjects();
// Setup GX pipeline state
@ -257,8 +257,8 @@ Renderer::Renderer() : ::Renderer(D3D::GetBackBufferWidth(), D3D::GetBackBufferH
D3D12_VIEWPORT vp = {0.f,
0.f,
static_cast<float>(s_target_width),
static_cast<float>(s_target_height),
static_cast<float>(m_target_width),
static_cast<float>(m_target_height),
D3D12_MIN_DEPTH,
D3D12_MAX_DEPTH};
D3D::current_command_list->RSSetViewports(1, &vp);
@ -634,7 +634,7 @@ void Renderer::SetBlendMode(bool force_update)
void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height,
const EFBRectangle& rc, u64 ticks, float gamma)
{
if ((!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fb_width || !fb_height)
if ((!m_xfb_written && !g_ActiveConfig.RealXFBEnabled()) || !fb_width || !fb_height)
{
Core::Callback_VideoCopiedToXFB(false);
return;
@ -821,7 +821,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
// Resize the back buffers NOW to avoid flickering
if (CalculateTargetSize() || xfb_changed || window_resized ||
s_last_efb_scale != g_ActiveConfig.iEFBScale ||
m_last_efb_scale != g_ActiveConfig.iEFBScale ||
s_last_multisamples != g_ActiveConfig.iMultisamples ||
s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
{
@ -848,13 +848,13 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
s_screenshot_texture = nullptr;
}
s_backbuffer_width = D3D::GetBackBufferWidth();
s_backbuffer_height = D3D::GetBackBufferHeight();
m_backbuffer_width = D3D::GetBackBufferWidth();
m_backbuffer_height = D3D::GetBackBufferHeight();
}
UpdateDrawRectangle();
s_last_efb_scale = g_ActiveConfig.iEFBScale;
m_last_efb_scale = g_ActiveConfig.iEFBScale;
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
PixelShaderManager::SetEfbScaleChanged();
@ -865,7 +865,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
nullptr);
g_framebuffer_manager.reset();
g_framebuffer_manager = std::make_unique<FramebufferManager>(s_target_width, s_target_height);
g_framebuffer_manager = std::make_unique<FramebufferManager>(m_target_width, m_target_height);
const float clear_color[4] = {0.f, 0.f, 0.f, 1.f};
FramebufferManager::GetEFBColorTexture()->TransitionToResourceState(
@ -1177,12 +1177,12 @@ u16 Renderer::BBoxRead(int index)
if (index < 2)
{
// left/right
value = value * EFB_WIDTH / s_target_width;
value = value * EFB_WIDTH / m_target_width;
}
else
{
// up/down
value = value * EFB_HEIGHT / s_target_height;
value = value * EFB_HEIGHT / m_target_height;
}
if (index & 1)
value++; // fix max values to describe the outer border
@ -1197,11 +1197,11 @@ void Renderer::BBoxWrite(int index, u16 value)
local_value--;
if (index < 2)
{
local_value = local_value * s_target_width / EFB_WIDTH;
local_value = local_value * m_target_width / EFB_WIDTH;
}
else
{
local_value = local_value * s_target_height / EFB_HEIGHT;
local_value = local_value * m_target_height / EFB_HEIGHT;
}
BBox::Set(index, local_value);

View File

@ -777,7 +777,7 @@ void Renderer::Init()
// Initialize the FramebufferManager
g_framebuffer_manager =
std::make_unique<FramebufferManager>(s_target_width, s_target_height, s_MSAASamples);
std::make_unique<FramebufferManager>(m_target_width, m_target_height, s_MSAASamples);
m_post_processor = std::make_unique<OpenGLPostProcessing>();
s_raster_font = std::make_unique<RasterFont>();
@ -1045,12 +1045,12 @@ u16 Renderer::BBoxRead(int index)
if (index < 2)
{
// left/right
value = value * EFB_WIDTH / s_target_width;
value = value * EFB_WIDTH / m_target_width;
}
else
{
// up/down -- we have to swap up and down
value = value * EFB_HEIGHT / s_target_height;
value = value * EFB_HEIGHT / m_target_height;
value = EFB_HEIGHT - value - 1;
}
if (index & 1)
@ -1066,13 +1066,13 @@ void Renderer::BBoxWrite(int index, u16 _value)
value--;
if (index < 2)
{
value = value * s_target_width / EFB_WIDTH;
value = value * m_target_width / EFB_WIDTH;
}
else
{
index ^= 1; // swap 2 and 3 for top/bottom
value = EFB_HEIGHT - value - 1;
value = value * s_target_height / EFB_HEIGHT;
value = value * m_target_height / EFB_HEIGHT;
}
BoundingBox::Set(index, value);
@ -1283,7 +1283,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
glDisable(GL_DEBUG_OUTPUT);
}
if ((!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight)
if ((!m_xfb_written && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight)
{
Core::Callback_VideoCopiedToXFB(false);
return;
@ -1353,13 +1353,13 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
bool window_resized = false;
int window_width = static_cast<int>(std::max(GLInterface->GetBackBufferWidth(), 1u));
int window_height = static_cast<int>(std::max(GLInterface->GetBackBufferHeight(), 1u));
if (window_width != s_backbuffer_width || window_height != s_backbuffer_height ||
s_last_efb_scale != g_ActiveConfig.iEFBScale)
if (window_width != m_backbuffer_width || window_height != m_backbuffer_height ||
m_last_efb_scale != g_ActiveConfig.iEFBScale)
{
window_resized = true;
s_backbuffer_width = window_width;
s_backbuffer_height = window_height;
s_last_efb_scale = g_ActiveConfig.iEFBScale;
m_backbuffer_width = window_width;
m_backbuffer_height = window_height;
m_last_efb_scale = g_ActiveConfig.iEFBScale;
}
bool target_size_changed = CalculateTargetSize();
@ -1389,7 +1389,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
g_framebuffer_manager.reset();
g_framebuffer_manager =
std::make_unique<FramebufferManager>(s_target_width, s_target_height, s_MSAASamples);
std::make_unique<FramebufferManager>(m_target_width, m_target_height, s_MSAASamples);
PixelShaderManager::SetEfbScaleChanged();
}
@ -1409,13 +1409,13 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
OSD::DrawMessages();
#ifdef ANDROID
if (s_surface_needs_change.IsSet())
if (m_surface_needs_change.IsSet())
{
GLInterface->UpdateHandle(s_new_surface_handle);
GLInterface->UpdateHandle(m_new_surface_handle);
GLInterface->UpdateSurface();
s_new_surface_handle = nullptr;
s_surface_needs_change.Clear();
s_surface_changed.Set();
m_new_surface_handle = nullptr;
m_surface_needs_change.Clear();
m_surface_changed.Set();
}
#endif
@ -1482,7 +1482,7 @@ void Renderer::DrawEFB(GLuint framebuffer, const TargetRectangle& target_rc,
// for msaa mode, we must resolve the efb content to non-msaa
GLuint tex = FramebufferManager::ResolveAndGetRenderTarget(source_rc);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
BlitScreen(scaled_source_rc, target_rc, tex, s_target_width, s_target_height);
BlitScreen(scaled_source_rc, target_rc, tex, m_target_width, m_target_height);
}
void Renderer::DrawVirtualXFB(GLuint framebuffer, const TargetRectangle& target_rc, u32 xfb_addr,
@ -1804,9 +1804,9 @@ void Renderer::ChangeSurface(void* new_surface_handle)
// This is only necessary for Android at this point, although handling resizes here
// would be more efficient than polling.
#ifdef ANDROID
s_new_surface_handle = new_surface_handle;
s_surface_needs_change.Set();
s_surface_changed.Wait();
m_new_surface_handle = new_surface_handle;
m_surface_needs_change.Set();
m_surface_changed.Wait();
#endif
}
}

View File

@ -266,12 +266,12 @@ u16 Renderer::BBoxRead(int index)
if (index < 2)
{
// left/right
value = value * EFB_WIDTH / s_target_width;
value = value * EFB_WIDTH / m_target_width;
}
else
{
// up/down
value = value * EFB_HEIGHT / s_target_height;
value = value * EFB_HEIGHT / m_target_height;
}
// fix max values to describe the outer border
@ -293,12 +293,12 @@ void Renderer::BBoxWrite(int index, u16 value)
if (index < 2)
{
// left/right
scaled_value = scaled_value * s_target_width / EFB_WIDTH;
scaled_value = scaled_value * m_target_width / EFB_WIDTH;
}
else
{
// up/down
scaled_value = scaled_value * s_target_height / EFB_HEIGHT;
scaled_value = scaled_value * m_target_height / EFB_HEIGHT;
}
m_bounding_box->Set(static_cast<size_t>(index), scaled_value);
@ -477,7 +477,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
FramebufferManager::GetInstance()->FlushEFBPokes();
// Check that we actually have an image to render in XFB-on modes.
if ((!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fb_width || !fb_height)
if ((!m_xfb_written && !g_ActiveConfig.RealXFBEnabled()) || !fb_width || !fb_height)
{
Core::Callback_VideoCopiedToXFB(false);
return;
@ -1020,22 +1020,22 @@ void Renderer::CheckForTargetResize(u32 fb_width, u32 fb_stride, u32 fb_height)
void Renderer::CheckForSurfaceChange()
{
if (!s_surface_needs_change.IsSet())
if (!m_surface_needs_change.IsSet())
return;
u32 old_width = m_swap_chain ? m_swap_chain->GetWidth() : 0;
u32 old_height = m_swap_chain ? m_swap_chain->GetHeight() : 0;
// Fast path, if the surface handle is the same, the window has just been resized.
if (m_swap_chain && s_new_surface_handle == m_swap_chain->GetNativeHandle())
if (m_swap_chain && m_new_surface_handle == m_swap_chain->GetNativeHandle())
{
INFO_LOG(VIDEO, "Detected window resize.");
ResizeSwapChain();
// Notify the main thread we are done.
s_surface_needs_change.Clear();
s_new_surface_handle = nullptr;
s_surface_changed.Set();
m_surface_needs_change.Clear();
m_new_surface_handle = nullptr;
m_surface_changed.Set();
}
else
{
@ -1045,7 +1045,7 @@ void Renderer::CheckForSurfaceChange()
// Did we previously have a swap chain?
if (m_swap_chain)
{
if (!s_new_surface_handle)
if (!m_new_surface_handle)
{
// If there is no surface now, destroy the swap chain.
m_swap_chain.reset();
@ -1053,7 +1053,7 @@ void Renderer::CheckForSurfaceChange()
else
{
// Recreate the surface. If this fails we're in trouble.
if (!m_swap_chain->RecreateSurface(s_new_surface_handle))
if (!m_swap_chain->RecreateSurface(m_new_surface_handle))
PanicAlert("Failed to recreate Vulkan surface. Cannot continue.");
}
}
@ -1061,10 +1061,10 @@ void Renderer::CheckForSurfaceChange()
{
// Previously had no swap chain. So create one.
VkSurfaceKHR surface = SwapChain::CreateVulkanSurface(g_vulkan_context->GetVulkanInstance(),
s_new_surface_handle);
m_new_surface_handle);
if (surface != VK_NULL_HANDLE)
{
m_swap_chain = SwapChain::Create(s_new_surface_handle, surface, g_ActiveConfig.IsVSync());
m_swap_chain = SwapChain::Create(m_new_surface_handle, surface, g_ActiveConfig.IsVSync());
if (!m_swap_chain)
PanicAlert("Failed to create swap chain.");
}
@ -1075,9 +1075,9 @@ void Renderer::CheckForSurfaceChange()
}
// Notify calling thread.
s_surface_needs_change.Clear();
s_new_surface_handle = nullptr;
s_surface_changed.Set();
m_surface_needs_change.Clear();
m_new_surface_handle = nullptr;
m_surface_changed.Set();
}
if (m_swap_chain)
@ -1111,7 +1111,7 @@ void Renderer::CheckForConfigChanges()
bool anisotropy_changed = old_anisotropy != g_ActiveConfig.iMaxAnisotropy;
bool force_texture_filtering_changed = old_force_filtering != g_ActiveConfig.bForceFiltering;
bool stereo_changed = old_stereo_mode != g_ActiveConfig.iStereoMode;
bool efb_scale_changed = s_last_efb_scale != g_ActiveConfig.iEFBScale;
bool efb_scale_changed = m_last_efb_scale != g_ActiveConfig.iEFBScale;
bool aspect_changed = old_aspect_ratio != g_ActiveConfig.iAspectRatio;
bool use_xfb_changed = old_use_xfb != g_ActiveConfig.bUseXFB;
bool use_realxfb_changed = old_use_realxfb != g_ActiveConfig.bUseRealXFB;
@ -1122,7 +1122,7 @@ void Renderer::CheckForConfigChanges()
// Handle settings that can cause the target rectangle to change.
if (efb_scale_changed || aspect_changed || use_xfb_changed || use_realxfb_changed)
{
s_last_efb_scale = g_ActiveConfig.iEFBScale;
m_last_efb_scale = g_ActiveConfig.iEFBScale;
if (CalculateTargetSize())
ResizeEFBTextures();
}
@ -1162,8 +1162,8 @@ void Renderer::CheckForConfigChanges()
void Renderer::OnSwapChainResized()
{
s_backbuffer_width = m_swap_chain->GetWidth();
s_backbuffer_height = m_swap_chain->GetHeight();
m_backbuffer_width = m_swap_chain->GetWidth();
m_backbuffer_height = m_swap_chain->GetHeight();
UpdateDrawRectangle();
if (CalculateTargetSize())
{
@ -1668,9 +1668,9 @@ void Renderer::SetViewport()
void Renderer::ChangeSurface(void* new_surface_handle)
{
// Called by the main thread when the window is resized.
s_new_surface_handle = new_surface_handle;
s_surface_needs_change.Set();
s_surface_changed.Set();
m_new_surface_handle = new_surface_handle;
m_surface_needs_change.Set();
m_surface_changed.Set();
}
void Renderer::RecompileShaders()

View File

@ -77,15 +77,13 @@ static float AspectToWidescreen(float aspect)
}
Renderer::Renderer(int backbuffer_width, int backbuffer_height)
: m_backbuffer_width(backbuffer_width), m_backbuffer_height(backbuffer_height),
m_last_efb_scale(g_ActiveConfig.iEFBScale)
{
FramebufferManagerBase::SetLastXfbWidth(MAX_XFB_WIDTH);
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
UpdateActiveConfig();
s_backbuffer_width = backbuffer_width;
s_backbuffer_height = backbuffer_height;
s_last_efb_scale = g_ActiveConfig.iEFBScale;
CalculateTargetSize();
UpdateDrawRectangle();
@ -108,7 +106,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbStri
if (!fbStride || !fbHeight)
return;
XFBWrited = true;
m_xfb_written = true;
if (g_ActiveConfig.bUseXFB)
{
@ -132,7 +130,7 @@ int Renderer::EFBToScaledX(int x)
return FramebufferManagerBase::ScaleToVirtualXfbWidth(x);
default:
return x * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX;
return x * (int)m_efb_scale_numeratorX / (int)m_efb_scale_denominatorX;
};
}
@ -144,7 +142,7 @@ int Renderer::EFBToScaledY(int y)
return FramebufferManagerBase::ScaleToVirtualXfbHeight(y);
default:
return y * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY;
return y * (int)m_efb_scale_numeratorY / (int)m_efb_scale_denominatorY;
};
}
@ -157,8 +155,8 @@ void Renderer::CalculateTargetScale(int x, int y, int* scaledX, int* scaledY)
}
else
{
*scaledX = x * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX;
*scaledY = y * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY;
*scaledX = x * (int)m_efb_scale_numeratorX / (int)m_efb_scale_denominatorX;
*scaledY = y * (int)m_efb_scale_numeratorY / (int)m_efb_scale_denominatorY;
}
}
@ -169,70 +167,70 @@ bool Renderer::CalculateTargetSize()
newEFBWidth = newEFBHeight = 0;
// TODO: Ugly. Clean up
switch (s_last_efb_scale)
switch (m_last_efb_scale)
{
case SCALE_AUTO:
case SCALE_AUTO_INTEGRAL:
newEFBWidth = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH);
newEFBHeight = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT);
if (s_last_efb_scale == SCALE_AUTO_INTEGRAL)
if (m_last_efb_scale == SCALE_AUTO_INTEGRAL)
{
efb_scale_numeratorX = efb_scale_numeratorY =
m_efb_scale_numeratorX = m_efb_scale_numeratorY =
std::max((newEFBWidth - 1) / EFB_WIDTH + 1, (newEFBHeight - 1) / EFB_HEIGHT + 1);
efb_scale_denominatorX = efb_scale_denominatorY = 1;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
newEFBWidth = EFBToScaledX(EFB_WIDTH);
newEFBHeight = EFBToScaledY(EFB_HEIGHT);
}
else
{
efb_scale_numeratorX = newEFBWidth;
efb_scale_denominatorX = EFB_WIDTH;
efb_scale_numeratorY = newEFBHeight;
efb_scale_denominatorY = EFB_HEIGHT;
m_efb_scale_numeratorX = newEFBWidth;
m_efb_scale_denominatorX = EFB_WIDTH;
m_efb_scale_numeratorY = newEFBHeight;
m_efb_scale_denominatorY = EFB_HEIGHT;
}
break;
case SCALE_1X:
efb_scale_numeratorX = efb_scale_numeratorY = 1;
efb_scale_denominatorX = efb_scale_denominatorY = 1;
m_efb_scale_numeratorX = m_efb_scale_numeratorY = 1;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
break;
case SCALE_1_5X:
efb_scale_numeratorX = efb_scale_numeratorY = 3;
efb_scale_denominatorX = efb_scale_denominatorY = 2;
m_efb_scale_numeratorX = m_efb_scale_numeratorY = 3;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 2;
break;
case SCALE_2X:
efb_scale_numeratorX = efb_scale_numeratorY = 2;
efb_scale_denominatorX = efb_scale_denominatorY = 1;
m_efb_scale_numeratorX = m_efb_scale_numeratorY = 2;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
break;
case SCALE_2_5X:
efb_scale_numeratorX = efb_scale_numeratorY = 5;
efb_scale_denominatorX = efb_scale_denominatorY = 2;
m_efb_scale_numeratorX = m_efb_scale_numeratorY = 5;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 2;
break;
default:
efb_scale_numeratorX = efb_scale_numeratorY = s_last_efb_scale - 3;
efb_scale_denominatorX = efb_scale_denominatorY = 1;
m_efb_scale_numeratorX = m_efb_scale_numeratorY = m_last_efb_scale - 3;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
const u32 max_size = GetMaxTextureSize();
if (max_size < EFB_WIDTH * efb_scale_numeratorX / efb_scale_denominatorX)
if (max_size < EFB_WIDTH * m_efb_scale_numeratorX / m_efb_scale_denominatorX)
{
efb_scale_numeratorX = efb_scale_numeratorY = (max_size / EFB_WIDTH);
efb_scale_denominatorX = efb_scale_denominatorY = 1;
m_efb_scale_numeratorX = m_efb_scale_numeratorY = (max_size / EFB_WIDTH);
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
}
break;
}
if (s_last_efb_scale > SCALE_AUTO_INTEGRAL)
if (m_last_efb_scale > SCALE_AUTO_INTEGRAL)
CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, &newEFBWidth, &newEFBHeight);
if (newEFBWidth != s_target_width || newEFBHeight != s_target_height)
if (newEFBWidth != m_target_width || newEFBHeight != m_target_height)
{
s_target_width = newEFBWidth;
s_target_height = newEFBHeight;
m_target_width = newEFBWidth;
m_target_height = newEFBHeight;
return true;
}
return false;
@ -261,25 +259,25 @@ void Renderer::ConvertStereoRectangle(const TargetRectangle& rc, TargetRectangle
leftRc = drawRc, rightRc = drawRc;
if (g_ActiveConfig.iStereoMode == STEREO_TAB)
{
leftRc.top -= s_backbuffer_height / 4;
leftRc.bottom -= s_backbuffer_height / 4;
rightRc.top += s_backbuffer_height / 4;
rightRc.bottom += s_backbuffer_height / 4;
leftRc.top -= m_backbuffer_height / 4;
leftRc.bottom -= m_backbuffer_height / 4;
rightRc.top += m_backbuffer_height / 4;
rightRc.bottom += m_backbuffer_height / 4;
}
else
{
leftRc.left -= s_backbuffer_width / 4;
leftRc.right -= s_backbuffer_width / 4;
rightRc.left += s_backbuffer_width / 4;
rightRc.right += s_backbuffer_width / 4;
leftRc.left -= m_backbuffer_width / 4;
leftRc.right -= m_backbuffer_width / 4;
rightRc.left += m_backbuffer_width / 4;
rightRc.right += m_backbuffer_width / 4;
}
}
void Renderer::SetScreenshot(const std::string& filename)
{
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
s_sScreenshotName = filename;
s_screenshot.Set();
std::lock_guard<std::mutex> lk(m_screenshot_lock);
m_screenshot_name = filename;
m_screenshot_request.Set();
}
// Create On-Screen-Messages
@ -432,7 +430,7 @@ float Renderer::CalculateDrawAspectRatio(int target_width, int target_height)
{
// If stretch is enabled, we prefer the aspect ratio of the window.
return (static_cast<float>(target_width) / static_cast<float>(target_height)) /
(static_cast<float>(s_backbuffer_width) / static_cast<float>(s_backbuffer_height));
(static_cast<float>(m_backbuffer_width) / static_cast<float>(m_backbuffer_height));
}
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
@ -477,8 +475,8 @@ TargetRectangle Renderer::CalculateFrameDumpDrawRectangle()
if (!g_ActiveConfig.bInternalResolutionFrameDumps || g_ActiveConfig.RealXFBEnabled())
{
// But still remove the borders, since the caller expects this.
rc.right = target_rc.GetWidth();
rc.bottom = target_rc.GetHeight();
rc.right = m_target_rectangle.GetWidth();
rc.bottom = m_target_rectangle.GetHeight();
return rc;
}
@ -496,8 +494,8 @@ TargetRectangle Renderer::CalculateFrameDumpDrawRectangle()
void Renderer::UpdateDrawRectangle()
{
float FloatGLWidth = static_cast<float>(s_backbuffer_width);
float FloatGLHeight = static_cast<float>(s_backbuffer_height);
float FloatGLWidth = static_cast<float>(m_backbuffer_width);
float FloatGLHeight = static_cast<float>(m_backbuffer_height);
float FloatXOffset = 0;
float FloatYOffset = 0;
@ -556,7 +554,7 @@ void Renderer::UpdateDrawRectangle()
// Check for force-settings and override.
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
float Ratio = CalculateDrawAspectRatio(s_backbuffer_width, s_backbuffer_height);
float Ratio = CalculateDrawAspectRatio(m_backbuffer_width, m_backbuffer_height);
if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH)
{
if (Ratio >= 0.995f && Ratio <= 1.005f)
@ -610,10 +608,10 @@ void Renderer::UpdateDrawRectangle()
iWhidth % 4; // ensure divisibility by 4 to make it compatible with all the video encoders
iHeight -= iHeight % 4;
target_rc.left = XOffset;
target_rc.top = YOffset;
target_rc.right = XOffset + iWhidth;
target_rc.bottom = YOffset + iHeight;
m_target_rectangle.left = XOffset;
m_target_rectangle.top = YOffset;
m_target_rectangle.right = XOffset + iWhidth;
m_target_rectangle.bottom = YOffset + iHeight;
}
void Renderer::InitializeCommon()
@ -705,7 +703,7 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const
// TODO: merge more generic parts into VideoCommon
g_renderer->SwapImpl(xfbAddr, fbWidth, fbStride, fbHeight, rc, ticks, Gamma);
if (XFBWrited)
if (m_xfb_written)
g_renderer->m_fps_counter.Update();
frameCount++;
@ -716,14 +714,14 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const
// New frame
stats.ResetFrame();
Core::Callback_VideoCopiedToXFB(XFBWrited ||
Core::Callback_VideoCopiedToXFB(m_xfb_written ||
(g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB));
XFBWrited = false;
m_xfb_written = false;
}
bool Renderer::IsFrameDumping()
{
if (s_screenshot.IsSet())
if (m_screenshot_request.IsSet())
return true;
#if defined(HAVE_LIBAV) || defined(_WIN32)
@ -804,17 +802,17 @@ void Renderer::RunFrameDumps()
}
// Save screenshot
if (s_screenshot.TestAndClear())
if (m_screenshot_request.TestAndClear())
{
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
std::lock_guard<std::mutex> lk(m_screenshot_lock);
if (TextureToPng(config.data, config.stride, s_sScreenshotName, config.width, config.height,
if (TextureToPng(config.data, config.stride, m_screenshot_name, config.width, config.height,
false))
OSD::AddMessage("Screenshot saved to " + s_sScreenshotName);
OSD::AddMessage("Screenshot saved to " + m_screenshot_name);
// Reset settings
s_sScreenshotName.clear();
s_screenshotCompleted.Set();
m_screenshot_name.clear();
s_screenshot_completed.Set();
}
if (SConfig::GetInstance().m_DumpFrames)

View File

@ -85,11 +85,11 @@ public:
// Ideal internal resolution - determined by display resolution (automatic scaling) and/or a
// multiple of the native EFB resolution
int GetTargetWidth() { return s_target_width; }
int GetTargetHeight() { return s_target_height; }
int GetTargetWidth() { return m_target_width; }
int GetTargetHeight() { return m_target_height; }
// Display resolution
int GetBackbufferWidth() { return s_backbuffer_width; }
int GetBackbufferHeight() { return s_backbuffer_height; }
int GetBackbufferWidth() { return m_backbuffer_width; }
int GetBackbufferHeight() { return m_backbuffer_height; }
void SetWindowSize(int width, int height);
// EFB coordinate conversion functions
@ -97,7 +97,7 @@ public:
// Use this to convert a whole native EFB rect to backbuffer coordinates
virtual TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) = 0;
const TargetRectangle& GetTargetRectangle() { return target_rc; }
const TargetRectangle& GetTargetRectangle() { return m_target_rectangle; }
float CalculateDrawAspectRatio(int target_width, int target_height);
std::tuple<float, float> ScaleToDisplayAspectRatio(int width, int height);
TargetRectangle CalculateFrameDumpDrawRectangle();
@ -138,13 +138,13 @@ public:
virtual void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
const EFBRectangle& rc, u64 ticks, float Gamma = 1.0f) = 0;
PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; }
void StorePixelFormat(PEControl::PixelFormat new_format) { prev_efb_format = new_format; }
PEControl::PixelFormat GetPrevPixelFormat() { return m_prev_efb_format; }
void StorePixelFormat(PEControl::PixelFormat new_format) { m_prev_efb_format = new_format; }
PostProcessingShaderImplementation* GetPostProcessor() { return m_post_processor.get(); }
// Max height/width
virtual u32 GetMaxTextureSize() = 0;
Common::Event s_screenshotCompleted;
Common::Event s_screenshot_completed;
// Final surface changing
// This is called when the surface is resized (WX) or the window changes (Android).
@ -161,24 +161,20 @@ protected:
bool swap_upside_down = false);
void FinishFrameData();
Common::Flag s_screenshot;
std::mutex s_criticalScreenshot;
std::string s_sScreenshotName;
Common::Flag m_screenshot_request;
std::mutex m_screenshot_lock;
std::string m_screenshot_name;
// The framebuffer size
int s_target_width = 0;
int s_target_height = 0;
int m_target_width = 0;
int m_target_height = 0;
// TODO: Add functionality to reinit all the render targets when the window is resized.
int s_backbuffer_width = 0;
int s_backbuffer_height = 0;
TargetRectangle target_rc;
// TODO: Can probably eliminate this static var.
int s_last_efb_scale = 0;
bool XFBWrited = false;
int m_backbuffer_width = 0;
int m_backbuffer_height = 0;
int m_last_efb_scale = 0;
TargetRectangle m_target_rectangle;
bool m_xfb_written = false;
FPSCounter m_fps_counter;
@ -186,19 +182,19 @@ protected:
static const float GX_MAX_DEPTH;
Common::Flag s_surface_needs_change;
Common::Event s_surface_changed;
void* s_new_surface_handle = nullptr;
Common::Flag m_surface_needs_change;
Common::Event m_surface_changed;
void* m_new_surface_handle = nullptr;
private:
void RunFrameDumps();
void ShutdownFrameDumping();
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;
PEControl::PixelFormat m_prev_efb_format = PEControl::INVALID_FMT;
unsigned int m_efb_scale_numeratorX = 1;
unsigned int m_efb_scale_numeratorY = 1;
unsigned int m_efb_scale_denominatorX = 1;
unsigned int m_efb_scale_denominatorY = 1;
// frame dumping
std::thread m_frame_dump_thread;