mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl:
* replace vertex interface with block interface. It avoid to depends on the ARB_sso extension. * disable geometry shader on Nvidia & Linux. Slower but better than a black screen ! * default logz to 1, avoid some glitches. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5699 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
f22b366cea
commit
a764950468
|
@ -102,6 +102,8 @@ PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation = NULL;
|
|||
namespace GLLoader {
|
||||
|
||||
bool fglrx_buggy_driver = false;
|
||||
bool nvidia_buggy_driver = false;
|
||||
|
||||
bool found_GL_ARB_separate_shader_objects = false;
|
||||
bool found_GL_ARB_shading_language_420pack = false;
|
||||
bool found_GL_ARB_texture_storage = false;
|
||||
|
@ -122,6 +124,8 @@ namespace GLLoader {
|
|||
// Name change but driver is still bad!
|
||||
if (strstr(vendor, "ATI") || strstr(vendor, "Advanced Micro Devices"))
|
||||
fglrx_buggy_driver = true;
|
||||
if (strstr(vendor, "NVIDIA Corporation"))
|
||||
nvidia_buggy_driver = true;
|
||||
|
||||
GLuint dot = 0;
|
||||
while (s[dot] != '\0' && s[dot] != '.') dot++;
|
||||
|
@ -134,6 +138,12 @@ namespace GLLoader {
|
|||
fprintf(stderr, "Geometry shaders are not supported. Required openGL3.2\n");
|
||||
found_geometry_shader = false;
|
||||
}
|
||||
#ifdef _LINUX
|
||||
if (nvidia_buggy_driver) {
|
||||
fprintf(stderr, "Buggy driver detected. Geometry shaders will be disabled\n");
|
||||
found_geometry_shader = false;
|
||||
}
|
||||
#endif
|
||||
if (theApp.GetConfig("override_geometry_shader", -1) != -1) {
|
||||
found_geometry_shader = !!theApp.GetConfig("override_geometry_shader", -1);
|
||||
fprintf(stderr, "Override geometry shaders detection\n");
|
||||
|
|
|
@ -103,13 +103,15 @@ namespace GLLoader {
|
|||
void init_gl_function();
|
||||
bool check_gl_supported_extension();
|
||||
|
||||
extern bool fglrx_buggy_driver;
|
||||
extern bool nvidia_buggy_driver;
|
||||
|
||||
extern bool found_GL_ARB_separate_shader_objects;
|
||||
extern bool found_GL_ARB_shading_language_420pack;
|
||||
extern bool found_GL_ARB_texture_storage;
|
||||
extern bool found_GL_ARB_copy_image;
|
||||
extern bool found_GL_NV_copy_image;
|
||||
extern bool found_geometry_shader;
|
||||
extern bool fglrx_buggy_driver;
|
||||
extern bool found_only_gl30;
|
||||
extern bool found_GL_ARB_gpu_shader5;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
GSRendererOGL::GSRendererOGL()
|
||||
: GSRendererHW(new GSTextureCacheOGL(this))
|
||||
{
|
||||
m_logz = !!theApp.GetConfig("logz", 0);
|
||||
m_logz = !!theApp.GetConfig("logz", 1);
|
||||
m_fba = !!theApp.GetConfig("fba", 1);
|
||||
UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0) && !!theApp.GetConfig("UserHacks", 0);
|
||||
UserHacks_AlphaStencil = !!theApp.GetConfig("UserHacks_AlphaStencil", 0) && !!theApp.GetConfig("UserHacks", 0);
|
||||
|
|
|
@ -256,8 +256,7 @@ std::string GSShaderOGL::GenGlslHeader(const std::string& entry, GLenum type, co
|
|||
if (m_sso) {
|
||||
header += "#extension GL_ARB_separate_shader_objects : require\n";
|
||||
} else {
|
||||
if (!GLLoader::fglrx_buggy_driver)
|
||||
header += "#define DISABLE_SSO\n";
|
||||
header += "#define DISABLE_SSO\n";
|
||||
}
|
||||
if (GLLoader::found_only_gl30) {
|
||||
// Need version 330
|
||||
|
|
|
@ -28,11 +28,19 @@ 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;
|
||||
#if __VERSION__ > 140
|
||||
|
||||
out SHADER
|
||||
{
|
||||
vec4 p;
|
||||
vec2 t;
|
||||
} VSout;
|
||||
|
||||
#define VSout_p (VSout.p)
|
||||
#define VSout_t (VSout.t)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef DISABLE_SSO
|
||||
out vec4 SHADERp;
|
||||
out vec2 SHADERt;
|
||||
|
@ -42,6 +50,7 @@ layout(location = 1) out vec2 SHADERt;
|
|||
#endif
|
||||
#define VSout_p SHADERp
|
||||
#define VSout_t SHADERt
|
||||
|
||||
#endif
|
||||
|
||||
void vs_main()
|
||||
|
@ -54,13 +63,20 @@ void vs_main()
|
|||
#endif
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
// NOTE: pixel can be clip with "discard"
|
||||
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex_basic PSin;
|
||||
#if __VERSION__ > 140
|
||||
|
||||
in SHADER
|
||||
{
|
||||
vec4 p;
|
||||
vec2 t;
|
||||
} PSin;
|
||||
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef DISABLE_SSO
|
||||
in vec4 SHADERp;
|
||||
in vec2 SHADERt;
|
||||
|
@ -70,6 +86,7 @@ layout(location = 1) in vec2 SHADERt;
|
|||
#endif
|
||||
#define PSin_p SHADERp
|
||||
#define PSin_t SHADERt
|
||||
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 SV_Target0;
|
||||
|
@ -86,17 +103,24 @@ vec4 sample_c()
|
|||
return texture(TextureSampler, PSin_t );
|
||||
}
|
||||
|
||||
uniform vec4 mask[4] = vec4[4]
|
||||
(
|
||||
vec4(1, 0, 0, 0),
|
||||
vec4(0, 1, 0, 0),
|
||||
vec4(0, 0, 1, 0),
|
||||
vec4(1, 1, 1, 0)
|
||||
);
|
||||
//uniform vec4 mask[4] = vec4[4]
|
||||
//(
|
||||
// vec4(1, 0, 0, 0),
|
||||
// vec4(0, 1, 0, 0),
|
||||
// vec4(0, 0, 1, 0),
|
||||
// vec4(1, 1, 1, 0)
|
||||
//);
|
||||
|
||||
|
||||
vec4 ps_crt(uint i)
|
||||
{
|
||||
vec4 mask[4] = vec4[4]
|
||||
(
|
||||
vec4(1, 0, 0, 0),
|
||||
vec4(0, 1, 0, 0),
|
||||
vec4(0, 0, 1, 0),
|
||||
vec4(1, 1, 1, 0)
|
||||
);
|
||||
return sample_c() * clamp((mask[i] + 0.5f), 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,11 +87,19 @@ uniform sampler2D TextureSampler;
|
|||
layout(binding = 0) uniform sampler2D TextureSampler;
|
||||
#endif
|
||||
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex_basic PSin;
|
||||
#if __VERSION__ > 140
|
||||
|
||||
in SHADER
|
||||
{
|
||||
vec4 p;
|
||||
vec2 t;
|
||||
} PSin;
|
||||
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef DISABLE_SSO
|
||||
in vec4 SHADERp;
|
||||
in vec2 SHADERt;
|
||||
|
@ -101,6 +109,7 @@ layout(location = 1) in vec2 SHADERt;
|
|||
#endif
|
||||
#define PSin_p SHADERp
|
||||
#define PSin_t SHADERt
|
||||
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 SV_Target0;
|
||||
|
|
|
@ -53,11 +53,19 @@ 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"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"\n"
|
||||
"out SHADER\n"
|
||||
"{\n"
|
||||
" vec4 p;\n"
|
||||
" vec2 t;\n"
|
||||
"} VSout;\n"
|
||||
"\n"
|
||||
"#define VSout_p (VSout.p)\n"
|
||||
"#define VSout_t (VSout.t)\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"#ifdef DISABLE_SSO\n"
|
||||
"out vec4 SHADERp;\n"
|
||||
"out vec2 SHADERt;\n"
|
||||
|
@ -67,6 +75,7 @@ static const char* convert_glsl =
|
|||
"#endif\n"
|
||||
"#define VSout_p SHADERp\n"
|
||||
"#define VSout_t SHADERt\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"void vs_main()\n"
|
||||
|
@ -79,13 +88,20 @@ static const char* convert_glsl =
|
|||
"#endif\n"
|
||||
"\n"
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"// NOTE: pixel can be clip with \"discard\"\n"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) in vertex_basic PSin;\n"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"\n"
|
||||
"in SHADER\n"
|
||||
"{\n"
|
||||
" vec4 p;\n"
|
||||
" vec2 t;\n"
|
||||
"} PSin;\n"
|
||||
"\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"#ifdef DISABLE_SSO\n"
|
||||
"in vec4 SHADERp;\n"
|
||||
"in vec2 SHADERt;\n"
|
||||
|
@ -95,6 +111,7 @@ static const char* convert_glsl =
|
|||
"#endif\n"
|
||||
"#define PSin_p SHADERp\n"
|
||||
"#define PSin_t SHADERt\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||
|
@ -111,17 +128,24 @@ static const char* convert_glsl =
|
|||
" return texture(TextureSampler, PSin_t );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"uniform vec4 mask[4] = vec4[4]\n"
|
||||
"(\n"
|
||||
" vec4(1, 0, 0, 0),\n"
|
||||
" vec4(0, 1, 0, 0),\n"
|
||||
" vec4(0, 0, 1, 0),\n"
|
||||
" vec4(1, 1, 1, 0)\n"
|
||||
");\n"
|
||||
"//uniform vec4 mask[4] = vec4[4]\n"
|
||||
"//(\n"
|
||||
"// vec4(1, 0, 0, 0),\n"
|
||||
"// vec4(0, 1, 0, 0),\n"
|
||||
"// vec4(0, 0, 1, 0),\n"
|
||||
"// vec4(1, 1, 1, 0)\n"
|
||||
"//);\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"vec4 ps_crt(uint i)\n"
|
||||
"{\n"
|
||||
" vec4 mask[4] = vec4[4]\n"
|
||||
" (\n"
|
||||
" vec4(1, 0, 0, 0),\n"
|
||||
" vec4(0, 1, 0, 0),\n"
|
||||
" vec4(0, 0, 1, 0),\n"
|
||||
" vec4(1, 1, 1, 0)\n"
|
||||
" );\n"
|
||||
" return sample_c() * clamp((mask[i] + 0.5f), 0.0f, 1.0f);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
|
@ -211,11 +235,19 @@ static const char* interlace_glsl =
|
|||
" vec2 t;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) in vertex_basic PSin;\n"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"\n"
|
||||
"in SHADER\n"
|
||||
"{\n"
|
||||
" vec4 p;\n"
|
||||
" vec2 t;\n"
|
||||
"} PSin;\n"
|
||||
"\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"#ifdef DISABLE_SSO\n"
|
||||
"in vec4 SHADERp;\n"
|
||||
"in vec2 SHADERt;\n"
|
||||
|
@ -225,7 +257,9 @@ static const char* interlace_glsl =
|
|||
"#endif\n"
|
||||
"#define PSin_p SHADERp\n"
|
||||
"#define PSin_t SHADERt\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||
|
@ -249,22 +283,22 @@ static const char* interlace_glsl =
|
|||
"// TODO ensure that clip (discard) is < 0 and not <= 0 ???\n"
|
||||
"void ps_main0()\n"
|
||||
"{\n"
|
||||
" if (fract(PSin_t.y * hH) - 0.5 < 0.0)\n"
|
||||
" discard;\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"
|
||||
" discard;\n"
|
||||
"\n"
|
||||
" SV_Target0 = c;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void ps_main1()\n"
|
||||
"{\n"
|
||||
" if (0.5 - fract(PSin_t.y * hH) < 0.0)\n"
|
||||
" discard;\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"
|
||||
" discard;\n"
|
||||
"\n"
|
||||
" SV_Target0 = c;\n"
|
||||
"}\n"
|
||||
|
@ -295,11 +329,19 @@ static const char* merge_glsl =
|
|||
" vec2 t;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) in vertex_basic PSin;\n"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"\n"
|
||||
"in SHADER\n"
|
||||
"{\n"
|
||||
" vec4 p;\n"
|
||||
" vec2 t;\n"
|
||||
"} PSin;\n"
|
||||
"\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"#ifdef DISABLE_SSO\n"
|
||||
"in vec4 SHADERp;\n"
|
||||
"in vec2 SHADERt;\n"
|
||||
|
@ -309,7 +351,9 @@ static const char* merge_glsl =
|
|||
"#endif\n"
|
||||
"#define PSin_p SHADERp\n"
|
||||
"#define PSin_t SHADERt\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#ifdef FRAGMENT_SHADER\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||
|
@ -363,11 +407,19 @@ 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"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"\n"
|
||||
"in SHADER\n"
|
||||
"{\n"
|
||||
" vec4 p;\n"
|
||||
" vec2 t;\n"
|
||||
"} PSin;\n"
|
||||
"\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"#ifdef DISABLE_SSO\n"
|
||||
"in vec4 SHADERp;\n"
|
||||
"in vec2 SHADERt;\n"
|
||||
|
@ -377,6 +429,7 @@ static const char* shadeboost_glsl =
|
|||
"#endif\n"
|
||||
"#define PSin_p SHADERp\n"
|
||||
"#define PSin_t SHADERt\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||
|
@ -495,13 +548,21 @@ 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"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"\n"
|
||||
"out SHADER\n"
|
||||
"{\n"
|
||||
" vec4 t;\n"
|
||||
" vec4 tp;\n"
|
||||
" vec4 c;\n"
|
||||
"} VSout;\n"
|
||||
"\n"
|
||||
"#define VSout_t (VSout.t)\n"
|
||||
"#define VSout_tp (VSout.tp)\n"
|
||||
"#define VSout_c (VSout.c)\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"#ifdef DISABLE_SSO\n"
|
||||
"out vec4 SHADERt;\n"
|
||||
"out vec4 SHADERtp;\n"
|
||||
|
@ -514,6 +575,7 @@ static const char* tfx_glsl =
|
|||
"#define VSout_t SHADERt\n"
|
||||
"#define VSout_tp SHADERtp\n"
|
||||
"#define VSout_c SHADERc\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140\n"
|
||||
|
@ -600,9 +662,35 @@ static const char* tfx_glsl =
|
|||
" float gl_ClipDistance[];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"layout(location = 0) in vertex GSin[];\n"
|
||||
"in SHADER\n"
|
||||
"{\n"
|
||||
" vec4 t;\n"
|
||||
" vec4 tp;\n"
|
||||
" vec4 c;\n"
|
||||
"} GSin[];\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vertex GSout;\n"
|
||||
"out SHADER\n"
|
||||
"{\n"
|
||||
" vec4 t;\n"
|
||||
" vec4 tp;\n"
|
||||
" vec4 c;\n"
|
||||
"} GSout;\n"
|
||||
"\n"
|
||||
"void out_vertex(in vertex v)\n"
|
||||
"{\n"
|
||||
" GSout.t = v.t;\n"
|
||||
" GSout.tp = v.tp;\n"
|
||||
" GSout.c = v.c;\n"
|
||||
" EmitVertex();\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void out_vertex_elem(in vec4 t, in vec4 tp, in vec4 c)\n"
|
||||
"{\n"
|
||||
" GSout.t = t;\n"
|
||||
" GSout.tp = tp;\n"
|
||||
" GSout.c = c;\n"
|
||||
" EmitVertex();\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"#if GS_PRIM == 0\n"
|
||||
"layout(points) in;\n"
|
||||
|
@ -612,8 +700,7 @@ static const char* tfx_glsl =
|
|||
"{\n"
|
||||
" for(int i = 0; i < gl_in.length(); i++) {\n"
|
||||
" gl_Position = gl_in[i].gl_Position;\n"
|
||||
" GSout = GSin[i];\n"
|
||||
" EmitVertex();\n"
|
||||
" out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[i].c);\n"
|
||||
" }\n"
|
||||
" EndPrimitive();\n"
|
||||
"}\n"
|
||||
|
@ -626,12 +713,12 @@ static const char* tfx_glsl =
|
|||
"{\n"
|
||||
" for(int i = 0; i < gl_in.length(); i++) {\n"
|
||||
" gl_Position = gl_in[i].gl_Position;\n"
|
||||
" GSout = GSin[i];\n"
|
||||
"#if GS_IIP == 0\n"
|
||||
" if (i == 0)\n"
|
||||
" GSout.c = GSin[1].c;\n"
|
||||
" // use latest color\n"
|
||||
" out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[1].c);\n"
|
||||
"#else\n"
|
||||
" out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[i].c);\n"
|
||||
"#endif\n"
|
||||
" EmitVertex();\n"
|
||||
" }\n"
|
||||
" EndPrimitive();\n"
|
||||
"}\n"
|
||||
|
@ -644,12 +731,12 @@ static const char* tfx_glsl =
|
|||
"{\n"
|
||||
" for(int i = 0; i < gl_in.length(); i++) {\n"
|
||||
" gl_Position = gl_in[i].gl_Position;\n"
|
||||
" GSout = GSin[i];\n"
|
||||
"#if GS_IIP == 0\n"
|
||||
" if (i == 0 || i == 1)\n"
|
||||
" GSout.c = GSin[2].c;\n"
|
||||
" // use latest color\n"
|
||||
" out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[2].c);\n"
|
||||
"#else\n"
|
||||
" out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[i].c);\n"
|
||||
"#endif\n"
|
||||
" EmitVertex();\n"
|
||||
" }\n"
|
||||
" EndPrimitive();\n"
|
||||
"}\n"
|
||||
|
@ -662,8 +749,12 @@ static const char* tfx_glsl =
|
|||
"{\n"
|
||||
" // left top => GSin[0];\n"
|
||||
" // right bottom => GSin[1];\n"
|
||||
" vertex rb = vertex(GSin[1].t, GSin[1].tp, GSin[1].c);\n"
|
||||
" vertex lt = vertex(GSin[0].t, GSin[0].tp, GSin[0].c);\n"
|
||||
"#if 0\n"
|
||||
" vertex rb = GSin[1];\n"
|
||||
" vertex lt = GSin[0];\n"
|
||||
"#endif\n"
|
||||
" vec4 rb_p = gl_in[1].gl_Position;\n"
|
||||
" vec4 lb_p = gl_in[1].gl_Position;\n"
|
||||
" vec4 rt_p = gl_in[1].gl_Position;\n"
|
||||
|
@ -685,31 +776,25 @@ static const char* tfx_glsl =
|
|||
"\n"
|
||||
" // Triangle 1\n"
|
||||
" gl_Position = lt_p;\n"
|
||||
" GSout = lt;\n"
|
||||
" EmitVertex();\n"
|
||||
" out_vertex(lt);\n"
|
||||
"\n"
|
||||
" gl_Position = lb_p;\n"
|
||||
" GSout = lb;\n"
|
||||
" EmitVertex();\n"
|
||||
" out_vertex(lb);\n"
|
||||
"\n"
|
||||
" gl_Position = rt_p;\n"
|
||||
" GSout = rt;\n"
|
||||
" EmitVertex();\n"
|
||||
" out_vertex(rt);\n"
|
||||
"\n"
|
||||
" EndPrimitive();\n"
|
||||
"\n"
|
||||
" // Triangle 2\n"
|
||||
" gl_Position = lb_p;\n"
|
||||
" GSout = lb;\n"
|
||||
" EmitVertex();\n"
|
||||
" out_vertex(lb);\n"
|
||||
"\n"
|
||||
" gl_Position = rt_p;\n"
|
||||
" GSout = rt;\n"
|
||||
" EmitVertex();\n"
|
||||
" out_vertex(rt);\n"
|
||||
"\n"
|
||||
" gl_Position = rb_p;\n"
|
||||
" GSout = rb;\n"
|
||||
" EmitVertex();\n"
|
||||
" out_vertex(rb);\n"
|
||||
"\n"
|
||||
" EndPrimitive();\n"
|
||||
"\n"
|
||||
|
@ -720,12 +805,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"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"\n"
|
||||
"in SHADER\n"
|
||||
"{\n"
|
||||
" vec4 t;\n"
|
||||
" vec4 tp;\n"
|
||||
" vec4 c;\n"
|
||||
"} PSin;\n"
|
||||
"\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"#define PSin_tp (PSin.tp)\n"
|
||||
"#define PSin_c (PSin.c)\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"#ifdef DISABLE_SSO\n"
|
||||
"in vec4 SHADERt;\n"
|
||||
"in vec4 SHADERtp;\n"
|
||||
|
@ -738,6 +833,7 @@ static const char* tfx_glsl =
|
|||
"#define PSin_t SHADERt\n"
|
||||
"#define PSin_tp SHADERtp\n"
|
||||
"#define PSin_c SHADERc\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"// Same buffer but 2 colors for dual source blending\n"
|
||||
|
@ -1225,11 +1321,19 @@ static const char* fxaa_fx =
|
|||
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
|
||||
"layout(location = 0) in vertex_basic PSin;\n"
|
||||
"#if __VERSION__ > 140\n"
|
||||
"\n"
|
||||
"in SHADER\n"
|
||||
"{\n"
|
||||
" vec4 p;\n"
|
||||
" vec2 t;\n"
|
||||
"} PSin;\n"
|
||||
"\n"
|
||||
"#define PSin_p (PSin.p)\n"
|
||||
"#define PSin_t (PSin.t)\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"#ifdef DISABLE_SSO\n"
|
||||
"in vec4 SHADERp;\n"
|
||||
"in vec2 SHADERt;\n"
|
||||
|
@ -1239,6 +1343,7 @@ static const char* fxaa_fx =
|
|||
"#endif\n"
|
||||
"#define PSin_p SHADERp\n"
|
||||
"#define PSin_t SHADERt\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||
|
|
|
@ -6,11 +6,19 @@ struct vertex_basic
|
|||
vec2 t;
|
||||
};
|
||||
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex_basic PSin;
|
||||
#if __VERSION__ > 140
|
||||
|
||||
in SHADER
|
||||
{
|
||||
vec4 p;
|
||||
vec2 t;
|
||||
} PSin;
|
||||
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef DISABLE_SSO
|
||||
in vec4 SHADERp;
|
||||
in vec2 SHADERt;
|
||||
|
@ -20,7 +28,9 @@ layout(location = 1) in vec2 SHADERt;
|
|||
#endif
|
||||
#define PSin_p SHADERp
|
||||
#define PSin_t SHADERt
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
|
||||
layout(location = 0) out vec4 SV_Target0;
|
||||
|
@ -44,22 +54,22 @@ layout(binding = 0) uniform sampler2D TextureSampler;
|
|||
// TODO ensure that clip (discard) is < 0 and not <= 0 ???
|
||||
void ps_main0()
|
||||
{
|
||||
if (fract(PSin_t.y * hH) - 0.5 < 0.0)
|
||||
discard;
|
||||
// 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)
|
||||
discard;
|
||||
|
||||
SV_Target0 = c;
|
||||
}
|
||||
|
||||
void ps_main1()
|
||||
{
|
||||
if (0.5 - fract(PSin_t.y * hH) < 0.0)
|
||||
discard;
|
||||
// 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)
|
||||
discard;
|
||||
|
||||
SV_Target0 = c;
|
||||
}
|
||||
|
|
|
@ -6,11 +6,19 @@ struct vertex_basic
|
|||
vec2 t;
|
||||
};
|
||||
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex_basic PSin;
|
||||
#if __VERSION__ > 140
|
||||
|
||||
in SHADER
|
||||
{
|
||||
vec4 p;
|
||||
vec2 t;
|
||||
} PSin;
|
||||
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef DISABLE_SSO
|
||||
in vec4 SHADERp;
|
||||
in vec2 SHADERt;
|
||||
|
@ -20,7 +28,9 @@ layout(location = 1) in vec2 SHADERt;
|
|||
#endif
|
||||
#define PSin_p SHADERp
|
||||
#define PSin_t SHADERt
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
|
||||
layout(location = 0) out vec4 SV_Target0;
|
||||
|
|
|
@ -14,11 +14,19 @@ struct vertex_basic
|
|||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex_basic PSin;
|
||||
#if __VERSION__ > 140
|
||||
|
||||
in SHADER
|
||||
{
|
||||
vec4 p;
|
||||
vec2 t;
|
||||
} PSin;
|
||||
|
||||
#define PSin_p (PSin.p)
|
||||
#define PSin_t (PSin.t)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef DISABLE_SSO
|
||||
in vec4 SHADERp;
|
||||
in vec2 SHADERt;
|
||||
|
@ -28,6 +36,7 @@ layout(location = 1) in vec2 SHADERt;
|
|||
#endif
|
||||
#define PSin_p SHADERp
|
||||
#define PSin_t SHADERt
|
||||
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 SV_Target0;
|
||||
|
|
|
@ -60,13 +60,21 @@ 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)
|
||||
#if __VERSION__ > 140
|
||||
|
||||
out SHADER
|
||||
{
|
||||
vec4 t;
|
||||
vec4 tp;
|
||||
vec4 c;
|
||||
} VSout;
|
||||
|
||||
#define VSout_t (VSout.t)
|
||||
#define VSout_tp (VSout.tp)
|
||||
#define VSout_c (VSout.c)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef DISABLE_SSO
|
||||
out vec4 SHADERt;
|
||||
out vec4 SHADERtp;
|
||||
|
@ -79,6 +87,7 @@ layout(location = 2) out vec4 SHADERc;
|
|||
#define VSout_t SHADERt
|
||||
#define VSout_tp SHADERtp
|
||||
#define VSout_c SHADERc
|
||||
|
||||
#endif
|
||||
|
||||
#if __VERSION__ > 140
|
||||
|
@ -165,9 +174,35 @@ out gl_PerVertex {
|
|||
float gl_ClipDistance[];
|
||||
};
|
||||
|
||||
layout(location = 0) in vertex GSin[];
|
||||
in SHADER
|
||||
{
|
||||
vec4 t;
|
||||
vec4 tp;
|
||||
vec4 c;
|
||||
} GSin[];
|
||||
|
||||
layout(location = 0) out vertex GSout;
|
||||
out SHADER
|
||||
{
|
||||
vec4 t;
|
||||
vec4 tp;
|
||||
vec4 c;
|
||||
} GSout;
|
||||
|
||||
void out_vertex(in vertex v)
|
||||
{
|
||||
GSout.t = v.t;
|
||||
GSout.tp = v.tp;
|
||||
GSout.c = v.c;
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
void out_vertex_elem(in vec4 t, in vec4 tp, in vec4 c)
|
||||
{
|
||||
GSout.t = t;
|
||||
GSout.tp = tp;
|
||||
GSout.c = c;
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
#if GS_PRIM == 0
|
||||
layout(points) in;
|
||||
|
@ -177,8 +212,7 @@ void gs_main()
|
|||
{
|
||||
for(int i = 0; i < gl_in.length(); i++) {
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
GSout = GSin[i];
|
||||
EmitVertex();
|
||||
out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[i].c);
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
||||
|
@ -191,12 +225,12 @@ void gs_main()
|
|||
{
|
||||
for(int i = 0; i < gl_in.length(); i++) {
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
GSout = GSin[i];
|
||||
#if GS_IIP == 0
|
||||
if (i == 0)
|
||||
GSout.c = GSin[1].c;
|
||||
// use latest color
|
||||
out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[1].c);
|
||||
#else
|
||||
out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[i].c);
|
||||
#endif
|
||||
EmitVertex();
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
||||
|
@ -209,12 +243,12 @@ void gs_main()
|
|||
{
|
||||
for(int i = 0; i < gl_in.length(); i++) {
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
GSout = GSin[i];
|
||||
#if GS_IIP == 0
|
||||
if (i == 0 || i == 1)
|
||||
GSout.c = GSin[2].c;
|
||||
// use latest color
|
||||
out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[2].c);
|
||||
#else
|
||||
out_vertex_elem(GSin[i].t, GSin[i].tp, GSin[i].c);
|
||||
#endif
|
||||
EmitVertex();
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
||||
|
@ -227,8 +261,12 @@ void gs_main()
|
|||
{
|
||||
// left top => GSin[0];
|
||||
// right bottom => GSin[1];
|
||||
vertex rb = vertex(GSin[1].t, GSin[1].tp, GSin[1].c);
|
||||
vertex lt = vertex(GSin[0].t, GSin[0].tp, GSin[0].c);
|
||||
#if 0
|
||||
vertex rb = GSin[1];
|
||||
vertex lt = GSin[0];
|
||||
#endif
|
||||
vec4 rb_p = gl_in[1].gl_Position;
|
||||
vec4 lb_p = gl_in[1].gl_Position;
|
||||
vec4 rt_p = gl_in[1].gl_Position;
|
||||
|
@ -250,31 +288,25 @@ void gs_main()
|
|||
|
||||
// Triangle 1
|
||||
gl_Position = lt_p;
|
||||
GSout = lt;
|
||||
EmitVertex();
|
||||
out_vertex(lt);
|
||||
|
||||
gl_Position = lb_p;
|
||||
GSout = lb;
|
||||
EmitVertex();
|
||||
out_vertex(lb);
|
||||
|
||||
gl_Position = rt_p;
|
||||
GSout = rt;
|
||||
EmitVertex();
|
||||
out_vertex(rt);
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
// Triangle 2
|
||||
gl_Position = lb_p;
|
||||
GSout = lb;
|
||||
EmitVertex();
|
||||
out_vertex(lb);
|
||||
|
||||
gl_Position = rt_p;
|
||||
GSout = rt;
|
||||
EmitVertex();
|
||||
out_vertex(rt);
|
||||
|
||||
gl_Position = rb_p;
|
||||
GSout = rb;
|
||||
EmitVertex();
|
||||
out_vertex(rb);
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
|
@ -285,12 +317,22 @@ void gs_main()
|
|||
#endif
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
|
||||
layout(location = 0) in vertex PSin;
|
||||
|
||||
#if __VERSION__ > 140
|
||||
|
||||
in SHADER
|
||||
{
|
||||
vec4 t;
|
||||
vec4 tp;
|
||||
vec4 c;
|
||||
} PSin;
|
||||
|
||||
#define PSin_t (PSin.t)
|
||||
#define PSin_tp (PSin.tp)
|
||||
#define PSin_c (PSin.c)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef DISABLE_SSO
|
||||
in vec4 SHADERt;
|
||||
in vec4 SHADERtp;
|
||||
|
@ -303,6 +345,7 @@ layout(location = 2) in vec4 SHADERc;
|
|||
#define PSin_t SHADERt
|
||||
#define PSin_tp SHADERtp
|
||||
#define PSin_c SHADERc
|
||||
|
||||
#endif
|
||||
|
||||
// Same buffer but 2 colors for dual source blending
|
||||
|
|
Loading…
Reference in New Issue