diff options
| author | Scott Mansell <phiren@gmail.com> | 2023-02-09 19:59:16 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-09 19:59:16 +1300 |
| commit | ccf92a3e56764d6378c436a8040519a5bffc3372 (patch) | |
| tree | e2b330b225044e1901e77a6ed147cf21b9d7ac0e /Source/Core/VideoCommon/VertexShaderManager.cpp | |
| parent | 72b22ef0a54f841b1c52d49cf0e00d3b12c29ac7 (diff) | |
| parent | 5c1b3ac61d7e660a9d1c206dbd0e615d637d3272 (diff) | |
Merge pull request #11522 from phire/KillRendererWithFire
Kill Renderer (with phire)
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderManager.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index deda07fd65..2408281da6 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -20,9 +20,10 @@ #include "VideoCommon/BPFunctions.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/CPMemory.h" +#include "VideoCommon/FramebufferManager.h" #include "VideoCommon/FreeLookCamera.h" #include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h" -#include "VideoCommon/RenderBase.h" +#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h" #include "VideoCommon/Statistics.h" #include "VideoCommon/VertexLoaderManager.h" #include "VideoCommon/VertexManagerBase.h" @@ -156,6 +157,25 @@ void VertexShaderManager::SetProjectionMatrix() } } +bool VertexShaderManager::UseVertexDepthRange() +{ + // We can't compute the depth range in the vertex shader if we don't support depth clamp. + if (!g_ActiveConfig.backend_info.bSupportsDepthClamp) + return false; + + // We need a full depth range if a ztexture is used. + if (bpmem.ztex2.op != ZTexOp::Disabled && !bpmem.zcontrol.early_ztest) + return true; + + // If an inverted depth range is unsupported, we also need to check if the range is inverted. + if (!g_ActiveConfig.backend_info.bSupportsReversedDepthRange && xfmem.viewport.zRange < 0.0f) + return true; + + // If an oversized depth range or a ztexture is used, we need to calculate the depth range + // in the vertex shader. + return fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f; +} + // Syncs the shader constant buffers with xfmem // TODO: A cleaner way to control the matrices without making a mess in the parameters field void VertexShaderManager::SetConstants(const std::vector<std::string>& textures) @@ -338,10 +358,10 @@ void VertexShaderManager::SetConstants(const std::vector<std::string>& textures) const bool bUseVertexRounding = g_ActiveConfig.UseVertexRounding(); const float viewport_width = bUseVertexRounding ? (2.f * xfmem.viewport.wd) : - g_renderer->EFBToScaledXf(2.f * xfmem.viewport.wd); + g_framebuffer_manager->EFBToScaledXf(2.f * xfmem.viewport.wd); const float viewport_height = bUseVertexRounding ? (2.f * xfmem.viewport.ht) : - g_renderer->EFBToScaledXf(2.f * xfmem.viewport.ht); + g_framebuffer_manager->EFBToScaledXf(2.f * xfmem.viewport.ht); const float pixel_size_x = 2.f / viewport_width; const float pixel_size_y = 2.f / viewport_height; constants.pixelcentercorrection[0] = pixel_center_correction * pixel_size_x; @@ -354,7 +374,7 @@ void VertexShaderManager::SetConstants(const std::vector<std::string>& textures) constants.viewport[0] = (2.f * xfmem.viewport.wd); constants.viewport[1] = (2.f * xfmem.viewport.ht); - if (g_renderer->UseVertexDepthRange()) + if (UseVertexDepthRange()) { // Oversized depth ranges are handled in the vertex shader. We need to reverse // the far value to use the reversed-Z trick. @@ -386,16 +406,15 @@ void VertexShaderManager::SetConstants(const std::vector<std::string>& textures) std::vector<GraphicsModAction*> projection_actions; if (g_ActiveConfig.bGraphicMods) { - for (const auto action : - g_renderer->GetGraphicsModManager().GetProjectionActions(xfmem.projection.type)) + for (const auto action : g_graphics_mod_manager->GetProjectionActions(xfmem.projection.type)) { projection_actions.push_back(action); } for (const auto& texture : textures) { - for (const auto action : g_renderer->GetGraphicsModManager().GetProjectionTextureActions( - xfmem.projection.type, texture)) + for (const auto action : + g_graphics_mod_manager->GetProjectionTextureActions(xfmem.projection.type, texture)) { projection_actions.push_back(action); } |
