mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl-wnd:
* fix a bad interaction when GL_ARB_SSO is supported without GL_ARB_shading_language_420pack * try to replace struct with flat parameter in glsl interface => with some hacks of the free driver, I was able to compile SW renderer shader. Unfortunately the rendering is broken. Maybe my hack :p * remove EGL context check (wasn't working as expected) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl-wnd@5644 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
c9b3dcf581
commit
aafa7a088a
|
@ -14,8 +14,6 @@ INCLUDE(CheckCXXSymbolExists)
|
|||
# include dir
|
||||
find_path(EGL_INCLUDE_DIR EGL/eglext.h)
|
||||
|
||||
CHECK_CXX_SYMBOL_EXISTS(EGL_KHR_create_context "EGL/eglext.h" EGL_GL_CONTEXT_SUPPORT)
|
||||
|
||||
# finally the library itself
|
||||
find_library(libEGL NAMES EGL)
|
||||
set(EGL_LIBRARIES ${libEGL})
|
||||
|
|
|
@ -47,11 +47,7 @@ endif(XDG_STD)
|
|||
|
||||
# Select the EGL API
|
||||
if(EGL_API AND EGL_FOUND)
|
||||
if (EGL_GL_CONTEXT_SUPPORT)
|
||||
add_definitions(-DEGL_API)
|
||||
else()
|
||||
message(WARNING "Current EGL implementation doesn't support openGL context. Fallback to standard GLX.")
|
||||
endif()
|
||||
add_definitions(-DEGL_API)
|
||||
endif()
|
||||
|
||||
set(GSdxSources
|
||||
|
@ -193,7 +189,7 @@ add_library(${Output} SHARED ${GSdxSources} ${GSdxHeaders})
|
|||
|
||||
target_link_libraries(${Output} ${X11_LIBRARIES})
|
||||
target_link_libraries(${Output} ${OPENGL_LIBRARIES})
|
||||
if(EGL_API AND EGL_FOUND AND EGL_GL_CONTEXT_SUPPORT)
|
||||
if(EGL_API AND EGL_FOUND)
|
||||
target_link_libraries(${Output} ${EGL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
|
|||
// NO GL4.1
|
||||
PFNGLUSEPROGRAMPROC gl_UseProgram = NULL;
|
||||
PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog = NULL;
|
||||
PFNGLPROGRAMUNIFORM1IPROC gl_ProgramUniform1i = NULL;
|
||||
// NO GL4.2
|
||||
PFNGLGETUNIFORMBLOCKINDEXPROC gl_GetUniformBlockIndex = NULL;
|
||||
PFNGLUNIFORMBLOCKBINDINGPROC gl_UniformBlockBinding = NULL;
|
||||
|
@ -190,6 +191,7 @@ namespace GLLoader {
|
|||
// NO GL4.1
|
||||
GL_LOADFN(gl_UseProgram, glUseProgram);
|
||||
GL_LOADFN(gl_GetShaderInfoLog, glGetShaderInfoLog);
|
||||
GL_LOADFN(gl_ProgramUniform1i, glProgramUniform1i);
|
||||
// NO GL4.2
|
||||
GL_LOADFN(gl_GetUniformBlockIndex, glGetUniformBlockIndex);
|
||||
GL_LOADFN(gl_UniformBlockBinding, glUniformBlockBinding);
|
||||
|
@ -231,6 +233,10 @@ namespace GLLoader {
|
|||
return false;
|
||||
}
|
||||
|
||||
// REMOVE ME: Emulate open source driver
|
||||
// found_GL_ARB_shading_language_420pack = false;
|
||||
// found_GL_ARB_separate_shader_objects = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D;
|
|||
// NO GL4.1
|
||||
extern PFNGLUSEPROGRAMPROC gl_UseProgram;
|
||||
extern PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog;
|
||||
extern PFNGLPROGRAMUNIFORM1IPROC gl_ProgramUniform1i;
|
||||
// NO GL4.2
|
||||
extern PFNGLGETUNIFORMBLOCKINDEXPROC gl_GetUniformBlockIndex;
|
||||
extern PFNGLUNIFORMBLOCKBINDINGPROC gl_UniformBlockBinding;
|
||||
|
|
|
@ -475,11 +475,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef OGL_FREE_DRIVER
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GSDeviceOGL::Reset(int w, int h)
|
||||
|
@ -602,7 +598,11 @@ static void set_uniform_buffer_binding(GLuint prog, GLchar* name, GLuint binding
|
|||
static void set_sampler_uniform_binding(GLuint prog, GLchar* name, GLuint binding) {
|
||||
GLint loc = gl_GetUniformLocation(prog, name);
|
||||
if (loc != -1) {
|
||||
gl_Uniform1i(loc, binding);
|
||||
if (GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||
gl_ProgramUniform1i(prog, loc, binding);
|
||||
} else {
|
||||
gl_Uniform1i(loc, binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1345,6 +1345,10 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
|
|||
}
|
||||
if (GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||
version += "#extension GL_ARB_separate_shader_objects : require\n";
|
||||
// REMOVE ME: Emulate open source driver
|
||||
//if (!GLLoader::found_GL_ARB_shading_language_420pack) {
|
||||
// version += "#define NO_STRUCT 1\n";
|
||||
//}
|
||||
}
|
||||
#ifdef OGL_FREE_DRIVER
|
||||
version += "#extension GL_ARB_explicit_attrib_location : require\n";
|
||||
|
|
|
@ -127,6 +127,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
|
|||
// Require a recent GLEW and GL4.3
|
||||
//gl_TexStorage2DMultisample(m_texture_target, msaa_level, m_format, m_size.x, m_size.y, false);
|
||||
} else {
|
||||
//glTexParameteri(m_texture_target, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
gl_TexStorage2D(m_texture_target, 1, m_format, m_size.x, m_size.y);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -134,7 +134,11 @@ bool GSWndOGL::Attach(void* handle, bool managed)
|
|||
m_NativeDisplay = XOpenDisplay(NULL);
|
||||
|
||||
// Note: 4.2 crash on latest nvidia drivers!
|
||||
#ifdef OGL_FREE_DRIVER
|
||||
if (!CreateContext(3, 0)) return false;
|
||||
#else
|
||||
if (!CreateContext(3, 3)) return false;
|
||||
#endif
|
||||
|
||||
AttachContext();
|
||||
|
||||
|
|
|
@ -28,12 +28,21 @@ layout(location = 1) in vec2 TEXCOORD0;
|
|||
// smooth, the default, means to do perspective-correct interpolation.
|
||||
//
|
||||
// The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area.
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) out vertex_basic VSout;
|
||||
#define VSout_p (VSout.p)
|
||||
#define VSout_t (VSout.t)
|
||||
#else
|
||||
layout(location = 0) out vec4 p;
|
||||
layout(location = 1) out vec2 t;
|
||||
#define VSout_p p
|
||||
#define VSout_t t
|
||||
#endif
|
||||
|
||||
void vs_main()
|
||||
{
|
||||
VSout.p = POSITION;
|
||||
VSout.t = TEXCOORD0;
|
||||
VSout_p = POSITION;
|
||||
VSout_t = TEXCOORD0;
|
||||
gl_Position = POSITION; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position
|
||||
}
|
||||
|
||||
|
@ -42,7 +51,16 @@ void vs_main()
|
|||
#ifdef FRAGMENT_SHADER
|
||||
// NOTE: pixel can be clip with "discard"
|
||||
|
||||
#if __VERSION__ > 140
|
||||
layout(location = 0) in vertex_basic PSin;
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
#else
|
||||
layout(location = 0) in vec4 p;
|
||||
layout(location = 1) in vec2 t;
|
||||
#define PSin_p p
|
||||
#define PSin_t t
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 SV_Target0;
|
||||
layout(location = 1) out uint SV_Target1;
|
||||
|
@ -55,7 +73,7 @@ layout(binding = 0) uniform sampler2D TextureSampler;
|
|||
|
||||
vec4 sample_c()
|
||||
{
|
||||
return texture(TextureSampler, PSin.t );
|
||||
return texture(TextureSampler, PSin_t );
|
||||
}
|
||||
|
||||
uniform vec4 mask[4] = vec4[4]
|
||||
|
@ -99,7 +117,7 @@ void ps_main7()
|
|||
|
||||
void ps_main5() // triangular
|
||||
{
|
||||
highp uvec4 p = uvec4(PSin.p);
|
||||
highp uvec4 p = uvec4(PSin_p);
|
||||
|
||||
vec4 c = ps_crt(((p.x + ((p.y >> 1u) & 1u) * 3u) >> 1u) % 3u);
|
||||
|
||||
|
@ -108,7 +126,7 @@ void ps_main5() // triangular
|
|||
|
||||
void ps_main6() // diagonal
|
||||
{
|
||||
uvec4 p = uvec4(PSin.p);
|
||||
uvec4 p = uvec4(PSin_p);
|
||||
|
||||
vec4 c = ps_crt((p.x + (p.y % 3u)) % 3u);
|
||||
|
||||
|
|
|
@ -56,12 +56,21 @@ static const char* convert_glsl =
|
|||
"// smooth, the default, means to do perspective-correct interpolation.\n"
|
||||
"//\n"
|
||||
"// The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area.\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) out vertex_basic VSout;\n"
|
||||
"#define VSout_p (VSout.p)\n"
|
||||
"#define VSout_t (VSout.t)\n"
|
||||
"#else\n"
|
||||
"layout(location = 0) out vec4 p;\n"
|
||||
"layout(location = 1) out vec2 t;\n"
|
||||
"#define VSout_p p\n"
|
||||
"#define VSout_t t\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"void vs_main()\n"
|
||||
"{\n"
|
||||
" VSout.p = POSITION;\n"
|
||||
" VSout.t = TEXCOORD0;\n"
|
||||
" VSout_p = POSITION;\n"
|
||||
" VSout_t = TEXCOORD0;\n"
|
||||
" gl_Position = POSITION; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
|
@ -70,7 +79,16 @@ static const char* convert_glsl =
|
|||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"// NOTE: pixel can be clip with \"discard\"\n"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"layout(location = 0) in vertex_basic PSin;\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"#else\n"
|
||||
"layout(location = 0) in vec4 p;\n"
|
||||
"layout(location = 1) in vec2 t;\n"
|
||||
"#define PSin_p p\n"
|
||||
"#define PSin_t t\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||
"layout(location = 1) out uint SV_Target1;\n"
|
||||
|
@ -83,7 +101,7 @@ static const char* convert_glsl =
|
|||
"\n"
|
||||
"vec4 sample_c()\n"
|
||||
"{\n"
|
||||
" return texture(TextureSampler, PSin.t );\n"
|
||||
" return texture(TextureSampler, PSin_t );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"uniform vec4 mask[4] = vec4[4]\n"
|
||||
|
@ -127,7 +145,7 @@ static const char* convert_glsl =
|
|||
"\n"
|
||||
"void ps_main5() // triangular\n"
|
||||
"{\n"
|
||||
" highp uvec4 p = uvec4(PSin.p);\n"
|
||||
" highp uvec4 p = uvec4(PSin_p);\n"
|
||||
"\n"
|
||||
" vec4 c = ps_crt(((p.x + ((p.y >> 1u) & 1u) * 3u) >> 1u) \% 3u);\n"
|
||||
"\n"
|
||||
|
@ -136,7 +154,7 @@ static const char* convert_glsl =
|
|||
"\n"
|
||||
"void ps_main6() // diagonal\n"
|
||||
"{\n"
|
||||
" uvec4 p = uvec4(PSin.p);\n"
|
||||
" uvec4 p = uvec4(PSin_p);\n"
|
||||
"\n"
|
||||
" vec4 c = ps_crt((p.x + (p.y \% 3u)) \% 3u);\n"
|
||||
"\n"
|
||||
|
|
|
@ -7,7 +7,16 @@ struct vertex_basic
|
|||
};
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex_basic PSin;
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
#else
|
||||
layout(location = 0) in vec4 p;
|
||||
layout(location = 1) in vec2 t;
|
||||
#define PSin_p p
|
||||
#define PSin_t t
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 SV_Target0;
|
||||
|
||||
|
@ -32,8 +41,8 @@ void ps_main0()
|
|||
{
|
||||
// I'm not sure it impact us but be safe to lookup texture before conditional if
|
||||
// see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control
|
||||
vec4 c = texture(TextureSampler, PSin.t);
|
||||
if (fract(PSin.t.y * hH) - 0.5 < 0.0)
|
||||
vec4 c = texture(TextureSampler, PSin_t);
|
||||
if (fract(PSin_t.y * hH) - 0.5 < 0.0)
|
||||
discard;
|
||||
|
||||
SV_Target0 = c;
|
||||
|
@ -43,8 +52,8 @@ void ps_main1()
|
|||
{
|
||||
// I'm not sure it impact us but be safe to lookup texture before conditional if
|
||||
// see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control
|
||||
vec4 c = texture(TextureSampler, PSin.t);
|
||||
if (0.5 - fract(PSin.t.y * hH) < 0.0)
|
||||
vec4 c = texture(TextureSampler, PSin_t);
|
||||
if (0.5 - fract(PSin_t.y * hH) < 0.0)
|
||||
discard;
|
||||
|
||||
SV_Target0 = c;
|
||||
|
@ -52,16 +61,16 @@ void ps_main1()
|
|||
|
||||
void ps_main2()
|
||||
{
|
||||
vec4 c0 = texture(TextureSampler, PSin.t - ZrH);
|
||||
vec4 c1 = texture(TextureSampler, PSin.t);
|
||||
vec4 c2 = texture(TextureSampler, PSin.t + ZrH);
|
||||
vec4 c0 = texture(TextureSampler, PSin_t - ZrH);
|
||||
vec4 c1 = texture(TextureSampler, PSin_t);
|
||||
vec4 c2 = texture(TextureSampler, PSin_t + ZrH);
|
||||
|
||||
SV_Target0 = (c0 + c1 * 2 + c2) / 4;
|
||||
}
|
||||
|
||||
void ps_main3()
|
||||
{
|
||||
SV_Target0 = texture(TextureSampler, PSin.t);
|
||||
SV_Target0 = texture(TextureSampler, PSin_t);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,7 +35,16 @@ static const char* interlace_glsl =
|
|||
"};\n"
|
||||
"\n"
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) in vertex_basic PSin;\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"#else\n"
|
||||
"layout(location = 0) in vec4 p;\n"
|
||||
"layout(location = 1) in vec2 t;\n"
|
||||
"#define PSin_p p\n"
|
||||
"#define PSin_t t\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||
"\n"
|
||||
|
@ -60,8 +69,8 @@ static const char* interlace_glsl =
|
|||
"{\n"
|
||||
" // I'm not sure it impact us but be safe to lookup texture before conditional if\n"
|
||||
" // see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control\n"
|
||||
" vec4 c = texture(TextureSampler, PSin.t);\n"
|
||||
" if (fract(PSin.t.y * hH) - 0.5 < 0.0)\n"
|
||||
" vec4 c = texture(TextureSampler, PSin_t);\n"
|
||||
" if (fract(PSin_t.y * hH) - 0.5 < 0.0)\n"
|
||||
" discard;\n"
|
||||
"\n"
|
||||
" SV_Target0 = c;\n"
|
||||
|
@ -71,8 +80,8 @@ static const char* interlace_glsl =
|
|||
"{\n"
|
||||
" // I'm not sure it impact us but be safe to lookup texture before conditional if\n"
|
||||
" // see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control\n"
|
||||
" vec4 c = texture(TextureSampler, PSin.t);\n"
|
||||
" if (0.5 - fract(PSin.t.y * hH) < 0.0)\n"
|
||||
" vec4 c = texture(TextureSampler, PSin_t);\n"
|
||||
" if (0.5 - fract(PSin_t.y * hH) < 0.0)\n"
|
||||
" discard;\n"
|
||||
"\n"
|
||||
" SV_Target0 = c;\n"
|
||||
|
@ -80,16 +89,16 @@ static const char* interlace_glsl =
|
|||
"\n"
|
||||
"void ps_main2()\n"
|
||||
"{\n"
|
||||
" vec4 c0 = texture(TextureSampler, PSin.t - ZrH);\n"
|
||||
" vec4 c1 = texture(TextureSampler, PSin.t);\n"
|
||||
" vec4 c2 = texture(TextureSampler, PSin.t + ZrH);\n"
|
||||
" vec4 c0 = texture(TextureSampler, PSin_t - ZrH);\n"
|
||||
" vec4 c1 = texture(TextureSampler, PSin_t);\n"
|
||||
" vec4 c2 = texture(TextureSampler, PSin_t + ZrH);\n"
|
||||
"\n"
|
||||
" SV_Target0 = (c0 + c1 * 2 + c2) / 4;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void ps_main3()\n"
|
||||
"{\n"
|
||||
" SV_Target0 = texture(TextureSampler, PSin.t);\n"
|
||||
" SV_Target0 = texture(TextureSampler, PSin_t);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
|
|
|
@ -7,7 +7,16 @@ struct vertex_basic
|
|||
};
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex_basic PSin;
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
#else
|
||||
layout(location = 0) in vec4 p;
|
||||
layout(location = 1) in vec2 t;
|
||||
#define PSin_p p
|
||||
#define PSin_t t
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 SV_Target0;
|
||||
|
||||
|
@ -28,14 +37,14 @@ layout(binding = 0) uniform sampler2D TextureSampler;
|
|||
|
||||
void ps_main0()
|
||||
{
|
||||
vec4 c = texture(TextureSampler, PSin.t);
|
||||
vec4 c = texture(TextureSampler, PSin_t);
|
||||
c.a = min(c.a * 2, 1.0);
|
||||
SV_Target0 = c;
|
||||
}
|
||||
|
||||
void ps_main1()
|
||||
{
|
||||
vec4 c = texture(TextureSampler, PSin.t);
|
||||
vec4 c = texture(TextureSampler, PSin_t);
|
||||
c.a = BGColor.a;
|
||||
SV_Target0 = c;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,16 @@ static const char* merge_glsl =
|
|||
"};\n"
|
||||
"\n"
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) in vertex_basic PSin;\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"#else\n"
|
||||
"layout(location = 0) in vec4 p;\n"
|
||||
"layout(location = 1) in vec2 t;\n"
|
||||
"#define PSin_p p\n"
|
||||
"#define PSin_t t\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||
"\n"
|
||||
|
@ -56,14 +65,14 @@ static const char* merge_glsl =
|
|||
"\n"
|
||||
"void ps_main0()\n"
|
||||
"{\n"
|
||||
" vec4 c = texture(TextureSampler, PSin.t);\n"
|
||||
" vec4 c = texture(TextureSampler, PSin_t);\n"
|
||||
" c.a = min(c.a * 2, 1.0);\n"
|
||||
" SV_Target0 = c;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void ps_main1()\n"
|
||||
"{\n"
|
||||
" vec4 c = texture(TextureSampler, PSin.t);\n"
|
||||
" vec4 c = texture(TextureSampler, PSin_t);\n"
|
||||
" c.a = BGColor.a;\n"
|
||||
" SV_Target0 = c;\n"
|
||||
"}\n"
|
||||
|
|
|
@ -14,7 +14,16 @@ struct vertex_basic
|
|||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex_basic PSin;
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
#else
|
||||
layout(location = 0) in vec4 p;
|
||||
layout(location = 1) in vec2 t;
|
||||
#define PSin_p p
|
||||
#define PSin_t t
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 SV_Target0;
|
||||
|
||||
|
@ -61,7 +70,7 @@ vec4 ContrastSaturationBrightness(vec4 color)
|
|||
|
||||
void ps_main()
|
||||
{
|
||||
vec4 c = texture(TextureSampler, PSin.t);
|
||||
vec4 c = texture(TextureSampler, PSin_t);
|
||||
SV_Target0 = ContrastSaturationBrightness(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,16 @@ static const char* shadeboost_glsl =
|
|||
"\n"
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) in vertex_basic PSin;\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"#else\n"
|
||||
"layout(location = 0) in vec4 p;\n"
|
||||
"layout(location = 1) in vec2 t;\n"
|
||||
"#define PSin_p p\n"
|
||||
"#define PSin_t t\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||
"\n"
|
||||
|
@ -89,7 +98,7 @@ static const char* shadeboost_glsl =
|
|||
"\n"
|
||||
"void ps_main()\n"
|
||||
"{\n"
|
||||
" vec4 c = texture(TextureSampler, PSin.t);\n"
|
||||
" vec4 c = texture(TextureSampler, PSin_t);\n"
|
||||
" SV_Target0 = ContrastSaturationBrightness(c);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
|
|
|
@ -61,7 +61,22 @@ layout(location = 4) in uint i_z;
|
|||
layout(location = 5) in uvec2 i_uv;
|
||||
layout(location = 6) in vec4 i_f;
|
||||
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) out vertex VSout;
|
||||
#define VSout_p (VSout.p)
|
||||
#define VSout_t (VSout.t)
|
||||
#define VSout_tp (VSout.tp)
|
||||
#define VSout_c (VSout.c)
|
||||
#else
|
||||
layout(location = 0) out vec4 p;
|
||||
layout(location = 1) out vec4 t;
|
||||
layout(location = 2) out vec4 tp;
|
||||
layout(location = 3) out vec4 c;
|
||||
#define VSout_p p
|
||||
#define VSout_t t
|
||||
#define VSout_tp tp
|
||||
#define VSout_c c
|
||||
#endif
|
||||
|
||||
#if __VERSION__ > 140
|
||||
out gl_PerVertex {
|
||||
|
@ -108,10 +123,10 @@ void vs_main()
|
|||
final_p.z = log2(1.0f + float(z)) / 32.0f;
|
||||
}
|
||||
|
||||
VSout.p = final_p;
|
||||
VSout_p = final_p;
|
||||
gl_Position = final_p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position
|
||||
#if VS_RTCOPY
|
||||
VSout.tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5;
|
||||
VSout_tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -119,25 +134,25 @@ void vs_main()
|
|||
{
|
||||
if(VS_FST != 0)
|
||||
{
|
||||
//VSout.t.xy = i_t * TextureScale;
|
||||
VSout.t.xy = i_uv * TextureScale;
|
||||
VSout.t.w = 1.0f;
|
||||
//VSout_t.xy = i_t * TextureScale;
|
||||
VSout_t.xy = i_uv * TextureScale;
|
||||
VSout_t.w = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//VSout.t.xy = i_t;
|
||||
VSout.t.xy = i_st;
|
||||
VSout.t.w = i_q;
|
||||
//VSout_t.xy = i_t;
|
||||
VSout_t.xy = i_st;
|
||||
VSout_t.w = i_q;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
VSout.t.xy = vec2(0.0f, 0.0f);
|
||||
VSout.t.w = 1.0f;
|
||||
VSout_t.xy = vec2(0.0f, 0.0f);
|
||||
VSout_t.w = 1.0f;
|
||||
}
|
||||
|
||||
VSout.c = i_c;
|
||||
VSout.t.z = i_f.r;
|
||||
VSout_c = i_c;
|
||||
VSout_t.z = i_f.r;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -271,7 +286,22 @@ void gs_main()
|
|||
#endif
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex PSin;
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
#define PSin_tp (PSin.tp)
|
||||
#define PSin_c (PSin.c)
|
||||
#else
|
||||
layout(location = 0) in vec4 PSinp;
|
||||
layout(location = 1) in vec4 PSint;
|
||||
layout(location = 2) in vec4 PSintp;
|
||||
layout(location = 3) in vec4 PSinc;
|
||||
#define PSin_p PSinp
|
||||
#define PSin_t PSint
|
||||
#define PSin_tp PSintp
|
||||
#define PSin_c PSinc
|
||||
#endif
|
||||
|
||||
// Same buffer but 2 colors for dual source blending
|
||||
layout(location = 0, index = 0) out vec4 SV_Target0;
|
||||
|
@ -551,7 +581,7 @@ vec4 tfx(vec4 t, vec4 c)
|
|||
void datst()
|
||||
{
|
||||
#if PS_DATE > 0
|
||||
float alpha = sample_rt(PSin.tp.xy).a;
|
||||
float alpha = sample_rt(PSin_tp.xy).a;
|
||||
float alpha0x80 = 128. / 255;
|
||||
|
||||
if (PS_DATE == 1 && alpha >= alpha0x80)
|
||||
|
@ -621,13 +651,13 @@ vec4 ps_color()
|
|||
{
|
||||
datst();
|
||||
|
||||
vec4 t = sample_color(PSin.t.xy, PSin.t.w);
|
||||
vec4 t = sample_color(PSin_t.xy, PSin_t.w);
|
||||
|
||||
vec4 c = tfx(t, PSin.c);
|
||||
vec4 c = tfx(t, PSin_c);
|
||||
|
||||
atst(c);
|
||||
|
||||
c = fog(c, PSin.t.z);
|
||||
c = fog(c, PSin_t.z);
|
||||
|
||||
if (PS_COLCLIP == 2)
|
||||
{
|
||||
|
|
|
@ -89,7 +89,22 @@ static const char* tfx_glsl =
|
|||
"layout(location = 5) in uvec2 i_uv;\n"
|
||||
"layout(location = 6) in vec4 i_f;\n"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) out vertex VSout;\n"
|
||||
"#define VSout_p (VSout.p)\n"
|
||||
"#define VSout_t (VSout.t)\n"
|
||||
"#define VSout_tp (VSout.tp)\n"
|
||||
"#define VSout_c (VSout.c)\n"
|
||||
"#else\n"
|
||||
"layout(location = 0) out vec4 p;\n"
|
||||
"layout(location = 1) out vec4 t;\n"
|
||||
"layout(location = 2) out vec4 tp;\n"
|
||||
"layout(location = 3) out vec4 c;\n"
|
||||
"#define VSout_p p\n"
|
||||
"#define VSout_t t\n"
|
||||
"#define VSout_tp tp\n"
|
||||
"#define VSout_c c\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"out gl_PerVertex {\n"
|
||||
|
@ -136,10 +151,10 @@ static const char* tfx_glsl =
|
|||
" final_p.z = log2(1.0f + float(z)) / 32.0f;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" VSout.p = final_p;\n"
|
||||
" VSout_p = final_p;\n"
|
||||
" gl_Position = final_p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position\n"
|
||||
"#if VS_RTCOPY\n"
|
||||
" VSout.tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5;\n"
|
||||
" VSout_tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5;\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"\n"
|
||||
|
@ -147,25 +162,25 @@ static const char* tfx_glsl =
|
|||
" {\n"
|
||||
" if(VS_FST != 0)\n"
|
||||
" {\n"
|
||||
" //VSout.t.xy = i_t * TextureScale;\n"
|
||||
" VSout.t.xy = i_uv * TextureScale;\n"
|
||||
" VSout.t.w = 1.0f;\n"
|
||||
" //VSout_t.xy = i_t * TextureScale;\n"
|
||||
" VSout_t.xy = i_uv * TextureScale;\n"
|
||||
" VSout_t.w = 1.0f;\n"
|
||||
" }\n"
|
||||
" else\n"
|
||||
" {\n"
|
||||
" //VSout.t.xy = i_t;\n"
|
||||
" VSout.t.xy = i_st;\n"
|
||||
" VSout.t.w = i_q;\n"
|
||||
" //VSout_t.xy = i_t;\n"
|
||||
" VSout_t.xy = i_st;\n"
|
||||
" VSout_t.w = i_q;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" else\n"
|
||||
" {\n"
|
||||
" VSout.t.xy = vec2(0.0f, 0.0f);\n"
|
||||
" VSout.t.w = 1.0f;\n"
|
||||
" VSout_t.xy = vec2(0.0f, 0.0f);\n"
|
||||
" VSout_t.w = 1.0f;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" VSout.c = i_c;\n"
|
||||
" VSout.t.z = i_f.r;\n"
|
||||
" VSout_c = i_c;\n"
|
||||
" VSout_t.z = i_f.r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
|
@ -299,7 +314,22 @@ static const char* tfx_glsl =
|
|||
"#endif\n"
|
||||
"\n"
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) in vertex PSin;\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"#define PSin_tp (PSin.tp)\n"
|
||||
"#define PSin_c (PSin.c)\n"
|
||||
"#else\n"
|
||||
"layout(location = 0) in vec4 PSinp;\n"
|
||||
"layout(location = 1) in vec4 PSint;\n"
|
||||
"layout(location = 2) in vec4 PSintp;\n"
|
||||
"layout(location = 3) in vec4 PSinc;\n"
|
||||
"#define PSin_p PSinp\n"
|
||||
"#define PSin_t PSint\n"
|
||||
"#define PSin_tp PSintp\n"
|
||||
"#define PSin_c PSinc\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"// Same buffer but 2 colors for dual source blending\n"
|
||||
"layout(location = 0, index = 0) out vec4 SV_Target0;\n"
|
||||
|
@ -579,7 +609,7 @@ static const char* tfx_glsl =
|
|||
"void datst()\n"
|
||||
"{\n"
|
||||
"#if PS_DATE > 0\n"
|
||||
" float alpha = sample_rt(PSin.tp.xy).a;\n"
|
||||
" float alpha = sample_rt(PSin_tp.xy).a;\n"
|
||||
" float alpha0x80 = 128. / 255;\n"
|
||||
"\n"
|
||||
" if (PS_DATE == 1 && alpha >= alpha0x80)\n"
|
||||
|
@ -649,13 +679,13 @@ static const char* tfx_glsl =
|
|||
"{\n"
|
||||
" datst();\n"
|
||||
"\n"
|
||||
" vec4 t = sample_color(PSin.t.xy, PSin.t.w);\n"
|
||||
" vec4 t = sample_color(PSin_t.xy, PSin_t.w);\n"
|
||||
"\n"
|
||||
" vec4 c = tfx(t, PSin.c);\n"
|
||||
" vec4 c = tfx(t, PSin_c);\n"
|
||||
"\n"
|
||||
" atst(c);\n"
|
||||
"\n"
|
||||
" c = fog(c, PSin.t.z);\n"
|
||||
" c = fog(c, PSin_t.z);\n"
|
||||
"\n"
|
||||
" if (PS_COLCLIP == 2)\n"
|
||||
" {\n"
|
||||
|
|
Loading…
Reference in New Issue