Skip to content

Commit

Permalink
Video: split frame dumping settings into 3 resolution dumping modes
Browse files Browse the repository at this point in the history
  • Loading branch information
Filoppi committed Feb 23, 2024
1 parent 750f2e9 commit 25bdb56
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Core/Config/GraphicsSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const Info<std::string> GFX_DUMP_PIXEL_FORMAT{{System::GFX, "Settings", "DumpPix
const Info<std::string> GFX_DUMP_ENCODER{{System::GFX, "Settings", "DumpEncoder"}, ""};
const Info<std::string> GFX_DUMP_PATH{{System::GFX, "Settings", "DumpPath"}, ""};
const Info<int> GFX_BITRATE_KBPS{{System::GFX, "Settings", "BitrateKbps"}, 25000};
const Info<bool> GFX_INTERNAL_RESOLUTION_FRAME_DUMPS{
{System::GFX, "Settings", "InternalResolutionFrameDumps"}, false};
const Info<FrameDumpResolutionType> GFX_FRAME_DUMPS_RESOLUTION_TYPE{
{System::GFX, "Settings", "FrameDumpsResolutionType"}, FrameDumpResolutionType::WINDOW_RESOLUTION};
const Info<int> GFX_PNG_COMPRESSION_LEVEL{{System::GFX, "Settings", "PNGCompressionLevel"}, 6};
const Info<bool> GFX_ENABLE_GPU_TEXTURE_DECODING{
{System::GFX, "Settings", "EnableGPUTextureDecoding"}, false};
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/Config/GraphicsSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum class TextureFilteringMode : int;
enum class OutputResamplingMode : int;
enum class ColorCorrectionRegion : int;
enum class TriState : int;
enum class FrameDumpResolutionType : int;

namespace Config
{
Expand Down Expand Up @@ -67,7 +68,7 @@ extern const Info<std::string> GFX_DUMP_PIXEL_FORMAT;
extern const Info<std::string> GFX_DUMP_ENCODER;
extern const Info<std::string> GFX_DUMP_PATH;
extern const Info<int> GFX_BITRATE_KBPS;
extern const Info<bool> GFX_INTERNAL_RESOLUTION_FRAME_DUMPS;
extern const Info<FrameDumpResolutionType> GFX_FRAME_DUMPS_RESOLUTION_TYPE;
extern const Info<int> GFX_PNG_COMPRESSION_LEVEL;
extern const Info<bool> GFX_ENABLE_GPU_TEXTURE_DECODING;
extern const Info<bool> GFX_ENABLE_PIXEL_LIGHTING;
Expand Down
26 changes: 18 additions & 8 deletions Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ void AdvancedWidget::CreateWidgets()
auto* dump_layout = new QGridLayout();
dump_box->setLayout(dump_layout);

m_use_fullres_framedumps = new ConfigBool(tr("Dump at Internal Resolution"),
Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS);
m_frame_dumps_resolution_type =
new ConfigChoice({tr("Window Resolution"), tr("Aspect Ratio Corrected Internal Resolution"),
tr("Raw Internal Resolution")},
Config::GFX_FRAME_DUMPS_RESOLUTION_TYPE);
m_dump_use_ffv1 = new ConfigBool(tr("Use Lossless Codec (FFV1)"), Config::GFX_USE_FFV1);
m_dump_bitrate = new ConfigInteger(0, 1000000, Config::GFX_BITRATE_KBPS, 1000);
m_png_compression_level = new ConfigInteger(0, 9, Config::GFX_PNG_COMPRESSION_LEVEL);

dump_layout->addWidget(m_use_fullres_framedumps, 0, 0);
dump_layout->addWidget(m_frame_dumps_resolution_type, 0, 0);
#if defined(HAVE_FFMPEG)
dump_layout->addWidget(m_dump_use_ffv1, 0, 1);
dump_layout->addWidget(new QLabel(tr("Bitrate (kbps):")), 1, 0);
Expand Down Expand Up @@ -338,10 +340,18 @@ void AdvancedWidget::AddDescriptions()
static const char TR_LOAD_GRAPHICS_MODS_DESCRIPTION[] =
QT_TR_NOOP("Loads graphics mods from User/Load/GraphicsMods/.<br><br><dolphin_emphasis>If "
"unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_INTERNAL_RESOLUTION_FRAME_DUMPING_DESCRIPTION[] = QT_TR_NOOP(
"Creates frame dumps and screenshots at the raw internal resolution of the renderer,"
"rather than using the size it is displayed within the window.<br><br>"
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_FRAME_DUMPS_RESOLUTION_TYPE_DESCRIPTION[] = QT_TR_NOOP(
"Selects how frame dumps and screenshots are going to be recorded.<br>"
"If the video resolution during a recording, multiple videos files will be created."
"<br><br><b>Window Resolution</b>: Uses the output window resolution (without black bars)."
"<br><b>Aspect Ratio Corrected Internal Resolution</b>: Uses the Internal Resolution (XFB "
"size), and corrects it by the target aspect ratio."
"<br><b>Raw Internal Resolution</b>: Uses the Internal Resolution (XFB size)"
" without corretting it with the target aspect ratio, "
"thus dumps will appear more crips.<br>This is "
"mostly meant to be used in case you need your videos to be in the highest quality possible,"
"without any post processing applied.<br><br>"
"<dolphin_emphasis>If unsure, leave this at \"Window Resolution\".</dolphin_emphasis>");
#if defined(HAVE_FFMPEG)
static const char TR_USE_FFV1_DESCRIPTION[] =
QT_TR_NOOP("Encodes frame dumps using the FFV1 codec.<br><br><dolphin_emphasis>If "
Expand Down Expand Up @@ -432,7 +442,7 @@ void AdvancedWidget::AddDescriptions()
m_dump_xfb_target->SetDescription(tr(TR_DUMP_XFB_DESCRIPTION));
m_disable_vram_copies->SetDescription(tr(TR_DISABLE_VRAM_COPIES_DESCRIPTION));
m_enable_graphics_mods->SetDescription(tr(TR_LOAD_GRAPHICS_MODS_DESCRIPTION));
m_use_fullres_framedumps->SetDescription(tr(TR_INTERNAL_RESOLUTION_FRAME_DUMPING_DESCRIPTION));
m_frame_dumps_resolution_type->SetDescription(tr(TR_FRAME_DUMPS_RESOLUTION_TYPE_DESCRIPTION));
#ifdef HAVE_FFMPEG
m_dump_use_ffv1->SetDescription(tr(TR_USE_FFV1_DESCRIPTION));
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AdvancedWidget final : public QWidget

// Frame dumping
ConfigBool* m_dump_use_ffv1;
ConfigBool* m_use_fullres_framedumps;
ConfigChoice* m_frame_dumps_resolution_type;
ConfigInteger* m_dump_bitrate;
ConfigInteger* m_png_compression_level;

Expand Down
34 changes: 31 additions & 3 deletions Source/Core/VideoCommon/Present.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,38 @@ void Presenter::ProcessFrameDumping(u64 ticks) const
if (g_frame_dumper->IsFrameDumping() && m_xfb_entry)
{
MathUtil::Rectangle<int> target_rect;
if (!g_ActiveConfig.bInternalResolutionFrameDumps && !g_gfx->IsHeadless())
target_rect = GetTargetRectangle();
else
switch (g_ActiveConfig.frame_dumps_resolution_type)
{
default:
case FrameDumpResolutionType::WINDOW_RESOLUTION:
{
if (!g_gfx->IsHeadless())
{
target_rect = GetTargetRectangle();
break;
}
[[fallthrough]];
}
case FrameDumpResolutionType::XFB_ASPECT_RATIO_CORRECTED_RESOLUTION:
{
target_rect = m_xfb_rect;
auto& vi = Core::System::GetInstance().GetVideoInterface();
const float source_aspect_ratio = vi.GetAspectRatio();
const float xfb_aspect_ratio = (float)m_xfb_rect.GetWidth() / (float)m_xfb_rect.GetHeight();
if (g_widescreen->IsGameWidescreen())
target_rect.right =
std::round(target_rect.right * SourceAspectRatioToWidescreen(source_aspect_ratio) /
xfb_aspect_ratio);
else
target_rect.right = std::round(target_rect.right * source_aspect_ratio / xfb_aspect_ratio);
break;
}
case FrameDumpResolutionType::XFB_RAW_RESOLUTION:
{
target_rect = m_xfb_rect;
break;
}
}

int width = target_rect.GetWidth();
int height = target_rect.GetHeight();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/VideoConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void VideoConfig::Refresh()
sDumpEncoder = Config::Get(Config::GFX_DUMP_ENCODER);
sDumpPath = Config::Get(Config::GFX_DUMP_PATH);
iBitrateKbps = Config::Get(Config::GFX_BITRATE_KBPS);
bInternalResolutionFrameDumps = Config::Get(Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS);
frame_dumps_resolution_type = Config::Get(Config::GFX_FRAME_DUMPS_RESOLUTION_TYPE);
bEnableGPUTextureDecoding = Config::Get(Config::GFX_ENABLE_GPU_TEXTURE_DECODING);
bPreferVSForLinePointExpansion = Config::Get(Config::GFX_PREFER_VS_FOR_LINE_POINT_EXPANSION);
bEnablePixelLighting = Config::Get(Config::GFX_ENABLE_PIXEL_LIGHTING);
Expand Down
13 changes: 12 additions & 1 deletion Source/Core/VideoCommon/VideoConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ enum class TriState : int
Auto
};

enum class FrameDumpResolutionType : int
{
// Window resolution (not including potential back buffer black borders),
// to avoid splitting the recording into multiple files
WINDOW_RESOLUTION,
// The aspect ratio corrected XFB resolution (XFB pixels might not have been square)
XFB_ASPECT_RATIO_CORRECTED_RESOLUTION,
// The raw unscaled XFB resolution (based on "internal resolution" scale)
XFB_RAW_RESOLUTION,
};

// Bitmask containing information about which configuration has changed for the backend.
enum ConfigChangeBits : u32
{
Expand Down Expand Up @@ -187,7 +198,7 @@ struct VideoConfig final
std::string sDumpEncoder;
std::string sDumpFormat;
std::string sDumpPath;
bool bInternalResolutionFrameDumps = false;
FrameDumpResolutionType frame_dumps_resolution_type = FrameDumpResolutionType::WINDOW_RESOLUTION;
bool bBorderlessFullscreen = false;
bool bEnableGPUTextureDecoding = false;
bool bPreferVSForLinePointExpansion = false;
Expand Down

0 comments on commit 25bdb56

Please sign in to comment.