mirror of https://github.com/PCSX2/pcsx2.git
gsdx glsl: create a common header definition
* avoid duplication between all the files for UBO * remove various interface define
This commit is contained in:
parent
8ee0783bd3
commit
1558220f74
|
@ -45,7 +45,7 @@ $gsdx_path = File::Spec->catdir(dirname(abs_path($0)), "..", "plugins", "GSdx",
|
||||||
my @tfx_res = qw/tfx_fs.glsl/;
|
my @tfx_res = qw/tfx_fs.glsl/;
|
||||||
my $tfx_all = File::Spec->catdir($gsdx_path, "tfx_fs_all.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);
|
concat($gsdx_path, $tfx_all, \@tfx_res);
|
||||||
|
|
||||||
glsl2h($gsdx_path, $gsdx_out, \@gsdx_res);
|
glsl2h($gsdx_path, $gsdx_out, \@gsdx_res);
|
||||||
|
@ -117,7 +117,7 @@ EOS
|
||||||
foreach my $file (@{$glsl_files}) {
|
foreach my $file (@{$glsl_files}) {
|
||||||
my $name = $file;
|
my $name = $file;
|
||||||
$name =~ s/\./_/;
|
$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";
|
open(my $GLSL, File::Spec->catfile($in_dir, $file)) or die "$! : $file";
|
||||||
my $line;
|
my $line;
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include "GSShaderOGL.h"
|
#include "GSShaderOGL.h"
|
||||||
#include "GLState.h"
|
#include "GLState.h"
|
||||||
|
|
||||||
|
#include "res/glsl_source.h"
|
||||||
|
|
||||||
GSShaderOGL::GSShaderOGL(bool debug) :
|
GSShaderOGL::GSShaderOGL(bool debug) :
|
||||||
m_pipeline(0),
|
m_pipeline(0),
|
||||||
m_debug_shader(debug)
|
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
|
// Note it is better to separate header and source file to have the good line number
|
||||||
// in the glsl compiler report
|
// 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);
|
std::string header = GenGlslHeader(entry, type, macro_sel);
|
||||||
int shader_nb = 1;
|
|
||||||
#if 1
|
|
||||||
sources[0] = header.c_str();
|
sources[0] = header.c_str();
|
||||||
sources[1] = glsl_h_code;
|
sources[1] = common_header_glsl;
|
||||||
shader_nb++;
|
sources[2] = glsl_h_code;
|
||||||
#else
|
|
||||||
sources[0] = header.append(glsl_h_code).c_str();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
program = glCreateShaderProgramv(type, shader_nb, sources);
|
program = glCreateShaderProgramv(type, shader_nb, sources);
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,6 @@
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
#if (FXAA_GLSL_130 == 1)
|
#if (FXAA_GLSL_130 == 1)
|
||||||
|
|
||||||
struct vertex_basic
|
|
||||||
{
|
|
||||||
vec4 p;
|
|
||||||
vec2 t;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout(binding = 0) uniform sampler2D TextureSampler;
|
|
||||||
|
|
||||||
in SHADER
|
in SHADER
|
||||||
{
|
{
|
||||||
vec4 p;
|
vec4 p;
|
||||||
|
|
|
@ -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
|
|
@ -1,22 +1,8 @@
|
||||||
//#version 420 // Keep it for editor detection
|
//#version 420 // Keep it for editor detection
|
||||||
|
|
||||||
struct vertex_basic
|
|
||||||
{
|
|
||||||
vec4 p;
|
|
||||||
vec2 t;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERTEX_SHADER
|
#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 = 0) in vec2 POSITION;
|
||||||
layout(location = 1) in vec2 TEXCOORD0;
|
layout(location = 1) in vec2 TEXCOORD0;
|
||||||
|
|
||||||
|
@ -34,13 +20,10 @@ out SHADER
|
||||||
vec2 t;
|
vec2 t;
|
||||||
} VSout;
|
} VSout;
|
||||||
|
|
||||||
#define VSout_p (VSout.p)
|
|
||||||
#define VSout_t (VSout.t)
|
|
||||||
|
|
||||||
void vs_main()
|
void vs_main()
|
||||||
{
|
{
|
||||||
VSout_p = vec4(POSITION, 0.5f, 1.0f);
|
VSout.p = vec4(POSITION, 0.5f, 1.0f);
|
||||||
VSout_t = TEXCOORD0;
|
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
|
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;
|
vec2 t;
|
||||||
} PSin;
|
} PSin;
|
||||||
|
|
||||||
#define PSin_p (PSin.p)
|
|
||||||
#define PSin_t (PSin.t)
|
|
||||||
|
|
||||||
// Give a different name so I remember there is a special case!
|
// Give a different name so I remember there is a special case!
|
||||||
#if defined(ps_main1) || defined(ps_main10)
|
#if defined(ps_main1) || defined(ps_main10)
|
||||||
layout(location = 0) out uint SV_Target1;
|
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;
|
layout(location = 0) out vec4 SV_Target0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
layout(binding = 0) uniform sampler2D TextureSampler;
|
|
||||||
|
|
||||||
layout(std140, binding = 15) uniform cb15
|
|
||||||
{
|
|
||||||
ivec4 ScalingFactor;
|
|
||||||
};
|
|
||||||
|
|
||||||
vec4 sample_c()
|
vec4 sample_c()
|
||||||
{
|
{
|
||||||
return texture(TextureSampler, PSin_t);
|
return texture(TextureSampler, PSin.t);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 ps_crt(uint i)
|
vec4 ps_crt(uint i)
|
||||||
|
@ -365,11 +338,11 @@ void ps_main9()
|
||||||
vec2 texdim = vec2(textureSize(TextureSampler, 0));
|
vec2 texdim = vec2(textureSize(TextureSampler, 0));
|
||||||
|
|
||||||
vec4 c;
|
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();
|
c = sample_c();
|
||||||
} else {
|
} else {
|
||||||
float factor = (0.9f - 0.4f * cos(2.0f * PI * PSin_t.y * 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));
|
c = factor * texture(TextureSampler, vec2(PSin.t.x, (floor(PSin.t.y * texdim.y) + 0.5f) / texdim.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
SV_Target0 = c;
|
SV_Target0 = c;
|
||||||
|
|
|
@ -1,67 +1,50 @@
|
||||||
//#version 420 // Keep it for editor detection
|
//#version 420 // Keep it for editor detection
|
||||||
|
|
||||||
struct vertex_basic
|
|
||||||
{
|
|
||||||
vec4 p;
|
|
||||||
vec2 t;
|
|
||||||
};
|
|
||||||
|
|
||||||
in SHADER
|
in SHADER
|
||||||
{
|
{
|
||||||
vec4 p;
|
vec4 p;
|
||||||
vec2 t;
|
vec2 t;
|
||||||
} PSin;
|
} PSin;
|
||||||
|
|
||||||
#define PSin_p (PSin.p)
|
|
||||||
#define PSin_t (PSin.t)
|
|
||||||
|
|
||||||
#ifdef FRAGMENT_SHADER
|
#ifdef FRAGMENT_SHADER
|
||||||
|
|
||||||
layout(location = 0) out vec4 SV_Target0;
|
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 ???
|
// TODO ensure that clip (discard) is < 0 and not <= 0 ???
|
||||||
void ps_main0()
|
void ps_main0()
|
||||||
{
|
{
|
||||||
if (fract(PSin_t.y * hH) - 0.5 < 0.0)
|
if (fract(PSin.t.y * hH) - 0.5 < 0.0)
|
||||||
discard;
|
discard;
|
||||||
// I'm not sure it impact us but be safe to lookup texture before conditional if
|
// 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
|
// 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;
|
SV_Target0 = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ps_main1()
|
void ps_main1()
|
||||||
{
|
{
|
||||||
if (0.5 - fract(PSin_t.y * hH) < 0.0)
|
if (0.5 - fract(PSin.t.y * hH) < 0.0)
|
||||||
discard;
|
discard;
|
||||||
// I'm not sure it impact us but be safe to lookup texture before conditional if
|
// 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
|
// 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;
|
SV_Target0 = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ps_main2()
|
void ps_main2()
|
||||||
{
|
{
|
||||||
vec4 c0 = texture(TextureSampler, PSin_t - ZrH);
|
vec4 c0 = texture(TextureSampler, PSin.t - ZrH);
|
||||||
vec4 c1 = texture(TextureSampler, PSin_t);
|
vec4 c1 = texture(TextureSampler, PSin.t);
|
||||||
vec4 c2 = texture(TextureSampler, PSin_t + ZrH);
|
vec4 c2 = texture(TextureSampler, PSin.t + ZrH);
|
||||||
|
|
||||||
SV_Target0 = (c0 + c1 * 2.0f + c2) / 4.0f;
|
SV_Target0 = (c0 + c1 * 2.0f + c2) / 4.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ps_main3()
|
void ps_main3()
|
||||||
{
|
{
|
||||||
SV_Target0 = texture(TextureSampler, PSin_t);
|
SV_Target0 = texture(TextureSampler, PSin.t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,34 +1,18 @@
|
||||||
//#version 420 // Keep it for editor detection
|
//#version 420 // Keep it for editor detection
|
||||||
|
|
||||||
struct vertex_basic
|
|
||||||
{
|
|
||||||
vec4 p;
|
|
||||||
vec2 t;
|
|
||||||
};
|
|
||||||
|
|
||||||
in SHADER
|
in SHADER
|
||||||
{
|
{
|
||||||
vec4 p;
|
vec4 p;
|
||||||
vec2 t;
|
vec2 t;
|
||||||
} PSin;
|
} PSin;
|
||||||
|
|
||||||
#define PSin_p (PSin.p)
|
|
||||||
#define PSin_t (PSin.t)
|
|
||||||
|
|
||||||
#ifdef FRAGMENT_SHADER
|
#ifdef FRAGMENT_SHADER
|
||||||
|
|
||||||
layout(location = 0) out vec4 SV_Target0;
|
layout(location = 0) out vec4 SV_Target0;
|
||||||
|
|
||||||
layout(std140, binding = 10) uniform cb10
|
|
||||||
{
|
|
||||||
vec4 BGColor;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout(binding = 0) uniform sampler2D TextureSampler;
|
|
||||||
|
|
||||||
void ps_main0()
|
void ps_main0()
|
||||||
{
|
{
|
||||||
vec4 c = texture(TextureSampler, PSin_t);
|
vec4 c = texture(TextureSampler, PSin.t);
|
||||||
// Note: clamping will be done by fixed unit
|
// Note: clamping will be done by fixed unit
|
||||||
c.a *= 2.0f;
|
c.a *= 2.0f;
|
||||||
SV_Target0 = c;
|
SV_Target0 = c;
|
||||||
|
@ -36,7 +20,7 @@ void ps_main0()
|
||||||
|
|
||||||
void ps_main1()
|
void ps_main1()
|
||||||
{
|
{
|
||||||
vec4 c = texture(TextureSampler, PSin_t);
|
vec4 c = texture(TextureSampler, PSin.t);
|
||||||
c.a = BGColor.a;
|
c.a = BGColor.a;
|
||||||
SV_Target0 = c;
|
SV_Target0 = c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,6 @@
|
||||||
** (but would be nice, if you say that you used my shaders :wink: ) but not necessary"
|
** (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
|
#ifdef FRAGMENT_SHADER
|
||||||
|
|
||||||
in SHADER
|
in SHADER
|
||||||
|
@ -23,32 +17,22 @@ in SHADER
|
||||||
vec2 t;
|
vec2 t;
|
||||||
} PSin;
|
} PSin;
|
||||||
|
|
||||||
#define PSin_p (PSin.p)
|
|
||||||
#define PSin_t (PSin.t)
|
|
||||||
|
|
||||||
layout(location = 0) out vec4 SV_Target0;
|
layout(location = 0) out vec4 SV_Target0;
|
||||||
|
|
||||||
layout(std140, binding = 12) uniform cb12
|
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
|
||||||
{
|
|
||||||
vec4 BGColor;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout(binding = 0) uniform sampler2D TextureSampler;
|
|
||||||
|
|
||||||
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
|
|
||||||
vec4 ContrastSaturationBrightness(vec4 color)
|
vec4 ContrastSaturationBrightness(vec4 color)
|
||||||
{
|
{
|
||||||
const float sat = SB_SATURATION / 50.0;
|
const float sat = SB_SATURATION / 50.0;
|
||||||
const float brt = SB_BRIGHTNESS / 50.0;
|
const float brt = SB_BRIGHTNESS / 50.0;
|
||||||
const float con = SB_CONTRAST / 50.0;
|
const float con = SB_CONTRAST / 50.0;
|
||||||
|
|
||||||
// Increase or decrease these values to adjust r, g and b color channels separately
|
// Increase or decrease these values to adjust r, g and b color channels separately
|
||||||
const float AvgLumR = 0.5;
|
const float AvgLumR = 0.5;
|
||||||
const float AvgLumG = 0.5;
|
const float AvgLumG = 0.5;
|
||||||
const float AvgLumB = 0.5;
|
const float AvgLumB = 0.5;
|
||||||
|
|
||||||
const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
|
const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
|
||||||
|
|
||||||
vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);
|
vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);
|
||||||
vec3 brtColor = color.rgb * brt;
|
vec3 brtColor = color.rgb * brt;
|
||||||
float dot_intensity = dot(brtColor, LumCoeff);
|
float dot_intensity = dot(brtColor, LumCoeff);
|
||||||
|
@ -56,14 +40,14 @@ vec4 ContrastSaturationBrightness(vec4 color)
|
||||||
vec3 satColor = mix(intensity, brtColor, sat);
|
vec3 satColor = mix(intensity, brtColor, sat);
|
||||||
vec3 conColor = mix(AvgLumin, satColor, con);
|
vec3 conColor = mix(AvgLumin, satColor, con);
|
||||||
|
|
||||||
color.rgb = conColor;
|
color.rgb = conColor;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ps_main()
|
void ps_main()
|
||||||
{
|
{
|
||||||
vec4 c = texture(TextureSampler, PSin_t);
|
vec4 c = texture(TextureSampler, PSin.t);
|
||||||
SV_Target0 = ContrastSaturationBrightness(c);
|
SV_Target0 = ContrastSaturationBrightness(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,14 +34,10 @@ in SHADER
|
||||||
flat vec4 fc;
|
flat vec4 fc;
|
||||||
} PSin;
|
} PSin;
|
||||||
|
|
||||||
#define PSin_c (PSin.c)
|
|
||||||
#define PSin_fc (PSin.fc)
|
|
||||||
|
|
||||||
// Same buffer but 2 colors for dual source blending
|
// Same buffer but 2 colors for dual source blending
|
||||||
layout(location = 0, index = 0) out vec4 SV_Target0;
|
layout(location = 0, index = 0) out vec4 SV_Target0;
|
||||||
layout(location = 0, index = 1) out vec4 SV_Target1;
|
layout(location = 0, index = 1) out vec4 SV_Target1;
|
||||||
|
|
||||||
layout(binding = 0) uniform sampler2D TextureSampler;
|
|
||||||
layout(binding = 1) uniform sampler2D PaletteSampler;
|
layout(binding = 1) uniform sampler2D PaletteSampler;
|
||||||
layout(binding = 3) uniform sampler2D RtSampler; // note 2 already use by the image below
|
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
|
// use basic stencil
|
||||||
#endif
|
#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)
|
vec4 sample_c(vec2 uv)
|
||||||
{
|
{
|
||||||
return texture(TextureSampler, uv);
|
return texture(TextureSampler, uv);
|
||||||
|
@ -364,9 +335,9 @@ vec4 ps_color()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PS_IIP == 1
|
#if PS_IIP == 1
|
||||||
vec4 C = tfx(T, PSin_c);
|
vec4 C = tfx(T, PSin.c);
|
||||||
#else
|
#else
|
||||||
vec4 C = tfx(T, PSin_fc);
|
vec4 C = tfx(T, PSin.fc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
atst(C);
|
atst(C);
|
||||||
|
|
|
@ -1,37 +1,5 @@
|
||||||
//#version 420 // Keep it for text editor detection
|
//#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
|
#ifdef VERTEX_SHADER
|
||||||
layout(location = 0) in vec2 i_st;
|
layout(location = 0) in vec2 i_st;
|
||||||
layout(location = 2) in vec4 i_c;
|
layout(location = 2) in vec4 i_c;
|
||||||
|
@ -49,17 +17,6 @@ out SHADER
|
||||||
flat vec4 fc;
|
flat vec4 fc;
|
||||||
} VSout;
|
} 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);
|
const float exp_min32 = exp2(-32.0f);
|
||||||
|
|
||||||
void texture_coord()
|
void texture_coord()
|
||||||
|
@ -101,8 +58,8 @@ void vs_main()
|
||||||
|
|
||||||
texture_coord();
|
texture_coord();
|
||||||
|
|
||||||
VSout_c = i_c;
|
VSout.c = i_c;
|
||||||
VSout_fc = i_c;
|
VSout.fc = i_c;
|
||||||
VSout.t_float.z = i_f.x; // pack for with texture
|
VSout.t_float.z = i_f.x; // pack for with texture
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,24 +67,6 @@ void vs_main()
|
||||||
|
|
||||||
#ifdef GEOMETRY_SHADER
|
#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
|
in SHADER
|
||||||
{
|
{
|
||||||
vec4 t_float;
|
vec4 t_float;
|
||||||
|
@ -144,12 +83,6 @@ out SHADER
|
||||||
flat vec4 fc;
|
flat vec4 fc;
|
||||||
} GSout;
|
} GSout;
|
||||||
|
|
||||||
layout(std140, binding = 22) uniform cb22
|
|
||||||
{
|
|
||||||
vec4 rt_size;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct vertex
|
struct vertex
|
||||||
{
|
{
|
||||||
vec4 t_float;
|
vec4 t_float;
|
||||||
|
|
|
@ -22,15 +22,12 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
static const char* convert_glsl =
|
static const char* const common_header_glsl =
|
||||||
"//#version 420 // Keep it for editor detection\n"
|
"//#version 420 // Keep it for editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"struct vertex_basic\n"
|
"//////////////////////////////////////////////////////////////////////\n"
|
||||||
"{\n"
|
"// Common Interface Definition\n"
|
||||||
" vec4 p;\n"
|
"//////////////////////////////////////////////////////////////////////\n"
|
||||||
" vec2 t;\n"
|
|
||||||
"};\n"
|
|
||||||
"\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"#ifdef VERTEX_SHADER\n"
|
"#ifdef VERTEX_SHADER\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -42,6 +39,101 @@ static const char* convert_glsl =
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"};\n"
|
"};\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 = 0) in vec2 POSITION;\n"
|
||||||
"layout(location = 1) in vec2 TEXCOORD0;\n"
|
"layout(location = 1) in vec2 TEXCOORD0;\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -59,13 +151,10 @@ static const char* convert_glsl =
|
||||||
" vec2 t;\n"
|
" vec2 t;\n"
|
||||||
"} VSout;\n"
|
"} VSout;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#define VSout_p (VSout.p)\n"
|
|
||||||
"#define VSout_t (VSout.t)\n"
|
|
||||||
"\n"
|
|
||||||
"void vs_main()\n"
|
"void vs_main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" VSout_p = vec4(POSITION, 0.5f, 1.0f);\n"
|
" VSout.p = vec4(POSITION, 0.5f, 1.0f);\n"
|
||||||
" VSout_t = TEXCOORD0;\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"
|
" 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"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -79,9 +168,6 @@ static const char* convert_glsl =
|
||||||
" vec2 t;\n"
|
" vec2 t;\n"
|
||||||
"} PSin;\n"
|
"} PSin;\n"
|
||||||
"\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"
|
"// Give a different name so I remember there is a special case!\n"
|
||||||
"#if defined(ps_main1) || defined(ps_main10)\n"
|
"#if defined(ps_main1) || defined(ps_main10)\n"
|
||||||
"layout(location = 0) out uint SV_Target1;\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"
|
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\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"
|
"vec4 sample_c()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" return texture(TextureSampler, PSin_t);\n"
|
" return texture(TextureSampler, PSin.t);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"vec4 ps_crt(uint i)\n"
|
"vec4 ps_crt(uint i)\n"
|
||||||
|
@ -390,11 +469,11 @@ static const char* convert_glsl =
|
||||||
" vec2 texdim = vec2(textureSize(TextureSampler, 0));\n"
|
" vec2 texdim = vec2(textureSize(TextureSampler, 0));\n"
|
||||||
"\n"
|
"\n"
|
||||||
" vec4 c;\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"
|
" c = sample_c();\n"
|
||||||
" } else {\n"
|
" } else {\n"
|
||||||
" float factor = (0.9f - 0.4f * cos(2.0f * PI * PSin_t.y * 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"
|
" c = factor * texture(TextureSampler, vec2(PSin.t.x, (floor(PSin.t.y * texdim.y) + 0.5f) / texdim.y));\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"\n"
|
"\n"
|
||||||
" SV_Target0 = c;\n"
|
" SV_Target0 = c;\n"
|
||||||
|
@ -431,108 +510,75 @@ static const char* convert_glsl =
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
static const char* interlace_glsl =
|
static const char* const interlace_glsl =
|
||||||
"//#version 420 // Keep it for editor detection\n"
|
"//#version 420 // Keep it for editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"struct vertex_basic\n"
|
|
||||||
"{\n"
|
|
||||||
" vec4 p;\n"
|
|
||||||
" vec2 t;\n"
|
|
||||||
"};\n"
|
|
||||||
"\n"
|
|
||||||
"in SHADER\n"
|
"in SHADER\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 p;\n"
|
" vec4 p;\n"
|
||||||
" vec2 t;\n"
|
" vec2 t;\n"
|
||||||
"} PSin;\n"
|
"} PSin;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#define PSin_p (PSin.p)\n"
|
|
||||||
"#define PSin_t (PSin.t)\n"
|
|
||||||
"\n"
|
|
||||||
"#ifdef FRAGMENT_SHADER\n"
|
"#ifdef FRAGMENT_SHADER\n"
|
||||||
"\n"
|
"\n"
|
||||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||||
"\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"
|
"// TODO ensure that clip (discard) is < 0 and not <= 0 ???\n"
|
||||||
"void ps_main0()\n"
|
"void ps_main0()\n"
|
||||||
"{\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"
|
" discard;\n"
|
||||||
" // I'm not sure it impact us but be safe to lookup texture before conditional if\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"
|
" // 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"
|
"\n"
|
||||||
" SV_Target0 = c;\n"
|
" SV_Target0 = c;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void ps_main1()\n"
|
"void ps_main1()\n"
|
||||||
"{\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"
|
" discard;\n"
|
||||||
" // I'm not sure it impact us but be safe to lookup texture before conditional if\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"
|
" // 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"
|
"\n"
|
||||||
" SV_Target0 = c;\n"
|
" SV_Target0 = c;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void ps_main2()\n"
|
"void ps_main2()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 c0 = texture(TextureSampler, PSin_t - ZrH);\n"
|
" vec4 c0 = texture(TextureSampler, PSin.t - ZrH);\n"
|
||||||
" vec4 c1 = texture(TextureSampler, PSin_t);\n"
|
" vec4 c1 = texture(TextureSampler, PSin.t);\n"
|
||||||
" vec4 c2 = texture(TextureSampler, PSin_t + ZrH);\n"
|
" vec4 c2 = texture(TextureSampler, PSin.t + ZrH);\n"
|
||||||
"\n"
|
"\n"
|
||||||
" SV_Target0 = (c0 + c1 * 2.0f + c2) / 4.0f;\n"
|
" SV_Target0 = (c0 + c1 * 2.0f + c2) / 4.0f;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void ps_main3()\n"
|
"void ps_main3()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" SV_Target0 = texture(TextureSampler, PSin_t);\n"
|
" SV_Target0 = texture(TextureSampler, PSin.t);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
static const char* merge_glsl =
|
static const char* const merge_glsl =
|
||||||
"//#version 420 // Keep it for editor detection\n"
|
"//#version 420 // Keep it for editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"struct vertex_basic\n"
|
|
||||||
"{\n"
|
|
||||||
" vec4 p;\n"
|
|
||||||
" vec2 t;\n"
|
|
||||||
"};\n"
|
|
||||||
"\n"
|
|
||||||
"in SHADER\n"
|
"in SHADER\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 p;\n"
|
" vec4 p;\n"
|
||||||
" vec2 t;\n"
|
" vec2 t;\n"
|
||||||
"} PSin;\n"
|
"} PSin;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#define PSin_p (PSin.p)\n"
|
|
||||||
"#define PSin_t (PSin.t)\n"
|
|
||||||
"\n"
|
|
||||||
"#ifdef FRAGMENT_SHADER\n"
|
"#ifdef FRAGMENT_SHADER\n"
|
||||||
"\n"
|
"\n"
|
||||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||||
"\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"
|
"void ps_main0()\n"
|
||||||
"{\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"
|
" // Note: clamping will be done by fixed unit\n"
|
||||||
" c.a *= 2.0f;\n"
|
" c.a *= 2.0f;\n"
|
||||||
" SV_Target0 = c;\n"
|
" SV_Target0 = c;\n"
|
||||||
|
@ -540,7 +586,7 @@ static const char* merge_glsl =
|
||||||
"\n"
|
"\n"
|
||||||
"void ps_main1()\n"
|
"void ps_main1()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 c = texture(TextureSampler, PSin_t);\n"
|
" vec4 c = texture(TextureSampler, PSin.t);\n"
|
||||||
" c.a = BGColor.a;\n"
|
" c.a = BGColor.a;\n"
|
||||||
" SV_Target0 = c;\n"
|
" SV_Target0 = c;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
@ -548,7 +594,7 @@ static const char* merge_glsl =
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
static const char* shadeboost_glsl =
|
static const char* const shadeboost_glsl =
|
||||||
"//#version 420 // Keep it for editor detection\n"
|
"//#version 420 // Keep it for editor detection\n"
|
||||||
"\n"
|
"\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"
|
"** (but would be nice, if you say that you used my shaders :wink: ) but not necessary\"\n"
|
||||||
"*/\n"
|
"*/\n"
|
||||||
"\n"
|
"\n"
|
||||||
"struct vertex_basic\n"
|
|
||||||
"{\n"
|
|
||||||
" vec4 p;\n"
|
|
||||||
" vec2 t;\n"
|
|
||||||
"};\n"
|
|
||||||
"\n"
|
|
||||||
"#ifdef FRAGMENT_SHADER\n"
|
"#ifdef FRAGMENT_SHADER\n"
|
||||||
"\n"
|
"\n"
|
||||||
"in SHADER\n"
|
"in SHADER\n"
|
||||||
|
@ -574,32 +614,22 @@ static const char* shadeboost_glsl =
|
||||||
" vec2 t;\n"
|
" vec2 t;\n"
|
||||||
"} PSin;\n"
|
"} PSin;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#define PSin_p (PSin.p)\n"
|
|
||||||
"#define PSin_t (PSin.t)\n"
|
|
||||||
"\n"
|
|
||||||
"layout(location = 0) out vec4 SV_Target0;\n"
|
"layout(location = 0) out vec4 SV_Target0;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"layout(std140, binding = 12) uniform cb12\n"
|
"// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%\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"
|
|
||||||
"vec4 ContrastSaturationBrightness(vec4 color)\n"
|
"vec4 ContrastSaturationBrightness(vec4 color)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" const float sat = SB_SATURATION / 50.0;\n"
|
" const float sat = SB_SATURATION / 50.0;\n"
|
||||||
" const float brt = SB_BRIGHTNESS / 50.0;\n"
|
" const float brt = SB_BRIGHTNESS / 50.0;\n"
|
||||||
" const float con = SB_CONTRAST / 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"
|
" // Increase or decrease these values to adjust r, g and b color channels separately\n"
|
||||||
" const float AvgLumR = 0.5;\n"
|
" const float AvgLumR = 0.5;\n"
|
||||||
" const float AvgLumG = 0.5;\n"
|
" const float AvgLumG = 0.5;\n"
|
||||||
" const float AvgLumB = 0.5;\n"
|
" const float AvgLumB = 0.5;\n"
|
||||||
" \n"
|
"\n"
|
||||||
" const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);\n"
|
" const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);\n"
|
||||||
" \n"
|
"\n"
|
||||||
" vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);\n"
|
" vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);\n"
|
||||||
" vec3 brtColor = color.rgb * brt;\n"
|
" vec3 brtColor = color.rgb * brt;\n"
|
||||||
" float dot_intensity = dot(brtColor, LumCoeff);\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 satColor = mix(intensity, brtColor, sat);\n"
|
||||||
" vec3 conColor = mix(AvgLumin, satColor, con);\n"
|
" vec3 conColor = mix(AvgLumin, satColor, con);\n"
|
||||||
"\n"
|
"\n"
|
||||||
" color.rgb = conColor; \n"
|
" color.rgb = conColor;\n"
|
||||||
" return color;\n"
|
" return color;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void ps_main()\n"
|
"void ps_main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 c = texture(TextureSampler, PSin_t);\n"
|
" vec4 c = texture(TextureSampler, PSin.t);\n"
|
||||||
" SV_Target0 = ContrastSaturationBrightness(c);\n"
|
" SV_Target0 = ContrastSaturationBrightness(c);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -622,41 +652,9 @@ static const char* shadeboost_glsl =
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
static const char* tfx_vgs_glsl =
|
static const char* const tfx_vgs_glsl =
|
||||||
"//#version 420 // Keep it for text editor detection\n"
|
"//#version 420 // Keep it for text editor detection\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"
|
|
||||||
"// 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"
|
"#ifdef VERTEX_SHADER\n"
|
||||||
"layout(location = 0) in vec2 i_st;\n"
|
"layout(location = 0) in vec2 i_st;\n"
|
||||||
"layout(location = 2) in vec4 i_c;\n"
|
"layout(location = 2) in vec4 i_c;\n"
|
||||||
|
@ -674,17 +672,6 @@ static const char* tfx_vgs_glsl =
|
||||||
" flat vec4 fc;\n"
|
" flat vec4 fc;\n"
|
||||||
"} VSout;\n"
|
"} VSout;\n"
|
||||||
"\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"
|
"const float exp_min32 = exp2(-32.0f);\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void texture_coord()\n"
|
"void texture_coord()\n"
|
||||||
|
@ -726,8 +713,8 @@ static const char* tfx_vgs_glsl =
|
||||||
"\n"
|
"\n"
|
||||||
" texture_coord();\n"
|
" texture_coord();\n"
|
||||||
"\n"
|
"\n"
|
||||||
" VSout_c = i_c;\n"
|
" VSout.c = i_c;\n"
|
||||||
" VSout_fc = i_c;\n"
|
" VSout.fc = i_c;\n"
|
||||||
" VSout.t_float.z = i_f.x; // pack for with texture\n"
|
" VSout.t_float.z = i_f.x; // pack for with texture\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -735,24 +722,6 @@ static const char* tfx_vgs_glsl =
|
||||||
"\n"
|
"\n"
|
||||||
"#ifdef GEOMETRY_SHADER\n"
|
"#ifdef GEOMETRY_SHADER\n"
|
||||||
"\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"
|
"in SHADER\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 t_float;\n"
|
" vec4 t_float;\n"
|
||||||
|
@ -769,12 +738,6 @@ static const char* tfx_vgs_glsl =
|
||||||
" flat vec4 fc;\n"
|
" flat vec4 fc;\n"
|
||||||
"} GSout;\n"
|
"} GSout;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"layout(std140, binding = 22) uniform cb22\n"
|
|
||||||
"{\n"
|
|
||||||
" vec4 rt_size;\n"
|
|
||||||
"};\n"
|
|
||||||
"\n"
|
|
||||||
"\n"
|
|
||||||
"struct vertex\n"
|
"struct vertex\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 t_float;\n"
|
" vec4 t_float;\n"
|
||||||
|
@ -872,7 +835,7 @@ static const char* tfx_vgs_glsl =
|
||||||
"#endif\n"
|
"#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"
|
"//#version 420 // Keep it for text editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"// Require for bit operation\n"
|
"// Require for bit operation\n"
|
||||||
|
@ -909,14 +872,10 @@ static const char* tfx_fs_all_glsl =
|
||||||
" flat vec4 fc;\n"
|
" flat vec4 fc;\n"
|
||||||
"} PSin;\n"
|
"} PSin;\n"
|
||||||
"\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"
|
"// Same buffer but 2 colors for dual source blending\n"
|
||||||
"layout(location = 0, index = 0) out vec4 SV_Target0;\n"
|
"layout(location = 0, index = 0) out vec4 SV_Target0;\n"
|
||||||
"layout(location = 0, index = 1) out vec4 SV_Target1;\n"
|
"layout(location = 0, index = 1) out vec4 SV_Target1;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
|
|
||||||
"layout(binding = 1) uniform sampler2D PaletteSampler;\n"
|
"layout(binding = 1) uniform sampler2D PaletteSampler;\n"
|
||||||
"layout(binding = 3) uniform sampler2D RtSampler; // note 2 already use by the image below\n"
|
"layout(binding = 3) uniform sampler2D RtSampler; // note 2 already use by the image below\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -948,31 +907,6 @@ static const char* tfx_fs_all_glsl =
|
||||||
"// use basic stencil\n"
|
"// use basic stencil\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\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"
|
"vec4 sample_c(vec2 uv)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" return texture(TextureSampler, uv);\n"
|
" return texture(TextureSampler, uv);\n"
|
||||||
|
@ -1239,9 +1173,9 @@ static const char* tfx_fs_all_glsl =
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#if PS_IIP == 1\n"
|
"#if PS_IIP == 1\n"
|
||||||
" vec4 C = tfx(T, PSin_c);\n"
|
" vec4 C = tfx(T, PSin.c);\n"
|
||||||
"#else\n"
|
"#else\n"
|
||||||
" vec4 C = tfx(T, PSin_fc);\n"
|
" vec4 C = tfx(T, PSin.fc);\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\n"
|
"\n"
|
||||||
" atst(C);\n"
|
" atst(C);\n"
|
||||||
|
@ -1489,7 +1423,7 @@ static const char* tfx_fs_all_glsl =
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
static const char* fxaa_fx =
|
static const char* const fxaa_fx =
|
||||||
"#if defined(SHADER_MODEL) || defined(FXAA_GLSL_130)\n"
|
"#if defined(SHADER_MODEL) || defined(FXAA_GLSL_130)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#ifndef FXAA_GLSL_130\n"
|
"#ifndef FXAA_GLSL_130\n"
|
||||||
|
@ -1505,14 +1439,6 @@ static const char* fxaa_fx =
|
||||||
"------------------------------------------------------------------------------*/\n"
|
"------------------------------------------------------------------------------*/\n"
|
||||||
"#if (FXAA_GLSL_130 == 1)\n"
|
"#if (FXAA_GLSL_130 == 1)\n"
|
||||||
"\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"
|
"in SHADER\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 p;\n"
|
" vec4 p;\n"
|
||||||
|
|
|
@ -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"
|
"//#version 420 Keep it for text editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"// ZZ Open GL graphics plugin\n"
|
"// ZZ Open GL graphics plugin\n"
|
||||||
|
|
Loading…
Reference in New Issue