mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
DX9/DX11: Workaround the viewpoint/EFB creation issues in e.g. SMG2 on NVIDIA hardware or when using HD. Will most likely cause glitches, but prevents crashing. Correct behavior can't be implemented in Direct3D, so this is the best option we have.
Also two little changes which don't affect functionality or performance: Change an IUnknown* cast to a T* cast. Improve some error messages. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5870 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -97,7 +97,7 @@ void FramebufferManager::Create()
|
||||
{
|
||||
hr = s_efb_color_texture->GetSurfaceLevel(0, &s_efb_color_surface);
|
||||
}
|
||||
CHECK(hr, "Create Color Texture (hr=%#x)", hr);
|
||||
CHECK(hr, "Create Color Texture (size: %dx%d; hr=%#x)", target_width, target_height, hr);
|
||||
hr = D3D::dev->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
|
||||
D3DPOOL_DEFAULT, &s_efb_colorRead_texture, NULL);
|
||||
CHECK(hr, "Create Color Read Texture (hr=%#x)", hr);
|
||||
@ -128,7 +128,7 @@ void FramebufferManager::Create()
|
||||
if (!FAILED(hr))
|
||||
break;
|
||||
}
|
||||
CHECK(hr, "Depth Color Texture (hr=%#x)", hr);
|
||||
CHECK(hr, "Depth Color Texture (size: %dx%d; hr=%#x)", target_width, target_height, hr);
|
||||
// Get the Surface
|
||||
if(s_efb_depth_texture)
|
||||
{
|
||||
|
@ -823,6 +823,9 @@ void UpdateViewport()
|
||||
// [3] = xorig + width/2 + 342
|
||||
// [4] = yorig + height/2 + 342
|
||||
// [5] = 16777215 * farz
|
||||
const int old_fulltarget_w = s_Fulltarget_width;
|
||||
const int old_fulltarget_h = s_Fulltarget_height;
|
||||
|
||||
int scissorXOff = bpmem.scissorOffset.x * 2;
|
||||
int scissorYOff = bpmem.scissorOffset.y * 2;
|
||||
|
||||
@ -877,6 +880,16 @@ void UpdateViewport()
|
||||
}
|
||||
if (sizeChanged)
|
||||
{
|
||||
D3DCAPS9 caps = D3D::GetCaps();
|
||||
// Make sure that the requested size is actually supported by the GFX driver
|
||||
if (s_Fulltarget_width > caps.MaxTextureWidth || s_Fulltarget_height > caps.MaxTextureHeight)
|
||||
{
|
||||
// Skip EFB recreation and viewport setting. Most likely cause glitches in this case, but prevents crashes at least
|
||||
ERROR_LOG(VIDEO, "Tried to set a viewport which is too wide to emulate with Direct3D9. Requested EFB size is %dx%d\n", s_Fulltarget_width, s_Fulltarget_height);
|
||||
s_Fulltarget_width = old_fulltarget_w;
|
||||
s_Fulltarget_height = old_fulltarget_h;
|
||||
return;
|
||||
}
|
||||
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
||||
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
|
||||
FBManager.Destroy();
|
||||
|
Reference in New Issue
Block a user