From 3c393227be88ada50f733c2323eec1be584336e7 Mon Sep 17 00:00:00 2001 From: Anthony Date: Sun, 7 Mar 2021 18:24:05 +1300 Subject: [PATCH 1/3] - Remove code that aligns the host backbuffer with the xbox backbuffer - Remove code related to setting the backbuffer format --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 30 ++++------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index be99f61ba..6b1e9c45e 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -2182,8 +2182,9 @@ static void SetupPresentationParameters // TODO: Investigate the best option for this params.SwapEffect = D3DSWAPEFFECT_COPY; - // Attempt to match backbuffer format, this is not *required*, but leads to faster blitting/swapping - params.BackBufferFormat = EmuXB2PC_D3DFormat(pXboxPresentationParameters->BackBufferFormat); + // Any backbuffer format should do, since we render to a separate xbox backbuffer + // Rather than directly to the host backbuffer + params.BackBufferFormat = D3DFMT_UNKNOWN; params.PresentationInterval = g_XBVideo.bVSync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; g_Xbox_PresentationInterval_Default = pXboxPresentationParameters->PresentationInterval; @@ -2214,26 +2215,10 @@ static void SetupPresentationParameters params.FullScreen_RefreshRateInHz = pXboxPresentationParameters->FullScreen_RefreshRateInHz; } - if(params.Windowed) - { - D3DDISPLAYMODE D3DDisplayMode; - g_pDirect3D->GetAdapterDisplayMode(g_EmuCDPD.Adapter, &D3DDisplayMode); - - params.BackBufferFormat = D3DDisplayMode.Format; + if (params.Windowed) { + // Refresh rate must be 0 in windowed mode, as is documented params.FullScreen_RefreshRateInHz = 0; } - else - { - // In exclusive fullscreen mode, make *sure* to use the info that was in the resolution string - if (strcmp(szBackBufferFormat, "x1r5g5b5") == 0) - params.BackBufferFormat = D3DFMT_X1R5G5B5; - else if (strcmp(szBackBufferFormat, "r5g6r5") == 0) - params.BackBufferFormat = D3DFMT_R5G6B5; - else if (strcmp(szBackBufferFormat, "x8r8g8b8") == 0) - params.BackBufferFormat = D3DFMT_X8R8G8B8; - else if (strcmp(szBackBufferFormat, "a8r8g8b8") == 0) - params.BackBufferFormat = D3DFMT_A8R8G8B8; - } } static void DetermineSupportedD3DFormats @@ -5679,11 +5664,6 @@ void CreateHostResource(xbox::X_D3DResource *pResource, DWORD D3DUsage, int iTex if (IsSupportedFormat(X_Format, XboxResourceType, D3DUsage)) { // Then use matching host format PCFormat = EmuXB2PC_D3DFormat(X_Format); - - // If, and ONLY if this is the default backbuffer, make sure the format matches the host backbuffer - if (pResource == g_pXbox_BackBufferSurface) { - PCFormat = g_EmuCDPD.HostPresentationParameters.BackBufferFormat; - } } else { if (D3DUsage & D3DUSAGE_DEPTHSTENCIL) { From 0c8ae3f3e2aa2363ac27d1ce38a7467a15c8c9f9 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 9 Mar 2021 19:33:13 +1300 Subject: [PATCH 2/3] Always convert D3DFMT_A8 to ARGB In D3D8, the RGB values appear to be undefined, and the Xbox uses 1. Whereas in D3D9, the RGB values are 0 --- src/core/hle/D3D8/XbConvert.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/hle/D3D8/XbConvert.cpp b/src/core/hle/D3D8/XbConvert.cpp index 52754b6c8..ffe442d34 100644 --- a/src/core/hle/D3D8/XbConvert.cpp +++ b/src/core/hle/D3D8/XbConvert.cpp @@ -900,13 +900,13 @@ static const FormatInfo FormatInfos[] = { /* 0x16 X_D3DFMT_LIN_R8B8 */ { 16, Linear, ____R8B8, D3DFMT_R5G6B5 , Texture, "X_D3DFMT_LIN_R8B8 -> D3DFMT_R5G6B5" }, /* 0x17 X_D3DFMT_LIN_G8B8 */ { 16, Linear, ____G8B8, D3DFMT_R5G6B5 , RenderTarget, "X_D3DFMT_LIN_G8B8 -> D3DFMT_R5G6B5" }, // Alias : X_D3DFMT_LIN_V8U8 /* 0x18 undefined */ {}, - /* 0x19 X_D3DFMT_A8 */ { 8, Swzzld, ______A8, D3DFMT_A8 }, + /* 0x19 X_D3DFMT_A8 */ { 8, Swzzld, ______A8, D3DFMT_A8 , Texture, "X_D3DFMT_LIN_A8 -> D3DFMT_A8R8G8B8" }, // D3D9 sets RGB = 0 instead of 1 /* 0x1A X_D3DFMT_A8L8 */ { 16, Swzzld, ____A8L8, D3DFMT_A8L8 }, /* 0x1B X_D3DFMT_LIN_AL8 */ { 8, Linear, _____AL8, D3DFMT_L8 , Texture, "X_D3DFMT_LIN_AL8 -> D3DFMT_L8" }, /* 0x1C X_D3DFMT_LIN_X1R5G5B5 */ { 16, Linear, X1R5G5B5, D3DFMT_X1R5G5B5 , RenderTarget }, /* 0x1D X_D3DFMT_LIN_A4R4G4B4 */ { 16, Linear, A4R4G4B4, D3DFMT_A4R4G4B4 }, /* 0x1E X_D3DFMT_LIN_X8R8G8B8 */ { 32, Linear, X8R8G8B8, D3DFMT_X8R8G8B8 , RenderTarget }, // Alias : X_D3DFMT_LIN_X8L8V8U8 - /* 0x1F X_D3DFMT_LIN_A8 */ { 8, Linear, ______A8, D3DFMT_A8 }, + /* 0x1F X_D3DFMT_LIN_A8 */ { 8, Linear, ______A8, D3DFMT_A8 , Texture, "X_D3DFMT_LIN_A8 -> D3DFMT_A8R8G8B8" }, // D3D9 sets RGB = 0 instead of 1 /* 0x20 X_D3DFMT_LIN_A8L8 */ { 16, Linear, ____A8L8, D3DFMT_A8L8 }, /* 0x21 undefined */ {}, /* 0x22 undefined */ {}, From 55d81a3bfbc07984702f966f907d75e23a5f5b00 Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 10 Mar 2021 20:14:48 +1300 Subject: [PATCH 3/3] fixup texture conversion warning --- src/core/hle/D3D8/XbConvert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/D3D8/XbConvert.cpp b/src/core/hle/D3D8/XbConvert.cpp index ffe442d34..8c55acae4 100644 --- a/src/core/hle/D3D8/XbConvert.cpp +++ b/src/core/hle/D3D8/XbConvert.cpp @@ -900,7 +900,7 @@ static const FormatInfo FormatInfos[] = { /* 0x16 X_D3DFMT_LIN_R8B8 */ { 16, Linear, ____R8B8, D3DFMT_R5G6B5 , Texture, "X_D3DFMT_LIN_R8B8 -> D3DFMT_R5G6B5" }, /* 0x17 X_D3DFMT_LIN_G8B8 */ { 16, Linear, ____G8B8, D3DFMT_R5G6B5 , RenderTarget, "X_D3DFMT_LIN_G8B8 -> D3DFMT_R5G6B5" }, // Alias : X_D3DFMT_LIN_V8U8 /* 0x18 undefined */ {}, - /* 0x19 X_D3DFMT_A8 */ { 8, Swzzld, ______A8, D3DFMT_A8 , Texture, "X_D3DFMT_LIN_A8 -> D3DFMT_A8R8G8B8" }, // D3D9 sets RGB = 0 instead of 1 + /* 0x19 X_D3DFMT_A8 */ { 8, Swzzld, ______A8, D3DFMT_A8 , Texture, "X_D3DFMT_A8 -> D3DFMT_A8R8G8B8" }, // D3D9 sets RGB = 0 instead of 1 /* 0x1A X_D3DFMT_A8L8 */ { 16, Swzzld, ____A8L8, D3DFMT_A8L8 }, /* 0x1B X_D3DFMT_LIN_AL8 */ { 8, Linear, _____AL8, D3DFMT_L8 , Texture, "X_D3DFMT_LIN_AL8 -> D3DFMT_L8" }, /* 0x1C X_D3DFMT_LIN_X1R5G5B5 */ { 16, Linear, X1R5G5B5, D3DFMT_X1R5G5B5 , RenderTarget },