diff --git a/artwork/bgfx/chains/hq2x.png b/artwork/bgfx/chains/hq2x.png new file mode 100644 index 00000000000..a49c0f484ac Binary files /dev/null and b/artwork/bgfx/chains/hq2x.png differ diff --git a/artwork/bgfx/chains/hq3x.png b/artwork/bgfx/chains/hq3x.png new file mode 100644 index 00000000000..6f5eb59c3f9 Binary files /dev/null and b/artwork/bgfx/chains/hq3x.png differ diff --git a/artwork/bgfx/chains/hq4x.png b/artwork/bgfx/chains/hq4x.png new file mode 100644 index 00000000000..18abeb31023 Binary files /dev/null and b/artwork/bgfx/chains/hq4x.png differ diff --git a/bgfx/chains/hq2x.json b/bgfx/chains/hq2x.json new file mode 100644 index 00000000000..20303a64c90 --- /dev/null +++ b/bgfx/chains/hq2x.json @@ -0,0 +1,60 @@ +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin + +/* +* Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) +* +* Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net ) +* +* Copyright (C) 2014 Jules Blok ( jules@aerix.nl ) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser 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 +*/ + +{ + "name": "HQ2x", + "author": "libretro", + "targets": [ + { + "name": "scaled_out", + "mode": "guest", + "scale": 2, + "doublebuffer": true + }, + { + "name": "internal", + "mode": "native", + "doublebuffer": true + } + ], + "passes": [ + { + "effect": "hq2x/hq2x", + "name": "HQ2x pass", + "input": [ + { "sampler": "decal", "texture": "screen" }, + { "sampler": "LUT", "texture": "bgfx/chains/hq2x.png", "bilinear": true } + ], + "output": "scaled_out" + }, + { "effect": "hq2x/blit", + "name": "Final Blit", + "input": [ + { "sampler": "s_tex", "target": "scaled_out" } + ], + "output": "output" + } + ] +} \ No newline at end of file diff --git a/bgfx/chains/hq3x.json b/bgfx/chains/hq3x.json new file mode 100644 index 00000000000..1f767b68825 --- /dev/null +++ b/bgfx/chains/hq3x.json @@ -0,0 +1,60 @@ +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin + +/* +* Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) +* +* Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net ) +* +* Copyright (C) 2014 Jules Blok ( jules@aerix.nl ) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser 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 +*/ + +{ + "name": "HQ3x", + "author": "libretro", + "targets": [ + { + "name": "scaled_out", + "mode": "guest", + "scale": 2, + "doublebuffer": true + }, + { + "name": "internal", + "mode": "native", + "doublebuffer": true + } + ], + "passes": [ + { + "effect": "hq3x/hq3x", + "name": "HQ3x pass", + "input": [ + { "sampler": "decal", "texture": "screen" }, + { "sampler": "LUT", "texture": "bgfx/chains/hq3x.png", "bilinear": false } + ], + "output": "scaled_out" + }, + { "effect": "hq3x/blit", + "name": "Final Blit", + "input": [ + { "sampler": "s_tex", "target": "scaled_out" } + ], + "output": "output" + } + ] +} \ No newline at end of file diff --git a/bgfx/chains/hq4x.json b/bgfx/chains/hq4x.json new file mode 100644 index 00000000000..9232966ecc4 --- /dev/null +++ b/bgfx/chains/hq4x.json @@ -0,0 +1,60 @@ +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin + +/* +* Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) +* +* Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net ) +* +* Copyright (C) 2014 Jules Blok ( jules@aerix.nl ) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser 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 +*/ + +{ + "name": "HQ4x", + "author": "libretro", + "targets": [ + { + "name": "scaled_out", + "mode": "guest", + "scale": 2, + "doublebuffer": true + }, + { + "name": "internal", + "mode": "native", + "doublebuffer": true + } + ], + "passes": [ + { + "effect": "hq4x/hq4x", + "name": "HQ4x pass", + "input": [ + { "sampler": "decal", "texture": "screen" }, + { "sampler": "LUT", "texture": "bgfx/chains/hq4x.png", "bilinear": false } + ], + "output": "scaled_out" + }, + { "effect": "hq4x/blit", + "name": "Final Blit", + "input": [ + { "sampler": "s_tex", "target": "scaled_out" } + ], + "output": "output" + } + ] +} \ No newline at end of file diff --git a/bgfx/effects/hq2x/blit.json b/bgfx/effects/hq2x/blit.json new file mode 100644 index 00000000000..9ea3078b35a --- /dev/null +++ b/bgfx/effects/hq2x/blit.json @@ -0,0 +1,121 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//============================================================ +// +// blit.json: A simple texture-to-target copy. +// +//============================================================ +{ + // blend (required): The blend state for this effect. + "blend": { + // equation (optional): What equation to perform on the source and destination blend values. + // values: "add", "sub", "revSub", "min", "max" + // default: "add" + // + // "subtract" and "revSubtract" are provided as aliases for "sub" and "revSub" + "equation": "add", + + // blend function parameters (optional): What factors to use in the blend function when calculating the final pixel. + // values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha" + // defaults (srcColor, srcAlpha): "1" + // defaults (dstColor, dstAlpha): "0" + // + // "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha" + "srcColor": "srcalpha", + "dstColor": "1-srcalpha", + "srcAlpha": "srcalpha", + "dstAlpha": "1-srcalpha" + }, + + // depth (required): The depth state for this effect. + "depth": { + // function (optional): The depth function to use when drawing. + // values: "never", "less", "equal", "lequal", "greater", "notequal", "gequal", "always" + // default: "always" + "function": "always", + + // writeenable (optional): Whether to store Z-buffer data. + // values: true, false + // default: false + "writeenable": false + }, + + // cull (required): The cull mode for this effect. + "cull": { + // mode (optional): What winding, if any, to cull. + // values: "none", "cw", "ccw" + // default: "ccw" + // + // "clockwise" and "counterclockwise" are provided as aliases for "cw" and "ccw" + "mode": "none" + }, + + // write (required): Write enable for color and alpha channels. + "write": { + // rgb (optional): Whether to store color data when drawing. + // values: true, false + // default: false + "rgb": true, + + // alpha (optional): Whether to store alpha data when drawing. + // values: true, false + // default: false + "alpha": true + }, + + // vertex (required): The vertex shader to use when drawing. + // value: A string containing the path and name of a shader file to use, minus the extension. + "vertex": "chains/hq2x/vs_blit", + + // pixel/fragment (required): The pixel or fragment shader to use when drawing. + // value: A string containing the path and name of a shader file to use, minus the extension. + "fragment": "chains/hq2x/fs_blit", + + // uniforms (required): The list of uniforms for this effect. Can be empty, but must exist. + "uniforms": [ + { + // name (required): The name of the uniform, as used in either the vertex or pixel/fragment shader. + // value: A string containing the name of the uniform as described above. + // + // NOTE: Some names correspond to special values that will be automatically filled by the BGFX + // code if they are used by the shader. These names are: + // "u_screen_dims" + // The dimensions of the first texture input if present, otherwise the dimensions of the output window. + // Valid values: xy + // "u_inv_screen_dims" + // The reciprocal of u_screen_dims. + // Valid values: xy + // "u_source_dims" + // The size, in pixels, of the screen texture incoming to the chain. + // Valid values: xy + // "u_rotation_type" + // This screen's rotation type. 0 if ROT0, 1 if ROT90, 2 if ROT180, 3 of ROT270. + // Valid values: x + // "u_swap_xy" + // Whether this screen is swapped on the X and Y axes. 1 if true, 0 if false. + // Valid values: x + // "u_quad_dims" + // The dimensions, in pixels, occupied by this one screen primitive itself in the output window. + // Valid values: xy + // "u_tex_sizeN" + // The dimensions, in pixels, of the texture in input pair N. Starts at 0. + // valid values: xy + "name": "s_tex", + + // type (required): The type of the uniform. + // values: "int", "vec4", "mat3", "mat4" + // + // Note: "int" should only be used for samplers. + "type": "int", + + // values (required): The array of numbers with which to initialize the uniform. + // value: A JSON array containin the correct amount of numbers to initialize a uniform of the + // above-specified type. The following size rules should be followed: + // "int": 1 float + // "vec4": 4 floats + // "mat3": 9 floats + // "mat4": 16 floats + "values": [ 1.0 ] + } + ] +} \ No newline at end of file diff --git a/bgfx/effects/hq2x/hq2x.json b/bgfx/effects/hq2x/hq2x.json new file mode 100644 index 00000000000..9b67b562b02 --- /dev/null +++ b/bgfx/effects/hq2x/hq2x.json @@ -0,0 +1,29 @@ +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/hq2x/vs_hq2x", + "fragment": "chains/hq2x/fs_hq2x", + "uniforms": [ + { "name": "decal", "type": "int", "values": [ 1.0 ] }, + { "name": "LUT", "type": "int", "values": [ 1.0 ] }, + { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] } + ] +} \ No newline at end of file diff --git a/bgfx/effects/hq3x/blit.json b/bgfx/effects/hq3x/blit.json new file mode 100644 index 00000000000..a3c21b9cf67 --- /dev/null +++ b/bgfx/effects/hq3x/blit.json @@ -0,0 +1,121 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//============================================================ +// +// blit.json: A simple texture-to-target copy. +// +//============================================================ +{ + // blend (required): The blend state for this effect. + "blend": { + // equation (optional): What equation to perform on the source and destination blend values. + // values: "add", "sub", "revSub", "min", "max" + // default: "add" + // + // "subtract" and "revSubtract" are provided as aliases for "sub" and "revSub" + "equation": "add", + + // blend function parameters (optional): What factors to use in the blend function when calculating the final pixel. + // values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha" + // defaults (srcColor, srcAlpha): "1" + // defaults (dstColor, dstAlpha): "0" + // + // "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha" + "srcColor": "srcalpha", + "dstColor": "1-srcalpha", + "srcAlpha": "srcalpha", + "dstAlpha": "1-srcalpha" + }, + + // depth (required): The depth state for this effect. + "depth": { + // function (optional): The depth function to use when drawing. + // values: "never", "less", "equal", "lequal", "greater", "notequal", "gequal", "always" + // default: "always" + "function": "always", + + // writeenable (optional): Whether to store Z-buffer data. + // values: true, false + // default: false + "writeenable": false + }, + + // cull (required): The cull mode for this effect. + "cull": { + // mode (optional): What winding, if any, to cull. + // values: "none", "cw", "ccw" + // default: "ccw" + // + // "clockwise" and "counterclockwise" are provided as aliases for "cw" and "ccw" + "mode": "none" + }, + + // write (required): Write enable for color and alpha channels. + "write": { + // rgb (optional): Whether to store color data when drawing. + // values: true, false + // default: false + "rgb": true, + + // alpha (optional): Whether to store alpha data when drawing. + // values: true, false + // default: false + "alpha": true + }, + + // vertex (required): The vertex shader to use when drawing. + // value: A string containing the path and name of a shader file to use, minus the extension. + "vertex": "chains/hq3x/vs_blit", + + // pixel/fragment (required): The pixel or fragment shader to use when drawing. + // value: A string containing the path and name of a shader file to use, minus the extension. + "fragment": "chains/hq3x/fs_blit", + + // uniforms (required): The list of uniforms for this effect. Can be empty, but must exist. + "uniforms": [ + { + // name (required): The name of the uniform, as used in either the vertex or pixel/fragment shader. + // value: A string containing the name of the uniform as described above. + // + // NOTE: Some names correspond to special values that will be automatically filled by the BGFX + // code if they are used by the shader. These names are: + // "u_screen_dims" + // The dimensions of the first texture input if present, otherwise the dimensions of the output window. + // Valid values: xy + // "u_inv_screen_dims" + // The reciprocal of u_screen_dims. + // Valid values: xy + // "u_source_dims" + // The size, in pixels, of the screen texture incoming to the chain. + // Valid values: xy + // "u_rotation_type" + // This screen's rotation type. 0 if ROT0, 1 if ROT90, 2 if ROT180, 3 of ROT270. + // Valid values: x + // "u_swap_xy" + // Whether this screen is swapped on the X and Y axes. 1 if true, 0 if false. + // Valid values: x + // "u_quad_dims" + // The dimensions, in pixels, occupied by this one screen primitive itself in the output window. + // Valid values: xy + // "u_tex_sizeN" + // The dimensions, in pixels, of the texture in input pair N. Starts at 0. + // valid values: xy + "name": "s_tex", + + // type (required): The type of the uniform. + // values: "int", "vec4", "mat3", "mat4" + // + // Note: "int" should only be used for samplers. + "type": "int", + + // values (required): The array of numbers with which to initialize the uniform. + // value: A JSON array containin the correct amount of numbers to initialize a uniform of the + // above-specified type. The following size rules should be followed: + // "int": 1 float + // "vec4": 4 floats + // "mat3": 9 floats + // "mat4": 16 floats + "values": [ 1.0 ] + } + ] +} \ No newline at end of file diff --git a/bgfx/effects/hq3x/hq3x.json b/bgfx/effects/hq3x/hq3x.json new file mode 100644 index 00000000000..4cc61706dce --- /dev/null +++ b/bgfx/effects/hq3x/hq3x.json @@ -0,0 +1,29 @@ +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/hq3x/vs_hq3x", + "fragment": "chains/hq3x/fs_hq3x", + "uniforms": [ + { "name": "decal", "type": "int", "values": [ 1.0 ] }, + { "name": "LUT", "type": "int", "values": [ 1.0 ] }, + { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] } + ] +} \ No newline at end of file diff --git a/bgfx/effects/hq4x/blit.json b/bgfx/effects/hq4x/blit.json new file mode 100644 index 00000000000..ddaab93e2ea --- /dev/null +++ b/bgfx/effects/hq4x/blit.json @@ -0,0 +1,121 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//============================================================ +// +// blit.json: A simple texture-to-target copy. +// +//============================================================ +{ + // blend (required): The blend state for this effect. + "blend": { + // equation (optional): What equation to perform on the source and destination blend values. + // values: "add", "sub", "revSub", "min", "max" + // default: "add" + // + // "subtract" and "revSubtract" are provided as aliases for "sub" and "revSub" + "equation": "add", + + // blend function parameters (optional): What factors to use in the blend function when calculating the final pixel. + // values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha" + // defaults (srcColor, srcAlpha): "1" + // defaults (dstColor, dstAlpha): "0" + // + // "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha" + "srcColor": "srcalpha", + "dstColor": "1-srcalpha", + "srcAlpha": "srcalpha", + "dstAlpha": "1-srcalpha" + }, + + // depth (required): The depth state for this effect. + "depth": { + // function (optional): The depth function to use when drawing. + // values: "never", "less", "equal", "lequal", "greater", "notequal", "gequal", "always" + // default: "always" + "function": "always", + + // writeenable (optional): Whether to store Z-buffer data. + // values: true, false + // default: false + "writeenable": false + }, + + // cull (required): The cull mode for this effect. + "cull": { + // mode (optional): What winding, if any, to cull. + // values: "none", "cw", "ccw" + // default: "ccw" + // + // "clockwise" and "counterclockwise" are provided as aliases for "cw" and "ccw" + "mode": "none" + }, + + // write (required): Write enable for color and alpha channels. + "write": { + // rgb (optional): Whether to store color data when drawing. + // values: true, false + // default: false + "rgb": true, + + // alpha (optional): Whether to store alpha data when drawing. + // values: true, false + // default: false + "alpha": true + }, + + // vertex (required): The vertex shader to use when drawing. + // value: A string containing the path and name of a shader file to use, minus the extension. + "vertex": "chains/hq4x/vs_blit", + + // pixel/fragment (required): The pixel or fragment shader to use when drawing. + // value: A string containing the path and name of a shader file to use, minus the extension. + "fragment": "chains/hq4x/fs_blit", + + // uniforms (required): The list of uniforms for this effect. Can be empty, but must exist. + "uniforms": [ + { + // name (required): The name of the uniform, as used in either the vertex or pixel/fragment shader. + // value: A string containing the name of the uniform as described above. + // + // NOTE: Some names correspond to special values that will be automatically filled by the BGFX + // code if they are used by the shader. These names are: + // "u_screen_dims" + // The dimensions of the first texture input if present, otherwise the dimensions of the output window. + // Valid values: xy + // "u_inv_screen_dims" + // The reciprocal of u_screen_dims. + // Valid values: xy + // "u_source_dims" + // The size, in pixels, of the screen texture incoming to the chain. + // Valid values: xy + // "u_rotation_type" + // This screen's rotation type. 0 if ROT0, 1 if ROT90, 2 if ROT180, 3 of ROT270. + // Valid values: x + // "u_swap_xy" + // Whether this screen is swapped on the X and Y axes. 1 if true, 0 if false. + // Valid values: x + // "u_quad_dims" + // The dimensions, in pixels, occupied by this one screen primitive itself in the output window. + // Valid values: xy + // "u_tex_sizeN" + // The dimensions, in pixels, of the texture in input pair N. Starts at 0. + // valid values: xy + "name": "s_tex", + + // type (required): The type of the uniform. + // values: "int", "vec4", "mat3", "mat4" + // + // Note: "int" should only be used for samplers. + "type": "int", + + // values (required): The array of numbers with which to initialize the uniform. + // value: A JSON array containin the correct amount of numbers to initialize a uniform of the + // above-specified type. The following size rules should be followed: + // "int": 1 float + // "vec4": 4 floats + // "mat3": 9 floats + // "mat4": 16 floats + "values": [ 1.0 ] + } + ] +} \ No newline at end of file diff --git a/bgfx/effects/hq4x/hq4x.json b/bgfx/effects/hq4x/hq4x.json new file mode 100644 index 00000000000..8d2221896ce --- /dev/null +++ b/bgfx/effects/hq4x/hq4x.json @@ -0,0 +1,29 @@ +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/hq4x/vs_hq4x", + "fragment": "chains/hq4x/fs_hq4x", + "uniforms": [ + { "name": "decal", "type": "int", "values": [ 1.0 ] }, + { "name": "LUT", "type": "int", "values": [ 1.0 ] }, + { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] } + ] +} \ No newline at end of file diff --git a/bgfx/shaders/dx11/chains/hq2x/fs_blit.bin b/bgfx/shaders/dx11/chains/hq2x/fs_blit.bin new file mode 100644 index 00000000000..80d85fb1107 Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq2x/fs_blit.bin differ diff --git a/bgfx/shaders/dx11/chains/hq2x/fs_hq2x.bin b/bgfx/shaders/dx11/chains/hq2x/fs_hq2x.bin new file mode 100644 index 00000000000..cdce652045f Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq2x/fs_hq2x.bin differ diff --git a/bgfx/shaders/dx11/chains/hq2x/vs_blit.bin b/bgfx/shaders/dx11/chains/hq2x/vs_blit.bin new file mode 100644 index 00000000000..b0bebf9da4c Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq2x/vs_blit.bin differ diff --git a/bgfx/shaders/dx11/chains/hq2x/vs_hq2x.bin b/bgfx/shaders/dx11/chains/hq2x/vs_hq2x.bin new file mode 100644 index 00000000000..5b037b2bfe8 Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq2x/vs_hq2x.bin differ diff --git a/bgfx/shaders/dx11/chains/hq3x/fs_blit.bin b/bgfx/shaders/dx11/chains/hq3x/fs_blit.bin new file mode 100644 index 00000000000..80d85fb1107 Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq3x/fs_blit.bin differ diff --git a/bgfx/shaders/dx11/chains/hq3x/fs_hq3x.bin b/bgfx/shaders/dx11/chains/hq3x/fs_hq3x.bin new file mode 100644 index 00000000000..29d6a5c2c3d Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq3x/fs_hq3x.bin differ diff --git a/bgfx/shaders/dx11/chains/hq3x/vs_blit.bin b/bgfx/shaders/dx11/chains/hq3x/vs_blit.bin new file mode 100644 index 00000000000..b0bebf9da4c Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq3x/vs_blit.bin differ diff --git a/bgfx/shaders/dx11/chains/hq3x/vs_hq3x.bin b/bgfx/shaders/dx11/chains/hq3x/vs_hq3x.bin new file mode 100644 index 00000000000..5b037b2bfe8 Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq3x/vs_hq3x.bin differ diff --git a/bgfx/shaders/dx11/chains/hq4x/fs_blit.bin b/bgfx/shaders/dx11/chains/hq4x/fs_blit.bin new file mode 100644 index 00000000000..80d85fb1107 Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq4x/fs_blit.bin differ diff --git a/bgfx/shaders/dx11/chains/hq4x/fs_hq4x.bin b/bgfx/shaders/dx11/chains/hq4x/fs_hq4x.bin new file mode 100644 index 00000000000..7ebeaab6cd7 Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq4x/fs_hq4x.bin differ diff --git a/bgfx/shaders/dx11/chains/hq4x/vs_blit.bin b/bgfx/shaders/dx11/chains/hq4x/vs_blit.bin new file mode 100644 index 00000000000..b0bebf9da4c Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq4x/vs_blit.bin differ diff --git a/bgfx/shaders/dx11/chains/hq4x/vs_hq4x.bin b/bgfx/shaders/dx11/chains/hq4x/vs_hq4x.bin new file mode 100644 index 00000000000..5b037b2bfe8 Binary files /dev/null and b/bgfx/shaders/dx11/chains/hq4x/vs_hq4x.bin differ diff --git a/bgfx/shaders/dx9/chains/hq2x/fs_blit.bin b/bgfx/shaders/dx9/chains/hq2x/fs_blit.bin new file mode 100644 index 00000000000..ef8fa0730c3 Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq2x/fs_blit.bin differ diff --git a/bgfx/shaders/dx9/chains/hq2x/fs_hq2x.bin b/bgfx/shaders/dx9/chains/hq2x/fs_hq2x.bin new file mode 100644 index 00000000000..7bebafd9962 Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq2x/fs_hq2x.bin differ diff --git a/bgfx/shaders/dx9/chains/hq2x/vs_blit.bin b/bgfx/shaders/dx9/chains/hq2x/vs_blit.bin new file mode 100644 index 00000000000..ea94c83e62d Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq2x/vs_blit.bin differ diff --git a/bgfx/shaders/dx9/chains/hq2x/vs_hq2x.bin b/bgfx/shaders/dx9/chains/hq2x/vs_hq2x.bin new file mode 100644 index 00000000000..de5213e137f Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq2x/vs_hq2x.bin differ diff --git a/bgfx/shaders/dx9/chains/hq3x/fs_blit.bin b/bgfx/shaders/dx9/chains/hq3x/fs_blit.bin new file mode 100644 index 00000000000..ef8fa0730c3 Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq3x/fs_blit.bin differ diff --git a/bgfx/shaders/dx9/chains/hq3x/fs_hq3x.bin b/bgfx/shaders/dx9/chains/hq3x/fs_hq3x.bin new file mode 100644 index 00000000000..6151be64f23 Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq3x/fs_hq3x.bin differ diff --git a/bgfx/shaders/dx9/chains/hq3x/vs_blit.bin b/bgfx/shaders/dx9/chains/hq3x/vs_blit.bin new file mode 100644 index 00000000000..ea94c83e62d Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq3x/vs_blit.bin differ diff --git a/bgfx/shaders/dx9/chains/hq3x/vs_hq3x.bin b/bgfx/shaders/dx9/chains/hq3x/vs_hq3x.bin new file mode 100644 index 00000000000..de5213e137f Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq3x/vs_hq3x.bin differ diff --git a/bgfx/shaders/dx9/chains/hq4x/fs_blit.bin b/bgfx/shaders/dx9/chains/hq4x/fs_blit.bin new file mode 100644 index 00000000000..ef8fa0730c3 Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq4x/fs_blit.bin differ diff --git a/bgfx/shaders/dx9/chains/hq4x/fs_hq4x.bin b/bgfx/shaders/dx9/chains/hq4x/fs_hq4x.bin new file mode 100644 index 00000000000..55d09ab2827 Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq4x/fs_hq4x.bin differ diff --git a/bgfx/shaders/dx9/chains/hq4x/vs_blit.bin b/bgfx/shaders/dx9/chains/hq4x/vs_blit.bin new file mode 100644 index 00000000000..ea94c83e62d Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq4x/vs_blit.bin differ diff --git a/bgfx/shaders/dx9/chains/hq4x/vs_hq4x.bin b/bgfx/shaders/dx9/chains/hq4x/vs_hq4x.bin new file mode 100644 index 00000000000..de5213e137f Binary files /dev/null and b/bgfx/shaders/dx9/chains/hq4x/vs_hq4x.bin differ diff --git a/bgfx/shaders/gles/chains/hq2x/fs_blit.bin b/bgfx/shaders/gles/chains/hq2x/fs_blit.bin new file mode 100644 index 00000000000..22e2f0c23d0 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq2x/fs_blit.bin differ diff --git a/bgfx/shaders/gles/chains/hq2x/fs_hq2x.bin b/bgfx/shaders/gles/chains/hq2x/fs_hq2x.bin new file mode 100644 index 00000000000..2b008d10a52 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq2x/fs_hq2x.bin differ diff --git a/bgfx/shaders/gles/chains/hq2x/vs_blit.bin b/bgfx/shaders/gles/chains/hq2x/vs_blit.bin new file mode 100644 index 00000000000..9dd618de8a0 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq2x/vs_blit.bin differ diff --git a/bgfx/shaders/gles/chains/hq2x/vs_hq2x.bin b/bgfx/shaders/gles/chains/hq2x/vs_hq2x.bin new file mode 100644 index 00000000000..413d1e8bd20 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq2x/vs_hq2x.bin differ diff --git a/bgfx/shaders/gles/chains/hq3x/fs_blit.bin b/bgfx/shaders/gles/chains/hq3x/fs_blit.bin new file mode 100644 index 00000000000..22e2f0c23d0 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq3x/fs_blit.bin differ diff --git a/bgfx/shaders/gles/chains/hq3x/fs_hq3x.bin b/bgfx/shaders/gles/chains/hq3x/fs_hq3x.bin new file mode 100644 index 00000000000..7494371f7eb Binary files /dev/null and b/bgfx/shaders/gles/chains/hq3x/fs_hq3x.bin differ diff --git a/bgfx/shaders/gles/chains/hq3x/vs_blit.bin b/bgfx/shaders/gles/chains/hq3x/vs_blit.bin new file mode 100644 index 00000000000..9dd618de8a0 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq3x/vs_blit.bin differ diff --git a/bgfx/shaders/gles/chains/hq3x/vs_hq3x.bin b/bgfx/shaders/gles/chains/hq3x/vs_hq3x.bin new file mode 100644 index 00000000000..413d1e8bd20 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq3x/vs_hq3x.bin differ diff --git a/bgfx/shaders/gles/chains/hq4x/fs_blit.bin b/bgfx/shaders/gles/chains/hq4x/fs_blit.bin new file mode 100644 index 00000000000..22e2f0c23d0 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq4x/fs_blit.bin differ diff --git a/bgfx/shaders/gles/chains/hq4x/fs_hq4x.bin b/bgfx/shaders/gles/chains/hq4x/fs_hq4x.bin new file mode 100644 index 00000000000..c215c28b740 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq4x/fs_hq4x.bin differ diff --git a/bgfx/shaders/gles/chains/hq4x/vs_blit.bin b/bgfx/shaders/gles/chains/hq4x/vs_blit.bin new file mode 100644 index 00000000000..9dd618de8a0 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq4x/vs_blit.bin differ diff --git a/bgfx/shaders/gles/chains/hq4x/vs_hq4x.bin b/bgfx/shaders/gles/chains/hq4x/vs_hq4x.bin new file mode 100644 index 00000000000..413d1e8bd20 Binary files /dev/null and b/bgfx/shaders/gles/chains/hq4x/vs_hq4x.bin differ diff --git a/bgfx/shaders/glsl/chains/hq2x/fs_blit.bin b/bgfx/shaders/glsl/chains/hq2x/fs_blit.bin new file mode 100644 index 00000000000..db0fe2b487b Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq2x/fs_blit.bin differ diff --git a/bgfx/shaders/glsl/chains/hq2x/fs_hq2x.bin b/bgfx/shaders/glsl/chains/hq2x/fs_hq2x.bin new file mode 100644 index 00000000000..7f3b9f36263 Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq2x/fs_hq2x.bin differ diff --git a/bgfx/shaders/glsl/chains/hq2x/vs_blit.bin b/bgfx/shaders/glsl/chains/hq2x/vs_blit.bin new file mode 100644 index 00000000000..af6c9349f41 Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq2x/vs_blit.bin differ diff --git a/bgfx/shaders/glsl/chains/hq2x/vs_hq2x.bin b/bgfx/shaders/glsl/chains/hq2x/vs_hq2x.bin new file mode 100644 index 00000000000..789e990106d Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq2x/vs_hq2x.bin differ diff --git a/bgfx/shaders/glsl/chains/hq3x/fs_blit.bin b/bgfx/shaders/glsl/chains/hq3x/fs_blit.bin new file mode 100644 index 00000000000..db0fe2b487b Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq3x/fs_blit.bin differ diff --git a/bgfx/shaders/glsl/chains/hq3x/fs_hq3x.bin b/bgfx/shaders/glsl/chains/hq3x/fs_hq3x.bin new file mode 100644 index 00000000000..b74aea5e0af Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq3x/fs_hq3x.bin differ diff --git a/bgfx/shaders/glsl/chains/hq3x/vs_blit.bin b/bgfx/shaders/glsl/chains/hq3x/vs_blit.bin new file mode 100644 index 00000000000..af6c9349f41 Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq3x/vs_blit.bin differ diff --git a/bgfx/shaders/glsl/chains/hq3x/vs_hq3x.bin b/bgfx/shaders/glsl/chains/hq3x/vs_hq3x.bin new file mode 100644 index 00000000000..789e990106d Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq3x/vs_hq3x.bin differ diff --git a/bgfx/shaders/glsl/chains/hq4x/fs_blit.bin b/bgfx/shaders/glsl/chains/hq4x/fs_blit.bin new file mode 100644 index 00000000000..db0fe2b487b Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq4x/fs_blit.bin differ diff --git a/bgfx/shaders/glsl/chains/hq4x/fs_hq4x.bin b/bgfx/shaders/glsl/chains/hq4x/fs_hq4x.bin new file mode 100644 index 00000000000..86a90e7fa48 Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq4x/fs_hq4x.bin differ diff --git a/bgfx/shaders/glsl/chains/hq4x/vs_blit.bin b/bgfx/shaders/glsl/chains/hq4x/vs_blit.bin new file mode 100644 index 00000000000..af6c9349f41 Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq4x/vs_blit.bin differ diff --git a/bgfx/shaders/glsl/chains/hq4x/vs_hq4x.bin b/bgfx/shaders/glsl/chains/hq4x/vs_hq4x.bin new file mode 100644 index 00000000000..789e990106d Binary files /dev/null and b/bgfx/shaders/glsl/chains/hq4x/vs_hq4x.bin differ diff --git a/bgfx/shaders/metal/chains/hq2x/fs_blit.bin b/bgfx/shaders/metal/chains/hq2x/fs_blit.bin new file mode 100644 index 00000000000..6a3da392480 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq2x/fs_blit.bin differ diff --git a/bgfx/shaders/metal/chains/hq2x/fs_hq2x.bin b/bgfx/shaders/metal/chains/hq2x/fs_hq2x.bin new file mode 100644 index 00000000000..434944fc7f3 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq2x/fs_hq2x.bin differ diff --git a/bgfx/shaders/metal/chains/hq2x/vs_blit.bin b/bgfx/shaders/metal/chains/hq2x/vs_blit.bin new file mode 100644 index 00000000000..122b7dee5c3 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq2x/vs_blit.bin differ diff --git a/bgfx/shaders/metal/chains/hq2x/vs_hq2x.bin b/bgfx/shaders/metal/chains/hq2x/vs_hq2x.bin new file mode 100644 index 00000000000..d7332288c05 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq2x/vs_hq2x.bin differ diff --git a/bgfx/shaders/metal/chains/hq3x/fs_blit.bin b/bgfx/shaders/metal/chains/hq3x/fs_blit.bin new file mode 100644 index 00000000000..6a3da392480 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq3x/fs_blit.bin differ diff --git a/bgfx/shaders/metal/chains/hq3x/fs_hq3x.bin b/bgfx/shaders/metal/chains/hq3x/fs_hq3x.bin new file mode 100644 index 00000000000..38ae9cf1aa5 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq3x/fs_hq3x.bin differ diff --git a/bgfx/shaders/metal/chains/hq3x/vs_blit.bin b/bgfx/shaders/metal/chains/hq3x/vs_blit.bin new file mode 100644 index 00000000000..122b7dee5c3 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq3x/vs_blit.bin differ diff --git a/bgfx/shaders/metal/chains/hq3x/vs_hq3x.bin b/bgfx/shaders/metal/chains/hq3x/vs_hq3x.bin new file mode 100644 index 00000000000..d7332288c05 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq3x/vs_hq3x.bin differ diff --git a/bgfx/shaders/metal/chains/hq4x/fs_blit.bin b/bgfx/shaders/metal/chains/hq4x/fs_blit.bin new file mode 100644 index 00000000000..6a3da392480 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq4x/fs_blit.bin differ diff --git a/bgfx/shaders/metal/chains/hq4x/fs_hq4x.bin b/bgfx/shaders/metal/chains/hq4x/fs_hq4x.bin new file mode 100644 index 00000000000..5e417d94af9 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq4x/fs_hq4x.bin differ diff --git a/bgfx/shaders/metal/chains/hq4x/vs_blit.bin b/bgfx/shaders/metal/chains/hq4x/vs_blit.bin new file mode 100644 index 00000000000..122b7dee5c3 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq4x/vs_blit.bin differ diff --git a/bgfx/shaders/metal/chains/hq4x/vs_hq4x.bin b/bgfx/shaders/metal/chains/hq4x/vs_hq4x.bin new file mode 100644 index 00000000000..d7332288c05 Binary files /dev/null and b/bgfx/shaders/metal/chains/hq4x/vs_hq4x.bin differ diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp index 2c8e08793b0..458a45d449c 100644 --- a/src/osd/modules/render/bgfx/chainmanager.cpp +++ b/src/osd/modules/render/bgfx/chainmanager.cpp @@ -245,7 +245,7 @@ void chain_manager::process_screen_quad(uint32_t view, uint32_t screen, render_p tex_width, tex_height, prim->texture.rowpixels, prim->texture.palette, prim->texture.base); std::string full_name = "screen" + std::to_string(screen); - bgfx_texture *texture = new bgfx_texture(full_name, bgfx::TextureFormat::RGBA8, tex_width, tex_height, mem); + bgfx_texture *texture = new bgfx_texture(full_name, bgfx::TextureFormat::RGBA8, tex_width, tex_height, mem, BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT); m_textures.add_provider(full_name, texture); m_targets.update_target_sizes(screen, tex_width, tex_height, TARGET_STYLE_GUEST); diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_blit.sc new file mode 100644 index 00000000000..9af7bcf0ee6 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_blit.sc @@ -0,0 +1,14 @@ +$input v_color0, v_texcoord0 + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +// Samplers +SAMPLER2D(s_tex, 0); + +void main() +{ + gl_FragColor = texture2D(s_tex, v_texcoord0) * v_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_hq2x.sc b/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_hq2x.sc new file mode 100644 index 00000000000..66bd69f253e --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_hq2x.sc @@ -0,0 +1,75 @@ +$input v_color0, v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3 + +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin + +#include "common.sh" + +// Autos +uniform vec4 u_tex_size0; + +// Samplers +SAMPLER2D(decal, 0); +SAMPLER2D(LUT, 1); + +#define trY 48.0 +#define trU 7.0 +#define trV 6.0 + +#define SCALE 2.0 + +float diff(vec3 yuv1, vec3 yuv2) +{ + vec3 yuv_threshold = vec3(trY / 255.0, trU / 255.0, trV / 255.0); + vec3 yuv_offset = vec3(0, 0.5, 0.5); + float res_x = (abs((yuv1.x + 0.0) - (yuv2.x + 0.0)) > (trY / 255.0)) ? 1.0 : 0.0; + float res_y = (abs((yuv1.y + 0.5) - (yuv2.y + 0.5)) > (trU / 255.0)) ? 1.0 : 0.0; + float res_z = (abs((yuv1.z + 0.5) - (yuv2.z + 0.5)) > (trV / 255.0)) ? 1.0 : 0.0; + return (res_x > 0.0) ? 1.0 : ((res_y > 0.0) ? 1.0 : ((res_z > 0.0) ? 1.0 : 0.0)); +} + +void main() +{ + mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.5, 0.5, -0.419, -0.081); + + vec2 fp = fract(v_texcoord0 * u_tex_size0.xy); + vec2 quad = sign(-0.5 + fp); + vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy; + + float dx = ps.x; + float dy = ps.y; + vec4 p1 = texture2D(decal, v_texcoord0); + vec4 p2 = texture2D(decal, v_texcoord0 + ps * quad); + vec4 p3 = texture2D(decal, v_texcoord0 + vec2(dx, 0) * quad); + vec4 p4 = texture2D(decal, v_texcoord0 + vec2(0, dy) * quad); + + vec3 w1 = mul(yuv, texture2D(decal, v_texcoord1.xw).rgb); + vec3 w2 = mul(yuv, texture2D(decal, v_texcoord1.yw).rgb); + vec3 w3 = mul(yuv, texture2D(decal, v_texcoord1.zw).rgb); + + vec3 w4 = mul(yuv, texture2D(decal, v_texcoord2.xw).rgb); + vec3 w5 = mul(yuv, p1.rgb); + vec3 w6 = mul(yuv, texture2D(decal, v_texcoord2.zw).rgb); + + vec3 w7 = mul(yuv, texture2D(decal, v_texcoord3.xw).rgb); + vec3 w8 = mul(yuv, texture2D(decal, v_texcoord3.yw).rgb); + vec3 w9 = mul(yuv, texture2D(decal, v_texcoord3.zw).rgb); + + mat3 pattern = mat3(diff(w5, w1), diff(w5, w2), diff(w5, w3), diff(w5, w4), 0.0, diff(w5, w6), diff(w5, w7), diff(w5, w8), diff(w5, w9)); + vec4 cross = vec4(diff(w4, w2), diff(w2, w6), diff(w8, w4), diff(w6, w8)); + + vec2 index; + index.x = dot(pattern[0], vec3( 1.0, 2.0, 4.0)) + + dot(pattern[1], vec3( 8.0, 0.0, 16.0)) + + dot(pattern[2], vec3(32.0, 64.0, 128.0)); + index.y = dot(cross, vec4(1.0, 2.0, 4.0, 8.0)) * SCALE * SCALE + dot(floor(fp * vec2(SCALE, SCALE)), vec2(1.0, SCALE)); + + vec2 step = vec2(1.0, 1.0) / vec2(256.0, 16.0 * (SCALE * SCALE)); + vec2 offset = step / vec2(2.0, 2.0); + vec4 weights = texture2D(LUT, index * step + offset); + float sum = dot(weights, vec4(1.0, 1.0, 1.0, 1.0)); + mat4 transposed = mat4(vec4(p1.x, p2.x, p3.x, p4.x), vec4(p1.y, p2.y, p3.y, p4.y), vec4(p1.z, p2.z, p3.z, p4.z), vec4(p1.w, p2.w, p3.w, p4.w)); + vec4 res = mul(transposed, weights / vec4(sum, sum, sum, sum)); + + gl_FragColor = vec4(res.rgb, 1.0); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/hq2x/varying.def.sc new file mode 100644 index 00000000000..57a7a910952 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq2x/varying.def.sc @@ -0,0 +1,9 @@ +vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); +vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0); +vec4 v_texcoord1 : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_texcoord2 : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_texcoord3 : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0); + +vec3 a_position : POSITION; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_blit.sc new file mode 100644 index 00000000000..405ef8feb3b --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_blit.sc @@ -0,0 +1,14 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texcoord0, v_color0 + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texcoord0 = a_texcoord0; + v_color0 = a_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_hq2x.sc b/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_hq2x.sc new file mode 100644 index 00000000000..a77ac7006f7 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_hq2x.sc @@ -0,0 +1,36 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0 + +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin + +#include "common.sh" + +// Autos +uniform vec4 u_tex_size0; + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_color0 = a_color0; + + vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy; + float dx = ps.x; + float dy = ps.y; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + v_texcoord0 = a_texcoord0; + v_texcoord1 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, -dy); // w1 | w2 | w3 + v_texcoord2 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, 0.0); // w4 | w5 | w6 + v_texcoord3 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, dy); // w7 | w8 | w9 +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_blit.sc new file mode 100644 index 00000000000..9af7bcf0ee6 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_blit.sc @@ -0,0 +1,14 @@ +$input v_color0, v_texcoord0 + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +// Samplers +SAMPLER2D(s_tex, 0); + +void main() +{ + gl_FragColor = texture2D(s_tex, v_texcoord0) * v_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_hq3x.sc b/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_hq3x.sc new file mode 100644 index 00000000000..8e0f46a80f1 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_hq3x.sc @@ -0,0 +1,75 @@ +$input v_color0, v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3 + +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin + +#include "common.sh" + +// Autos +uniform vec4 u_tex_size0; + +// Samplers +SAMPLER2D(decal, 0); +SAMPLER2D(LUT, 1); + +#define trY 48.0 +#define trU 7.0 +#define trV 6.0 + +#define SCALE 3.0 + +float diff(vec3 yuv1, vec3 yuv2) +{ + vec3 yuv_threshold = vec3(trY / 255.0, trU / 255.0, trV / 255.0); + vec3 yuv_offset = vec3(0, 0.5, 0.5); + float res_x = (abs((yuv1.x + 0.0) - (yuv2.x + 0.0)) > (trY / 255.0)) ? 1.0 : 0.0; + float res_y = (abs((yuv1.y + 0.5) - (yuv2.y + 0.5)) > (trU / 255.0)) ? 1.0 : 0.0; + float res_z = (abs((yuv1.z + 0.5) - (yuv2.z + 0.5)) > (trV / 255.0)) ? 1.0 : 0.0; + return (res_x > 0.0) ? 1.0 : ((res_y > 0.0) ? 1.0 : ((res_z > 0.0) ? 1.0 : 0.0)); +} + +void main() +{ + mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.5, 0.5, -0.419, -0.081); + + vec2 fp = fract(v_texcoord0 * u_tex_size0.xy); + vec2 quad = sign(-0.5 + fp); + vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy; + + float dx = ps.x; + float dy = ps.y; + vec4 p1 = texture2D(decal, v_texcoord0); + vec4 p2 = texture2D(decal, v_texcoord0 + ps * quad); + vec4 p3 = texture2D(decal, v_texcoord0 + vec2(dx, 0) * quad); + vec4 p4 = texture2D(decal, v_texcoord0 + vec2(0, dy) * quad); + + vec3 w1 = mul(yuv, texture2D(decal, v_texcoord1.xw).rgb); + vec3 w2 = mul(yuv, texture2D(decal, v_texcoord1.yw).rgb); + vec3 w3 = mul(yuv, texture2D(decal, v_texcoord1.zw).rgb); + + vec3 w4 = mul(yuv, texture2D(decal, v_texcoord2.xw).rgb); + vec3 w5 = mul(yuv, p1.rgb); + vec3 w6 = mul(yuv, texture2D(decal, v_texcoord2.zw).rgb); + + vec3 w7 = mul(yuv, texture2D(decal, v_texcoord3.xw).rgb); + vec3 w8 = mul(yuv, texture2D(decal, v_texcoord3.yw).rgb); + vec3 w9 = mul(yuv, texture2D(decal, v_texcoord3.zw).rgb); + + mat3 pattern = mat3(diff(w5, w1), diff(w5, w2), diff(w5, w3), diff(w5, w4), 0.0, diff(w5, w6), diff(w5, w7), diff(w5, w8), diff(w5, w9)); + vec4 cross = vec4(diff(w4, w2), diff(w2, w6), diff(w8, w4), diff(w6, w8)); + + vec2 index; + index.x = dot(pattern[0], vec3( 1.0, 2.0, 4.0)) + + dot(pattern[1], vec3( 8.0, 0.0, 16.0)) + + dot(pattern[2], vec3(32.0, 64.0, 128.0)); + index.y = dot(cross, vec4(1.0, 2.0, 4.0, 8.0)) * SCALE * SCALE + dot(floor(fp * vec2(SCALE, SCALE)), vec2(1.0, SCALE)); + + vec2 step = vec2(1.0, 1.0) / vec2(256.0, 16.0 * (SCALE * SCALE)); + vec2 offset = step / vec2(2.0, 2.0); + vec4 weights = texture2D(LUT, index * step + offset); + float sum = dot(weights, vec4(1.0, 1.0, 1.0, 1.0)); + mat4 transposed = mat4(vec4(p1.x, p2.x, p3.x, p4.x), vec4(p1.y, p2.y, p3.y, p4.y), vec4(p1.z, p2.z, p3.z, p4.z), vec4(p1.w, p2.w, p3.w, p4.w)); + vec4 res = mul(transposed, weights / vec4(sum, sum, sum, sum)); + + gl_FragColor = vec4(res.rgb, 1.0); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq3x/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/hq3x/varying.def.sc new file mode 100644 index 00000000000..57a7a910952 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq3x/varying.def.sc @@ -0,0 +1,9 @@ +vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); +vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0); +vec4 v_texcoord1 : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_texcoord2 : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_texcoord3 : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0); + +vec3 a_position : POSITION; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_blit.sc new file mode 100644 index 00000000000..405ef8feb3b --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_blit.sc @@ -0,0 +1,14 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texcoord0, v_color0 + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texcoord0 = a_texcoord0; + v_color0 = a_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_hq3x.sc b/src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_hq3x.sc new file mode 100644 index 00000000000..a77ac7006f7 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_hq3x.sc @@ -0,0 +1,36 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0 + +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin + +#include "common.sh" + +// Autos +uniform vec4 u_tex_size0; + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_color0 = a_color0; + + vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy; + float dx = ps.x; + float dy = ps.y; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + v_texcoord0 = a_texcoord0; + v_texcoord1 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, -dy); // w1 | w2 | w3 + v_texcoord2 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, 0.0); // w4 | w5 | w6 + v_texcoord3 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, dy); // w7 | w8 | w9 +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_blit.sc new file mode 100644 index 00000000000..9af7bcf0ee6 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_blit.sc @@ -0,0 +1,14 @@ +$input v_color0, v_texcoord0 + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +// Samplers +SAMPLER2D(s_tex, 0); + +void main() +{ + gl_FragColor = texture2D(s_tex, v_texcoord0) * v_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_hq4x.sc b/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_hq4x.sc new file mode 100644 index 00000000000..8e769bee46c --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_hq4x.sc @@ -0,0 +1,75 @@ +$input v_color0, v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3 + +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin + +#include "common.sh" + +// Autos +uniform vec4 u_tex_size0; + +// Samplers +SAMPLER2D(decal, 0); +SAMPLER2D(LUT, 1); + +#define trY 48.0 +#define trU 7.0 +#define trV 6.0 + +#define SCALE 4.0 + +float diff(vec3 yuv1, vec3 yuv2) +{ + vec3 yuv_threshold = vec3(trY / 255.0, trU / 255.0, trV / 255.0); + vec3 yuv_offset = vec3(0, 0.5, 0.5); + float res_x = (abs((yuv1.x + 0.0) - (yuv2.x + 0.0)) > (trY / 255.0)) ? 1.0 : 0.0; + float res_y = (abs((yuv1.y + 0.5) - (yuv2.y + 0.5)) > (trU / 255.0)) ? 1.0 : 0.0; + float res_z = (abs((yuv1.z + 0.5) - (yuv2.z + 0.5)) > (trV / 255.0)) ? 1.0 : 0.0; + return (res_x > 0.0) ? 1.0 : ((res_y > 0.0) ? 1.0 : ((res_z > 0.0) ? 1.0 : 0.0)); +} + +void main() +{ + mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.5, 0.5, -0.419, -0.081); + + vec2 fp = fract(v_texcoord0 * u_tex_size0.xy); + vec2 quad = sign(-0.5 + fp); + vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy; + + float dx = ps.x; + float dy = ps.y; + vec4 p1 = texture2D(decal, v_texcoord0); + vec4 p2 = texture2D(decal, v_texcoord0 + ps * quad); + vec4 p3 = texture2D(decal, v_texcoord0 + vec2(dx, 0) * quad); + vec4 p4 = texture2D(decal, v_texcoord0 + vec2(0, dy) * quad); + + vec3 w1 = mul(yuv, texture2D(decal, v_texcoord1.xw).rgb); + vec3 w2 = mul(yuv, texture2D(decal, v_texcoord1.yw).rgb); + vec3 w3 = mul(yuv, texture2D(decal, v_texcoord1.zw).rgb); + + vec3 w4 = mul(yuv, texture2D(decal, v_texcoord2.xw).rgb); + vec3 w5 = mul(yuv, p1.rgb); + vec3 w6 = mul(yuv, texture2D(decal, v_texcoord2.zw).rgb); + + vec3 w7 = mul(yuv, texture2D(decal, v_texcoord3.xw).rgb); + vec3 w8 = mul(yuv, texture2D(decal, v_texcoord3.yw).rgb); + vec3 w9 = mul(yuv, texture2D(decal, v_texcoord3.zw).rgb); + + mat3 pattern = mat3(diff(w5, w1), diff(w5, w2), diff(w5, w3), diff(w5, w4), 0.0, diff(w5, w6), diff(w5, w7), diff(w5, w8), diff(w5, w9)); + vec4 cross = vec4(diff(w4, w2), diff(w2, w6), diff(w8, w4), diff(w6, w8)); + + vec2 index; + index.x = dot(pattern[0], vec3( 1.0, 2.0, 4.0)) + + dot(pattern[1], vec3( 8.0, 0.0, 16.0)) + + dot(pattern[2], vec3(32.0, 64.0, 128.0)); + index.y = dot(cross, vec4(1.0, 2.0, 4.0, 8.0)) * SCALE * SCALE + dot(floor(fp * vec2(SCALE, SCALE)), vec2(1.0, SCALE)); + + vec2 step = vec2(1.0, 1.0) / vec2(256.0, 16.0 * (SCALE * SCALE)); + vec2 offset = step / vec2(2.0, 2.0); + vec4 weights = texture2D(LUT, index * step + offset); + float sum = dot(weights, vec4(1.0, 1.0, 1.0, 1.0)); + mat4 transposed = mat4(vec4(p1.x, p2.x, p3.x, p4.x), vec4(p1.y, p2.y, p3.y, p4.y), vec4(p1.z, p2.z, p3.z, p4.z), vec4(p1.w, p2.w, p3.w, p4.w)); + vec4 res = mul(transposed, weights / vec4(sum, sum, sum, sum)); + + gl_FragColor = vec4(res.rgb, 1.0); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq4x/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/hq4x/varying.def.sc new file mode 100644 index 00000000000..57a7a910952 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq4x/varying.def.sc @@ -0,0 +1,9 @@ +vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); +vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0); +vec4 v_texcoord1 : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_texcoord2 : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_texcoord3 : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0); + +vec3 a_position : POSITION; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_blit.sc new file mode 100644 index 00000000000..405ef8feb3b --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_blit.sc @@ -0,0 +1,14 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texcoord0, v_color0 + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texcoord0 = a_texcoord0; + v_color0 = a_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_hq4x.sc b/src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_hq4x.sc new file mode 100644 index 00000000000..a77ac7006f7 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_hq4x.sc @@ -0,0 +1,36 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0 + +// license:LGPL-2.1+ +// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin + +#include "common.sh" + +// Autos +uniform vec4 u_tex_size0; + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_color0 = a_color0; + + vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy; + float dx = ps.x; + float dy = ps.y; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + v_texcoord0 = a_texcoord0; + v_texcoord1 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, -dy); // w1 | w2 | w3 + v_texcoord2 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, 0.0); // w4 | w5 | w6 + v_texcoord3 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, dy); // w7 | w8 | w9 +}