Merge pull request #2419 from Armada651/clip-control

OGL: Add glClipControl support.
This commit is contained in:
Markus Wick 2015-05-25 09:29:43 +02:00
commit 732802ebd0
10 changed files with 1031 additions and 163 deletions

1153
Externals/GL/GL/glext.h vendored

File diff suppressed because it is too large Load Diff

View File

@ -83,6 +83,7 @@ void InitBackendInfo()
g_Config.backend_info.bSupports3DVision = true;
g_Config.backend_info.bSupportsPostProcessing = false;
g_Config.backend_info.bSupportsPaletteConversion = true;
g_Config.backend_info.bSupportsClipControl = false;
IDXGIFactory* factory;
IDXGIAdapter* ad;

View File

@ -0,0 +1,8 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "VideoBackends/OGL/GLExtensions/gl_common.h"
extern PFNGLCLIPCONTROLPROC glClipControl;

View File

@ -785,6 +785,9 @@ PFNGLENDOCCLUSIONQUERYNVPROC glEndOcclusionQueryNV;
PFNGLGETOCCLUSIONQUERYIVNVPROC glGetOcclusionQueryivNV;
PFNGLGETOCCLUSIONQUERYUIVNVPROC glGetOcclusionQueryuivNV;
// ARB_clip_control
PFNGLCLIPCONTROLPROC glClipControl;
// Creates a GLFunc object that requires a feature
#define GLFUNC_REQUIRES(x, y) { (void**)&x, #x, y }
// Creates a GLFunc object with a different function suffix
@ -1272,6 +1275,9 @@ const GLFunc gl_function_array[] =
GLFUNC_REQUIRES(glGetOcclusionQueryivNV, "GL_NV_occlusion_query_samples"),
GLFUNC_REQUIRES(glGetOcclusionQueryuivNV, "GL_NV_occlusion_query_samples"),
// ARB_clip_control
GLFUNC_REQUIRES(glClipControl, "GL_ARB_clip_control"),
// gl_1_1
// OpenGL 1.1 is at the end due to a bug in Android's EGL stack.
// eglGetProcAddress can only return a finite amount of function pointers

View File

@ -8,6 +8,7 @@
#include "VideoBackends/OGL/GLExtensions/ARB_blend_func_extended.h"
#include "VideoBackends/OGL/GLExtensions/ARB_buffer_storage.h"
#include "VideoBackends/OGL/GLExtensions/ARB_clip_control.h"
#include "VideoBackends/OGL/GLExtensions/ARB_debug_output.h"
#include "VideoBackends/OGL/GLExtensions/ARB_draw_elements_base_vertex.h"
#include "VideoBackends/OGL/GLExtensions/ARB_ES2_compatibility.h"

View File

@ -59,6 +59,7 @@
<ClInclude Include="FramebufferManager.h" />
<ClInclude Include="GLExtensions\ARB_blend_func_extended.h" />
<ClInclude Include="GLExtensions\ARB_buffer_storage.h" />
<ClInclude Include="GLExtensions\ARB_clip_control.h" />
<ClInclude Include="GLExtensions\ARB_debug_output.h" />
<ClInclude Include="GLExtensions\ARB_draw_elements_base_vertex.h" />
<ClInclude Include="GLExtensions\ARB_ES2_compatibility.h" />

View File

@ -199,6 +199,9 @@
<ClInclude Include="GLInterface\WGL.h">
<Filter>GLInterface</Filter>
</ClInclude>
<ClInclude Include="GLExtensions\ARB_clip_control.h">
<Filter>GLExtensions</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />

View File

@ -468,6 +468,7 @@ Renderer::Renderer()
g_Config.backend_info.bSupportsGSInstancing = GLExtensions::Supports("GL_ARB_gpu_shader5");
g_Config.backend_info.bSupportsGeometryShaders = GLExtensions::Version() >= 320;
g_Config.backend_info.bSupportsPaletteConversion = GLExtensions::Supports("GL_ARB_texture_buffer_object");
g_Config.backend_info.bSupportsClipControl = GLExtensions::Supports("GL_ARB_clip_control");
// Desktop OpenGL supports the binding layout if it supports 420pack
// OpenGL ES 3.1 supports it implicitly without an extension
@ -480,7 +481,7 @@ Renderer::Renderer()
GLExtensions::Supports("GL_EXT_draw_elements_base_vertex") ||
GLExtensions::Supports("GL_OES_draw_elements_base_vertex");
g_ogl_config.bSupportsGLBufferStorage = GLExtensions::Supports("GL_ARB_buffer_storage") ||
GLExtensions::Supports("GL_EXT_buffer_storage");;
GLExtensions::Supports("GL_EXT_buffer_storage");
g_ogl_config.bSupportsMSAA = GLExtensions::Supports("GL_ARB_texture_multisample");
g_ogl_config.bSupportSampleShading = GLExtensions::Supports("GL_ARB_sample_shading");
g_ogl_config.bSupportOGL31 = GLExtensions::Version() >= 310;
@ -585,7 +586,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",
WARN_LOG(VIDEO,"Missing OGL Extensions: %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 ",
@ -596,7 +597,8 @@ Renderer::Renderer()
g_ogl_config.bSupportsGLSync ? "" : "Sync ",
g_ogl_config.bSupportsMSAA ? "" : "MSAA ",
g_ogl_config.bSupportSampleShading ? "" : "SSAA ",
g_ActiveConfig.backend_info.bSupportsGSInstancing ? "" : "GSInstancing "
g_ActiveConfig.backend_info.bSupportsGSInstancing ? "" : "GSInstancing ",
g_ActiveConfig.backend_info.bSupportsClipControl ? "" : "ClipControl "
);
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
@ -633,6 +635,8 @@ Renderer::Renderer()
glBlendFunc(GL_ONE, GL_ONE);
glViewport(0, 0, GetTargetWidth(), GetTargetHeight()); // Reset The Current Viewport
if (g_ActiveConfig.backend_info.bSupportsClipControl)
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearDepthf(1.0f);
@ -1241,7 +1245,7 @@ void Renderer::SetViewport()
};
glViewport(iceilf(X), iceilf(Y), iceilf(Width), iceilf(Height));
}
glDepthRangef(GLNear, GLFar);
glDepthRangef(GLFar, GLNear);
}
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)

View File

@ -379,7 +379,11 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
//write the true depth value, if the game uses depth textures pixel shaders will override with the correct values
//if not early z culling will improve speed
if (api_type == API_D3D)
if (g_ActiveConfig.backend_info.bSupportsClipControl)
{
out.Write("o.pos.z = -o.pos.z;\n");
}
else if (api_type == API_D3D)
{
out.Write("o.pos.z = o.pos.w + o.pos.z;\n");
}
@ -387,7 +391,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
{
// this results in a scale from -1..0 to -1..1 after perspective
// divide
out.Write("o.pos.z = o.pos.w + o.pos.z * 2.0;\n");
out.Write("o.pos.z = o.pos.z * -2.0 - o.pos.w;\n");
// the next steps of the OGL pipeline are:
// (x_c,y_c,z_c,w_c) = o.pos //switch to OGL spec terminology

View File

@ -159,6 +159,7 @@ struct VideoConfig final
bool bSupportsGSInstancing; // Needed by GeometryShaderGen, so must stay in VideoCommon
bool bSupportsPostProcessing;
bool bSupportsPaletteConversion;
bool bSupportsClipControl; // Needed by VertexShaderGen, so must stay in VideoCommon
} backend_info;
// Utility