From 4595b89ad80ce2384d188de802ee03a183eb5905 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 12 Nov 2021 14:32:17 -0800 Subject: [PATCH] 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/Core/DolphinAnalytics.cpp | 1 - Source/Core/VideoBackends/D3D/D3DMain.cpp | 1 - .../Core/VideoBackends/D3D12/VideoBackend.cpp | 1 - .../Core/VideoBackends/Null/NullBackend.cpp | 1 - Source/Core/VideoBackends/OGL/OGLMain.cpp | 1 - Source/Core/VideoBackends/Software/SWmain.cpp | 1 - .../VideoBackends/Vulkan/VulkanContext.cpp | 1 - Source/Core/VideoCommon/BPFunctions.cpp | 11 ---- .../Core/VideoCommon/VertexShaderManager.cpp | 56 ------------------- Source/Core/VideoCommon/VideoConfig.h | 1 - 10 files changed, 75 deletions(-) diff --git a/Source/Core/Core/DolphinAnalytics.cpp b/Source/Core/Core/DolphinAnalytics.cpp index d55a5fba5e..5b67fd2c04 100644 --- a/Source/Core/Core/DolphinAnalytics.cpp +++ b/Source/Core/Core/DolphinAnalytics.cpp @@ -406,7 +406,6 @@ void DolphinAnalytics::MakePerGameBuilder() g_Config.backend_info.bSupportsExclusiveFullscreen); builder.AddData("gpu-has-dual-source-blend", g_Config.backend_info.bSupportsDualSourceBlend); builder.AddData("gpu-has-primitive-restart", g_Config.backend_info.bSupportsPrimitiveRestart); - builder.AddData("gpu-has-oversized-viewports", g_Config.backend_info.bSupportsOversizedViewports); builder.AddData("gpu-has-geometry-shaders", g_Config.backend_info.bSupportsGeometryShaders); builder.AddData("gpu-has-3d-vision", g_Config.backend_info.bSupports3DVision); builder.AddData("gpu-has-early-z", g_Config.backend_info.bSupportsEarlyZ); diff --git a/Source/Core/VideoBackends/D3D/D3DMain.cpp b/Source/Core/VideoBackends/D3D/D3DMain.cpp index ea11c33676..6fc2c285a1 100644 --- a/Source/Core/VideoBackends/D3D/D3DMain.cpp +++ b/Source/Core/VideoBackends/D3D/D3DMain.cpp @@ -79,7 +79,6 @@ void VideoBackend::FillBackendInfo() g_Config.backend_info.bSupportsExclusiveFullscreen = true; g_Config.backend_info.bSupportsDualSourceBlend = true; g_Config.backend_info.bSupportsPrimitiveRestart = true; - g_Config.backend_info.bSupportsOversizedViewports = false; g_Config.backend_info.bSupportsGeometryShaders = true; g_Config.backend_info.bSupportsComputeShaders = false; g_Config.backend_info.bSupports3DVision = true; diff --git a/Source/Core/VideoBackends/D3D12/VideoBackend.cpp b/Source/Core/VideoBackends/D3D12/VideoBackend.cpp index 2ddec74236..197d309332 100644 --- a/Source/Core/VideoBackends/D3D12/VideoBackend.cpp +++ b/Source/Core/VideoBackends/D3D12/VideoBackend.cpp @@ -51,7 +51,6 @@ void VideoBackend::FillBackendInfo() g_Config.backend_info.bSupportsExclusiveFullscreen = true; g_Config.backend_info.bSupportsDualSourceBlend = true; g_Config.backend_info.bSupportsPrimitiveRestart = true; - g_Config.backend_info.bSupportsOversizedViewports = false; g_Config.backend_info.bSupportsGeometryShaders = true; g_Config.backend_info.bSupports3DVision = false; g_Config.backend_info.bSupportsEarlyZ = true; diff --git a/Source/Core/VideoBackends/Null/NullBackend.cpp b/Source/Core/VideoBackends/Null/NullBackend.cpp index 0a400fc2fa..5d04a5adac 100644 --- a/Source/Core/VideoBackends/Null/NullBackend.cpp +++ b/Source/Core/VideoBackends/Null/NullBackend.cpp @@ -30,7 +30,6 @@ void VideoBackend::InitBackendInfo() g_Config.backend_info.bSupportsExclusiveFullscreen = true; g_Config.backend_info.bSupportsDualSourceBlend = true; g_Config.backend_info.bSupportsPrimitiveRestart = true; - g_Config.backend_info.bSupportsOversizedViewports = true; g_Config.backend_info.bSupportsGeometryShaders = true; g_Config.backend_info.bSupportsComputeShaders = false; g_Config.backend_info.bSupports3DVision = false; diff --git a/Source/Core/VideoBackends/OGL/OGLMain.cpp b/Source/Core/VideoBackends/OGL/OGLMain.cpp index 3e16b86ae8..a286625b34 100644 --- a/Source/Core/VideoBackends/OGL/OGLMain.cpp +++ b/Source/Core/VideoBackends/OGL/OGLMain.cpp @@ -78,7 +78,6 @@ void VideoBackend::InitBackendInfo() g_Config.backend_info.MaxTextureSize = 16384; g_Config.backend_info.bUsesLowerLeftOrigin = true; g_Config.backend_info.bSupportsExclusiveFullscreen = false; - g_Config.backend_info.bSupportsOversizedViewports = true; g_Config.backend_info.bSupportsGeometryShaders = true; g_Config.backend_info.bSupportsComputeShaders = false; g_Config.backend_info.bSupports3DVision = false; diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index 753f869c8e..a74b2eb1c9 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -68,7 +68,6 @@ void VideoSoftware::InitBackendInfo() g_Config.backend_info.bSupports3DVision = false; g_Config.backend_info.bSupportsDualSourceBlend = true; g_Config.backend_info.bSupportsEarlyZ = true; - g_Config.backend_info.bSupportsOversizedViewports = true; g_Config.backend_info.bSupportsPrimitiveRestart = false; g_Config.backend_info.bSupportsMultithreading = false; g_Config.backend_info.bSupportsComputeShaders = false; diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp index 8e0f0ed513..677bedf9d9 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp +++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp @@ -260,7 +260,6 @@ void VulkanContext::PopulateBackendInfo(VideoConfig* config) { config->backend_info.api_type = APIType::Vulkan; config->backend_info.bSupports3DVision = false; // D3D-exclusive. - config->backend_info.bSupportsOversizedViewports = true; // Assumed support. config->backend_info.bSupportsEarlyZ = true; // Assumed support. config->backend_info.bSupportsPrimitiveRestart = true; // Assumed support. config->backend_info.bSupportsBindingLayout = false; // Assumed support. diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp index fe3867c29c..9bc26fb9d2 100644 --- a/Source/Core/VideoCommon/BPFunctions.cpp +++ b/Source/Core/VideoCommon/BPFunctions.cpp @@ -153,17 +153,6 @@ void SetViewport() far_depth = 1.0f - min_depth; } - // Clamp to size if oversized not supported. Required for D3D. - if (!g_ActiveConfig.backend_info.bSupportsOversizedViewports) - { - const float max_width = static_cast(g_renderer->GetCurrentFramebuffer()->GetWidth()); - const float max_height = static_cast(g_renderer->GetCurrentFramebuffer()->GetHeight()); - x = std::clamp(x, 0.0f, max_width - 1.0f); - y = std::clamp(y, 0.0f, max_height - 1.0f); - width = std::clamp(width, 1.0f, max_width - x); - height = std::clamp(height, 1.0f, max_height - y); - } - // Lower-left flip. if (g_ActiveConfig.backend_info.bUsesLowerLeftOrigin) y = static_cast(g_renderer->GetCurrentFramebuffer()->GetHeight()) - y - height; 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()) diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index def1435b7f..2ff4d502af 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -199,7 +199,6 @@ struct VideoConfig final bool bSupportsExclusiveFullscreen = false; bool bSupportsDualSourceBlend = false; bool bSupportsPrimitiveRestart = false; - bool bSupportsOversizedViewports = false; bool bSupportsGeometryShaders = false; bool bSupportsComputeShaders = false; bool bSupports3DVision = false;