diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj
index 831dcad4a7..b4a0f1fba5 100644
--- a/Source/Core/Common/Common.vcxproj
+++ b/Source/Core/Common/Common.vcxproj
@@ -105,6 +105,7 @@
+
diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters
index 3c9b952742..77d639045a 100644
--- a/Source/Core/Common/Common.vcxproj.filters
+++ b/Source/Core/Common/Common.vcxproj.filters
@@ -218,6 +218,9 @@
GL\GLExtensions
+
+ GL\GLExtensions
+
GL\GLInterface
diff --git a/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp b/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp
index 591792468e..ff252bb1f7 100644
--- a/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp
+++ b/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp
@@ -984,6 +984,11 @@ PFNDOLCOPYIMAGESUBDATAPROC dolCopyImageSubData;
// ARB_shader_storage_buffer_object
PFNDOLSHADERSTORAGEBLOCKBINDINGPROC dolShaderStorageBlockBinding;
+// NV_depth_buffer_float
+PFNDOLDEPTHRANGEDNVPROC dolDepthRangedNV;
+PFNDOLCLEARDEPTHDNVPROC dolClearDepthdNV;
+PFNDOLDEPTHBOUNDSDNVPROC dolDepthBoundsdNV;
+
// Creates a GLFunc object that requires a feature
#define GLFUNC_REQUIRES(x, y) \
{ \
@@ -1838,6 +1843,11 @@ const GLFunc gl_function_array[] = {
// ARB_shader_storage_buffer_object
GLFUNC_REQUIRES(glShaderStorageBlockBinding, "ARB_shader_storage_buffer_object !VERSION_4_3"),
+
+ // NV_depth_buffer_float
+ GLFUNC_REQUIRES(glDepthRangedNV, "GL_NV_depth_buffer_float"),
+ GLFUNC_REQUIRES(glClearDepthdNV, "GL_NV_depth_buffer_float"),
+ GLFUNC_REQUIRES(glDepthBoundsdNV, "GL_NV_depth_buffer_float"),
};
namespace GLExtensions
@@ -2060,26 +2070,21 @@ static void InitExtensionList()
// Quite a lot of these had their names changed when merged in to core
// Disable the ones that have
std::string gl300exts[] = {
- "GL_ARB_map_buffer_range",
+ "GL_ARB_map_buffer_range", "GL_ARB_color_buffer_float", "GL_ARB_texture_float",
+ "GL_ARB_half_float_pixel", "GL_ARB_framebuffer_object", "GL_ARB_texture_float",
+ "GL_ARB_vertex_array_object", "GL_NV_depth_buffer_float",
+ //"GL_EXT_texture_integer",
//"GL_EXT_gpu_shader4",
//"GL_APPLE_flush_buffer_range",
- "GL_ARB_color_buffer_float",
- //"GL_NV_depth_buffer_float",
- "GL_ARB_texture_float",
//"GL_EXT_packed_float",
//"GL_EXT_texture_shared_exponent",
- "GL_ARB_half_float_pixel",
//"GL_NV_half_float",
- "GL_ARB_framebuffer_object",
//"GL_EXT_framebuffer_sRGB",
- "GL_ARB_texture_float",
- //"GL_EXT_texture_integer",
//"GL_EXT_draw_buffers2",
//"GL_EXT_texture_integer",
//"GL_EXT_texture_array",
//"GL_EXT_texture_compression_rgtc",
//"GL_EXT_transform_feedback",
- "GL_ARB_vertex_array_object",
//"GL_NV_conditional_render",
"VERSION_3_0",
};
diff --git a/Source/Core/Common/GL/GLExtensions/GLExtensions.h b/Source/Core/Common/GL/GLExtensions/GLExtensions.h
index fa00aa4a97..4c58167700 100644
--- a/Source/Core/Common/GL/GLExtensions/GLExtensions.h
+++ b/Source/Core/Common/GL/GLExtensions/GLExtensions.h
@@ -31,6 +31,7 @@
#include "Common/GL/GLExtensions/EXT_texture_filter_anisotropic.h"
#include "Common/GL/GLExtensions/HP_occlusion_test.h"
#include "Common/GL/GLExtensions/KHR_debug.h"
+#include "Common/GL/GLExtensions/NV_depth_buffer_float.h"
#include "Common/GL/GLExtensions/NV_occlusion_query_samples.h"
#include "Common/GL/GLExtensions/NV_primitive_restart.h"
#include "Common/GL/GLExtensions/gl_1_1.h"
diff --git a/Source/Core/Common/GL/GLExtensions/NV_depth_buffer_float.h b/Source/Core/Common/GL/GLExtensions/NV_depth_buffer_float.h
new file mode 100644
index 0000000000..7912c55ba2
--- /dev/null
+++ b/Source/Core/Common/GL/GLExtensions/NV_depth_buffer_float.h
@@ -0,0 +1,41 @@
+/*
+** Copyright (c) 2013-2015 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+#include "Common/GL/GLExtensions/gl_common.h"
+
+#define GL_DEPTH_COMPONENT32F_NV 0x8DAB
+#define GL_DEPTH32F_STENCIL8_NV 0x8DAC
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD
+#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF
+
+typedef void(APIENTRYP PFNDOLDEPTHRANGEDNVPROC)(GLdouble zNear, GLdouble zFar);
+typedef void(APIENTRYP PFNDOLCLEARDEPTHDNVPROC)(GLdouble depth);
+typedef void(APIENTRYP PFNDOLDEPTHBOUNDSDNVPROC)(GLdouble zmin, GLdouble zmax);
+
+extern PFNDOLDEPTHRANGEDNVPROC dolDepthRangedNV;
+extern PFNDOLCLEARDEPTHDNVPROC dolClearDepthdNV;
+extern PFNDOLDEPTHBOUNDSDNVPROC dolDepthBoundsdNV;
+
+#define glDepthRangedNV dolDepthRangedNV
+#define glClearDepthdNV dolClearDepthdNV
+#define glDepthBoundsdNV dolDepthBoundsdNV
diff --git a/Source/Core/Core/Analytics.cpp b/Source/Core/Core/Analytics.cpp
index 8638b79dba..7c71446565 100644
--- a/Source/Core/Core/Analytics.cpp
+++ b/Source/Core/Core/Analytics.cpp
@@ -234,6 +234,8 @@ void DolphinAnalytics::MakePerGameBuilder()
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-oversized-depth-ranges",
+ g_Config.backend_info.bSupportsOversizedDepthRanges);
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/main.cpp b/Source/Core/VideoBackends/D3D/main.cpp
index fe32d89603..4f2a32d32e 100644
--- a/Source/Core/VideoBackends/D3D/main.cpp
+++ b/Source/Core/VideoBackends/D3D/main.cpp
@@ -64,6 +64,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsDualSourceBlend = true;
g_Config.backend_info.bSupportsPrimitiveRestart = true;
g_Config.backend_info.bSupportsOversizedViewports = false;
+ g_Config.backend_info.bSupportsOversizedDepthRanges = false;
g_Config.backend_info.bSupportsGeometryShaders = true;
g_Config.backend_info.bSupports3DVision = true;
g_Config.backend_info.bSupportsPostProcessing = false;
diff --git a/Source/Core/VideoBackends/D3D12/main.cpp b/Source/Core/VideoBackends/D3D12/main.cpp
index ef377bab41..7d903bae63 100644
--- a/Source/Core/VideoBackends/D3D12/main.cpp
+++ b/Source/Core/VideoBackends/D3D12/main.cpp
@@ -68,6 +68,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsDualSourceBlend = true;
g_Config.backend_info.bSupportsPrimitiveRestart = true;
g_Config.backend_info.bSupportsOversizedViewports = false;
+ g_Config.backend_info.bSupportsOversizedDepthRanges = false;
g_Config.backend_info.bSupportsGeometryShaders = true;
g_Config.backend_info.bSupports3DVision = true;
g_Config.backend_info.bSupportsPostProcessing = false;
diff --git a/Source/Core/VideoBackends/Null/NullBackend.cpp b/Source/Core/VideoBackends/Null/NullBackend.cpp
index 1e3117088e..854b8450a4 100644
--- a/Source/Core/VideoBackends/Null/NullBackend.cpp
+++ b/Source/Core/VideoBackends/Null/NullBackend.cpp
@@ -28,6 +28,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsDualSourceBlend = true;
g_Config.backend_info.bSupportsPrimitiveRestart = true;
g_Config.backend_info.bSupportsOversizedViewports = true;
+ g_Config.backend_info.bSupportsOversizedDepthRanges = 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/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index f55d06ecbc..abee545ba4 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -474,6 +474,8 @@ Renderer::Renderer()
// Clip distance support is useless without a method to clamp the depth range
g_Config.backend_info.bSupportsDepthClamp = GLExtensions::Supports("GL_ARB_depth_clamp");
+ g_Config.backend_info.bSupportsOversizedDepthRanges =
+ GLExtensions::Supports("GL_NV_depth_buffer_float");
g_ogl_config.bSupportsGLSLCache = GLExtensions::Supports("GL_ARB_get_program_binary");
g_ogl_config.bSupportsGLPinnedMemory = GLExtensions::Supports("GL_AMD_pinned_memory");
@@ -666,7 +668,7 @@ Renderer::Renderer()
g_ogl_config.gl_renderer, g_ogl_config.gl_version),
5000);
- WARN_LOG(VIDEO, "Missing OGL Extensions: %s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ WARN_LOG(VIDEO, "Missing OGL Extensions: %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
g_ActiveConfig.backend_info.bSupportsDualSourceBlend ? "" : "DualSourceBlend ",
g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? "" : "PrimitiveRestart ",
g_ActiveConfig.backend_info.bSupportsEarlyZ ? "" : "EarlyZ ",
@@ -679,7 +681,8 @@ Renderer::Renderer()
g_ActiveConfig.backend_info.bSupportsGSInstancing ? "" : "GSInstancing ",
g_ActiveConfig.backend_info.bSupportsClipControl ? "" : "ClipControl ",
g_ogl_config.bSupportsCopySubImage ? "" : "CopyImageSubData ",
- g_ActiveConfig.backend_info.bSupportsDepthClamp ? "" : "DepthClamp ");
+ g_ActiveConfig.backend_info.bSupportsDepthClamp ? "" : "DepthClamp ",
+ g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges ? "" : "DepthRangedNV ");
s_last_multisamples = g_ActiveConfig.iMultisamples;
s_MSAASamples = s_last_multisamples;
@@ -1108,10 +1111,6 @@ void Renderer::SetViewport()
(float)scissorYOff);
float Width = EFBToScaledXf(2.0f * xfmem.viewport.wd);
float Height = EFBToScaledYf(-2.0f * xfmem.viewport.ht);
- float range = MathUtil::Clamp(xfmem.viewport.zRange, -16777215.0f, 16777215.0f);
- float min_depth =
- MathUtil::Clamp(xfmem.viewport.farZ - range, 0.0f, 16777215.0f) / 16777216.0f;
- float max_depth = MathUtil::Clamp(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f;
if (Width < 0)
{
X += Width;
@@ -1123,24 +1122,6 @@ void Renderer::SetViewport()
Height *= -1;
}
- // If an oversized depth range is used, we need to calculate the depth range in the vertex shader.
- if (g_ActiveConfig.backend_info.bSupportsDepthClamp &&
- (fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f))
- {
- // 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.
- if (xfmem.viewport.zRange < 0.0f)
- {
- min_depth = GX_MAX_DEPTH;
- max_depth = 0.0f;
- }
- else
- {
- min_depth = 0.0f;
- max_depth = GX_MAX_DEPTH;
- }
- }
-
// Update the view port
if (g_ogl_config.bSupportViewportFloat)
{
@@ -1153,7 +1134,40 @@ void Renderer::SetViewport()
}
// Set the reversed depth range.
- glDepthRangef(max_depth, min_depth);
+ if (g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges)
+ {
+ float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
+ float max_depth = xfmem.viewport.farZ / 16777216.0f;
+ glDepthRangedNV(max_depth, min_depth);
+ }
+ else
+ {
+ float range = MathUtil::Clamp(xfmem.viewport.zRange, -16777216.0f, 16777216.0f);
+ float min_depth =
+ MathUtil::Clamp(xfmem.viewport.farZ - range, 0.0f, 16777215.0f) / 16777216.0f;
+ float max_depth = MathUtil::Clamp(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f;
+
+ // If an oversized depth range is used, we need to calculate the depth range in the
+ // vertex shader.
+ if (g_ActiveConfig.backend_info.bSupportsDepthClamp &&
+ (fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f))
+ {
+ // 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.
+ if (xfmem.viewport.zRange < 0.0f)
+ {
+ min_depth = GX_MAX_DEPTH;
+ max_depth = 0.0f;
+ }
+ else
+ {
+ min_depth = 0.0f;
+ max_depth = GX_MAX_DEPTH;
+ }
+ }
+
+ glDepthRangef(max_depth, min_depth);
+ }
}
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
diff --git a/Source/Core/VideoBackends/OGL/main.cpp b/Source/Core/VideoBackends/OGL/main.cpp
index 0d46982cca..fa08587ca1 100644
--- a/Source/Core/VideoBackends/OGL/main.cpp
+++ b/Source/Core/VideoBackends/OGL/main.cpp
@@ -107,6 +107,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsInternalResolutionFrameDumps = true;
// Overwritten in Render.cpp later
+ g_Config.backend_info.bSupportsOversizedDepthRanges = false;
g_Config.backend_info.bSupportsDualSourceBlend = true;
g_Config.backend_info.bSupportsPrimitiveRestart = true;
g_Config.backend_info.bSupportsPaletteConversion = true;
diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp
index adbe5046b6..e840ac4921 100644
--- a/Source/Core/VideoBackends/Software/SWmain.cpp
+++ b/Source/Core/VideoBackends/Software/SWmain.cpp
@@ -128,6 +128,7 @@ void VideoSoftware::InitBackendInfo()
g_Config.backend_info.bSupportsDualSourceBlend = true;
g_Config.backend_info.bSupportsEarlyZ = true;
g_Config.backend_info.bSupportsOversizedViewports = true;
+ g_Config.backend_info.bSupportsOversizedDepthRanges = true;
g_Config.backend_info.bSupportsPrimitiveRestart = false;
g_Config.backend_info.bSupportsMultithreading = false;
g_Config.backend_info.bSupportsInternalResolutionFrameDumps = false;
diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
index 7dc809e6b2..d3f981e5f5 100644
--- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
+++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
@@ -225,15 +225,16 @@ VulkanContext::GPUList VulkanContext::EnumerateGPUs(VkInstance instance)
void VulkanContext::PopulateBackendInfo(VideoConfig* config)
{
config->backend_info.api_type = APIType::Vulkan;
- config->backend_info.bSupportsExclusiveFullscreen = false; // Currently WSI does not allow this.
- 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.
- config->backend_info.bSupportsPaletteConversion = true; // Assumed support.
- config->backend_info.bSupportsClipControl = true; // Assumed support.
- config->backend_info.bSupportsMultithreading = true; // Assumed support.
+ config->backend_info.bSupportsExclusiveFullscreen = false; // Currently WSI does not allow this.
+ config->backend_info.bSupports3DVision = false; // D3D-exclusive.
+ config->backend_info.bSupportsOversizedViewports = true; // Assumed support.
+ config->backend_info.bSupportsOversizedDepthRanges = false; // No support yet.
+ config->backend_info.bSupportsEarlyZ = true; // Assumed support.
+ config->backend_info.bSupportsPrimitiveRestart = true; // Assumed support.
+ config->backend_info.bSupportsBindingLayout = false; // Assumed support.
+ config->backend_info.bSupportsPaletteConversion = true; // Assumed support.
+ config->backend_info.bSupportsClipControl = true; // Assumed support.
+ config->backend_info.bSupportsMultithreading = true; // Assumed support.
config->backend_info.bSupportsInternalResolutionFrameDumps = true; // Assumed support.
config->backend_info.bSupportsPostProcessing = false; // No support yet.
config->backend_info.bSupportsDualSourceBlend = false; // Dependent on features.
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp
index e516c2c63c..ed8d52efb7 100644
--- a/Source/Core/VideoCommon/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexShaderManager.cpp
@@ -391,7 +391,8 @@ void VertexShaderManager::SetConstants()
constants.pixelcentercorrection[2] = 1.0f;
constants.pixelcentercorrection[3] = 0.0f;
- if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
+ if (g_ActiveConfig.backend_info.bSupportsDepthClamp &&
+ !g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges)
{
// Oversized depth ranges are handled in the vertex shader. We need to reverse
// the far value to get a reversed depth range mapping. This is necessary
diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h
index 9e6b0180f3..2972dca664 100644
--- a/Source/Core/VideoCommon/VideoConfig.h
+++ b/Source/Core/VideoCommon/VideoConfig.h
@@ -172,6 +172,7 @@ struct VideoConfig final
bool bSupportsDualSourceBlend;
bool bSupportsPrimitiveRestart;
bool bSupportsOversizedViewports;
+ bool bSupportsOversizedDepthRanges;
bool bSupportsGeometryShaders;
bool bSupports3DVision;
bool bSupportsEarlyZ; // needed by PixelShaderGen, so must stay in VideoCommon