From 4595b89ad80ce2384d188de802ee03a183eb5905 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 12 Nov 2021 14:32:17 -0800 Subject: VideoCommon: Remove bSupportsOversizedViewports I think this is a relic of D3D9. D3D11 and D3D12 seem to work fine without it. Plus, ViewportCorrectionMatrix just didn't work correctly (at least with the viewports being generated by the new scissor code). --- Source/Core/VideoCommon/VertexShaderManager.cpp | 56 ------------------------- 1 file changed, 56 deletions(-) (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp') diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 23e94776be..6ba7144345 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -49,55 +49,6 @@ static Common::Matrix44 s_viewportCorrection; VertexShaderConstants VertexShaderManager::constants; bool VertexShaderManager::dirty; -// Viewport correction: -// In D3D, the viewport rectangle must fit within the render target. -// Say you want a viewport at (ix, iy) with size (iw, ih), -// but your viewport must be clamped at (ax, ay) with size (aw, ah). -// Just multiply the projection matrix with the following to get the same -// effect: -// [ (iw/aw) 0 0 ((iw - 2*(ax-ix)) / aw - 1) ] -// [ 0 (ih/ah) 0 ((-ih + 2*(ay-iy)) / ah + 1) ] -// [ 0 0 1 0 ] -// [ 0 0 0 1 ] -static void ViewportCorrectionMatrix(Common::Matrix44& result) -{ - int scissorXOff = bpmem.scissorOffset.x * 2; - int scissorYOff = bpmem.scissorOffset.y * 2; - - // TODO: ceil, floor or just cast to int? - // TODO: Directly use the floats instead of rounding them? - float intendedX = xfmem.viewport.xOrig - xfmem.viewport.wd - scissorXOff; - float intendedY = xfmem.viewport.yOrig + xfmem.viewport.ht - scissorYOff; - float intendedWd = 2.0f * xfmem.viewport.wd; - float intendedHt = -2.0f * xfmem.viewport.ht; - - if (intendedWd < 0.f) - { - intendedX += intendedWd; - intendedWd = -intendedWd; - } - if (intendedHt < 0.f) - { - intendedY += intendedHt; - intendedHt = -intendedHt; - } - - // fit to EFB size - float X = (intendedX >= 0.f) ? intendedX : 0.f; - float Y = (intendedY >= 0.f) ? intendedY : 0.f; - float Wd = (X + intendedWd <= EFB_WIDTH) ? intendedWd : (EFB_WIDTH - X); - float Ht = (Y + intendedHt <= EFB_HEIGHT) ? intendedHt : (EFB_HEIGHT - Y); - - result = Common::Matrix44::Identity(); - if (Wd == 0 || Ht == 0) - return; - - result.data[4 * 0 + 0] = intendedWd / Wd; - result.data[4 * 0 + 3] = (intendedWd - 2.f * (X - intendedX)) / Wd - 1.f; - result.data[4 * 1 + 1] = intendedHt / Ht; - result.data[4 * 1 + 3] = (-intendedHt + 2.f * (Y - intendedY)) / Ht + 1.f; -} - void VertexShaderManager::Init() { // Initialize state tracking variables @@ -348,13 +299,6 @@ void VertexShaderManager::SetConstants() dirty = true; BPFunctions::SetViewport(); - - // Update projection if the viewport isn't 1:1 useable - if (!g_ActiveConfig.backend_info.bSupportsOversizedViewports) - { - ViewportCorrectionMatrix(s_viewportCorrection); - bProjectionChanged = true; - } } if (bProjectionChanged || g_freelook_camera.GetController()->IsDirty()) -- cgit v1.2.3 From 076392a0f65fa11b8c3475b762b8b9794057ae11 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 12 Nov 2021 11:48:26 -0800 Subject: VideoCommon: Rework scissor handling This increases accuracy, fixing the white rendering in Major Minor's Majestic March. However, the hardware backends can only have one viewport and scissor rectangle at a time, while sometimes multiple are needed to accurately emulate what is happening. If possible, this will need to be fixed later. --- Source/Core/VideoCommon/VertexShaderManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp') diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 6ba7144345..fc8b9e69f8 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -298,7 +298,7 @@ void VertexShaderManager::SetConstants() } dirty = true; - BPFunctions::SetViewport(); + BPFunctions::SetScissorAndViewport(); } if (bProjectionChanged || g_freelook_camera.GetController()->IsDirty()) -- cgit v1.2.3 From f3eff70e2fda8ad0894f34336584f331ab989b68 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sat, 27 Nov 2021 17:09:55 -0800 Subject: Implement ImGui window for scissor rectangles This is mainly for debugging, and is only exposed by manually editing the configuration. --- Source/Core/VideoCommon/VertexShaderManager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp') diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index fc8b9e69f8..2b5fc68185 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -299,6 +299,7 @@ void VertexShaderManager::SetConstants() dirty = true; BPFunctions::SetScissorAndViewport(); + g_stats.AddScissorRect(); } if (bProjectionChanged || g_freelook_camera.GetController()->IsDirty()) -- cgit v1.2.3