2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:09:55 +00:00
|
|
|
// Refer to the license.txt file included.
|
2010-11-18 02:21:26 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------
|
|
|
|
// GC graphics pipeline
|
|
|
|
// ---------------------------------------------------------------------------------------------
|
2015-01-11 05:17:29 +00:00
|
|
|
// 3d commands are issued through the fifo. The GPU draws to the 2MB EFB.
|
2010-11-18 02:21:26 +00:00
|
|
|
// The efb can be copied back into ram in two forms: as textures or as XFB.
|
|
|
|
// The XFB is the region in RAM that the VI chip scans out to the television.
|
|
|
|
// So, after all rendering to EFB is done, the image is copied into one of two XFBs in RAM.
|
|
|
|
// Next frame, that one is scanned out and the other one gets the copy. = double buffering.
|
|
|
|
// ---------------------------------------------------------------------------------------------
|
|
|
|
|
2017-02-03 17:31:20 +00:00
|
|
|
#include "VideoCommon/RenderBase.h"
|
|
|
|
|
2017-12-25 23:38:44 +00:00
|
|
|
#include <algorithm>
|
2014-12-20 11:14:33 +00:00
|
|
|
#include <cinttypes>
|
2010-11-18 02:21:26 +00:00
|
|
|
#include <cmath>
|
2015-12-21 02:49:49 +00:00
|
|
|
#include <memory>
|
2016-01-17 21:54:31 +00:00
|
|
|
#include <mutex>
|
2010-11-18 02:21:26 +00:00
|
|
|
#include <string>
|
2017-02-03 17:31:20 +00:00
|
|
|
#include <tuple>
|
2010-11-18 02:21:26 +00:00
|
|
|
|
2019-11-22 22:10:41 +00:00
|
|
|
#include <fmt/format.h>
|
2019-07-17 00:18:48 +00:00
|
|
|
#include <imgui.h>
|
2018-10-09 13:57:52 +00:00
|
|
|
|
2016-11-10 12:36:11 +00:00
|
|
|
#include "Common/Assert.h"
|
2019-06-29 09:27:53 +00:00
|
|
|
#include "Common/ChunkFile.h"
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2017-08-01 14:37:42 +00:00
|
|
|
#include "Common/Config/Config.h"
|
2016-10-07 18:31:51 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "Common/Flag.h"
|
2020-12-16 14:34:50 +00:00
|
|
|
#include "Common/Image.h"
|
2016-11-18 12:57:08 +00:00
|
|
|
#include "Common/Logging/Log.h"
|
|
|
|
#include "Common/MsgHandler.h"
|
2014-12-20 11:14:33 +00:00
|
|
|
#include "Common/Profiler.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2016-10-08 01:11:37 +00:00
|
|
|
#include "Common/Thread.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/Timer.h"
|
|
|
|
|
2019-04-02 21:13:42 +00:00
|
|
|
#include "Core/Config/NetplaySettings.h"
|
2017-08-01 14:37:42 +00:00
|
|
|
#include "Core/Config/SYSCONFSettings.h"
|
2014-10-13 03:53:10 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/Core.h"
|
2020-09-15 10:13:10 +00:00
|
|
|
#include "Core/DolphinAnalytics.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/FifoPlayer/FifoRecorder.h"
|
2020-12-06 18:03:50 +00:00
|
|
|
#include "Core/FreeLookConfig.h"
|
2018-10-27 03:11:20 +00:00
|
|
|
#include "Core/HW/SystemTimers.h"
|
2015-07-21 00:12:29 +00:00
|
|
|
#include "Core/HW/VideoInterface.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/Host.h"
|
2014-12-20 11:14:33 +00:00
|
|
|
#include "Core/Movie.h"
|
2015-07-21 00:12:29 +00:00
|
|
|
|
2020-01-24 06:06:39 +00:00
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
|
|
|
|
2018-01-21 10:22:45 +00:00
|
|
|
#include "VideoCommon/AbstractFramebuffer.h"
|
2017-11-19 07:33:53 +00:00
|
|
|
#include "VideoCommon/AbstractStagingTexture.h"
|
2017-09-03 02:30:34 +00:00
|
|
|
#include "VideoCommon/AbstractTexture.h"
|
2019-02-15 01:59:50 +00:00
|
|
|
#include "VideoCommon/BPFunctions.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/BPMemory.h"
|
|
|
|
#include "VideoCommon/CPMemory.h"
|
|
|
|
#include "VideoCommon/CommandProcessor.h"
|
2014-07-09 21:18:11 +00:00
|
|
|
#include "VideoCommon/FPSCounter.h"
|
2019-03-18 04:50:53 +00:00
|
|
|
#include "VideoCommon/FrameDump.h"
|
2019-02-15 01:59:50 +00:00
|
|
|
#include "VideoCommon/FramebufferManager.h"
|
2019-10-02 02:19:47 +00:00
|
|
|
#include "VideoCommon/FramebufferShaderGen.h"
|
2020-12-06 18:03:50 +00:00
|
|
|
#include "VideoCommon/FreeLookCamera.h"
|
2019-03-17 00:09:06 +00:00
|
|
|
#include "VideoCommon/NetPlayChatUI.h"
|
2019-04-02 21:13:42 +00:00
|
|
|
#include "VideoCommon/NetPlayGolfUI.h"
|
2016-10-15 10:36:11 +00:00
|
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
2019-12-05 13:11:52 +00:00
|
|
|
#include "VideoCommon/OpcodeDecoding.h"
|
2019-02-15 01:59:50 +00:00
|
|
|
#include "VideoCommon/PixelEngine.h"
|
2017-03-04 06:40:08 +00:00
|
|
|
#include "VideoCommon/PixelShaderManager.h"
|
2015-12-22 23:47:20 +00:00
|
|
|
#include "VideoCommon/PostProcessing.h"
|
2018-02-24 15:15:35 +00:00
|
|
|
#include "VideoCommon/ShaderCache.h"
|
2017-07-20 07:10:02 +00:00
|
|
|
#include "VideoCommon/ShaderGenCommon.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/Statistics.h"
|
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2017-01-03 07:31:16 +00:00
|
|
|
#include "VideoCommon/TextureDecoder.h"
|
2018-10-09 14:26:31 +00:00
|
|
|
#include "VideoCommon/VertexLoaderManager.h"
|
2017-03-03 22:36:51 +00:00
|
|
|
#include "VideoCommon/VertexManagerBase.h"
|
|
|
|
#include "VideoCommon/VertexShaderManager.h"
|
2019-02-15 01:59:50 +00:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2019-07-17 00:18:48 +00:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
|
|
|
#include "VideoCommon/XFMemory.h"
|
|
|
|
|
2015-12-21 02:49:49 +00:00
|
|
|
std::unique_ptr<Renderer> g_renderer;
|
2010-11-18 02:21:26 +00:00
|
|
|
|
2016-01-08 00:31:48 +00:00
|
|
|
static float AspectToWidescreen(float aspect)
|
|
|
|
{
|
|
|
|
return aspect * ((16.0f / 9.0f) / (4.0f / 3.0f));
|
|
|
|
}
|
2012-05-28 09:31:37 +00:00
|
|
|
|
2020-12-16 14:34:50 +00:00
|
|
|
static bool DumpFrameToPNG(const FrameDump::FrameData& frame, const std::string& file_name)
|
|
|
|
{
|
|
|
|
return Common::ConvertRGBAToRGBAndSavePNG(file_name, frame.data, frame.width, frame.height,
|
|
|
|
frame.stride);
|
|
|
|
}
|
|
|
|
|
2019-01-18 14:35:00 +00:00
|
|
|
Renderer::Renderer(int backbuffer_width, int backbuffer_height, float backbuffer_scale,
|
2017-09-09 06:09:24 +00:00
|
|
|
AbstractTextureFormat backbuffer_format)
|
|
|
|
: m_backbuffer_width(backbuffer_width), m_backbuffer_height(backbuffer_height),
|
2019-07-17 00:18:48 +00:00
|
|
|
m_backbuffer_scale(backbuffer_scale),
|
|
|
|
m_backbuffer_format(backbuffer_format), m_last_xfb_width{MAX_XFB_WIDTH}, m_last_xfb_height{
|
|
|
|
MAX_XFB_HEIGHT}
|
2010-11-18 02:21:26 +00:00
|
|
|
{
|
|
|
|
UpdateActiveConfig();
|
2020-12-06 18:03:50 +00:00
|
|
|
FreeLook::UpdateActiveConfig();
|
2017-03-04 06:40:08 +00:00
|
|
|
UpdateDrawRectangle();
|
2017-03-09 13:39:48 +00:00
|
|
|
CalculateTargetSize();
|
2017-03-04 06:40:08 +00:00
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
m_is_game_widescreen = SConfig::GetInstance().bWii && Config::Get(Config::SYSCONF_WIDESCREEN);
|
2020-12-26 04:19:09 +00:00
|
|
|
g_freelook_camera.SetControlType(FreeLook::GetActiveConfig().camera_config.control_type);
|
2010-11-18 02:21:26 +00:00
|
|
|
}
|
|
|
|
|
2017-09-14 04:46:30 +00:00
|
|
|
Renderer::~Renderer() = default;
|
|
|
|
|
2018-02-09 10:52:25 +00:00
|
|
|
bool Renderer::Initialize()
|
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
if (!InitializeImGui())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_post_processor = std::make_unique<VideoCommon::PostProcessing>();
|
|
|
|
if (!m_post_processor->Initialize(m_backbuffer_format))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2018-02-09 10:52:25 +00:00
|
|
|
}
|
|
|
|
|
2018-01-26 05:09:07 +00:00
|
|
|
void Renderer::Shutdown()
|
|
|
|
{
|
2020-01-24 06:06:39 +00:00
|
|
|
// Disable ControllerInterface's aspect ratio adjustments so mapping dialog behaves normally.
|
|
|
|
g_controller_interface.SetAspectRatioAdjustment(1);
|
|
|
|
|
2018-01-26 05:09:07 +00:00
|
|
|
// First stop any framedumping, which might need to dump the last xfb frame. This process
|
|
|
|
// can require additional graphics sub-systems so it needs to be done first
|
|
|
|
ShutdownFrameDumping();
|
2018-10-09 13:57:52 +00:00
|
|
|
ShutdownImGui();
|
2019-02-15 01:59:50 +00:00
|
|
|
m_post_processor.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::BeginUtilityDrawing()
|
|
|
|
{
|
|
|
|
g_vertex_manager->Flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::EndUtilityDrawing()
|
|
|
|
{
|
|
|
|
// Reset framebuffer/scissor/viewport. Pipeline will be reset at next draw.
|
|
|
|
g_framebuffer_manager->BindEFBFramebuffer();
|
|
|
|
BPFunctions::SetScissor();
|
|
|
|
BPFunctions::SetViewport();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::SetFramebuffer(AbstractFramebuffer* framebuffer)
|
|
|
|
{
|
|
|
|
m_current_framebuffer = framebuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
|
|
|
|
{
|
|
|
|
m_current_framebuffer = framebuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer,
|
|
|
|
const ClearColor& color_value, float depth_value)
|
|
|
|
{
|
|
|
|
m_current_framebuffer = framebuffer;
|
|
|
|
}
|
|
|
|
|
2019-03-09 13:31:29 +00:00
|
|
|
bool Renderer::EFBHasAlphaChannel() const
|
|
|
|
{
|
|
|
|
return m_prev_efb_format == PEControl::RGBA6_Z24;
|
|
|
|
}
|
|
|
|
|
2019-04-15 14:47:46 +00:00
|
|
|
void Renderer::ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
|
|
|
|
bool zEnable, u32 color, u32 z)
|
2019-02-15 01:59:50 +00:00
|
|
|
{
|
|
|
|
g_framebuffer_manager->ClearEFB(rc, colorEnable, alphaEnable, zEnable, color, z);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::ReinterpretPixelData(EFBReinterpretType convtype)
|
|
|
|
{
|
|
|
|
g_framebuffer_manager->ReinterpretPixelData(convtype);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
|
|
|
{
|
|
|
|
if (type == EFBAccessType::PeekColor)
|
|
|
|
{
|
|
|
|
u32 color = g_framebuffer_manager->PeekEFBColor(x, y);
|
|
|
|
|
|
|
|
// a little-endian value is expected to be returned
|
|
|
|
color = ((color & 0xFF00FF00) | ((color >> 16) & 0xFF) | ((color << 16) & 0xFF0000));
|
|
|
|
|
|
|
|
// check what to do with the alpha channel (GX_PokeAlphaRead)
|
|
|
|
PixelEngine::UPEAlphaReadReg alpha_read_mode = PixelEngine::GetAlphaReadMode();
|
|
|
|
|
|
|
|
if (bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24)
|
|
|
|
{
|
|
|
|
color = RGBA8ToRGBA6ToRGBA8(color);
|
|
|
|
}
|
|
|
|
else if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16)
|
|
|
|
{
|
|
|
|
color = RGBA8ToRGB565ToRGBA8(color);
|
|
|
|
}
|
|
|
|
if (bpmem.zcontrol.pixel_format != PEControl::RGBA6_Z24)
|
|
|
|
{
|
|
|
|
color |= 0xFF000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alpha_read_mode.ReadMode == 2)
|
|
|
|
{
|
|
|
|
return color; // GX_READ_NONE
|
|
|
|
}
|
|
|
|
else if (alpha_read_mode.ReadMode == 1)
|
|
|
|
{
|
|
|
|
return color | 0xFF000000; // GX_READ_FF
|
|
|
|
}
|
|
|
|
else /*if(alpha_read_mode.ReadMode == 0)*/
|
|
|
|
{
|
|
|
|
return color & 0x00FFFFFF; // GX_READ_00
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // if (type == EFBAccessType::PeekZ)
|
|
|
|
{
|
|
|
|
// Depth buffer is inverted for improved precision near far plane
|
|
|
|
float depth = g_framebuffer_manager->PeekEFBDepth(x, y);
|
|
|
|
if (!g_ActiveConfig.backend_info.bSupportsReversedDepthRange)
|
|
|
|
depth = 1.0f - depth;
|
|
|
|
|
|
|
|
u32 ret = 0;
|
|
|
|
if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16)
|
|
|
|
{
|
|
|
|
// if Z is in 16 bit format you must return a 16 bit integer
|
2017-12-25 23:38:44 +00:00
|
|
|
ret = std::clamp<u32>(static_cast<u32>(depth * 65536.0f), 0, 0xFFFF);
|
2019-02-15 01:59:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-25 23:38:44 +00:00
|
|
|
ret = std::clamp<u32>(static_cast<u32>(depth * 16777216.0f), 0, 0xFFFFFF);
|
2019-02-15 01:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points)
|
|
|
|
{
|
|
|
|
if (type == EFBAccessType::PokeColor)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < num_points; i++)
|
|
|
|
{
|
|
|
|
// Convert to expected format (BGRA->RGBA)
|
|
|
|
// TODO: Check alpha, depending on mode?
|
|
|
|
const EfbPokeData& point = points[i];
|
|
|
|
u32 color = ((point.data & 0xFF00FF00) | ((point.data >> 16) & 0xFF) |
|
|
|
|
((point.data << 16) & 0xFF0000));
|
|
|
|
g_framebuffer_manager->PokeEFBColor(point.x, point.y, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // if (type == EFBAccessType::PokeZ)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < num_points; i++)
|
|
|
|
{
|
|
|
|
// Convert to floating-point depth.
|
|
|
|
const EfbPokeData& point = points[i];
|
|
|
|
float depth = float(point.data & 0xFFFFFF) / 16777216.0f;
|
|
|
|
if (!g_ActiveConfig.backend_info.bSupportsReversedDepthRange)
|
|
|
|
depth = 1.0f - depth;
|
|
|
|
|
|
|
|
g_framebuffer_manager->PokeEFBDepth(point.x, point.y, depth);
|
|
|
|
}
|
|
|
|
}
|
2018-01-26 05:09:07 +00:00
|
|
|
}
|
|
|
|
|
2019-04-15 14:47:46 +00:00
|
|
|
void Renderer::RenderToXFB(u32 xfbAddr, const MathUtil::Rectangle<int>& sourceRc, u32 fbStride,
|
|
|
|
u32 fbHeight, float Gamma)
|
2010-11-18 02:21:26 +00:00
|
|
|
{
|
2011-03-27 02:55:08 +00:00
|
|
|
CheckFifoRecording();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-07-07 13:09:25 +00:00
|
|
|
if (!fbStride || !fbHeight)
|
2010-11-18 02:21:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-03 15:04:46 +00:00
|
|
|
unsigned int Renderer::GetEFBScale() const
|
|
|
|
{
|
|
|
|
return m_efb_scale;
|
|
|
|
}
|
|
|
|
|
2017-04-08 23:40:04 +00:00
|
|
|
int Renderer::EFBToScaledX(int x) const
|
2011-01-07 04:57:59 +00:00
|
|
|
{
|
2017-07-03 14:32:02 +00:00
|
|
|
return x * static_cast<int>(m_efb_scale);
|
2012-10-02 20:11:15 +00:00
|
|
|
}
|
|
|
|
|
2017-04-08 23:40:04 +00:00
|
|
|
int Renderer::EFBToScaledY(int y) const
|
2011-01-07 04:57:59 +00:00
|
|
|
{
|
2017-07-03 14:32:02 +00:00
|
|
|
return y * static_cast<int>(m_efb_scale);
|
2012-10-02 20:11:15 +00:00
|
|
|
}
|
|
|
|
|
2017-04-08 23:40:04 +00:00
|
|
|
float Renderer::EFBToScaledXf(float x) const
|
|
|
|
{
|
|
|
|
return x * ((float)GetTargetWidth() / (float)EFB_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
float Renderer::EFBToScaledYf(float y) const
|
|
|
|
{
|
|
|
|
return y * ((float)GetTargetHeight() / (float)EFB_HEIGHT);
|
|
|
|
}
|
|
|
|
|
2017-04-09 18:38:43 +00:00
|
|
|
std::tuple<int, int> Renderer::CalculateTargetScale(int x, int y) const
|
2012-10-02 20:11:15 +00:00
|
|
|
{
|
2017-07-03 14:32:02 +00:00
|
|
|
return std::make_tuple(x * static_cast<int>(m_efb_scale), y * static_cast<int>(m_efb_scale));
|
2012-10-02 20:11:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// return true if target size changed
|
2016-11-10 13:31:44 +00:00
|
|
|
bool Renderer::CalculateTargetSize()
|
2012-10-02 20:11:15 +00:00
|
|
|
{
|
2017-07-03 14:32:02 +00:00
|
|
|
if (g_ActiveConfig.iEFBScale == EFB_SCALE_AUTO_INTEGRAL)
|
|
|
|
{
|
|
|
|
// Set a scale based on the window size
|
2017-08-13 00:51:33 +00:00
|
|
|
int width = EFB_WIDTH * m_target_rectangle.GetWidth() / m_last_xfb_width;
|
2018-06-25 04:48:57 +00:00
|
|
|
int height = EFB_HEIGHT * m_target_rectangle.GetHeight() / m_last_xfb_height;
|
2017-07-03 14:32:02 +00:00
|
|
|
m_efb_scale = std::max((width - 1) / EFB_WIDTH + 1, (height - 1) / EFB_HEIGHT + 1);
|
|
|
|
}
|
|
|
|
else
|
2012-10-02 20:11:15 +00:00
|
|
|
{
|
2017-07-03 14:32:02 +00:00
|
|
|
m_efb_scale = g_ActiveConfig.iEFBScale;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-07-03 14:32:02 +00:00
|
|
|
const u32 max_size = g_ActiveConfig.backend_info.MaxTextureSize;
|
|
|
|
if (max_size < EFB_WIDTH * m_efb_scale)
|
|
|
|
m_efb_scale = max_size / EFB_WIDTH;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-08-05 02:57:12 +00:00
|
|
|
auto [new_efb_width, new_efb_height] = CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT);
|
2019-02-15 01:59:50 +00:00
|
|
|
new_efb_width = std::max(new_efb_width, 1);
|
|
|
|
new_efb_height = std::max(new_efb_height, 1);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-04-09 18:38:43 +00:00
|
|
|
if (new_efb_width != m_target_width || new_efb_height != m_target_height)
|
2010-11-18 02:21:26 +00:00
|
|
|
{
|
2017-04-09 18:38:43 +00:00
|
|
|
m_target_width = new_efb_width;
|
|
|
|
m_target_height = new_efb_height;
|
2017-03-04 06:42:27 +00:00
|
|
|
PixelShaderManager::SetEfbScaleChanged(EFBToScaledXf(1), EFBToScaledYf(1));
|
2010-11-18 02:21:26 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-15 14:47:46 +00:00
|
|
|
std::tuple<MathUtil::Rectangle<int>, MathUtil::Rectangle<int>>
|
|
|
|
Renderer::ConvertStereoRectangle(const MathUtil::Rectangle<int>& rc) const
|
2014-10-31 15:24:35 +00:00
|
|
|
{
|
|
|
|
// Resize target to half its original size
|
2019-04-15 14:47:46 +00:00
|
|
|
auto draw_rc = rc;
|
2017-11-11 03:55:00 +00:00
|
|
|
if (g_ActiveConfig.stereo_mode == StereoMode::TAB)
|
2014-10-31 15:24:35 +00:00
|
|
|
{
|
|
|
|
// The height may be negative due to flipped rectangles
|
|
|
|
int height = rc.bottom - rc.top;
|
2017-04-09 19:05:24 +00:00
|
|
|
draw_rc.top += height / 4;
|
|
|
|
draw_rc.bottom -= height / 4;
|
2014-10-31 15:24:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int width = rc.right - rc.left;
|
2017-04-09 19:05:24 +00:00
|
|
|
draw_rc.left += width / 4;
|
|
|
|
draw_rc.right -= width / 4;
|
2014-10-31 15:24:35 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-10-31 15:24:35 +00:00
|
|
|
// Create two target rectangle offset to the sides of the backbuffer
|
2019-04-15 14:47:46 +00:00
|
|
|
auto left_rc = draw_rc;
|
|
|
|
auto right_rc = draw_rc;
|
2017-11-11 03:55:00 +00:00
|
|
|
if (g_ActiveConfig.stereo_mode == StereoMode::TAB)
|
2014-10-31 15:24:35 +00:00
|
|
|
{
|
2017-04-09 19:05:24 +00:00
|
|
|
left_rc.top -= m_backbuffer_height / 4;
|
|
|
|
left_rc.bottom -= m_backbuffer_height / 4;
|
|
|
|
right_rc.top += m_backbuffer_height / 4;
|
|
|
|
right_rc.bottom += m_backbuffer_height / 4;
|
2014-10-31 15:24:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-09 19:05:24 +00:00
|
|
|
left_rc.left -= m_backbuffer_width / 4;
|
|
|
|
left_rc.right -= m_backbuffer_width / 4;
|
|
|
|
right_rc.left += m_backbuffer_width / 4;
|
|
|
|
right_rc.right += m_backbuffer_width / 4;
|
2014-10-31 15:24:35 +00:00
|
|
|
}
|
2017-04-09 19:05:24 +00:00
|
|
|
|
|
|
|
return std::make_tuple(left_rc, right_rc);
|
2014-10-31 15:24:35 +00:00
|
|
|
}
|
|
|
|
|
2020-08-06 19:57:12 +00:00
|
|
|
void Renderer::SaveScreenshot(std::string filename)
|
2010-11-18 02:21:26 +00:00
|
|
|
{
|
2020-08-06 19:57:12 +00:00
|
|
|
std::lock_guard<std::mutex> lk(m_screenshot_lock);
|
|
|
|
m_screenshot_name = std::move(filename);
|
|
|
|
m_screenshot_request.Set();
|
2010-11-18 02:21:26 +00:00
|
|
|
}
|
|
|
|
|
2018-11-28 04:30:47 +00:00
|
|
|
void Renderer::CheckForConfigChanges()
|
2017-07-20 07:10:02 +00:00
|
|
|
{
|
2018-11-28 04:30:47 +00:00
|
|
|
const ShaderHostConfig old_shader_host_config = ShaderHostConfig::GetCurrent();
|
|
|
|
const StereoMode old_stereo = g_ActiveConfig.stereo_mode;
|
|
|
|
const u32 old_multisamples = g_ActiveConfig.iMultisamples;
|
|
|
|
const int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
|
2019-03-02 05:11:47 +00:00
|
|
|
const int old_efb_access_tile_size = g_ActiveConfig.iEFBAccessTileSize;
|
2018-11-28 04:30:47 +00:00
|
|
|
const bool old_force_filtering = g_ActiveConfig.bForceFiltering;
|
2019-01-27 02:24:53 +00:00
|
|
|
const bool old_vsync = g_ActiveConfig.bVSyncActive;
|
2018-11-28 04:30:47 +00:00
|
|
|
const bool old_bbox = g_ActiveConfig.bBBoxEnable;
|
|
|
|
|
|
|
|
UpdateActiveConfig();
|
2020-12-06 18:03:50 +00:00
|
|
|
FreeLook::UpdateActiveConfig();
|
|
|
|
|
|
|
|
g_freelook_camera.SetControlType(FreeLook::GetActiveConfig().camera_config.control_type);
|
2018-11-28 04:30:47 +00:00
|
|
|
|
|
|
|
// Update texture cache settings with any changed options.
|
|
|
|
g_texture_cache->OnConfigChanged(g_ActiveConfig);
|
|
|
|
|
2019-03-02 05:11:47 +00:00
|
|
|
// EFB tile cache doesn't need to notify the backend.
|
|
|
|
if (old_efb_access_tile_size != g_ActiveConfig.iEFBAccessTileSize)
|
|
|
|
g_framebuffer_manager->SetEFBCacheTileSize(std::max(g_ActiveConfig.iEFBAccessTileSize, 0));
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
// Check for post-processing shader changes. Done up here as it doesn't affect anything outside
|
|
|
|
// the post-processor. Note that options are applied every frame, so no need to check those.
|
|
|
|
if (m_post_processor->GetConfig()->GetShader() != g_ActiveConfig.sPostProcessingShader)
|
2019-03-07 00:54:54 +00:00
|
|
|
{
|
|
|
|
// The existing shader must not be in use when it's destroyed
|
|
|
|
WaitForGPUIdle();
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
m_post_processor->RecompileShader();
|
2019-03-07 00:54:54 +00:00
|
|
|
}
|
2019-02-15 01:59:50 +00:00
|
|
|
|
2018-11-28 04:30:47 +00:00
|
|
|
// Determine which (if any) settings have changed.
|
2017-07-20 07:10:02 +00:00
|
|
|
ShaderHostConfig new_host_config = ShaderHostConfig::GetCurrent();
|
2018-11-28 04:30:47 +00:00
|
|
|
u32 changed_bits = 0;
|
|
|
|
if (old_shader_host_config.bits != new_host_config.bits)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_HOST_CONFIG;
|
|
|
|
if (old_stereo != g_ActiveConfig.stereo_mode)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_STEREO_MODE;
|
|
|
|
if (old_multisamples != g_ActiveConfig.iMultisamples)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_MULTISAMPLES;
|
|
|
|
if (old_anisotropy != g_ActiveConfig.iMaxAnisotropy)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_ANISOTROPY;
|
|
|
|
if (old_force_filtering != g_ActiveConfig.bForceFiltering)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_FORCE_TEXTURE_FILTERING;
|
2019-01-27 02:24:53 +00:00
|
|
|
if (old_vsync != g_ActiveConfig.bVSyncActive)
|
2018-11-28 04:30:47 +00:00
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_VSYNC;
|
|
|
|
if (old_bbox != g_ActiveConfig.bBBoxEnable)
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_BBOX;
|
|
|
|
if (CalculateTargetSize())
|
|
|
|
changed_bits |= CONFIG_CHANGE_BIT_TARGET_SIZE;
|
|
|
|
|
|
|
|
// No changes?
|
|
|
|
if (changed_bits == 0)
|
|
|
|
return;
|
2017-07-20 07:10:02 +00:00
|
|
|
|
2018-11-28 04:30:47 +00:00
|
|
|
// Notify the backend of the changes, if any.
|
|
|
|
OnConfigChanged(changed_bits);
|
2018-02-24 15:15:35 +00:00
|
|
|
|
2019-10-02 02:19:47 +00:00
|
|
|
// If there's any shader changes, wait for the GPU to finish before destroying anything.
|
|
|
|
if (changed_bits & (CONFIG_CHANGE_BIT_HOST_CONFIG | CONFIG_CHANGE_BIT_MULTISAMPLES))
|
|
|
|
{
|
|
|
|
WaitForGPUIdle();
|
|
|
|
SetPipeline(nullptr);
|
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
// Framebuffer changed?
|
|
|
|
if (changed_bits & (CONFIG_CHANGE_BIT_MULTISAMPLES | CONFIG_CHANGE_BIT_STEREO_MODE |
|
|
|
|
CONFIG_CHANGE_BIT_TARGET_SIZE))
|
|
|
|
{
|
|
|
|
g_framebuffer_manager->RecreateEFBFramebuffer();
|
|
|
|
}
|
|
|
|
|
2018-11-28 04:30:47 +00:00
|
|
|
// Reload shaders if host config has changed.
|
|
|
|
if (changed_bits & (CONFIG_CHANGE_BIT_HOST_CONFIG | CONFIG_CHANGE_BIT_MULTISAMPLES))
|
|
|
|
{
|
|
|
|
OSD::AddMessage("Video config changed, reloading shaders.", OSD::Duration::NORMAL);
|
|
|
|
g_vertex_manager->InvalidatePipelineObject();
|
2019-02-15 01:59:50 +00:00
|
|
|
g_shader_cache->SetHostConfig(new_host_config);
|
|
|
|
g_shader_cache->Reload();
|
|
|
|
g_framebuffer_manager->RecompileShaders();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Viewport and scissor rect have to be reset since they will be scaled differently.
|
|
|
|
if (changed_bits & CONFIG_CHANGE_BIT_TARGET_SIZE)
|
|
|
|
{
|
|
|
|
BPFunctions::SetViewport();
|
|
|
|
BPFunctions::SetScissor();
|
2018-11-28 04:30:47 +00:00
|
|
|
}
|
2019-10-02 02:19:47 +00:00
|
|
|
|
|
|
|
// Stereo mode change requires recompiling our post processing pipeline and imgui pipelines for
|
|
|
|
// rendering the UI.
|
|
|
|
if (changed_bits & CONFIG_CHANGE_BIT_STEREO_MODE)
|
|
|
|
{
|
|
|
|
RecompileImGuiPipeline();
|
|
|
|
m_post_processor->RecompilePipeline();
|
|
|
|
}
|
2017-07-20 07:10:02 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 10:36:11 +00:00
|
|
|
// Create On-Screen-Messages
|
2010-11-18 02:21:26 +00:00
|
|
|
void Renderer::DrawDebugText()
|
|
|
|
{
|
2018-10-09 14:26:31 +00:00
|
|
|
const auto& config = SConfig::GetInstance();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2018-10-09 14:26:31 +00:00
|
|
|
if (g_ActiveConfig.bShowFPS)
|
2016-10-04 02:37:18 +00:00
|
|
|
{
|
2018-10-09 14:26:31 +00:00
|
|
|
// Position in the top-right corner of the screen.
|
|
|
|
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - (10.0f * m_backbuffer_scale),
|
|
|
|
10.0f * m_backbuffer_scale),
|
|
|
|
ImGuiCond_Always, ImVec2(1.0f, 0.0f));
|
|
|
|
ImGui::SetNextWindowSize(ImVec2(100.0f * m_backbuffer_scale, 30.0f * m_backbuffer_scale));
|
|
|
|
|
|
|
|
if (ImGui::Begin("FPS", nullptr,
|
|
|
|
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs |
|
|
|
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings |
|
|
|
|
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav |
|
|
|
|
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing))
|
2014-12-20 12:02:00 +00:00
|
|
|
{
|
2018-10-09 14:26:31 +00:00
|
|
|
ImGui::TextColored(ImVec4(0.0f, 1.0f, 1.0f, 1.0f), "FPS: %.2f", m_fps_counter.GetFPS());
|
2014-12-20 12:02:00 +00:00
|
|
|
}
|
2018-10-09 14:26:31 +00:00
|
|
|
ImGui::End();
|
2014-12-20 12:02:00 +00:00
|
|
|
}
|
2016-10-15 10:36:11 +00:00
|
|
|
|
2018-10-09 14:26:31 +00:00
|
|
|
const bool show_movie_window =
|
|
|
|
config.m_ShowFrameCount | config.m_ShowLag | config.m_ShowInputDisplay | config.m_ShowRTC;
|
|
|
|
if (show_movie_window)
|
2016-10-15 10:36:11 +00:00
|
|
|
{
|
2018-10-09 14:26:31 +00:00
|
|
|
// Position under the FPS display.
|
|
|
|
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - (10.0f * m_backbuffer_scale),
|
|
|
|
50.0f * m_backbuffer_scale),
|
|
|
|
ImGuiCond_FirstUseEver, ImVec2(1.0f, 0.0f));
|
|
|
|
ImGui::SetNextWindowSizeConstraints(
|
|
|
|
ImVec2(150.0f * m_backbuffer_scale, 20.0f * m_backbuffer_scale),
|
|
|
|
ImGui::GetIO().DisplaySize);
|
|
|
|
if (ImGui::Begin("Movie", nullptr, ImGuiWindowFlags_NoFocusOnAppearing))
|
2016-10-15 10:36:11 +00:00
|
|
|
{
|
2018-10-09 14:26:31 +00:00
|
|
|
if (config.m_ShowFrameCount)
|
|
|
|
{
|
|
|
|
ImGui::Text("Frame: %" PRIu64, Movie::GetCurrentFrame());
|
|
|
|
}
|
|
|
|
if (Movie::IsPlayingInput())
|
|
|
|
{
|
|
|
|
ImGui::Text("Input: %" PRIu64 " / %" PRIu64, Movie::GetCurrentInputCount(),
|
|
|
|
Movie::GetTotalInputCount());
|
|
|
|
}
|
|
|
|
if (SConfig::GetInstance().m_ShowLag)
|
|
|
|
ImGui::Text("Lag: %" PRIu64 "\n", Movie::GetCurrentLagCount());
|
|
|
|
if (SConfig::GetInstance().m_ShowInputDisplay)
|
|
|
|
ImGui::TextUnformatted(Movie::GetInputDisplay().c_str());
|
|
|
|
if (SConfig::GetInstance().m_ShowRTC)
|
|
|
|
ImGui::TextUnformatted(Movie::GetRTCDisplay().c_str());
|
2016-10-15 10:36:11 +00:00
|
|
|
}
|
2018-10-09 14:26:31 +00:00
|
|
|
ImGui::End();
|
2016-10-15 10:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (g_ActiveConfig.bOverlayStats)
|
2019-07-11 03:34:50 +00:00
|
|
|
g_stats.Display();
|
2016-10-15 10:36:11 +00:00
|
|
|
|
2019-03-17 00:09:06 +00:00
|
|
|
if (g_ActiveConfig.bShowNetPlayMessages && g_netplay_chat_ui)
|
|
|
|
g_netplay_chat_ui->Display();
|
|
|
|
|
2019-04-02 21:13:42 +00:00
|
|
|
if (Config::Get(Config::NETPLAY_GOLF_MODE_OVERLAY) && g_netplay_golf_ui)
|
|
|
|
g_netplay_golf_ui->Display();
|
|
|
|
|
2016-10-15 10:36:11 +00:00
|
|
|
if (g_ActiveConfig.bOverlayProjStats)
|
2019-07-11 03:34:50 +00:00
|
|
|
g_stats.DisplayProj();
|
2020-06-29 09:59:47 +00:00
|
|
|
|
|
|
|
const std::string profile_output = Common::Profiler::ToString();
|
|
|
|
if (!profile_output.empty())
|
|
|
|
ImGui::TextUnformatted(profile_output.c_str());
|
2014-12-20 11:14:33 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 01:51:31 +00:00
|
|
|
float Renderer::CalculateDrawAspectRatio() const
|
2016-11-10 12:36:11 +00:00
|
|
|
{
|
2020-01-26 01:04:50 +00:00
|
|
|
const auto aspect_mode = g_ActiveConfig.aspect_mode;
|
|
|
|
|
|
|
|
// If stretch is enabled, we prefer the aspect ratio of the window.
|
|
|
|
if (aspect_mode == AspectMode::Stretch)
|
2017-03-03 01:51:31 +00:00
|
|
|
return (static_cast<float>(m_backbuffer_width) / static_cast<float>(m_backbuffer_height));
|
2016-11-10 12:36:11 +00:00
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
const float aspect_ratio = VideoInterface::GetAspectRatio();
|
|
|
|
|
|
|
|
if (aspect_mode == AspectMode::AnalogWide ||
|
|
|
|
(aspect_mode == AspectMode::Auto && m_is_game_widescreen))
|
2016-11-10 12:36:11 +00:00
|
|
|
{
|
2020-01-26 01:04:50 +00:00
|
|
|
return AspectToWidescreen(aspect_ratio);
|
2016-11-10 12:36:11 +00:00
|
|
|
}
|
2020-01-26 01:04:50 +00:00
|
|
|
|
|
|
|
return aspect_ratio;
|
2016-11-10 12:36:11 +00:00
|
|
|
}
|
|
|
|
|
2019-04-28 06:53:16 +00:00
|
|
|
void Renderer::AdjustRectanglesToFitBounds(MathUtil::Rectangle<int>* target_rect,
|
|
|
|
MathUtil::Rectangle<int>* source_rect, int fb_width,
|
|
|
|
int fb_height)
|
|
|
|
{
|
|
|
|
const int orig_target_width = target_rect->GetWidth();
|
|
|
|
const int orig_target_height = target_rect->GetHeight();
|
|
|
|
const int orig_source_width = source_rect->GetWidth();
|
|
|
|
const int orig_source_height = source_rect->GetHeight();
|
|
|
|
if (target_rect->left < 0)
|
|
|
|
{
|
|
|
|
const int offset = -target_rect->left;
|
|
|
|
target_rect->left = 0;
|
|
|
|
source_rect->left += offset * orig_source_width / orig_target_width;
|
|
|
|
}
|
|
|
|
if (target_rect->right > fb_width)
|
|
|
|
{
|
|
|
|
const int offset = target_rect->right - fb_width;
|
|
|
|
target_rect->right -= offset;
|
|
|
|
source_rect->right -= offset * orig_source_width / orig_target_width;
|
|
|
|
}
|
|
|
|
if (target_rect->top < 0)
|
|
|
|
{
|
|
|
|
const int offset = -target_rect->top;
|
|
|
|
target_rect->top = 0;
|
|
|
|
source_rect->top += offset * orig_source_height / orig_target_height;
|
|
|
|
}
|
|
|
|
if (target_rect->bottom > fb_height)
|
|
|
|
{
|
|
|
|
const int offset = target_rect->bottom - fb_height;
|
2019-06-18 22:33:44 +00:00
|
|
|
target_rect->bottom -= offset;
|
|
|
|
source_rect->bottom -= offset * orig_source_height / orig_target_height;
|
2019-04-28 06:53:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-23 06:53:44 +00:00
|
|
|
bool Renderer::IsHeadless() const
|
|
|
|
{
|
2018-10-03 13:03:13 +00:00
|
|
|
return true;
|
2017-11-23 06:53:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-26 06:23:24 +00:00
|
|
|
void Renderer::ChangeSurface(void* new_surface_handle)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> lock(m_swap_mutex);
|
|
|
|
m_new_surface_handle = new_surface_handle;
|
|
|
|
m_surface_changed.Set();
|
|
|
|
}
|
|
|
|
|
2018-10-03 13:03:16 +00:00
|
|
|
void Renderer::ResizeSurface()
|
2018-01-26 06:23:24 +00:00
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> lock(m_swap_mutex);
|
|
|
|
m_surface_resized.Set();
|
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
void Renderer::SetViewportAndScissor(const MathUtil::Rectangle<int>& rect, float min_depth,
|
|
|
|
float max_depth)
|
|
|
|
{
|
|
|
|
SetViewport(static_cast<float>(rect.left), static_cast<float>(rect.top),
|
|
|
|
static_cast<float>(rect.GetWidth()), static_cast<float>(rect.GetHeight()), min_depth,
|
|
|
|
max_depth);
|
|
|
|
SetScissorRect(rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::ScaleTexture(AbstractFramebuffer* dst_framebuffer,
|
|
|
|
const MathUtil::Rectangle<int>& dst_rect,
|
|
|
|
const AbstractTexture* src_texture,
|
|
|
|
const MathUtil::Rectangle<int>& src_rect)
|
|
|
|
{
|
|
|
|
ASSERT(dst_framebuffer->GetColorFormat() == AbstractTextureFormat::RGBA8);
|
|
|
|
|
|
|
|
BeginUtilityDrawing();
|
|
|
|
|
|
|
|
// The shader needs to know the source rectangle.
|
2019-08-05 03:01:16 +00:00
|
|
|
const auto converted_src_rect =
|
|
|
|
ConvertFramebufferRectangle(src_rect, src_texture->GetWidth(), src_texture->GetHeight());
|
2019-02-15 01:59:50 +00:00
|
|
|
const float rcp_src_width = 1.0f / src_texture->GetWidth();
|
|
|
|
const float rcp_src_height = 1.0f / src_texture->GetHeight();
|
|
|
|
const std::array<float, 4> uniforms = {{converted_src_rect.left * rcp_src_width,
|
|
|
|
converted_src_rect.top * rcp_src_height,
|
|
|
|
converted_src_rect.GetWidth() * rcp_src_width,
|
|
|
|
converted_src_rect.GetHeight() * rcp_src_height}};
|
|
|
|
g_vertex_manager->UploadUtilityUniforms(&uniforms, sizeof(uniforms));
|
|
|
|
|
|
|
|
// Discard if we're overwriting the whole thing.
|
|
|
|
if (static_cast<u32>(dst_rect.GetWidth()) == dst_framebuffer->GetWidth() &&
|
|
|
|
static_cast<u32>(dst_rect.GetHeight()) == dst_framebuffer->GetHeight())
|
|
|
|
{
|
|
|
|
SetAndDiscardFramebuffer(dst_framebuffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetFramebuffer(dst_framebuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetViewportAndScissor(ConvertFramebufferRectangle(dst_rect, dst_framebuffer));
|
|
|
|
SetPipeline(dst_framebuffer->GetLayers() > 1 ? g_shader_cache->GetRGBA8StereoCopyPipeline() :
|
|
|
|
g_shader_cache->GetRGBA8CopyPipeline());
|
|
|
|
SetTexture(0, src_texture);
|
|
|
|
SetSamplerState(0, RenderState::GetLinearSamplerState());
|
|
|
|
Draw(0, 3);
|
|
|
|
EndUtilityDrawing();
|
|
|
|
if (dst_framebuffer->GetColorAttachment())
|
|
|
|
dst_framebuffer->GetColorAttachment()->FinishedRendering();
|
|
|
|
}
|
|
|
|
|
|
|
|
MathUtil::Rectangle<int>
|
|
|
|
Renderer::ConvertFramebufferRectangle(const MathUtil::Rectangle<int>& rect,
|
2019-08-05 02:45:25 +00:00
|
|
|
const AbstractFramebuffer* framebuffer) const
|
2019-02-15 01:59:50 +00:00
|
|
|
{
|
|
|
|
return ConvertFramebufferRectangle(rect, framebuffer->GetWidth(), framebuffer->GetHeight());
|
|
|
|
}
|
|
|
|
|
|
|
|
MathUtil::Rectangle<int> Renderer::ConvertFramebufferRectangle(const MathUtil::Rectangle<int>& rect,
|
2019-08-05 02:45:25 +00:00
|
|
|
u32 fb_width, u32 fb_height) const
|
2019-02-15 01:59:50 +00:00
|
|
|
{
|
|
|
|
MathUtil::Rectangle<int> ret = rect;
|
|
|
|
if (g_ActiveConfig.backend_info.bUsesLowerLeftOrigin)
|
|
|
|
{
|
|
|
|
ret.top = fb_height - rect.bottom;
|
|
|
|
ret.bottom = fb_height - rect.top;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-08-05 02:45:25 +00:00
|
|
|
MathUtil::Rectangle<int> Renderer::ConvertEFBRectangle(const MathUtil::Rectangle<int>& rc) const
|
2019-02-15 01:59:50 +00:00
|
|
|
{
|
2019-04-15 14:47:46 +00:00
|
|
|
MathUtil::Rectangle<int> result;
|
2019-02-15 01:59:50 +00:00
|
|
|
result.left = EFBToScaledX(rc.left);
|
|
|
|
result.top = EFBToScaledY(rc.top);
|
|
|
|
result.right = EFBToScaledX(rc.right);
|
|
|
|
result.bottom = EFBToScaledY(rc.bottom);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-04-08 23:40:04 +00:00
|
|
|
std::tuple<float, float> Renderer::ScaleToDisplayAspectRatio(const int width,
|
|
|
|
const int height) const
|
2017-01-23 18:33:26 +00:00
|
|
|
{
|
|
|
|
// Scale either the width or height depending the content aspect ratio.
|
|
|
|
// This way we preserve as much resolution as possible when scaling.
|
2017-03-03 01:51:31 +00:00
|
|
|
float scaled_width = static_cast<float>(width);
|
|
|
|
float scaled_height = static_cast<float>(height);
|
|
|
|
const float draw_aspect = CalculateDrawAspectRatio();
|
|
|
|
if (scaled_width / scaled_height >= draw_aspect)
|
|
|
|
scaled_height = scaled_width / draw_aspect;
|
|
|
|
else
|
|
|
|
scaled_width = scaled_height * draw_aspect;
|
|
|
|
return std::make_tuple(scaled_width, scaled_height);
|
2017-01-23 18:33:26 +00:00
|
|
|
}
|
|
|
|
|
2016-11-10 13:31:44 +00:00
|
|
|
void Renderer::UpdateDrawRectangle()
|
2010-11-18 03:50:50 +00:00
|
|
|
{
|
2020-01-26 01:04:50 +00:00
|
|
|
const float draw_aspect_ratio = CalculateDrawAspectRatio();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2012-09-28 22:04:55 +00:00
|
|
|
// Update aspect ratio hack values
|
|
|
|
// Won't take effect until next frame
|
|
|
|
// Don't know if there is a better place for this code so there isn't a 1 frame delay
|
2015-02-15 19:43:31 +00:00
|
|
|
if (g_ActiveConfig.bWidescreenHack)
|
2010-11-18 03:50:50 +00:00
|
|
|
{
|
2016-01-08 00:31:48 +00:00
|
|
|
float source_aspect = VideoInterface::GetAspectRatio();
|
2020-01-26 01:04:50 +00:00
|
|
|
if (m_is_game_widescreen)
|
2016-01-08 00:31:48 +00:00
|
|
|
source_aspect = AspectToWidescreen(source_aspect);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
const float adjust = source_aspect / draw_aspect_ratio;
|
2015-02-15 19:43:31 +00:00
|
|
|
if (adjust > 1)
|
2012-09-28 22:04:55 +00:00
|
|
|
{
|
|
|
|
// Vert+
|
|
|
|
g_Config.fAspectRatioHackW = 1;
|
2015-02-15 19:43:31 +00:00
|
|
|
g_Config.fAspectRatioHackH = 1 / adjust;
|
2012-09-28 22:04:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Hor+
|
|
|
|
g_Config.fAspectRatioHackW = adjust;
|
|
|
|
g_Config.fAspectRatioHackH = 1;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2012-09-28 22:04:55 +00:00
|
|
|
}
|
2010-11-18 03:50:50 +00:00
|
|
|
else
|
|
|
|
{
|
2020-01-26 01:04:50 +00:00
|
|
|
// Hack is disabled.
|
2012-09-28 22:04:55 +00:00
|
|
|
g_Config.fAspectRatioHackW = 1;
|
|
|
|
g_Config.fAspectRatioHackH = 1;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
// The rendering window size
|
|
|
|
const float win_width = static_cast<float>(m_backbuffer_width);
|
|
|
|
const float win_height = static_cast<float>(m_backbuffer_height);
|
2020-01-24 06:06:39 +00:00
|
|
|
|
|
|
|
// Make ControllerInterface aware of the render window region actually being used
|
|
|
|
// to adjust mouse cursor inputs.
|
|
|
|
g_controller_interface.SetAspectRatioAdjustment(draw_aspect_ratio / (win_width / win_height));
|
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
float draw_width = draw_aspect_ratio;
|
|
|
|
float draw_height = 1;
|
2017-03-03 01:51:31 +00:00
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
// Crop the picture to a standard aspect ratio. (if enabled)
|
|
|
|
auto [crop_width, crop_height] = ApplyStandardAspectCrop(draw_width, draw_height);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-03-03 01:51:31 +00:00
|
|
|
// scale the picture to fit the rendering window
|
|
|
|
if (win_width / win_height >= crop_width / crop_height)
|
2012-09-28 22:04:55 +00:00
|
|
|
{
|
2017-03-03 01:51:31 +00:00
|
|
|
// the window is flatter than the picture
|
|
|
|
draw_width *= win_height / crop_height;
|
|
|
|
crop_width *= win_height / crop_height;
|
|
|
|
draw_height *= win_height / crop_height;
|
|
|
|
crop_height = win_height;
|
2012-09-28 22:04:55 +00:00
|
|
|
}
|
2017-03-03 01:51:31 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// the window is skinnier than the picture
|
|
|
|
draw_width *= win_width / crop_width;
|
|
|
|
draw_height *= win_width / crop_width;
|
|
|
|
crop_height *= win_width / crop_width;
|
|
|
|
crop_width = win_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ensure divisibility by 4 to make it compatible with all the video encoders
|
|
|
|
draw_width = std::ceil(draw_width) - static_cast<int>(std::ceil(draw_width)) % 4;
|
|
|
|
draw_height = std::ceil(draw_height) - static_cast<int>(std::ceil(draw_height)) % 4;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-03-03 01:51:31 +00:00
|
|
|
m_target_rectangle.left = static_cast<int>(std::round(win_width / 2.0 - draw_width / 2.0));
|
|
|
|
m_target_rectangle.top = static_cast<int>(std::round(win_height / 2.0 - draw_height / 2.0));
|
|
|
|
m_target_rectangle.right = m_target_rectangle.left + static_cast<int>(draw_width);
|
|
|
|
m_target_rectangle.bottom = m_target_rectangle.top + static_cast<int>(draw_height);
|
2010-11-18 03:50:50 +00:00
|
|
|
}
|
|
|
|
|
2013-01-16 20:46:11 +00:00
|
|
|
void Renderer::SetWindowSize(int width, int height)
|
2011-03-15 23:09:12 +00:00
|
|
|
{
|
2019-08-05 02:57:12 +00:00
|
|
|
const auto [out_width, out_height] = CalculateOutputDimensions(width, height);
|
2017-08-29 05:24:25 +00:00
|
|
|
|
|
|
|
// Track the last values of width/height to avoid sending a window resize event every frame.
|
2019-08-05 02:57:12 +00:00
|
|
|
if (out_width == m_last_window_request_width && out_height == m_last_window_request_height)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_last_window_request_width = out_width;
|
|
|
|
m_last_window_request_height = out_height;
|
|
|
|
Host_RequestRenderWindowSize(out_width, out_height);
|
2017-08-29 05:24:25 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
// Crop to exactly 16:9 or 4:3 if enabled and not AspectMode::Stretch.
|
|
|
|
std::tuple<float, float> Renderer::ApplyStandardAspectCrop(float width, float height) const
|
|
|
|
{
|
|
|
|
const auto aspect_mode = g_ActiveConfig.aspect_mode;
|
|
|
|
|
|
|
|
if (!g_ActiveConfig.bCrop || aspect_mode == AspectMode::Stretch)
|
|
|
|
return {width, height};
|
|
|
|
|
|
|
|
// Force 4:3 or 16:9 by cropping the image.
|
|
|
|
const float current_aspect = width / height;
|
|
|
|
const float expected_aspect = (aspect_mode == AspectMode::AnalogWide ||
|
|
|
|
(aspect_mode == AspectMode::Auto && m_is_game_widescreen)) ?
|
|
|
|
(16.0f / 9.0f) :
|
|
|
|
(4.0f / 3.0f);
|
|
|
|
if (current_aspect > expected_aspect)
|
|
|
|
{
|
|
|
|
// keep height, crop width
|
|
|
|
width = height * expected_aspect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// keep width, crop height
|
|
|
|
height = width / expected_aspect;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {width, height};
|
|
|
|
}
|
|
|
|
|
2019-08-05 02:45:25 +00:00
|
|
|
std::tuple<int, int> Renderer::CalculateOutputDimensions(int width, int height) const
|
2017-08-29 05:24:25 +00:00
|
|
|
{
|
|
|
|
width = std::max(width, 1);
|
|
|
|
height = std::max(height, 1);
|
|
|
|
|
2019-08-05 02:57:12 +00:00
|
|
|
auto [scaled_width, scaled_height] = ScaleToDisplayAspectRatio(width, height);
|
2017-01-23 22:13:54 +00:00
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
// Apply crop if enabled.
|
|
|
|
std::tie(scaled_width, scaled_height) = ApplyStandardAspectCrop(scaled_width, scaled_height);
|
2017-01-23 22:13:54 +00:00
|
|
|
|
|
|
|
width = static_cast<int>(std::ceil(scaled_width));
|
|
|
|
height = static_cast<int>(std::ceil(scaled_height));
|
|
|
|
|
|
|
|
// UpdateDrawRectangle() makes sure that the rendered image is divisible by four for video
|
|
|
|
// encoders, so do that here too to match it
|
|
|
|
width -= width % 4;
|
|
|
|
height -= height % 4;
|
|
|
|
|
2017-08-29 05:24:25 +00:00
|
|
|
return std::make_tuple(width, height);
|
2011-03-15 23:09:12 +00:00
|
|
|
}
|
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
void Renderer::CheckFifoRecording()
|
|
|
|
{
|
2019-12-05 13:11:52 +00:00
|
|
|
const bool was_recording = OpcodeDecoder::g_record_fifo_data;
|
|
|
|
OpcodeDecoder::g_record_fifo_data = FifoRecorder::GetInstance().IsRecording();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-12-05 13:11:52 +00:00
|
|
|
if (!OpcodeDecoder::g_record_fifo_data)
|
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-12-05 13:11:52 +00:00
|
|
|
if (!was_recording)
|
|
|
|
{
|
|
|
|
RecordVideoMemory();
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
2019-12-05 13:11:52 +00:00
|
|
|
|
|
|
|
FifoRecorder::GetInstance().EndFrame(CommandProcessor::fifo.CPBase, CommandProcessor::fifo.CPEnd);
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::RecordVideoMemory()
|
|
|
|
{
|
2016-08-01 21:37:57 +00:00
|
|
|
const u32* bpmem_ptr = reinterpret_cast<const u32*>(&bpmem);
|
|
|
|
u32 cpmem[256] = {};
|
2014-05-17 01:40:06 +00:00
|
|
|
// The FIFO recording format splits XF memory into xfmem and xfregs; follow
|
|
|
|
// that split here.
|
2016-08-01 21:37:57 +00:00
|
|
|
const u32* xfmem_ptr = reinterpret_cast<const u32*>(&xfmem);
|
|
|
|
const u32* xfregs_ptr = reinterpret_cast<const u32*>(&xfmem) + FifoDataFile::XF_MEM_SIZE;
|
2014-05-17 01:40:06 +00:00
|
|
|
u32 xfregs_size = sizeof(XFMemory) / 4 - FifoDataFile::XF_MEM_SIZE;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-17 01:40:06 +00:00
|
|
|
FillCPMemoryArray(cpmem);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-01-03 07:31:16 +00:00
|
|
|
FifoRecorder::GetInstance().SetVideoMemory(bpmem_ptr, cpmem, xfmem_ptr, xfregs_ptr, xfregs_size,
|
|
|
|
texMem);
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
2018-10-09 13:57:52 +00:00
|
|
|
bool Renderer::InitializeImGui()
|
|
|
|
{
|
|
|
|
if (!ImGui::CreateContext())
|
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
PanicAlertFmt("Creating ImGui context failed");
|
2018-10-09 13:57:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't create an ini file. TODO: Do we want this in the future?
|
|
|
|
ImGui::GetIO().IniFilename = nullptr;
|
2019-01-18 14:35:33 +00:00
|
|
|
ImGui::GetIO().DisplayFramebufferScale.x = m_backbuffer_scale;
|
|
|
|
ImGui::GetIO().DisplayFramebufferScale.y = m_backbuffer_scale;
|
|
|
|
ImGui::GetIO().FontGlobalScale = m_backbuffer_scale;
|
|
|
|
ImGui::GetStyle().ScaleAllSizes(m_backbuffer_scale);
|
2018-10-09 13:57:52 +00:00
|
|
|
|
|
|
|
PortableVertexDeclaration vdecl = {};
|
|
|
|
vdecl.position = {VAR_FLOAT, 2, offsetof(ImDrawVert, pos), true, false};
|
|
|
|
vdecl.texcoords[0] = {VAR_FLOAT, 2, offsetof(ImDrawVert, uv), true, false};
|
|
|
|
vdecl.colors[0] = {VAR_UNSIGNED_BYTE, 4, offsetof(ImDrawVert, col), true, false};
|
|
|
|
vdecl.stride = sizeof(ImDrawVert);
|
2019-02-15 01:59:50 +00:00
|
|
|
m_imgui_vertex_format = CreateNativeVertexFormat(vdecl);
|
2018-10-09 13:57:52 +00:00
|
|
|
if (!m_imgui_vertex_format)
|
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
PanicAlertFmt("Failed to create imgui vertex format");
|
2018-10-09 13:57:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-02 02:19:47 +00:00
|
|
|
// Font texture(s).
|
|
|
|
{
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
|
u8* font_tex_pixels;
|
|
|
|
int font_tex_width, font_tex_height;
|
|
|
|
io.Fonts->GetTexDataAsRGBA32(&font_tex_pixels, &font_tex_width, &font_tex_height);
|
|
|
|
|
|
|
|
TextureConfig font_tex_config(font_tex_width, font_tex_height, 1, 1, 1,
|
|
|
|
AbstractTextureFormat::RGBA8, 0);
|
|
|
|
std::unique_ptr<AbstractTexture> font_tex = CreateTexture(font_tex_config);
|
|
|
|
if (!font_tex)
|
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
PanicAlertFmt("Failed to create imgui texture");
|
2019-10-02 02:19:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
font_tex->Load(0, font_tex_width, font_tex_height, font_tex_width, font_tex_pixels,
|
|
|
|
sizeof(u32) * font_tex_width * font_tex_height);
|
|
|
|
|
|
|
|
io.Fonts->TexID = font_tex.get();
|
|
|
|
|
|
|
|
m_imgui_textures.push_back(std::move(font_tex));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!RecompileImGuiPipeline())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_imgui_last_frame_time = Common::Timer::GetTimeUs();
|
|
|
|
BeginImGuiFrame();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Renderer::RecompileImGuiPipeline()
|
|
|
|
{
|
2019-10-02 02:52:45 +00:00
|
|
|
std::unique_ptr<AbstractShader> vertex_shader = CreateShaderFromSource(
|
|
|
|
ShaderStage::Vertex, FramebufferShaderGen::GenerateImGuiVertexShader());
|
2019-05-30 07:07:40 +00:00
|
|
|
std::unique_ptr<AbstractShader> pixel_shader =
|
2019-10-02 02:52:45 +00:00
|
|
|
CreateShaderFromSource(ShaderStage::Pixel, FramebufferShaderGen::GenerateImGuiPixelShader());
|
2018-10-09 13:57:52 +00:00
|
|
|
if (!vertex_shader || !pixel_shader)
|
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
PanicAlertFmt("Failed to compile imgui shaders");
|
2018-10-09 13:57:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-02 02:19:47 +00:00
|
|
|
// GS is used to render the UI to both eyes in stereo modes.
|
|
|
|
std::unique_ptr<AbstractShader> geometry_shader;
|
|
|
|
if (UseGeometryShaderForUI())
|
|
|
|
{
|
|
|
|
geometry_shader = CreateShaderFromSource(
|
|
|
|
ShaderStage::Geometry, FramebufferShaderGen::GeneratePassthroughGeometryShader(1, 1));
|
|
|
|
if (!geometry_shader)
|
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
PanicAlertFmt("Failed to compile imgui geometry shader");
|
2019-10-02 02:19:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-09 13:57:52 +00:00
|
|
|
AbstractPipelineConfig pconfig = {};
|
|
|
|
pconfig.vertex_format = m_imgui_vertex_format.get();
|
|
|
|
pconfig.vertex_shader = vertex_shader.get();
|
2019-10-02 02:19:47 +00:00
|
|
|
pconfig.geometry_shader = geometry_shader.get();
|
2018-10-09 13:57:52 +00:00
|
|
|
pconfig.pixel_shader = pixel_shader.get();
|
2019-03-21 12:15:43 +00:00
|
|
|
pconfig.rasterization_state = RenderState::GetNoCullRasterizationState(PrimitiveType::Triangles);
|
2019-02-15 01:59:50 +00:00
|
|
|
pconfig.depth_state = RenderState::GetNoDepthTestingDepthState();
|
|
|
|
pconfig.blending_state = RenderState::GetNoBlendingBlendState();
|
2018-10-09 13:57:52 +00:00
|
|
|
pconfig.blending_state.blendenable = true;
|
|
|
|
pconfig.blending_state.srcfactor = BlendMode::SRCALPHA;
|
|
|
|
pconfig.blending_state.dstfactor = BlendMode::INVSRCALPHA;
|
|
|
|
pconfig.blending_state.srcfactoralpha = BlendMode::ZERO;
|
|
|
|
pconfig.blending_state.dstfactoralpha = BlendMode::ONE;
|
|
|
|
pconfig.framebuffer_state.color_texture_format = m_backbuffer_format;
|
|
|
|
pconfig.framebuffer_state.depth_texture_format = AbstractTextureFormat::Undefined;
|
|
|
|
pconfig.framebuffer_state.samples = 1;
|
|
|
|
pconfig.framebuffer_state.per_sample_shading = false;
|
|
|
|
pconfig.usage = AbstractPipelineUsage::Utility;
|
2019-08-05 03:01:16 +00:00
|
|
|
m_imgui_pipeline = CreatePipeline(pconfig);
|
2018-10-09 13:57:52 +00:00
|
|
|
if (!m_imgui_pipeline)
|
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
PanicAlertFmt("Failed to create imgui pipeline");
|
2018-10-09 13:57:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::ShutdownImGui()
|
|
|
|
{
|
|
|
|
ImGui::EndFrame();
|
|
|
|
ImGui::DestroyContext();
|
|
|
|
m_imgui_pipeline.reset();
|
|
|
|
m_imgui_vertex_format.reset();
|
|
|
|
m_imgui_textures.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::BeginImGuiFrame()
|
|
|
|
{
|
2018-11-28 04:30:47 +00:00
|
|
|
std::unique_lock<std::mutex> imgui_lock(m_imgui_mutex);
|
|
|
|
|
2018-10-09 13:57:52 +00:00
|
|
|
const u64 current_time_us = Common::Timer::GetTimeUs();
|
|
|
|
const u64 time_diff_us = current_time_us - m_imgui_last_frame_time;
|
|
|
|
const float time_diff_secs = static_cast<float>(time_diff_us / 1000000.0);
|
|
|
|
m_imgui_last_frame_time = current_time_us;
|
|
|
|
|
|
|
|
// Update I/O with window dimensions.
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
|
io.DisplaySize =
|
|
|
|
ImVec2(static_cast<float>(m_backbuffer_width), static_cast<float>(m_backbuffer_height));
|
|
|
|
io.DeltaTime = time_diff_secs;
|
|
|
|
|
|
|
|
ImGui::NewFrame();
|
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
void Renderer::DrawImGui()
|
2018-10-09 13:57:52 +00:00
|
|
|
{
|
|
|
|
ImDrawData* draw_data = ImGui::GetDrawData();
|
|
|
|
if (!draw_data)
|
|
|
|
return;
|
|
|
|
|
2018-11-28 04:30:47 +00:00
|
|
|
SetViewport(0.0f, 0.0f, static_cast<float>(m_backbuffer_width),
|
|
|
|
static_cast<float>(m_backbuffer_height), 0.0f, 1.0f);
|
|
|
|
|
2018-10-09 13:57:52 +00:00
|
|
|
// Uniform buffer for draws.
|
|
|
|
struct ImGuiUbo
|
|
|
|
{
|
|
|
|
float u_rcp_viewport_size_mul2[2];
|
|
|
|
float padding[2];
|
|
|
|
};
|
|
|
|
ImGuiUbo ubo = {{1.0f / m_backbuffer_width * 2.0f, 1.0f / m_backbuffer_height * 2.0f}};
|
|
|
|
|
|
|
|
// Set up common state for drawing.
|
2018-11-28 04:30:47 +00:00
|
|
|
SetPipeline(m_imgui_pipeline.get());
|
2018-10-09 13:57:52 +00:00
|
|
|
SetSamplerState(0, RenderState::GetPointSamplerState());
|
2018-11-28 04:30:47 +00:00
|
|
|
g_vertex_manager->UploadUtilityUniforms(&ubo, sizeof(ubo));
|
2018-10-09 13:57:52 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < draw_data->CmdListsCount; i++)
|
|
|
|
{
|
|
|
|
const ImDrawList* cmdlist = draw_data->CmdLists[i];
|
|
|
|
if (cmdlist->VtxBuffer.empty() || cmdlist->IdxBuffer.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
u32 base_vertex, base_index;
|
|
|
|
g_vertex_manager->UploadUtilityVertices(cmdlist->VtxBuffer.Data, sizeof(ImDrawVert),
|
|
|
|
cmdlist->VtxBuffer.Size, cmdlist->IdxBuffer.Data,
|
|
|
|
cmdlist->IdxBuffer.Size, &base_vertex, &base_index);
|
|
|
|
|
|
|
|
for (const ImDrawCmd& cmd : cmdlist->CmdBuffer)
|
|
|
|
{
|
|
|
|
if (cmd.UserCallback)
|
|
|
|
{
|
|
|
|
cmd.UserCallback(cmdlist, &cmd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
SetScissorRect(ConvertFramebufferRectangle(
|
|
|
|
MathUtil::Rectangle<int>(
|
|
|
|
static_cast<int>(cmd.ClipRect.x), static_cast<int>(cmd.ClipRect.y),
|
|
|
|
static_cast<int>(cmd.ClipRect.z), static_cast<int>(cmd.ClipRect.w)),
|
|
|
|
m_current_framebuffer));
|
2018-10-09 13:57:52 +00:00
|
|
|
SetTexture(0, reinterpret_cast<const AbstractTexture*>(cmd.TextureId));
|
|
|
|
DrawIndexed(base_index, cmd.ElemCount, base_vertex);
|
|
|
|
base_index += cmd.ElemCount;
|
|
|
|
}
|
|
|
|
}
|
2019-06-15 11:05:57 +00:00
|
|
|
|
|
|
|
// Some capture software (such as OBS) hooks SwapBuffers and uses glBlitFramebuffer to copy our
|
|
|
|
// back buffer just before swap. Because glBlitFramebuffer honors the scissor test, the capture
|
|
|
|
// itself will be clipped to whatever bounds were last set by ImGui, resulting in a rather useless
|
|
|
|
// capture whenever any ImGui windows are open. We'll reset the scissor rectangle to the entire
|
|
|
|
// viewport here to avoid this problem.
|
|
|
|
SetScissorRect(ConvertFramebufferRectangle(
|
|
|
|
MathUtil::Rectangle<int>(0, 0, m_backbuffer_width, m_backbuffer_height),
|
|
|
|
m_current_framebuffer));
|
2018-10-09 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2019-10-02 02:19:47 +00:00
|
|
|
bool Renderer::UseGeometryShaderForUI() const
|
|
|
|
{
|
|
|
|
// OpenGL doesn't render to a 2-layer backbuffer like D3D/Vulkan for quad-buffered stereo,
|
|
|
|
// instead drawing twice and the eye selected by glDrawBuffer() (see
|
|
|
|
// OGL::Renderer::RenderXFBToScreen).
|
|
|
|
return g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer &&
|
|
|
|
g_ActiveConfig.backend_info.api_type != APIType::OpenGL;
|
|
|
|
}
|
|
|
|
|
2018-10-10 11:41:52 +00:00
|
|
|
std::unique_lock<std::mutex> Renderer::GetImGuiLock()
|
|
|
|
{
|
|
|
|
return std::unique_lock<std::mutex>(m_imgui_mutex);
|
|
|
|
}
|
|
|
|
|
2018-11-28 04:30:47 +00:00
|
|
|
void Renderer::BeginUIFrame()
|
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
if (IsHeadless())
|
|
|
|
return;
|
|
|
|
|
|
|
|
BeginUtilityDrawing();
|
2018-11-28 04:30:47 +00:00
|
|
|
BindBackbuffer({0.0f, 0.0f, 0.0f, 1.0f});
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::EndUIFrame()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto lock = GetImGuiLock();
|
2019-02-15 01:59:50 +00:00
|
|
|
ImGui::Render();
|
2018-11-28 04:30:47 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
if (!IsHeadless())
|
2018-11-28 04:30:47 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
DrawImGui();
|
|
|
|
|
2018-11-28 04:30:47 +00:00
|
|
|
std::lock_guard<std::mutex> guard(m_swap_mutex);
|
|
|
|
PresentBackbuffer();
|
2019-02-15 01:59:50 +00:00
|
|
|
EndUtilityDrawing();
|
2018-11-28 04:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BeginImGuiFrame();
|
|
|
|
}
|
|
|
|
|
2019-08-17 19:40:58 +00:00
|
|
|
void Renderer::ForceReloadTextures()
|
|
|
|
{
|
|
|
|
m_force_reload_textures.Set();
|
|
|
|
}
|
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
// Heuristic to detect if a GameCube game is in 16:9 anamorphic widescreen mode.
|
|
|
|
void Renderer::UpdateWidescreenHeuristic()
|
2014-02-05 10:48:45 +00:00
|
|
|
{
|
2020-01-26 01:04:50 +00:00
|
|
|
// VertexManager maintains no statistics in Wii mode.
|
|
|
|
if (SConfig::GetInstance().bWii)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const auto flush_statistics = g_vertex_manager->ResetFlushAspectRatioCount();
|
|
|
|
|
|
|
|
// If suggested_aspect_mode (GameINI) is configured don't use heuristic.
|
|
|
|
if (g_ActiveConfig.suggested_aspect_mode != AspectMode::Auto)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If widescreen hack isn't active and aspect_mode (UI) is 4:3 or 16:9 don't use heuristic.
|
|
|
|
if (!g_ActiveConfig.bWidescreenHack && (g_ActiveConfig.aspect_mode == AspectMode::Analog ||
|
|
|
|
g_ActiveConfig.aspect_mode == AspectMode::AnalogWide))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Modify the threshold based on which aspect ratio we're already using:
|
|
|
|
// If the game's in 4:3, it probably won't switch to anamorphic, and vice-versa.
|
|
|
|
static constexpr u32 TRANSITION_THRESHOLD = 3;
|
|
|
|
|
|
|
|
const auto looks_normal = [](auto& counts) {
|
|
|
|
return counts.normal_vertex_count > counts.anamorphic_vertex_count * TRANSITION_THRESHOLD;
|
|
|
|
};
|
|
|
|
const auto looks_anamorphic = [](auto& counts) {
|
|
|
|
return counts.anamorphic_vertex_count > counts.normal_vertex_count * TRANSITION_THRESHOLD;
|
|
|
|
};
|
|
|
|
|
2020-01-31 21:14:19 +00:00
|
|
|
const auto& persp = flush_statistics.perspective;
|
|
|
|
const auto& ortho = flush_statistics.orthographic;
|
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
const auto ortho_looks_anamorphic = looks_anamorphic(ortho);
|
|
|
|
|
|
|
|
if (looks_anamorphic(persp) || ortho_looks_anamorphic)
|
2017-03-03 22:36:51 +00:00
|
|
|
{
|
2020-01-26 01:04:50 +00:00
|
|
|
// If either perspective or orthographic projections look anamorphic, it's a safe bet.
|
|
|
|
m_is_game_widescreen = true;
|
2018-11-07 18:00:24 +00:00
|
|
|
}
|
2020-01-26 01:04:50 +00:00
|
|
|
else if (looks_normal(persp) || (m_was_orthographically_anamorphic && looks_normal(ortho)))
|
2018-11-07 18:00:24 +00:00
|
|
|
{
|
2020-01-26 01:04:50 +00:00
|
|
|
// Many widescreen games (or AR/GeckoCodes) use anamorphic perspective projections
|
|
|
|
// with NON-anamorphic orthographic projections.
|
|
|
|
// This can cause incorrect changes to 4:3 when perspective projections are temporarily not
|
|
|
|
// shown. e.g. Animal Crossing's inventory menu.
|
2020-12-31 10:59:54 +00:00
|
|
|
// Unless we were in a situation which was orthographically anamorphic
|
2020-01-26 01:04:50 +00:00
|
|
|
// we won't consider orthographic data for changes from 16:9 to 4:3.
|
|
|
|
m_is_game_widescreen = false;
|
2018-11-07 18:00:24 +00:00
|
|
|
}
|
2017-03-03 22:36:51 +00:00
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
m_was_orthographically_anamorphic = ortho_looks_anamorphic;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks)
|
|
|
|
{
|
|
|
|
if (SConfig::GetInstance().bWii)
|
|
|
|
m_is_game_widescreen = Config::Get(Config::SYSCONF_WIDESCREEN);
|
|
|
|
|
|
|
|
// suggested_aspect_mode overrides SYSCONF_WIDESCREEN
|
|
|
|
if (g_ActiveConfig.suggested_aspect_mode == AspectMode::Analog)
|
|
|
|
m_is_game_widescreen = false;
|
|
|
|
else if (g_ActiveConfig.suggested_aspect_mode == AspectMode::AnalogWide)
|
|
|
|
m_is_game_widescreen = true;
|
|
|
|
|
|
|
|
// If widescreen hack is disabled override game's AR if UI is set to 4:3 or 16:9.
|
|
|
|
if (!g_ActiveConfig.bWidescreenHack)
|
|
|
|
{
|
|
|
|
const auto aspect_mode = g_ActiveConfig.aspect_mode;
|
|
|
|
if (aspect_mode == AspectMode::Analog)
|
|
|
|
m_is_game_widescreen = false;
|
|
|
|
else if (aspect_mode == AspectMode::AnalogWide)
|
|
|
|
m_is_game_widescreen = true;
|
2017-03-03 22:36:51 +00:00
|
|
|
}
|
|
|
|
|
2017-11-19 07:33:53 +00:00
|
|
|
// Ensure the last frame was written to the dump.
|
|
|
|
// This is required even if frame dumping has stopped, since the frame dump is one frame
|
|
|
|
// behind the renderer.
|
|
|
|
FlushFrameDump();
|
2017-05-31 04:44:03 +00:00
|
|
|
|
2019-03-31 04:11:53 +00:00
|
|
|
if (xfb_addr && fb_width && fb_stride && fb_height)
|
2017-05-29 22:02:09 +00:00
|
|
|
{
|
|
|
|
// Get the current XFB from texture cache
|
2019-03-31 04:11:53 +00:00
|
|
|
MathUtil::Rectangle<int> xfb_rect;
|
|
|
|
const auto* xfb_entry =
|
|
|
|
g_texture_cache->GetXFBTexture(xfb_addr, fb_width, fb_height, fb_stride, &xfb_rect);
|
2020-01-14 00:57:35 +00:00
|
|
|
if (xfb_entry &&
|
|
|
|
(!g_ActiveConfig.bSkipPresentingDuplicateXFBs || xfb_entry->id != m_last_xfb_id))
|
2017-07-03 02:24:20 +00:00
|
|
|
{
|
2020-01-14 00:57:35 +00:00
|
|
|
const bool is_duplicate_frame = xfb_entry->id == m_last_xfb_id;
|
2017-08-20 19:24:37 +00:00
|
|
|
m_last_xfb_id = xfb_entry->id;
|
2017-05-29 22:02:09 +00:00
|
|
|
|
2018-01-20 15:32:20 +00:00
|
|
|
// Since we use the common pipelines here and draw vertices if a batch is currently being
|
|
|
|
// built by the vertex loader, we end up trampling over its pointer, as we share the buffer
|
|
|
|
// with the loader, and it has not been unmapped yet. Force a pipeline flush to avoid this.
|
|
|
|
g_vertex_manager->Flush();
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
// Render any UI elements to the draw list.
|
2018-11-28 04:30:47 +00:00
|
|
|
{
|
|
|
|
auto lock = GetImGuiLock();
|
|
|
|
|
|
|
|
DrawDebugText();
|
|
|
|
OSD::DrawMessages();
|
2019-02-15 01:59:50 +00:00
|
|
|
ImGui::Render();
|
2018-11-28 04:30:47 +00:00
|
|
|
}
|
2018-10-09 13:57:52 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
// Render the XFB to the screen.
|
|
|
|
BeginUtilityDrawing();
|
|
|
|
if (!IsHeadless())
|
2018-01-26 06:23:24 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
BindBackbuffer({{0.0f, 0.0f, 0.0f, 1.0f}});
|
2020-01-26 01:04:50 +00:00
|
|
|
|
|
|
|
if (!is_duplicate_frame)
|
|
|
|
UpdateWidescreenHeuristic();
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
UpdateDrawRectangle();
|
2019-04-28 07:00:18 +00:00
|
|
|
|
|
|
|
// Adjust the source rectangle instead of using an oversized viewport to render the XFB.
|
|
|
|
auto render_target_rc = GetTargetRectangle();
|
|
|
|
auto render_source_rc = xfb_rect;
|
2019-06-18 22:33:44 +00:00
|
|
|
AdjustRectanglesToFitBounds(&render_target_rc, &render_source_rc, m_backbuffer_width,
|
2019-04-28 07:00:18 +00:00
|
|
|
m_backbuffer_height);
|
|
|
|
RenderXFBToScreen(render_target_rc, xfb_entry->texture.get(), render_source_rc);
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
DrawImGui();
|
|
|
|
|
|
|
|
// Present to the window system.
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(m_swap_mutex);
|
|
|
|
PresentBackbuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the window size based on the frame that was just rendered.
|
|
|
|
// Due to depending on guest state, we need to call this every frame.
|
2019-03-31 04:11:53 +00:00
|
|
|
SetWindowSize(xfb_rect.GetWidth(), xfb_rect.GetHeight());
|
2018-01-26 06:23:24 +00:00
|
|
|
}
|
2017-08-05 05:40:17 +00:00
|
|
|
|
2020-01-14 00:57:35 +00:00
|
|
|
if (!is_duplicate_frame)
|
|
|
|
{
|
|
|
|
m_fps_counter.Update();
|
|
|
|
|
|
|
|
DolphinAnalytics::PerformanceSample perf_sample;
|
|
|
|
perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance();
|
|
|
|
perf_sample.num_prims = g_stats.this_frame.num_prims + g_stats.this_frame.num_dl_prims;
|
|
|
|
perf_sample.num_draw_calls = g_stats.this_frame.num_draw_calls;
|
|
|
|
DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample));
|
2017-11-19 07:33:53 +00:00
|
|
|
|
2020-01-14 00:57:35 +00:00
|
|
|
if (IsFrameDumping())
|
2020-11-21 21:25:57 +00:00
|
|
|
DumpCurrentFrame(xfb_entry->texture.get(), xfb_rect, ticks, m_frame_count);
|
2018-10-27 03:11:20 +00:00
|
|
|
|
2020-01-14 00:57:35 +00:00
|
|
|
// Begin new frame
|
|
|
|
m_frame_count++;
|
|
|
|
g_stats.ResetFrame();
|
|
|
|
}
|
2017-12-15 18:46:18 +00:00
|
|
|
|
2018-02-24 15:15:35 +00:00
|
|
|
g_shader_cache->RetrieveAsyncShaders();
|
2019-02-15 01:59:50 +00:00
|
|
|
g_vertex_manager->OnEndFrame();
|
2018-11-28 04:30:47 +00:00
|
|
|
BeginImGuiFrame();
|
2018-02-24 15:15:35 +00:00
|
|
|
|
|
|
|
// We invalidate the pipeline object at the start of the frame.
|
|
|
|
// This is for the rare case where only a single pipeline configuration is used,
|
|
|
|
// and hybrid ubershaders have compiled the specialized shader, but without any
|
|
|
|
// state changes the specialized shader will not take over.
|
|
|
|
g_vertex_manager->InvalidatePipelineObject();
|
2017-12-15 18:46:18 +00:00
|
|
|
|
2019-08-17 19:40:58 +00:00
|
|
|
if (m_force_reload_textures.TestAndClear())
|
|
|
|
{
|
|
|
|
g_texture_cache->ForceReload();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Flush any outstanding EFB copies to RAM, in case the game is running at an uncapped frame
|
|
|
|
// rate and not waiting for vblank. Otherwise, we'd end up with a huge list of pending
|
|
|
|
// copies.
|
|
|
|
g_texture_cache->FlushEFBCopies();
|
|
|
|
}
|
2018-11-02 14:17:00 +00:00
|
|
|
|
2020-01-14 00:57:35 +00:00
|
|
|
if (!is_duplicate_frame)
|
|
|
|
{
|
|
|
|
// Remove stale EFB/XFB copies.
|
|
|
|
g_texture_cache->Cleanup(m_frame_count);
|
2020-04-08 22:21:04 +00:00
|
|
|
Core::Callback_FramePresented();
|
2020-01-14 00:57:35 +00:00
|
|
|
}
|
2018-11-28 04:30:47 +00:00
|
|
|
|
2020-12-31 10:59:54 +00:00
|
|
|
// Handle any config changes, this gets propagated to the backend.
|
2018-11-28 04:30:47 +00:00
|
|
|
CheckForConfigChanges();
|
|
|
|
g_Config.iSaveTargetId = 0;
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
EndUtilityDrawing();
|
2017-07-03 02:24:20 +00:00
|
|
|
}
|
2019-01-08 10:28:59 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Flush();
|
|
|
|
}
|
2017-08-13 00:51:33 +00:00
|
|
|
|
|
|
|
// Update our last xfb values
|
2019-06-29 09:27:53 +00:00
|
|
|
m_last_xfb_addr = xfb_addr;
|
|
|
|
m_last_xfb_ticks = ticks;
|
|
|
|
m_last_xfb_width = fb_width;
|
|
|
|
m_last_xfb_stride = fb_stride;
|
|
|
|
m_last_xfb_height = fb_height;
|
2017-05-29 22:02:09 +00:00
|
|
|
}
|
2019-01-08 10:28:59 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Flush();
|
|
|
|
}
|
2014-02-05 10:48:45 +00:00
|
|
|
}
|
2015-05-01 16:58:11 +00:00
|
|
|
|
2019-04-28 07:00:18 +00:00
|
|
|
void Renderer::RenderXFBToScreen(const MathUtil::Rectangle<int>& target_rc,
|
|
|
|
const AbstractTexture* source_texture,
|
|
|
|
const MathUtil::Rectangle<int>& source_rc)
|
2019-02-15 01:59:50 +00:00
|
|
|
{
|
|
|
|
if (g_ActiveConfig.stereo_mode == StereoMode::SBS ||
|
|
|
|
g_ActiveConfig.stereo_mode == StereoMode::TAB)
|
|
|
|
{
|
2019-08-05 02:57:12 +00:00
|
|
|
const auto [left_rc, right_rc] = ConvertStereoRectangle(target_rc);
|
2019-02-15 01:59:50 +00:00
|
|
|
|
2019-04-28 07:00:18 +00:00
|
|
|
m_post_processor->BlitFromTexture(left_rc, source_rc, source_texture, 0);
|
|
|
|
m_post_processor->BlitFromTexture(right_rc, source_rc, source_texture, 1);
|
2019-02-15 01:59:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-28 07:00:18 +00:00
|
|
|
m_post_processor->BlitFromTexture(target_rc, source_rc, source_texture, 0);
|
2019-02-15 01:59:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-05 02:45:25 +00:00
|
|
|
bool Renderer::IsFrameDumping() const
|
2016-10-07 18:31:51 +00:00
|
|
|
{
|
2017-03-04 06:42:21 +00:00
|
|
|
if (m_screenshot_request.IsSet())
|
2016-10-08 16:23:57 +00:00
|
|
|
return true;
|
|
|
|
|
2016-10-07 18:31:51 +00:00
|
|
|
if (SConfig::GetInstance().m_DumpFrames)
|
|
|
|
return true;
|
2016-10-08 01:11:37 +00:00
|
|
|
|
2016-10-07 18:31:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-03-31 04:11:53 +00:00
|
|
|
void Renderer::DumpCurrentFrame(const AbstractTexture* src_texture,
|
2020-11-21 21:25:57 +00:00
|
|
|
const MathUtil::Rectangle<int>& src_rect, u64 ticks,
|
|
|
|
int frame_number)
|
2017-08-29 05:24:25 +00:00
|
|
|
{
|
2019-03-31 04:11:53 +00:00
|
|
|
int source_width = src_rect.GetWidth();
|
|
|
|
int source_height = src_rect.GetHeight();
|
2017-08-29 05:24:25 +00:00
|
|
|
int target_width, target_height;
|
2017-11-23 06:53:44 +00:00
|
|
|
if (!g_ActiveConfig.bInternalResolutionFrameDumps && !IsHeadless())
|
2017-11-19 09:20:45 +00:00
|
|
|
{
|
|
|
|
auto target_rect = GetTargetRectangle();
|
|
|
|
target_width = target_rect.GetWidth();
|
|
|
|
target_height = target_rect.GetHeight();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-31 04:11:53 +00:00
|
|
|
std::tie(target_width, target_height) = CalculateOutputDimensions(source_width, source_height);
|
2017-11-19 09:20:45 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
// We only need to render a copy if we need to stretch/scale the XFB copy.
|
2019-03-31 04:11:53 +00:00
|
|
|
MathUtil::Rectangle<int> copy_rect = src_rect;
|
|
|
|
if (source_width != target_width || source_height != target_height)
|
2017-11-19 07:33:53 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
if (!CheckFrameDumpRenderTexture(target_width, target_height))
|
|
|
|
return;
|
|
|
|
|
2019-03-31 04:11:53 +00:00
|
|
|
ScaleTexture(m_frame_dump_render_framebuffer.get(), m_frame_dump_render_framebuffer->GetRect(),
|
|
|
|
src_texture, src_rect);
|
|
|
|
src_texture = m_frame_dump_render_texture.get();
|
|
|
|
copy_rect = src_texture->GetRect();
|
2017-11-19 07:33:53 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
if (!CheckFrameDumpReadbackTexture(target_width, target_height))
|
|
|
|
return;
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
m_frame_dump_readback_texture->CopyFromTexture(src_texture, copy_rect, 0, 0,
|
|
|
|
m_frame_dump_readback_texture->GetRect());
|
2020-11-21 21:25:57 +00:00
|
|
|
m_last_frame_state = m_frame_dump.FetchState(ticks, frame_number);
|
2020-10-21 14:37:16 +00:00
|
|
|
m_frame_dump_needs_flush = true;
|
2019-02-15 01:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Renderer::CheckFrameDumpRenderTexture(u32 target_width, u32 target_height)
|
|
|
|
{
|
|
|
|
// Ensure framebuffer exists (we lazily allocate it in case frame dumping isn't used).
|
|
|
|
// Or, resize texture if it isn't large enough to accommodate the current frame.
|
|
|
|
if (m_frame_dump_render_texture && m_frame_dump_render_texture->GetWidth() == target_width &&
|
|
|
|
m_frame_dump_render_texture->GetHeight() == target_height)
|
2017-11-19 07:33:53 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
return true;
|
2017-11-19 07:33:53 +00:00
|
|
|
}
|
2019-02-15 01:59:50 +00:00
|
|
|
|
|
|
|
// Recreate texture, but release before creating so we don't temporarily use twice the RAM.
|
|
|
|
m_frame_dump_render_framebuffer.reset();
|
|
|
|
m_frame_dump_render_texture.reset();
|
|
|
|
m_frame_dump_render_texture =
|
|
|
|
CreateTexture(TextureConfig(target_width, target_height, 1, 1, 1,
|
|
|
|
AbstractTextureFormat::RGBA8, AbstractTextureFlag_RenderTarget));
|
|
|
|
if (!m_frame_dump_render_texture)
|
2017-11-19 07:33:53 +00:00
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
PanicAlertFmt("Failed to allocate frame dump render texture");
|
2019-02-15 01:59:50 +00:00
|
|
|
return false;
|
2017-11-19 07:33:53 +00:00
|
|
|
}
|
2019-02-15 01:59:50 +00:00
|
|
|
m_frame_dump_render_framebuffer = CreateFramebuffer(m_frame_dump_render_texture.get(), nullptr);
|
|
|
|
ASSERT(m_frame_dump_render_framebuffer);
|
|
|
|
return true;
|
2017-11-19 07:33:53 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
bool Renderer::CheckFrameDumpReadbackTexture(u32 target_width, u32 target_height)
|
2017-11-19 07:33:53 +00:00
|
|
|
{
|
2020-10-21 14:37:16 +00:00
|
|
|
std::unique_ptr<AbstractStagingTexture>& rbtex = m_frame_dump_readback_texture;
|
2019-02-15 01:59:50 +00:00
|
|
|
if (rbtex && rbtex->GetWidth() == target_width && rbtex->GetHeight() == target_height)
|
|
|
|
return true;
|
2017-11-19 07:33:53 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
rbtex.reset();
|
|
|
|
rbtex = CreateStagingTexture(
|
|
|
|
StagingTextureType::Readback,
|
|
|
|
TextureConfig(target_width, target_height, 1, 1, 1, AbstractTextureFormat::RGBA8, 0));
|
|
|
|
if (!rbtex)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2017-11-19 07:33:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Renderer::FlushFrameDump()
|
|
|
|
{
|
2020-10-21 14:37:16 +00:00
|
|
|
if (!m_frame_dump_needs_flush)
|
2017-11-19 07:33:53 +00:00
|
|
|
return;
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
// Ensure dumping thread is done with output texture before swapping.
|
2017-11-19 07:33:53 +00:00
|
|
|
FinishFrameData();
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
std::swap(m_frame_dump_output_texture, m_frame_dump_readback_texture);
|
|
|
|
|
2017-11-19 07:33:53 +00:00
|
|
|
// Queue encoding of the last frame dumped.
|
2020-10-21 14:37:16 +00:00
|
|
|
auto& output = m_frame_dump_output_texture;
|
|
|
|
output->Flush();
|
|
|
|
if (output->Map())
|
|
|
|
{
|
|
|
|
DumpFrameData(reinterpret_cast<u8*>(output->GetMappedPointer()), output->GetConfig().width,
|
|
|
|
output->GetConfig().height, static_cast<int>(output->GetMappedStride()));
|
|
|
|
}
|
|
|
|
else
|
2017-08-29 05:24:25 +00:00
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
ERROR_LOG_FMT(VIDEO, "Failed to map texture for dumping.");
|
2017-08-29 05:24:25 +00:00
|
|
|
}
|
2017-11-19 07:33:53 +00:00
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
m_frame_dump_needs_flush = false;
|
2017-11-19 07:33:53 +00:00
|
|
|
|
|
|
|
// Shutdown frame dumping if it is no longer active.
|
|
|
|
if (!IsFrameDumping())
|
|
|
|
ShutdownFrameDumping();
|
2017-08-29 05:24:25 +00:00
|
|
|
}
|
|
|
|
|
2016-10-08 01:11:37 +00:00
|
|
|
void Renderer::ShutdownFrameDumping()
|
|
|
|
{
|
2017-11-19 07:33:53 +00:00
|
|
|
// Ensure the last queued readback has been sent to the encoder.
|
|
|
|
FlushFrameDump();
|
|
|
|
|
2016-10-08 01:11:37 +00:00
|
|
|
if (!m_frame_dump_thread_running.IsSet())
|
|
|
|
return;
|
|
|
|
|
2017-11-19 07:33:53 +00:00
|
|
|
// Ensure previous frame has been encoded.
|
2016-10-08 01:11:37 +00:00
|
|
|
FinishFrameData();
|
2017-11-19 07:33:53 +00:00
|
|
|
|
|
|
|
// Wake thread up, and wait for it to exit.
|
2016-10-08 01:11:37 +00:00
|
|
|
m_frame_dump_thread_running.Clear();
|
|
|
|
m_frame_dump_start.Set();
|
2017-11-19 07:33:53 +00:00
|
|
|
if (m_frame_dump_thread.joinable())
|
|
|
|
m_frame_dump_thread.join();
|
2019-02-15 01:59:50 +00:00
|
|
|
m_frame_dump_render_framebuffer.reset();
|
2018-01-26 02:12:00 +00:00
|
|
|
m_frame_dump_render_texture.reset();
|
2020-10-21 14:37:16 +00:00
|
|
|
|
|
|
|
m_frame_dump_readback_texture.reset();
|
|
|
|
m_frame_dump_output_texture.reset();
|
2016-10-08 01:11:37 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
void Renderer::DumpFrameData(const u8* data, int w, int h, int stride)
|
2016-10-07 18:31:51 +00:00
|
|
|
{
|
2020-10-21 14:37:16 +00:00
|
|
|
m_frame_dump_data = FrameDump::FrameData{data, w, h, stride, m_last_frame_state};
|
2016-10-08 16:23:57 +00:00
|
|
|
|
2016-10-08 01:11:37 +00:00
|
|
|
if (!m_frame_dump_thread_running.IsSet())
|
2016-10-08 16:23:57 +00:00
|
|
|
{
|
2016-10-08 01:11:37 +00:00
|
|
|
if (m_frame_dump_thread.joinable())
|
|
|
|
m_frame_dump_thread.join();
|
|
|
|
m_frame_dump_thread_running.Set();
|
2020-10-21 14:37:16 +00:00
|
|
|
m_frame_dump_thread = std::thread(&Renderer::FrameDumpThreadFunc, this);
|
2016-10-08 01:11:37 +00:00
|
|
|
}
|
2016-10-08 16:23:57 +00:00
|
|
|
|
2017-11-19 07:33:53 +00:00
|
|
|
// Wake worker thread up.
|
2016-10-08 01:11:37 +00:00
|
|
|
m_frame_dump_start.Set();
|
|
|
|
m_frame_dump_frame_running = true;
|
|
|
|
}
|
2016-10-08 16:23:57 +00:00
|
|
|
|
2016-10-08 01:11:37 +00:00
|
|
|
void Renderer::FinishFrameData()
|
|
|
|
{
|
|
|
|
if (!m_frame_dump_frame_running)
|
|
|
|
return;
|
2016-10-07 18:31:51 +00:00
|
|
|
|
2016-10-08 01:11:37 +00:00
|
|
|
m_frame_dump_done.Wait();
|
|
|
|
m_frame_dump_frame_running = false;
|
2020-10-21 14:37:16 +00:00
|
|
|
|
|
|
|
m_frame_dump_output_texture->Unmap();
|
2016-10-08 01:11:37 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
void Renderer::FrameDumpThreadFunc()
|
2016-10-08 01:11:37 +00:00
|
|
|
{
|
|
|
|
Common::SetCurrentThreadName("FrameDumping");
|
2020-10-21 14:37:16 +00:00
|
|
|
|
2019-03-18 04:50:53 +00:00
|
|
|
bool dump_to_ffmpeg = !g_ActiveConfig.bDumpFramesAsImages;
|
2016-11-18 12:57:08 +00:00
|
|
|
bool frame_dump_started = false;
|
|
|
|
|
2019-03-18 04:50:53 +00:00
|
|
|
// If Dolphin was compiled without ffmpeg, we only support dumping to images.
|
2017-05-22 19:27:10 +00:00
|
|
|
#if !defined(HAVE_FFMPEG)
|
2019-03-18 04:50:53 +00:00
|
|
|
if (dump_to_ffmpeg)
|
2016-11-18 12:57:08 +00:00
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
WARN_LOG_FMT(VIDEO, "FrameDump: Dolphin was not compiled with FFmpeg, using fallback option. "
|
|
|
|
"Frames will be saved as PNG images instead.");
|
2019-03-18 04:50:53 +00:00
|
|
|
dump_to_ffmpeg = false;
|
2016-11-18 12:57:08 +00:00
|
|
|
}
|
|
|
|
#endif
|
2016-10-08 01:11:37 +00:00
|
|
|
|
|
|
|
while (true)
|
2016-10-07 18:31:51 +00:00
|
|
|
{
|
2016-10-08 01:11:37 +00:00
|
|
|
m_frame_dump_start.Wait();
|
|
|
|
if (!m_frame_dump_thread_running.IsSet())
|
|
|
|
break;
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
auto frame = m_frame_dump_data;
|
2016-10-08 01:11:37 +00:00
|
|
|
|
|
|
|
// Save screenshot
|
2017-03-04 06:42:21 +00:00
|
|
|
if (m_screenshot_request.TestAndClear())
|
2016-10-07 18:31:51 +00:00
|
|
|
{
|
2017-03-04 06:42:21 +00:00
|
|
|
std::lock_guard<std::mutex> lk(m_screenshot_lock);
|
2016-10-08 01:11:37 +00:00
|
|
|
|
2020-12-16 14:34:50 +00:00
|
|
|
if (DumpFrameToPNG(frame, m_screenshot_name))
|
2017-03-04 06:42:21 +00:00
|
|
|
OSD::AddMessage("Screenshot saved to " + m_screenshot_name);
|
2016-10-08 01:11:37 +00:00
|
|
|
|
|
|
|
// Reset settings
|
2017-03-04 06:42:21 +00:00
|
|
|
m_screenshot_name.clear();
|
2017-03-04 06:42:35 +00:00
|
|
|
m_screenshot_completed.Set();
|
2016-10-07 18:31:51 +00:00
|
|
|
}
|
2016-10-08 01:11:37 +00:00
|
|
|
|
|
|
|
if (SConfig::GetInstance().m_DumpFrames)
|
2016-10-07 18:31:51 +00:00
|
|
|
{
|
2016-11-18 12:57:08 +00:00
|
|
|
if (!frame_dump_started)
|
2016-10-08 01:11:37 +00:00
|
|
|
{
|
2019-03-18 04:50:53 +00:00
|
|
|
if (dump_to_ffmpeg)
|
2020-10-21 14:37:16 +00:00
|
|
|
frame_dump_started = StartFrameDumpToFFMPEG(frame);
|
2016-10-08 01:11:37 +00:00
|
|
|
else
|
2020-10-21 14:37:16 +00:00
|
|
|
frame_dump_started = StartFrameDumpToImage(frame);
|
2016-11-18 12:57:08 +00:00
|
|
|
|
|
|
|
// Stop frame dumping if we fail to start.
|
|
|
|
if (!frame_dump_started)
|
2016-10-08 01:11:37 +00:00
|
|
|
SConfig::GetInstance().m_DumpFrames = false;
|
|
|
|
}
|
|
|
|
|
2016-11-18 12:57:08 +00:00
|
|
|
// If we failed to start frame dumping, don't write a frame.
|
|
|
|
if (frame_dump_started)
|
|
|
|
{
|
2019-03-18 04:50:53 +00:00
|
|
|
if (dump_to_ffmpeg)
|
2020-10-21 14:37:16 +00:00
|
|
|
DumpFrameToFFMPEG(frame);
|
2016-11-18 12:57:08 +00:00
|
|
|
else
|
2020-10-21 14:37:16 +00:00
|
|
|
DumpFrameToImage(frame);
|
2016-11-18 12:57:08 +00:00
|
|
|
}
|
2016-10-07 18:31:51 +00:00
|
|
|
}
|
2016-11-07 21:46:48 +00:00
|
|
|
|
|
|
|
m_frame_dump_done.Set();
|
2016-10-08 01:11:37 +00:00
|
|
|
}
|
2016-10-07 18:31:51 +00:00
|
|
|
|
2016-11-18 12:57:08 +00:00
|
|
|
if (frame_dump_started)
|
|
|
|
{
|
|
|
|
// No additional cleanup is needed when dumping to images.
|
2019-03-18 04:50:53 +00:00
|
|
|
if (dump_to_ffmpeg)
|
|
|
|
StopFrameDumpToFFMPEG();
|
2016-11-18 12:57:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-22 19:27:10 +00:00
|
|
|
#if defined(HAVE_FFMPEG)
|
2016-11-18 12:57:08 +00:00
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
bool Renderer::StartFrameDumpToFFMPEG(const FrameDump::FrameData& frame)
|
2016-11-18 12:57:08 +00:00
|
|
|
{
|
2020-11-21 21:25:57 +00:00
|
|
|
// If dumping started at boot, the start time must be set to the boot time to maintain audio sync.
|
|
|
|
// TODO: Perhaps we should care about this when starting dumping in the middle of emulation too,
|
|
|
|
// but it's less important there since the first frame to dump usually gets delivered quickly.
|
|
|
|
const u64 start_ticks = frame.state.frame_number == 0 ? 0 : frame.state.ticks;
|
|
|
|
return m_frame_dump.Start(frame.width, frame.height, start_ticks);
|
2016-11-18 12:57:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
void Renderer::DumpFrameToFFMPEG(const FrameDump::FrameData& frame)
|
2016-11-18 12:57:08 +00:00
|
|
|
{
|
2020-10-21 14:37:16 +00:00
|
|
|
m_frame_dump.AddFrame(frame);
|
2016-11-18 12:57:08 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 04:50:53 +00:00
|
|
|
void Renderer::StopFrameDumpToFFMPEG()
|
2016-11-18 12:57:08 +00:00
|
|
|
{
|
2020-10-21 14:37:16 +00:00
|
|
|
m_frame_dump.Stop();
|
2016-11-18 12:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
bool Renderer::StartFrameDumpToFFMPEG(const FrameDump::FrameData&)
|
2016-11-18 12:57:08 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
void Renderer::DumpFrameToFFMPEG(const FrameDump::FrameData&)
|
2016-11-18 12:57:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-03-18 04:50:53 +00:00
|
|
|
void Renderer::StopFrameDumpToFFMPEG()
|
2016-11-18 12:57:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-05-22 19:27:10 +00:00
|
|
|
#endif // defined(HAVE_FFMPEG)
|
2016-11-18 12:57:08 +00:00
|
|
|
|
|
|
|
std::string Renderer::GetFrameDumpNextImageFileName() const
|
|
|
|
{
|
2019-11-22 22:10:41 +00:00
|
|
|
return fmt::format("{}framedump_{}.png", File::GetUserPath(D_DUMPFRAMES_IDX),
|
|
|
|
m_frame_dump_image_counter);
|
2016-11-18 12:57:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
bool Renderer::StartFrameDumpToImage(const FrameDump::FrameData&)
|
2016-11-18 12:57:08 +00:00
|
|
|
{
|
|
|
|
m_frame_dump_image_counter = 1;
|
|
|
|
if (!SConfig::GetInstance().m_DumpFramesSilent)
|
2016-10-08 01:11:37 +00:00
|
|
|
{
|
2016-11-18 12:57:08 +00:00
|
|
|
// Only check for the presence of the first image to confirm overwriting.
|
|
|
|
// A previous run will always have at least one image, and it's safe to assume that if the user
|
|
|
|
// has allowed the first image to be overwritten, this will apply any remaining images as well.
|
|
|
|
std::string filename = GetFrameDumpNextImageFileName();
|
|
|
|
if (File::Exists(filename))
|
|
|
|
{
|
2020-11-20 18:53:53 +00:00
|
|
|
if (!AskYesNoFmtT("Frame dump image(s) '{0}' already exists. Overwrite?", filename))
|
2016-11-18 12:57:08 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-10-08 16:23:57 +00:00
|
|
|
}
|
2016-11-18 12:57:08 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-21 14:37:16 +00:00
|
|
|
void Renderer::DumpFrameToImage(const FrameDump::FrameData& frame)
|
2016-11-18 12:57:08 +00:00
|
|
|
{
|
2020-12-16 14:34:50 +00:00
|
|
|
DumpFrameToPNG(frame, GetFrameDumpNextImageFileName());
|
2016-11-18 12:57:08 +00:00
|
|
|
m_frame_dump_image_counter++;
|
2016-10-07 18:31:51 +00:00
|
|
|
}
|
2017-02-24 14:16:28 +00:00
|
|
|
|
|
|
|
bool Renderer::UseVertexDepthRange() const
|
|
|
|
{
|
|
|
|
// We can't compute the depth range in the vertex shader if we don't support depth clamp.
|
|
|
|
if (!g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
|
|
|
return false;
|
|
|
|
|
2017-03-14 00:02:13 +00:00
|
|
|
// We need a full depth range if a ztexture is used.
|
|
|
|
if (bpmem.ztex2.type != ZTEXTURE_DISABLE && !bpmem.zcontrol.early_ztest)
|
|
|
|
return true;
|
2017-02-24 14:16:28 +00:00
|
|
|
|
2017-03-14 00:02:13 +00:00
|
|
|
// If an inverted depth range is unsupported, we also need to check if the range is inverted.
|
|
|
|
if (!g_ActiveConfig.backend_info.bSupportsReversedDepthRange && xfmem.viewport.zRange < 0.0f)
|
|
|
|
return true;
|
2017-02-24 14:16:28 +00:00
|
|
|
|
2017-03-14 00:02:13 +00:00
|
|
|
// If an oversized depth range or a ztexture is used, we need to calculate the depth range
|
|
|
|
// in the vertex shader.
|
|
|
|
return fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f;
|
2017-02-24 14:16:28 +00:00
|
|
|
}
|
2018-02-25 07:56:09 +00:00
|
|
|
|
2019-06-29 09:27:53 +00:00
|
|
|
void Renderer::DoState(PointerWrap& p)
|
|
|
|
{
|
2020-01-26 01:04:50 +00:00
|
|
|
p.Do(m_is_game_widescreen);
|
2019-06-29 09:27:53 +00:00
|
|
|
p.Do(m_frame_count);
|
|
|
|
p.Do(m_prev_efb_format);
|
|
|
|
p.Do(m_last_xfb_ticks);
|
|
|
|
p.Do(m_last_xfb_addr);
|
|
|
|
p.Do(m_last_xfb_width);
|
|
|
|
p.Do(m_last_xfb_stride);
|
|
|
|
p.Do(m_last_xfb_height);
|
|
|
|
|
|
|
|
if (p.GetMode() == PointerWrap::MODE_READ)
|
|
|
|
{
|
|
|
|
// Force the next xfb to be displayed.
|
|
|
|
m_last_xfb_id = std::numeric_limits<u64>::max();
|
|
|
|
|
2020-01-26 01:04:50 +00:00
|
|
|
m_was_orthographically_anamorphic = false;
|
|
|
|
|
2019-06-29 09:27:53 +00:00
|
|
|
// And actually display it.
|
|
|
|
Swap(m_last_xfb_addr, m_last_xfb_width, m_last_xfb_stride, m_last_xfb_height, m_last_xfb_ticks);
|
|
|
|
}
|
2020-10-21 14:37:16 +00:00
|
|
|
|
|
|
|
#if defined(HAVE_FFMPEG)
|
|
|
|
m_frame_dump.DoState(p);
|
|
|
|
#endif
|
2019-06-29 09:27:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-25 07:56:09 +00:00
|
|
|
std::unique_ptr<VideoCommon::AsyncShaderCompiler> Renderer::CreateAsyncShaderCompiler()
|
|
|
|
{
|
|
|
|
return std::make_unique<VideoCommon::AsyncShaderCompiler>();
|
|
|
|
}
|