mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
VertexShaderGen: Remove the need for an extra UID.
This commit is contained in:
parent
ad84b904e4
commit
f866748006
@ -30,10 +30,6 @@ VertexShaderUid GetVertexShaderUid()
|
||||
uid_data->msaa = g_ActiveConfig.iMultisamples > 1;
|
||||
uid_data->ssaa = g_ActiveConfig.iMultisamples > 1 && g_ActiveConfig.bSSAA;
|
||||
uid_data->numColorChans = xfmem.numChan.numColorChans;
|
||||
uid_data->vertex_depth =
|
||||
g_ActiveConfig.backend_info.bSupportsDepthClamp &&
|
||||
((fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f) ||
|
||||
(xfmem.viewport.zRange < 0.0f && !g_ActiveConfig.backend_info.bSupportsReversedDepthRange));
|
||||
|
||||
GetLightingShaderUid(uid_data->lighting);
|
||||
|
||||
@ -438,8 +434,7 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
|
||||
// override it with the correct values if not then early z culling will improve speed.
|
||||
// There are two different ways to do this, when the depth range is oversized, we process
|
||||
// the depth range in the vertex shader, if not we let the host driver handle it.
|
||||
if (uid_data->vertex_depth)
|
||||
{
|
||||
//
|
||||
// Adjust z for the depth range. We're using an equation which incorperates a depth inversion,
|
||||
// so we can map the console -1..0 range to the 0..1 range used in the depth buffer.
|
||||
// We have to handle the depth range in the vertex shader instead of after the perspective
|
||||
@ -448,13 +443,6 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
|
||||
// games effectively add a depth bias to the values written to the depth buffer.
|
||||
out.Write("o.pos.z = o.pos.w * " I_PIXELCENTERCORRECTION ".w - "
|
||||
"o.pos.z * " I_PIXELCENTERCORRECTION ".z;\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Here we rely on the host driver to process the depth range, however we still need to invert
|
||||
// the console -1..0 range to the 0..1 range used in the depth buffer.
|
||||
out.Write("o.pos.z = -o.pos.z;\n");
|
||||
}
|
||||
|
||||
if (!g_ActiveConfig.backend_info.bSupportsClipControl)
|
||||
{
|
||||
|
@ -43,8 +43,7 @@ struct vertex_shader_uid_data
|
||||
u32 texMtxInfo_n_projection : 16; // Stored separately to guarantee that the texMtxInfo struct is
|
||||
// 8 bits wide
|
||||
u32 ssaa : 1;
|
||||
u32 vertex_depth : 1;
|
||||
u32 pad : 14;
|
||||
u32 pad : 15;
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -387,6 +387,11 @@ void VertexShaderManager::SetConstants()
|
||||
constants.pixelcentercorrection[0] = pixel_center_correction * pixel_size_x;
|
||||
constants.pixelcentercorrection[1] = pixel_center_correction * pixel_size_y;
|
||||
|
||||
if (g_ActiveConfig.backend_info.bSupportsDepthClamp &&
|
||||
((fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f) ||
|
||||
(xfmem.viewport.zRange < 0.0f &&
|
||||
!g_ActiveConfig.backend_info.bSupportsReversedDepthRange)))
|
||||
{
|
||||
// The depth range is handled in the vertex shader. We need to reverse
|
||||
// the far value to get a reversed depth range mapping. This is necessary
|
||||
// because the standard depth range equation pushes all depth values towards
|
||||
@ -412,6 +417,12 @@ void VertexShaderManager::SetConstants()
|
||||
constants.pixelcentercorrection[2] = xfmem.viewport.zRange / 16777215.0f;
|
||||
constants.pixelcentercorrection[3] = 1.0f - xfmem.viewport.farZ / 16777215.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
constants.pixelcentercorrection[2] = 1.0f;
|
||||
constants.pixelcentercorrection[3] = 0.0f;
|
||||
}
|
||||
|
||||
dirty = true;
|
||||
// This is so implementation-dependent that we can't have it here.
|
||||
|
Loading…
x
Reference in New Issue
Block a user