Merge pull request #1996 from CookiePLMonster/viewport-clear-improvements

SetViewport & Clear improvements
This commit is contained in:
Luke Usher 2020-10-17 16:04:51 +01:00 committed by GitHub
commit 6a70a08c59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -4117,6 +4117,8 @@ xbox::void_xt WINAPI xbox::EMUPATCH(D3DDevice_SetViewport)
// Apply MSAA scale and offset // Apply MSAA scale and offset
HostViewPort.Width = static_cast<DWORD>(HostViewPort.Width * g_Xbox_MultiSampleXScale); HostViewPort.Width = static_cast<DWORD>(HostViewPort.Width * g_Xbox_MultiSampleXScale);
HostViewPort.Height = static_cast<DWORD>(HostViewPort.Height * g_Xbox_MultiSampleYScale); HostViewPort.Height = static_cast<DWORD>(HostViewPort.Height * g_Xbox_MultiSampleYScale);
HostViewPort.X = static_cast<DWORD>(HostViewPort.X * g_Xbox_MultiSampleXScale);
HostViewPort.Y = static_cast<DWORD>(HostViewPort.Y * g_Xbox_MultiSampleYScale);
// Since Width and Height are DWORD, adding GetMultiSampleOffset 0.0f or 0.5f makes no sense // Since Width and Height are DWORD, adding GetMultiSampleOffset 0.0f or 0.5f makes no sense
HRESULT hRet = g_pD3DDevice->SetViewport(&HostViewPort); HRESULT hRet = g_pD3DDevice->SetViewport(&HostViewPort);
@ -4997,12 +4999,14 @@ xbox::void_xt WINAPI xbox::EMUPATCH(D3DDevice_Clear)
if (pRects != nullptr) { if (pRects != nullptr) {
// Scale the fill based on our scale factor and MSAA scale // Scale the fill based on our scale factor and MSAA scale
D3DRECT rect; std::vector<D3DRECT> rects(Count);
rect.x1 = static_cast<LONG>(pRects->x1 * g_Xbox_MultiSampleXScale * g_RenderScaleFactor); for (DWORD i = 0; i < Count; i++) {
rect.x2 = static_cast<LONG>(pRects->x2 * g_Xbox_MultiSampleXScale * g_RenderScaleFactor); rects[i].x1 = static_cast<LONG>(pRects[i].x1 * g_Xbox_MultiSampleXScale * g_RenderScaleFactor);
rect.y1 = static_cast<LONG>(pRects->y1 * g_Xbox_MultiSampleYScale * g_RenderScaleFactor); rects[i].x2 = static_cast<LONG>(pRects[i].x2 * g_Xbox_MultiSampleXScale * g_RenderScaleFactor);
rect.y2 = static_cast<LONG>(pRects->y2 * g_Xbox_MultiSampleYScale * g_RenderScaleFactor); rects[i].y1 = static_cast<LONG>(pRects[i].y1 * g_Xbox_MultiSampleYScale * g_RenderScaleFactor);
hRet = g_pD3DDevice->Clear(Count, &rect, HostFlags, Color, Z, Stencil); rects[i].y2 = static_cast<LONG>(pRects[i].y2 * g_Xbox_MultiSampleYScale * g_RenderScaleFactor);
}
hRet = g_pD3DDevice->Clear(Count, rects.data(), HostFlags, Color, Z, Stencil);
} else { } else {
hRet = g_pD3DDevice->Clear(Count, pRects, HostFlags, Color, Z, Stencil); hRet = g_pD3DDevice->Clear(Count, pRects, HostFlags, Color, Z, Stencil);
} }