mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-07-11 01:34:17 +02:00
GS/GL: Add basic clip control fallback.
When GLAD_GL_ARB_clip_control is not supported then change the vertex shader depth ranges to make sure it matches -1 1.
This commit is contained in:
@@ -83,7 +83,13 @@ void vs_main()
|
||||
// example: 133.0625 (133 + 1/16) should start from line 134, ceil(133.0625 - 0.05) still above 133
|
||||
gl_Position.xy = vec2(i_p) - vec2(0.05f, 0.05f);
|
||||
gl_Position.xy = gl_Position.xy * VertexScale - VertexOffset;
|
||||
gl_Position.z = float(z) * exp_min32;
|
||||
|
||||
#if HAS_CLIP_CONTROL
|
||||
gl_Position.z = float(z) * exp_min32;
|
||||
#else
|
||||
gl_Position.z = (float(z) * exp_min32) * 2.0f - 1.0f;
|
||||
#endif
|
||||
|
||||
gl_Position.w = 1.0f;
|
||||
|
||||
texture_coord();
|
||||
@@ -160,7 +166,13 @@ ProcessedVertex load_vertex(uint index)
|
||||
uint z = min(i_z, MaxDepth);
|
||||
vtx.p.xy = vec2(i_p) - vec2(0.05f, 0.05f);
|
||||
vtx.p.xy = vtx.p.xy * VertexScale - VertexOffset;
|
||||
vtx.p.z = float(z) * exp_min32;
|
||||
|
||||
#if HAS_CLIP_CONTROL
|
||||
vtx.p.z = float(z) * exp_min32;
|
||||
#else
|
||||
vtx.p.z = (float(z) * exp_min32) * 2.0f - 1.0f;
|
||||
#endif
|
||||
|
||||
vtx.p.w = 1.0f;
|
||||
|
||||
vec2 uv = vec2(i_uv) - TextureOffset;
|
||||
|
||||
@@ -626,7 +626,8 @@ bool GSDeviceOGL::Create(GSVSyncMode vsync_mode, bool allow_present_throttle)
|
||||
// This extension allow FS depth to range from -1 to 1. So
|
||||
// gl_position.z could range from [0, 1]
|
||||
// Change depth convention
|
||||
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
||||
if (GLAD_GL_ARB_clip_control)
|
||||
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
||||
|
||||
// ****************************************************************
|
||||
// HW renderer shader
|
||||
@@ -778,15 +779,14 @@ bool GSDeviceOGL::CheckFeatures()
|
||||
|
||||
if (!GLAD_GL_VERSION_4_3 && !GLAD_GL_ARB_copy_image && !GLAD_GL_EXT_copy_image && !GLAD_GL_NV_copy_image)
|
||||
{
|
||||
Host::ReportFormattedErrorAsync(
|
||||
"GS", "GL_ARB_copy_image is not supported, copies will be slower.");
|
||||
Host::AddOSDMessage(
|
||||
"GL_ARB_copy_image is not supported, copies will be slower.", Host::OSD_ERROR_DURATION);
|
||||
}
|
||||
|
||||
if (!GLAD_GL_VERSION_4_5 && !GLAD_GL_ARB_clip_control)
|
||||
{
|
||||
Host::ReportFormattedErrorAsync(
|
||||
"GS", "GL_ARB_clip_control is not supported, this is required for the OpenGL renderer.");
|
||||
return false;
|
||||
Host::AddOSDMessage(
|
||||
"GL_ARB_clip_control is not supported, depth will be less accurate.", Host::OSD_ERROR_DURATION);
|
||||
}
|
||||
|
||||
if (!GLAD_GL_ARB_viewport_array)
|
||||
@@ -1498,6 +1498,11 @@ std::string GSDeviceOGL::GenGlslHeader(const std::string_view entry, GLenum type
|
||||
header += "#define DEPTH_FEEDBACK_SUPPORT 2\n"; // Depth as RT
|
||||
}
|
||||
|
||||
if (GLAD_GL_ARB_clip_control)
|
||||
header += "#define HAS_CLIP_CONTROL 1\n";
|
||||
else
|
||||
header += "#define HAS_CLIP_CONTROL 0\n";
|
||||
|
||||
// Allow to puts several shader in 1 files
|
||||
switch (type)
|
||||
{
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
/// Version number for GS and other shaders. Increment whenever any of the contents of the
|
||||
/// shaders change, to invalidate the cache.
|
||||
static constexpr u32 SHADER_CACHE_VERSION = 100; // Last changed in PR 14503
|
||||
static constexpr u32 SHADER_CACHE_VERSION = 101; // Last changed in PR 14547
|
||||
|
||||
Reference in New Issue
Block a user