mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Move UseVertexDepthRange() out of Renderer
There wasn't really a good place for it, but this will do
This commit is contained in:
parent
2cfc02a116
commit
5803786beb
@ -18,6 +18,7 @@
|
|||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
#include "VideoCommon/RenderState.h"
|
#include "VideoCommon/RenderState.h"
|
||||||
#include "VideoCommon/VertexManagerBase.h"
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
|
#include "VideoCommon/VertexShaderManager.h"
|
||||||
#include "VideoCommon/VideoCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
#include "VideoCommon/XFMemory.h"
|
#include "VideoCommon/XFMemory.h"
|
||||||
@ -246,7 +247,7 @@ void SetScissorAndViewport()
|
|||||||
max_depth = std::clamp(max_depth, 0.0f, GX_MAX_DEPTH);
|
max_depth = std::clamp(max_depth, 0.0f, GX_MAX_DEPTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_renderer->UseVertexDepthRange())
|
if (VertexShaderManager::UseVertexDepthRange())
|
||||||
{
|
{
|
||||||
// We need to ensure depth values are clamped the maximum value supported by the console GPU.
|
// We need to ensure depth values are clamped the maximum value supported by the console GPU.
|
||||||
// Taking into account whether the depth range is inverted or not.
|
// Taking into account whether the depth range is inverted or not.
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "VideoCommon/VideoBackendBase.h"
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
#include "VideoCommon/VideoCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
#include "VideoCommon/XFMemory.h"
|
|
||||||
|
|
||||||
std::unique_ptr<Renderer> g_renderer;
|
std::unique_ptr<Renderer> g_renderer;
|
||||||
|
|
||||||
@ -141,22 +140,3 @@ void Renderer::PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Renderer::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;
|
|
||||||
}
|
|
||||||
|
@ -34,8 +34,6 @@ public:
|
|||||||
|
|
||||||
virtual u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data);
|
virtual u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data);
|
||||||
virtual void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points);
|
virtual void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points);
|
||||||
|
|
||||||
static bool UseVertexDepthRange();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::unique_ptr<Renderer> g_renderer;
|
extern std::unique_ptr<Renderer> g_renderer;
|
||||||
|
@ -158,6 +158,26 @@ 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
|
// Syncs the shader constant buffers with xfmem
|
||||||
// TODO: A cleaner way to control the matrices without making a mess in the parameters field
|
// 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)
|
void VertexShaderManager::SetConstants(const std::vector<std::string>& textures)
|
||||||
@ -356,7 +376,7 @@ void VertexShaderManager::SetConstants(const std::vector<std::string>& textures)
|
|||||||
constants.viewport[0] = (2.f * xfmem.viewport.wd);
|
constants.viewport[0] = (2.f * xfmem.viewport.wd);
|
||||||
constants.viewport[1] = (2.f * xfmem.viewport.ht);
|
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
|
// Oversized depth ranges are handled in the vertex shader. We need to reverse
|
||||||
// the far value to use the reversed-Z trick.
|
// the far value to use the reversed-Z trick.
|
||||||
|
@ -44,9 +44,13 @@ public:
|
|||||||
// (i.e. VertexShaderManager::SetConstants needs to be called before using this!)
|
// (i.e. VertexShaderManager::SetConstants needs to be called before using this!)
|
||||||
void TransformToClipSpace(const float* data, float* out, u32 mtxIdx);
|
void TransformToClipSpace(const float* data, float* out, u32 mtxIdx);
|
||||||
|
|
||||||
|
static bool UseVertexDepthRange();
|
||||||
|
|
||||||
VertexShaderConstants constants{};
|
VertexShaderConstants constants{};
|
||||||
bool dirty = false;
|
bool dirty = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
alignas(16) std::array<float, 16> m_projection_matrix;
|
alignas(16) std::array<float, 16> m_projection_matrix;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user