From afb13123036012c29f0a822c047d6c4f3a8befee Mon Sep 17 00:00:00 2001 From: hunterk Date: Sun, 24 Mar 2019 22:09:46 -0500 Subject: [PATCH] remove old nonfunctional shaders and add mame hlsl ports in progress --- .../shaders/mame/mame_bloom.slang | 251 ++++++++++++++ .../shaders/mame/mame_chroma.slang | 64 ++++ .../shaders/mame/mame_color.slang | 89 +++++ .../shaders/mame/mame_deconverge.slang | 103 ++++++ .../shaders/mame/mame_distortion.slang | 314 ++++++++++++++++++ .../shaders/mame/mame_downsample.slang | 63 ++++ .../shaders/mame/mame_focus.slang | 79 +++++ .../super-xbr/custom-jinc2-sharper.slang | 161 --------- .../shaders/super-xbr/super-xbr-params.inc | 3 - .../shaders/super-xbr/super-xbr-pass0.slang | 201 ----------- .../shaders/super-xbr/super-xbr-pass1.slang | 191 ----------- .../shaders/super-xbr/super-xbr-pass2.slang | 200 ----------- .../shaders/xbr-lv3-noblend-standard.slang | 236 ------------- .../shaders/xbr-lv3-noblend.slang | 255 -------------- .../xbr-mlv4-multipass/xbr-mlv4-pass1.slang | 268 --------------- .../xbr-mlv4-multipass/xbr-mlv4-pass2.slang | 295 ---------------- .../xbr-mlv4-multipass/xbr-mlv4-pass3.slang | 254 -------------- .../xbr-mlv4-multipass/xbr-mlv4-pass4.slang | 175 ---------- test/nonfunctional/super-xbr-2p.slangp | 19 -- test/nonfunctional/xbr-mlv4-multipass.slangp | 32 -- 20 files changed, 963 insertions(+), 2290 deletions(-) create mode 100644 test/nonfunctional/shaders/mame/mame_bloom.slang create mode 100644 test/nonfunctional/shaders/mame/mame_chroma.slang create mode 100644 test/nonfunctional/shaders/mame/mame_color.slang create mode 100644 test/nonfunctional/shaders/mame/mame_deconverge.slang create mode 100644 test/nonfunctional/shaders/mame/mame_distortion.slang create mode 100644 test/nonfunctional/shaders/mame/mame_downsample.slang create mode 100644 test/nonfunctional/shaders/mame/mame_focus.slang delete mode 100644 test/nonfunctional/shaders/super-xbr/custom-jinc2-sharper.slang delete mode 100644 test/nonfunctional/shaders/super-xbr/super-xbr-params.inc delete mode 100644 test/nonfunctional/shaders/super-xbr/super-xbr-pass0.slang delete mode 100644 test/nonfunctional/shaders/super-xbr/super-xbr-pass1.slang delete mode 100644 test/nonfunctional/shaders/super-xbr/super-xbr-pass2.slang delete mode 100644 test/nonfunctional/shaders/xbr-lv3-noblend-standard.slang delete mode 100644 test/nonfunctional/shaders/xbr-lv3-noblend.slang delete mode 100644 test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass1.slang delete mode 100644 test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass2.slang delete mode 100644 test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass3.slang delete mode 100644 test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass4.slang delete mode 100644 test/nonfunctional/super-xbr-2p.slangp delete mode 100644 test/nonfunctional/xbr-mlv4-multipass.slangp diff --git a/test/nonfunctional/shaders/mame/mame_bloom.slang b/test/nonfunctional/shaders/mame/mame_bloom.slang new file mode 100644 index 0000000..642bc25 --- /dev/null +++ b/test/nonfunctional/shaders/mame/mame_bloom.slang @@ -0,0 +1,251 @@ +#version 450 + +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz,ImJezze +//----------------------------------------------------------------------------- +// Bloom Effect +//----------------------------------------------------------------------------- + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OutputSize; + float BloomBlendMode; + float VectorScreen; + float BloomScale; + float BloomOverdrive_r; + float BloomOverdrive_g; + float BloomOverdrive_b; + float Level0Weight; + float Level1Weight; + float Level2Weight; + float Level3Weight; + float Level4Weight; + float Level5Weight; + float Level6Weight; + float Level7Weight; + float Level8Weight; +} params; + +#pragma parameter BloomBlendMode "Bloom Blend Mode" 0.0 0.0 1.0 1.0 +#pragma parameter VectorScreen "Vector Screen Mode" 0.0 0.0 1.0 1.0 +#pragma parameter BloomScale "Bloom Scale" 1.0 0.0 4.0 0.1 +#pragma parameter BloomOverdrive_r "Bloom Overdrive R" 1.0 0.0 1.0 0.01 +#pragma parameter BloomOverdrive_g "Bloom Overdrive G" 1.0 0.0 1.0 0.01 +#pragma parameter BloomOverdrive_b "Bloom Overdrive B" 1.0 0.0 1.0 0.01 + +#pragma parameter Level0Weight "Bloom Level 0 Weight" 1.0 0.0 1.0 0.01 +#pragma parameter Level1Weight "Bloom Level 1 Weight" 0.64 0.0 1.0 0.01 +#pragma parameter Level2Weight "Bloom Level 2 Weight" 0.32 0.0 1.0 0.01 +#pragma parameter Level3Weight "Bloom Level 3 Weight" 0.16 0.0 1.0 0.01 +#pragma parameter Level4Weight "Bloom Level 4 Weight" 0.08 0.0 1.0 0.01 +#pragma parameter Level5Weight "Bloom Level 5 Weight" 0.06 0.0 1.0 0.01 +#pragma parameter Level6Weight "Bloom Level 6 Weight" 0.04 0.0 1.0 0.01 +#pragma parameter Level7Weight "Bloom Level 7 Weight" 0.02 0.0 1.0 0.01 +#pragma parameter Level8Weight "Bloom Level 8 Weight" 0.01 0.0 1.0 0.01 + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const float E = 2.7182817f; +const float Gelfond = 23.140692f; // e^pi (Gelfond constant) +const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond-Schneider constant) + +//----------------------------------------------------------------------------- +// Funcions +//----------------------------------------------------------------------------- + +// www.stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader/ +float random(vec2 seed) +{ + // irrationals for pseudo randomness + vec2 i = vec2(Gelfond, GelfondSchneider); + + return fract(cos(dot(seed, i)) * 123456.0f); +} + +//----------------------------------------------------------------------------- +// Bloom Vertex Shader +//----------------------------------------------------------------------------- + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; +layout(location = 1) out vec2 BloomCoord; + +void main() +{ + vec4 bloomPos = vec4(Position.xyz, 1.0); +// bloomPos.xy *= params.OutputSize.zw; +// bloomPos.y = 1.0 - bloomPos.y; // flip y +// bloomPos.xy -= 0.5f; // center +// bloomPos.xy *= 2.0f; // zoom + gl_Position = global.MVP * bloomPos; // using bloomPos just makes a black screen /shrug + vTexCoord = TexCoord; +// vTexCoord += 0.5f * params.OutputSize.zw; // half texel offset correction (DX9) + BloomCoord = vTexCoord; + BloomCoord += 0.5f * params.SourceSize.zw; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec2 BloomCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +#define DiffuseSampler Source + +#define BloomSamplerA Source +#define BloomSamplerB Source +#define BloomSamplerC Source +#define BloomSamplerD Source +#define BloomSamplerE Source +#define BloomSamplerF Source +#define BloomSamplerG Source +#define BloomSamplerH Source + +// vector screen uses twice -1 as many bloom levels +#define BloomSamplerI Source +#define BloomSamplerJ Source +#define BloomSamplerK Source +#define BloomSamplerL Source +#define BloomSamplerM Source +#define BloomSamplerN Source +#define BloomSamplerO Source + +vec3 GetNoiseFactor(vec3 n, float random) +{ + // smaller n become more noisy + vec3 NoiseFactor; + NoiseFactor.x = 1.0f + random * max(0.0f, 0.25f * pow(E, -8. * n.x)); + NoiseFactor.y = 1.0f + random * max(0.0f, 0.25f * pow(E, -8. * n.y)); + NoiseFactor.z = 1.0f + random * max(0.0f, 0.25f * pow(E, -8. * n.z)); + return NoiseFactor; +} + +void main() +{ + vec3 texel = texture(DiffuseSampler, vTexCoord).rgb; + + vec3 texelA = texture(BloomSamplerA, BloomCoord.xy).rgb; + vec3 texelB = texture(BloomSamplerB, BloomCoord.xy).rgb; + vec3 texelC = texture(BloomSamplerC, BloomCoord.xy).rgb; + vec3 texelD = texture(BloomSamplerD, BloomCoord.xy).rgb; + vec3 texelE = texture(BloomSamplerE, BloomCoord.xy).rgb; + vec3 texelF = texture(BloomSamplerF, BloomCoord.xy).rgb; + vec3 texelG = texture(BloomSamplerG, BloomCoord.xy).rgb; + vec3 texelH = texture(BloomSamplerH, BloomCoord.xy).rgb; + + vec3 texelI = vec3(0.0f, 0.0f, 0.0f); + vec3 texelJ = vec3(0.0f, 0.0f, 0.0f); + vec3 texelK = vec3(0.0f, 0.0f, 0.0f); + vec3 texelL = vec3(0.0f, 0.0f, 0.0f); + vec3 texelM = vec3(0.0f, 0.0f, 0.0f); + vec3 texelN = vec3(0.0f, 0.0f, 0.0f); + vec3 texelO = vec3(0.0f, 0.0f, 0.0f); + + + // vector screen uses twice -1 as many bloom levels + if (params.VectorScreen > 0.5) + { + texelI = texture(BloomSamplerI, BloomCoord.xy).rgb; + texelJ = texture(BloomSamplerJ, BloomCoord.xy).rgb; + texelK = texture(BloomSamplerK, BloomCoord.xy).rgb; + texelL = texture(BloomSamplerL, BloomCoord.xy).rgb; + texelM = texture(BloomSamplerM, BloomCoord.xy).rgb; + texelN = texture(BloomSamplerN, BloomCoord.xy).rgb; + texelO = texture(BloomSamplerO, BloomCoord.xy).rgb; + } + + vec3 blend; + + // brighten + if (params.BloomBlendMode < 0.5) + { + vec3 bloom = vec3(0.0f, 0.0f, 0.0f); + + texel *= params.Level0Weight; + + if (params.VectorScreen < 0.5) + { + bloom += texelA * params.Level1Weight; + bloom += texelB * params.Level2Weight; + bloom += texelC * params.Level3Weight; + bloom += texelD * params.Level4Weight; + bloom += texelE * params.Level5Weight; + bloom += texelF * params.Level6Weight; + bloom += texelG * params.Level7Weight; + bloom += texelH * params.Level8Weight; + } + // vector screen uses twice -1 as many bloom levels + else + { + bloom += texelA * (params.Level1Weight); + bloom += texelB * (params.Level1Weight + params.Level2Weight) * 0.5f; + bloom += texelC * (params.Level2Weight); + bloom += texelD * (params.Level2Weight + params.Level3Weight) * 0.5f; + bloom += texelE * (params.Level3Weight); + bloom += texelF * (params.Level3Weight + params.Level4Weight) * 0.5f; + bloom += texelG * (params.Level4Weight); + bloom += texelH * (params.Level4Weight + params.Level5Weight) * 0.5f; + bloom += texelI * (params.Level5Weight); + bloom += texelJ * (params.Level5Weight + params.Level6Weight) * 0.5f; + bloom += texelK * (params.Level6Weight); + bloom += texelL * (params.Level6Weight + params.Level7Weight) * 0.5f; + bloom += texelM * (params.Level7Weight); + bloom += texelN * (params.Level7Weight + params.Level8Weight) * 0.5f; + bloom += texelO * (params.Level8Weight); + } + + bloom *= params.BloomScale; + + vec3 bloomOverdrive; + bloomOverdrive.r = max(0.0f, texel.r + bloom.r - 1.0f) * params.BloomOverdrive_r; + bloomOverdrive.g = max(0.0f, texel.g + bloom.g - 1.0f) * params.BloomOverdrive_g; + bloomOverdrive.b = max(0.0f, texel.b + bloom.b - 1.0f) * params.BloomOverdrive_b; + + bloom.r += bloomOverdrive.g * 0.5f; + bloom.r += bloomOverdrive.b * 0.5f; + bloom.g += bloomOverdrive.r * 0.5f; + bloom.g += bloomOverdrive.b * 0.5f; + bloom.b += bloomOverdrive.r * 0.5f; + bloom.b += bloomOverdrive.g * 0.5f; + + vec2 NoiseCoord = vTexCoord; + vec3 NoiseFactor = GetNoiseFactor(bloom, random(NoiseCoord)); + + blend = texel + bloom * NoiseFactor; + } + + // darken + else + { + texelA = min(texel, texelA); + texelB = min(texel, texelB); + texelC = min(texel, texelC); + texelD = min(texel, texelD); + texelE = min(texel, texelE); + texelF = min(texel, texelF); + texelG = min(texel, texelG); + texelH = min(texel, texelH); + + blend = texel * params.Level0Weight; + blend = mix(blend, texelA, params.Level1Weight * params.BloomScale); + blend = mix(blend, texelB, params.Level2Weight * params.BloomScale); + blend = mix(blend, texelC, params.Level3Weight * params.BloomScale); + blend = mix(blend, texelD, params.Level4Weight * params.BloomScale); + blend = mix(blend, texelE, params.Level5Weight * params.BloomScale); + blend = mix(blend, texelF, params.Level6Weight * params.BloomScale); + blend = mix(blend, texelG, params.Level7Weight * params.BloomScale); + blend = mix(blend, texelH, params.Level8Weight * params.BloomScale); + } + + FragColor = vec4(blend, 1.0); +} diff --git a/test/nonfunctional/shaders/mame/mame_chroma.slang b/test/nonfunctional/shaders/mame/mame_chroma.slang new file mode 100644 index 0000000..6740c5d --- /dev/null +++ b/test/nonfunctional/shaders/mame/mame_chroma.slang @@ -0,0 +1,64 @@ +#version 450 + +// license:BSD-3-Clause +// copyright-holders:W. M. Martinez +//----------------------------------------------------------------------------- +// Phosphor Chromaticity to sRGB Transform Effect +//----------------------------------------------------------------------------- + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +#define DiffuseSampler Source +#define mul(a,b) (b*a) + +const vec3 YGain = vec3(0.2126, 0.7152, 0.0722); +const vec2 ChromaA = vec2(0.630, 0.340); +const vec2 ChromaB = vec2(0.310, 0.595); +const vec2 ChromaC = vec2(0.155, 0.070); + +const mat3 XYZ_TO_sRGB = mat3( + 3.2406, -1.5372, -0.4986, + -0.9689, 1.8758, 0.0415, + 0.0557, -0.2040, 1.0570); + +void main() +{ + vec4 cin = texture(DiffuseSampler, vTexCoord); + vec4 cout = vec4(0.0, 0.0, 0.0, cin.a); + mat3x2 xy = { ChromaA, ChromaB, ChromaC }; + + for (int i = 0; i < 3; ++i) { + float Y = YGain[i] * cin[i]; + float X = xy[i].x * (Y / xy[i].y); + float Z = (1.0 - xy[i].x - xy[i].y) * (Y / xy[i].y); + cout.rgb += mul(XYZ_TO_sRGB, vec3(X, Y, Z)); + } + FragColor = cout; +} diff --git a/test/nonfunctional/shaders/mame/mame_color.slang b/test/nonfunctional/shaders/mame/mame_color.slang new file mode 100644 index 0000000..5b08a8b --- /dev/null +++ b/test/nonfunctional/shaders/mame/mame_color.slang @@ -0,0 +1,89 @@ +#version 450 + +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//----------------------------------------------------------------------------- +// Color-Convolution Effect +//----------------------------------------------------------------------------- + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float col_red; + float col_grn; + float col_blu; + float col_offset_x; + float col_offset_y; + float col_offset_z; + float col_scale_x; + float col_scale_y; + float col_scale_z; + float col_saturation; +} params; + +#pragma parameter col_red "Red Shift" 1.0 0.0 1.0 0.01 +#pragma parameter col_grn "Green Shift" 1.0 0.0 1.0 0.01 +#pragma parameter col_blu "Blue Shift" 1.0 0.0 1.0 0.01 +#pragma parameter col_offset_x "Offset X" 0.0 0.0 1.0 0.01 +#pragma parameter col_offset_y "Offset Y" 0.0 0.0 1.0 0.01 +#pragma parameter col_offset_z "Offset Z" 0.0 0.0 1.0 0.01 +#pragma parameter col_scale_x "Scale X" 1.0 0.0 1.0 0.01 +#pragma parameter col_scale_y "Scale Y" 1.0 0.0 1.0 0.01 +#pragma parameter col_scale_z "Scale Z" 1.0 0.0 1.0 0.01 +#pragma parameter col_saturation "Saturation" 1.0 0.0 0.01 + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +#define DiffuseSampler Source + +vec3 RedRatios = vec3(params.col_red, 0.0f, 0.0f); +vec3 GrnRatios = vec3(0.0f, params.col_grn, 0.0f); +vec3 BluRatios = vec3(0.0f, 0.0f, params.col_blu); +vec3 Offset = vec3(params.col_offset_x, params.col_offset_y, params.col_offset_z); +vec3 Scale = vec3(params.col_scale_x, params.col_scale_y, params.col_scale_z); +float Saturation = params.col_saturation; + +void main() +{ + vec4 BaseTexel = texture(DiffuseSampler, vTexCoord); + + vec3 OutRGB = BaseTexel.rgb; + + // RGB Tint & Shift + float ShiftedRed = dot(OutRGB, RedRatios); + float ShiftedGrn = dot(OutRGB, GrnRatios); + float ShiftedBlu = dot(OutRGB, BluRatios); + + // RGB Scale & Offset + vec3 OutTexel = vec3(ShiftedRed, ShiftedGrn, ShiftedBlu) * Scale + Offset; + + // Saturation + vec3 Grayscale = vec3(0.299f, 0.587f, 0.114f); + float OutLuma = dot(OutTexel, Grayscale); + vec3 OutChroma = OutTexel - OutLuma; + vec3 Saturated = OutLuma + OutChroma * Saturation; + + FragColor = vec4(Saturated, BaseTexel.a); +} diff --git a/test/nonfunctional/shaders/mame/mame_deconverge.slang b/test/nonfunctional/shaders/mame/mame_deconverge.slang new file mode 100644 index 0000000..b51a080 --- /dev/null +++ b/test/nonfunctional/shaders/mame/mame_deconverge.slang @@ -0,0 +1,103 @@ +#version 450 + +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz,ImJezze +//----------------------------------------------------------------------------- +// Deconvergence Effect +//----------------------------------------------------------------------------- + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float converge_x_r; + float converge_x_g; + float converge_x_b; + float converge_y_r; + float converge_y_g; + float converge_y_b; + float radial_conv_x_r; + float radial_conv_x_g; + float radial_conv_x_b; + float radial_conv_y_r; + float radial_conv_y_g; + float radial_conv_y_b; +} params; + +#pragma parameter converge_x_r "Convergence X Red" 0.0 -100.0 100.0 0.5 +#pragma parameter converge_x_g "Convergence X Green" 0.0 -100.0 100.0 0.5 +#pragma parameter converge_x_b "Convergence X Blue" 0.0 -100.0 100.0 0.5 +#pragma parameter converge_y_r "Convergence Y Red" 0.0 -100.0 100.0 0.5 +#pragma parameter converge_y_g "Convergence Y Green" 0.0 -100.0 100.0 0.5 +#pragma parameter converge_y_b "Convergence Y Blue" 0.0 -100.0 100.0 0.5 +#pragma parameter radial_conv_x_r "Radial Conv X Red" 0.0 -100.0 100.0 0.5 +#pragma parameter radial_conv_x_g "Radial Conv X Green" 0.0 -100.0 100.0 0.5 +#pragma parameter radial_conv_x_b "Radial Conv X Blue" 0.0 -100.0 100.0 0.5 +#pragma parameter radial_conv_y_r "Radial Conv Y Red" 0.0 -100.0 100.0 0.5 +#pragma parameter radial_conv_y_g "Radial Conv Y Green" 0.0 -100.0 100.0 0.5 +#pragma parameter radial_conv_y_b "Radial Conv Y Blue" 0.0 -100.0 100.0 0.5 + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +vec3 ConvergeX = vec3(params.converge_x_r, params.converge_x_g, params.converge_x_b); +vec3 ConvergeY = vec3(params.converge_y_r, params.converge_y_g, params.converge_y_b); +vec3 RadialConvergeX = vec3(params.radial_conv_x_r, params.radial_conv_x_g, params.radial_conv_x_b); +vec3 RadialConvergeY = vec3(params.radial_conv_y_r, params.radial_conv_y_g, params.radial_conv_y_b); + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec3 TexCoordX; +layout(location = 1) out vec3 TexCoordY; + +void main() +{ + gl_Position = global.MVP * Position; + + // imaginary texel dimensions independed from screen dimension, but ratio + vec2 TexelDims = vec2(1.0f / 1024.); + + TexCoordX = TexCoord.xxx; + TexCoordY = TexCoord.yyy; + + // center coordinates + TexCoordX -= 0.5f; + TexCoordY -= 0.5f; + + // radial converge offset to "translate" the most outer pixel as thay would be translated by the linar converge with the same amount + vec2 radialConvergeOffset = vec2(2.0); + + // radial converge + TexCoordX *= 1.0f + RadialConvergeX * TexelDims.xxx * radialConvergeOffset.xxx; + TexCoordY *= 1.0f + RadialConvergeY * TexelDims.yyy * radialConvergeOffset.yyy; + + // un-center coordinates + TexCoordX += 0.5f; + TexCoordY += 0.5f; + + // linear converge + TexCoordX += ConvergeX * TexelDims.xxx; + TexCoordY += ConvergeY * TexelDims.yyy; +} + +#pragma stage fragment +layout(location = 0) in vec3 TexCoordX; +layout(location = 1) in vec3 TexCoordY; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +#define DiffuseSampler Source + +void main() +{ + float r = texture(DiffuseSampler, vec2(TexCoordX.x, TexCoordY.x)).r; + float g = texture(DiffuseSampler, vec2(TexCoordX.y, TexCoordY.y)).g; + float b = texture(DiffuseSampler, vec2(TexCoordX.z, TexCoordY.z)).b; + + FragColor = vec4(r, g, b, 1.0); +} diff --git a/test/nonfunctional/shaders/mame/mame_distortion.slang b/test/nonfunctional/shaders/mame/mame_distortion.slang new file mode 100644 index 0000000..74b1f4b --- /dev/null +++ b/test/nonfunctional/shaders/mame/mame_distortion.slang @@ -0,0 +1,314 @@ +#version 450 + +// license:BSD-3-Clause +// copyright-holders:ImJezze +//----------------------------------------------------------------------------- +// Distortion Effect +//----------------------------------------------------------------------------- + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float distortion_amount; + float cubic_distortion_amount; + float distort_corner_amount; + float round_corner_amount; + float smooth_border_amount; + float vignette_amount; + float reflection_amount; + float reflection_col_r; + float reflection_col_g; + float reflection_col_b; + float swapxy; + float target_scale; +} params; + +#pragma parameter distortion_amount "Distortion Amount" 0.0 0.0 1.0 0.01 +#pragma parameter cubic_distortion_amount "Cubic Dist. Amt" 0.0 0.0 1.0 0.01 +#pragma parameter distort_corner_amount "Corner Dist. Amt" 0.0 0.0 1.0 0.01 +#pragma parameter round_corner_amount "Corner Rounding" 0.0 0.0 1.0 0.01 +#pragma parameter smooth_border_amount "Border Smoothing" 0.0 0.0 1.0 0.01 +#pragma parameter vignette_amount "Vignetting Amount" 0.0 0.0 1.0 0.01 +#pragma parameter reflection_amount "Reflection Amount" 0.0 0.0 1.0 0.01 +#pragma parameter reflection_col_r "Reflection Color R" 1.0 0.0 1.0 0.01 +#pragma parameter reflection_col_g "Reflection Color G" 0.9 0.0 1.0 0.01 +#pragma parameter reflection_col_b "Reflection Color B" 0.8 0.0 1.0 0.01 + +#pragma parameter swapxy "Swap X and Y" 0.0 0.0 1.0 1.0 +#pragma parameter target_scale "Target Scale" 1.0 1.0 10.0 1.0 + +#define saturate(c) clamp(c, 0.0, 1.0) +#define mul(a,b) (b*a) +const int ScreenCount = 1; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const float Epsilon = 1.0e-7f; +const float PI = 3.1415927f; +const float E = 2.7182817f; +const float Gelfond = 23.140692f; // e^pi (Gelfond constant) +const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond-Schneider constant) + +//----------------------------------------------------------------------------- +// Functions +//----------------------------------------------------------------------------- + +// www.stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader/ +float random(vec2 seed) +{ + // irrationals for pseudo randomness + vec2 i = vec2(Gelfond, GelfondSchneider); + + return fract(cos(dot(seed, i)) * 123456.0f); +} + +// www.dinodini.wordpress.com/2010/04/05/normalized-tunable-sigmoid-functions/ +float normalizedSigmoid(float n, float k) +{ + // valid for n and k in range of -1.0 and 1.0 + return (n - n * k) / (k - abs(n) * 2.0f * k + 1); +} + +// www.iquilezles.org/www/articles/distfunctions/distfunctions.htm +float roundBox(vec2 p, vec2 b, float r) +{ + return length(max(abs(p) - b + r, 0.0f)) - r; +} + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +#define DiffuseSampler Source + +float DistortionAmount = params.distortion_amount; // k - quartic distortion coefficient +float CubicDistortionAmount = params.cubic_distortion_amount; // kcube - cubic distortion modifier +float DistortCornerAmount = params.distort_corner_amount; +float RoundCornerAmount = params.round_corner_amount; +float SmoothBorderAmount = params.smooth_border_amount; +float VignettingAmount = params.vignette_amount; +float ReflectionAmount = params.reflection_amount; +vec3 LightReflectionColor = vec3(params.reflection_col_r, params.reflection_col_g, params.reflection_col_b); // color temperature 5.000 Kelvin + +bool SwapXY = bool(params.swapxy); +vec2 QuadDims = params.SourceSize.xy; +vec2 TargetDims = params.SourceSize.xy; +float TargetScale = params.target_scale; + +float GetNoiseFactor(vec3 n, float random) +{ + // smaller n become more noisy + return 1.0f + random * max(0.0f, 0.25f * pow(E, -8 * n.x)); +} + +float GetVignetteFactor(vec2 coord, float amount) +{ + vec2 VignetteCoord = coord; + + float VignetteLength = length(VignetteCoord); + float VignetteBlur = (amount * 0.75f) + 0.25; + + // 0.5 full screen fitting circle + float VignetteRadius = 1.0f - (amount * 0.25f); + float Vignette = smoothstep(VignetteRadius, VignetteRadius - VignetteBlur, VignetteLength); + + return saturate(Vignette); +} + +float GetSpotAddend(vec2 coord, float amount) +{ + vec2 SpotCoord = coord; + + // upper right quadrant + vec2 spotOffset = vec2(-0.25f, 0.25f); + + // normalized screen canvas ratio + vec2 CanvasRatio = SwapXY + ? vec2(1.0f, QuadDims.x / QuadDims.y) + : vec2(1.0f, QuadDims.y / QuadDims.x); + + SpotCoord += spotOffset; + SpotCoord *= CanvasRatio; + + float SpotBlur = amount; + + // 0.5 full screen fitting circle + float SpotRadius = amount * 0.75f; + float Spot = smoothstep(SpotRadius, SpotRadius - SpotBlur, length(SpotCoord)); + + float SigmoidSpot = amount * normalizedSigmoid(Spot, 0.75); + + // increase strength by 100% + SigmoidSpot = SigmoidSpot * 2.0f; + + return saturate(SigmoidSpot); +} + +float GetBoundsFactor(vec2 coord, vec2 bounds, float radiusAmount, float smoothAmount) +{ + // reduce smooth amount down to radius amount + smoothAmount = min(smoothAmount, radiusAmount); + + float range = min(bounds.x, bounds.y); + float amountMinimum = 1.0f / range; + float radius = range * max(radiusAmount, amountMinimum); + float smooth_ = 1.0f / (range * max(smoothAmount, amountMinimum * 2.0f)); + + // compute box + float box = roundBox(bounds * (coord * 2.0f), bounds, radius); + + // apply smooth + box *= smooth_; + box += 1.0f - pow(smooth_ * 0.5f, 0.5f); + + float border = smoothstep(1.0f, 0.0f, box); + + return saturate(border); +} + +// www.francois-tarlier.com/blog/cubic-lens-distortion-shader/ +vec2 GetDistortedCoords(vec2 centerCoord, float amount, float amountCube) +{ + // lens distortion coefficient + float k = amount; + + // cubic distortion value + float kcube = amountCube; + + // compute cubic distortion factor + float r2 = centerCoord.x * centerCoord.x + centerCoord.y * centerCoord.y; + float f = kcube == 0.0f + ? 1.0f + r2 * k + : 1.0f + r2 * (k + kcube * sqrt(r2)); + + // fit screen bounds + f /= 1.0f + amount * 0.25f + amountCube * 0.125f; + + // apply cubic distortion factor + centerCoord *= f; + + return centerCoord; +} + +vec2 GetTextureCoords(vec2 coord, float distortionAmount, float cubicDistortionAmount) +{ + // center coordinates + coord -= 0.5f; + + // distort coordinates + coord = GetDistortedCoords(coord, distortionAmount, cubicDistortionAmount); + + // un-center coordinates + coord += 0.5f; + + return coord; +} + +vec2 GetQuadCoords(vec2 coord, vec2 scale, float distortionAmount, float cubicDistortionAmount) +{ + // center coordinates + coord -= 0.5f; + + // apply scale + coord *= scale; + + // distort coordinates + coord = GetDistortedCoords(coord, distortionAmount, cubicDistortionAmount); + + return coord; +} + +void main() +{ + // image distortion + float distortionAmount = DistortionAmount; + float cubicDistortionAmount = CubicDistortionAmount > 0.0f + ? CubicDistortionAmount * 1.1f // cubic distortion need to be a little higher to compensate the quartic distortion + : CubicDistortionAmount * 1.2f; // negativ values even more + + // corner distortion at least by the amount of the image distorition + float distortCornerAmount = max(DistortCornerAmount, DistortionAmount + CubicDistortionAmount); + + float roundCornerAmount = RoundCornerAmount * 0.5f; + float smoothBorderAmount = SmoothBorderAmount * 0.5f; + + vec2 TexelDims = 1.0f / TargetDims; + + // base-target dimensions (without oversampling) + vec2 BaseTargetDims = TargetDims / TargetScale; + BaseTargetDims = SwapXY + ? BaseTargetDims.yx + : BaseTargetDims.xy; + + // base-target/quad difference scale + vec2 BaseTargetQuadScale = (ScreenCount == 1) + ? BaseTargetDims / QuadDims // keeps the coords inside of the quad bounds of a single screen + : vec2(1.0); + + // Screen Texture Curvature + vec2 BaseCoord = GetTextureCoords(vTexCoord, distortionAmount, cubicDistortionAmount); + + // Screen Quad Curvature + vec2 QuadCoord = GetQuadCoords(vTexCoord, BaseTargetQuadScale, distortCornerAmount, 0.0f); +/* + // clip border + if (BaseCoord.x < 0.0f - TexelDims.x || BaseCoord.y < 0.0f - TexelDims.y || + BaseCoord.x > 1.0f + TexelDims.x || BaseCoord.y > 1.0f + TexelDims.y) + { + // we don't use the clip function, because we don't clear the render target before + return vec4(0.0f, 0.0f, 0.0f, 1.0f); + } +*/ + + // Color + vec4 BaseColor = texture(DiffuseSampler, BaseCoord); + BaseColor.a = 1.0f; + + // Vignetting Simulation + vec2 VignetteCoord = QuadCoord; + + float VignetteFactor = GetVignetteFactor(VignetteCoord, VignettingAmount); + BaseColor.rgb *= VignetteFactor; + + // Light Reflection Simulation + vec2 SpotCoord = QuadCoord; + + vec3 SpotAddend = GetSpotAddend(SpotCoord, ReflectionAmount) * LightReflectionColor; + BaseColor.rgb += SpotAddend * GetNoiseFactor(SpotAddend, random(SpotCoord)); + + // Round Corners Simulation + vec2 RoundCornerCoord = QuadCoord; + vec2 RoundCornerBounds = (ScreenCount == 1) + ? QuadDims // align corners to quad bounds of a single screen + : BaseTargetDims; // align corners to target bounds of multiple screens + RoundCornerBounds = SwapXY + ? RoundCornerBounds.yx + : RoundCornerBounds.xy; + + float roundCornerFactor = GetBoundsFactor(RoundCornerCoord, RoundCornerBounds, roundCornerAmount, smoothBorderAmount); + BaseColor.rgb *= roundCornerFactor; + + FragColor = BaseColor; +} diff --git a/test/nonfunctional/shaders/mame/mame_downsample.slang b/test/nonfunctional/shaders/mame/mame_downsample.slang new file mode 100644 index 0000000..61db9b9 --- /dev/null +++ b/test/nonfunctional/shaders/mame/mame_downsample.slang @@ -0,0 +1,63 @@ +#version 450 + +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz,ImJezze +//----------------------------------------------------------------------------- +// Downsample Effect +//----------------------------------------------------------------------------- + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec4 TexCoord01; +layout(location = 1) out vec4 TexCoord23; + +const vec2 Coord0Offset = vec2(-0.5f, -0.5f); +const vec2 Coord1Offset = vec2( 0.5f, -0.5f); +const vec2 Coord2Offset = vec2(-0.5f, 0.5f); +const vec2 Coord3Offset = vec2( 0.5f, 0.5f); + +void main() +{ + gl_Position = global.MVP * Position; + + vec2 HalfTargetTexelDims = 0.5 * params.SourceSize.zw; + + TexCoord01.xy = TexCoord + Coord0Offset * HalfTargetTexelDims; + TexCoord01.zw = TexCoord + Coord1Offset * HalfTargetTexelDims; + TexCoord23.xy = TexCoord + Coord2Offset * HalfTargetTexelDims; + TexCoord23.zw = TexCoord + Coord3Offset * HalfTargetTexelDims; +} + +#pragma stage fragment +layout(location = 0) in vec4 TexCoord01; +layout(location = 1) in vec4 TexCoord23; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +#define DiffuseSampler Source + +void main() +{ + vec3 texel0 = texture(DiffuseSampler, TexCoord01.xy).rgb; + vec3 texel1 = texture(DiffuseSampler, TexCoord01.zw).rgb; + vec3 texel2 = texture(DiffuseSampler, TexCoord23.xy).rgb; + vec3 texel3 = texture(DiffuseSampler, TexCoord23.zw).rgb; + + vec3 outTexel = (texel0 + texel1 + texel2 + texel3) / 4.0; + + FragColor = vec4(outTexel, 1.0); +} diff --git a/test/nonfunctional/shaders/mame/mame_focus.slang b/test/nonfunctional/shaders/mame/mame_focus.slang new file mode 100644 index 0000000..4ad9350 --- /dev/null +++ b/test/nonfunctional/shaders/mame/mame_focus.slang @@ -0,0 +1,79 @@ +#version 450 + +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz,ImJezze +//----------------------------------------------------------------------------- +// Defocus Effect +//----------------------------------------------------------------------------- + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float defocus_x; + float defocus_y; +} params; + +#pragma parameter defocus_x "Defocus X Axis" 0.0 0.0 10.0 0.1 +#pragma parameter defocus_y "Defocus Y Axis" 0.0 0.0 10.0 0.1 + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +#define DiffuseSampler Source + +vec2 Defocus = vec2(params.defocus_x, params.defocus_y); + +// previously this pass was applied two times with offsets of 0.25, 0.5, 0.75, 1.0 +// now this pass is applied only once with offsets of 0.25, 0.55, 1.0, 1.6 to achieve the same appearance as before till a maximum defocus of 2.0 +const vec2 CoordOffset8[8] = +vec2[8]( + // 0.075x² + 0.225x + 0.25 + vec2(-1.60f, 0.25f), + vec2(-1.00f, -0.55f), + vec2(-0.55f, 1.00f), + vec2(-0.25f, -1.60f), + vec2( 0.25f, 1.60f), + vec2( 0.55f, -1.00f), + vec2( 1.00f, 0.55f), + vec2( 1.60f, -0.25f) +); + +void main() +{ + // imaginary texel dimensions independed from source and target dimension + vec2 TexelDims = vec2(1.0f / 1024.0f); + + vec2 DefocusTexelDims = Defocus * TexelDims; + + vec3 texel = texture(DiffuseSampler, vTexCoord).rgb; + float samples = 1.0f; + + for (int i = 0; i < 8; i++) + { + texel += texture(DiffuseSampler, vTexCoord + CoordOffset8[i] * DefocusTexelDims).rgb; + samples += 1.0f; + } + + FragColor = vec4(texel / samples, 1.0); +} diff --git a/test/nonfunctional/shaders/super-xbr/custom-jinc2-sharper.slang b/test/nonfunctional/shaders/super-xbr/custom-jinc2-sharper.slang deleted file mode 100644 index 1e45a90..0000000 --- a/test/nonfunctional/shaders/super-xbr/custom-jinc2-sharper.slang +++ /dev/null @@ -1,161 +0,0 @@ -#version 450 - -/* - Hyllian's jinc windowed-jinc 2-lobe sharper with anti-ringing Shader - - Copyright (C) 2011-2014 Hyllian/Jararaca - sergiogdb@gmail.com - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; - vec4 OutputSize; - vec4 OriginalSize; - vec4 SourceSize; - uint FrameCount; -} global; - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; - -/* VERTEX_SHADER */ -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord; -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; - -#define JINC2_WINDOW_SINC 0.42 -#define JINC2_SINC 0.92 -#define JINC2_AR_STRENGTH 0.0 -// END PARAMETERS // - -/* - This is an approximation of Jinc(x)*Jinc(x*r1/r2) for x < 2.5, - where r1 and r2 are the first two zeros of jinc function. - For a jinc 2-lobe best approximation, use A=0.5 and B=0.825. -*/ - -// A=0.5, B=0.825 is the best jinc approximation for x<2.5. if B=1.0, it's a lanczos filter. -// Increase A to get more blur. Decrease it to get a sharper picture. -// B = 0.825 to get rid of dithering. Increase B to get a fine sharpness, though dithering returns. - -#define halfpi 1.5707963267948966192313216916398 -#define pi 3.1415926535897932384626433832795 -#define wa (JINC2_WINDOW_SINC*pi) -#define wb (JINC2_SINC*pi) - -vec3 Y = vec3(0.299, 0.587, 0.114); - -// Calculates the distance between two points -float d(vec2 pt1, vec2 pt2) -{ - vec2 v = pt2 - pt1; - return sqrt(dot(v, v)); -} - -vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d) -{ - return min(a, min(b, min(c, d))); -} -vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d) -{ - return max(a, max(b, max(c, d))); -} - -vec4 resampler(vec4 x) -{ - return (x == vec4(0.0)) ? vec4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x); -} - -void main() -{ - vec2 dx = vec2(1.0, 0.0); - vec2 dy = vec2(0.0, 1.0); - - vec2 pc = vTexCoord*global.SourceSize.xy; - - vec2 tc = (floor(pc - vec2(0.5, 0.5)) + vec2(0.5, 0.5)); - - mat4x4 weights = mat4x4( - resampler(vec4(d(pc, tc -dx -dy), d(pc, tc -dy), d(pc, tc +dx -dy), d(pc, tc+2.0*dx -dy))), - resampler(vec4(d(pc, tc -dx ), d(pc, tc ), d(pc, tc +dx ), d(pc, tc+2.0*dx ))), - resampler(vec4(d(pc, tc -dx +dy), d(pc, tc +dy), d(pc, tc +dx +dy), d(pc, tc+2.0*dx +dy))), - resampler(vec4(d(pc, tc -dx+2.0*dy), d(pc, tc +2.0*dy), d(pc, tc +dx+2.0*dy), d(pc, tc+2.0*dx+2.0*dy))) - ); - //weights[0][0] = weights[0][3] = weights[3][0] = weights[3][3] = 0.0; - - dx = dx*global.SourceSize.zw; - dy = dy*global.SourceSize.zw; - tc = tc*global.SourceSize.zw; - - // reading the texels - vec3 c00 = texture(Source, tc -dx -dy).xyz; - vec3 c10 = texture(Source, tc -dy).xyz; - vec3 c20 = texture(Source, tc +dx -dy).xyz; - vec3 c30 = texture(Source, tc+2.0*dx -dy).xyz; - vec3 c01 = texture(Source, tc -dx ).xyz; - vec3 c11 = texture(Source, tc ).xyz; - vec3 c21 = texture(Source, tc +dx ).xyz; - vec3 c31 = texture(Source, tc+2.0*dx ).xyz; - vec3 c02 = texture(Source, tc -dx +dy).xyz; - vec3 c12 = texture(Source, tc +dy).xyz; - vec3 c22 = texture(Source, tc +dx +dy).xyz; - vec3 c32 = texture(Source, tc+2.0*dx +dy).xyz; - vec3 c03 = texture(Source, tc -dx+2.0*dy).xyz; - vec3 c13 = texture(Source, tc +2.0*dy).xyz; - vec3 c23 = texture(Source, tc +dx+2.0*dy).xyz; - vec3 c33 = texture(Source, tc+2.0*dx+2.0*dy).xyz; - - vec3 color; - color = mat4x3(c00, c10, c20, c30) * weights[0]; - color+= mat4x3(c01, c11, c21, c31) * weights[1]; - color+= mat4x3(c02, c12, c22, c32) * weights[2]; - color+= mat4x3(c03, c13, c23, c33) * weights[3]; - color = color / dot( vec4(1.0) * weights, vec4(1.0) ); - - // Anti-ringing - // Get min/max samples - pc = vTexCoord; - c00 = texture(Source, pc ).xyz; - c11 = texture(Source, pc +dx ).xyz; - c21 = texture(Source, pc -dx ).xyz; - c12 = texture(Source, pc +dy).xyz; - c22 = texture(Source, pc -dy).xyz; - - - vec3 min_sample = min4(c11, c21, c12, c22); - vec3 max_sample = max4(c11, c21, c12, c22); - min_sample = min(min_sample, c00); - max_sample = max(max_sample, c00); - - vec3 aux = color; - - color = clamp(color, min_sample, max_sample); - color = mix(aux, color, JINC2_AR_STRENGTH); - - // final sum and weight normalization - FragColor = vec4(color, 1.0); -} diff --git a/test/nonfunctional/shaders/super-xbr/super-xbr-params.inc b/test/nonfunctional/shaders/super-xbr/super-xbr-params.inc deleted file mode 100644 index d7a59c8..0000000 --- a/test/nonfunctional/shaders/super-xbr/super-xbr-params.inc +++ /dev/null @@ -1,3 +0,0 @@ -#define XBR_EDGE_STR 0.6 -#define XBR_WEIGHT 1.0 -#define XBR_ANTI_RINGING 1.0 diff --git a/test/nonfunctional/shaders/super-xbr/super-xbr-pass0.slang b/test/nonfunctional/shaders/super-xbr/super-xbr-pass0.slang deleted file mode 100644 index d4e4f66..0000000 --- a/test/nonfunctional/shaders/super-xbr/super-xbr-pass0.slang +++ /dev/null @@ -1,201 +0,0 @@ -#version 450 -#include "super-xbr-params.inc" - -/* - - ******* Super XBR Shader - pass0 ******* - - Copyright (c) 2015 Hyllian - sergiogdb@gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; - vec4 OutputSize; - vec4 OriginalSize; - vec4 SourceSize; - uint FrameCount; -} global; - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; -layout(location = 1) out vec4 t1; -layout(location = 2) out vec4 t2; -layout(location = 3) out vec4 t3; -layout(location = 4) out vec4 t4; - - -/* VERTEX_SHADER */ -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord; - - vec2 ps = vec2(global.SourceSize.z, global.SourceSize.w); - float dx = ps.x; - float dy = ps.y; - - t1 = vTexCoord.xyxy + vec4(-dx, -dy, 2.0*dx, 2.0*dy); - t2 = vTexCoord.xyxy + vec4( 0, -dy, dx, 2.0*dy); - t3 = vTexCoord.xyxy + vec4(-dx, 0, 2.0*dx, dy); - t4 = vTexCoord.xyxy + vec4( 0, 0, dx, dy); -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 1) in vec4 t1; -layout(location = 2) in vec4 t2; -layout(location = 3) in vec4 t3; -layout(location = 4) in vec4 t4; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; - -#define wp1 1.0 -#define wp2 0.0 -#define wp3 0.0 -#define wp4 2.0 -#define wp5 -1.0 -#define wp6 0.0 - -#define weight1 (XBR_WEIGHT*1.29633/10.0) -#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0) - -vec3 Y = vec3(.2126, .7152, .0722); - -float RGBtoYUV(vec3 color) -{ - return dot(color, Y); -} - -float df(float A, float B) -{ - return abs(A-B); -} - -/* - P1 - |P0|B |C |P1| C F4 |a0|b1|c2|d3| - |D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2| - |G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4| - |P2|H5|I5|P3| D H I5 |d0|e1|f2|g3| - G H5 - P2 -*/ - -float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, - float d2, float d3, float e1, float e2, float e3, float f2, float f3) -{ - return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + - wp2*(df(d2,d3) + df(d0,d1)) + - wp3*(df(d1,d3) + df(d0,d2)) + - wp4* df(d1,d2) + - wp5*(df(c0,c2) + df(e1,e3)) + - wp6*(df(b0,b1) + df(f2,f3))); -} - -float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, - float e3, float e4) -{ - return (wp4*(df(i1,i2) + df(i3,i4)) + - wp1*(df(i1,e1) + df(i2,e2) + df(i3,e3) + df(i4,e4)) + - wp3*(df(i1,e2) + df(i3,e4) + df(e1,i2) + df(e3,i4))); -} - -vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d) -{ - return min(a, min(b, min(c, d))); -} -vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d) -{ - return max(a, max(b, max(c, d))); -} - -void main() -{ - vec3 P0 = texture(Source, t1.xy).xyz; - vec3 P1 = texture(Source, t1.zy).xyz; - vec3 P2 = texture(Source, t1.xw).xyz; - vec3 P3 = texture(Source, t1.zw).xyz; - - vec3 B = texture(Source, t2.xy).xyz; - vec3 C = texture(Source, t2.zy).xyz; - vec3 H5 = texture(Source, t2.xw).xyz; - vec3 I5 = texture(Source, t2.zw).xyz; - - vec3 D = texture(Source, t3.xy).xyz; - vec3 F4 = texture(Source, t3.zy).xyz; - vec3 G = texture(Source, t3.xw).xyz; - vec3 I4 = texture(Source, t3.zw).xyz; - - vec3 E = texture(Source, t4.xy).xyz; - vec3 F = texture(Source, t4.zy).xyz; - vec3 H = texture(Source, t4.xw).xyz; - vec3 I = texture(Source, t4.zw).xyz; - - float b = RGBtoYUV( B ); - float c = RGBtoYUV( C ); - float d = RGBtoYUV( D ); - float e = RGBtoYUV( E ); - float f = RGBtoYUV( F ); - float g = RGBtoYUV( G ); - float h = RGBtoYUV( H ); - float i = RGBtoYUV( I ); - - float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 ); - float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 ); - float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 ); - float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 ); - - - /* Calc edgeness in diagonal directions. */ - float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 )); - - /* Calc edgeness in horizontal/vertical directions. */ - float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - - hv_wd(e, f, h, i, d, f4, g, i4)); - - float limits = XBR_EDGE_STR + 0.000001; - float edge_strength = smoothstep(0.0, limits, abs(d_edge)); - - /* Filter weights. Two taps only. */ - vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1); - vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2); - - /* Filtering and normalization in four direction generating four colors. */ - vec3 c1 = mat4x3( P2, H, F, P1 ) * w1; - vec3 c2 = mat4x3( P0, E, I, P3 ) * w1; - vec3 c3 = mat4x3(D+G, E+H, F+I, F4+I4) * w2; - vec3 c4 = mat4x3(C+B, F+E, I+H, I5+H5) * w2; - - /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */ - vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1 - edge_strength); - - /* Anti-ringing code. */ - vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge)); - vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge)); - color = clamp(color, min_sample, max_sample); - - FragColor = vec4(color, 1.0); -} diff --git a/test/nonfunctional/shaders/super-xbr/super-xbr-pass1.slang b/test/nonfunctional/shaders/super-xbr/super-xbr-pass1.slang deleted file mode 100644 index 9c6ff38..0000000 --- a/test/nonfunctional/shaders/super-xbr/super-xbr-pass1.slang +++ /dev/null @@ -1,191 +0,0 @@ -#version 450 -#include "super-xbr-params.inc" - -/* - - ******* Super XBR Shader - pass1 ******* - - Copyright (c) 2015 Hyllian - sergiogdb@gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; - vec4 OutputSize; - vec4 OriginalSize; - vec4 SourceSize; - uint FrameCount; -} global; - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; - -/* VERTEX_SHADER */ -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord; -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; -layout(set = 0, binding = 3) uniform sampler2D Original; - -#define wp1 1.0 -#define wp2 0.0 -#define wp3 0.0 -#define wp4 4.0 -#define wp5 0.0 -#define wp6 0.0 - -#define weight1 (XBR_WEIGHT*1.75068/10.0) -#define weight2 (XBR_WEIGHT*1.29633/10.0/2.0) - -const vec3 Y = vec3(.2126, .7152, .0722); - -float RGBtoYUV(vec3 color) -{ - return dot(color, Y); -} - -float df(float A, float B) -{ - return abs(A-B); -} - -/* - P1 - |P0|B |C |P1| C F4 |a0|b1|c2|d3| - |D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2| - |G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4| - |P2|H5|I5|P3| D H I5 |d0|e1|f2|g3| - G H5 - P2 -*/ - -float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, - float d2, float d3, float e1, float e2, float e3, float f2, float f3) -{ - return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + - wp2*(df(d2,d3) + df(d0,d1)) + - wp3*(df(d1,d3) + df(d0,d2)) + - wp4* df(d1,d2) + - wp5*(df(c0,c2) + df(e1,e3)) + - wp6*(df(b0,b1) + df(f2,f3))); -} - -float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, - float e3, float e4) -{ - return (wp4*(df(i1,i2) + df(i3,i4)) + - wp1*(df(i1,e1) + df(i2,e2) + df(i3,e3) + df(i4,e4)) + - wp3*(df(i1,e2) + df(i3,e4) + df(e1,i2) + df(e3,i4))); -} - -vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d) -{ - return min(a, min(b, min(c, d))); -} -vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d) -{ - return max(a, max(b, max(c, d))); -} - -void main() -{ - //Skip pixels on wrong grid - vec2 fp = fract(vTexCoord*global.SourceSize.xy); - vec2 dir = fp - vec2(0.5, 0.5); - if ((dir.x*dir.y) > 0.0) - FragColor = (fp.x > 0.5) ? texture(Source, vTexCoord) : texture(Original, vTexCoord); - - vec2 g1 = (fp.x>0.5) ? vec2(0.5*global.SourceSize.z, 0.0) : vec2(0.0, 0.5*global.SourceSize.w); - vec2 g2 = (fp.x>0.5) ? vec2(0.0, 0.5*global.SourceSize.w) : vec2(0.5*global.SourceSize.z, 0.0); - - vec3 P0 = texture(Original, vTexCoord -3.0*g1 ).xyz; - vec3 P1 = texture( Source, vTexCoord -3.0*g2).xyz; - vec3 P2 = texture( Source, vTexCoord +3.0*g2).xyz; - vec3 P3 = texture(Original, vTexCoord +3.0*g1 ).xyz; - - vec3 B = texture( Source, vTexCoord -2.0*g1 -g2).xyz; - vec3 C = texture(Original, vTexCoord -g1 -2.0*g2).xyz; - vec3 D = texture( Source, vTexCoord -2.0*g1 +g2).xyz; - vec3 E = texture(Original, vTexCoord -g1 ).xyz; - vec3 F = texture( Source, vTexCoord -g2).xyz; - vec3 G = texture(Original, vTexCoord -g1 +2.0*g2).xyz; - vec3 H = texture( Source, vTexCoord +g2).xyz; - vec3 I = texture(Original, vTexCoord +g1 ).xyz; - - vec3 F4 = texture(Original, vTexCoord +g1 -2.0*g2).xyz; - vec3 I4 = texture( Source, vTexCoord +2.0*g1 -g2).xyz; - vec3 H5 = texture(Original, vTexCoord +g1 +2.0*g2).xyz; - vec3 I5 = texture( Source, vTexCoord +2.0*g1 +g2).xyz; - - float b = RGBtoYUV( B ); - float c = RGBtoYUV( C ); - float d = RGBtoYUV( D ); - float e = RGBtoYUV( E ); - float f = RGBtoYUV( F ); - float g = RGBtoYUV( G ); - float h = RGBtoYUV( H ); - float i = RGBtoYUV( I ); - - float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 ); - float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 ); - float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 ); - float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 ); - - /* Calc edgeness in diagonal directions. */ - float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 )); - - /* Calc edgeness in horizontal/vertical directions. */ - float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - - hv_wd(e, f, h, i, d, f4, g, i4)); - - float limits = XBR_EDGE_STR + 0.000001; - float edge_strength = smoothstep(0.0, limits, abs(d_edge)); - - /* Filter weights. Two taps only. */ - vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1); - vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2); - - /* Filtering and normalization in four direction generating four colors. */ - vec3 c1 = mat4x3( P2, H, F, P1 ) * w1; - vec3 c2 = mat4x3( P0, E, I, P3 ) * w1; - vec3 c3 = mat4x3(D+G, E+H, F+I, F4+I4) * w2; - vec3 c4 = mat4x3(C+B, F+E, I+H, I5+H5) * w2; - - /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */ - vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1 - edge_strength); - - /* Anti-ringing code. */ - vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge)); - vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge)); - color = clamp(color, min_sample, max_sample); - - FragColor = vec4(color, 1.0); -} diff --git a/test/nonfunctional/shaders/super-xbr/super-xbr-pass2.slang b/test/nonfunctional/shaders/super-xbr/super-xbr-pass2.slang deleted file mode 100644 index 6447844..0000000 --- a/test/nonfunctional/shaders/super-xbr/super-xbr-pass2.slang +++ /dev/null @@ -1,200 +0,0 @@ -#version 450 -#include "super-xbr-params.inc" - -/* - - ******* Super XBR Shader - pass2 ******* This pass is optional. - - Copyright (c) 2015 Hyllian - sergiogdb@gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; - vec4 OutputSize; - vec4 OriginalSize; - vec4 SourceSize; - uint FrameCount; -} global; - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; -layout(location = 1) out vec4 t1; -layout(location = 2) out vec4 t2; -layout(location = 3) out vec4 t3; -layout(location = 4) out vec4 t4; - - -/* VERTEX_SHADER */ -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord; - - vec2 ps = vec2(global.SourceSize.z, global.SourceSize.w); - float dx = ps.x; - float dy = ps.y; - - t1 = vTexCoord.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy); - t2 = vTexCoord.xyxy + vec4( -dx, -2.0*dy, 0, dy); - t3 = vTexCoord.xyxy + vec4(-2.0*dx, -dy, dx, 0); - t4 = vTexCoord.xyxy + vec4( -dx, -dy, 0, 0); -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 1) in vec4 t1; -layout(location = 2) in vec4 t2; -layout(location = 3) in vec4 t3; -layout(location = 4) in vec4 t4; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; - -#define wp1 1.0 -#define wp2 0.0 -#define wp3 0.0 -#define wp4 0.0 -#define wp5 -1.0 -#define wp6 0.0 - -#define weight1 (XBR_WEIGHT*1.29633/10.0) -#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0) - -vec3 Y = vec3(.2126, .7152, .0722); - -float RGBtoYUV(vec3 color) -{ - return dot(color, Y); -} - -float df(float A, float B) -{ - return abs(A-B); -} - -/* - P1 - |P0|B |C |P1| C F4 |a0|b1|c2|d3| - |D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2| - |G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4| - |P2|H5|I5|P3| D H I5 |d0|e1|f2|g3| - G H5 - P2 -*/ - -float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, - float d2, float d3, float e1, float e2, float e3, float f2, float f3) -{ - return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + - wp2*(df(d2,d3) + df(d0,d1)) + - wp3*(df(d1,d3) + df(d0,d2)) + - wp4* df(d1,d2) + - wp5*(df(c0,c2) + df(e1,e3)) + - wp6*(df(b0,b1) + df(f2,f3))); -} - -float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, - float e3, float e4) -{ - return (wp4*(df(i1,i2) + df(i3,i4)) + - wp1*(df(i1,e1) + df(i2,e2) + df(i3,e3) + df(i4,e4)) + - wp3*(df(i1,e2) + df(i3,e4) + df(e1,i2) + df(e3,i4))); -} - -vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d) -{ - return min(a, min(b, min(c, d))); -} -vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d) -{ - return max(a, max(b, max(c, d))); -} - -void main() -{ - vec3 P0 = texture(Source, t1.xy).xyz; - vec3 P1 = texture(Source, t1.zy).xyz; - vec3 P2 = texture(Source, t1.xw).xyz; - vec3 P3 = texture(Source, t1.zw).xyz; - - vec3 B = texture(Source, t2.xy).xyz; - vec3 C = texture(Source, t2.zy).xyz; - vec3 H5 = texture(Source, t2.xw).xyz; - vec3 I5 = texture(Source, t2.zw).xyz; - - vec3 D = texture(Source, t3.xy).xyz; - vec3 F4 = texture(Source, t3.zy).xyz; - vec3 G = texture(Source, t3.xw).xyz; - vec3 I4 = texture(Source, t3.zw).xyz; - - vec3 E = texture(Source, t4.xy).xyz; - vec3 F = texture(Source, t4.zy).xyz; - vec3 H = texture(Source, t4.xw).xyz; - vec3 I = texture(Source, t4.zw).xyz; - - float b = RGBtoYUV( B ); - float c = RGBtoYUV( C ); - float d = RGBtoYUV( D ); - float e = RGBtoYUV( E ); - float f = RGBtoYUV( F ); - float g = RGBtoYUV( G ); - float h = RGBtoYUV( H ); - float i = RGBtoYUV( I ); - - float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 ); - float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 ); - float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 ); - float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 ); - - /* Calc edgeness in diagonal directions. */ - float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 )); - - /* Calc edgeness in horizontal/vertical directions. */ - float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - - hv_wd(e, f, h, i, d, f4, g, i4)); - - float limits = XBR_EDGE_STR + 0.000001; - float edge_strength = smoothstep(0.0, limits, abs(d_edge)); - - /* Filter weights. Two taps only. */ - vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1); - vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2); - - /* Filtering and normalization in four direction generating four colors. */ - vec3 c1 = mat4x3( P2, H, F, P1 ) * w1; - vec3 c2 = mat4x3( P0, E, I, P3 ) * w1; - vec3 c3 = mat4x3(D+G, E+H, F+I, F4+I4) * w2; - vec3 c4 = mat4x3(C+B, F+E, I+H, I5+H5) * w2; - - /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */ - vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1 - edge_strength); - - /* Anti-ringing code. */ - vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge)); - vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge)); - color = clamp(color, min_sample, max_sample); - - FragColor = vec4(color, 1.0); -} diff --git a/test/nonfunctional/shaders/xbr-lv3-noblend-standard.slang b/test/nonfunctional/shaders/xbr-lv3-noblend-standard.slang deleted file mode 100644 index c2ea7dd..0000000 --- a/test/nonfunctional/shaders/xbr-lv3-noblend-standard.slang +++ /dev/null @@ -1,236 +0,0 @@ -#version 450 - -/* - Hyllian's xBR-lv3-noblend shader - ported to GLSL by guest.r - - Copyright (C) 2011/2016 Hyllian - sergiogdb@gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -layout(push_constant) uniform Push -{ - vec4 SourceSize; - vec4 OriginalSize; - vec4 OutputSize; - uint FrameCount; -} params; - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; -} global; - -// Uncomment just one of the three params below to choose the corner detection -//#define CORNER_A -//#define CORNER_B -#define CORNER_C -//#define CORNER_D - - -#define XBR_EQ_THRESHOLD 0.6 -#define XBR_EQ_THRESHOLD2 0.01 -#define XBR_LV2_COEFFICIENT 2.0 - - -const vec3 Y = vec3(0.2126, 0.7152, 0.0722); - -//const vec2 OGLSize = vec2( 1024.0, 512.0); // replace with params.SourceSize.xy -//const vec2 OGLInvSize = vec2( 0.0009765625, 0.001953125); // replace with params.SourceSize.zw -const vec2 dx = vec2( 0.0009765625, 0.0); -const vec2 dy = vec2( 0.0, 0.001953125 ); -const vec2 x2 = vec2( 0.001953125 , 0.0); -const vec2 y2 = vec2( 0.0 , 0.00390625 ); -const vec4 xy = vec4( 0.0009765625, 0.001953125,-0.0009765625,-0.001953125); -const vec4 zw = vec4( 0.001953125 , 0.001953125,-0.001953125 ,-0.001953125); -const vec4 wz = vec4( 0.0009765625, 0.00390625 ,-0.0009765625,-0.00390625 ); - - -vec4 noteq(vec4 A, vec4 B) -{ - return vec4(notEqual(A, B)); -} - -vec4 not(vec4 A) -{ - return vec4(1.0)-A; -} - -vec4 df(vec4 A, vec4 B) -{ - return abs(A-B); -} - -vec4 eq(vec4 A, vec4 B) -{ - return vec4(lessThan(df(A, B), vec4(XBR_EQ_THRESHOLD))); -} - - -vec4 eq2(vec4 A, vec4 B) -{ - return vec4(lessThan(df(A, B), vec4(XBR_EQ_THRESHOLD2))); -} - - -vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) -{ - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; - -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord; -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; - -void main() -{ - vec4 edr, edri, edr_left, edr_up, edr3_left, edr3_up; // px = pixel, edr = edge detection rule - vec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up, interp_restriction_lv3_left, interp_restriction_lv3_up; - vec4 fx, fx_left, fx_up, final_fx, fx3_left, fx3_up; // inequations of straight lines. - bvec4 nc, px; - - vec2 fp = fract(vTexCoord.xy*params.SourceSize.xy); - vec2 TexCoord_0 = vTexCoord.xy-fp*params.SourceSize.zw + 0.5*params.SourceSize.zw; - - vec3 A = texture(Source, TexCoord_0 + xy.zw ).xyz; - vec3 B = texture(Source, TexCoord_0 -dy ).xyz; - vec3 C = texture(Source, TexCoord_0 + xy.xw ).xyz; - vec3 D = texture(Source, TexCoord_0 - dx ).xyz; - vec3 E = texture(Source, TexCoord_0 ).xyz; - vec3 F = texture(Source, TexCoord_0 + dx ).xyz; - vec3 G = texture(Source, TexCoord_0 + xy.zy ).xyz; - vec3 H = texture(Source, TexCoord_0 +dy ).xyz; - vec3 I = texture(Source, TexCoord_0 + xy.xy ).xyz; - vec3 A1 = texture(Source, TexCoord_0 + wz.zw ).xyz; - vec3 C1 = texture(Source, TexCoord_0 + wz.xw ).xyz; - vec3 A0 = texture(Source, TexCoord_0 + zw.zw ).xyz; - vec3 G0 = texture(Source, TexCoord_0 + zw.zy ).xyz; - vec3 C4 = texture(Source, TexCoord_0 + zw.xw ).xyz; - vec3 I4 = texture(Source, TexCoord_0 + zw.xy ).xyz; - vec3 G5 = texture(Source, TexCoord_0 + wz.zy ).xyz; - vec3 I5 = texture(Source, TexCoord_0 + wz.xy ).xyz; - vec3 B1 = texture(Source, TexCoord_0 - y2 ).xyz; - vec3 D0 = texture(Source, TexCoord_0 - x2 ).xyz; - vec3 H5 = texture(Source, TexCoord_0 + y2 ).xyz; - vec3 F4 = texture(Source, TexCoord_0 + x2 ).xyz; - - vec4 b = vec4(dot(B ,Y), dot(D ,Y), dot(H ,Y), dot(F ,Y)); - vec4 c = vec4(dot(C ,Y), dot(A ,Y), dot(G ,Y), dot(I ,Y)); - vec4 d = b.yzwx; - vec4 e = vec4(dot(E,Y)); - vec4 f = b.wxyz; - vec4 g = c.zwxy; - vec4 h = b.zwxy; - vec4 i = c.wxyz; - vec4 i4 = vec4(dot(I4,Y), dot(C1,Y), dot(A0,Y), dot(G5,Y)); - vec4 i5 = vec4(dot(I5,Y), dot(C4,Y), dot(A1,Y), dot(G0,Y)); - vec4 h5 = vec4(dot(H5,Y), dot(F4,Y), dot(B1,Y), dot(D0,Y)); - vec4 f4 = h5.yzwx; - vec4 c4 = i5.yzwx; - vec4 g5 = i4.wxyz; - vec4 c1 = i4.yzwx; - vec4 g0 = i5.wxyz; - vec4 b1 = h5.zwxy; - vec4 d0 = h5.wxyz; - - vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); - vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); - vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); - vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); - vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); - vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); - vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); - vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); - vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); - - vec4 Az = vec4( 6.0, -2.0, -6.0, 2.0 ); - vec4 Bz = vec4( 2.0, 6.0, -2.0, -6.0 ); - vec4 Cz = vec4( 5.0, 3.0, -3.0, -1.0 ); - vec4 Aw = vec4( 2.0, -6.0, -2.0, 6.0 ); - vec4 Bw = vec4( 6.0, 2.0, -6.0,-2.0 ); - vec4 Cw = vec4( 5.0, -1.0, -3.0, 3.0 ); - - -// These inequations define the line below which interpolation occurs. - fx = vec4(greaterThan(Ao*fp.y+Bo*fp.x, Co)); - fx_left = vec4(greaterThan(Ax*fp.y+Bx*fp.x, Cx)); - fx_up = vec4(greaterThan(Ay*fp.y+By*fp.x, Cy)); - fx3_left = vec4(greaterThan(Az*fp.y+Bz*fp.x, Cz)); - fx3_up = vec4(greaterThan(Aw*fp.y+Bw*fp.x, Cw)); - - -#ifdef CORNER_A - interp_restriction_lv1 = sign(noteq(e,f) * noteq(e,h)); -#endif -#ifdef CORNER_B - interp_restriction_lv1 = sign(noteq(e,f) * noteq(e,h) * ( not(eq(f,b)) * not(eq(h,d)) + eq(e,i) * not(eq(f,i4)) * not(eq(h,i5)) + eq(e,g) + eq(e,c))); -#endif -#ifdef CORNER_D - interp_restriction_lv1 = sign(noteq(e,f)*noteq(e,h)*(not(eq(f,b))* not(eq(h,d)) + eq(e,i) * not(eq(f,i4)) * not(eq(h,i5)) + eq(e,g) + eq(e,c) ) * (noteq(f,f4)* noteq(f,i) + noteq(h,h5) * noteq(h,i) + noteq(h,g) + noteq(f,c) + eq(b,c1) * eq(d,g0))); -#endif -#ifdef CORNER_C - interp_restriction_lv1 = sign(noteq(e,f) * noteq(e,h) * ( not(eq(f,b)) * not(eq(f,c)) + not(eq(h,d)) * not(eq(h,g)) + eq(e,i) * (not(eq(f,f4)) * not(eq(f,i4)) + not(eq(h,h5)) * not(eq(h,i5))) + eq(e,g) + eq(e,c))); -#endif - - interp_restriction_lv2_left = noteq(e,g)* noteq(d,g); - interp_restriction_lv2_up = noteq(e,c)* noteq(b,c); - interp_restriction_lv3_left = eq2(g,g0) * noteq(d0,g0); - interp_restriction_lv3_up = eq2(c,c1) * noteq(b1,c1); - - vec4 wd1 = weighted_distance( e, c, g, i, h5, f4, h, f); - vec4 wd2 = weighted_distance( h, d, i5, f, i4, b, e, i); - - edri = vec4(lessThanEqual(wd1, wd2)) * interp_restriction_lv1; - edr = vec4(lessThan(wd1, wd2)) * interp_restriction_lv1; - - edr = edr * sign(not(edri.yzwx) + not(edri.wxyz)); - edr_left = vec4(lessThanEqual(XBR_LV2_COEFFICIENT*df(f,g), df(h,c))) * interp_restriction_lv2_left * edr * (not(edri.yzwx) * eq(e,c)); - edr_up = vec4(greaterThanEqual(df(f,g), XBR_LV2_COEFFICIENT*df(h,c))) * interp_restriction_lv2_up * edr * (not(edri.wxyz) * eq(e,g)); - edr3_left = interp_restriction_lv3_left; - edr3_up = interp_restriction_lv3_up; - - nc = bvec4( edr * ( fx + edr_left * (fx_left + edr3_left * fx3_left * eq(e,c4)) + edr_up * (fx_up + edr3_up * fx3_up * eq(e,g5)))); - - px = lessThanEqual(df(e,f),df(e,h)); - - vec3 res1 = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E; - vec3 res2 = nc.w ? px.w ? H : D : nc.z ? px.z ? D : B : nc.y ? px.y ? B : F : nc.x ? px.x ? F : H : E; - - vec2 df12; - - df12.x = abs(dot(res1, Y) - e.x); - df12.y = abs(dot(res2, Y) - e.y); - - vec3 res = mix(res1, res2, step(df12.x, df12.y)); - - FragColor = vec4(res, 1.0); -} \ No newline at end of file diff --git a/test/nonfunctional/shaders/xbr-lv3-noblend.slang b/test/nonfunctional/shaders/xbr-lv3-noblend.slang deleted file mode 100644 index fac2f50..0000000 --- a/test/nonfunctional/shaders/xbr-lv3-noblend.slang +++ /dev/null @@ -1,255 +0,0 @@ -#version 450 - -/* - Hyllian's xBR-lv3-noblend shader - ported to GLSL by guest.r - - Copyright (C) 2011/2016 Hyllian - sergiogdb@gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -layout(push_constant) uniform Push -{ - vec4 SourceSize; - vec4 OriginalSize; - vec4 OutputSize; - uint FrameCount; -} params; - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; -} global; - -// Uncomment just one of the three params below to choose the corner detection -//#define CORNER_A -//#define CORNER_B -#define CORNER_C -//#define CORNER_D - - -#define XBR_EQ_THRESHOLD 0.6 -#define XBR_EQ_THRESHOLD2 0.01 -#define XBR_LV2_COEFFICIENT 2.0 - -#define XBR_RED_COEF 17.0 -#define XBR_GREEN_COEF 20.0 -#define XBR_BLUE_COEF 3.0 - -const vec3 Y = vec3(0.2126, 0.7152, 0.0722); - -//const vec2 OGLSize = vec2( 1024.0, 512.0); // replace with params.SourceSize.xy -//const vec2 OGLInvSize = vec2( 0.0009765625, 0.001953125); // replace with params.SourceSize.zw -const vec2 dx = vec2( 0.0009765625, 0.0); -const vec2 dy = vec2( 0.0, 0.001953125 ); -const vec2 x2 = vec2( 0.001953125 , 0.0); -const vec2 y2 = vec2( 0.0 , 0.00390625 ); -const vec4 xy = vec4( 0.0009765625, 0.001953125,-0.0009765625,-0.001953125); -const vec4 zw = vec4( 0.001953125 , 0.001953125,-0.001953125 ,-0.001953125); -const vec4 wz = vec4( 0.0009765625, 0.00390625 ,-0.0009765625,-0.00390625 ); - - -vec4 noteq(vec4 A, vec4 B) -{ - return vec4(notEqual(A, B)); -} - -vec4 not(vec4 A) -{ - return vec4(1.0)-A; -} - -vec4 df(vec4 A, vec4 B) -{ - return abs(A-B); -} - -vec4 eq(vec4 A, vec4 B) -{ - return vec4(lessThan(df(A, B), vec4(XBR_EQ_THRESHOLD))); -} - - -vec4 eq2(vec4 A, vec4 B) -{ - return vec4(lessThan(df(A, B), vec4(XBR_EQ_THRESHOLD2))); -} - - -vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) -{ - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} - - -float df1(vec3 A, vec3 B) -{ - float rmean = (A.r+B.r)/2.0; - vec3 diff = A - B; - vec3 K = vec3(XBR_RED_COEF+rmean, XBR_GREEN_COEF, XBR_BLUE_COEF-rmean); - return sqrt(dot(K*diff, diff)); -} - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; - -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord; -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; - -void main() -{ - vec4 edr, edri, edr_left, edr_up, edr3_left, edr3_up; // px = pixel, edr = edge detection rule - vec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up, interp_restriction_lv3_left, interp_restriction_lv3_up; - vec4 fx, fx_left, fx_up, final_fx, fx3_left, fx3_up; // inequations of straight lines. - bvec4 nc, px; - - vec2 fp = fract(vTexCoord.xy*params.SourceSize.xy); - vec2 TexCoord_0 = vTexCoord.xy-fp*params.SourceSize.zw + 0.5*params.SourceSize.zw; - - vec3 A = texture(Source, TexCoord_0 + xy.zw ).xyz; - vec3 B = texture(Source, TexCoord_0 -dy ).xyz; - vec3 C = texture(Source, TexCoord_0 + xy.xw ).xyz; - vec3 D = texture(Source, TexCoord_0 - dx ).xyz; - vec3 E = texture(Source, TexCoord_0 ).xyz; - vec3 F = texture(Source, TexCoord_0 + dx ).xyz; - vec3 G = texture(Source, TexCoord_0 + xy.zy ).xyz; - vec3 H = texture(Source, TexCoord_0 +dy ).xyz; - vec3 I = texture(Source, TexCoord_0 + xy.xy ).xyz; - vec3 A1 = texture(Source, TexCoord_0 + wz.zw ).xyz; - vec3 C1 = texture(Source, TexCoord_0 + wz.xw ).xyz; - vec3 A0 = texture(Source, TexCoord_0 + zw.zw ).xyz; - vec3 G0 = texture(Source, TexCoord_0 + zw.zy ).xyz; - vec3 C4 = texture(Source, TexCoord_0 + zw.xw ).xyz; - vec3 I4 = texture(Source, TexCoord_0 + zw.xy ).xyz; - vec3 G5 = texture(Source, TexCoord_0 + wz.zy ).xyz; - vec3 I5 = texture(Source, TexCoord_0 + wz.xy ).xyz; - vec3 B1 = texture(Source, TexCoord_0 - y2 ).xyz; - vec3 D0 = texture(Source, TexCoord_0 - x2 ).xyz; - vec3 H5 = texture(Source, TexCoord_0 + y2 ).xyz; - vec3 F4 = texture(Source, TexCoord_0 + x2 ).xyz; - - vec4 b = vec4(dot(B ,Y), dot(D ,Y), dot(H ,Y), dot(F ,Y)); - vec4 c = vec4(dot(C ,Y), dot(A ,Y), dot(G ,Y), dot(I ,Y)); - vec4 d = b.yzwx; - vec4 e = vec4(dot(E,Y)); - vec4 f = b.wxyz; - vec4 g = c.zwxy; - vec4 h = b.zwxy; - vec4 i = c.wxyz; - vec4 i4 = vec4(dot(I4,Y), dot(C1,Y), dot(A0,Y), dot(G5,Y)); - vec4 i5 = vec4(dot(I5,Y), dot(C4,Y), dot(A1,Y), dot(G0,Y)); - vec4 h5 = vec4(dot(H5,Y), dot(F4,Y), dot(B1,Y), dot(D0,Y)); - vec4 f4 = h5.yzwx; - vec4 c4 = i5.yzwx; - vec4 g5 = i4.wxyz; - vec4 c1 = i4.yzwx; - vec4 g0 = i5.wxyz; - vec4 b1 = h5.zwxy; - vec4 d0 = h5.wxyz; - - vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); - vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); - vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); - vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); - vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); - vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); - vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); - vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); - vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); - - vec4 Az = vec4( 6.0, -2.0, -6.0, 2.0 ); - vec4 Bz = vec4( 2.0, 6.0, -2.0, -6.0 ); - vec4 Cz = vec4( 5.0, 3.0, -3.0, -1.0 ); - vec4 Aw = vec4( 2.0, -6.0, -2.0, 6.0 ); - vec4 Bw = vec4( 6.0, 2.0, -6.0,-2.0 ); - vec4 Cw = vec4( 5.0, -1.0, -3.0, 3.0 ); - - -// These inequations define the line below which interpolation occurs. - fx = vec4(greaterThan(Ao*fp.y+Bo*fp.x, Co)); - fx_left = vec4(greaterThan(Ax*fp.y+Bx*fp.x, Cx)); - fx_up = vec4(greaterThan(Ay*fp.y+By*fp.x, Cy)); - fx3_left = vec4(greaterThan(Az*fp.y+Bz*fp.x, Cz)); - fx3_up = vec4(greaterThan(Aw*fp.y+Bw*fp.x, Cw)); - - -#ifdef CORNER_A - interp_restriction_lv1 = sign(noteq(e,f) * noteq(e,h)); -#endif -#ifdef CORNER_B - interp_restriction_lv1 = sign(noteq(e,f) * noteq(e,h) * ( not(eq(f,b)) * not(eq(h,d)) + eq(e,i) * not(eq(f,i4)) * not(eq(h,i5)) + eq(e,g) + eq(e,c))); -#endif -#ifdef CORNER_D - interp_restriction_lv1 = sign(noteq(e,f)*noteq(e,h)*(not(eq(f,b))* not(eq(h,d)) + eq(e,i) * not(eq(f,i4)) * not(eq(h,i5)) + eq(e,g) + eq(e,c) ) * (noteq(f,f4)* noteq(f,i) + noteq(h,h5) * noteq(h,i) + noteq(h,g) + noteq(f,c) + eq(b,c1) * eq(d,g0))); -#endif -#ifdef CORNER_C - interp_restriction_lv1 = sign(noteq(e,f) * noteq(e,h) * ( not(eq(f,b)) * not(eq(f,c)) + not(eq(h,d)) * not(eq(h,g)) + eq(e,i) * (not(eq(f,f4)) * not(eq(f,i4)) + not(eq(h,h5)) * not(eq(h,i5))) + eq(e,g) + eq(e,c))); -#endif - - interp_restriction_lv2_left = noteq(e,g)* noteq(d,g); - interp_restriction_lv2_up = noteq(e,c)* noteq(b,c); - interp_restriction_lv3_left = eq2(g,g0) * noteq(d0,g0); - interp_restriction_lv3_up = eq2(c,c1) * noteq(b1,c1); - - vec4 wd1 = weighted_distance( e, c, g, i, h5, f4, h, f); - vec4 wd2 = weighted_distance( h, d, i5, f, i4, b, e, i); - - edri = vec4(lessThanEqual(wd1, wd2)) * interp_restriction_lv1; - edr = vec4(lessThan(wd1, wd2)) * interp_restriction_lv1; - - vec4 w1, w2; - w1.x = df1(F,G); w1.y = df1(B,I); w1.z = df1(D,C); w1.w = df1(H,A); - w2.x = df1(H,C); w2.y = df1(F,A); w2.z = df1(B,G); w2.w = df1(D,I); - - edr = edr * sign(not(edri.yzwx) + not(edri.wxyz)); - edr_left = vec4(lessThanEqual(XBR_LV2_COEFFICIENT*w1, w2)) * interp_restriction_lv2_left * edr * (not(edri.yzwx) * eq(e,c)); - edr_up = vec4(greaterThanEqual(w1, XBR_LV2_COEFFICIENT*w2)) * interp_restriction_lv2_up * edr * (not(edri.wxyz) * eq(e,g)); - edr3_left = interp_restriction_lv3_left; - edr3_up = interp_restriction_lv3_up; - - nc = bvec4( edr * ( fx + edr_left * (fx_left + edr3_left * fx3_left * eq(e,c4)) + edr_up * (fx_up + edr3_up * fx3_up * eq(e,g5)))); - - w1.x = df1(E,F); w1.y = df1(E,B); w1.z = df1(E,D); w1.w = df1(E,H); - w2 = w1.wxyz; - - px = lessThanEqual(w1,w2); - - vec3 res1 = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E; - vec3 res2 = nc.w ? px.w ? H : D : nc.z ? px.z ? D : B : nc.y ? px.y ? B : F : nc.x ? px.x ? F : H : E; - - vec2 df12; - - df12.x = dot(abs(res1-E),Y); - df12.y = dot(abs(res2-E),Y); - - vec3 res = mix(res1, res2, step(df12.x, df12.y)); - - FragColor = vec4(res, 1.0); -} \ No newline at end of file diff --git a/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass1.slang b/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass1.slang deleted file mode 100644 index affdb9b..0000000 --- a/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass1.slang +++ /dev/null @@ -1,268 +0,0 @@ -#version 450 - -/* - - Hyllian's xBR MultiLevel4 Shader - Pass1 - - Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -layout(push_constant) uniform Push -{ - vec4 SourceSize; - vec4 OriginalSize; - vec4 OutputSize; - uint FrameCount; -} params; - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; -} global; - -#define round(X) floor((X)+0.5) -#define TEX(dx,dy) texture(Source, vTexCoord+vec2((dx),(dy))*t1).rgb - -const float cf2 = 2.0; -const float cf3 = 4.0; -const float cf4 = 4.0; -const vec4 eq_thresholdold = vec4(15.0, 15.0, 15.0, 15.0); -const vec4 eq_threshold = vec4( 2.0, 2.0, 2.0, 2.0); -const vec4 eq_threshold3 = vec4(25.0, 25.0, 25.0, 25.0); -const vec3 Yuv_weight = vec3(4.0, 1.0, 2.0); -const mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.499, 0.499, -0.418, -0.0813); -const mat3 yuvT = mat3(0.299, -0.169, 0.499, 0.587, -0.331, -0.418, 0.114, 0.499, -0.0813); -const vec3 yuv_weighted0 = vec3( 1.196, 2.348, 0.228);//precalculate Yuv_weight.x * yuv[0]; -const vec3 yuv_weighted1 = vec3(-0.169, -0.331, 0.499);//precalculate Yuv_weight.y * yuv[1]; -const vec3 yuv_weighted2 = vec3( 0.898, -0.836, -0.163);//precalculate Yuv_weight.z * yuv[2]; -const vec4 maximo = vec4(255.0, 255.0, 255.0, 255.0); - - -vec4 df(vec4 A, vec4 B) -{ - return vec4(abs(A-B)); -} - -bvec4 rd(vec4 A, vec4 B, vec4 C, vec4 D) -{ - return (greaterThan(df(C,D)/(df(A,B)+0.000000001) , vec4(2.0))); -} - -bvec4 id(vec4 A, vec4 B, vec4 C, vec4 D) -{ - return greaterThan(df(C,D) , df(A,B)); -} - - -vec4 remapTo01(vec4 v, vec4 high) -{ - return (v/high); -} - -bvec4 eq(vec4 A, vec4 B) -{ - return lessThan(df(A, B) , eq_threshold); -} - -bvec4 eq3(vec4 A, vec4 B) -{ - return lessThan(df(A, B) , eq_threshold3); -} - -vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) -{ - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} - -bvec4 and(bvec4 A, bvec4 B) -{ - return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w); -} - -bvec4 or(bvec4 A, bvec4 B) -{ - return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w); -} - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; -layout(location = 1) out vec2 t1; - -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord * 1.0004; - - // A3 B3 C3 - // A1 B1 C1 - //A2 A0 A B C C4 C6 - //D2 D0 D E F F4 F6 - //G2 G0 G H I I4 I6 - // G5 H5 I5 - // G7 H7 I7 - - t1 = vec2(params.SourceSize.z, params.SourceSize.w); // F H -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 1) in vec2 t1; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; - -void main() -{ - bvec4 edr0, edr, edr_left, edr_up, edr3_left, edr3_up, edr4_left, edr4_up; // edr = edge detection rule - bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up; - bvec4 interp_restriction_lv3_left, interp_restriction_lv3_up; - bvec4 interp_restriction_lv4_left, interp_restriction_lv4_up; - - vec3 A3 = TEX(-1,-3); vec3 B3 = TEX( 0,-3); vec3 C3 = TEX( 1,-3); - vec3 A1 = TEX(-1,-2); vec3 B1 = TEX( 0,-2); vec3 C1 = TEX( 1,-2); - vec3 A2 = TEX(-3,-1); vec3 A0 = TEX(-2,-1); vec3 A = TEX(-1,-1); vec3 B = TEX( 0,-1); vec3 C = TEX( 1,-1); vec3 C4 = TEX( 2,-1); vec3 C6 = TEX( 3,-1); - vec3 D2 = TEX(-3, 0); vec3 D0 = TEX(-2, 0); vec3 D = TEX(-1, 0); vec3 E = TEX( 0, 0); vec3 F = TEX( 1, 0); vec3 F4 = TEX( 2, 0); vec3 F6 = TEX( 3, 0); - vec3 G2 = TEX(-3, 1); vec3 G0 = TEX(-2, 1); vec3 G = TEX(-1, 1); vec3 H = TEX( 0, 1); vec3 I = TEX( 1, 1); vec3 I4 = TEX( 2, 1); vec3 I6 = TEX( 3, 1); - vec3 G5 = TEX(-1, 2); vec3 H5 = TEX( 0, 2); vec3 I5 = TEX( 1, 2); - vec3 G7 = TEX(-1, 3); vec3 H7 = TEX( 0, 3); vec3 I7 = TEX( 1, 3); - - mat4x3 bdhf0 = yuvT * mat4x3(B, D, H, F); - bdhf0 = mat4x3(abs(bdhf0[0]), abs(bdhf0[1]), abs(bdhf0[2]), abs(bdhf0[3])); - vec4 b = Yuv_weight * bdhf0; - - mat4x3 bdhf1 = yuvT * mat4x3(C, A, G, I); - bdhf1 = mat4x3(abs(bdhf1[0]), abs(bdhf1[1]), abs(bdhf1[2]), abs(bdhf1[3])); - vec4 c = Yuv_weight * bdhf1; - - mat4x3 bdhf2 = yuvT * mat4x3(E, E, E, E); - bdhf2 = mat4x3(abs(bdhf2[0]), abs(bdhf2[1]), abs(bdhf2[2]), abs(bdhf2[3])); - vec4 e = Yuv_weight * bdhf2; - - vec4 d = b.yzwx; - vec4 f = b.wxyz; - vec4 g = c.zwxy; - vec4 h = b.zwxy; - vec4 i = c.wxyz; - - mat4x3 bdhf3 = yuvT * mat4x3(I4, C1, A0, G5); - bdhf3 = mat4x3(abs(bdhf3[0]), abs(bdhf3[1]), abs(bdhf3[2]), abs(bdhf3[3])); - vec4 i4 = Yuv_weight * bdhf3; - - mat4x3 bdhf4 = yuvT * mat4x3(I5, C4, A1, G0); - bdhf4 = mat4x3(abs(bdhf4[0]), abs(bdhf4[1]), abs(bdhf4[2]), abs(bdhf4[3])); - vec4 i5 = Yuv_weight * bdhf4; - - mat4x3 bdhf5 = yuvT * mat4x3(H5, F4, B1, D0); - bdhf5 = mat4x3(abs(bdhf5[0]), abs(bdhf5[1]), abs(bdhf5[2]), abs(bdhf5[3])); - vec4 h5 = Yuv_weight * bdhf5; - - vec4 f4 = h5.yzwx; - vec4 c1 = i4.yzwx; - vec4 g0 = i5.wxyz; - vec4 b1 = h5.zwxy; - vec4 d0 = h5.wxyz; - - mat4x3 bdhf6 = yuvT * mat4x3(I6, C3, A2, G7); - bdhf6 = mat4x3(abs(bdhf6[0]), abs(bdhf6[1]), abs(bdhf6[2]), abs(bdhf6[3])); - vec4 i6 = Yuv_weight * bdhf6; - - mat4x3 bdhf7 = yuvT * mat4x3(I7, C6, A3, G2); - bdhf7 = mat4x3(abs(bdhf7[0]), abs(bdhf7[1]), abs(bdhf7[2]), abs(bdhf7[3])); - vec4 i7 = Yuv_weight * bdhf7; - - mat4x3 bdhf8 = yuvT * mat4x3(H7, F6, B3, D2); - bdhf8 = mat4x3(abs(bdhf8[0]), abs(bdhf8[1]), abs(bdhf8[2]), abs(bdhf8[3])); - vec4 h7 = Yuv_weight * bdhf8; - - vec4 f6 = h7.yzwx; - vec4 c3 = i6.yzwx; - vec4 g2 = i7.wxyz; - vec4 b3 = h7.zwxy; - vec4 d2 = h7.wxyz; - - interp_restriction_lv1 = and(notEqual(e,f) , notEqual(e,h)); - interp_restriction_lv2_left = or(and(and(notEqual(e,g) , notEqual(d,g)) , eq(e, d)) , eq(h, g)); - interp_restriction_lv2_up = or(and(and(notEqual(e,c) , notEqual(b,c)) , eq(e, b)) , eq(f, c)); - interp_restriction_lv3_left = or(and(and(notEqual(e,g0) , notEqual(d0,g0)) , eq(d,d0)) , eq(g,g0)); - interp_restriction_lv3_up = or(and(and(notEqual(e,c1) , notEqual(b1,c1)) , eq(b,b1)) , eq(c,c1)); - interp_restriction_lv4_left = or(and(and(notEqual(e,g2) , notEqual(d2,g2)) , eq(d0,d2)) , eq(g0,g2)); - interp_restriction_lv4_up = or(and(and(notEqual(e,c3) , notEqual(b3,c3)) , eq(b1,b3)) , eq(c1,c3)); - - vec4 wd1 = weighted_distance( e, c, g, i, h5, f4, h, f); - vec4 wd2 = weighted_distance( h, d, i5, f, i4, b, e, i); - - bvec4 comp1 = and(not(eq(h,d)) , not(id(h,g,h,d))); - bvec4 comp2 = and(not(eq(f,b)) , not(id(f,c,f,b))); - - edr0 = and(lessThanEqual(wd1 , wd2) , interp_restriction_lv1); - edr = and(lessThan(wd1 , wd2) , and(interp_restriction_lv1 , ( or(comp2 , or(comp1 , or(eq(e,g) , eq(e,c)))) ) )); - edr_left = and(lessThanEqual((cf2*df(f,g)) , df(h,c)) , and(interp_restriction_lv2_left , edr)); - edr_up = and(greaterThanEqual(df(f,g) , (cf2*df(h,c))) , and(interp_restriction_lv2_up , edr)); - edr3_left = and(lessThanEqual((cf3*df(f,g0)) , df(h,c1)) , and(interp_restriction_lv3_left , edr_left)); - edr3_up = and(greaterThanEqual(df(f,g0) , (cf3*df(h,c1))) , and(interp_restriction_lv3_up , edr_up)); - edr4_left = and(lessThanEqual((cf4*df(f,g2)) , df(h,c3)) , and(interp_restriction_lv4_left , edr3_left)); - edr4_up = and(greaterThanEqual(df(f,g2) , (cf4*df(h,c3))) , and(interp_restriction_lv4_up , edr3_up)); - - vec4 info; //groan, gotta separate these into their components??? - info.x = (edr0.x == true) ? 1.0 : 0.0; - info.y = (edr0.y == true) ? 1.0 : 0.0; - info.z = (edr0.z == true) ? 1.0 : 0.0; - info.w = (edr0.w == true) ? 1.0 : 0.0; - - info.x = (edr.x == true) ? 2.0 : info.x; - info.y = (edr.y == true) ? 2.0 : info.y; - info.z = (edr.z == true) ? 2.0 : info.z; - info.w = (edr.w == true) ? 2.0 : info.w; - - info.x = and(edr_up , not(edr_left)).x == true ? 3.0 : info.x; - info.y = and(edr_up , not(edr_left)).y == true ? 3.0 : info.y; - info.z = and(edr_up , not(edr_left)).z == true ? 3.0 : info.z; - info.w = and(edr_up , not(edr_left)).w == true ? 3.0 : info.w; - - info.x = and(edr_left , not(edr_up)).x == true ? 4.0 : info.x; - info.y = and(edr_left , not(edr_up)).y == true ? 4.0 : info.y; - info.z = and(edr_left , not(edr_up)).z == true ? 4.0 : info.z; - info.w = and(edr_left , not(edr_up)).w == true ? 4.0 : info.w; - - info.x = and(edr3_up , not(edr3_left)).x == true ? 5.0 : info.x; - info.y = and(edr3_up , not(edr3_left)).y == true ? 5.0 : info.y; - info.z = and(edr3_up , not(edr3_left)).z == true ? 5.0 : info.z; - info.w = and(edr3_up , not(edr3_left)).w == true ? 5.0 : info.w; - - info.x = and(edr3_left , not(edr3_up)).x == true ? 6.0 : info.x; - info.y = and(edr3_left , not(edr3_up)).y == true ? 6.0 : info.y; - info.z = and(edr3_left , not(edr3_up)).z == true ? 6.0 : info.z; - info.w = and(edr3_left , not(edr3_up)).w == true ? 6.0 : info.w; - - info.x = and(edr4_up , not(edr4_left)).x == true ? 7.0 : info.x; - info.y = and(edr4_up , not(edr4_left)).y == true ? 7.0 : info.y; - info.z = and(edr4_up , not(edr4_left)).z == true ? 7.0 : info.z; - info.w = and(edr4_up , not(edr4_left)).w == true ? 7.0 : info.w; - - info.x = and(edr4_left , not(edr4_up)).x == true ? 8.0 : info.x; - info.y = and(edr4_left , not(edr4_up)).y == true ? 8.0 : info.y; - info.z = and(edr4_left , not(edr4_up)).z == true ? 8.0 : info.z; - info.w = and(edr4_left , not(edr4_up)).w == true ? 8.0 : info.w; - - FragColor = vec4(remapTo01(info, maximo)); -} \ No newline at end of file diff --git a/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass2.slang b/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass2.slang deleted file mode 100644 index d56da84..0000000 --- a/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass2.slang +++ /dev/null @@ -1,295 +0,0 @@ -#version 450 - -/* - - Hyllian's xBR MultiLevel4 Shader - Pass2 - - Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -layout(push_constant) uniform Push -{ - vec4 SourceSize; - vec4 OriginalSize; - vec4 OutputSize; - uint FrameCount; -} params; - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; -} global; - -#define round(X) floor((X)+0.5) -#define mul(a,b) (b*a) -#define saturate(c) clamp(c, 0.0, 1.0) - -const float cf2 = 2.0; -const float cf3 = 4.0; -const float cf4 = 4.0; -const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0); -const vec4 eq_threshold2 = vec4( 5.0, 5.0, 5.0, 5.0); -const vec4 eq_threshold3 = vec4(25.0, 25.0, 25.0, 25.0); -const float y_weight = 48.0; -const float u_weight = 7.0; -const float v_weight = 6.0; -const vec3 yuv0 = vec3(0.299, 0.587, 0.114); -const vec3 yuv1 = vec3(-0.169, -0.331, 0.499); -const vec3 yuv2 = vec3(0.499, -0.418, -0.0813); -const vec3 yuv_weighted0 = vec3(14.352, 28.176, 5.472);//precalculate y_weight * yuv[0]; -const vec3 yuv_weighted1 = vec3(-1.183, -2.317, 3.493);//precalculate u_weight * yuv[1]; -const vec3 yuv_weighted2 = vec3(2.994, -2.508, -0.488);//precalculate v_weight * yuv[2]; -const vec4 maximo = vec4(255.0, 255.0, 255.0, 255.0); - - -vec4 df(vec4 A, vec4 B) -{ - return vec4(abs(A-B)); -} - -bvec4 rd(vec4 A, vec4 B, vec4 C, vec4 D) -{ - return (greaterThan(df(C,D)/(df(A,B)+0.000000001) , vec4(2.0))); -} - -bvec4 id(vec4 A, vec4 B, vec4 C, vec4 D) -{ - return greaterThan(df(C,D) , df(A,B)); -} - -vec4 remapTo01(vec4 v, vec4 high) -{ - return (v/high); -} - -vec4 remapFrom01(vec4 v, vec4 high) -{ - return round(high*v); -} - -bvec4 eq(vec4 A, vec4 B) -{ - return lessThan(df(A, B) , eq_threshold); -} - -bvec4 eq2(vec4 A, vec4 B) -{ - return lessThan(df(A, B) , eq_threshold2); -} - -bvec4 eq3(vec4 A, vec4 B) -{ - return lessThan(df(A, B) , eq_threshold3); -} - -vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) -{ - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} - -bvec4 and(bvec4 A, bvec4 B) -{ - return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w); -} - -bvec4 or(bvec4 A, bvec4 B) -{ - return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w); -} - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; -layout(location = 1) out vec4 t1; -layout(location = 2) out vec4 t2; -layout(location = 3) out vec4 t3; -layout(location = 4) out vec4 t4; -layout(location = 5) out vec4 t5; -layout(location = 6) out vec4 t6; -layout(location = 7) out vec4 t7; - -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord * 1.0004; - - float dx = params.SourceSize.z; - float dy = params.SourceSize.w; - - // A1 B1 C1 - // A0 A B C C4 - // D0 D E F F4 - // G0 G H I I4 - // G5 H5 I5 - - t1 = vTexCoord.xxxy + vec4( -dx, 0., dx,-2.0*dy); // A1 B1 C1 - t2 = vTexCoord.xxxy + vec4( -dx, 0., dx, -dy); // A B C - t3 = vTexCoord.xxxy + vec4( -dx, 0., dx, 0); // D E F - t4 = vTexCoord.xxxy + vec4( -dx, 0., dx, dy); // G H I - t5 = vTexCoord.xxxy + vec4( -dx, 0., dx, 2.0*dy); // G5 H5 I5 - t6 = vTexCoord.xyyy + vec4(-2.0*dx,-dy, 0., dy); // A0 D0 G0 - t7 = vTexCoord.xyyy + vec4( 2.0*dx,-dy, 0., dy); // C4 F4 I4 -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 1) in vec4 t1; -layout(location = 2) in vec4 t2; -layout(location = 3) in vec4 t3; -layout(location = 4) in vec4 t4; -layout(location = 5) in vec4 t5; -layout(location = 6) in vec4 t6; -layout(location = 7) in vec4 t7; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; -layout(set = 0, binding = 3) uniform sampler2D Original; - -void main() -{ - vec4 PA = texture(Source, t2.xw); - vec4 PB = texture(Source, t2.yw); - vec4 PC = texture(Source, t2.zw); - - vec4 PD = texture(Source, t3.xw); - vec4 PE = texture(Source, t3.yw); - vec4 PF = texture(Source, t3.zw); - - vec4 PG = texture(Source, t4.xw); - vec4 PH = texture(Source, t4.yw); - vec4 PI = texture(Source, t4.zw); - - vec3 A1 = texture(Original, t1.xw).rgb; - vec3 B1 = texture(Original, t1.yw).rgb; - vec3 C1 = texture(Original, t1.zw).rgb; - - vec3 A = texture(Original, t2.xw).rgb; - vec3 B = texture(Original, t2.yw).rgb; - vec3 C = texture(Original, t2.zw).rgb; - - vec3 D = texture(Original, t3.xw).rgb; - vec3 E = texture(Original, t3.yw).rgb; - vec3 F = texture(Original, t3.zw).rgb; - - vec3 G = texture(Original, t4.xw).rgb; - vec3 H = texture(Original, t4.yw).rgb; - vec3 I = texture(Original, t4.zw).rgb; - - vec3 G5 = texture(Original, t5.xw).rgb; - vec3 H5 = texture(Original, t5.yw).rgb; - vec3 I5 = texture(Original, t5.zw).rgb; - - vec3 A0 = texture(Original, t6.xy).rgb; - vec3 D0 = texture(Original, t6.xz).rgb; - vec3 G0 = texture(Original, t6.xw).rgb; - - vec3 C4 = texture(Original, t7.xy).rgb; - vec3 F4 = texture(Original, t7.xz).rgb; - vec3 I4 = texture(Original, t7.xw).rgb; - - vec4 b = mul( mat4x3(B, D, H, F), yuv_weighted0 ); - vec4 c = mul( mat4x3(C, A, G, I), yuv_weighted0 ); - vec4 e = mul( mat4x3(E, E, E, E), yuv_weighted0 ); - vec4 d = b.yzwx; - vec4 f = b.wxyz; - vec4 g = c.zwxy; - vec4 h = b.zwxy; - vec4 i = c.wxyz; - - vec4 i4 = mul( mat4x3(I4, C1, A0, G5), yuv_weighted0 ); - vec4 i5 = mul( mat4x3(I5, C4, A1, G0), yuv_weighted0 ); - vec4 h5 = mul( mat4x3(H5, F4, B1, D0), yuv_weighted0 ); - vec4 f4 = h5.yzwx; - - vec4 pe = remapFrom01(PE, maximo); - vec4 pf = remapFrom01(PF, maximo); - vec4 ph = remapFrom01(PH, maximo); - vec4 pb = remapFrom01(PB, maximo); - vec4 pd = remapFrom01(PD, maximo); - - vec4 f2 = vec4(pf.z, pb.w, pd.x, ph.y); - vec4 h2 = vec4(ph.z, pf.w, pb.x, pd.y); - vec4 f1 = vec4(pf.y, pb.z, pd.w, ph.x); - vec4 h3 = vec4(ph.w, pf.x, pb.y, pd.z); - - bvec4 nbrs; - nbrs.x = (pe.y > 1.0) || (pe.w > 1.0) ? true : false; - nbrs.y = (pe.z > 1.0) || (pe.x > 1.0) ? true : false; - nbrs.z = (pe.w > 1.0) || (pe.y > 1.0) ? true : false; - nbrs.w = (pe.x > 1.0) || (pe.z > 1.0) ? true : false; - - bvec4 jag1; - jag1.x = (f2.x > 1.0) || (h2.x > 1.0) ? true : false; - jag1.y = (f2.y > 1.0) || (h2.y > 1.0) ? true : false; - jag1.z = (f2.z > 1.0) || (h2.z > 1.0) ? true : false; - jag1.w = (f2.w > 1.0) || (h2.w > 1.0) ? true : false; - - bvec4 jag2; - jag2.x = (f2.x > 2.0) || (h2.x > 2.0) ? true : false; - jag2.x = (f2.y > 2.0) || (h2.y > 2.0) ? true : false; - jag2.x = (f2.z > 2.0) || (h2.z > 2.0) ? true : false; - jag2.x = (f2.w > 2.0) || (h2.w > 2.0) ? true : false; - - bvec4 jag3; - jag3.x = (f2.x > 4.0) || (h2.x > 4.0) ? true : false; - jag3.y = (f2.y > 4.0) || (h2.y > 4.0) ? true : false; - jag3.z = (f2.z > 4.0) || (h2.z > 4.0) ? true : false; - jag3.w = (f2.w > 4.0) || (h2.w > 4.0) ? true : false; - - pe.x = (pe.x == 7.0 || pe.x == 8.0) ? ((jag3.x) ? pe.x : (pe.x - 2.0)) : pe.x; - pe.y = (pe.y == 7.0 || pe.y == 8.0) ? ((jag3.y) ? pe.y : (pe.y - 2.0)) : pe.y; - pe.z = (pe.z == 7.0 || pe.z == 8.0) ? ((jag3.z) ? pe.z : (pe.z - 2.0)) : pe.z; - pe.w = (pe.w == 7.0 || pe.w == 8.0) ? ((jag3.w) ? pe.w : (pe.w - 2.0)) : pe.w; - - pe.x = (pe.x == 5.0 || pe.x == 6.0) ? ((jag2.x) ? pe.x : (pe.x - 2.0)) : pe.x; - pe.y = (pe.y == 5.0 || pe.y == 6.0) ? ((jag2.y) ? pe.y : (pe.y - 2.0)) : pe.y; - pe.z = (pe.z == 5.0 || pe.z == 6.0) ? ((jag2.z) ? pe.z : (pe.z - 2.0)) : pe.z; - pe.w = (pe.w == 5.0 || pe.w == 6.0) ? ((jag2.w) ? pe.w : (pe.w - 2.0)) : pe.w; - - bvec4 jag91; - jag91.x = ((id(h,i,e,h).x || id(i4,i,f4,i4).x) && (f2.x > 1.0) && (f1.x > 1.0)); - jag91.y = ((id(h,i,e,h).y || id(i4,i,f4,i4).y) && (f2.y > 1.0) && (f1.y > 1.0)); - jag91.z = ((id(h,i,e,h).z || id(i4,i,f4,i4).z) && (f2.z > 1.0) && (f1.z > 1.0)); - jag91.w = ((id(h,i,e,h).w || id(i4,i,f4,i4).w) && (f2.w > 1.0) && (f1.w > 1.0)); - - bvec4 jag92; - jag92.x = ((id(f,i,e,f).x || id(i5,i,h5,i5).x) && (h2.x > 1.0) && (h3.x > 1.0)); - jag92.y = ((id(f,i,e,f).y || id(i5,i,h5,i5).y) && (h2.y > 1.0) && (h3.y > 1.0)); - jag92.z = ((id(f,i,e,f).z || id(i5,i,h5,i5).z) && (h2.z > 1.0) && (h3.z > 1.0)); - jag92.w = ((id(f,i,e,f).w || id(i5,i,h5,i5).w) && (h2.w > 1.0) && (h3.w > 1.0)); - - bvec4 jag93 = ( rd(h,g,e,g)); - bvec4 jag94 = ( rd(f,c,e,c)); - - bvec4 jag9; - jag9.x = (!(jag91.x && jag93.x || jag92.x && jag94.x)); - jag9.y = (!(jag91.y && jag93.y || jag92.y && jag94.y)); - jag9.z = (!(jag91.z && jag93.z || jag92.z && jag94.z)); - jag9.w = (!(jag91.w && jag93.w || jag92.w && jag94.w)); - - pe.x = ((pe.x == 0.0) || (!nbrs.x || jag1.x) && jag9.x) ? pe.x : 1.0; - pe.y = ((pe.y == 0.0) || (!nbrs.y || jag1.y) && jag9.y) ? pe.y : 1.0; - pe.z = ((pe.z == 0.0) || (!nbrs.z || jag1.z) && jag9.z) ? pe.z : 1.0; - pe.w = ((pe.w == 0.0) || (!nbrs.w || jag1.w) && jag9.w) ? pe.w : 1.0; - - FragColor = vec4(remapTo01(pe, maximo)); -} \ No newline at end of file diff --git a/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass3.slang b/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass3.slang deleted file mode 100644 index b18aa6c..0000000 --- a/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass3.slang +++ /dev/null @@ -1,254 +0,0 @@ -#version 450 - -/* - - Hyllian's xBR MultiLevel4 Shader - Pass3 - - Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -layout(push_constant) uniform Push -{ - vec4 SourceSize; - vec4 OriginalSize; - vec4 OutputSize; - uint FrameCount; -} params; - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; -} global; - -#define round(X) floor((X)+0.5) -#define saturate(c) clamp(c, 0.0, 1.0) -#define mul(a,b) (b*a) - -const float coef = 2.0; -const float cf = 4.0; -const float eq_threshold = 15.0; -const float y_weight = 48.0; -const float u_weight = 7.0; -const float v_weight = 6.0; -const vec3 yuv0 = vec3(0.299, 0.587, 0.114); -const vec3 yuv1 = vec3(-0.169, -0.331, 0.499); -const vec3 yuv2 = vec3(0.499, -0.418, -0.0813); -const vec3 yuv_weighted0 = vec3(14.352, 28.176, 5.472);//precalculate y_weight * yuv[0]; -const vec3 yuv_weighted1 = vec3(-1.183, -2.317, 3.493);//precalculate u_weight * yuv[1]; -const vec3 yuv_weighted2 = vec3(2.994, -2.508, -0.488);//precalculate v_weight * yuv[2]; -const vec4 maximo = vec4(255.0, 255.0, 255.0, 255.0); -const vec4 low = vec4(-64.0, -64.0, -64.0, -64.0); -const vec4 high = vec4( 64.0, 64.0, 64.0, 64.0); - -const mat2x4 sym_vectors = mat2x4(1., 1., -1., -1., 1., -1., -1., 1.); - -// Bx, Ay, C -const vec3 lines0 = vec3( 4.0, 4.0, 4.0); // 0 NL -const vec3 lines1 = vec3( 4.0, 4.0, 3.0); // 1 LV0 -const vec3 lines2 = vec3( 4.0, 4.0, 2.0); // 2 LV1 -const vec3 lines3 = vec3( 8.0, 4.0, 2.0); // 3 LV2u -const vec3 lines4 = vec3( 4.0, 8.0, 2.0); // 4 LV2l -const vec3 lines5 = vec3(12.0, 4.0, 2.0); // 5 LV3u -const vec3 lines6 = vec3( 4.0, 12.0, 2.0); // 6 LV3l -const vec3 lines7 = vec3(16.0, 4.0, 2.0); // 7 LV4u -const vec3 lines8 = vec3( 4.0, 16.0, 2.0); // 8 LV4l -const vec3 lines9 = vec3(12.0, 4.0, 6.0); // 9 LV3u -const vec3 lines10 = vec3( 4.0, 12.0, 6.0); // 10 LV3l -const vec3 lines11 = vec3(16.0, 4.0, 6.0); // 11 LV4u -const vec3 lines12 = vec3( 4.0, 16.0, 6.0); // 12 LV4l - -vec4 remapTo01(vec4 v, vec4 low, vec4 high) -{ - return saturate((v - low)/(high-low)); -} - -float remapFrom01(float v, float high) -{ - return round(high*v); -} - -float df(float A, float B) -{ - return abs(A-B); -} - -bool eq(float A, float B) -{ - return (df(A, B) < eq_threshold); -} - -float weighted_distance(float a, float b, float c, float d, float e, float f, float g, float h) -{ - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} - -float bool_to_float(bool A) -{ - return A ? 1.0 : 0.0; -} - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; -layout(location = 1) out vec4 t1; - -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord * 1.0004; - float dx = params.OriginalSize.z; - float dy = params.OriginalSize.w; - - // A3 B3 C3 - // A1 B1 C1 - //A2 A0 A B C C4 C6 - //D2 D0 D E F F4 F6 - //G2 G0 G H I I4 I6 - // G5 H5 I5 - // G7 H7 I7 - - t1 = vec4(dx, 0., 0., dy); // F H -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 1) in vec4 t1; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; -layout(set = 0, binding = 3) uniform sampler2D Original; - -void main() -{ - float px; - - vec2 pos = fract(vTexCoord.xy * params.OriginalSize.xy) - vec2(0.4999, 0.4999); // pos = pixel position - vec2 dir = sign(pos); // dir = pixel direction - - vec2 g1 = dir * ( saturate(-dir.y*dir.x) * t1.zw + saturate( dir.y*dir.x) * t1.xy ); - vec2 g2 = dir * ( saturate( dir.y*dir.x) * t1.zw + saturate(-dir.y*dir.x) * t1.xy ); - - vec3 E = texture(Original, vTexCoord ).rgb; - vec3 F = texture(Original, vTexCoord + g1).rgb; - vec3 H = texture(Original, vTexCoord + g2).rgb; - vec3 I = texture(Original, vTexCoord + g1 + g2).rgb; - vec3 F4 = texture(Original, vTexCoord + 2.0 * g1).rgb; - vec3 H5 = texture(Original, vTexCoord + 2.0 * g2).rgb; - - float e = dot(E, yuv_weighted0); - float f = dot(F, yuv_weighted0); - float h = dot(H, yuv_weighted0); - float i = dot(I, yuv_weighted0); - float f4 = dot(F4, yuv_weighted0); - float h5 = dot(H5, yuv_weighted0); - - vec4 icomp = round(saturate(mul(dir, sym_vectors))); // choose info component - - float infoE = remapFrom01(dot(texture(Source, vTexCoord ), icomp), 255.0); // retrieve 1st pass info - float infoF = remapFrom01(dot(texture(Source, vTexCoord+g1), icomp), 255.0); // 1st pass info from neighbor r - float infoH = remapFrom01(dot(texture(Source, vTexCoord+g2), icomp), 255.0); // 1st pass info from neighbor d - - vec4 lparam; - vec2 addr; - - if (infoF == 8.0) - { - lparam.xyz = lines12; - px = bool_to_float(df(f,f4) <= df(f,i)); - addr.x = 2. * px + saturate(1.0 - px); - addr.y = saturate(1.0 - px); - } - else if (infoH == 7.0) - { - lparam.xyz = lines11; - px = bool_to_float(df(h,h5) <= df(h,i)); - addr.x = saturate(1.0 - px); - addr.y = 2. * px + saturate(1.0 - px); - } - else if (infoF == 6.0) - { - lparam.xyz = lines10; - px = bool_to_float(df(f,f4) <= df(f,i)); - addr.x = 2. * px + saturate(1.0 - px); - addr.y = saturate(1.0 - px); - } - else if (infoH == 5.0) - { - lparam.xyz = lines9; - px = bool_to_float(df(h,h5) <= df(h,i)); - addr.x = saturate(1.0 - px); - addr.y = 2. * px + saturate(1.0 - px); - } - else - { - px = bool_to_float(df(e,f) <= df(e,h)); - addr.x = px; - addr.y = saturate(1.0 - px); - - lparam.xyz = ((infoE == 1.0) ? lines1 : lines0); - lparam.xyz = ((infoE == 2.0) ? lines2 : lparam.xyz); - lparam.xyz = ((infoE == 3.0) ? lines3 : lparam.xyz); - lparam.xyz = ((infoE == 4.0) ? lines4 : lparam.xyz); - lparam.xyz = ((infoE == 5.0) ? lines5 : lparam.xyz); - lparam.xyz = ((infoE == 6.0) ? lines6 : lparam.xyz); - lparam.xyz = ((infoE == 7.0) ? lines7 : lparam.xyz); - lparam.xyz = ((infoE == 8.0) ? lines8 : lparam.xyz); - } - - bool inv = (dir.x*dir.y) < 0.0 ? true : false; - - // Rotate address from relative to absolute. - addr = addr * dir.yx; - addr = inv ? addr.yx : addr; - - // Rotate straight line equation from relative to absolute. - lparam.xy = lparam.xy * dir.yx; - lparam.xy = inv ? lparam.yx : lparam.xy; - - addr.x += 2.0; - addr.y += 2.0; - - lparam.w = addr.x * 8.0 + addr.y; - - FragColor = vec4(remapTo01(lparam, low, high)); -} - -/* -19 1 -9 1 -4 0 -2 0 -1 1 -0 0 - -0 0000 ND -1 0001 EDR0 -2 0010 EDR -3 0011 EDRU -4 0100 EDRL -5 0101 EDRU3 -6 0110 EDRL3 - -0 1 2 3 4 --2 -1 0 1 2 - -*/ \ No newline at end of file diff --git a/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass4.slang b/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass4.slang deleted file mode 100644 index 53d68b2..0000000 --- a/test/nonfunctional/shaders/xbr-mlv4-multipass/xbr-mlv4-pass4.slang +++ /dev/null @@ -1,175 +0,0 @@ -#version 450 - -/* - - Hyllian's xBR MultiLevel4 Shader - Pass4 - - Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -layout(push_constant) uniform Push -{ - vec4 SourceSize; - vec4 OriginalSize; - vec4 OutputSize; - uint FrameCount; -} params; - -layout(std140, set = 0, binding = 0) uniform UBO -{ - mat4 MVP; -} global; - -#define round(X) floor((X)+0.5) -#define mul(a,b) (b*a) -#define saturate(c) clamp(c, 0.0, 1.0) - -const vec3 bin = vec3( 4.0, 2.0, 1.0); -const vec4 low = vec4(-64.0, -64.0, -64.0, -64.0); -const vec4 high = vec4( 64.0, 64.0, 64.0, 64.0); - -vec4 remapFrom01(vec4 v, vec4 low, vec4 high) -{ - return round(mix(low, high, v)); -} - -float c_df(vec3 c1, vec3 c2) -{ - vec3 df = abs(c1 - c2); - return df.r + df.g + df.b; -} - -vec4 unpack_info(float i) -{ - vec4 info; - info.x = round(modf(i / 2.0, i)); - info.y = round(modf(i / 2.0, i)); - info.z = round(modf(i / 2.0, i)); - info.w = i; - - return info; -} - -float df(float A, float B) -{ - return abs(A-B); -} - -#define GET_PIXEL(PARAM, PIXEL)\ - info = PARAM;\ - ay.z = round( modf( info / 2.0, info ) );\ - ay.y = round( modf( info / 2.0, info ) );\ - ay.x = round( modf( info / 2.0, info ) );\ - ax.z = round( modf( info / 2.0, info ) );\ - ax.y = round( modf( info / 2.0, info ) );\ - ax.x = round( info );\ - iq.x = dot( ax, bin ) - 2.0;\ - iq.y = dot( ay, bin ) - 2.0;\ - PIXEL = texture( Original, vTexCoord + iq.x * t1.xy + iq.y * t1.zw ).xyz; - -#pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 vTexCoord; -layout(location = 1) out vec4 t1; -layout(location = 2) out float scale_factor; - -void main() -{ - gl_Position = global.MVP * Position; - vTexCoord = TexCoord * 1.0004; - float dx = params.OriginalSize.z; - float dy = params.OriginalSize.w; - - // A3 B3 C3 - // A1 B1 C1 - //A2 A0 A B C C4 C6 - //D2 D0 D E F F4 F6 - //G2 G0 G H I I4 I6 - // G5 H5 I5 - // G7 H7 I7 - t1 = vec4(dx, 0., 0., dy); // F H - scale_factor = params.OutputSize.x * params.OriginalSize.z; -} - -#pragma stage fragment -layout(location = 0) in vec2 vTexCoord; -layout(location = 1) in vec4 t1; -layout(location = 2) in float scale_factor; -layout(location = 0) out vec4 FragColor; -layout(set = 0, binding = 2) uniform sampler2D Source; -layout(set = 0, binding = 3) uniform sampler2D Original; - -void main() -{ - vec2 fp = fract( vTexCoord * params.OriginalSize.xy ) - vec2( 0.4999, 0.4999 ); // pos = pixel position - - vec2 pxcoord = floor(vTexCoord * params.OriginalSize.xy) * params.OriginalSize.zw; - - vec4 UL = texture(Source, pxcoord + 0.25 * t1.xy + 0.25 * t1.zw ); - vec4 UR = texture(Source, pxcoord + 0.75 * t1.xy + 0.25 * t1.zw ); - vec4 DL = texture(Source, pxcoord + 0.25 * t1.xy + 0.75 * t1.zw ); - vec4 DR = texture(Source, pxcoord + 0.75 * t1.xy + 0.75 * t1.zw ); - - vec4 ulparam = remapFrom01( UL, low, high ); // retrieve 1st pass info - vec4 urparam = remapFrom01( UR, low, high ); // retrieve 1st pass info - vec4 dlparam = remapFrom01( DL, low, high ); // retrieve 1st pass info - vec4 drparam = remapFrom01( DR, low, high ); // retrieve 1st pass info - - vec3 E = texture( Original, vTexCoord ).xyz; - - vec3 ax, ay, PX, PY, PZ, PW; - float info; - vec2 iq; - - GET_PIXEL(ulparam.w, PX); - GET_PIXEL(urparam.w, PY); - GET_PIXEL(dlparam.w, PZ); - GET_PIXEL(drparam.w, PW); - - vec3 fp1 = vec3( fp, -1. ); - - vec3 color; - vec4 fx; - - vec4 inc = vec4(abs(ulparam.x / ulparam.y), abs(urparam.x / urparam.y), abs(dlparam.x / dlparam.y), abs(drparam.x / drparam.y)); - vec4 level = max(inc, 1.0 / inc); - - fx.x = saturate( dot( fp1, ulparam.xyz ) * scale_factor / ( 8. * level.x ) + 0.5 ); - fx.y = saturate( dot( fp1, urparam.xyz ) * scale_factor / ( 8. * level.y ) + 0.5 ); - fx.z = saturate( dot( fp1, dlparam.xyz ) * scale_factor / ( 8. * level.z ) + 0.5 ); - fx.w = saturate( dot( fp1, drparam.xyz ) * scale_factor / ( 8. * level.w ) + 0.5 ); - - vec3 c1, c2, c3, c4; - - c1 = mix( E, PX, fx.x ); - c2 = mix( E, PY, fx.y ); - c3 = mix( E, PZ, fx.z ); - c4 = mix( E, PW, fx.w ); - - color = c1; - color = ( (c_df(c2, E) > c_df(color, E)) ) ? c2 : color; - color = ( (c_df(c3, E) > c_df(color, E)) ) ? c3 : color; - color = ( (c_df(c4, E) > c_df(color, E)) ) ? c4 : color; - - FragColor = vec4(color, 1.0); -} \ No newline at end of file diff --git a/test/nonfunctional/super-xbr-2p.slangp b/test/nonfunctional/super-xbr-2p.slangp deleted file mode 100644 index 9ee48b9..0000000 --- a/test/nonfunctional/super-xbr-2p.slangp +++ /dev/null @@ -1,19 +0,0 @@ -shaders = 3 - -shader0 = shaders/super-xbr/super-xbr-pass0.slang -filter_linear0 = false -scale_type_x0 = "source" -scale_x0 = "1.000000" -scale_type_y0 = "source" -scale_y0 = "1.000000" - -shader1 = shaders/super-xbr/super-xbr-pass1.slang -filter_linear1 = false -scale_type_x1 = "source" -scale_x1 = "2.000000" -scale_type_y1 = "source" -scale_y1 = "2.000000" - -shader2 = shaders/super-xbr/custom-jinc2-sharper.slang -filter_linear2 = false - diff --git a/test/nonfunctional/xbr-mlv4-multipass.slangp b/test/nonfunctional/xbr-mlv4-multipass.slangp deleted file mode 100644 index c485309..0000000 --- a/test/nonfunctional/xbr-mlv4-multipass.slangp +++ /dev/null @@ -1,32 +0,0 @@ -shaders = "4" - -shader0 = shaders/xbr-mlv4-multipass/xbr-mlv4-pass1.slang -filter_linear0 = "false" -float_framebuffer0 = "false" -scale_type_x0 = "source" -scale_x0 = "1.000000" -scale_type_y0 = "source" -scale_y0 = "1.000000" -alias0 = "PASS1" - -shader1 = shaders/xbr-mlv4-multipass/xbr-mlv4-pass2.slang -filter_linear1 = "false" -float_framebuffer1 = "false" -scale_type_x1 = "source" -scale_x1 = "1.000000" -scale_type_y1 = "source" -scale_y1 = "1.000000" -alias1 = "PASS2" - -shader2 = shaders/xbr-mlv4-multipass/xbr-mlv4-pass3.slang -filter_linear2 = "false" -float_framebuffer2 = "false" -scale_type_x2 = "source" -scale_x2 = "2.000000" -scale_type_y2 = "source" -scale_y2 = "2.000000" -alias2 = "PASS3" - -shader3 = shaders/xbr-mlv4-multipass/xbr-mlv4-pass4.slang -filter_linear3 = "false" -float_framebuffer3 = "false"