Merge pull request #5498 from iwubcode/hybrid_xfb

Hybrid xfb
This commit is contained in:
Pierre Bourdon
2017-11-19 04:58:59 +01:00
committed by GitHub
329 changed files with 2602 additions and 3736 deletions

View File

@ -219,13 +219,13 @@ void DolphinAnalytics::MakePerGameBuilder()
builder.AddData("cfg-gfx-multisamples", g_Config.iMultisamples);
builder.AddData("cfg-gfx-ssaa", g_Config.bSSAA);
builder.AddData("cfg-gfx-anisotropy", g_Config.iMaxAnisotropy);
builder.AddData("cfg-gfx-realxfb", g_Config.RealXFBEnabled());
builder.AddData("cfg-gfx-virtualxfb", g_Config.VirtualXFBEnabled());
builder.AddData("cfg-gfx-vsync", g_Config.bVSync);
builder.AddData("cfg-gfx-aspect-ratio", g_Config.iAspectRatio);
builder.AddData("cfg-gfx-efb-access", g_Config.bEFBAccessEnable);
builder.AddData("cfg-gfx-efb-copy-format-changes", g_Config.bEFBEmulateFormatChanges);
builder.AddData("cfg-gfx-efb-copy-ram", !g_Config.bSkipEFBCopyToRam);
builder.AddData("cfg-gfx-xfb-copy-ram", !g_Config.bSkipXFBCopyToRam);
builder.AddData("cfg-gfx-immediate-xfb", !g_Config.bImmediateXFB);
builder.AddData("cfg-gfx-efb-copy-scaled", g_Config.bCopyEFBScaled);
builder.AddData("cfg-gfx-internal-resolution", g_Config.iEFBScale);
builder.AddData("cfg-gfx-tc-samples", g_Config.iSafeTextureCache_ColorSamples);

View File

@ -26,8 +26,6 @@ const ConfigInfo<int> GFX_ASPECT_RATIO{{System::GFX, "Settings", "AspectRatio"},
const ConfigInfo<int> GFX_SUGGESTED_ASPECT_RATIO{{System::GFX, "Settings", "SuggestedAspectRatio"},
static_cast<int>(ASPECT_AUTO)};
const ConfigInfo<bool> GFX_CROP{{System::GFX, "Settings", "Crop"}, false};
const ConfigInfo<bool> GFX_USE_XFB{{System::GFX, "Settings", "UseXFB"}, false};
const ConfigInfo<bool> GFX_USE_REAL_XFB{{System::GFX, "Settings", "UseRealXFB"}, false};
const ConfigInfo<int> GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES{
{System::GFX, "Settings", "SafeTextureCacheColorSamples"}, 128};
const ConfigInfo<bool> GFX_SHOW_FPS{{System::GFX, "Settings", "ShowFPS"}, false};
@ -45,6 +43,7 @@ const ConfigInfo<bool> GFX_CONVERT_HIRES_TEXTURES{{System::GFX, "Settings", "Con
const ConfigInfo<bool> GFX_CACHE_HIRES_TEXTURES{{System::GFX, "Settings", "CacheHiresTextures"},
false};
const ConfigInfo<bool> GFX_DUMP_EFB_TARGET{{System::GFX, "Settings", "DumpEFBTarget"}, false};
const ConfigInfo<bool> GFX_DUMP_XFB_TARGET{{System::GFX, "Settings", "DumpXFBTarget"}, false};
const ConfigInfo<bool> GFX_DUMP_FRAMES_AS_IMAGES{{System::GFX, "Settings", "DumpFramesAsImages"},
false};
const ConfigInfo<bool> GFX_FREE_LOOK{{System::GFX, "Settings", "FreeLook"}, false};
@ -132,6 +131,9 @@ const ConfigInfo<bool> GFX_HACK_BBOX_PREFER_STENCIL_IMPLEMENTATION{
const ConfigInfo<bool> GFX_HACK_FORCE_PROGRESSIVE{{System::GFX, "Hacks", "ForceProgressive"}, true};
const ConfigInfo<bool> GFX_HACK_SKIP_EFB_COPY_TO_RAM{{System::GFX, "Hacks", "EFBToTextureEnable"},
true};
const ConfigInfo<bool> GFX_HACK_SKIP_XFB_COPY_TO_RAM{{System::GFX, "Hacks", "XFBToTextureEnable"},
true};
const ConfigInfo<bool> GFX_HACK_IMMEDIATE_XFB{{System::GFX, "Hacks", "ImmediateXFBEnable"}, false};
const ConfigInfo<bool> GFX_HACK_COPY_EFB_ENABLED{{System::GFX, "Hacks", "EFBScaledCopy"}, true};
const ConfigInfo<bool> GFX_HACK_EFB_EMULATE_FORMAT_CHANGES{
{System::GFX, "Hacks", "EFBEmulateFormatChanges"}, false};

View File

@ -23,8 +23,6 @@ extern const ConfigInfo<bool> GFX_WIDESCREEN_HACK;
extern const ConfigInfo<int> GFX_ASPECT_RATIO;
extern const ConfigInfo<int> GFX_SUGGESTED_ASPECT_RATIO;
extern const ConfigInfo<bool> GFX_CROP;
extern const ConfigInfo<bool> GFX_USE_XFB;
extern const ConfigInfo<bool> GFX_USE_REAL_XFB;
extern const ConfigInfo<int> GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES;
extern const ConfigInfo<bool> GFX_SHOW_FPS;
extern const ConfigInfo<bool> GFX_SHOW_NETPLAY_PING;
@ -37,6 +35,7 @@ extern const ConfigInfo<bool> GFX_HIRES_TEXTURES;
extern const ConfigInfo<bool> GFX_CONVERT_HIRES_TEXTURES;
extern const ConfigInfo<bool> GFX_CACHE_HIRES_TEXTURES;
extern const ConfigInfo<bool> GFX_DUMP_EFB_TARGET;
extern const ConfigInfo<bool> GFX_DUMP_XFB_TARGET;
extern const ConfigInfo<bool> GFX_DUMP_FRAMES_AS_IMAGES;
extern const ConfigInfo<bool> GFX_FREE_LOOK;
extern const ConfigInfo<bool> GFX_USE_FFV1;
@ -100,6 +99,8 @@ extern const ConfigInfo<bool> GFX_HACK_BBOX_ENABLE;
extern const ConfigInfo<bool> GFX_HACK_BBOX_PREFER_STENCIL_IMPLEMENTATION;
extern const ConfigInfo<bool> GFX_HACK_FORCE_PROGRESSIVE;
extern const ConfigInfo<bool> GFX_HACK_SKIP_EFB_COPY_TO_RAM;
extern const ConfigInfo<bool> GFX_HACK_SKIP_XFB_COPY_TO_RAM;
extern const ConfigInfo<bool> GFX_HACK_IMMEDIATE_XFB;
extern const ConfigInfo<bool> GFX_HACK_COPY_EFB_ENABLED;
extern const ConfigInfo<bool> GFX_HACK_EFB_EMULATE_FORMAT_CHANGES;
extern const ConfigInfo<bool> GFX_HACK_VERTEX_ROUDING;

View File

@ -74,8 +74,6 @@ static const INIToLocationMap& GetINIToLocationMap()
{{"Video_Settings", "AspectRatio"}, {Config::GFX_ASPECT_RATIO.location}},
{{"Video_Settings", "SuggestedAspectRatio"}, {Config::GFX_SUGGESTED_ASPECT_RATIO.location}},
{{"Video_Settings", "Crop"}, {Config::GFX_CROP.location}},
{{"Video_Settings", "UseXFB"}, {Config::GFX_USE_XFB.location}},
{{"Video_Settings", "UseRealXFB"}, {Config::GFX_USE_REAL_XFB.location}},
{{"Video_Settings", "SafeTextureCacheColorSamples"},
{Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location}},
{{"Video_Settings", "HiresTextures"}, {Config::GFX_HIRES_TEXTURES.location}},
@ -109,6 +107,8 @@ static const INIToLocationMap& GetINIToLocationMap()
{{"Video_Hacks", "BBoxEnable"}, {Config::GFX_HACK_BBOX_ENABLE.location}},
{{"Video_Hacks", "ForceProgressive"}, {Config::GFX_HACK_FORCE_PROGRESSIVE.location}},
{{"Video_Hacks", "EFBToTextureEnable"}, {Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM.location}},
{{"Video_Hacks", "XFBToTextureEnable"}, {Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM.location}},
{{"Video_Hacks", "ImmediateXFBEnable"}, {Config::GFX_HACK_IMMEDIATE_XFB.location}},
{{"Video_Hacks", "EFBScaledCopy"}, {Config::GFX_EFB_SCALE.location}},
{{"Video_Hacks", "EFBEmulateFormatChanges"},
{Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES.location}},

View File

@ -28,17 +28,17 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
// Graphics.Settings
Config::GFX_WIDESCREEN_HACK.location, Config::GFX_ASPECT_RATIO.location,
Config::GFX_CROP.location, Config::GFX_USE_XFB.location, Config::GFX_USE_REAL_XFB.location,
Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location, Config::GFX_SHOW_FPS.location,
Config::GFX_SHOW_NETPLAY_PING.location, Config::GFX_SHOW_NETPLAY_MESSAGES.location,
Config::GFX_LOG_RENDER_TIME_TO_FILE.location, Config::GFX_OVERLAY_STATS.location,
Config::GFX_OVERLAY_PROJ_STATS.location, Config::GFX_DUMP_TEXTURES.location,
Config::GFX_HIRES_TEXTURES.location, Config::GFX_CONVERT_HIRES_TEXTURES.location,
Config::GFX_CACHE_HIRES_TEXTURES.location, Config::GFX_DUMP_EFB_TARGET.location,
Config::GFX_DUMP_FRAMES_AS_IMAGES.location, Config::GFX_FREE_LOOK.location,
Config::GFX_USE_FFV1.location, Config::GFX_DUMP_FORMAT.location,
Config::GFX_DUMP_CODEC.location, Config::GFX_DUMP_PATH.location,
Config::GFX_BITRATE_KBPS.location, Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS.location,
Config::GFX_CROP.location, Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location,
Config::GFX_SHOW_FPS.location, Config::GFX_SHOW_NETPLAY_PING.location,
Config::GFX_SHOW_NETPLAY_MESSAGES.location, Config::GFX_LOG_RENDER_TIME_TO_FILE.location,
Config::GFX_OVERLAY_STATS.location, Config::GFX_OVERLAY_PROJ_STATS.location,
Config::GFX_DUMP_TEXTURES.location, Config::GFX_HIRES_TEXTURES.location,
Config::GFX_CONVERT_HIRES_TEXTURES.location, Config::GFX_CACHE_HIRES_TEXTURES.location,
Config::GFX_DUMP_EFB_TARGET.location, Config::GFX_DUMP_FRAMES_AS_IMAGES.location,
Config::GFX_FREE_LOOK.location, Config::GFX_USE_FFV1.location,
Config::GFX_DUMP_FORMAT.location, Config::GFX_DUMP_CODEC.location,
Config::GFX_DUMP_PATH.location, Config::GFX_BITRATE_KBPS.location,
Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS.location,
Config::GFX_ENABLE_GPU_TEXTURE_DECODING.location, Config::GFX_ENABLE_PIXEL_LIGHTING.location,
Config::GFX_FAST_DEPTH_CALC.location, Config::GFX_MSAA.location, Config::GFX_SSAA.location,
Config::GFX_EFB_SCALE.location, Config::GFX_TEXFMT_OVERLAY_ENABLE.location,
@ -73,6 +73,7 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
Config::GFX_HACK_EFB_ACCESS_ENABLE.location, Config::GFX_HACK_BBOX_ENABLE.location,
Config::GFX_HACK_BBOX_PREFER_STENCIL_IMPLEMENTATION.location,
Config::GFX_HACK_FORCE_PROGRESSIVE.location, Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM.location,
Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM.location, Config::GFX_HACK_IMMEDIATE_XFB.location,
Config::GFX_HACK_COPY_EFB_ENABLED.location,
Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES.location,
Config::GFX_HACK_VERTEX_ROUDING.location,

View File

@ -39,10 +39,10 @@ static void LoadFromDTM(Config::Layer* config_layer, Movie::DTMHeader* dtm)
else
config_layer->Set(Config::MAIN_GC_LANGUAGE, static_cast<int>(dtm->language));
config_layer->Set(Config::GFX_USE_XFB, dtm->bUseXFB);
config_layer->Set(Config::GFX_USE_REAL_XFB, dtm->bUseRealXFB);
config_layer->Set(Config::GFX_HACK_EFB_ACCESS_ENABLE, dtm->bEFBAccessEnable);
config_layer->Set(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM, dtm->bSkipEFBCopyToRam);
config_layer->Set(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM, dtm->bSkipXFBCopyToRam);
config_layer->Set(Config::GFX_HACK_IMMEDIATE_XFB, dtm->bImmediateXFB);
config_layer->Set(Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES, dtm->bEFBEmulateFormatChanges);
}
@ -62,10 +62,10 @@ void SaveToDTM(Movie::DTMHeader* dtm)
else
dtm->language = Config::Get(Config::MAIN_GC_LANGUAGE);
dtm->bUseXFB = Config::Get(Config::GFX_USE_XFB);
dtm->bUseRealXFB = Config::Get(Config::GFX_USE_REAL_XFB);
dtm->bEFBAccessEnable = Config::Get(Config::GFX_HACK_EFB_ACCESS_ENABLE);
dtm->bSkipEFBCopyToRam = Config::Get(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM);
dtm->bSkipXFBCopyToRam = Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM);
dtm->bImmediateXFB = Config::Get(Config::GFX_HACK_IMMEDIATE_XFB);
dtm->bEFBEmulateFormatChanges = Config::Get(Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES);
// This never used the regular config

View File

@ -393,7 +393,7 @@ static void CpuThread()
s_is_started = false;
if (!_CoreParameter.bCPUThread)
g_video_backend->Video_Cleanup();
g_video_backend->Video_CleanupShared();
if (_CoreParameter.bFastmem)
EMM::UninstallExceptionHandler();
@ -445,7 +445,7 @@ static void FifoPlayerThread()
}
if (!_CoreParameter.bCPUThread)
g_video_backend->Video_Cleanup();
g_video_backend->Video_CleanupShared();
}
// Initialize and create emulation thread
@ -654,7 +654,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot)
INFO_LOG(CONSOLE, "%s", StopMessage(true, "CPU thread stopped.").c_str());
if (core_parameter.bCPUThread)
g_video_backend->Video_Cleanup();
g_video_backend->Video_CleanupShared();
// If we shut down normally, the stop message does not need to be triggered.
stop_message_guard.Dismiss();

View File

@ -72,6 +72,11 @@ FifoDataFile::FifoDataFile() = default;
FifoDataFile::~FifoDataFile() = default;
bool FifoDataFile::ShouldGenerateFakeVIUpdates() const
{
return true;
}
bool FifoDataFile::HasBrokenEFBCopies() const
{
return m_Version < 2;

View File

@ -60,6 +60,7 @@ public:
void SetIsWii(bool isWii);
bool GetIsWii() const;
bool HasBrokenEFBCopies() const;
bool ShouldGenerateFakeVIUpdates() const;
u32* GetBPMem() { return m_BPMem; }
u32* GetCPMem() { return m_CPMem; }

View File

@ -162,6 +162,16 @@ std::unique_ptr<CPUCoreBase> FifoPlayer::GetCPUCore()
return std::make_unique<CPUCore>(this);
}
bool FifoPlayer::IsRunningWithFakeVideoInterfaceUpdates() const
{
if (!m_File || m_File->GetFrameCount() == 0)
{
return false;
}
return m_File->ShouldGenerateFakeVIUpdates();
}
u32 FifoPlayer::GetFrameObjectCount() const
{
if (m_CurrentFrame < m_FrameInfo.size())

View File

@ -94,6 +94,8 @@ public:
void SetFrameWrittenCallback(CallbackFunc callback) { m_FrameWrittenCb = callback; }
static FifoPlayer& GetInstance();
bool IsRunningWithFakeVideoInterfaceUpdates() const;
private:
class CPUCore;

View File

@ -18,6 +18,7 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/FifoPlayer/FifoPlayer.h"
#include "Core/HW/MMIO.h"
#include "Core/HW/ProcessorInterface.h"
#include "Core/HW/SI/SI.h"
@ -549,8 +550,9 @@ float GetAspectRatio()
// 5. Calculate the final ratio and scale to 4:3
float ratio = horizontal_active_ratio / vertical_active_ratio;
if (std::isnormal(
ratio)) // Check we have a sane ratio and haven't propagated any infs/nans/zeros
bool running_fifo_log = FifoPlayer::GetInstance().IsRunningWithFakeVideoInterfaceUpdates();
if (std::isnormal(ratio) && // Check we have a sane ratio without any infs/nans/zeros
!running_fifo_log) // we don't know the correct ratio for fifos
return ratio * (4.0f / 3.0f); // Scale to 4:3
else
return (4.0f / 3.0f); // VI isn't initialized correctly, just return 4:3 instead
@ -775,4 +777,44 @@ void Update(u64 ticks)
UpdateInterrupts();
}
// Create a fake VI mode for a fifolog
void FakeVIUpdate(u32 xfb_address, u32 fb_width, u32 fb_height)
{
u32 fb_stride = fb_width;
bool interlaced = fb_height > 480 / 2;
if (interlaced)
{
fb_height = fb_height / 2;
fb_stride = fb_stride * 2;
}
m_XFBInfoTop.POFF = 1;
m_XFBInfoBottom.POFF = 1;
m_VerticalTimingRegister.ACV = fb_height;
m_VerticalTimingRegister.EQU = 6;
m_VBlankTimingOdd.PRB = 502 - fb_height * 2;
m_VBlankTimingOdd.PSB = 5;
m_VBlankTimingEven.PRB = 503 - fb_height * 2;
m_VBlankTimingEven.PSB = 4;
m_PictureConfiguration.WPL = fb_width / 16;
m_PictureConfiguration.STD = fb_stride / 16;
UpdateParameters();
u32 total_halflines = GetHalfLinesPerEvenField() + GetHalfLinesPerOddField();
if ((s_half_line_count - s_even_field_first_hl) % total_halflines <
(s_half_line_count - s_odd_field_first_hl) % total_halflines)
{
// Even/Bottom field is next.
m_XFBInfoBottom.FBB = interlaced ? (xfb_address + fb_width * 2) >> 5 : xfb_address >> 5;
}
else
{
// Odd/Top field is next
m_XFBInfoTop.FBB = (xfb_address >> 5);
}
}
} // namespace

View File

@ -373,4 +373,7 @@ u32 GetTicksPerField();
// result by 1.33333..
float GetAspectRatio();
// Create a fake VI mode for a fifolog
void FakeVIUpdate(u32 xfb_address, u32 fb_width, u32 fb_height);
} // namespace VideoInterface

View File

@ -72,6 +72,8 @@ const std::string hotkey_labels[] = {
_trans("Toggle Crop"),
_trans("Toggle Aspect Ratio"),
_trans("Toggle EFB Copies"),
_trans("Toggle XFB Copies"),
_trans("Toggle XFB Immediate Mode"),
_trans("Toggle Fog"),
_trans("Toggle Texture Dumping"),
_trans("Toggle Custom Textures"),

View File

@ -70,6 +70,8 @@ enum Hotkey
HK_TOGGLE_CROP,
HK_TOGGLE_AR,
HK_TOGGLE_EFBCOPIES,
HK_TOGGLE_XFBCOPIES,
HK_TOGGLE_IMMEDIATE_XFB,
HK_TOGGLE_FOG,
HK_TOGGLE_DUMPTEXTURES,
HK_TOGGLE_TEXTURES,

View File

@ -1367,9 +1367,9 @@ void SetGraphicsConfig()
{
g_Config.bEFBAccessEnable = tmpHeader.bEFBAccessEnable;
g_Config.bSkipEFBCopyToRam = tmpHeader.bSkipEFBCopyToRam;
g_Config.bSkipXFBCopyToRam = tmpHeader.bSkipXFBCopyToRam;
g_Config.bImmediateXFB = tmpHeader.bImmediateXFB;
g_Config.bEFBEmulateFormatChanges = tmpHeader.bEFBEmulateFormatChanges;
g_Config.bUseXFB = tmpHeader.bUseXFB;
g_Config.bUseRealXFB = tmpHeader.bUseRealXFB;
}
// NOTE: EmuThread / Host Thread

View File

@ -87,10 +87,10 @@ struct DTMHeader
bool bEFBAccessEnable;
bool bEFBCopyEnable;
bool bSkipEFBCopyToRam;
bool bSkipXFBCopyToRam;
bool bImmediateXFB;
bool bEFBCopyCacheEnable;
bool bEFBEmulateFormatChanges;
bool bUseXFB;
bool bUseRealXFB;
u8 memcards; // Memcards inserted (from least to most significant, the bits are slot A and B)
bool bClearSave; // Create a new memory card when playing back a movie if true
u8 bongos; // Bongos plugged in (from least to most significant, the bits are ports 1-4)