mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
Merge pull request #1781 from Armada651/xfb-fixes
D3D: Fix Virtual XFB viewport.
This commit is contained in:
@ -40,12 +40,13 @@
|
||||
namespace DX11
|
||||
{
|
||||
|
||||
static u32 s_LastAA = 0;
|
||||
static u32 s_last_multisample_mode = 0;
|
||||
|
||||
static Television s_television;
|
||||
|
||||
static bool s_last_fullscreen_mode = false;
|
||||
static bool s_LastStereo = 0;
|
||||
static bool s_last_stereo_mode = 0;
|
||||
static bool s_last_xfb_mode = false;
|
||||
|
||||
ID3D11Buffer* access_efb_cbuf = nullptr;
|
||||
ID3D11BlendState* clearblendstates[4] = {nullptr};
|
||||
@ -227,10 +228,11 @@ Renderer::Renderer(void *&window_handle)
|
||||
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
s_LastAA = g_ActiveConfig.iMultisampleMode;
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
|
||||
s_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
s_last_fullscreen_mode = g_ActiveConfig.bFullscreen;
|
||||
s_LastStereo = g_ActiveConfig.iStereoMode > 0;
|
||||
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
|
||||
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
|
||||
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
SetupDeviceObjects();
|
||||
@ -744,8 +746,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
|
||||
int xfbWidth = xfbSource->srcWidth;
|
||||
int hOffset = ((s32)xfbSource->srcAddr - (s32)xfbAddr) / ((s32)fbStride * 2);
|
||||
|
||||
drawRc.top = targetRc.bottom - (hOffset + xfbHeight) * targetRc.GetHeight() / fbHeight;
|
||||
drawRc.bottom = targetRc.bottom - hOffset * targetRc.GetHeight() / fbHeight;
|
||||
drawRc.top = targetRc.top + hOffset * targetRc.GetHeight() / fbHeight;
|
||||
drawRc.bottom = targetRc.top + (hOffset + xfbHeight) * targetRc.GetHeight() / fbHeight;
|
||||
drawRc.left = targetRc.left + (targetRc.GetWidth() - xfbWidth * targetRc.GetWidth() / fbStride) / 2;
|
||||
drawRc.right = targetRc.left + (targetRc.GetWidth() + xfbWidth * targetRc.GetWidth() / fbStride) / 2;
|
||||
|
||||
@ -878,7 +880,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
|
||||
}
|
||||
}
|
||||
|
||||
bool xfbchanged = false;
|
||||
bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB;
|
||||
|
||||
if (FramebufferManagerBase::LastXfbWidth() != fbStride || FramebufferManagerBase::LastXfbHeight() != fbHeight)
|
||||
{
|
||||
@ -896,11 +898,12 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
|
||||
if (xfbchanged ||
|
||||
windowResized ||
|
||||
fullscreen_changed ||
|
||||
s_LastEFBScale != g_ActiveConfig.iEFBScale ||
|
||||
s_LastAA != g_ActiveConfig.iMultisampleMode ||
|
||||
s_LastStereo != (g_ActiveConfig.iStereoMode > 0))
|
||||
s_last_efb_scale != g_ActiveConfig.iEFBScale ||
|
||||
s_last_multisample_mode != g_ActiveConfig.iMultisampleMode ||
|
||||
s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
|
||||
{
|
||||
s_LastAA = g_ActiveConfig.iMultisampleMode;
|
||||
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
|
||||
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
|
||||
PixelShaderCache::InvalidateMSAAShaders();
|
||||
|
||||
if (windowResized || fullscreen_changed)
|
||||
@ -928,8 +931,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
|
||||
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
s_LastStereo = g_ActiveConfig.iStereoMode > 0;
|
||||
s_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
|
||||
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), nullptr);
|
||||
|
@ -92,7 +92,7 @@ static const char XFB_ENCODE_PS[] =
|
||||
"float3 SampleEFB(float2 coord)\n"
|
||||
"{\n"
|
||||
"float2 texCoord = lerp(float2(Params.TexLeft,Params.TexTop), float2(Params.TexRight,Params.TexBottom), coord / float2(Params.Width,Params.Height));\n"
|
||||
"return EFBTexture.Sample(EFBSampler, float3(texCoord, 0)).rgb;\n"
|
||||
"return EFBTexture.Sample(EFBSampler, float3(texCoord, 0.0)).rgb;\n"
|
||||
"}\n"
|
||||
|
||||
"void main(out float4 ocol0 : SV_Target, in float4 Pos : SV_Position, in float2 Coord : ENCODECOORD)\n"
|
||||
|
@ -85,9 +85,9 @@ static RasterFont* s_pfont = nullptr;
|
||||
|
||||
// 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA.
|
||||
static int s_MSAASamples = 1;
|
||||
static int s_LastMultisampleMode = 0;
|
||||
|
||||
static bool s_LastStereo = false;
|
||||
static int s_last_multisample_mode = 0;
|
||||
static bool s_last_stereo_mode = false;
|
||||
static bool s_last_xfb_mode = false;
|
||||
|
||||
static u32 s_blendMode;
|
||||
|
||||
@ -586,10 +586,12 @@ Renderer::Renderer()
|
||||
g_ActiveConfig.backend_info.bSupportsGSInstancing ? "" : "GSInstancing "
|
||||
);
|
||||
|
||||
s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode;
|
||||
s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode);
|
||||
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
|
||||
s_MSAASamples = GetNumMSAASamples(s_last_multisample_mode);
|
||||
ApplySSAASettings();
|
||||
s_LastStereo = g_ActiveConfig.iStereoMode > 0;
|
||||
|
||||
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
|
||||
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
|
||||
|
||||
// Decide framebuffer size
|
||||
s_backbuffer_width = (int)GLInterface->GetBackBufferWidth();
|
||||
@ -605,7 +607,7 @@ Renderer::Renderer()
|
||||
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
s_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
// Because of the fixed framebuffer size we need to disable the resolution
|
||||
@ -1625,7 +1627,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
|
||||
|
||||
GLInterface->Update(); // just updates the render window position and the backbuffer size
|
||||
|
||||
bool xfbchanged = false;
|
||||
bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB;
|
||||
|
||||
if (FramebufferManagerBase::LastXfbWidth() != fbStride || FramebufferManagerBase::LastXfbHeight() != fbHeight)
|
||||
{
|
||||
@ -1639,24 +1641,26 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
|
||||
bool WindowResized = false;
|
||||
int W = (int)GLInterface->GetBackBufferWidth();
|
||||
int H = (int)GLInterface->GetBackBufferHeight();
|
||||
if (W != s_backbuffer_width || H != s_backbuffer_height || s_LastEFBScale != g_ActiveConfig.iEFBScale)
|
||||
if (W != s_backbuffer_width || H != s_backbuffer_height || s_last_efb_scale != g_ActiveConfig.iEFBScale)
|
||||
{
|
||||
WindowResized = true;
|
||||
s_backbuffer_width = W;
|
||||
s_backbuffer_height = H;
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
s_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
}
|
||||
|
||||
if (xfbchanged || WindowResized || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode) || (s_LastStereo != (g_ActiveConfig.iStereoMode > 0)))
|
||||
if (xfbchanged || WindowResized || (s_last_multisample_mode != g_ActiveConfig.iMultisampleMode) || (s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0)))
|
||||
{
|
||||
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
|
||||
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
|
||||
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
if (CalculateTargetSize(s_backbuffer_width, s_backbuffer_height) || s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode || s_LastStereo != (g_ActiveConfig.iStereoMode > 0))
|
||||
if (CalculateTargetSize(s_backbuffer_width, s_backbuffer_height) || s_last_multisample_mode != g_ActiveConfig.iMultisampleMode || s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
|
||||
{
|
||||
s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode;
|
||||
s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode);
|
||||
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
|
||||
s_MSAASamples = GetNumMSAASamples(s_last_multisample_mode);
|
||||
ApplySSAASettings();
|
||||
s_LastStereo = g_ActiveConfig.iStereoMode > 0;
|
||||
|
||||
delete g_framebuffer_manager;
|
||||
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,
|
||||
|
Reference in New Issue
Block a user