summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/render')
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.cpp52
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.h4
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/fs_bob-and-ghost-deinterlace.sc55
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/fs_deposterize-pass0.sc45
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/fs_deposterize-pass1.sc45
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/fs_saturation.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_saturation.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/varying.def.sc7
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hlsl/vs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/vs_bob-and-ghost-deinterlace.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/vs_deposterize-pass0.sc30
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/vs_deposterize-pass1.sc30
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/vs_saturation.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/vs_saturation.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_saturation.sc25
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_saturation.sc25
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_saturation.sc25
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/fs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/fs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/fs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/vs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/fs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/vs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/fs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/vs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/fs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/vs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/fs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_blit.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/vs_saturation.sc)2
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/vs_saturation.sc)2
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/vs_blit.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/vs_saturation.sc)2
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv1-noblend.sc132
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-3d.sc260
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-fast.sc201
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc229
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_custom-jinc2-sharper.sc134
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass0.sc227
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass1.sc211
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass2.sc213
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass0.sc217
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass1.sc210
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass1f.sc211
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass2.sc226
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass3.sc210
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass3f.sc211
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass0.sc169
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass1.sc159
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass2.sc162
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass0.sc160
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass1.sc178
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass2.sc170
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/varying.def.sc10
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_custom-jinc2-sharper.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-2xbr-3d-pass0.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-2xbr-3d-pass1.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-2xbr-3d-pass2.sc50
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass0.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass1.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass1f.sc24
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass2.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass3.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass3f.sc24
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass0.sc40
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass1.sc40
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass2.sc40
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass0.sc50
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass1.sc40
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass2.sc50
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass3.sc50
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/varying.def.sc13
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv1-noblend.sc22
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-3d.sc23
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-fast.sc29
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2.sc27
107 files changed, 5170 insertions, 83 deletions
diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp
index 458a45d449c..80934ed073a 100644
--- a/src/osd/modules/render/bgfx/chainmanager.cpp
+++ b/src/osd/modules/render/bgfx/chainmanager.cpp
@@ -48,7 +48,7 @@ chain_manager::chain_manager(running_machine& machine, osd_options& options, tex
, m_slider_notifier(slider_notifier)
, m_screen_count(0)
{
- find_available_chains(options.bgfx_path());
+ refresh_available_chains();
parse_chain_selections(options.bgfx_screen_chains());
}
@@ -57,12 +57,41 @@ chain_manager::~chain_manager()
destroy_chains();
}
-void chain_manager::find_available_chains(std::string path)
+void chain_manager::refresh_available_chains()
{
m_available_chains.clear();
m_available_chains.push_back("none");
- osd_directory *directory = osd_opendir((path + "/chains").c_str());
+ find_available_chains(std::string(m_options.bgfx_path()) + "/chains");
+
+ destroy_unloaded_chains();
+}
+
+void chain_manager::destroy_unloaded_chains()
+{
+ // O(shaders*available_chains), but we don't care because asset reloading happens rarely
+ for (int i = 0; i < m_chain_names.size(); i++)
+ {
+ std::string name = m_chain_names[i];
+ if (name.length() > 0)
+ {
+ for (std::string available_name : m_available_chains)
+ {
+ if (available_name == name)
+ {
+ delete m_screen_chains[i];
+ m_chain_names[i] = "";
+ m_current_chain[i] = CHAIN_NONE;
+ break;
+ }
+ }
+ }
+ }
+}
+
+void chain_manager::find_available_chains(std::string path)
+{
+ osd_directory *directory = osd_opendir(path.c_str());
if (directory != nullptr)
{
for (const osd_directory_entry *entry = osd_readdir(directory); entry != nullptr; entry = osd_readdir(directory))
@@ -85,6 +114,14 @@ void chain_manager::find_available_chains(std::string path)
}
}
}
+ else if (entry->type == ENTTYPE_DIR)
+ {
+ std::string name = entry->name;
+ if (!(name == "." || name == ".."))
+ {
+ find_available_chains(path + PATH_SEPARATOR + name);
+ }
+ }
}
osd_closedir(directory);
@@ -144,6 +181,7 @@ void chain_manager::parse_chain_selections(std::string chain_str)
while (m_current_chain.size() != chain_names.size())
{
m_screen_chains.push_back(nullptr);
+ m_chain_names.push_back("");
m_current_chain.push_back(CHAIN_NONE);
}
@@ -161,10 +199,12 @@ void chain_manager::parse_chain_selections(std::string chain_str)
if (chain_index < m_available_chains.size())
{
m_current_chain[index] = chain_index;
+ m_chain_names[index] = m_available_chains[chain_index];
}
else
{
m_current_chain[index] = CHAIN_NONE;
+ m_chain_names[index] = "";
}
}
}
@@ -201,7 +241,8 @@ void chain_manager::load_chains()
{
if (m_current_chain[chain] != CHAIN_NONE)
{
- m_screen_chains[chain] = load_chain(m_available_chains[m_current_chain[chain]], uint32_t(chain));
+ m_chain_names[chain] = m_available_chains[m_current_chain[chain]];
+ m_screen_chains[chain] = load_chain(m_chain_names[chain], uint32_t(chain));
}
}
}
@@ -245,7 +286,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_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT);
+ bgfx_texture *texture = new bgfx_texture(full_name, bgfx::TextureFormat::RGBA8, tex_width, tex_height, mem, BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | 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);
@@ -293,6 +334,7 @@ void chain_manager::update_screen_count(uint32_t screen_count)
while (m_screen_chains.size() < m_screen_count)
{
m_screen_chains.push_back(nullptr);
+ m_chain_names.push_back("");
m_current_chain.push_back(CHAIN_NONE);
}
diff --git a/src/osd/modules/render/bgfx/chainmanager.h b/src/osd/modules/render/bgfx/chainmanager.h
index 7d8d0c16eb3..022dbecfa14 100644
--- a/src/osd/modules/render/bgfx/chainmanager.h
+++ b/src/osd/modules/render/bgfx/chainmanager.h
@@ -15,6 +15,7 @@
#define __DRAWBGFX_CHAIN_MANAGER__
#include <vector>
+#include <map>
#include <string>
#include "texturemanager.h"
@@ -48,6 +49,8 @@ private:
void destroy_chains();
void reload_chains();
+ void refresh_available_chains();
+ void destroy_unloaded_chains();
void find_available_chains(std::string path);
void parse_chain_selections(std::string chain_str);
std::vector<std::string> split_option_string(std::string chain_str) const;
@@ -69,6 +72,7 @@ private:
uint32_t m_screen_count;
std::vector<std::string> m_available_chains;
std::vector<bgfx_chain*> m_screen_chains;
+ std::vector<std::string> m_chain_names;
std::vector<ui_menu_item> m_selection_sliders;
std::vector<int32_t> m_current_chain;
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit.sc
index 9af7bcf0ee6..9af7bcf0ee6 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_bob-and-ghost-deinterlace.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_bob-and-ghost-deinterlace.sc
new file mode 100644
index 00000000000..45d38a0e020
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_bob-and-ghost-deinterlace.sc
@@ -0,0 +1,55 @@
+$input v_color0, v_texcoord0
+
+// license:BSD-3-Clause
+// copyright-holders:Dario Manesku
+
+/*
+ Bob-and-ghost Deinterlacing
+ Author: hunterk
+ License: Public domain
+
+ Note: This shader is designed to work with the typical interlaced output from an emulator, which displays both even and odd fields twice.
+ As such, it is inappropriate for general video use unless the video has already been similarly woven beforehand.
+*/
+
+#include "common.sh"
+
+// Samplers
+SAMPLER2D(s0, 0);
+
+uniform vec4 u_tex_size0;
+
+#define one_pixel vec2(1.0 / u_tex_size0.xy)
+
+void main()
+{
+ vec4 exponent = vec4(2.2, 2.2, 2.2, 2.2);
+ vec4 inv_exponent = 1.0 / exponent;
+ vec4 res = vec4(pow(texture2D(s0, v_texcoord0), exponent));
+ vec4 color;
+ float y;
+
+ // assume anything with a vertical resolution greater than 400 lines is interlaced
+ if (u_tex_size0.y > 400.0)
+ {
+ y = u_tex_size0.y * v_texcoord0.y;// FIXME + IN.frame_count;
+ res = pow(vec4(texture2D(s0, v_texcoord0 + vec2(0.0, one_pixel.y))), exponent);
+ color = pow((vec4(texture2D(s0, v_texcoord0 - vec2(0.0, 0.5 * one_pixel.y))) + vec4(texture2D(s0, v_texcoord0 + vec2(0.0, 0.5 * one_pixel.y)))) / 2.0, exponent);
+ }
+ else
+ {
+ y = 2.0 * u_tex_size0.y * v_texcoord0.y;
+ color = res;
+ }
+
+ if (mod(y, 2.0) > 0.99999)
+ {
+ res = res;
+ }
+ else
+ {
+ res = vec4(pow(texture2D(s0, v_texcoord0), exponent));
+ }
+
+ gl_FragColor = vec4(pow((res + color) / 2.0, inv_exponent));
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_deposterize-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_deposterize-pass0.sc
new file mode 100644
index 00000000000..cbff9f450e8
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_deposterize-pass0.sc
@@ -0,0 +1,45 @@
+$input v_color0, v_texcoord0, v_texcoord1
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's Deposterize Shader - Pass0
+
+ Copyright (C) 2011/2016 Hyllian/Jararaca - sergiogdb@gmail.com
+
+*/
+
+#include "common.sh"
+
+// Samplers
+SAMPLER2D(decal, 0);
+
+uniform vec4 EQ_THRESH1;
+uniform vec4 DIFF_THRESH1;
+
+vec3 df3(vec3 c1, vec3 c2)
+{
+ return abs(c1 - c2);
+}
+
+bvec3 le3(vec3 A, vec3 B, vec3 param)
+{
+ return lessThanEqual(df3(A, B), param);
+}
+
+bvec3 gt3(vec3 A, vec3 B, vec3 param)
+{
+ return greaterThan(df3(A, B), param);
+}
+
+void main()
+{
+ vec3 D = texture2D(decal, v_texcoord1.xw).rgb;
+ vec3 E = texture2D(decal, v_texcoord1.yw).rgb;
+ vec3 F = texture2D(decal, v_texcoord1.zw).rgb;
+
+ vec3 res = (any(gt3(D, F, EQ_THRESH1.xxx)) && (any(le3(E, F, DIFF_THRESH1.xxx)) && any(le3(D, E, EQ_THRESH1.xxx)) || any(le3(D, E, DIFF_THRESH1.xxx)) && any(le3(E, F, EQ_THRESH1.xxx)))) ? 0.5 * (D + F) : E;
+
+ gl_FragColor = vec4(res, 1.0);
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_deposterize-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_deposterize-pass1.sc
new file mode 100644
index 00000000000..c6e0e87b018
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_deposterize-pass1.sc
@@ -0,0 +1,45 @@
+$input v_color0, v_texcoord0, v_texcoord1
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's Deposterize Shader - Pass1
+
+ Copyright (C) 2011/2016 Hyllian/Jararaca - sergiogdb@gmail.com
+
+*/
+
+#include "common.sh"
+
+// Samplers
+SAMPLER2D(decal, 0);
+
+uniform vec4 EQ_THRESH2;
+uniform vec4 DIFF_THRESH2;
+
+vec3 df3(vec3 c1, vec3 c2)
+{
+ return abs(c1 - c2);
+}
+
+bvec3 le3(vec3 A, vec3 B, vec3 param)
+{
+ return lessThanEqual(df3(A, B), param);
+}
+
+bvec3 gt3(vec3 A, vec3 B, vec3 param)
+{
+ return greaterThan(df3(A, B), param);
+}
+
+void main()
+{
+ vec3 B = texture2D(decal, v_texcoord1.xy).rgb;
+ vec3 E = texture2D(decal, v_texcoord1.xz).rgb;
+ vec3 H = texture2D(decal, v_texcoord1.xw).rgb;
+
+ vec3 res = (any(gt3(B, H, EQ_THRESH2.xxx)) && (any(le3(E, H, DIFF_THRESH2.xxx)) && any(le3(B, E, EQ_THRESH2.xxx)) || any(le3(B, E, DIFF_THRESH2.xxx)) && any(le3(E, H, EQ_THRESH2.xxx)))) ? 0.5 * (B + H) : E;
+
+ gl_FragColor = vec4(res, 1.0);
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_saturation.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_saturation.sc
index c14f61601c8..c14f61601c8 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_saturation.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_saturation.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/varying.def.sc
new file mode 100644
index 00000000000..8404fc635e1
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/varying.def.sc
@@ -0,0 +1,7 @@
+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);
+
+vec3 a_position : POSITION;
+vec4 a_color0 : COLOR0;
+vec2 a_texcoord0 : TEXCOORD0;
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hlsl/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_blit.sc
index 405ef8feb3b..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hlsl/vs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_bob-and-ghost-deinterlace.sc
index 405ef8feb3b..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_bob-and-ghost-deinterlace.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/vs_deposterize-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_deposterize-pass0.sc
new file mode 100644
index 00000000000..1c3b3ee592f
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_deposterize-pass0.sc
@@ -0,0 +1,30 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's Deposterize Shader - Pass0 vertex shader
+
+ Copyright (C) 2011/2016 Hyllian/Jararaca - sergiogdb@gmail.com
+
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+
+ vec2 ps = vec2(1.0 / u_tex_size0.xy);
+ float dx = ps.x;
+ float dy = ps.y;
+
+ // This line fixes a bug in ATI cards.
+ v_texcoord0 = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ v_texcoord1 = v_texcoord0.xxxy + vec4(-dx, 0, dx, 0); // D E F
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/vs_deposterize-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_deposterize-pass1.sc
new file mode 100644
index 00000000000..7af87394655
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_deposterize-pass1.sc
@@ -0,0 +1,30 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's Deposterize Shader - Pass1 vertex shader
+
+ Copyright (C) 2011/2016 Hyllian/Jararaca - sergiogdb@gmail.com
+
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+
+ vec2 ps = vec2(1.0 / u_tex_size0.xy);
+ float dx = ps.x;
+ float dy = ps.y;
+
+ // This line fixes a bug in ATI cards.
+ v_texcoord0 = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ v_texcoord1 = v_texcoord0.xyyy + vec4(0, -dy, 0, dy); // D E F
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/vs_saturation.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_saturation.sc
index fc524496a1f..fc524496a1f 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/vs_saturation.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_saturation.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_saturation.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_saturation.sc
deleted file mode 100644
index c14f61601c8..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_saturation.sc
+++ /dev/null
@@ -1,25 +0,0 @@
-$input v_color0, v_texcoord0
-
-// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz
-
-#include "common.sh"
-
-// User-supplied
-uniform vec4 u_saturation;
-
-// Samplers
-SAMPLER2D(s_tex, 0);
-
-void main()
-{
- vec4 base = texture2D(s_tex, v_texcoord0);
- vec3 rgb = base.rgb;
-
- vec3 gray = vec3(0.299, 0.587, 0.114);
- float luma = dot(rgb, gray);
- vec3 chroma = rgb - luma;
- vec3 saturated = luma + chroma * u_saturation.x;
-
- gl_FragColor = vec4(saturated, base.a);
-}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_saturation.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_saturation.sc
deleted file mode 100644
index c14f61601c8..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_saturation.sc
+++ /dev/null
@@ -1,25 +0,0 @@
-$input v_color0, v_texcoord0
-
-// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz
-
-#include "common.sh"
-
-// User-supplied
-uniform vec4 u_saturation;
-
-// Samplers
-SAMPLER2D(s_tex, 0);
-
-void main()
-{
- vec4 base = texture2D(s_tex, v_texcoord0);
- vec3 rgb = base.rgb;
-
- vec3 gray = vec3(0.299, 0.587, 0.114);
- float luma = dot(rgb, gray);
- vec3 chroma = rgb - luma;
- vec3 saturated = luma + chroma * u_saturation.x;
-
- gl_FragColor = vec4(saturated, base.a);
-}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_saturation.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_saturation.sc
deleted file mode 100644
index c14f61601c8..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_saturation.sc
+++ /dev/null
@@ -1,25 +0,0 @@
-$input v_color0, v_texcoord0
-
-// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz
-
-#include "common.sh"
-
-// User-supplied
-uniform vec4 u_saturation;
-
-// Samplers
-SAMPLER2D(s_tex, 0);
-
-void main()
-{
- vec4 base = texture2D(s_tex, v_texcoord0);
- vec3 rgb = base.rgb;
-
- vec3 gray = vec3(0.299, 0.587, 0.114);
- float luma = dot(rgb, gray);
- vec3 chroma = rgb - luma;
- vec3 saturated = luma + chroma * u_saturation.x;
-
- gl_FragColor = vec4(saturated, base.a);
-}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/fs_blit.sc
index 9af7bcf0ee6..9af7bcf0ee6 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/fs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/super-4xbr-3d-4p/vs_blit.sc
index 405ef8feb3b..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/vs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/fs_blit.sc
index 9af7bcf0ee6..9af7bcf0ee6 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/fs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/super-4xbr-3d-6p-smoother/vs_blit.sc
index 405ef8feb3b..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/vs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/fs_blit.sc
index 9af7bcf0ee6..9af7bcf0ee6 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/fs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/pillarbox_left_horizontal/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/vs_blit.sc
index 405ef8feb3b..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/vs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/vs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/fs_blit.sc
index 9af7bcf0ee6..9af7bcf0ee6 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/fs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/pillarbox_left_vertical/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/vs_blit.sc
index 405ef8feb3b..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/vs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/vs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/fs_blit.sc
index 9af7bcf0ee6..9af7bcf0ee6 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/fs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/pillarbox_right_horizontal/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/vs_blit.sc
index 405ef8feb3b..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/vs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/vs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/fs_blit.sc
index 9af7bcf0ee6..9af7bcf0ee6 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/fs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/pillarbox_right_vertical/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/vs_blit.sc
index 405ef8feb3b..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/vs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/vs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/fs_blit.sc
index 9af7bcf0ee6..9af7bcf0ee6 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_blit.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/fs_blit.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/pillarbox_left_horizontal/vs_saturation.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/vs_blit.sc
index 57be1439a8b..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/vs_saturation.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/vs_blit.sc
@@ -9,6 +9,6 @@ $output v_texcoord0, v_color0
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
- v_texcoord0 = a_texcoord0 * vec2(0.16666666 * 0.9, 1.0 * 0.8) + vec2(0.1, 0.1);
+ v_texcoord0 = a_texcoord0;
v_color0 = a_color0;
}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/fs_blit.sc
new file mode 100644
index 00000000000..9af7bcf0ee6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/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/xbr-lv2-deposterize/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/pillarbox_right_vertical/vs_saturation.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/vs_blit.sc
index ef86b6a0a43..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/vs_saturation.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/vs_blit.sc
@@ -9,6 +9,6 @@ $output v_texcoord0, v_color0
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
- v_texcoord0 = a_texcoord0 * vec2(1.0 * 0.8, 0.685185 * 0.9) + vec2(0.1, 0.9 - 0.685185 * 0.9);
+ v_texcoord0 = a_texcoord0;
v_color0 = a_color0;
}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/fs_blit.sc
new file mode 100644
index 00000000000..9af7bcf0ee6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/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/xbr-lv2-fast/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/pillarbox_right_horizontal/vs_saturation.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/vs_blit.sc
index c0f9321abc1..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/vs_saturation.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/vs_blit.sc
@@ -9,6 +9,6 @@ $output v_texcoord0, v_color0
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
- v_texcoord0 = a_texcoord0 * vec2(0.16666666 * 0.9, 1.0 * 0.8) + vec2(0.9 - 0.16666666 * 0.9, 0.1);
+ v_texcoord0 = a_texcoord0;
v_color0 = a_color0;
}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/fs_blit.sc
new file mode 100644
index 00000000000..9af7bcf0ee6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/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/xbr-lv2-multipass/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/xbr-lv2-multipass/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/vs_blit.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/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/xbr-lv2-noblend/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/fs_blit.sc
new file mode 100644
index 00000000000..9af7bcf0ee6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/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/xbr-lv2-noblend/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/xbr-lv2-noblend/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/vs_blit.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/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/xbr-lv3-multipass/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/fs_blit.sc
new file mode 100644
index 00000000000..9af7bcf0ee6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/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/xbr-lv3-multipass/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/xbr-lv3-multipass/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/vs_blit.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/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/xbr-lv3-noblend/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/fs_blit.sc
new file mode 100644
index 00000000000..9af7bcf0ee6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/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/xbr-lv3-noblend/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/xbr-lv3-noblend/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/vs_blit.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/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/xbr-lv3/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/fs_blit.sc
new file mode 100644
index 00000000000..9af7bcf0ee6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/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/xbr-lv3/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/xbr-lv3/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/vs_blit.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/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/xbr-mlv4-dilation/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/fs_blit.sc
new file mode 100644
index 00000000000..9af7bcf0ee6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/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/xbr-mlv4-dilation/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/xbr-mlv4-dilation/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/vs_blit.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/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/xbr-mlv4-multipass/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/fs_blit.sc
new file mode 100644
index 00000000000..9af7bcf0ee6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/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/xbr-mlv4-multipass/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/xbr-mlv4-multipass/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/vs_blit.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/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/xbr/fs_xbr-lv1-noblend.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv1-noblend.sc
new file mode 100644
index 00000000000..72212fa74a7
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv1-noblend.sc
@@ -0,0 +1,132 @@
+$input v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR-lv1-noblend Shader
+
+ Copyright (C) 2011-2014 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.
+
+*/
+
+#include "common.sh"
+
+uniform vec4 XBR_Y_WEIGHT;
+uniform vec4 XBR_EQ_THRESHOLD;
+
+uniform vec4 u_tex_size0;
+
+SAMPLER2D(decal, 0);
+
+// Uncomment just one of the three params below to choose the corner detection
+//#define CORNER_A
+//#define CORNER_B
+#define CORNER_C
+
+float RGBtoYUV(vec3 color)
+{
+ return dot(color, XBR_Y_WEIGHT.xxx * vec3(0.2126, 0.7152, 0.0722));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < XBR_EQ_THRESHOLD.x);
+}
+
+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));
+}
+
+/*
+ xBR LVL1 works over the pixels below:
+
+ |B |C |
+ |D |E |F |F4|
+ |G |H |I |I4|
+ |H5|I5|
+
+ Consider E as the central pixel. xBR LVL1 needs only to look at 12 texture pixels.
+*/
+
+void main()
+{
+ vec2 pos = fract(v_texcoord0 * u_tex_size0.xy) - vec2(0.5, 0.5); // pos = pixel position
+ vec2 dir = sign(pos); // dir = pixel direction
+
+ vec2 g1 = dir * v_texcoord1.xy;
+ vec2 g2 = dir * v_texcoord1.zw;
+
+ vec3 B = texture2D(decal, v_texcoord0 +g1 ).xyz;
+ vec3 C = texture2D(decal, v_texcoord0 +g1-g2).xyz;
+ vec3 D = texture2D(decal, v_texcoord0 +g2).xyz;
+ vec3 E = texture2D(decal, v_texcoord0 ).xyz;
+ vec3 F = texture2D(decal, v_texcoord0 -g2).xyz;
+ vec3 G = texture2D(decal, v_texcoord0 -g1+g2).xyz;
+ vec3 H = texture2D(decal, v_texcoord0 -g1 ).xyz;
+ vec3 I = texture2D(decal, v_texcoord0 -g1-g2).xyz;
+
+ vec3 F4 = texture2D(decal,v_texcoord0 -2.0*g2 ).xyz;
+ vec3 I4 = texture2D(decal,v_texcoord0 -g1-2.0*g2 ).xyz;
+ vec3 H5 = texture2D(decal,v_texcoord0 -2.0*g1 ).xyz;
+ vec3 I5 = texture2D(decal,v_texcoord0 -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 i5 = RGBtoYUV( I5 );
+ float h5 = RGBtoYUV( H5 );
+ float f4 = RGBtoYUV( F4 );
+
+ bool fx = (dot(dir,pos) > 0.5); // inequations of straight lines.
+
+// It uses CORNER_C if none of the others are defined.
+#ifdef CORNER_A
+ bool interp_restriction_lv1 = ((e!=f) && (e!=h));
+#elif CORNER_B
+ bool interp_restriction_lv1 = ((e!=f) && (e!=h) && ( !eq(f,b) && !eq(h,d) || eq(e,i) && !eq(f,i4) && !eq(h,i5) || eq(e,g) || eq(e,c) ) );
+#else
+ bool interp_restriction_lv1 = ((e!=f) && (e!=h) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+#endif
+ bool edr = (weighted_distance(e, c, g, i, h5, f4, h, f) < weighted_distance(h, d, i5, f, i4, b, e, i)) && interp_restriction_lv1; // edr = edge detection rule
+
+ bool nc = (edr && fx); // new_color
+
+ bool px = (df(e,f) <= df(e,h)); // px = pixel
+
+ vec3 res = nc ? px ? F : H : E;
+
+ // final sum and weight normalization
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-3d.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-3d.sc
new file mode 100644
index 00000000000..1febb8f5ee3
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-3d.sc
@@ -0,0 +1,260 @@
+$input v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR-lv2-3d Shader
+
+ 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.
+
+ Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
+*/
+
+#include "common.sh"
+
+uniform vec4 XBR_SCALE;
+uniform vec4 XBR_Y_WEIGHT;
+uniform vec4 XBR_EQ_THRESHOLD;
+uniform vec4 XBR_LV2_COEFFICIENT;
+uniform vec4 XBR_RES;
+
+uniform vec4 u_tex_size0;
+
+SAMPLER2D(decal, 0);
+
+// 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
+
+#ifndef CORNER_A
+ #define SMOOTH_TIPS
+#endif
+
+const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25);
+
+const vec4 Y = vec4(0.2126, 0.7152, 0.0722, 0.0);
+
+vec4 df(vec4 A, vec4 B)
+{
+ return abs(A - B);
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 eq(vec4 A, vec4 B)
+{
+ return vec4(equal(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 abslt(vec4 A, vec4 B)
+{
+ return lt(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+}
+
+vec4 absge(vec4 A, vec4 B)
+{
+ return ge(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+}
+
+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));
+}
+
+void main()
+{
+ vec4 delta = 1.0 / XBR_SCALE.xxxx;
+ vec4 deltaL = vec4(0.5, 1.0, 0.5, 1.0) / XBR_SCALE.xxxx;
+ vec4 deltaU = deltaL.yxwz;
+
+ vec2 fp = fract(v_texcoord0 * u_tex_size0.xy / XBR_RES.xx);
+
+ vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES.xx) + vec2(0.5, 0.5)) * XBR_RES.xx / u_tex_size0.xy;
+
+ vec2 dx = v_texcoord1.xy;
+ vec2 dy = v_texcoord1.zw;
+
+ vec4 A = texture2D(decal, v_texcoord0 -dx -dy);
+ vec4 B = texture2D(decal, v_texcoord0 -dy);
+ vec4 C = texture2D(decal, v_texcoord0 +dx -dy);
+ vec4 D = texture2D(decal, v_texcoord0 -dx );
+ vec4 E = texture2D(decal, v_texcoord0 );
+ vec4 F = texture2D(decal, v_texcoord0 +dx );
+ vec4 G = texture2D(decal, v_texcoord0 -dx +dy);
+ vec4 H = texture2D(decal, v_texcoord0 +dy);
+ vec4 I = texture2D(decal, v_texcoord0 +dx +dy);
+
+ vec4 A1 = texture2D(decal, v_texcoord0 -dx -2.0*dy);
+ vec4 B1 = texture2D(decal, v_texcoord0 -2.0*dy);
+ vec4 C1 = texture2D(decal, v_texcoord0 +dx -2.0*dy);
+ vec4 G5 = texture2D(decal, v_texcoord0 -dx +2.0*dy);
+ vec4 H5 = texture2D(decal, v_texcoord0 +2.0*dy);
+ vec4 I5 = texture2D(decal, v_texcoord0 +dx +2.0*dy);
+ vec4 A0 = texture2D(decal, v_texcoord0 -2.0*dx -dy);
+ vec4 D0 = texture2D(decal, v_texcoord0 -2.0*dx );
+ vec4 G0 = texture2D(decal, v_texcoord0 -2.0*dx +dy);
+ vec4 C4 = texture2D(decal, v_texcoord0 +2.0*dx -dy);
+ vec4 F4 = texture2D(decal, v_texcoord0 +2.0*dx );
+ vec4 I4 = texture2D(decal, v_texcoord0 +2.0*dx +dy);
+
+ vec4 F6 = texture2D(decal, tex +dx+0.25*dx+0.25*dy);
+ vec4 F7 = texture2D(decal, tex +dx+0.25*dx-0.25*dy);
+ vec4 F8 = texture2D(decal, tex +dx-0.25*dx-0.25*dy);
+ vec4 F9 = texture2D(decal, tex +dx-0.25*dx+0.25*dy);
+
+ vec4 B6 = texture2D(decal, tex +0.25*dx+0.25*dy-dy);
+ vec4 B7 = texture2D(decal, tex +0.25*dx-0.25*dy-dy);
+ vec4 B8 = texture2D(decal, tex -0.25*dx-0.25*dy-dy);
+ vec4 B9 = texture2D(decal, tex -0.25*dx+0.25*dy-dy);
+
+ vec4 D6 = texture2D(decal, tex -dx+0.25*dx+0.25*dy);
+ vec4 D7 = texture2D(decal, tex -dx+0.25*dx-0.25*dy);
+ vec4 D8 = texture2D(decal, tex -dx-0.25*dx-0.25*dy);
+ vec4 D9 = texture2D(decal, tex -dx-0.25*dx+0.25*dy);
+
+ vec4 H6 = texture2D(decal, tex +0.25*dx+0.25*dy+dy);
+ vec4 H7 = texture2D(decal, tex +0.25*dx-0.25*dy+dy);
+ vec4 H8 = texture2D(decal, tex -0.25*dx-0.25*dy+dy);
+ vec4 H9 = texture2D(decal, tex -0.25*dx+0.25*dy+dy);
+
+ vec4 b = mul(mat4(B, D, H, F), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 c = mul(mat4(C, A, G, I), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 e = mul(mat4(E, E, E, E), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 d = b.yzwx;
+ vec4 f = b.wxyz;
+ vec4 g = c.zwxy;
+ vec4 h = b.zwxy;
+ vec4 i = c.wxyz;
+
+ vec4 i4 = mul(mat4(I4, C1, A0, G5), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 f4 = h5.yzwx;
+
+ vec4 f0 = mul(mat4(F6, B6, D6, H6), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 f1 = mul(mat4(F7, B7, D7, H7), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 f2 = mul(mat4(F8, B8, D8, H8), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 f3 = mul(mat4(F9, B9, D9, H9), XBR_Y_WEIGHT.xxxx * Y);
+
+ vec4 h0 = f0.wxyz;
+ vec4 h1 = f1.wxyz;
+ vec4 h2 = f2.wxyz;
+ vec4 h3 = f3.wxyz;
+
+ // These inequations define the line below which interpolation occurs.
+ vec4 fx = (Ao*fp.y+Bo*fp.x);
+ vec4 fx_left = (Ax*fp.y+Bx*fp.x);
+ vec4 fx_up = (Ay*fp.y+By*fp.x);
+
+ vec4 block_3d = (eq(f0,f1) * eq(f1,f2) * eq(f2,f3) * eq(h0,h1) * eq(h1,h2) * eq(h2,h3));
+ vec4 interp_restriction_lv0 = (ne(e,f) * ne(e,h) * block_3d);
+ vec4 interp_restriction_lv1 = interp_restriction_lv0;
+
+#ifdef CORNER_B
+ interp_restriction_lv1 = (interp_restriction_lv0 * (ge(f,b) * ge(h,d) + eq(e,i) * ge(f,i4) * ge(h,i5) + eq(e,g) + eq(e,c)));
+#endif
+#ifdef CORNER_D
+ vec4 c1 = i4.yzwx;
+ vec4 g0 = i5.wxyz;
+ interp_restriction_lv1 = (interp_restriction_lv0 * (ge(f,b) * ge(h,d) + eq(e,i) * ge(f,i4) * ge(h,i5) + eq(e,g) + eq(e,c) ) * (ne(f,f4) * ne(f,i) + ne(h,h5) * ne(h,i) + ne(h,g) + ne(f,c) + eq(b,c1) * eq(d,g0)));
+#endif
+#ifdef CORNER_C
+ interp_restriction_lv1 = (interp_restriction_lv0 * (ge(f,b) * ge(f,c) + ge(h,d) * ge(h,g) + eq(e,i) * (ge(f,f4) * ge(f,i4) + ge(h,h5) * ge(h,i5)) + eq(e,g) + eq(e,c)));
+#endif
+
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 fx45i = saturate((fx + delta -Co - Ci) / (2.0 * delta ));
+ vec4 fx45 = saturate((fx + delta -Co ) / (2.0 * delta ));
+ vec4 fx30 = saturate((fx_left + deltaL -Cx ) / (2.0 * deltaL));
+ vec4 fx60 = saturate((fx_up + deltaU -Cy ) / (2.0 * deltaU));
+
+ vec4 wd1 = weighted_distance( e, c, g, i, h5, f4, h, f);
+ vec4 wd2 = weighted_distance( h, d, i5, f, i4, b, e, i);
+
+ vec4 edri = le(wd1,wd2) * interp_restriction_lv0;
+ vec4 edr = lt(wd1,wd2) * interp_restriction_lv1;
+ vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr;
+
+ fx45 = edr * fx45;
+ fx30 = edr_left * fx30;
+ fx60 = edr_up * fx60;
+ fx45i = edri * fx45i;
+
+ vec4 px = le(df(e,f3), df(e,h1));
+
+#ifdef SMOOTH_TIPS
+ vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
+#else
+ vec4 maximos = max(max(fx30, fx60), fx45);
+#endif
+
+ vec3 res1 = E.xyz;
+ res1 = mix(res1, mix(H.xyz, F.xyz, px.x), maximos.x);
+ res1 = mix(res1, mix(B.xyz, D.xyz, px.z), maximos.z);
+
+ vec3 res2 = E.xyz;
+ res2 = mix(res2, mix(F.xyz, B.xyz, px.y), maximos.y);
+ res2 = mix(res2, mix(D.xyz, H.xyz, px.w), maximos.w);
+
+ vec3 E_mix = (c_df(E.xyz, res2) >= c_df(E.xyz, res1)) ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 res = mix(res1, res2, E_mix);
+
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-fast.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-fast.sc
new file mode 100644
index 00000000000..0525a1bd297
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-fast.sc
@@ -0,0 +1,201 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR-lv2-lq Shader
+
+ Copyright (C) 2011/2015 Hyllian/Jararaca - sergiogdb@gmail.com
+
+ 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.
+
+ Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
+*/
+
+#include "common.sh"
+
+uniform vec4 XBR_SCALE;
+uniform vec4 XBR_Y_WEIGHT;
+uniform vec4 XBR_EQ_THRESHOLD;
+uniform vec4 XBR_LV2_COEFFICIENT;
+
+uniform vec4 u_tex_size0;
+
+SAMPLER2D(decal, 0);
+
+// Uncomment just one of the three params below to choose the corner detection
+//#define CORNER_A
+#define CORNER_C
+
+#ifdef CORNER_C
+ #define SMOOTH_TIPS
+#endif
+
+const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25);
+
+const vec4 Y = vec4(0.2126, 0.7152, 0.0722, 0.0);
+
+vec4 df(vec4 A, vec4 B)
+{
+ return abs(A - B);
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 eq(vec4 A, vec4 B)
+{
+ return vec4(equal(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 abslt(vec4 A, vec4 B)
+{
+ return lt(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+}
+
+vec4 absge(vec4 A, vec4 B)
+{
+ return ge(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+}
+
+vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
+{
+ return (df(c,d) + df(e,f) + 3.0*df(g,h));
+// return (1.0*df(a,b) + 2.0*df(c,d) + 2.0*df(e,f) + 4.0*df(g,h));
+}
+
+void main()
+{
+ vec4 delta = 1.0 / XBR_SCALE.xxxx;
+ vec4 deltaL = vec4(0.5, 1.0, 0.5, 1.0) / XBR_SCALE.xxxx;
+ vec4 deltaU = deltaL.yxwz;
+
+ vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
+
+ vec4 A = texture2D(decal, v_texcoord1.xw);
+ vec4 B = texture2D(decal, v_texcoord1.yw);
+ vec4 C = texture2D(decal, v_texcoord1.zw);
+
+ vec4 D = texture2D(decal, v_texcoord2.xw);
+ vec4 E = texture2D(decal, v_texcoord2.yw);
+ vec4 F = texture2D(decal, v_texcoord2.zw);
+
+ vec4 G = texture2D(decal, v_texcoord3.xw);
+ vec4 H = texture2D(decal, v_texcoord3.yw);
+ vec4 I = texture2D(decal, v_texcoord3.zw);
+
+ vec4 b = mul(mat4(B, D, H, F), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 c = mul(mat4(C, A, G, I), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 e = mul(mat4(E, E, E, E), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 a = c.yzwx;
+ vec4 d = b.yzwx;
+ vec4 f = b.wxyz;
+ vec4 g = c.zwxy;
+ vec4 h = b.zwxy;
+ vec4 i = c.wxyz;
+
+ // These inequations define the line below which interpolation occurs.
+ vec4 fx = (Ao*fp.y+Bo*fp.x);
+ vec4 fx_left = (Ax*fp.y+Bx*fp.x);
+ vec4 fx_up = (Ay*fp.y+By*fp.x);
+
+ vec4 interp_restriction_lv0 = (ne(e,f) * ne(e,h));
+ vec4 interp_restriction_lv1 = interp_restriction_lv0;
+
+#ifndef CORNER_A
+ interp_restriction_lv1 = clamp(interp_restriction_lv0 * (ge(f,b) * ge(f,c) + ge(h,d) * ge(h,g) + lt(e,g) + lt(e,c)), 0.0, 1.0);
+#endif
+
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 fx45i = saturate((fx + delta -Co - Ci) / (2.0 * delta ));
+ vec4 fx45 = saturate((fx + delta -Co ) / (2.0 * delta ));
+ vec4 fx30 = saturate((fx_left + deltaL -Cx ) / (2.0 * deltaL));
+ vec4 fx60 = saturate((fx_up + deltaU -Cy ) / (2.0 * deltaU));
+
+ vec4 wd1 = weighted_distance( d, b, g, e, e, c, h, f);
+ vec4 wd2 = weighted_distance( a, e, b, f, d, h, e, i);
+
+ vec4 edri = le(wd1, wd2) * interp_restriction_lv0;
+ vec4 edr = lt(wd1, wd2) * interp_restriction_lv1;
+ vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr;
+
+ fx45 = edr * fx45;
+ fx30 = edr_left * fx30;
+ fx60 = edr_up * fx60;
+ fx45i = edri * fx45i;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+#ifdef SMOOTH_TIPS
+ vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
+#else
+ vec4 maximos = max(max(fx30, fx60), fx45);
+#endif
+
+ vec3 res1 = E.xyz;
+ res1 = mix(res1, mix(H.xyz, F.xyz, px.x), maximos.x);
+ res1 = mix(res1, mix(B.xyz, D.xyz, px.z), maximos.z);
+
+ vec3 res2 = E.xyz;
+ res2 = mix(res2, mix(F.xyz, B.xyz, px.y), maximos.y);
+ res2 = mix(res2, mix(D.xyz, H.xyz, px.w), maximos.w);
+
+ vec3 E_mix = (c_df(E.xyz, res2) >= c_df(E.xyz, res1)) ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 res = mix(res1, res2, E_mix);
+
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc
new file mode 100644
index 00000000000..421cf1efb9d
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc
@@ -0,0 +1,229 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR-lv2 Shader
+
+ 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.
+
+ Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
+*/
+
+#include "common.sh"
+
+uniform vec4 XBR_SCALE;
+uniform vec4 XBR_Y_WEIGHT;
+uniform vec4 XBR_EQ_THRESHOLD;
+uniform vec4 XBR_LV2_COEFFICIENT;
+
+uniform vec4 u_tex_size0;
+
+SAMPLER2D(decal, 0);
+
+// 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
+
+const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25);
+
+const vec4 Y = vec4(0.2126, 0.7152, 0.0722, 0.0);
+
+vec4 df(vec4 A, vec4 B)
+{
+ return abs(A - B);
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 eq(vec4 A, vec4 B)
+{
+ return vec4(equal(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 abslt(vec4 A, vec4 B)
+{
+ return lt(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+}
+
+vec4 absge(vec4 A, vec4 B)
+{
+ return ge(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+}
+
+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));
+}
+
+void main()
+{
+ vec4 delta = 1.0 / XBR_SCALE.xxxx;
+ vec4 deltaL = vec4(0.5, 1.0, 0.5, 1.0) / XBR_SCALE.xxxx;
+ vec4 deltaU = deltaL.yxwz;
+
+ vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
+
+ vec4 A1 = texture2D(decal, v_texcoord1.xw);
+ vec4 B1 = texture2D(decal, v_texcoord1.yw);
+ vec4 C1 = texture2D(decal, v_texcoord1.zw);
+
+ vec4 A = texture2D(decal, v_texcoord2.xw);
+ vec4 B = texture2D(decal, v_texcoord2.yw);
+ vec4 C = texture2D(decal, v_texcoord2.zw);
+
+ vec4 D = texture2D(decal, v_texcoord3.xw);
+ vec4 E = texture2D(decal, v_texcoord3.yw);
+ vec4 F = texture2D(decal, v_texcoord3.zw);
+
+ vec4 G = texture2D(decal, v_texcoord4.xw);
+ vec4 H = texture2D(decal, v_texcoord4.yw);
+ vec4 I = texture2D(decal, v_texcoord4.zw);
+
+ vec4 G5 = texture2D(decal, v_texcoord5.xw);
+ vec4 H5 = texture2D(decal, v_texcoord5.yw);
+ vec4 I5 = texture2D(decal, v_texcoord5.zw);
+
+ vec4 A0 = texture2D(decal, v_texcoord6.xy);
+ vec4 D0 = texture2D(decal, v_texcoord6.xz);
+ vec4 G0 = texture2D(decal, v_texcoord6.xw);
+
+ vec4 C4 = texture2D(decal, v_texcoord7.xy);
+ vec4 F4 = texture2D(decal, v_texcoord7.xz);
+ vec4 I4 = texture2D(decal, v_texcoord7.xw);
+
+ vec4 b = mul(mat4(B, D, H, F), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 c = mul(mat4(C, A, G, I), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 e = mul(mat4(E, E, E, E), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 d = b.yzwx;
+ vec4 f = b.wxyz;
+ vec4 g = c.zwxy;
+ vec4 h = b.zwxy;
+ vec4 i = c.wxyz;
+
+ vec4 i4 = mul(mat4(I4, C1, A0, G5), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 f4 = h5.yzwx;
+
+ // These inequations define the line below which interpolation occurs.
+ vec4 fx = (Ao*fp.y+Bo*fp.x);
+ vec4 fx_left = (Ax*fp.y+Bx*fp.x);
+ vec4 fx_up = (Ay*fp.y+By*fp.x);
+
+ vec4 interp_restriction_lv0 = (ne(e,f) * ne(e,h));
+ vec4 interp_restriction_lv1 = interp_restriction_lv0;
+
+#ifdef CORNER_B
+ interp_restriction_lv1 = (interp_restriction_lv0 * ( ge(f,b) * ge(h,d) + lt(e,i) * ge(f,i4) * ge(h,i5) + lt(e,g) + lt(e,c) ) );
+#endif
+#ifdef CORNER_D
+ vec4 c1 = i4.yzwx;
+ vec4 g0 = i5.wxyz;
+ interp_restriction_lv1 = (interp_restriction_lv0 * ( ge(f,b) * ge(h,d) + lt(e,i) * ge(f,i4) * ge(h,i5) + lt(e,g) + lt(e,c) ) * (ne(f,f4) * ne(f,i) + ne(h,h5) * ne(h,i) + ne(h,g) + ne(f,c) + lt(b,c1) * lt(d,g0)));
+#endif
+#ifdef CORNER_C
+ interp_restriction_lv1 = (interp_restriction_lv0 * ( ge(f,b) * ge(f,c) + ge(h,d) * ge(h,g) + lt(e,i) * (ge(f,f4) * ge(f,i4) + ge(h,h5) * ge(h,i5)) + lt(e,g) + lt(e,c)) );
+#endif
+
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 fx45i = saturate((fx + delta -Co - Ci) / (2.0 * delta ));
+ vec4 fx45 = saturate((fx + delta -Co ) / (2.0 * delta ));
+ vec4 fx30 = saturate((fx_left + deltaL -Cx ) / (2.0 * deltaL));
+ vec4 fx60 = saturate((fx_up + deltaU -Cy ) / (2.0 * deltaU));
+
+ vec4 wd1 = weighted_distance( e, c, g, i, h5, f4, h, f);
+ vec4 wd2 = weighted_distance( h, d, i5, f, i4, b, e, i);
+
+ vec4 one = vec4(1.0, 1.0, 1.0, 1.0);
+ vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
+ vec4 edri = le(wd1,wd2) * interp_restriction_lv0;
+ vec4 edr = lt(wd1,wd2) * interp_restriction_lv1;
+#ifdef CORNER_A
+ edr = clamp(edr * ((one - edri.yzwx) + (one - edri.wxyz)), 0.0, 1.0);
+ vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr * (one - edri.yzwx) * eq(e,c);
+ vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr * (one - edri.wxyz) * eq(e,g);
+#endif
+#ifndef CORNER_A
+ vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr;
+#endif
+
+ fx45 = edr * fx45;
+ fx30 = edr_left * fx30;
+ fx60 = edr_up * fx60;
+ fx45i = edri * fx45i;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
+
+ vec3 res1 = E.xyz;
+ res1 = mix(res1, mix(H.xyz, F.xyz, px.x), maximos.x);
+ res1 = mix(res1, mix(B.xyz, D.xyz, px.z), maximos.z);
+
+ vec3 res2 = E.xyz;
+ res2 = mix(res2, mix(F.xyz, B.xyz, px.y), maximos.y);
+ res2 = mix(res2, mix(D.xyz, H.xyz, px.w), maximos.w);
+
+ vec3 E_mix = (c_df(E.xyz, res2) >= c_df(E.xyz, res1)) ? one.xyz : zero.xyz;
+ vec3 res = mix(res1, res2, E_mix);
+
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_custom-jinc2-sharper.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_custom-jinc2-sharper.sc
new file mode 100644
index 00000000000..0abd7ff41c9
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_custom-jinc2-sharper.sc
@@ -0,0 +1,134 @@
+$input v_texcoord0, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's jinc windowed-jinc 2-lobe sharper with anti-ringing Shader
+
+ Copyright (C) 2011-2014 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+#include "common.sh"
+
+uniform vec4 JINC2_WINDOW_SINC;
+uniform vec4 JINC2_SINC;
+uniform vec4 JINC2_AR_STRENGTH;
+uniform vec4 u_tex_size0;
+
+SAMPLER2D(s_p, 0);
+
+ /*
+ 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.x * pi)
+#define wb (JINC2_SINC.x * pi)
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+// Calculates the distance between two points
+float d(vec2 pt1, vec2 pt2)
+{
+ vec2 v = pt2 - pt1;
+ return sqrt(dot(v,v));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+vec4 resampler(vec4 x)
+{
+ float wawb = wa*wb;
+ vec4 wawb4 = vec4(wawb, wawb, wawb, wawb);
+ return (x == vec4(0.0, 0.0, 0.0, 0.0)) ? wawb4 : sin(x*wa) * sin(x*wb) / (x*x);
+}
+
+void main()
+{
+ vec3 color;
+ mat4 weights;
+
+ vec2 dx = vec2(1.0, 0.0);
+ vec2 dy = vec2(0.0, 1.0);
+
+ vec2 pc = v_texcoord0 * u_tex_size0.xy;
+
+ vec2 tc = (floor(pc - vec2(0.5,0.5)) + vec2(0.5,0.5));
+
+ weights[0] = resampler(vec4(d(pc, tc -dx -dy), d(pc, tc -dy), d(pc, tc +dx -dy), d(pc, tc+2.0*dx -dy)));
+ weights[1] = resampler(vec4(d(pc, tc -dx ), d(pc, tc ), d(pc, tc +dx ), d(pc, tc+2.0*dx )));
+ weights[2] = resampler(vec4(d(pc, tc -dx +dy), d(pc, tc +dy), d(pc, tc +dx +dy), d(pc, tc+2.0*dx +dy)));
+ weights[3] = 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 / u_tex_size0.xy;
+ dy = dy / u_tex_size0.xy;
+ tc = tc / u_tex_size0.xy;
+
+ // reading the texels
+
+ vec4 c00 = texture2D(s_p, tc -dx -dy);
+ vec4 c10 = texture2D(s_p, tc -dy);
+ vec4 c20 = texture2D(s_p, tc +dx -dy);
+ vec4 c30 = texture2D(s_p, tc+2.0*dx -dy);
+ vec4 c01 = texture2D(s_p, tc -dx );
+ vec4 c11 = texture2D(s_p, tc );
+ vec4 c21 = texture2D(s_p, tc +dx );
+ vec4 c31 = texture2D(s_p, tc+2.0*dx );
+ vec4 c02 = texture2D(s_p, tc -dx +dy);
+ vec4 c12 = texture2D(s_p, tc +dy);
+ vec4 c22 = texture2D(s_p, tc +dx +dy);
+ vec4 c32 = texture2D(s_p, tc+2.0*dx +dy);
+ vec4 c03 = texture2D(s_p, tc -dx+2.0*dy);
+ vec4 c13 = texture2D(s_p, tc +2.0*dy);
+ vec4 c23 = texture2D(s_p, tc +dx+2.0*dy);
+ vec4 c33 = texture2D(s_p, tc+2.0*dx+2.0*dy);
+
+ color = mul(weights[0], mat4(c00, c10, c20, c30)).xyz;
+ color+= mul(weights[1], mat4(c01, c11, c21, c31)).xyz;
+ color+= mul(weights[2], mat4(c02, c12, c22, c32)).xyz;
+ color+= mul(weights[3], mat4(c03, c13, c23, c33)).xyz;
+ color = color / (dot(mul(weights, vec4(1.0, 1.0, 1.0, 1.0)), vec4(1.0, 1.0, 1.0, 1.0)));
+
+ // Anti-ringing
+ // Get min/max samples
+ pc = v_texcoord0;
+ c00 = texture2D(s_p, pc );
+ c11 = texture2D(s_p, pc +dx );
+ c21 = texture2D(s_p, pc -dx );
+ c12 = texture2D(s_p, pc +dy);
+ c22 = texture2D(s_p, pc -dy);
+
+ vec4 min_sample = min4(c11, c21, c12, c22);
+ vec4 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.xyz, max_sample.xyz);
+ color = mix(aux, color, JINC2_AR_STRENGTH.xxx);
+
+ // final sum and weight normalization
+ gl_FragColor = vec4(color, 1);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass0.sc
new file mode 100644
index 00000000000..8fa47570af5
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass0.sc
@@ -0,0 +1,227 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR 3D Shader - pass0 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#define XBR_RES 2.0
+
+#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.x * 1.29633 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.75068 / 10.0 / 2.0)
+
+vec4 reduce4(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return mul(mat4(A, B, C, D), vec4(65536.0, 255.0, 1.0, 0.0));
+}
+
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < 15.0);
+}
+
+
+/*
+ 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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ //Skip pixels on wrong grid
+ vec2 fraction = fract(v_texcoord0 * u_tex_size0.xy / XBR_RES);
+ if (fraction.x < 0.5 || fraction.y < 0.5)
+ {
+ gl_FragColor = texture2D(s0, v_texcoord0);
+ return;
+ }
+
+ vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES) + vec2(0.5, 0.5)) * XBR_RES / u_tex_size0.xy;
+
+ vec2 g1 = vec2(XBR_RES / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, XBR_RES / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord0 -g1 -g2);
+ vec4 P1 = texture2D(s0, v_texcoord0 +2.0*g1 -g2);
+ vec4 P2 = texture2D(s0, v_texcoord0 -g1+2.0*g2);
+ vec4 P3 = texture2D(s0, v_texcoord0 +2.0*g1+2.0*g2);
+
+ vec4 B = texture2D(s0, v_texcoord0 -g2);
+ vec4 C = texture2D(s0, v_texcoord0 +g1-g2);
+ vec4 D = texture2D(s0, v_texcoord0 -g1 );
+ vec4 E = texture2D(s0, v_texcoord0 );
+ vec4 F = texture2D(s0, v_texcoord0 +g1 );
+ vec4 G = texture2D(s0, v_texcoord0 -g1+g2);
+ vec4 H = texture2D(s0, v_texcoord0 +g2);
+ vec4 I = texture2D(s0, v_texcoord0 +g1+g2);
+
+ vec4 F4 = texture2D(s0, v_texcoord0 +2.0*g1 );
+ vec4 I4 = texture2D(s0, v_texcoord0 +g2+2.0*g1 );
+ vec4 H5 = texture2D(s0, v_texcoord0 +2.0*g2 );
+ vec4 I5 = texture2D(s0, v_texcoord0 +2.0*g2+g1 );
+
+ vec4 F6 = texture2D(s0, tex + g1 + 0.25 * g1 + 0.25 * g2);
+ vec4 F7 = texture2D(s0, tex + g1 + 0.25 * g1 - 0.25 * g2);
+ vec4 F8 = texture2D(s0, tex + g1 - 0.25 * g1 - 0.25 * g2);
+ vec4 F9 = texture2D(s0, tex + g1 - 0.25 * g1 + 0.25 * g2);
+
+ vec4 H6 = texture2D(s0, tex + 0.25 * g1 + 0.25 * g2 + g2);
+ vec4 H7 = texture2D(s0, tex + 0.25 * g1 - 0.25 * g2 + g2);
+ vec4 H8 = texture2D(s0, tex - 0.25 * g1 - 0.25 * g2 + g2);
+ vec4 H9 = texture2D(s0, tex - 0.25 * g1 + 0.25 * g2 + g2);
+
+ vec4 f0 = reduce4(F6, F7, F8, F9);
+ vec4 h0 = reduce4(H6, H7, H8, H9);
+
+ bool block_3d = (f0.x == f0.y && f0.y == f0.z && f0.z == f0.w && h0.x == h0.y && h0.y == h0.z && h0.z == h0.w);
+
+ 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 );
+
+/*
+ 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
+*/
+
+
+ /* 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.x + 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 = mul(w1, mat4( P2, H, F, P1)).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3)).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+/*
+ 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
+*/
+
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4( E, F, H, I ) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4( E, F, H, I ) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ color = block_3d ? color : E.xyz;
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass1.sc
new file mode 100644
index 00000000000..72009ad3335
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass1.sc
@@ -0,0 +1,211 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR 3D Shader - pass0 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#define XBR_RES 2.0
+
+#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.x * 1.75068 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.29633 / 10.0 / 2.0)
+
+vec4 reduce4(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return mul(mat4(A, B, C, D), vec4(65536.0, 255.0, 1.0, 0.0));
+}
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color, vec4(0.2126, 0.7152, 0.0722, 0.0));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < 15.0);
+}
+
+
+/*
+ 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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ // Skip pixels on wrong grid
+ vec2 dir = fract(v_texcoord0 * u_tex_size0.xy / XBR_RES) - vec2(0.5, 0.5);
+ if ((dir.x * dir.y) > 0.0)
+ {
+ gl_FragColor = texture2D(s0, v_texcoord0);
+ return;
+ }
+
+ vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES) + vec2(0.5, 0.5)) * XBR_RES / u_tex_size0.xy;
+
+ vec2 g1 = vec2((XBR_RES / 2.0) / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, (XBR_RES / 2.0) / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord0 -3.0*g1 );
+ vec4 P1 = texture2D(s0, v_texcoord0 -3.0*g2);
+ vec4 P2 = texture2D(s0, v_texcoord0 +3.0*g2);
+ vec4 P3 = texture2D(s0, v_texcoord0 +3.0*g1 );
+
+ vec4 B = texture2D(s0, v_texcoord0 -2.0*g1 -g2);
+ vec4 C = texture2D(s0, v_texcoord0 -g1 -2.0*g2);
+ vec4 D = texture2D(s0, v_texcoord0 -2.0*g1 +g2);
+ vec4 E = texture2D(s0, v_texcoord0 -g1 );
+ vec4 F = texture2D(s0, v_texcoord0 -g2);
+ vec4 G = texture2D(s0, v_texcoord0 -g1 +2.0*g2);
+ vec4 H = texture2D(s0, v_texcoord0 +g2);
+ vec4 I = texture2D(s0, v_texcoord0 +g1 );
+
+ vec4 F4 = texture2D(s0,v_texcoord0 +g1 -2.0*g2);
+ vec4 I4 = texture2D(s0,v_texcoord0 +2.0*g1 -g2);
+ vec4 H5 = texture2D(s0,v_texcoord0 +g1 +2.0*g2);
+ vec4 I5 = texture2D(s0,v_texcoord0 +2.0*g1 +g2);
+
+ vec3 A = texture2D(s0, v_texcoord0).xyz;
+
+ g1 *= 2.0;
+ g2 *= 2.0;
+
+ vec4 F6 = texture2D(ORIG_texture, tex +g1+0.25*g1+0.25*g2);
+ vec4 F7 = texture2D(ORIG_texture, tex +g1+0.25*g1-0.25*g2);
+ vec4 F8 = texture2D(ORIG_texture, tex +g1-0.25*g1-0.25*g2);
+ vec4 F9 = texture2D(ORIG_texture, tex +g1-0.25*g1+0.25*g2);
+
+ vec4 H6 = texture2D(ORIG_texture, tex +0.25*g1+0.25*g2+g2);
+ vec4 H7 = texture2D(ORIG_texture, tex +0.25*g1-0.25*g2+g2);
+ vec4 H8 = texture2D(ORIG_texture, tex -0.25*g1-0.25*g2+g2);
+ vec4 H9 = texture2D(ORIG_texture, tex -0.25*g1+0.25*g2+g2);
+
+ vec4 f0 = reduce4(F6, F7, F8, F9);
+ vec4 h0 = reduce4(H6, H7, H8, H9);
+
+ bool block_3d = (f0.x == f0.y && f0.y == f0.z && f0.z == f0.w && h0.x == h0.y && h0.y == h0.z && h0.z == h0.w);
+
+ 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.x + 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 = mul(w1, mat4( P2, H, F, P1)).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3)).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4( E, F, H, I ) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4( E, F, H, I ) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ color = block_3d ? color : A;
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass2.sc
new file mode 100644
index 00000000000..c2656424ed6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-2xbr-3d-pass2.sc
@@ -0,0 +1,213 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR 3D Shader - pass2 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#define XBR_RES 2.0
+
+#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.x * 1.29633 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.75068 / 10.0 / 2.0)
+
+vec4 reduce4(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return mul(mat4(A, B, C, D), vec4(65536.0, 255.0, 1.0, 0.0));
+}
+
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color, vec4(0.2126, 0.7152, 0.0722, 0.0));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < 15.0);
+}
+
+
+/*
+ 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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES) + vec2(0.5, 0.5)) * XBR_RES / u_tex_size0.xy;
+
+ vec2 g1 = vec2(XBR_RES / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, XBR_RES / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord1.xy);
+ vec4 P1 = texture2D(s0, v_texcoord1.zy);
+ vec4 P2 = texture2D(s0, v_texcoord1.xw);
+ vec4 P3 = texture2D(s0, v_texcoord1.zw);
+
+ vec4 B = texture2D(s0, v_texcoord2.xy);
+ vec4 C = texture2D(s0, v_texcoord2.zy);
+ vec4 H5 = texture2D(s0, v_texcoord2.xw);
+ vec4 I5 = texture2D(s0, v_texcoord2.zw);
+
+ vec4 D = texture2D(s0, v_texcoord3.xy);
+ vec4 F4 = texture2D(s0, v_texcoord3.zy);
+ vec4 G = texture2D(s0, v_texcoord3.xw);
+ vec4 I4 = texture2D(s0, v_texcoord3.zw);
+
+ vec4 E = texture2D(s0, v_texcoord4.xy);
+ vec4 F = texture2D(s0, v_texcoord4.zy);
+ vec4 H = texture2D(s0, v_texcoord4.xw);
+ vec4 I = texture2D(s0, v_texcoord4.zw);
+
+ vec4 A = texture2D(s0, v_texcoord0);
+
+ vec4 F6 = texture2D(ORIG_texture, tex +g1+0.25*g1+0.25*g2);
+ vec4 F7 = texture2D(ORIG_texture, tex +g1+0.25*g1-0.25*g2);
+ vec4 F8 = texture2D(ORIG_texture, tex +g1-0.25*g1-0.25*g2);
+ vec4 F9 = texture2D(ORIG_texture, tex +g1-0.25*g1+0.25*g2);
+
+ vec4 H6 = texture2D(ORIG_texture, tex +0.25*g1+0.25*g2+g2);
+ vec4 H7 = texture2D(ORIG_texture, tex +0.25*g1-0.25*g2+g2);
+ vec4 H8 = texture2D(ORIG_texture, tex -0.25*g1-0.25*g2+g2);
+ vec4 H9 = texture2D(ORIG_texture, tex -0.25*g1+0.25*g2+g2);
+
+ vec4 f0 = reduce4(F6, F7, F8, F9);
+ vec4 h0 = reduce4(H6, H7, H8, H9);
+
+ bool block_3d = (f0.x == f0.y && f0.y == f0.z && f0.z == f0.w && h0.x == h0.y && h0.y == h0.z && h0.z == h0.w);
+
+ 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 );
+
+/*
+ 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
+*/
+
+
+ /* 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.x + 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 = mul(w1, mat4( P2, H, F, P1)).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3)).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4( E, F, H, I ) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4( E, F, H, I ) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ color = block_3d ? color : A.xyz;
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass0.sc
new file mode 100644
index 00000000000..8a56a3899a6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass0.sc
@@ -0,0 +1,217 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super 4XBR 3D Shader - pass0 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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 XBR_RES 4.0
+
+#define weight1 (XBR_WEIGHT.x * 1.29633 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.75068 / 10.0 / 2.0)
+
+vec4 reduce4(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return mul(mat4(A, B, C, D), vec4(65536.0, 255.0, 1.0, 0.0));
+}
+
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < 15.0);
+}
+
+
+/*
+ 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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ //Skip pixels on wrong grid
+ vec2 fraction = fract(v_texcoord0 * u_tex_size0.xy / XBR_RES);
+ if (fraction.x < 0.5 || fraction.y < 0.5)
+ {
+ gl_FragColor = texture2D(s0, v_texcoord0);
+ return;
+ }
+
+ vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES) + vec2(0.5, 0.5)) * XBR_RES / u_tex_size0.xy;
+
+ vec2 g1 = vec2(XBR_RES / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, XBR_RES / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord0 -g1 -g2);
+ vec4 P1 = texture2D(s0, v_texcoord0 +2.0*g1 -g2);
+ vec4 P2 = texture2D(s0, v_texcoord0 -g1+2.0*g2);
+ vec4 P3 = texture2D(s0, v_texcoord0 +2.0*g1+2.0*g2);
+
+ vec4 B = texture2D(s0, v_texcoord0 -g2);
+ vec4 C = texture2D(s0, v_texcoord0 +g1-g2);
+ vec4 D = texture2D(s0, v_texcoord0 -g1 );
+ vec4 E = texture2D(s0, v_texcoord0 );
+ vec4 F = texture2D(s0, v_texcoord0 +g1 );
+ vec4 G = texture2D(s0, v_texcoord0 -g1+g2);
+ vec4 H = texture2D(s0, v_texcoord0 +g2);
+ vec4 I = texture2D(s0, v_texcoord0 +g1+g2);
+
+ vec4 F4 = texture2D(s0,v_texcoord0 +2.0*g1 );
+ vec4 I4 = texture2D(s0,v_texcoord0 +g2+2.0*g1 );
+ vec4 H5 = texture2D(s0,v_texcoord0 +2.0*g2 );
+ vec4 I5 = texture2D(s0,v_texcoord0 +2.0*g2+g1 );
+
+ vec4 F6 = texture2D(s0, tex +g1+0.25*g1+0.25*g2);
+ vec4 F7 = texture2D(s0, tex +g1+0.25*g1-0.25*g2);
+ vec4 F8 = texture2D(s0, tex +g1-0.25*g1-0.25*g2);
+ vec4 F9 = texture2D(s0, tex +g1-0.25*g1+0.25*g2);
+
+ vec4 H6 = texture2D(s0, tex +0.25*g1+0.25*g2+g2);
+ vec4 H7 = texture2D(s0, tex +0.25*g1-0.25*g2+g2);
+ vec4 H8 = texture2D(s0, tex -0.25*g1-0.25*g2+g2);
+ vec4 H9 = texture2D(s0, tex -0.25*g1+0.25*g2+g2);
+
+ vec4 f0 = reduce4(F6, F7, F8, F9);
+ vec4 h0 = reduce4(H6, H7, H8, H9);
+
+ bool block_3d = (f0.x == f0.y && f0.y == f0.z && f0.z == f0.w && h0.x == h0.y && h0.y == h0.z && h0.z == h0.w);
+
+ 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 );
+
+/*
+ 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
+*/
+
+
+ /* 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.x + 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 = mul(w1, mat4( P2, H, F, P1 )).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3 )).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ color = block_3d ? color : E.xyz;
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass1.sc
new file mode 100644
index 00000000000..10288b45f5a
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass1.sc
@@ -0,0 +1,210 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super 4XBR 3D Shader - pass1 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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 XBR_RES 4.0
+
+#define weight1 (XBR_WEIGHT.x * 1.75068 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.29633 / 10.0 / 2.0)
+
+vec4 reduce4(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return mul(mat4(A, B, C, D), vec4(65536.0, 255.0, 1.0, 0.0));
+}
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < 15.0);
+}
+
+
+/*
+ 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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ //Skip pixels on wrong grid
+ vec2 dir = fract(v_texcoord0 * u_tex_size0.xy / XBR_RES) - vec2(0.5, 0.5);
+ if ((dir.x * dir.y) > 0.0)
+ {
+ gl_FragColor = texture2D(s0, v_texcoord0);
+ return;
+ }
+
+ vec2 tex = (floor(v_texcoord0*u_tex_size0.xy / XBR_RES) + vec2(0.5, 0.5)) * XBR_RES / u_tex_size0.xy;
+
+ vec2 g1 = vec2((XBR_RES/2.0)/u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, (XBR_RES/2.0)/u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord0 -3.0*g1 );
+ vec4 P1 = texture2D(s0, v_texcoord0 -3.0*g2);
+ vec4 P2 = texture2D(s0, v_texcoord0 +3.0*g2);
+ vec4 P3 = texture2D(s0, v_texcoord0 +3.0*g1 );
+
+ vec4 B = texture2D(s0, v_texcoord0 -2.0*g1 -g2);
+ vec4 C = texture2D(s0, v_texcoord0 -g1 -2.0*g2);
+ vec4 D = texture2D(s0, v_texcoord0 -2.0*g1 +g2);
+ vec4 E = texture2D(s0, v_texcoord0 -g1 );
+ vec4 F = texture2D(s0, v_texcoord0 -g2);
+ vec4 G = texture2D(s0, v_texcoord0 -g1 +2.0*g2);
+ vec4 H = texture2D(s0, v_texcoord0 +g2);
+ vec4 I = texture2D(s0, v_texcoord0 +g1 );
+
+ vec4 F4 = texture2D(s0,v_texcoord0 +g1 -2.0*g2);
+ vec4 I4 = texture2D(s0,v_texcoord0 +2.0*g1 -g2);
+ vec4 H5 = texture2D(s0,v_texcoord0 +g1 +2.0*g2);
+ vec4 I5 = texture2D(s0,v_texcoord0 +2.0*g1 +g2);
+
+ vec4 A = texture2D(s0, v_texcoord0);
+
+ g1 *= 2.0;
+ g2 *= 2.0;
+
+ vec4 F6 = texture2D(ORIG_texture, tex +g1+0.25*g1+0.25*g2);
+ vec4 F7 = texture2D(ORIG_texture, tex +g1+0.25*g1-0.25*g2);
+ vec4 F8 = texture2D(ORIG_texture, tex +g1-0.25*g1-0.25*g2);
+ vec4 F9 = texture2D(ORIG_texture, tex +g1-0.25*g1+0.25*g2);
+
+ vec4 H6 = texture2D(ORIG_texture, tex +0.25*g1+0.25*g2+g2);
+ vec4 H7 = texture2D(ORIG_texture, tex +0.25*g1-0.25*g2+g2);
+ vec4 H8 = texture2D(ORIG_texture, tex -0.25*g1-0.25*g2+g2);
+ vec4 H9 = texture2D(ORIG_texture, tex -0.25*g1+0.25*g2+g2);
+
+ vec4 f0 = reduce4(F6, F7, F8, F9);
+ vec4 h0 = reduce4(H6, H7, H8, H9);
+
+ bool block_3d = (f0.x == f0.y && f0.y == f0.z && f0.z == f0.w && h0.x == h0.y && h0.y == h0.z && h0.z == h0.w);
+
+ 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.x + 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 = mul(w1, mat4( P2, H, F, P1 )).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3 )).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ color = block_3d ? color : A.xyz;
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass1f.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass1f.sc
new file mode 100644
index 00000000000..51f2c6ea887
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass1f.sc
@@ -0,0 +1,211 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super 4XBR 3D Shader - pass1 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#define XBR_RES 4.0
+
+#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.x * 1.29633 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.75068 / 10.0 / 2.0)
+
+vec4 reduce4(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return mul(mat4(A, B, C, D), vec4(65536.0, 255.0, 1.0, 0.0));
+}
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < 15.0);
+}
+
+
+/*
+ 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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES) + vec2(0.5, 0.5)) * XBR_RES / u_tex_size0.xy;
+
+ vec2 g1 = vec2(XBR_RES / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, XBR_RES / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord1.xy);
+ vec4 P1 = texture2D(s0, v_texcoord1.zy);
+ vec4 P2 = texture2D(s0, v_texcoord1.xw);
+ vec4 P3 = texture2D(s0, v_texcoord1.zw);
+
+ vec4 B = texture2D(s0, v_texcoord2.xy);
+ vec4 C = texture2D(s0, v_texcoord2.zy);
+ vec4 H5 = texture2D(s0, v_texcoord2.xw);
+ vec4 I5 = texture2D(s0, v_texcoord2.zw);
+
+ vec4 D = texture2D(s0, v_texcoord3.xy);
+ vec4 F4 = texture2D(s0, v_texcoord3.zy);
+ vec4 G = texture2D(s0, v_texcoord3.xw);
+ vec4 I4 = texture2D(s0, v_texcoord3.zw);
+
+ vec4 E = texture2D(s0, v_texcoord4.xy);
+ vec4 F = texture2D(s0, v_texcoord4.zy);
+ vec4 H = texture2D(s0, v_texcoord4.xw);
+ vec4 I = texture2D(s0, v_texcoord4.zw);
+
+ vec4 A = texture2D(s0, v_texcoord0);
+
+ vec4 F6 = texture2D(ORIG_texture, tex +g1+0.25*g1+0.25*g2);
+ vec4 F7 = texture2D(ORIG_texture, tex +g1+0.25*g1-0.25*g2);
+ vec4 F8 = texture2D(ORIG_texture, tex +g1-0.25*g1-0.25*g2);
+ vec4 F9 = texture2D(ORIG_texture, tex +g1-0.25*g1+0.25*g2);
+
+ vec4 H6 = texture2D(ORIG_texture, tex +0.25*g1+0.25*g2+g2);
+ vec4 H7 = texture2D(ORIG_texture, tex +0.25*g1-0.25*g2+g2);
+ vec4 H8 = texture2D(ORIG_texture, tex -0.25*g1-0.25*g2+g2);
+ vec4 H9 = texture2D(ORIG_texture, tex -0.25*g1+0.25*g2+g2);
+
+ vec4 f0 = reduce4(F6, F7, F8, F9);
+ vec4 h0 = reduce4(H6, H7, H8, H9);
+
+ bool block_3d = (f0.x == f0.y && f0.y == f0.z && f0.z == f0.w && h0.x == h0.y && h0.y == h0.z && h0.z == h0.w);
+
+ 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 );
+
+/*
+ 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
+*/
+
+
+ /* 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.x + 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 = mul(w1, mat4( P2, H, F, P1 )).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3 )).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ color = block_3d ? color : A.xyz;
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass2.sc
new file mode 100644
index 00000000000..f1566381325
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass2.sc
@@ -0,0 +1,226 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super 4XBR 3D Shader - pass2 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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 XBR_RES2 2.0
+
+#define weight1 (XBR_WEIGHT.x * 1.29633 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.75068 / 10.0 / 2.0)
+
+vec4 reduce4(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return mul(mat4(A, B, C, D), vec4(65536.0, 255.0, 1.0, 0.0));
+}
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < 15.0);
+}
+
+
+/*
+ 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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ //Skip pixels on wrong grid
+ vec2 fraction = fract(v_texcoord0 * u_tex_size0.xy / XBR_RES2);
+ if (fraction.x < 0.5 || fraction.y < 0.5)
+ {
+ gl_FragColor = texture2D(s0, v_texcoord0);
+ return;
+ }
+
+ vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES2) + vec2(0.5, 0.5)) * XBR_RES2 / u_tex_size0.xy;
+
+ vec2 g1 = vec2(XBR_RES2 / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, XBR_RES2 / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord0 -g1 -g2);
+ vec4 P1 = texture2D(s0, v_texcoord0 +2.0*g1 -g2);
+ vec4 P2 = texture2D(s0, v_texcoord0 -g1+2.0*g2);
+ vec4 P3 = texture2D(s0, v_texcoord0 +2.0*g1+2.0*g2);
+
+ vec4 B = texture2D(s0, v_texcoord0 -g2);
+ vec4 C = texture2D(s0, v_texcoord0 +g1-g2);
+ vec4 D = texture2D(s0, v_texcoord0 -g1 );
+ vec4 E = texture2D(s0, v_texcoord0 );
+ vec4 F = texture2D(s0, v_texcoord0 +g1 );
+ vec4 G = texture2D(s0, v_texcoord0 -g1+g2);
+ vec4 H = texture2D(s0, v_texcoord0 +g2);
+ vec4 I = texture2D(s0, v_texcoord0 +g1+g2);
+
+ vec4 F4 = texture2D(s0,v_texcoord0 +2.0*g1 );
+ vec4 I4 = texture2D(s0,v_texcoord0 +g2+2.0*g1 );
+ vec4 H5 = texture2D(s0,v_texcoord0 +2.0*g2 );
+ vec4 I5 = texture2D(s0,v_texcoord0 +2.0*g2+g1 );
+
+ vec4 F6 = texture2D(s0, tex +g1+0.25*g1+0.25*g2);
+ vec4 F7 = texture2D(s0, tex +g1+0.25*g1-0.25*g2);
+ vec4 F8 = texture2D(s0, tex +g1-0.25*g1-0.25*g2);
+ vec4 F9 = texture2D(s0, tex +g1-0.25*g1+0.25*g2);
+
+ vec4 H6 = texture2D(s0, tex +0.25*g1+0.25*g2+g2);
+ vec4 H7 = texture2D(s0, tex +0.25*g1-0.25*g2+g2);
+ vec4 H8 = texture2D(s0, tex -0.25*g1-0.25*g2+g2);
+ vec4 H9 = texture2D(s0, tex -0.25*g1+0.25*g2+g2);
+
+ vec4 f0 = reduce4(F6, F7, F8, F9);
+ vec4 h0 = reduce4(H6, H7, H8, H9);
+
+ bool block_3d = (f0.x == f0.y && f0.y == f0.z && f0.z == f0.w && h0.x == h0.y && h0.y == h0.z && h0.z == h0.w);
+
+ 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 );
+
+/*
+ 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
+*/
+
+
+ /* 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.x + 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 = mul(w1, mat4( P2, H, F, P1 )).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3 )).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+/*
+ 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
+*/
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ color = block_3d ? color : E.xyz;
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass3.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass3.sc
new file mode 100644
index 00000000000..3aa921a0e37
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass3.sc
@@ -0,0 +1,210 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super 4XBR 3D Shader - pass3 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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 XBR_RES2 2.0
+
+#define weight1 (XBR_WEIGHT.x * 1.75068 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.29633 / 10.0 / 2.0)
+
+vec4 reduce4(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return mul(mat4(A, B, C, D), vec4(65536.0, 255.0, 1.0, 0.0));
+}
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < 15.0);
+}
+
+
+/*
+ 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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ //Skip pixels on wrong grid
+ vec2 dir = fract(v_texcoord0 * u_tex_size0.xy / XBR_RES2) - vec2(0.5, 0.5);
+ if ((dir.x * dir.y) > 0.0)
+ {
+ gl_FragColor = texture2D(s0, v_texcoord0);
+ return;
+ }
+
+ vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES2) + vec2(0.5, 0.5)) * XBR_RES2 / u_tex_size0.xy;
+
+ vec2 g1 = vec2((XBR_RES2 / 2.0) / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, (XBR_RES2 / 2.0) / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord0 -3.0*g1 );
+ vec4 P1 = texture2D(s0, v_texcoord0 -3.0*g2);
+ vec4 P2 = texture2D(s0, v_texcoord0 +3.0*g2);
+ vec4 P3 = texture2D(s0, v_texcoord0 +3.0*g1 );
+
+ vec4 B = texture2D(s0, v_texcoord0 -2.0*g1 -g2);
+ vec4 C = texture2D(s0, v_texcoord0 -g1 -2.0*g2);
+ vec4 D = texture2D(s0, v_texcoord0 -2.0*g1 +g2);
+ vec4 E = texture2D(s0, v_texcoord0 -g1 );
+ vec4 F = texture2D(s0, v_texcoord0 -g2);
+ vec4 G = texture2D(s0, v_texcoord0 -g1 +2.0*g2);
+ vec4 H = texture2D(s0, v_texcoord0 +g2);
+ vec4 I = texture2D(s0, v_texcoord0 +g1 );
+
+ vec4 F4 = texture2D(s0,v_texcoord0 +g1 -2.0*g2);
+ vec4 I4 = texture2D(s0,v_texcoord0 +2.0*g1 -g2);
+ vec4 H5 = texture2D(s0,v_texcoord0 +g1 +2.0*g2);
+ vec4 I5 = texture2D(s0,v_texcoord0 +2.0*g1 +g2);
+
+ vec4 A = texture2D(s0, v_texcoord0);
+
+ g1 *= 2.0;
+ g2 *= 2.0;
+
+ vec4 F6 = texture2D(ORIG_texture, tex +g1+0.25*g1+0.25*g2);
+ vec4 F7 = texture2D(ORIG_texture, tex +g1+0.25*g1-0.25*g2);
+ vec4 F8 = texture2D(ORIG_texture, tex +g1-0.25*g1-0.25*g2);
+ vec4 F9 = texture2D(ORIG_texture, tex +g1-0.25*g1+0.25*g2);
+
+ vec4 H6 = texture2D(ORIG_texture, tex +0.25*g1+0.25*g2+g2);
+ vec4 H7 = texture2D(ORIG_texture, tex +0.25*g1-0.25*g2+g2);
+ vec4 H8 = texture2D(ORIG_texture, tex -0.25*g1-0.25*g2+g2);
+ vec4 H9 = texture2D(ORIG_texture, tex -0.25*g1+0.25*g2+g2);
+
+ vec4 f0 = reduce4(F6, F7, F8, F9);
+ vec4 h0 = reduce4(H6, H7, H8, H9);
+
+ bool block_3d = (f0.x == f0.y && f0.y == f0.z && f0.z == f0.w && h0.x == h0.y && h0.y == h0.z && h0.z == h0.w);
+
+ 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.x + 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 = mul(w1, mat4( P2, H, F, P1 )).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3 )).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ color = block_3d ? color : A.xyz;
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass3f.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass3f.sc
new file mode 100644
index 00000000000..b417613a657
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-4xbr-3d-pass3f.sc
@@ -0,0 +1,211 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super 4XBR 3D Shader - pass3 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#define XBR_RES 2.0
+
+#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.x * 1.29633 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.75068 / 10.0 / 2.0)
+
+vec4 reduce4(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return mul(mat4(A, B, C, D), vec4(65536.0, 255.0, 1.0, 0.0));
+}
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+bool eq(float A, float B)
+{
+ return (df(A, B) < 15.0);
+}
+
+
+/*
+ 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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES) + vec2(0.5, 0.5)) * XBR_RES / u_tex_size0.xy;
+
+ vec2 g1 = vec2(XBR_RES / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, XBR_RES / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord1.xy);
+ vec4 P1 = texture2D(s0, v_texcoord1.zy);
+ vec4 P2 = texture2D(s0, v_texcoord1.xw);
+ vec4 P3 = texture2D(s0, v_texcoord1.zw);
+
+ vec4 B = texture2D(s0, v_texcoord2.xy);
+ vec4 C = texture2D(s0, v_texcoord2.zy);
+ vec4 H5 = texture2D(s0, v_texcoord2.xw);
+ vec4 I5 = texture2D(s0, v_texcoord2.zw);
+
+ vec4 D = texture2D(s0, v_texcoord3.xy);
+ vec4 F4 = texture2D(s0, v_texcoord3.zy);
+ vec4 G = texture2D(s0, v_texcoord3.xw);
+ vec4 I4 = texture2D(s0, v_texcoord3.zw);
+
+ vec4 E = texture2D(s0, v_texcoord4.xy);
+ vec4 F = texture2D(s0, v_texcoord4.zy);
+ vec4 H = texture2D(s0, v_texcoord4.xw);
+ vec4 I = texture2D(s0, v_texcoord4.zw);
+
+ vec4 A = texture2D(s0, v_texcoord0);
+
+ vec4 F6 = texture2D(ORIG_texture, tex +g1+0.25*g1+0.25*g2);
+ vec4 F7 = texture2D(ORIG_texture, tex +g1+0.25*g1-0.25*g2);
+ vec4 F8 = texture2D(ORIG_texture, tex +g1-0.25*g1-0.25*g2);
+ vec4 F9 = texture2D(ORIG_texture, tex +g1-0.25*g1+0.25*g2);
+
+ vec4 H6 = texture2D(ORIG_texture, tex +0.25*g1+0.25*g2+g2);
+ vec4 H7 = texture2D(ORIG_texture, tex +0.25*g1-0.25*g2+g2);
+ vec4 H8 = texture2D(ORIG_texture, tex -0.25*g1-0.25*g2+g2);
+ vec4 H9 = texture2D(ORIG_texture, tex -0.25*g1+0.25*g2+g2);
+
+ vec4 f0 = reduce4(F6, F7, F8, F9);
+ vec4 h0 = reduce4(H6, H7, H8, H9);
+
+ bool block_3d = (f0.x == f0.y && f0.y == f0.z && f0.z == f0.w && h0.x == h0.y && h0.y == h0.z && h0.z == h0.w);
+
+ 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 );
+
+/*
+ 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
+*/
+
+
+ /* 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.x + 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 = mul(w1, mat4( P2, H, F, P1 )).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3 )).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ color = block_3d ? color : A.xyz;
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass0.sc
new file mode 100644
index 00000000000..84fc371a0a7
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass0.sc
@@ -0,0 +1,169 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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 weight (XBR_WEIGHT.x * 1.29633 / 10.0)
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ //Skip pixels on wrong grid
+ vec2 pix_frac = fract(v_texcoord0 * u_tex_size0.xy);
+ if (pix_frac.x < 0.5 || pix_frac.y < 0.5)
+ {
+ gl_FragColor = texture2D(s0, v_texcoord0);
+ return;
+ }
+
+ vec2 g1 = vec2(1.0 / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, 1.0 / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord0 -g1 -g2);
+ vec4 P1 = texture2D(s0, v_texcoord0 +2.0*g1 -g2);
+ vec4 P2 = texture2D(s0, v_texcoord0 -g1+2.0*g2);
+ vec4 P3 = texture2D(s0, v_texcoord0 +2.0*g1+2.0*g2);
+
+ vec4 B = texture2D(s0, v_texcoord0 -g2);
+ vec4 C = texture2D(s0, v_texcoord0 +g1-g2);
+ vec4 D = texture2D(s0, v_texcoord0 -g1 );
+ vec4 E = texture2D(s0, v_texcoord0 );
+ vec4 F = texture2D(s0, v_texcoord0 +g1 );
+ vec4 G = texture2D(s0, v_texcoord0 -g1+g2);
+ vec4 H = texture2D(s0, v_texcoord0 +g2);
+ vec4 I = texture2D(s0, v_texcoord0 +g1+g2);
+
+ vec4 F4 = texture2D(s0,v_texcoord0 +2.0*g1 );
+ vec4 I4 = texture2D(s0,v_texcoord0 +g2+2.0*g1 );
+ vec4 H5 = texture2D(s0,v_texcoord0 +2.0*g2 );
+ vec4 I5 = texture2D(s0,v_texcoord0 +2.0*g2+g1 );
+
+ 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 );
+
+/*
+ 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
+*/
+
+
+ /* 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 ));
+
+ float limits = XBR_EDGE_STR.x + 0.000001;
+ float edge_strength = smoothstep(-limits, limits, d_edge);
+
+ /* Filter weights. Two taps only. */
+ vec4 w = vec4(-weight, weight+0.5, weight+0.5, -weight);
+
+ /* Filtering and normalization in two directions generating two colors. */
+ vec3 c1 = mul(w, mat4(P2, H, F, P1)).xyz;
+ vec3 c2 = mul(w, mat4(P0, E, I, P3)).xyz;
+
+ /* Smoothly blends the two directions according to edge strength. */
+ vec3 color = mix(c1, c2, vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+// color = mix(aux, color, 1-2.0*abs(edge_strength-0.5));
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass1.sc
new file mode 100644
index 00000000000..d67c215de66
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass1.sc
@@ -0,0 +1,159 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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 weight (XBR_WEIGHT.x * 1.75068 / 10.0)
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ //Skip pixels on wrong grid
+ vec2 dir = fract(v_texcoord0 * u_tex_size0.xy / 2.0) - vec2(0.5, 0.5);
+ if ((dir.x * dir.y) > 0.0)
+ {
+ gl_FragColor = texture2D(s0, v_texcoord0);
+ return;
+ }
+
+ vec2 g1 = vec2(1.0 / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, 1.0 / u_tex_size0.y);
+
+ vec4 P0 = texture2D(s0, v_texcoord0 -3.0*g1 );
+ vec4 P1 = texture2D(s0, v_texcoord0 -3.0*g2);
+ vec4 P2 = texture2D(s0, v_texcoord0 +3.0*g2);
+ vec4 P3 = texture2D(s0, v_texcoord0 +3.0*g1 );
+
+ vec4 B = texture2D(s0, v_texcoord0 -2.0*g1 -g2);
+ vec4 C = texture2D(s0, v_texcoord0 -g1 -2.0*g2);
+ vec4 D = texture2D(s0, v_texcoord0 -2.0*g1 +g2);
+ vec4 E = texture2D(s0, v_texcoord0 -g1 );
+ vec4 F = texture2D(s0, v_texcoord0 -g2);
+ vec4 G = texture2D(s0, v_texcoord0 -g1 +2.0*g2);
+ vec4 H = texture2D(s0, v_texcoord0 +g2);
+ vec4 I = texture2D(s0, v_texcoord0 +g1 );
+
+ vec4 F4 = texture2D(s0,v_texcoord0 +g1 -2.0*g2);
+ vec4 I4 = texture2D(s0,v_texcoord0 +2.0*g1 -g2);
+ vec4 H5 = texture2D(s0,v_texcoord0 +g1 +2.0*g2);
+ vec4 I5 = texture2D(s0,v_texcoord0 +2.0*g1 +g2);
+
+ 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 ));
+
+ float limits = XBR_EDGE_STR.x + 0.000001;
+ float edge_strength = smoothstep(-limits, limits, d_edge);
+
+ /* Filter weights. Two taps only. */
+ vec4 w = vec4(-weight, weight+0.5, weight+0.5, -weight);
+
+ /* Filtering and normalization in two directions generating two colors. */
+ vec3 c1 = mul(w, mat4(P2, H, F, P1)).xyz;
+ vec3 c2 = mul(w, mat4(P0, E, I, P3)).xyz;
+
+ /* Smoothly blends the two directions according to edge strength. */
+ vec3 color = mix(c1, c2, vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec4 min_sample = min4( E, F, H, I ) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4( E, F, H, I ) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+// color = mix(aux, color, 1-2.0*abs(edge_strength-0.5));
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass2.sc
new file mode 100644
index 00000000000..89e82d00a31
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-fast-pass2.sc
@@ -0,0 +1,162 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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 weight (XBR_WEIGHT.x * 1.29633 / 10.0)
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ vec2 g1 = vec2(1.0 / u_tex_size0.x, 0.0);
+ vec2 g2 = vec2(0.0, 1.0 / u_tex_size0.y);
+ vec2 texcoord = v_texcoord0 - 1.0 / u_tex_size0.xy;
+
+ vec4 P0 = texture2D(s0, texcoord -g1 -g2);
+ vec4 P1 = texture2D(s0, texcoord +2.0*g1 -g2);
+ vec4 P2 = texture2D(s0, texcoord -g1+2.0*g2);
+ vec4 P3 = texture2D(s0, texcoord +2.0*g1+2.0*g2);
+
+ vec4 B = texture2D(s0, texcoord -g2);
+ vec4 C = texture2D(s0, texcoord +g1-g2);
+ vec4 D = texture2D(s0, texcoord -g1 );
+ vec4 E = texture2D(s0, texcoord );
+ vec4 F = texture2D(s0, texcoord +g1 );
+ vec4 G = texture2D(s0, texcoord -g1+g2);
+ vec4 H = texture2D(s0, texcoord +g2);
+ vec4 I = texture2D(s0, texcoord +g1+g2);
+
+ vec4 F4 = texture2D(s0,texcoord +2.0*g1 );
+ vec4 I4 = texture2D(s0,texcoord +g2+2.0*g1 );
+ vec4 H5 = texture2D(s0,texcoord +2.0*g2 );
+ vec4 I5 = texture2D(s0,texcoord +2.0*g2+g1 );
+
+ 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 );
+
+/*
+ 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
+*/
+
+
+ /* 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 ));
+
+ float limits = XBR_EDGE_STR.x + 0.000001;
+ float edge_strength = smoothstep(-limits, limits, d_edge);
+
+ /* Filter weights. Two taps only. */
+ vec4 w = vec4(-weight, weight+0.5, weight+0.5, -weight);
+
+ /* Filtering and normalization in two directions generating two colors. */
+ vec3 c1 = mul(w, mat4(P2, H, F, P1)).xyz;
+ vec3 c2 = mul(w, mat4(P0, E, I, P3)).xyz;
+
+ /* Smoothly blends the two directions according to edge strength. */
+ vec3 color = mix(c1, c2, vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec4 min_sample = min4( E, F, H, I ) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4( E, F, H, I ) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+// color = mix(aux, color, 1-2.0*abs(edge_strength-0.5));
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass0.sc
new file mode 100644
index 00000000000..a1158ebecca
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass0.sc
@@ -0,0 +1,160 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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.x * 1.29633 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.75068 / 10.0 / 2.0)
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ vec4 P0 = texture2D(s0, v_texcoord1.xy);
+ vec4 P1 = texture2D(s0, v_texcoord1.zy);
+ vec4 P2 = texture2D(s0, v_texcoord1.xw);
+ vec4 P3 = texture2D(s0, v_texcoord1.zw);
+
+ vec4 B = texture2D(s0, v_texcoord2.xy);
+ vec4 C = texture2D(s0, v_texcoord2.zy);
+ vec4 H5 = texture2D(s0, v_texcoord2.xw);
+ vec4 I5 = texture2D(s0, v_texcoord2.zw);
+
+ vec4 D = texture2D(s0, v_texcoord3.xy);
+ vec4 F4 = texture2D(s0, v_texcoord3.zy);
+ vec4 G = texture2D(s0, v_texcoord3.xw);
+ vec4 I4 = texture2D(s0, v_texcoord3.zw);
+
+ vec4 E = texture2D(s0, v_texcoord4.xy);
+ vec4 F = texture2D(s0, v_texcoord4.zy);
+ vec4 H = texture2D(s0, v_texcoord4.xw);
+ vec4 I = texture2D(s0, v_texcoord4.zw);
+
+ 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.x + 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 = mul(w1, mat4( P2, H, F, P1 )).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3 )).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass1.sc
new file mode 100644
index 00000000000..421fc78b58c
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass1.sc
@@ -0,0 +1,178 @@
+$input v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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.x * 1.75068 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.29633 / 10.0 / 2.0)
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ //Skip pixels on wrong grid
+ vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
+ vec2 dir = fp - vec2(0.5,0.5);
+ if ((dir.x * dir.y) > 0.0)
+ {
+ if (fp.x > 0.5)
+ {
+ gl_FragColor = texture2D(s0, v_texcoord0);
+ }
+ else
+ {
+ gl_FragColor = texture2D(ORIG_texture, v_texcoord0);
+ }
+ return;
+ }
+
+ vec2 g1 = (fp.x > 0.5) ? vec2(0.5 / u_tex_size0.x, 0.0) : vec2(0.0, 0.5 / u_tex_size0.y);
+ vec2 g2 = (fp.x > 0.5) ? vec2(0.0, 0.5 / u_tex_size0.y) : vec2(0.5 / u_tex_size0.x, 0.0);
+
+ vec4 P0 = texture2D(ORIG_texture, v_texcoord0 -3.0*g1 );
+ vec4 P1 = texture2D( s0, v_texcoord0 -3.0*g2);
+ vec4 P2 = texture2D( s0, v_texcoord0 +3.0*g2);
+ vec4 P3 = texture2D(ORIG_texture, v_texcoord0 +3.0*g1 );
+
+ vec4 B = texture2D( s0, v_texcoord0 -2.0*g1 -g2);
+ vec4 C = texture2D(ORIG_texture, v_texcoord0 -g1 -2.0*g2);
+ vec4 D = texture2D( s0, v_texcoord0 -2.0*g1 +g2);
+ vec4 E = texture2D(ORIG_texture, v_texcoord0 -g1 );
+ vec4 F = texture2D( s0, v_texcoord0 -g2);
+ vec4 G = texture2D(ORIG_texture, v_texcoord0 -g1 +2.0*g2);
+ vec4 H = texture2D( s0, v_texcoord0 +g2);
+ vec4 I = texture2D(ORIG_texture, v_texcoord0 +g1 );
+
+ vec4 F4 = texture2D(ORIG_texture, v_texcoord0 +g1 -2.0*g2);
+ vec4 I4 = texture2D( s0, v_texcoord0 +2.0*g1 -g2);
+ vec4 H5 = texture2D(ORIG_texture, v_texcoord0 +g1 +2.0*g2);
+ vec4 I5 = texture2D( s0, v_texcoord0 +2.0*g1 +g2);
+
+ 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.x + 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 = mul(w1, mat4( P2, H, F, P1 )).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3 )).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass2.sc
new file mode 100644
index 00000000000..c343dc155a2
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/fs_super-xbr-pass2.sc
@@ -0,0 +1,170 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s0, 0);
+
+uniform vec4 XBR_EDGE_STR;
+uniform vec4 XBR_WEIGHT;
+uniform vec4 XBR_ANTI_RINGING;
+uniform vec4 u_tex_size0;
+
+#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.x * 1.29633 / 10.0)
+#define weight2 (XBR_WEIGHT.x * 1.75068 / 10.0 / 2.0)
+
+float RGBtoYUV(vec4 color)
+{
+ return dot(color.xyz, vec3(0.2126, 0.7152, 0.0722));
+}
+
+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)));
+}
+
+vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return min(a, min(b, min(c, d)));
+}
+
+vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
+{
+ return max(a, max(b, max(c, d)));
+}
+
+void main()
+{
+ vec4 P0 = texture2D(s0, v_texcoord1.xy);
+ vec4 P1 = texture2D(s0, v_texcoord1.zy);
+ vec4 P2 = texture2D(s0, v_texcoord1.xw);
+ vec4 P3 = texture2D(s0, v_texcoord1.zw);
+
+ vec4 B = texture2D(s0, v_texcoord2.xy);
+ vec4 C = texture2D(s0, v_texcoord2.zy);
+ vec4 H5 = texture2D(s0, v_texcoord2.xw);
+ vec4 I5 = texture2D(s0, v_texcoord2.zw);
+
+ vec4 D = texture2D(s0, v_texcoord3.xy);
+ vec4 F4 = texture2D(s0, v_texcoord3.zy);
+ vec4 G = texture2D(s0, v_texcoord3.xw);
+ vec4 I4 = texture2D(s0, v_texcoord3.zw);
+
+ vec4 E = texture2D(s0, v_texcoord4.xy);
+ vec4 F = texture2D(s0, v_texcoord4.zy);
+ vec4 H = texture2D(s0, v_texcoord4.xw);
+ vec4 I = texture2D(s0, v_texcoord4.zw);
+
+ 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 );
+
+/*
+ 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
+*/
+
+
+ /* 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.x + 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 = mul(w1, mat4( P2, H, F, P1 )).xyz;
+ vec3 c2 = mul(w1, mat4( P0, E, I, P3 )).xyz;
+ vec3 c3 = mul(w2, mat4(D+G, E+H, F+I, F4+I4)).xyz;
+ vec3 c4 = mul(w2, mat4(C+B, F+E, I+H, I5+H5)).xyz;
+
+ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
+ vec4 d_mix = d_edge >= 0.0 ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0);
+ vec3 hv_mix = hv_edge >= 0.0 ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 color = mix(mix(c1, c2, d_mix.xyz), mix(c3, c4, hv_mix), vec3(1.0, 1.0, 1.0) - vec3(edge_strength, edge_strength, edge_strength));
+
+ /* Anti-ringing code. */
+ float anti_ring = 1.0 - XBR_ANTI_RINGING.x;
+ vec4 min_sample = min4(E, F, H, I) + anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ vec4 max_sample = max4(E, F, H, I) - anti_ring * mix((P2-H)*(F-P1), (P0-E)*(I-P3), d_mix);
+ color = clamp(color, min_sample.xyz, max_sample.xyz);
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/varying.def.sc
new file mode 100644
index 00000000000..c65b5426733
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/varying.def.sc
@@ -0,0 +1,10 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = 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/xbr/super-xbr/vs_custom-jinc2-sharper.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_custom-jinc2-sharper.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_custom-jinc2-sharper.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/xbr/super-xbr/vs_super-2xbr-3d-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-2xbr-3d-pass0.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-2xbr-3d-pass0.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/xbr/super-xbr/vs_super-2xbr-3d-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-2xbr-3d-pass1.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-2xbr-3d-pass1.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/xbr/super-xbr/vs_super-2xbr-3d-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-2xbr-3d-pass2.sc
new file mode 100644
index 00000000000..ae3b049b57a
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-2xbr-3d-pass2.sc
@@ -0,0 +1,50 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR 3D Shader - pass2 *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ vec2 ps = 1.0 / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy);
+ v_texcoord2 = v_texcoord0.xyxy + vec4( -dx, -2.0*dy, 0.0, dy);
+ v_texcoord3 = v_texcoord0.xyxy + vec4(-2.0*dx, -dy, dx, 0.0);
+ v_texcoord4 = v_texcoord0.xyxy + vec4( -dx, -dy, 0.0, 0.0);
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass0.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass0.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/xbr/super-xbr/vs_super-4xbr-3d-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass1.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass1.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/xbr/super-xbr/vs_super-4xbr-3d-pass1f.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass1f.sc
new file mode 100644
index 00000000000..c5bd41ee120
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass1f.sc
@@ -0,0 +1,24 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Dario Manesku
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ vec2 ps = 1.0 / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy);
+ v_texcoord2 = v_texcoord0.xyxy + vec4( -dx, -2.0*dy, 0.0, dy);
+ v_texcoord3 = v_texcoord0.xyxy + vec4(-2.0*dx, -dy, dx, 0.0);
+ v_texcoord4 = v_texcoord0.xyxy + vec4( -dx, -dy, 0.0, 0.0);
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass2.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass2.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/xbr/super-xbr/vs_super-4xbr-3d-pass3.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass3.sc
new file mode 100644
index 00000000000..405ef8feb3b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass3.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/xbr/super-xbr/vs_super-4xbr-3d-pass3f.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass3f.sc
new file mode 100644
index 00000000000..c5bd41ee120
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-4xbr-3d-pass3f.sc
@@ -0,0 +1,24 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Dario Manesku
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ vec2 ps = 1.0 / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy);
+ v_texcoord2 = v_texcoord0.xyxy + vec4( -dx, -2.0*dy, 0.0, dy);
+ v_texcoord3 = v_texcoord0.xyxy + vec4(-2.0*dx, -dy, dx, 0.0);
+ v_texcoord4 = v_texcoord0.xyxy + vec4( -dx, -dy, 0.0, 0.0);
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass0.sc
new file mode 100644
index 00000000000..67e2a4d6250
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass0.sc
@@ -0,0 +1,40 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR Shader - pass0 vertex shader *******
+
+ Copyright (c) 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.
+
+*/
+
+#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/xbr/super-xbr/vs_super-xbr-fast-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass1.sc
new file mode 100644
index 00000000000..d76ec041199
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass1.sc
@@ -0,0 +1,40 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR Shader - pass1 vertex shader *******
+
+ Copyright (c) 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.
+
+*/
+
+#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/xbr/super-xbr/vs_super-xbr-fast-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass2.sc
new file mode 100644
index 00000000000..579ee064622
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-fast-pass2.sc
@@ -0,0 +1,40 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR Shader - pass2 vertex shader *******
+
+ Copyright (c) 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.
+
+*/
+
+#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/xbr/super-xbr/vs_super-xbr-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass0.sc
new file mode 100644
index 00000000000..f03cc46e2b7
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass0.sc
@@ -0,0 +1,50 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR Shader - pass0 vertex shader *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ vec2 ps = 1.0 / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xyxy + vec4(-dx, -dy, 2.0*dx, 2.0*dy);
+ v_texcoord2 = v_texcoord0.xyxy + vec4(0.0, -dy, dx, 2.0*dy);
+ v_texcoord3 = v_texcoord0.xyxy + vec4(-dx, 0.0, 2.0*dx, dy);
+ v_texcoord4 = v_texcoord0.xyxy + vec4(0.0, 0.0, dx, dy);
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass1.sc
new file mode 100644
index 00000000000..67e2a4d6250
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass1.sc
@@ -0,0 +1,40 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR Shader - pass0 vertex shader *******
+
+ Copyright (c) 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.
+
+*/
+
+#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/xbr/super-xbr/vs_super-xbr-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass2.sc
new file mode 100644
index 00000000000..51ffe87fcaa
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass2.sc
@@ -0,0 +1,50 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR Shader - pass0 vertex shader *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ vec2 ps = 1.0 / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy);
+ v_texcoord2 = v_texcoord0.xyxy + vec4( -dx, -2.0*dy, 0.0, dy);
+ v_texcoord3 = v_texcoord0.xyxy + vec4(-2.0*dx, -dy, dx, 0.0);
+ v_texcoord4 = v_texcoord0.xyxy + vec4( -dx, -dy, 0.0, 0.0);
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass3.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass3.sc
new file mode 100644
index 00000000000..51ffe87fcaa
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/super-xbr/vs_super-xbr-pass3.sc
@@ -0,0 +1,50 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ ******* Super XBR Shader - pass0 vertex shader *******
+
+ Copyright (c) 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.
+
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ vec2 ps = 1.0 / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy);
+ v_texcoord2 = v_texcoord0.xyxy + vec4( -dx, -2.0*dy, 0.0, dy);
+ v_texcoord3 = v_texcoord0.xyxy + vec4(-2.0*dx, -dy, dx, 0.0);
+ v_texcoord4 = v_texcoord0.xyxy + vec4( -dx, -dy, 0.0, 0.0);
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/varying.def.sc
new file mode 100644
index 00000000000..92c3034f498
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/varying.def.sc
@@ -0,0 +1,13 @@
+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);
+vec4 v_texcoord4 : TEXCOORD4 = vec4(0.0, 0.0, 0.0, 0.0);
+vec4 v_texcoord5 : TEXCOORD5 = vec4(0.0, 0.0, 0.0, 0.0);
+vec4 v_texcoord6 : TEXCOORD6 = vec4(0.0, 0.0, 0.0, 0.0);
+vec4 v_texcoord7 : TEXCOORD7 = 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/xbr/vs_xbr-lv1-noblend.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv1-noblend.sc
new file mode 100644
index 00000000000..3e97446a880
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv1-noblend.sc
@@ -0,0 +1,22 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Dario Manesku
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ vec2 ps = 1.0 / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1.xy = vec2(0.0,-dy); // B
+ v_texcoord1.zw = vec2(-dx,0.0); // D
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-3d.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-3d.sc
new file mode 100644
index 00000000000..476e11da6ea
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-3d.sc
@@ -0,0 +1,23 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Dario Manesku
+
+#include "common.sh"
+
+uniform vec4 XBR_RES;
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ vec2 ps = XBR_RES.xx / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = vec4(dx, 0, 0, dy); // F H
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-fast.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-fast.sc
new file mode 100644
index 00000000000..38e92865308
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-fast.sc
@@ -0,0 +1,29 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Dario Manesku
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ // A1 B1 C1
+ // A0 A B C C4
+ // D0 D E F F4
+ // G0 G H I I4
+ // G5 H5 I5
+
+ vec2 ps = 1.0 / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, -dy); // A B C
+ v_texcoord2 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, 0.0); // D E F
+ v_texcoord3 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, dy); // G H I
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2.sc
new file mode 100644
index 00000000000..ce6e411b75d
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2.sc
@@ -0,0 +1,27 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Dario Manesku
+
+#include "common.sh"
+
+uniform vec4 u_tex_size0;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ vec2 ps = 1.0 / u_tex_size0.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, -2.0*dy); // A1 B1 C1
+ v_texcoord2 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, -dy); // A B C
+ v_texcoord3 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, 0.0); // D E F
+ v_texcoord4 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, dy); // G H I
+ v_texcoord5 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, 2.0*dy); // G5 H5 I5
+ v_texcoord6 = v_texcoord0.xyyy + vec4(-2.0*dx, -dy, 0.0, dy); // A0 D0 G0
+ v_texcoord7 = v_texcoord0.xyyy + vec4( 2.0*dx, -dy, 0.0, dy); // C4 F4 I4
+ v_color0 = a_color0;
+}