Merge pull request #2151 from NZJenkins/fix-backbuffer-format

Use the backbuffer format requested by the title
This commit is contained in:
PatrickvL 2021-03-10 18:11:03 +01:00 committed by GitHub
commit 72acea23b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 27 deletions

View File

@ -2182,8 +2182,9 @@ static void SetupPresentationParameters
// TODO: Investigate the best option for this // TODO: Investigate the best option for this
params.SwapEffect = D3DSWAPEFFECT_COPY; params.SwapEffect = D3DSWAPEFFECT_COPY;
// Attempt to match backbuffer format, this is not *required*, but leads to faster blitting/swapping // Any backbuffer format should do, since we render to a separate xbox backbuffer
params.BackBufferFormat = EmuXB2PC_D3DFormat(pXboxPresentationParameters->BackBufferFormat); // Rather than directly to the host backbuffer
params.BackBufferFormat = D3DFMT_UNKNOWN;
params.PresentationInterval = g_XBVideo.bVSync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; params.PresentationInterval = g_XBVideo.bVSync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
g_Xbox_PresentationInterval_Default = pXboxPresentationParameters->PresentationInterval; g_Xbox_PresentationInterval_Default = pXboxPresentationParameters->PresentationInterval;
@ -2214,26 +2215,10 @@ static void SetupPresentationParameters
params.FullScreen_RefreshRateInHz = pXboxPresentationParameters->FullScreen_RefreshRateInHz; params.FullScreen_RefreshRateInHz = pXboxPresentationParameters->FullScreen_RefreshRateInHz;
} }
if(params.Windowed) if (params.Windowed) {
{ // Refresh rate must be 0 in windowed mode, as is documented
D3DDISPLAYMODE D3DDisplayMode;
g_pDirect3D->GetAdapterDisplayMode(g_EmuCDPD.Adapter, &D3DDisplayMode);
params.BackBufferFormat = D3DDisplayMode.Format;
params.FullScreen_RefreshRateInHz = 0; 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 static void DetermineSupportedD3DFormats
@ -5679,11 +5664,6 @@ void CreateHostResource(xbox::X_D3DResource *pResource, DWORD D3DUsage, int iTex
if (IsSupportedFormat(X_Format, XboxResourceType, D3DUsage)) { if (IsSupportedFormat(X_Format, XboxResourceType, D3DUsage)) {
// Then use matching host format // Then use matching host format
PCFormat = EmuXB2PC_D3DFormat(X_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 { else {
if (D3DUsage & D3DUSAGE_DEPTHSTENCIL) { if (D3DUsage & D3DUSAGE_DEPTHSTENCIL) {

View File

@ -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" }, /* 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 /* 0x17 X_D3DFMT_LIN_G8B8 */ { 16, Linear, ____G8B8, D3DFMT_R5G6B5 , RenderTarget, "X_D3DFMT_LIN_G8B8 -> D3DFMT_R5G6B5" }, // Alias : X_D3DFMT_LIN_V8U8
/* 0x18 undefined */ {}, /* 0x18 undefined */ {},
/* 0x19 X_D3DFMT_A8 */ { 8, Swzzld, ______A8, D3DFMT_A8 }, /* 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 }, /* 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" }, /* 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 }, /* 0x1C X_D3DFMT_LIN_X1R5G5B5 */ { 16, Linear, X1R5G5B5, D3DFMT_X1R5G5B5 , RenderTarget },
/* 0x1D X_D3DFMT_LIN_A4R4G4B4 */ { 16, Linear, A4R4G4B4, D3DFMT_A4R4G4B4 }, /* 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 /* 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 }, /* 0x20 X_D3DFMT_LIN_A8L8 */ { 16, Linear, ____A8L8, D3DFMT_A8L8 },
/* 0x21 undefined */ {}, /* 0x21 undefined */ {},
/* 0x22 undefined */ {}, /* 0x22 undefined */ {},