gsdx glsl: create a common header definition

* avoid duplication between all the files for UBO
* remove various interface define
This commit is contained in:
Gregory Hainaut 2016-04-24 10:54:39 +02:00
parent 8ee0783bd3
commit 1558220f74
12 changed files with 270 additions and 422 deletions

View File

@ -45,7 +45,7 @@ $gsdx_path = File::Spec->catdir(dirname(abs_path($0)), "..", "plugins", "GSdx",
my @tfx_res = qw/tfx_fs.glsl/;
my $tfx_all = File::Spec->catdir($gsdx_path, "tfx_fs_all.glsl");
my @gsdx_res = qw/convert.glsl interlace.glsl merge.glsl shadeboost.glsl tfx_vgs.glsl tfx_fs_all.glsl fxaa.fx/;
my @gsdx_res = qw/common_header.glsl convert.glsl interlace.glsl merge.glsl shadeboost.glsl tfx_vgs.glsl tfx_fs_all.glsl fxaa.fx/;
concat($gsdx_path, $tfx_all, \@tfx_res);
glsl2h($gsdx_path, $gsdx_out, \@gsdx_res);
@ -117,7 +117,7 @@ EOS
foreach my $file (@{$glsl_files}) {
my $name = $file;
$name =~ s/\./_/;
$data .= "\nstatic const char* $name =\n";
$data .= "\nstatic const char* const $name =\n";
open(my $GLSL, File::Spec->catfile($in_dir, $file)) or die "$! : $file";
my $line;

View File

@ -23,6 +23,8 @@
#include "GSShaderOGL.h"
#include "GLState.h"
#include "res/glsl_source.h"
GSShaderOGL::GSShaderOGL(bool debug) :
m_pipeline(0),
m_debug_shader(debug)
@ -184,17 +186,14 @@ GLuint GSShaderOGL::Compile(const std::string& glsl_file, const std::string& ent
// Note it is better to separate header and source file to have the good line number
// in the glsl compiler report
const char* sources[2];
const int shader_nb = 3;
const char* sources[shader_nb];
std::string header = GenGlslHeader(entry, type, macro_sel);
int shader_nb = 1;
#if 1
sources[0] = header.c_str();
sources[1] = glsl_h_code;
shader_nb++;
#else
sources[0] = header.append(glsl_h_code).c_str();
#endif
sources[1] = common_header_glsl;
sources[2] = glsl_h_code;
program = glCreateShaderProgramv(type, shader_nb, sources);

View File

@ -13,14 +13,6 @@
------------------------------------------------------------------------------*/
#if (FXAA_GLSL_130 == 1)
struct vertex_basic
{
vec4 p;
vec2 t;
};
layout(binding = 0) uniform sampler2D TextureSampler;
in SHADER
{
vec4 p;

View File

@ -0,0 +1,103 @@
//#version 420 // Keep it for editor detection
//////////////////////////////////////////////////////////////////////
// Common Interface Definition
//////////////////////////////////////////////////////////////////////
#ifdef VERTEX_SHADER
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
#if !pGL_ES
float gl_ClipDistance[1];
#endif
};
#endif
#ifdef GEOMETRY_SHADER
in gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
#if !pGL_ES
float gl_ClipDistance[1];
#endif
} gl_in[];
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
#if !pGL_ES
float gl_ClipDistance[1];
#endif
};
#endif
//////////////////////////////////////////////////////////////////////
// Constant Buffer Definition
//////////////////////////////////////////////////////////////////////
layout(std140, binding = 10) uniform cb10
{
vec4 BGColor;
};
layout(std140, binding = 11) uniform cb11
{
vec2 ZrH;
float hH;
};
layout(std140, binding = 15) uniform cb15
{
ivec4 ScalingFactor;
};
layout(std140, binding = 20) uniform cb20
{
vec2 VertexScale;
vec2 VertexOffset;
vec2 _removed_TextureScale;
vec2 PointSize;
};
layout(std140, binding = 21) uniform cb21
{
vec3 FogColor;
float AREF;
vec4 WH;
vec2 TA;
float _pad0;
float Af;
uvec4 MskFix;
uvec4 FbMask;
vec4 HalfTexel;
vec4 MinMax;
vec2 TextureScale;
vec2 TC_OffsetHack;
};
layout(std140, binding = 22) uniform cb22
{
vec4 rt_size;
};
//////////////////////////////////////////////////////////////////////
// Default Sampler
//////////////////////////////////////////////////////////////////////
#ifdef FRAGMENT_SHADER
layout(binding = 0) uniform sampler2D TextureSampler;
#endif

View File

@ -1,22 +1,8 @@
//#version 420 // Keep it for editor detection
struct vertex_basic
{
vec4 p;
vec2 t;
};
#ifdef VERTEX_SHADER
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
#if !pGL_ES
float gl_ClipDistance[1];
#endif
};
layout(location = 0) in vec2 POSITION;
layout(location = 1) in vec2 TEXCOORD0;
@ -34,13 +20,10 @@ out SHADER
vec2 t;
} VSout;
#define VSout_p (VSout.p)
#define VSout_t (VSout.t)
void vs_main()
{
VSout_p = vec4(POSITION, 0.5f, 1.0f);
VSout_t = TEXCOORD0;
VSout.p = vec4(POSITION, 0.5f, 1.0f);
VSout.t = TEXCOORD0;
gl_Position = vec4(POSITION, 0.5f, 1.0f); // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position
}
@ -54,9 +37,6 @@ in SHADER
vec2 t;
} PSin;
#define PSin_p (PSin.p)
#define PSin_t (PSin.t)
// Give a different name so I remember there is a special case!
#if defined(ps_main1) || defined(ps_main10)
layout(location = 0) out uint SV_Target1;
@ -64,16 +44,9 @@ layout(location = 0) out uint SV_Target1;
layout(location = 0) out vec4 SV_Target0;
#endif
layout(binding = 0) uniform sampler2D TextureSampler;
layout(std140, binding = 15) uniform cb15
{
ivec4 ScalingFactor;
};
vec4 sample_c()
{
return texture(TextureSampler, PSin_t);
return texture(TextureSampler, PSin.t);
}
vec4 ps_crt(uint i)
@ -365,11 +338,11 @@ void ps_main9()
vec2 texdim = vec2(textureSize(TextureSampler, 0));
vec4 c;
if (dFdy(PSin_t.y) * PSin_t.y > 0.5f) {
if (dFdy(PSin.t.y) * PSin.t.y > 0.5f) {
c = sample_c();
} else {
float factor = (0.9f - 0.4f * cos(2.0f * PI * PSin_t.y * texdim.y));
c = factor * texture(TextureSampler, vec2(PSin_t.x, (floor(PSin_t.y * texdim.y) + 0.5f) / texdim.y));
float factor = (0.9f - 0.4f * cos(2.0f * PI * PSin.t.y * texdim.y));
c = factor * texture(TextureSampler, vec2(PSin.t.x, (floor(PSin.t.y * texdim.y) + 0.5f) / texdim.y));
}
SV_Target0 = c;

View File

@ -1,67 +1,50 @@
//#version 420 // Keep it for editor detection
struct vertex_basic
{
vec4 p;
vec2 t;
};
in SHADER
{
vec4 p;
vec2 t;
} PSin;
#define PSin_p (PSin.p)
#define PSin_t (PSin.t)
#ifdef FRAGMENT_SHADER
layout(location = 0) out vec4 SV_Target0;
layout(std140, binding = 11) uniform cb11
{
vec2 ZrH;
float hH;
};
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)
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);
vec4 c = texture(TextureSampler, PSin.t);
SV_Target0 = c;
}
void ps_main1()
{
if (0.5 - fract(PSin_t.y * hH) < 0.0)
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);
vec4 c = texture(TextureSampler, PSin.t);
SV_Target0 = c;
}
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.0f + c2) / 4.0f;
}
void ps_main3()
{
SV_Target0 = texture(TextureSampler, PSin_t);
SV_Target0 = texture(TextureSampler, PSin.t);
}
#endif

View File

@ -1,34 +1,18 @@
//#version 420 // Keep it for editor detection
struct vertex_basic
{
vec4 p;
vec2 t;
};
in SHADER
{
vec4 p;
vec2 t;
} PSin;
#define PSin_p (PSin.p)
#define PSin_t (PSin.t)
#ifdef FRAGMENT_SHADER
layout(location = 0) out vec4 SV_Target0;
layout(std140, binding = 10) uniform cb10
{
vec4 BGColor;
};
layout(binding = 0) uniform sampler2D TextureSampler;
void ps_main0()
{
vec4 c = texture(TextureSampler, PSin_t);
vec4 c = texture(TextureSampler, PSin.t);
// Note: clamping will be done by fixed unit
c.a *= 2.0f;
SV_Target0 = c;
@ -36,7 +20,7 @@ void ps_main0()
void ps_main1()
{
vec4 c = texture(TextureSampler, PSin_t);
vec4 c = texture(TextureSampler, PSin.t);
c.a = BGColor.a;
SV_Target0 = c;
}

View File

@ -9,12 +9,6 @@
** (but would be nice, if you say that you used my shaders :wink: ) but not necessary"
*/
struct vertex_basic
{
vec4 p;
vec2 t;
};
#ifdef FRAGMENT_SHADER
in SHADER
@ -23,32 +17,22 @@ in SHADER
vec2 t;
} PSin;
#define PSin_p (PSin.p)
#define PSin_t (PSin.t)
layout(location = 0) out vec4 SV_Target0;
layout(std140, binding = 12) uniform cb12
{
vec4 BGColor;
};
layout(binding = 0) uniform sampler2D TextureSampler;
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
vec4 ContrastSaturationBrightness(vec4 color)
{
const float sat = SB_SATURATION / 50.0;
const float brt = SB_BRIGHTNESS / 50.0;
const float con = SB_CONTRAST / 50.0;
// Increase or decrease these values to adjust r, g and b color channels separately
const float AvgLumR = 0.5;
const float AvgLumG = 0.5;
const float AvgLumB = 0.5;
const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);
vec3 brtColor = color.rgb * brt;
float dot_intensity = dot(brtColor, LumCoeff);
@ -56,14 +40,14 @@ vec4 ContrastSaturationBrightness(vec4 color)
vec3 satColor = mix(intensity, brtColor, sat);
vec3 conColor = mix(AvgLumin, satColor, con);
color.rgb = conColor;
color.rgb = conColor;
return color;
}
void ps_main()
{
vec4 c = texture(TextureSampler, PSin_t);
vec4 c = texture(TextureSampler, PSin.t);
SV_Target0 = ContrastSaturationBrightness(c);
}

View File

@ -34,14 +34,10 @@ in SHADER
flat vec4 fc;
} PSin;
#define PSin_c (PSin.c)
#define PSin_fc (PSin.fc)
// Same buffer but 2 colors for dual source blending
layout(location = 0, index = 0) out vec4 SV_Target0;
layout(location = 0, index = 1) out vec4 SV_Target1;
layout(binding = 0) uniform sampler2D TextureSampler;
layout(binding = 1) uniform sampler2D PaletteSampler;
layout(binding = 3) uniform sampler2D RtSampler; // note 2 already use by the image below
@ -73,31 +69,6 @@ layout(early_fragment_tests) in;
// use basic stencil
#endif
// Warning duplicated in both GLSL file
layout(std140, binding = 21) uniform cb21
{
vec3 FogColor;
float AREF;
vec4 WH;
vec2 TA;
float _pad0;
float Af;
uvec4 MskFix;
uvec4 FbMask;
vec4 HalfTexel;
vec4 MinMax;
vec2 TextureScale;
vec2 TC_OffsetHack;
};
vec4 sample_c(vec2 uv)
{
return texture(TextureSampler, uv);
@ -364,9 +335,9 @@ vec4 ps_color()
#endif
#if PS_IIP == 1
vec4 C = tfx(T, PSin_c);
vec4 C = tfx(T, PSin.c);
#else
vec4 C = tfx(T, PSin_fc);
vec4 C = tfx(T, PSin.fc);
#endif
atst(C);

View File

@ -1,37 +1,5 @@
//#version 420 // Keep it for text editor detection
layout(std140, binding = 20) uniform cb20
{
vec2 VertexScale;
vec2 VertexOffset;
vec2 _removed_TextureScale;
vec2 PointSize;
};
// Warning duplicated in both GLSL file
layout(std140, binding = 21) uniform cb21
{
vec3 FogColor;
float AREF;
vec4 WH;
vec2 TA;
float _pad0;
float Af;
uvec4 MskFix;
uvec4 FbMask;
vec4 HalfTexel;
vec4 MinMax;
vec2 TextureScale;
vec2 TC_OffsetHack;
};
#ifdef VERTEX_SHADER
layout(location = 0) in vec2 i_st;
layout(location = 2) in vec4 i_c;
@ -49,17 +17,6 @@ out SHADER
flat vec4 fc;
} VSout;
#define VSout_c (VSout.c)
#define VSout_fc (VSout.fc)
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
#if !pGL_ES
float gl_ClipDistance[1];
#endif
};
const float exp_min32 = exp2(-32.0f);
void texture_coord()
@ -101,8 +58,8 @@ void vs_main()
texture_coord();
VSout_c = i_c;
VSout_fc = i_c;
VSout.c = i_c;
VSout.fc = i_c;
VSout.t_float.z = i_f.x; // pack for with texture
}
@ -110,24 +67,6 @@ void vs_main()
#ifdef GEOMETRY_SHADER
in gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
#if !pGL_ES
float gl_ClipDistance[1];
#endif
} gl_in[];
//in int gl_PrimitiveIDIn;
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
#if !pGL_ES
float gl_ClipDistance[1];
#endif
};
//out int gl_PrimitiveID;
in SHADER
{
vec4 t_float;
@ -144,12 +83,6 @@ out SHADER
flat vec4 fc;
} GSout;
layout(std140, binding = 22) uniform cb22
{
vec4 rt_size;
};
struct vertex
{
vec4 t_float;

View File

@ -22,15 +22,12 @@
#include "stdafx.h"
static const char* convert_glsl =
static const char* const common_header_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"struct vertex_basic\n"
"{\n"
" vec4 p;\n"
" vec2 t;\n"
"};\n"
"\n"
"//////////////////////////////////////////////////////////////////////\n"
"// Common Interface Definition\n"
"//////////////////////////////////////////////////////////////////////\n"
"\n"
"#ifdef VERTEX_SHADER\n"
"\n"
@ -42,6 +39,101 @@ static const char* convert_glsl =
"#endif\n"
"};\n"
"\n"
"#endif\n"
"\n"
"\n"
"\n"
"#ifdef GEOMETRY_SHADER\n"
"\n"
"in gl_PerVertex {\n"
" vec4 gl_Position;\n"
" float gl_PointSize;\n"
"#if !pGL_ES\n"
" float gl_ClipDistance[1];\n"
"#endif\n"
"} gl_in[];\n"
"\n"
"out gl_PerVertex {\n"
" vec4 gl_Position;\n"
" float gl_PointSize;\n"
"#if !pGL_ES\n"
" float gl_ClipDistance[1];\n"
"#endif\n"
"};\n"
"\n"
"#endif\n"
"\n"
"//////////////////////////////////////////////////////////////////////\n"
"// Constant Buffer Definition\n"
"//////////////////////////////////////////////////////////////////////\n"
"layout(std140, binding = 10) uniform cb10\n"
"{\n"
" vec4 BGColor;\n"
"};\n"
"\n"
"layout(std140, binding = 11) uniform cb11\n"
"{\n"
" vec2 ZrH;\n"
" float hH;\n"
"};\n"
"\n"
"layout(std140, binding = 15) uniform cb15\n"
"{\n"
" ivec4 ScalingFactor;\n"
"};\n"
"\n"
"layout(std140, binding = 20) uniform cb20\n"
"{\n"
" vec2 VertexScale;\n"
" vec2 VertexOffset;\n"
" vec2 _removed_TextureScale;\n"
" vec2 PointSize;\n"
"};\n"
"\n"
"layout(std140, binding = 21) uniform cb21\n"
"{\n"
" vec3 FogColor;\n"
" float AREF;\n"
"\n"
" vec4 WH;\n"
"\n"
" vec2 TA;\n"
" float _pad0;\n"
" float Af;\n"
"\n"
" uvec4 MskFix;\n"
"\n"
" uvec4 FbMask;\n"
"\n"
" vec4 HalfTexel;\n"
"\n"
" vec4 MinMax;\n"
"\n"
" vec2 TextureScale;\n"
" vec2 TC_OffsetHack;\n"
"};\n"
"\n"
"layout(std140, binding = 22) uniform cb22\n"
"{\n"
" vec4 rt_size;\n"
"};\n"
"\n"
"//////////////////////////////////////////////////////////////////////\n"
"// Default Sampler\n"
"//////////////////////////////////////////////////////////////////////\n"
"#ifdef FRAGMENT_SHADER\n"
"\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"\n"
"#endif\n"
;
static const char* const convert_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"\n"
"#ifdef VERTEX_SHADER\n"
"\n"
"layout(location = 0) in vec2 POSITION;\n"
"layout(location = 1) in vec2 TEXCOORD0;\n"
"\n"
@ -59,13 +151,10 @@ static const char* convert_glsl =
" vec2 t;\n"
"} VSout;\n"
"\n"
"#define VSout_p (VSout.p)\n"
"#define VSout_t (VSout.t)\n"
"\n"
"void vs_main()\n"
"{\n"
" VSout_p = vec4(POSITION, 0.5f, 1.0f);\n"
" VSout_t = TEXCOORD0;\n"
" VSout.p = vec4(POSITION, 0.5f, 1.0f);\n"
" VSout.t = TEXCOORD0;\n"
" gl_Position = vec4(POSITION, 0.5f, 1.0f); // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position\n"
"}\n"
"\n"
@ -79,9 +168,6 @@ static const char* convert_glsl =
" vec2 t;\n"
"} PSin;\n"
"\n"
"#define PSin_p (PSin.p)\n"
"#define PSin_t (PSin.t)\n"
"\n"
"// Give a different name so I remember there is a special case!\n"
"#if defined(ps_main1) || defined(ps_main10)\n"
"layout(location = 0) out uint SV_Target1;\n"
@ -89,16 +175,9 @@ static const char* convert_glsl =
"layout(location = 0) out vec4 SV_Target0;\n"
"#endif\n"
"\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"\n"
"layout(std140, binding = 15) uniform cb15\n"
"{\n"
" ivec4 ScalingFactor;\n"
"};\n"
"\n"
"vec4 sample_c()\n"
"{\n"
" return texture(TextureSampler, PSin_t);\n"
" return texture(TextureSampler, PSin.t);\n"
"}\n"
"\n"
"vec4 ps_crt(uint i)\n"
@ -390,11 +469,11 @@ static const char* convert_glsl =
" vec2 texdim = vec2(textureSize(TextureSampler, 0));\n"
"\n"
" vec4 c;\n"
" if (dFdy(PSin_t.y) * PSin_t.y > 0.5f) {\n"
" if (dFdy(PSin.t.y) * PSin.t.y > 0.5f) {\n"
" c = sample_c();\n"
" } else {\n"
" float factor = (0.9f - 0.4f * cos(2.0f * PI * PSin_t.y * texdim.y));\n"
" c = factor * texture(TextureSampler, vec2(PSin_t.x, (floor(PSin_t.y * texdim.y) + 0.5f) / texdim.y));\n"
" float factor = (0.9f - 0.4f * cos(2.0f * PI * PSin.t.y * texdim.y));\n"
" c = factor * texture(TextureSampler, vec2(PSin.t.x, (floor(PSin.t.y * texdim.y) + 0.5f) / texdim.y));\n"
" }\n"
"\n"
" SV_Target0 = c;\n"
@ -431,108 +510,75 @@ static const char* convert_glsl =
"#endif\n"
;
static const char* interlace_glsl =
static const char* const interlace_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"struct vertex_basic\n"
"{\n"
" vec4 p;\n"
" vec2 t;\n"
"};\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"
"#ifdef FRAGMENT_SHADER\n"
"\n"
"layout(location = 0) out vec4 SV_Target0;\n"
"\n"
"layout(std140, binding = 11) uniform cb11\n"
"{\n"
" vec2 ZrH;\n"
" float hH;\n"
"};\n"
"\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"\n"
"// 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"
" 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"
" vec4 c = texture(TextureSampler, PSin.t);\n"
"\n"
" SV_Target0 = c;\n"
"}\n"
"\n"
"void ps_main1()\n"
"{\n"
" if (0.5 - fract(PSin_t.y * hH) < 0.0)\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"
" vec4 c = texture(TextureSampler, PSin.t);\n"
"\n"
" SV_Target0 = c;\n"
"}\n"
"\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.0f + c2) / 4.0f;\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"
;
static const char* merge_glsl =
static const char* const merge_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"struct vertex_basic\n"
"{\n"
" vec4 p;\n"
" vec2 t;\n"
"};\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"
"#ifdef FRAGMENT_SHADER\n"
"\n"
"layout(location = 0) out vec4 SV_Target0;\n"
"\n"
"layout(std140, binding = 10) uniform cb10\n"
"{\n"
" vec4 BGColor;\n"
"};\n"
"\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"\n"
"void ps_main0()\n"
"{\n"
" vec4 c = texture(TextureSampler, PSin_t);\n"
" vec4 c = texture(TextureSampler, PSin.t);\n"
" // Note: clamping will be done by fixed unit\n"
" c.a *= 2.0f;\n"
" SV_Target0 = c;\n"
@ -540,7 +586,7 @@ static const char* merge_glsl =
"\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"
@ -548,7 +594,7 @@ static const char* merge_glsl =
"#endif\n"
;
static const char* shadeboost_glsl =
static const char* const shadeboost_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"/*\n"
@ -560,12 +606,6 @@ static const char* shadeboost_glsl =
"** (but would be nice, if you say that you used my shaders :wink: ) but not necessary\"\n"
"*/\n"
"\n"
"struct vertex_basic\n"
"{\n"
" vec4 p;\n"
" vec2 t;\n"
"};\n"
"\n"
"#ifdef FRAGMENT_SHADER\n"
"\n"
"in SHADER\n"
@ -574,32 +614,22 @@ static const char* shadeboost_glsl =
" vec2 t;\n"
"} PSin;\n"
"\n"
"#define PSin_p (PSin.p)\n"
"#define PSin_t (PSin.t)\n"
"\n"
"layout(location = 0) out vec4 SV_Target0;\n"
"\n"
"layout(std140, binding = 12) uniform cb12\n"
"{\n"
" vec4 BGColor;\n"
"};\n"
"\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"\n"
"// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150% \n"
"// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%\n"
"vec4 ContrastSaturationBrightness(vec4 color)\n"
"{\n"
" const float sat = SB_SATURATION / 50.0;\n"
" const float brt = SB_BRIGHTNESS / 50.0;\n"
" const float con = SB_CONTRAST / 50.0;\n"
" \n"
"\n"
" // Increase or decrease these values to adjust r, g and b color channels separately\n"
" const float AvgLumR = 0.5;\n"
" const float AvgLumG = 0.5;\n"
" const float AvgLumB = 0.5;\n"
" \n"
"\n"
" const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);\n"
" \n"
"\n"
" vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);\n"
" vec3 brtColor = color.rgb * brt;\n"
" float dot_intensity = dot(brtColor, LumCoeff);\n"
@ -607,14 +637,14 @@ static const char* shadeboost_glsl =
" vec3 satColor = mix(intensity, brtColor, sat);\n"
" vec3 conColor = mix(AvgLumin, satColor, con);\n"
"\n"
" color.rgb = conColor; \n"
" color.rgb = conColor;\n"
" return color;\n"
"}\n"
"\n"
"\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"
@ -622,41 +652,9 @@ static const char* shadeboost_glsl =
"#endif\n"
;
static const char* tfx_vgs_glsl =
static const char* const tfx_vgs_glsl =
"//#version 420 // Keep it for text editor detection\n"
"\n"
"layout(std140, binding = 20) uniform cb20\n"
"{\n"
" vec2 VertexScale;\n"
" vec2 VertexOffset;\n"
" vec2 _removed_TextureScale;\n"
" vec2 PointSize;\n"
"};\n"
"\n"
"// Warning duplicated in both GLSL file\n"
"layout(std140, binding = 21) uniform cb21\n"
"{\n"
" vec3 FogColor;\n"
" float AREF;\n"
"\n"
" vec4 WH;\n"
"\n"
" vec2 TA;\n"
" float _pad0;\n"
" float Af;\n"
"\n"
" uvec4 MskFix;\n"
"\n"
" uvec4 FbMask;\n"
"\n"
" vec4 HalfTexel;\n"
"\n"
" vec4 MinMax;\n"
"\n"
" vec2 TextureScale;\n"
" vec2 TC_OffsetHack;\n"
"};\n"
"\n"
"#ifdef VERTEX_SHADER\n"
"layout(location = 0) in vec2 i_st;\n"
"layout(location = 2) in vec4 i_c;\n"
@ -674,17 +672,6 @@ static const char* tfx_vgs_glsl =
" flat vec4 fc;\n"
"} VSout;\n"
"\n"
"#define VSout_c (VSout.c)\n"
"#define VSout_fc (VSout.fc)\n"
"\n"
"out gl_PerVertex {\n"
" vec4 gl_Position;\n"
" float gl_PointSize;\n"
"#if !pGL_ES\n"
" float gl_ClipDistance[1];\n"
"#endif\n"
"};\n"
"\n"
"const float exp_min32 = exp2(-32.0f);\n"
"\n"
"void texture_coord()\n"
@ -726,8 +713,8 @@ static const char* tfx_vgs_glsl =
"\n"
" texture_coord();\n"
"\n"
" VSout_c = i_c;\n"
" VSout_fc = i_c;\n"
" VSout.c = i_c;\n"
" VSout.fc = i_c;\n"
" VSout.t_float.z = i_f.x; // pack for with texture\n"
"}\n"
"\n"
@ -735,24 +722,6 @@ static const char* tfx_vgs_glsl =
"\n"
"#ifdef GEOMETRY_SHADER\n"
"\n"
"in gl_PerVertex {\n"
" vec4 gl_Position;\n"
" float gl_PointSize;\n"
"#if !pGL_ES\n"
" float gl_ClipDistance[1];\n"
"#endif\n"
"} gl_in[];\n"
"//in int gl_PrimitiveIDIn;\n"
"\n"
"out gl_PerVertex {\n"
" vec4 gl_Position;\n"
" float gl_PointSize;\n"
"#if !pGL_ES\n"
" float gl_ClipDistance[1];\n"
"#endif\n"
"};\n"
"//out int gl_PrimitiveID;\n"
"\n"
"in SHADER\n"
"{\n"
" vec4 t_float;\n"
@ -769,12 +738,6 @@ static const char* tfx_vgs_glsl =
" flat vec4 fc;\n"
"} GSout;\n"
"\n"
"layout(std140, binding = 22) uniform cb22\n"
"{\n"
" vec4 rt_size;\n"
"};\n"
"\n"
"\n"
"struct vertex\n"
"{\n"
" vec4 t_float;\n"
@ -872,7 +835,7 @@ static const char* tfx_vgs_glsl =
"#endif\n"
;
static const char* tfx_fs_all_glsl =
static const char* const tfx_fs_all_glsl =
"//#version 420 // Keep it for text editor detection\n"
"\n"
"// Require for bit operation\n"
@ -909,14 +872,10 @@ static const char* tfx_fs_all_glsl =
" flat vec4 fc;\n"
"} PSin;\n"
"\n"
"#define PSin_c (PSin.c)\n"
"#define PSin_fc (PSin.fc)\n"
"\n"
"// Same buffer but 2 colors for dual source blending\n"
"layout(location = 0, index = 0) out vec4 SV_Target0;\n"
"layout(location = 0, index = 1) out vec4 SV_Target1;\n"
"\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"layout(binding = 1) uniform sampler2D PaletteSampler;\n"
"layout(binding = 3) uniform sampler2D RtSampler; // note 2 already use by the image below\n"
"\n"
@ -948,31 +907,6 @@ static const char* tfx_fs_all_glsl =
"// use basic stencil\n"
"#endif\n"
"\n"
"\n"
"// Warning duplicated in both GLSL file\n"
"layout(std140, binding = 21) uniform cb21\n"
"{\n"
" vec3 FogColor;\n"
" float AREF;\n"
"\n"
" vec4 WH;\n"
"\n"
" vec2 TA;\n"
" float _pad0;\n"
" float Af;\n"
"\n"
" uvec4 MskFix;\n"
"\n"
" uvec4 FbMask;\n"
"\n"
" vec4 HalfTexel;\n"
"\n"
" vec4 MinMax;\n"
"\n"
" vec2 TextureScale;\n"
" vec2 TC_OffsetHack;\n"
"};\n"
"\n"
"vec4 sample_c(vec2 uv)\n"
"{\n"
" return texture(TextureSampler, uv);\n"
@ -1239,9 +1173,9 @@ static const char* tfx_fs_all_glsl =
"#endif\n"
"\n"
"#if PS_IIP == 1\n"
" vec4 C = tfx(T, PSin_c);\n"
" vec4 C = tfx(T, PSin.c);\n"
"#else\n"
" vec4 C = tfx(T, PSin_fc);\n"
" vec4 C = tfx(T, PSin.fc);\n"
"#endif\n"
"\n"
" atst(C);\n"
@ -1489,7 +1423,7 @@ static const char* tfx_fs_all_glsl =
"#endif\n"
;
static const char* fxaa_fx =
static const char* const fxaa_fx =
"#if defined(SHADER_MODEL) || defined(FXAA_GLSL_130)\n"
"\n"
"#ifndef FXAA_GLSL_130\n"
@ -1505,14 +1439,6 @@ static const char* fxaa_fx =
"------------------------------------------------------------------------------*/\n"
"#if (FXAA_GLSL_130 == 1)\n"
"\n"
"struct vertex_basic\n"
"{\n"
" vec4 p;\n"
" vec2 t;\n"
"};\n"
"\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"\n"
"in SHADER\n"
"{\n"
" vec4 p;\n"

View File

@ -22,7 +22,7 @@
static const char* ps2hw_gl4_glsl =
static const char* const ps2hw_gl4_glsl =
"//#version 420 Keep it for text editor detection\n"
"\n"
"// ZZ Open GL graphics plugin\n"