Merge pull request #1667 from LukeUsher/remove-host-backbuffer-hack

Remove 'Render to Host Backbuffer' hack
This commit is contained in:
RadWolfie 2019-07-16 13:05:10 -05:00 committed by GitHub
commit e2cceb695a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 18 additions and 64 deletions

View File

@ -628,7 +628,6 @@ BEGIN
POPUP "Speed Hacks", 65535,MFT_STRING,MFS_ENABLED
BEGIN
MENUITEM "Run Xbox threads on all cores", ID_HACKS_RUNXBOXTHREADSONALLCORES,MFT_STRING,MFS_ENABLED
MENUITEM "Render directly to Host Backbuffer", ID_HACKS_RENDERDIRECTLYTOHOSTBACKBUFFER,MFT_STRING,MFS_ENABLED
END
MENUITEM "Disable Pixel Shaders", ID_HACKS_DISABLEPIXELSHADERS,MFT_STRING,MFS_ENABLED
MENUITEM "Skip rdtsc patching", ID_HACKS_SKIPRDTSCPATCHING,MFT_STRING,MFS_ENABLED

View File

@ -126,7 +126,6 @@ static struct {
const char* DisablePixelShaders = "DisablePixelShaders";
const char* UseAllCores = "UseAllCores";
const char* SkipRdtscPatching = "SkipRdtscPatching";
const char* DirectHostBackBufferAccess = "DirectHostBackBufferAccess";
} sect_hack_keys;
std::string GenerateExecDirectoryStr()
@ -382,7 +381,6 @@ bool Settings::LoadConfig()
m_hacks.DisablePixelShaders = m_si.GetBoolValue(section_hack, sect_hack_keys.DisablePixelShaders, /*Default=*/false);
m_hacks.UseAllCores = m_si.GetBoolValue(section_hack, sect_hack_keys.UseAllCores, /*Default=*/false);
m_hacks.SkipRdtscPatching = m_si.GetBoolValue(section_hack, sect_hack_keys.SkipRdtscPatching, /*Default=*/false);
m_hacks.DirectHostBackBufferAccess = m_si.GetBoolValue(section_hack, sect_hack_keys.DirectHostBackBufferAccess, /*Default=*/false);
// ==== Hack End ============
@ -644,7 +642,6 @@ bool Settings::Save(std::string file_path)
m_si.SetBoolValue(section_hack, sect_hack_keys.DisablePixelShaders, m_hacks.DisablePixelShaders, nullptr, true);
m_si.SetBoolValue(section_hack, sect_hack_keys.UseAllCores, m_hacks.UseAllCores, nullptr, true);
m_si.SetBoolValue(section_hack, sect_hack_keys.SkipRdtscPatching, m_hacks.SkipRdtscPatching, nullptr, true);
m_si.SetBoolValue(section_hack, sect_hack_keys.DirectHostBackBufferAccess, m_hacks.DirectHostBackBufferAccess, nullptr, true);
// ==== Hack End ============

View File

@ -219,7 +219,7 @@ public:
bool UseAllCores;
bool SkipRdtscPatching;
bool Reserved3;
bool DirectHostBackBufferAccess;
bool Reserved4;
bool Reserved7 = 0;
bool Reserved8 = 0;
int Reserved99[8] = { 0 };

View File

@ -147,8 +147,6 @@ class EmuShared : public Mutex
void SetUseAllCores(const int* value) { Lock(); m_hacks.UseAllCores = *value; Unlock(); }
void GetSkipRdtscPatching(int* value) { Lock(); *value = m_hacks.SkipRdtscPatching; Unlock(); }
void SetSkipRdtscPatching(const int* value) { Lock(); m_hacks.SkipRdtscPatching = *value; Unlock(); }
void GetDirectHostBackBufferAccess(int* value) { Lock(); *value = m_hacks.DirectHostBackBufferAccess; Unlock(); }
void SetDirectHostBackBufferAccess(const int* value) { Lock(); m_hacks.DirectHostBackBufferAccess = *value; Unlock(); }
// ******************************************************************
// * FPS/Benchmark values Accessors

View File

@ -1925,9 +1925,8 @@ static DWORD WINAPI EmuCreateDeviceProxy(LPVOID)
}
if (g_EmuCDPD.bCreate) {
// HACK: Disable higher resolution when the host backbuffer hack is enabled
// This is to preserve existing hack behavior
g_RenderScaleFactor = g_DirectHostBackBufferAccess ? 1 : g_XBVideo.renderScaleFactor;
// Apply render scale factor for high-resolution rendering
g_RenderScaleFactor = g_XBVideo.renderScaleFactor;
if(g_EmuCDPD.XboxPresentationParameters.BufferSurfaces[0] != NULL)
EmuLog(LOG_LEVEL::WARNING, "BufferSurfaces[0] : 0x%.08X", g_EmuCDPD.XboxPresentationParameters.BufferSurfaces[0]);
@ -3226,9 +3225,7 @@ void ValidateRenderTargetDimensions(DWORD HostRenderTarget_Width, DWORD HostRend
if (HostRenderTarget_Width_Unscaled != XboxRenderTarget_Width || HostRenderTarget_Height_Unscaled != XboxRenderTarget_Height) {
LOG_TEST_CASE("Existing RenderTarget width/height changed");
// NOTE: If the host backbuffer hack is enabled, we must skip this operation, otherwise everything will break
// In that situation, there's nothing we can do without causing damage.
if (!g_DirectHostBackBufferAccess && g_pXboxRenderTarget == g_XboxBackBufferSurface) {
if (g_pXboxRenderTarget == g_XboxBackBufferSurface) {
FreeHostResource(GetHostResourceKey(g_pXboxRenderTarget)); g_pD3DDevice->SetRenderTarget(0, GetHostSurface(g_pXboxRenderTarget, D3DUSAGE_RENDERTARGET));
FreeHostResource(GetHostResourceKey(g_pXboxDepthStencil)); g_pD3DDevice->SetDepthStencilSurface(GetHostSurface(g_pXboxDepthStencil, D3DUSAGE_DEPTHSTENCIL));
}
@ -4551,22 +4548,20 @@ DWORD WINAPI XTL::EMUPATCH(D3DDevice_Swap)
const D3DTEXTUREFILTERTYPE LoadSurfaceFilter = D3DTEXF_LINEAR;
const DWORD LoadOverlayFilter = D3DX_DEFAULT;
if (!g_DirectHostBackBufferAccess) {
auto pXboxBackBufferHostSurface = GetHostSurface(g_XboxBackBufferSurface, D3DUSAGE_RENDERTARGET);
if (pXboxBackBufferHostSurface) {
// Blit Xbox BackBuffer to host BackBuffer
// TODO: Respect aspect ratio
hRet = g_pD3DDevice->StretchRect(
/* pSourceSurface = */ pXboxBackBufferHostSurface,
/* pSourceRect = */ nullptr,
/* pDestSurface = */ pCurrentHostBackBuffer,
/* pDestRect = */ nullptr,
/* Filter = */ LoadSurfaceFilter
);
auto pXboxBackBufferHostSurface = GetHostSurface(g_XboxBackBufferSurface, D3DUSAGE_RENDERTARGET);
if (pXboxBackBufferHostSurface) {
// Blit Xbox BackBuffer to host BackBuffer
// TODO: Respect aspect ratio
hRet = g_pD3DDevice->StretchRect(
/* pSourceSurface = */ pXboxBackBufferHostSurface,
/* pSourceRect = */ nullptr,
/* pDestSurface = */ pCurrentHostBackBuffer,
/* pDestRect = */ nullptr,
/* Filter = */ LoadSurfaceFilter
);
if (hRet != D3D_OK) {
EmuLog(LOG_LEVEL::WARNING, "Couldn't blit Xbox BackBuffer to host BackBuffer : %X", hRet);
}
if (hRet != D3D_OK) {
EmuLog(LOG_LEVEL::WARNING, "Couldn't blit Xbox BackBuffer to host BackBuffer : %X", hRet);
}
}
@ -7962,23 +7957,6 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetRenderTarget)
g_pXboxDepthStencil = pNewZStencil;
pHostDepthStencil = GetHostSurface(g_pXboxDepthStencil, D3DUSAGE_DEPTHSTENCIL);
if (g_DirectHostBackBufferAccess) {
if (pRenderTarget == g_XboxBackBufferSurface) {
HRESULT hRet = g_pD3DDevice->GetBackBuffer(
0, // iSwapChain
0, D3DBACKBUFFER_TYPE_MONO, &pHostRenderTarget);
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->GetBackBuffer");
if (FAILED(hRet)) {
CxbxKrnlCleanup("Could not get host backbuffer");
}
}
if (pNewZStencil == g_XboxDefaultDepthStencilSurface) {
pHostDepthStencil = g_DefaultHostDepthBufferSuface;
}
}
HRESULT hRet;
// Mimick Direct3D 8 SetRenderTarget by only setting render target if non-null
if (pHostRenderTarget) {
@ -7993,10 +7971,6 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetRenderTarget)
hRet = g_pD3DDevice->SetDepthStencilSurface(pHostDepthStencil);
DEBUG_D3DRESULT(hRet, "g_pD3DDevice->SetDepthStencilSurface");
if (g_DirectHostBackBufferAccess && pRenderTarget == g_XboxBackBufferSurface) {
pHostRenderTarget->Release();
}
if (SUCCEEDED(hRet)) {
// Once we're sure the host depth-stencil is activated...
UpdateDepthStencilFlags(pHostDepthStencil);

View File

@ -609,7 +609,6 @@ void PrintCurrentConfigurationLog()
printf("Disable Pixel Shaders: %s\n", g_DisablePixelShaders == 1 ? "On" : "Off (Default)");
printf("Run Xbox threads on all cores: %s\n", g_UseAllCores == 1 ? "On" : "Off (Default)");
printf("Skip RDTSC Patching: %s\n", g_SkipRdtscPatching == 1 ? "On" : "Off (Default)");
printf("Render directly to Host BackBuffer: %s\n", g_DirectHostBackBufferAccess == 1 ? "On" : "Off (Default)");
}
printf("------------------------- END OF CONFIG LOG ------------------------\n");
@ -1413,8 +1412,6 @@ __declspec(noreturn) void CxbxKrnlInit
g_UseAllCores = !!HackEnabled;
g_EmuShared->GetSkipRdtscPatching(&HackEnabled);
g_SkipRdtscPatching = !!HackEnabled;
g_EmuShared->GetDirectHostBackBufferAccess(&HackEnabled);
g_DirectHostBackBufferAccess = !!HackEnabled;
}
#ifdef _DEBUG_PRINT_CURRENT_CONF

View File

@ -54,7 +54,6 @@ volatile bool g_bPrintfOn = true;
bool g_DisablePixelShaders = false;
bool g_UseAllCores = false;
bool g_SkipRdtscPatching = false;
bool g_DirectHostBackBufferAccess = false;
int g_RenderScaleFactor = 1.0f;
// Delta added to host SystemTime, used in KiClockIsr and KeSetSystemTime

View File

@ -98,7 +98,6 @@ typedef struct DUMMY_KERNEL
extern bool g_DisablePixelShaders;
extern bool g_UseAllCores;
extern bool g_SkipRdtscPatching;
extern bool g_DirectHostBackBufferAccess;
extern bool g_SkipRdtscPatching;
extern int g_RenderScaleFactor;
#endif

View File

@ -349,7 +349,6 @@
#define ID_HACKS_RUNXBOXTHREADSONALLCORES 40098
#define ID_HACKS_SKIPRDTSCPATCHING 40099
#define ID_SETTINGS_CONFIG_XBOX_CONTROLLER_MAPPING 40101
#define ID_HACKS_RENDERDIRECTLYTOHOSTBACKBUFFER 40102
#define ID_HACKS_SPEEDHACKS 40103
#define ID_SETTINGS_CONFIG_DLOCCUSTOM 40104
#define ID_SETTINGS_CONFIG_DLOCAPPDATA 40105

View File

@ -1266,11 +1266,6 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
RefreshMenus();
break;
case ID_HACKS_RENDERDIRECTLYTOHOSTBACKBUFFER:
g_Settings->m_hacks.DirectHostBackBufferAccess = !g_Settings->m_hacks.DirectHostBackBufferAccess;
RefreshMenus();
break;
case ID_SETTINGS_ALLOWADMINPRIVILEGE:
g_Settings->m_core.allowAdminPrivilege = !g_Settings->m_core.allowAdminPrivilege;
RefreshMenus();
@ -1716,9 +1711,6 @@ void WndMain::RefreshMenus()
chk_flag = (g_Settings->m_hacks.SkipRdtscPatching) ? MF_CHECKED : MF_UNCHECKED;
CheckMenuItem(settings_menu, ID_HACKS_SKIPRDTSCPATCHING, chk_flag);
chk_flag = (g_Settings->m_hacks.DirectHostBackBufferAccess) ? MF_CHECKED : MF_UNCHECKED;
CheckMenuItem(settings_menu, ID_HACKS_RENDERDIRECTLYTOHOSTBACKBUFFER, chk_flag);
switch (g_Settings->m_gui.DataStorageToggle) {
case CXBX_DATA_APPDATA:
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCAPPDATA, MF_CHECKED);