summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.cpp32
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.h17
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/blurs/fs_smart-blur.sc64
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/blurs/varying.def.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq2x/varying.def.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/blurs/vs_smart-blur.sc48
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/eagle/fs_eagle.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_eagle.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/eagle/varying.def.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/supereagle/varying.def.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/eagle/vs_eagle.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_eagle.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/hqx/fs_hq2x.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_hq2x.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/hqx/fs_hq3x.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_hq3x.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/hqx/fs_hq4x.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_hq4x.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/hqx/varying.def.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq3x/varying.def.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/hqx/vs_hq2x.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_hq2x.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/hqx/vs_hq3x.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_hq3x.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/hqx/vs_hq4x.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_hq4x.sc)0
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/warp/fs_dilation-horizontal-fast.sc46
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/warp/varying.def.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/hq4x/varying.def.sc)2
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/warp/vs_dilation-horizontal-fast.sc51
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/fs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/vs_blit.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/fs_blit.sc14
-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.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/fs_blit.sc14
-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.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/fs_blit.sc14
-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.sc14
-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.sc14
-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.sc14
-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-lv2-noblend.sc210
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3-noblend.sc234
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3.sc254
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-noblend.sc59
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv3-noblend.sc60
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv3.sc60
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-sharp.sc336
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v2-gamma.sc265
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v2.sc255
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4-gamma.sc281
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4.sc271
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4b.sc256
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v5-gamma.sc288
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid.sc341
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/varying.def.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/varying.def.sc)3
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-sharp.sc72
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v2-gamma.sc72
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v2.sc72
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4-gamma.sc72
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4.sc72
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4b.sc72
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v5-gamma.sc72
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid.sc72
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-a-pass0.sc159
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-accuracy-pass0.sc174
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-accuracy-pass1.sc160
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-b-pass0.sc160
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-c-pass0.sc158
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-d-pass0.sc163
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-noblend-pass1.sc162
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-pass1.sc185
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/varying.def.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/varying.def.sc)3
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-a-pass0.sc60
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-accuracy-pass0.sc59
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-accuracy-pass1.sc55
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-b-pass0.sc60
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-c-pass0.sc60
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-d-pass0.sc60
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-noblend-pass1.sc54
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-pass1.sc56
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/fs_xbr-lv3-pass0.sc216
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/fs_xbr-lv3-pass1.sc180
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/varying.def.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/varying.def.sc)3
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/vs_xbr-lv3-pass0.sc60
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/vs_xbr-lv3-pass1.sc55
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass1.sc208
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass2.sc235
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass3.sc172
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass4.sc164
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/varying.def.sc (renamed from src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/varying.def.sc)3
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass1.sc52
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass2.sc59
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass3.sc55
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass4.sc53
118 files changed, 7295 insertions, 613 deletions
diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp
index c3aeb586136..70d678d1f2b 100644
--- a/src/osd/modules/render/bgfx/chainmanager.cpp
+++ b/src/osd/modules/render/bgfx/chainmanager.cpp
@@ -59,9 +59,9 @@ chain_manager::~chain_manager()
void chain_manager::refresh_available_chains()
{
m_available_chains.clear();
- m_available_chains.push_back("none");
+ m_available_chains.push_back(chain_desc("none", ""));
- find_available_chains(std::string(m_options.bgfx_path()) + "/chains");
+ find_available_chains(std::string(m_options.bgfx_path()) + "/chains", "");
destroy_unloaded_chains();
}
@@ -74,9 +74,9 @@ void chain_manager::destroy_unloaded_chains()
std::string name = m_chain_names[i];
if (name.length() > 0)
{
- for (std::string available_name : m_available_chains)
+ for (chain_desc desc : m_available_chains)
{
- if (available_name == name)
+ if (desc.m_name == name)
{
delete m_screen_chains[i];
m_chain_names[i] = "";
@@ -88,9 +88,9 @@ void chain_manager::destroy_unloaded_chains()
}
}
-void chain_manager::find_available_chains(std::string path)
+void chain_manager::find_available_chains(std::string root, std::string path)
{
- osd_directory *directory = osd_opendir(path.c_str());
+ osd_directory *directory = osd_opendir((root + path).c_str());
if (directory != nullptr)
{
for (const osd_directory_entry *entry = osd_readdir(directory); entry != nullptr; entry = osd_readdir(directory))
@@ -109,7 +109,7 @@ void chain_manager::find_available_chains(std::string path)
// Does it end in .json?
if (test_segment == extension)
{
- m_available_chains.push_back(name.substr(0, start));
+ m_available_chains.push_back(chain_desc(name.substr(0, start), path));
}
}
}
@@ -118,7 +118,12 @@ void chain_manager::find_available_chains(std::string path)
std::string name = entry->name;
if (!(name == "." || name == ".."))
{
- find_available_chains(path + PATH_SEPARATOR + name);
+ std::string appended_path = path + "/" + name;
+ if (path.length() == 0)
+ {
+ appended_path = name;
+ }
+ find_available_chains(root, path + "/" + name);
}
}
}
@@ -189,7 +194,7 @@ void chain_manager::parse_chain_selections(std::string chain_str)
size_t chain_index = 0;
for (chain_index = 0; chain_index < m_available_chains.size(); chain_index++)
{
- if (m_available_chains[chain_index] == chain_names[index])
+ if (m_available_chains[chain_index].m_name == chain_names[index])
{
break;
}
@@ -198,7 +203,7 @@ 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];
+ m_chain_names[index] = m_available_chains[chain_index].m_name;
}
else
{
@@ -240,8 +245,9 @@ void chain_manager::load_chains()
{
if (m_current_chain[chain] != CHAIN_NONE)
{
- m_chain_names[chain] = m_available_chains[m_current_chain[chain]];
- m_screen_chains[chain] = load_chain(m_chain_names[chain], uint32_t(chain));
+ chain_desc& desc = m_available_chains[m_current_chain[chain]];
+ m_chain_names[chain] = desc.m_name;
+ m_screen_chains[chain] = load_chain(desc.m_path + "/" + desc.m_name, uint32_t(chain));
}
}
}
@@ -369,7 +375,7 @@ int32_t chain_manager::chain_changed(int32_t id, std::string *str, int32_t newva
if (str != nullptr)
{
- *str = string_format("%s", m_available_chains[m_current_chain[id]].c_str());
+ *str = string_format("%s", m_available_chains[m_current_chain[id]].m_name.c_str());
}
return m_current_chain[id];
diff --git a/src/osd/modules/render/bgfx/chainmanager.h b/src/osd/modules/render/bgfx/chainmanager.h
index d527bc7122c..022fe6e3b2e 100644
--- a/src/osd/modules/render/bgfx/chainmanager.h
+++ b/src/osd/modules/render/bgfx/chainmanager.h
@@ -30,6 +30,19 @@ class render_primitive;
class bgfx_chain;
class bgfx_slider;
+class chain_desc
+{
+public:
+ chain_desc(std::string name, std::string path)
+ : m_name(name)
+ , m_path(path)
+ {
+ }
+
+ const std::string m_name;
+ const std::string m_path;
+};
+
class chain_manager
{
public:
@@ -60,7 +73,7 @@ private:
void refresh_available_chains();
void destroy_unloaded_chains();
- void find_available_chains(std::string path);
+ void find_available_chains(std::string root, std::string path);
void parse_chain_selections(std::string chain_str);
std::vector<std::string> split_option_string(std::string chain_str) const;
@@ -79,7 +92,7 @@ private:
uint32_t m_window_index;
slider_dirty_notifier& m_slider_notifier;
uint32_t m_screen_count;
- std::vector<std::string> m_available_chains;
+ std::vector<chain_desc> 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;
diff --git a/src/osd/modules/render/bgfx/shaders/chains/blurs/fs_smart-blur.sc b/src/osd/modules/render/bgfx/shaders/chains/blurs/fs_smart-blur.sc
new file mode 100644
index 00000000000..78229ec9c49
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/blurs/fs_smart-blur.sc
@@ -0,0 +1,64 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian Smart-Blur 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(s_p, 0);
+
+uniform vec4 SB_THRESHOLD;
+
+// Below the thresholds, blur is applied for each color channel.
+// Threshold is the max color differency among the eight pixel neighbors from central pixel.
+
+bool eq(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r < SB_THRESHOLD.r && df.g < SB_THRESHOLD.g && df.b < SB_THRESHOLD.b;
+}
+
+void main()
+{
+ vec3 A = texture2D(s_p, v_texcoord1.xw).xyz;
+ vec3 B = texture2D(s_p, v_texcoord1.yw).xyz;
+ vec3 C = texture2D(s_p, v_texcoord1.zw).xyz;
+ vec3 D = texture2D(s_p, v_texcoord2.xw).xyz;
+ vec3 E = texture2D(s_p, v_texcoord2.yw).xyz;
+ vec3 F = texture2D(s_p, v_texcoord2.zw).xyz;
+ vec3 G = texture2D(s_p, v_texcoord3.xw).xyz;
+ vec3 H = texture2D(s_p, v_texcoord3.yw).xyz;
+ vec3 I = texture2D(s_p, v_texcoord3.zw).xyz;
+
+ if (eq(E,F) && eq(E,H) && eq(E,I) && eq(E,B) && eq(E,C) && eq(E,A) && eq(E,D) && eq(E,G))
+ {
+ E = (A + B + C + D + E + F + G + H + I) / 9.0;
+ }
+
+ gl_FragColor = vec4(E, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/blurs/varying.def.sc
index 57a7a910952..57a7a910952 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq2x/varying.def.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/blurs/varying.def.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/blurs/vs_smart-blur.sc b/src/osd/modules/render/bgfx/shaders/chains/blurs/vs_smart-blur.sc
new file mode 100644
index 00000000000..c82d7c82bec
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/blurs/vs_smart-blur.sc
@@ -0,0 +1,48 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian Smart-Blur 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.
+
+*/
+
+#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, -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/supereagle/fs_eagle.sc b/src/osd/modules/render/bgfx/shaders/chains/eagle/fs_eagle.sc
index a07a848ffbd..a07a848ffbd 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_eagle.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/eagle/fs_eagle.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/supereagle/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/eagle/varying.def.sc
index 7adabc462e5..7adabc462e5 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/supereagle/varying.def.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/eagle/varying.def.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_eagle.sc b/src/osd/modules/render/bgfx/shaders/chains/eagle/vs_eagle.sc
index d233629a036..d233629a036 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_eagle.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/eagle/vs_eagle.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_hq2x.sc b/src/osd/modules/render/bgfx/shaders/chains/hqx/fs_hq2x.sc
index 66bd69f253e..66bd69f253e 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq2x/fs_hq2x.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/hqx/fs_hq2x.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_hq3x.sc b/src/osd/modules/render/bgfx/shaders/chains/hqx/fs_hq3x.sc
index 8e0f46a80f1..8e0f46a80f1 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq3x/fs_hq3x.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/hqx/fs_hq3x.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_hq4x.sc b/src/osd/modules/render/bgfx/shaders/chains/hqx/fs_hq4x.sc
index 8e769bee46c..8e769bee46c 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq4x/fs_hq4x.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/hqx/fs_hq4x.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq3x/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/hqx/varying.def.sc
index 57a7a910952..57a7a910952 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq3x/varying.def.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/hqx/varying.def.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_hq2x.sc b/src/osd/modules/render/bgfx/shaders/chains/hqx/vs_hq2x.sc
index a77ac7006f7..a77ac7006f7 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq2x/vs_hq2x.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/hqx/vs_hq2x.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_hq3x.sc b/src/osd/modules/render/bgfx/shaders/chains/hqx/vs_hq3x.sc
index a77ac7006f7..a77ac7006f7 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq3x/vs_hq3x.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/hqx/vs_hq3x.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_hq4x.sc b/src/osd/modules/render/bgfx/shaders/chains/hqx/vs_hq4x.sc
index a77ac7006f7..a77ac7006f7 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq4x/vs_hq4x.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/hqx/vs_hq4x.sc
diff --git a/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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/super-4xbr-3d-4p/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/vs_blit.sc
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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/super-4xbr-3d-6p-smoother/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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/super-4xbr-3d-6p-smoother/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/vs_blit.sc
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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/supereagle/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_blit.sc
deleted file mode 100644
index 874846cce0d..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$input v_color0, texCoord
-
-// license:BSD-3-Clause
-// copyright-holders:Dario Manesku
-
-#include "common.sh"
-
-// Samplers
-SAMPLER2D(s_tex, 0);
-
-void main()
-{
- gl_FragColor = texture2D(s_tex, texCoord) * v_color0;
-}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_blit.sc
deleted file mode 100644
index 7d857008291..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$input a_position, a_texcoord0, a_color0
-$output texCoord, 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));
- texCoord = a_texcoord0.xy;
- v_color0 = a_color0;
-}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/warp/fs_dilation-horizontal-fast.sc b/src/osd/modules/render/bgfx/shaders/chains/warp/fs_dilation-horizontal-fast.sc
new file mode 100644
index 00000000000..3f03d8e6adb
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/warp/fs_dilation-horizontal-fast.sc
@@ -0,0 +1,46 @@
+$input v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's dilation-horizontal-fast Shader
+
+ 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+#define TEX(dx,dy) texture2D(decal, v_texcoord0 + vec2(dx,dy) * v_texcoord1.xy)
+
+void main()
+{
+ vec3 D = TEX(-1, 0).rgb;
+ vec3 E = TEX( 0, 0).rgb;
+ vec3 F = TEX( 1, 0).rgb;
+
+ vec3 res = max(E, max(F, D));
+
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hq4x/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/warp/varying.def.sc
index 57a7a910952..8404fc635e1 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hq4x/varying.def.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/warp/varying.def.sc
@@ -1,8 +1,6 @@
vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
vec4 v_texcoord1 : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0);
-vec4 v_texcoord2 : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0);
-vec4 v_texcoord3 : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0);
vec3 a_position : POSITION;
vec4 a_color0 : COLOR0;
diff --git a/src/osd/modules/render/bgfx/shaders/chains/warp/vs_dilation-horizontal-fast.sc b/src/osd/modules/render/bgfx/shaders/chains/warp/vs_dilation-horizontal-fast.sc
new file mode 100644
index 00000000000..828dc3078cf
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/warp/vs_dilation-horizontal-fast.sc
@@ -0,0 +1,51 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's dilation-horizontal-fast Shader
+
+ 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.
+
+*/
+
+#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;
+ // B
+ // D E F
+ // H
+
+ v_texcoord1 = vec4(1.0 / u_tex_size0.xy, 0.0, 0.0); // F H
+
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-hybrid/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/vs_blit.sc
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-lv1-noblend/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-lv1-noblend/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/vs_blit.sc
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-3d/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-3d/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/varying.def.sc
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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-3d/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/vs_blit.sc
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-3d/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-accuracy-multipass/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-accuracy-multipass/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/varying.def.sc
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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-accuracy-multipass/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/vs_blit.sc
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-multipass/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-accuracy-smart-blur/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-accuracy-smart-blur/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/varying.def.sc
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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-accuracy-smart-blur/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/vs_blit.sc
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-accuracy-smart-blur/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-deposterize/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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-deposterize/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/vs_blit.sc
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-deposterize/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-fast/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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-fast/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/vs_blit.sc
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-fast/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-multipass/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/fs_blit.sc
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-multipass/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv2-noblend/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-multipass/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3-noblend/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv3/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-dilation/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index 9af7bcf0ee6..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/fs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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
deleted file mode 100644
index c65b5426733..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/varying.def.sc
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644
index 405ef8feb3b..00000000000
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-mlv4-multipass/vs_blit.sc
+++ /dev/null
@@ -1,14 +0,0 @@
-$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-lv2-noblend.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-noblend.sc
new file mode 100644
index 00000000000..ee5ebb4398e
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2-noblend.sc
@@ -0,0 +1,210 @@
+$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-noblend 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_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 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 gt(vec4 A, vec4 B)
+{
+ return vec4(greaterThan(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()
+{
+ 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), Y);
+ vec4 c = mul(mat4(C, A, G, I), Y);
+ vec4 e = mul(mat4(E, E, E, E), 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), Y);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), Y);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), Y);
+ vec4 f4 = h5.yzwx;
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ // These inequations define the line below which interpolation occurs.
+ vec4 fx = gt(Ao * fp.y + Bo * fp.x, Co);
+ vec4 fx_left = gt(Ax * fp.y + Bx * fp.x, Cx);
+ vec4 fx_up = gt(Ay * fp.y + By * fp.x, Cy);
+
+#ifdef CORNER_A
+ vec4 interp_restriction_lv1 = ne(e,f) * ne(e,h);
+#endif
+#ifdef CORNER_B
+ vec4 interp_restriction_lv1 = (ne(e,f) * ne(e,h) * (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;
+ vec4 interp_restriction_lv1 = (ne(e,f) * ne(e,h) * (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
+ vec4 interp_restriction_lv1 = (ne(e,f) * ne(e,h) * (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
+
+ interp_restriction_lv1 = clamp(interp_restriction_lv1, 0.0, 1.0);
+
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ 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_lv1;
+ vec4 edr = lt(wd1,wd2) * interp_restriction_lv1 * ((one - edri.yzwx) + (one - edri.wxyz));
+ vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr * ((one - edri.yzwx) * lt(e,c));
+ vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr * ((one - edri.wxyz) * lt(e,g));
+
+
+ vec4 nc = clamp(edr * (fx + edr_left * fx_left + edr_up * fx_up), 0.0, 1.0);
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec3 res1 = nc.x > 0.0 ? px.x > 0.0 ? F.xyz : H.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : E.xyz;
+ vec3 res2 = nc.w > 0.0 ? px.w > 0.0 ? H.xyz : D.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : E.xyz;
+
+ vec2 df12 = abs(mul(mat3(res1, res2, vec3(0.0, 0.0, 0.0)), Y.xyz).xy - e.xy);
+
+ vec3 res_mix = (df12.y >= df12.x) ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 res = mix(res1, res2, res_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-lv3-noblend.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3-noblend.sc
new file mode 100644
index 00000000000..05cf1124896
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3-noblend.sc
@@ -0,0 +1,234 @@
+$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-lv3-noblend - 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_EQ_THRESHOLD;
+uniform vec4 XBR_EQ_THRESHOLD2;
+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 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 gt(vec4 A, vec4 B)
+{
+ return vec4(greaterThan(A, B));
+}
+
+vec4 abslt2(vec4 A, vec4 B)
+{
+ return lt(df(A, B), XBR_EQ_THRESHOLD2.xxxx);
+}
+
+vec4 absge(vec4 A, vec4 B)
+{
+ return ge(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+}
+
+vec4 absge2(vec4 A, vec4 B)
+{
+ return ge(df(A, B), XBR_EQ_THRESHOLD2.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()
+{
+ 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), Y);
+ vec4 c = mul(mat4(C, A, G, I), Y);
+ vec4 e = mul(mat4(E, E, E, E), 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), Y);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), Y);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), Y);
+ vec4 f4 = h5.yzwx;
+
+ vec4 c4 = i5.yzwx;
+ vec4 g5 = i4.wxyz;
+
+ vec4 c1 = i4.yzwx;
+ vec4 g0 = i5.wxyz;
+ vec4 b1 = h5.zwxy;
+ vec4 d0 = h5.wxyz;
+
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ vec4 Az = vec4( 6.0, -2.0, -6.0, 2.0 );
+ vec4 Bz = vec4( 2.0, 6.0, -2.0, -6.0 );
+ vec4 Cz = vec4( 5.0, 3.0, -3.0, -1.0 );
+ vec4 Aw = vec4( 2.0, -6.0, -2.0, 6.0 );
+ vec4 Bw = vec4( 6.0, 2.0, -6.0,-2.0 );
+ vec4 Cw = vec4( 5.0, -1.0, -3.0, 3.0 );
+
+ // These inequations define the line below which interpolation occurs.
+ vec4 fx = gt(Ao * fp.y + Bo * fp.x, Co);
+ vec4 fx_left = gt(Ax * fp.y + Bx * fp.x, Cx);
+ vec4 fx_up = gt(Ay * fp.y + By * fp.x, Cy);
+ vec4 fx3_left= gt(Az * fp.y + Bz * fp.x, Cz);
+ vec4 fx3_up = gt(Aw * fp.y + Bw * fp.x, Cw);
+
+ vec4 interp_restriction_lv0 = (ne(e,f) * ne(e,h));
+
+ // It uses CORNER_C if none of the others are defined.
+#ifdef CORNER_A
+ vec4 interp_restriction_lv1 = interp_restriction_lv0;
+#elif CORNER_B
+ vec4 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)));
+#elif CORNER_D
+ vec4 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)));
+#elif CORNER_C
+ vec4 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
+
+ interp_restriction_lv1 = clamp(interp_restriction_lv1, 0.0, 1.0);
+
+ vec4 interp_restriction_lv2_left = ne(e,g) * ne(d,g);
+ vec4 interp_restriction_lv2_up = ne(e,c) * ne(b,c);
+ vec4 interp_restriction_lv3_left = abslt2(g,g0) * absge2(d0,g0);
+ vec4 interp_restriction_lv3_up = abslt2(c,c1) * absge2(b1,c1);
+
+ vec4 wd1 = weighted_distance(e, c, g, i, h5, f4, h, f);
+ vec4 wd2 = weighted_distance(h, d, i5, f, i4, b, e, i);
+
+ 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_lv1;
+ vec4 edr = clamp(lt(wd1,wd2) * interp_restriction_lv1 * ((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) * lt(e,c);
+ vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr * (one - edri.wxyz) * lt(e,g);
+ vec4 edr3_left = interp_restriction_lv3_left;
+ vec4 edr3_up = interp_restriction_lv3_up;
+
+ vec4 nc = clamp((edr * fx + edr_left * (fx_left + edr3_left * fx3_left * lt(e,c4)) + edr_up * (fx_up + edr3_up * fx3_up * lt(e,g5))), 0.0, 1.0);
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec3 res1 = nc.x > 0.0 ? px.x > 0.0 ? F.xyz : H.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : nc.w > 0.0 ? px.w > 0.0 ? H.xyz : D.xyz : E.xyz;
+ vec3 res2 = nc.w > 0.0 ? px.w > 0.0 ? H.xyz : D.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : nc.x > 0.0 ? px.x > 0.0 ? F.xyz : H.xyz : E.xyz;
+
+ vec2 df12 = abs(mul(mat3(res1, res2, zero.xyz), Y.xyz).xy - e.xy);
+
+ vec3 res = mix(res1, res2, (df12.y >= df12.x) ? one.xyz : zero.xyz);
+
+ 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-lv3.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3.sc
new file mode 100644
index 00000000000..b2fd0d94714
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3.sc
@@ -0,0 +1,254 @@
+$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-lv3 Shader
+
+ 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_Y_WEIGHT;
+uniform vec4 XBR_EQ_THRESHOLD;
+uniform vec4 XBR_EQ_THRESHOLD2;
+uniform vec4 XBR_LV2_COEFFICIENT;
+
+uniform vec4 u_tex_size0;
+
+SAMPLER2D(decal, 0);
+
+const vec4 yuv = vec4(0.299, 0.587, 0.114, 0.0);
+const vec4 delta = vec4(0.4, 0.4, 0.4, 0.4);
+
+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 abslt2(vec4 A, vec4 B)
+{
+ return lt(df(A, B), XBR_EQ_THRESHOLD2.xxxx);
+}
+
+vec4 absge(vec4 A, vec4 B)
+{
+ return ge(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+}
+
+vec4 absge2(vec4 A, vec4 B)
+{
+ return ge(df(A, B), XBR_EQ_THRESHOLD2.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()
+{
+ 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 * yuv);
+ vec4 c = mul(mat4(C, A, G, I), XBR_Y_WEIGHT.xxxx * yuv);
+ vec4 e = mul(mat4(E, E, E, E), XBR_Y_WEIGHT.xxxx * yuv);
+ 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 * yuv);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), XBR_Y_WEIGHT.xxxx * yuv);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), XBR_Y_WEIGHT.xxxx * yuv);
+ vec4 f4 = h5.yzwx;
+
+ vec4 c1 = i4.yzwx;
+ vec4 g0 = i5.wxyz;
+ vec4 b1 = h5.zwxy;
+ vec4 d0 = h5.wxyz;
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ vec4 Az = vec4( 6.0, -2.0, -6.0, 2.0 );
+ vec4 Bz = vec4( 2.0, 6.0, -2.0, -6.0 );
+ vec4 Cz = vec4( 5.0, 3.0, -3.0, -1.0 );
+ vec4 Aw = vec4( 2.0, -6.0, -2.0, 6.0 );
+ vec4 Bw = vec4( 6.0, 2.0, -6.0,-2.0 );
+ vec4 Cw = vec4( 5.0, -1.0, -3.0, 3.0 );
+
+ // These inequations define the line below which interpolation occurs.
+ 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 fx3_left= (Az * fp.y + Bz * fp.x);
+ vec4 fx3_up = (Aw * fp.y + Bw * fp.x);
+
+ vec4 interp_restriction_lv0 = (ne(e,f) * ne(e,h));
+
+// It uses CORNER_C if none of the others are defined.
+#ifdef CORNER_A
+ vec4 interp_restriction_lv1 = interp_restriction_lv0;
+#elif CORNER_B
+ vec4 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) ) );
+#elif CORNER_D
+ vec4 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) ) * (f!=f4 * f!=i + h!=h5 * h!=i + h!=g + f!=c + lt(b,c1) * lt(d,g0)));
+#else
+ vec4 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
+
+ interp_restriction_lv1 = clamp(interp_restriction_lv1, 0.0, 1.0);
+
+ vec4 interp_restriction_lv2_left = ne(e,g) * ne(d,g);
+ vec4 interp_restriction_lv2_up = ne(e,c) * ne(b,c);
+ vec4 interp_restriction_lv3_left = abslt2(g,g0) * absge2(d0,g0);
+ vec4 interp_restriction_lv3_up = abslt2(c,c1) * absge2(b1,c1);
+
+ vec4 fx45 = smoothstep(Co - delta, Co + delta, fx);
+ vec4 fx30 = smoothstep(Cx - delta, Cx + delta, fx_left);
+ vec4 fx60 = smoothstep(Cy - delta, Cy + delta, fx_up);
+ vec4 fx15 = smoothstep(Cz - delta, Cz + delta, fx3_left);
+ vec4 fx75 = smoothstep(Cw - delta, Cw + delta, fx3_up);
+
+ vec4 edr = lt(weighted_distance(e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left;
+ vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up;
+
+ vec4 edr3_left = interp_restriction_lv3_left;
+ vec4 edr3_up = interp_restriction_lv3_up;
+
+ vec4 nc45 = edr * fx45;
+ vec4 nc30 = edr * edr_left * fx30;
+ vec4 nc60 = edr * edr_up * fx60;
+ vec4 nc15 = edr * edr_left * edr3_left * fx15;
+ vec4 nc75 = edr * edr_up * edr3_up * fx75;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec4 nc = nc75 + nc15 + nc30 + nc60 + nc45;
+
+ vec4 final45 = nc45 * fx45;
+ vec4 final30 = nc30 * fx30;
+ vec4 final60 = nc60 * fx60;
+ vec4 final15 = nc15 * fx15;
+ vec4 final75 = nc75 * fx75;
+
+ vec4 maximo = max(max(max(final15, final75),max(final30, final60)), final45);
+
+ float blend1;
+ vec3 pix1;
+ if (nc.x > 0.0) {pix1 = px.x > 0.0 ? F.xyz : H.xyz; blend1 = maximo.x;}
+ else if (nc.y > 0.0) {pix1 = px.y > 0.0 ? B.xyz : F.xyz; blend1 = maximo.y;}
+ else if (nc.z > 0.0) {pix1 = px.z > 0.0 ? D.xyz : B.xyz; blend1 = maximo.z;}
+ else if (nc.w > 0.0) {pix1 = px.w > 0.0 ? H.xyz : D.xyz; blend1 = maximo.w;}
+
+ float blend2;
+ vec3 pix2;
+ if (nc.w > 0.0) {pix2 = px.w > 0.0 ? H.xyz : D.xyz; blend2 = maximo.w;}
+ else if (nc.z > 0.0) {pix2 = px.z > 0.0 ? D.xyz : B.xyz; blend2 = maximo.z;}
+ else if (nc.y > 0.0) {pix2 = px.y > 0.0 ? B.xyz : F.xyz; blend2 = maximo.y;}
+ else if (nc.x > 0.0) {pix2 = px.x > 0.0 ? F.xyz : H.xyz; blend2 = maximo.x;}
+
+ vec3 res1 = mix(E.xyz, pix1, blend1);
+ vec3 res2 = mix(E.xyz, pix2, blend2);
+
+ 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/vs_xbr-lv2-noblend.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-noblend.sc
new file mode 100644
index 00000000000..75541985e36
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv2-noblend.sc
@@ -0,0 +1,59 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR-lv2-noblend 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 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, -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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv3-noblend.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv3-noblend.sc
new file mode 100644
index 00000000000..5421eaf2955
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv3-noblend.sc
@@ -0,0 +1,60 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR-lv3-noblend - 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 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, -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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv3.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv3.sc
new file mode 100644
index 00000000000..f4ee1f55ab3
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/vs_xbr-lv3.sc
@@ -0,0 +1,60 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR-lv3 - 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 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, -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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-sharp.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-sharp.sc
new file mode 100644
index 00000000000..533bfe0f762
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-sharp.sc
@@ -0,0 +1,336 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.7c+ReverseAA (squared) Shader
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+uniform vec4 u_tex_size0;
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+vec4 lt_coeff(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ge_coeff(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec3 lt3(vec3 A, vec3 B)
+{
+ return vec3(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec3 gt3(vec3 A, vec3 B)
+{
+ return vec3(greaterThan(A, B));
+}
+
+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()
+{
+ 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 interp_restriction_lv1 = clamp((ne(e,f) * ne(e,h) * (ge_coeff(f,b) * ge_coeff(f,c) + ge_coeff(h,d) * ge_coeff(h,g) + lt_coeff(e,i) * (ge_coeff(f,f4) * ge_coeff(f,i4) + ge_coeff(h,h5) * ge_coeff(h,i5)) + lt_coeff(e,g) + lt_coeff(e,c))), 0.0, 1.0);
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 edr = lt(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec4 P[4];
+ P[0] = px.x > 0.0 ? F : H;
+ P[1] = px.y > 0.0 ? B : F;
+ P[2] = px.z > 0.0 ? D : B;
+ P[3] = px.w > 0.0 ? H : D;
+
+ vec4 res = E;
+
+ vec3 threshold = vec3(0.8, 0.42, 0.29);
+ vec3 xx = vec3(0.0, 0.0, 0.0);
+
+ vec3 n1 = B1.xyz;
+ vec3 n2 = B.xyz;
+ vec3 s = E.xyz;
+ vec3 n3 = H.xyz;
+ vec3 n4 = H5.xyz;
+
+ vec3 aa = n2 - n1;
+ vec3 bb = s - n2;
+ vec3 cc = n3 - s;
+ vec3 dd = n4 - n3;
+
+ vec3 t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ vec3 m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, 2.0 * abs(bb));
+ m = min(m, 2.0 * abs(cc));
+ vec3 sim1 = gt3(abs(bb) * 2.0, threshold) + gt3(abs(cc) * 2.0, threshold);
+ t = clamp(t, -m, m);
+
+ vec3 s1 = (2.0 * fp.y - 1.0) * t + s;
+
+ n1 = D0.xyz;
+ n2 = D.xyz;
+ s = s1;
+ n3 = F.xyz;
+ n4 = F4.xyz;
+
+ aa = n2 - n1;
+ bb = s - n2;
+ cc = n3 - s;
+ dd = n4 - n3;
+
+ t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, 2.0 * abs(bb));
+ m = min(m, 2.0 * abs(cc));
+ vec3 sim2 = gt3(abs(bb) * 2.0, threshold) + gt3(abs(cc) * 2.0, threshold);
+ t = clamp(t, -m, m);
+
+ vec3 s0 = (2.0 * fp.x - 1.0) * t + s;
+
+ res = vec4(s0, 1.0);
+
+ if ((sim1.x > 0.0 || sim1.y > 0.0 || sim1.z > 0.0) && (sim2.x > 0.0 || sim2.y > 0.0 || sim2.z > 0.0))
+ {
+ if (fp.x >= 0.5)
+ {
+ if (fp.y >= 0.5)
+ {
+ if (edr.x > 0.0 && edr_left.x > 0.0 && edr_up.x > 0.0)
+ {
+ res = mix(E , P[0], 0.833333);
+ }
+ else if (edr.x > 0.0 && (edr_left.x > 0.0 || edr_up.x > 0.0))
+ {
+ res = mix(E , P[0], 0.75);
+ }
+ else if (edr.y > 0.0 && edr_left.y > 0.0 && edr.w > 0.0 && edr_up.w > 0.0)
+ {
+ res = mix(E , P[1], 0.25);
+ res = mix(E , P[3], 0.25);
+ }
+ else if (edr.y > 0.0 && edr_left.y > 0.0)
+ {
+ res = mix(E , P[1], 0.25);
+ }
+ else if (edr.w > 0.0 && edr_up.w > 0.0)
+ {
+ res = mix(E , P[3], 0.25);
+ }
+ else if (edr.x > 0.0)
+ {
+ res = mix(E , P[0], 0.5);
+ }
+ }
+ else
+ {
+ if (edr.y > 0.0 && edr_left.y > 0.0 && edr_up.y > 0.0)
+ {
+ res = mix(E , P[1], 0.833333);
+ }
+ else if (edr.y > 0.0 && (edr_left.y > 0.0 || edr_up.y > 0.0))
+ {
+ res = mix(E , P[1], 0.75);
+ }
+ else if (edr.z > 0.0 && edr_left.z > 0.0 && edr.x > 0.0 && edr_up.x > 0.0)
+ {
+ res = mix(E , P[2], 0.25);
+ res = mix(E , P[0], 0.25);
+ }
+ else if (edr.z > 0.0 && edr_left.z > 0.0)
+ {
+ res = mix(E , P[2], 0.25);
+ }
+ else if (edr.x > 0.0 && edr_up.x > 0.0)
+ {
+ res = mix(E , P[0], 0.25);
+ }
+ else if (edr.y > 0.0)
+ {
+ res = mix(E , P[1], 0.5);
+ }
+ }
+ }
+ else
+ {
+ if (fp.y >= 0.5)
+ {
+ if (edr.w > 0.0 && edr_left.w > 0.0 && edr_up.w > 0.0)
+ {
+ res = mix(E , P[3], 0.833333);
+ }
+ else if (edr.w > 0.0 && (edr_left.w > 0.0 || edr_up.w > 0.0))
+ {
+ res = mix(E , P[3], 0.75);
+ }
+ else if (edr.x > 0.0 && edr_left.x > 0.0 && edr.z > 0.0 && edr_up.z > 0.0)
+ {
+ res = mix(E , P[0], 0.25);
+ res = mix(E , P[2], 0.25);
+ }
+ else if (edr.x > 0.0 && edr_left.x > 0.0)
+ {
+ res = mix(E , P[0], 0.25);
+ }
+ else if (edr.z > 0.0 && edr_up.z > 0.0)
+ {
+ res = mix(E , P[2], 0.25);
+ }
+ else if (edr.w > 0.0)
+ {
+ res = mix(E , P[3], 0.5);
+ }
+ }
+ else
+ {
+ if (edr.z > 0.0 && edr_left.z > 0.0 && edr_up.z > 0.0)
+ {
+ res = mix(E , P[2], 0.833333);
+ }
+ else if (edr.z > 0.0 && (edr_left.z > 0.0 || edr_up.z > 0.0))
+ {
+ res = mix(E , P[2], 0.75);
+ }
+ else if (edr.w > 0.0 && edr_left.w > 0.0 && edr.y > 0.0 && edr_up.y > 0.0)
+ {
+ res = mix(E , P[3], 0.25);
+ res = mix(E , P[1], 0.25);
+ }
+ else if (edr.w > 0.0 && edr_left.w > 0.0)
+ {
+ res = mix(E , P[3], 0.25);
+ }
+ else if (edr.y > 0.0 && edr_up.y > 0.0)
+ {
+ res = mix(E , P[1], 0.25);
+ }
+ else if (edr.z > 0.0)
+ {
+ res = mix(E, P[2], 0.5);
+ }
+ }
+ }
+ }
+
+ gl_FragColor = vec4(res.xyz, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v2-gamma.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v2-gamma.sc
new file mode 100644
index 00000000000..ea58584408b
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v2-gamma.sc
@@ -0,0 +1,265 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - beta1
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+uniform vec4 u_tex_size0;
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+const vec4 delta = vec4(0.5, 0.5, 0.5, 0.5);
+
+// Constants used with gamma correction.
+#define InputGamma 2.4
+#define OutputGamma 2.2
+
+#define GAMMA_IN(color) pow(color, vec3(InputGamma, InputGamma, InputGamma))
+#define GAMMA_OUT(color) pow(color, vec3(1.0 / OutputGamma, 1.0 / OutputGamma, 1.0 / OutputGamma))
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+vec4 lt_coeff(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ge_coeff(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 lt_coeff2(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 ge_coeff2(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec3 lt3(vec3 A, vec3 B)
+{
+ return vec3(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec3 gt3(vec3 A, vec3 B)
+{
+ return vec3(greaterThan(A, B));
+}
+
+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()
+{
+ 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ vec4 a = c.yzwx;
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ // 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_lv1 = clamp((ne(e,f) * ne(e,h) * ((lt_coeff2(e,b) + lt_coeff2(e,d) + ge_coeff2(e,a)) * (lt_coeff2(f,f4) + lt_coeff2(f,c) + lt_coeff2(h,h5) + lt_coeff2(h,g))) * ( ge_coeff(f,b) * ge_coeff(f,c) + ge_coeff(h,d) * ge_coeff(h,g) + lt_coeff(e,i) * (ge_coeff(f,f4) * ge_coeff(f,i4) + ge_coeff(h,h5) * ge_coeff(h,i5)) + lt_coeff(e,g) + lt_coeff(e,c))), 0.0, 1.0);
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 fx45 = smoothstep(Co - delta, Co + delta, fx);
+ vec4 fx30 = smoothstep(Cx - delta, Cx + delta, fx_left);
+ vec4 fx60 = smoothstep(Cy - delta, Cy + delta, fx_up);
+
+ vec4 edr = lt((weighted_distance(e, c, g, i, h5, f4, h, f) + 3.5), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up;
+
+ vec4 nc45 = edr * fx45;
+ vec4 nc30 = edr * edr_left * fx30;
+ vec4 nc60 = edr * edr_up * fx60;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec3 res = E.xyz;
+
+ vec3 n1 = B1.xyz;
+ vec3 n2 = B.xyz;
+ vec3 s = E.xyz;
+ vec3 n3 = H.xyz;
+ vec3 n4 = H5.xyz;
+
+ vec3 aa = n2 - n1;
+ vec3 bb = s - n2;
+ vec3 cc = n3 - s;
+ vec3 dd = n4 - n3;
+
+ vec3 t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ vec3 m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, 2.0 * abs(bb));
+ m = min(m, 2.0 * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s1 = (2.0 * fp.y - 1.0) * t + s;
+
+ n1 = D0.xyz;
+ n2 = D.xyz;
+ s = s1;
+ n3 = F.xyz;
+ n4 = F4.xyz;
+
+ aa = n2 - n1;
+ bb = s - n2;
+ cc = n3 - s;
+ dd = n4 - n3;
+
+ t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, 2.0 * abs(bb));
+ m = min(m, 2.0 * abs(cc));
+ t = clamp(t, -m, m);
+
+ res = (2.0 * fp.x - 1.0) * t + s;
+
+ vec4 nc = clamp(nc30 + nc60 + nc45, 0.0, 1.0);
+
+ float blend = 0.0;
+ vec3 pix = res;
+
+ float final45 = dot(nc45, fx45);
+ float final30 = dot(nc30, fx30);
+ float final60 = dot(nc60, fx60);
+
+ float maximo = max(max(final30, final60), final45);
+
+ if (nc.x > 0.0) {pix = px.x > 0.0 ? F.xyz : H.xyz; blend = maximo;}
+ else if (nc.y > 0.0) {pix = px.y > 0.0 ? B.xyz : F.xyz; blend = maximo;}
+ else if (nc.z > 0.0) {pix = px.z > 0.0 ? D.xyz : B.xyz; blend = maximo;}
+ else if (nc.w > 0.0) {pix = px.w > 0.0 ? H.xyz : D.xyz; blend = maximo;}
+
+ res = GAMMA_IN(res);
+ pix = GAMMA_IN(pix);
+
+ res = mix(res, pix, blend);
+
+ gl_FragColor = vec4(clamp(GAMMA_OUT(res), 0.0, 1.0), 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v2.sc
new file mode 100644
index 00000000000..a4e59937d54
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v2.sc
@@ -0,0 +1,255 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - Dithering preserved
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+uniform vec4 u_tex_size0;
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+const vec4 delta = vec4(0.5, 0.5, 0.5, 0.5);
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+vec4 lt_coeff(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ge_coeff(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 lt_coeff2(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 ge_coeff2(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec3 lt3(vec3 A, vec3 B)
+{
+ return vec3(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec3 gt3(vec3 A, vec3 B)
+{
+ return vec3(greaterThan(A, B));
+}
+
+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()
+{
+ 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ vec4 a = c.yzwx;
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ // 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_lv1 = clamp((ne(e,f) * ne(e,h) * ((lt_coeff2(e,b) + lt_coeff2(e,d) + ge_coeff2(e,a)) * (lt_coeff2(f,f4) + lt_coeff2(f,c) + lt_coeff2(h,h5) + lt_coeff2(h,g))) * ( ge_coeff(f,b) * ge_coeff(f,c) + ge_coeff(h,d) * ge_coeff(h,g) + lt_coeff(e,i) * (ge_coeff(f,f4) * ge_coeff(f,i4) + ge_coeff(h,h5) * ge_coeff(h,i5)) + lt_coeff(e,g) + lt_coeff(e,c))), 0.0, 1.0);
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 fx45 = smoothstep(Co - delta, Co + delta, fx);
+ vec4 fx30 = smoothstep(Cx - delta, Cx + delta, fx_left);
+ vec4 fx60 = smoothstep(Cy - delta, Cy + delta, fx_up);
+
+ vec4 edr = lt((weighted_distance(e, c, g, i, h5, f4, h, f) + 3.5), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up;
+
+ vec4 nc45 = edr * fx45;
+ vec4 nc30 = edr * edr_left * fx30;
+ vec4 nc60 = edr * edr_up * fx60;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec3 res = E.xyz;
+
+ vec3 n1 = B1.xyz;
+ vec3 n2 = B.xyz;
+ vec3 s = E.xyz;
+ vec3 n3 = H.xyz;
+ vec3 n4 = H5.xyz;
+
+ vec3 aa = n2 - n1;
+ vec3 bb = s - n2;
+ vec3 cc = n3 - s;
+ vec3 dd = n4 - n3;
+
+ vec3 t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ vec3 m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, 2.0 * abs(bb));
+ m = min(m, 2.0 * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s1 = (2.0 * fp.y - 1.0) * t + s;
+
+ n1 = D0.xyz;
+ n2 = D.xyz;
+ s = s1;
+ n3 = F.xyz;
+ n4 = F4.xyz;
+
+ aa = n2 - n1;
+ bb = s - n2;
+ cc = n3 - s;
+ dd = n4 - n3;
+
+ t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, 2.0 * abs(bb));
+ m = min(m, 2.0 * abs(cc));
+ t = clamp(t, -m, m);
+
+ res = (2.0 * fp.x - 1.0) * t + s;
+
+ vec4 nc = clamp(nc30 + nc60 + nc45, 0.0, 1.0);
+
+ float blend = 0.0;
+ vec3 pix = res;
+
+ float final45 = dot(nc45, fx45);
+ float final30 = dot(nc30, fx30);
+ float final60 = dot(nc60, fx60);
+
+ float maximo = max(max(final30, final60), final45);
+
+ if (nc.x > 0.0) {pix = px.x > 0.0 ? F.xyz : H.xyz; blend = maximo;}
+ else if (nc.y > 0.0) {pix = px.y > 0.0 ? B.xyz : F.xyz; blend = maximo;}
+ else if (nc.z > 0.0) {pix = px.z > 0.0 ? D.xyz : B.xyz; blend = maximo;}
+ else if (nc.w > 0.0) {pix = px.w > 0.0 ? H.xyz : D.xyz; blend = maximo;}
+
+ res = mix(res, pix, blend);
+
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4-gamma.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4-gamma.sc
new file mode 100644
index 00000000000..254e8d878cb
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4-gamma.sc
@@ -0,0 +1,281 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - beta3
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+uniform vec4 u_tex_size0;
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+const vec4 delta = vec4(0.5, 0.5, 0.5, 0.5);
+const float sharpness = 0.65;
+
+// Constants used with gamma correction.
+#define InputGamma 2.4
+#define OutputGamma 2.2
+
+#define GAMMA_IN(color) pow(color, vec3(InputGamma, InputGamma, InputGamma))
+#define GAMMA_OUT(color) pow(color, vec3(1.0 / OutputGamma, 1.0 / OutputGamma, 1.0 / OutputGamma))
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 lt_coeff(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ge_coeff(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 lt_coeff2(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 ge_coeff2(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec3 lt3(vec3 A, vec3 B)
+{
+ return vec3(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec3 gt3(vec3 A, vec3 B)
+{
+ return vec3(greaterThan(A, B));
+}
+
+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()
+{
+ 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ vec4 a = c.yzwx;
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ // 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_lv1 = clamp((ne(e,f) * ne(e,h) * (ge_coeff(f,b) * ge_coeff(f,c) + ge_coeff(h,d) * ge_coeff(h,g) + lt_coeff(e,i) * (ge_coeff(f,f4) * ge_coeff(f,i4) + ge_coeff(h,h5) * ge_coeff(h,i5)) + lt_coeff(e,g) + lt_coeff(e,c))), 0.0, 1.0);
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 fx45 = smoothstep(Co - delta, Co + delta, fx);
+ vec4 fx30 = smoothstep(Cx - delta, Cx + delta, fx_left);
+ vec4 fx60 = smoothstep(Cy - delta, Cy + delta, fx_up);
+
+ vec4 edr = lt((weighted_distance(e, c, g, i, h5, f4, h, f) + 3.5), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up;
+
+ vec4 nc45 = edr * fx45;
+ vec4 nc30 = edr * edr_left * fx30;
+ vec4 nc60 = edr * edr_up * fx60;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec3 res = E.xyz;
+
+ vec3 n1 = B1.xyz;
+ vec3 n2 = B.xyz;
+ vec3 s = E.xyz;
+ vec3 n3 = H.xyz;
+ vec3 n4 = H5.xyz;
+
+ vec3 aa = n2 - n1;
+ vec3 bb = s - n2;
+ vec3 cc = n3 - s;
+ vec3 dd = n4 - n3;
+
+ vec3 t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ vec3 m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, sharpness * abs(bb));
+ m = min(m, sharpness * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s1 = (2.0 * fp.y - 1.0) * t + s;
+
+ n1 = D0.xyz;
+ n2 = D.xyz;
+ s = s1;
+ n3 = F.xyz;
+ n4 = F4.xyz;
+
+ aa = n2 - n1;
+ bb = s - n2;
+ cc = n3 - s;
+ dd = n4 - n3;
+
+ t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, sharpness * abs(bb));
+ m = min(m, sharpness * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s0 = (2.0 * fp.x - 1.0) * t + s;
+
+ vec4 nc = clamp(nc30 + nc60 + nc45, 0.0, 1.0);
+
+ float blend1 = 0.0;
+ float blend2 = 0.0;
+
+ vec4 final45 = nc45 * fx45;
+ vec4 final30 = nc30 * fx30;
+ vec4 final60 = nc60 * fx60;
+
+ vec4 maximo = max(max(final30, final60), final45);
+
+ vec3 pix1 = vec3(0.0, 0.0, 0.0);
+ if (nc.x > 0.0) {pix1 = px.x > 0.0 ? F.xyz : H.xyz; blend1 = maximo.x;}
+ else if (nc.y > 0.0) {pix1 = px.y > 0.0 ? B.xyz : F.xyz; blend1 = maximo.y;}
+ else if (nc.z > 0.0) {pix1 = px.z > 0.0 ? D.xyz : B.xyz; blend1 = maximo.z;}
+ else if (nc.w > 0.0) {pix1 = px.w > 0.0 ? H.xyz : D.xyz; blend1 = maximo.w;}
+
+ vec3 pix2 = vec3(0.0, 0.0, 0.0);
+ if (nc.w > 0.0) {pix2 = px.w > 0.0 ? H.xyz : D.xyz; blend2 = maximo.w;}
+ else if (nc.z > 0.0) {pix2 = px.z > 0.0 ? D.xyz : B.xyz; blend2 = maximo.z;}
+ else if (nc.y > 0.0) {pix2 = px.y > 0.0 ? B.xyz : F.xyz; blend2 = maximo.y;}
+ else if (nc.x > 0.0) {pix2 = px.x > 0.0 ? F.xyz : H.xyz; blend2 = maximo.x;}
+
+ E.xyz = GAMMA_IN(E.xyz);
+ s0 = GAMMA_IN(s0);
+
+ vec3 res1 = mix(s0, GAMMA_IN(pix1), blend1);
+ vec3 res2 = mix(s0, GAMMA_IN(pix2), blend2);
+
+ res = mix(res1, res2, step(c_df(E.xyz, res1), c_df(E.xyz, res2)));
+
+ gl_FragColor = vec4(clamp(GAMMA_OUT(res), 0.0, 1.0), 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4.sc
new file mode 100644
index 00000000000..e3791fed702
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4.sc
@@ -0,0 +1,271 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - v4
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+uniform vec4 u_tex_size0;
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+const vec4 delta = vec4(0.5, 0.5, 0.5, 0.5);
+const float sharpness = 0.65;
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 lt_coeff(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ge_coeff(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 lt_coeff2(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 ge_coeff2(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec3 lt3(vec3 A, vec3 B)
+{
+ return vec3(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec3 gt3(vec3 A, vec3 B)
+{
+ return vec3(greaterThan(A, B));
+}
+
+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()
+{
+ 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ vec4 a = c.yzwx;
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ // 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_lv1 = clamp((ne(e,f) * ne(e,h) * (ge_coeff(f,b) * ge_coeff(f,c) + ge_coeff(h,d) * ge_coeff(h,g) + lt_coeff(e,i) * (ge_coeff(f,f4) * ge_coeff(f,i4) + ge_coeff(h,h5) * ge_coeff(h,i5)) + lt_coeff(e,g) + lt_coeff(e,c))), 0.0, 1.0);
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 fx45 = smoothstep(Co - delta, Co + delta, fx);
+ vec4 fx30 = smoothstep(Cx - delta, Cx + delta, fx_left);
+ vec4 fx60 = smoothstep(Cy - delta, Cy + delta, fx_up);
+
+ vec4 edr = lt((weighted_distance(e, c, g, i, h5, f4, h, f) + 3.5), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up;
+
+ vec4 nc45 = edr * fx45;
+ vec4 nc30 = edr * edr_left * fx30;
+ vec4 nc60 = edr * edr_up * fx60;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec3 res = E.xyz;
+
+ vec3 n1 = B1.xyz;
+ vec3 n2 = B.xyz;
+ vec3 s = E.xyz;
+ vec3 n3 = H.xyz;
+ vec3 n4 = H5.xyz;
+
+ vec3 aa = n2 - n1;
+ vec3 bb = s - n2;
+ vec3 cc = n3 - s;
+ vec3 dd = n4 - n3;
+
+ vec3 t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ vec3 m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, sharpness * abs(bb));
+ m = min(m, sharpness * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s1 = (2.0 * fp.y - 1.0) * t + s;
+
+ n1 = D0.xyz;
+ n2 = D.xyz;
+ s = s1;
+ n3 = F.xyz;
+ n4 = F4.xyz;
+
+ aa = n2 - n1;
+ bb = s - n2;
+ cc = n3 - s;
+ dd = n4 - n3;
+
+ t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, sharpness * abs(bb));
+ m = min(m, sharpness * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s0 = (2.0 * fp.x - 1.0) * t + s;
+
+ vec4 nc = clamp(nc30 + nc60 + nc45, 0.0, 1.0);
+
+ float blend1 = 0.0;
+ float blend2 = 0.0;
+
+ vec4 final45 = nc45 * fx45;
+ vec4 final30 = nc30 * fx30;
+ vec4 final60 = nc60 * fx60;
+
+ vec4 maximo = max(max(final30, final60), final45);
+
+ vec3 pix1 = vec3(0.0, 0.0, 0.0);
+ if (nc.x > 0.0) {pix1 = px.x > 0.0 ? F.xyz : H.xyz; blend1 = maximo.x;}
+ else if (nc.y > 0.0) {pix1 = px.y > 0.0 ? B.xyz : F.xyz; blend1 = maximo.y;}
+ else if (nc.z > 0.0) {pix1 = px.z > 0.0 ? D.xyz : B.xyz; blend1 = maximo.z;}
+ else if (nc.w > 0.0) {pix1 = px.w > 0.0 ? H.xyz : D.xyz; blend1 = maximo.w;}
+
+ vec3 pix2 = vec3(0.0, 0.0, 0.0);
+ if (nc.w > 0.0) {pix2 = px.w > 0.0 ? H.xyz : D.xyz; blend2 = maximo.w;}
+ else if (nc.z > 0.0) {pix2 = px.z > 0.0 ? D.xyz : B.xyz; blend2 = maximo.z;}
+ else if (nc.y > 0.0) {pix2 = px.y > 0.0 ? B.xyz : F.xyz; blend2 = maximo.y;}
+ else if (nc.x > 0.0) {pix2 = px.x > 0.0 ? F.xyz : H.xyz; blend2 = maximo.x;}
+
+ vec3 res1 = mix(s0, pix1, blend1);
+ vec3 res2 = mix(s0, pix2, blend2);
+
+ res = mix(res1, res2, step(c_df(E.xyz, res1), c_df(E.xyz, res2)));
+
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4b.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4b.sc
new file mode 100644
index 00000000000..858342d25c6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v4b.sc
@@ -0,0 +1,256 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8b+ReverseAA (semi-rounded) Shader - v4
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+uniform vec4 u_tex_size0;
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+const vec4 delta = vec4(0.5, 0.5, 0.5, 0.5);
+const float sharpness = 0.65;
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 lt_coeff(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ge_coeff(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec3 lt3(vec3 A, vec3 B)
+{
+ return vec3(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+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()
+{
+ 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ vec4 a = c.yzwx;
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ // 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_lv1 = clamp((ne(e,f) * ne(e,h) * (ge_coeff(f,b) * ge_coeff(h,d) + lt_coeff(e,i) * ge_coeff(f,i4) * ge_coeff(h,i5) + lt_coeff(e,g) + lt_coeff(e,c))), 0.0, 1.0);
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 fx45 = smoothstep(Co - delta, Co + delta, fx);
+ vec4 fx30 = smoothstep(Cx - delta, Cx + delta, fx_left);
+ vec4 fx60 = smoothstep(Cy - delta, Cy + delta, fx_up);
+
+ vec4 edr = lt((weighted_distance(e, c, g, i, h5, f4, h, f) + 3.5), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up;
+
+ vec4 nc45 = edr * fx45;
+ vec4 nc30 = edr * edr_left * fx30;
+ vec4 nc60 = edr * edr_up * fx60;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec3 res = E.xyz;
+
+ vec3 n1 = B1.xyz;
+ vec3 n2 = B.xyz;
+ vec3 s = E.xyz;
+ vec3 n3 = H.xyz;
+ vec3 n4 = H5.xyz;
+
+ vec3 aa = n2 - n1;
+ vec3 bb = s - n2;
+ vec3 cc = n3 - s;
+ vec3 dd = n4 - n3;
+
+ vec3 t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ vec3 m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, sharpness * abs(bb));
+ m = min(m, sharpness * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s1 = (2.0 * fp.y - 1.0) * t + s;
+
+ n1 = D0.xyz;
+ n2 = D.xyz;
+ s = s1;
+ n3 = F.xyz;
+ n4 = F4.xyz;
+
+ aa = n2 - n1;
+ bb = s - n2;
+ cc = n3 - s;
+ dd = n4 - n3;
+
+ t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, sharpness * abs(bb));
+ m = min(m, sharpness * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s0 = (2.0 * fp.x - 1.0) * t + s;
+
+ vec4 nc = clamp(nc30 + nc60 + nc45, 0.0, 1.0);
+
+ float blend1 = 0.0;
+ float blend2 = 0.0;
+
+ vec4 final45 = nc45 * fx45;
+ vec4 final30 = nc30 * fx30;
+ vec4 final60 = nc60 * fx60;
+
+ vec4 maximo = max(max(final30, final60), final45);
+
+ vec3 pix1 = vec3(0.0, 0.0, 0.0);
+ if (nc.x > 0.0) {pix1 = px.x > 0.0 ? F.xyz : H.xyz; blend1 = maximo.x;}
+ else if (nc.y > 0.0) {pix1 = px.y > 0.0 ? B.xyz : F.xyz; blend1 = maximo.y;}
+ else if (nc.z > 0.0) {pix1 = px.z > 0.0 ? D.xyz : B.xyz; blend1 = maximo.z;}
+ else if (nc.w > 0.0) {pix1 = px.w > 0.0 ? H.xyz : D.xyz; blend1 = maximo.w;}
+
+ vec3 pix2 = vec3(0.0, 0.0, 0.0);
+ if (nc.w > 0.0) {pix2 = px.w > 0.0 ? H.xyz : D.xyz; blend2 = maximo.w;}
+ else if (nc.z > 0.0) {pix2 = px.z > 0.0 ? D.xyz : B.xyz; blend2 = maximo.z;}
+ else if (nc.y > 0.0) {pix2 = px.y > 0.0 ? B.xyz : F.xyz; blend2 = maximo.y;}
+ else if (nc.x > 0.0) {pix2 = px.x > 0.0 ? F.xyz : H.xyz; blend2 = maximo.x;}
+
+ vec3 res1 = mix(s0, pix1, blend1);
+ vec3 res2 = mix(s0, pix2, blend2);
+
+ res = mix(res1, res2, step(c_df(E.xyz, res1), c_df(E.xyz, res2)));
+
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v5-gamma.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v5-gamma.sc
new file mode 100644
index 00000000000..1a4ad25e765
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid-v5-gamma.sc
@@ -0,0 +1,288 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - beta3
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+uniform vec4 u_tex_size0;
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+const vec4 delta = vec4(0.5, 0.5, 0.5, 0.5);
+const float sharpness = 0.65;
+
+// Constants used with gamma correction.
+#define InputGamma 2.4
+#define OutputGamma 2.2
+
+#define GAMMA_IN(color) pow(color, vec3(InputGamma, InputGamma, InputGamma))
+#define GAMMA_OUT(color) pow(color, vec3(1.0 / OutputGamma, 1.0 / OutputGamma, 1.0 / OutputGamma))
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 lt_coeff(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ge_coeff(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 lt_coeff2(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 lt_coeff3(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(5.0, 5.0, 5.0, 5.0)));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec3 lt3(vec3 A, vec3 B)
+{
+ return vec3(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec3 gt3(vec3 A, vec3 B)
+{
+ return vec3(greaterThan(A, B));
+}
+
+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()
+{
+ 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ vec4 a = c.yzwx;
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ // 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_lv1 = clamp((ne(e,f) * ne(e,h) * (ge_coeff(f,b) * ge_coeff(f,c) + ge_coeff(h,d) * ge_coeff(h,g) + lt_coeff(e,i) * (ge_coeff(f,f4) * ge_coeff(f,i4) + ge_coeff(h,h5) * ge_coeff(h,i5)) + lt_coeff(e,g) + lt_coeff(e,c))), 0.0, 1.0);
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 fx45 = smoothstep(Co - delta, Co + delta, fx);
+ vec4 fx30 = smoothstep(Cx - delta, Cx + delta, fx_left);
+ vec4 fx60 = smoothstep(Cy - delta, Cy + delta, fx_up);
+
+ vec4 edr = lt((weighted_distance(e, c, g, i, h5, f4, h, f) + 3.5), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up;
+
+ vec4 nc45 = edr * fx45;
+ vec4 nc30 = edr * edr_left * fx30;
+ vec4 nc60 = edr * edr_up * fx60;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec3 res = E.xyz;
+
+ vec3 n1 = B1.xyz;
+ vec3 n2 = B.xyz;
+ vec3 s = E.xyz;
+ vec3 n3 = H.xyz;
+ vec3 n4 = H5.xyz;
+
+ vec3 aa = n2 - n1;
+ vec3 bb = s - n2;
+ vec3 cc = n3 - s;
+ vec3 dd = n4 - n3;
+
+ vec3 t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ vec3 m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, sharpness * abs(bb));
+ m = min(m, sharpness * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s1 = (2.0 * fp.y - 1.0) * t + s;
+
+ n1 = D0.xyz;
+ n2 = D.xyz;
+ s = s1;
+ n3 = F.xyz;
+ n4 = F4.xyz;
+
+ aa = n2 - n1;
+ bb = s - n2;
+ cc = n3 - s;
+ dd = n4 - n3;
+
+ t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, sharpness * abs(bb));
+ m = min(m, sharpness * abs(cc));
+ t = clamp(t, -m, m);
+
+ vec3 s0 = (2.0 * fp.x - 1.0) * t + s;
+
+ vec4 nc = clamp(nc30 + nc60 + nc45, 0.0, 1.0);
+
+ float blend = 0.0;
+
+ vec4 r1 = mix(e, f, edr);
+
+ vec4 yeseq3 = vec4(0.0, 0.0, 0.0, 0.0);
+
+ vec3 pix;
+ vec4 lt_res = lt_coeff3(r1,e);
+ if (lt_res.x > 0.0 && lt_res.y > 0.0 && lt_res.z > 0.0)
+ {
+ yeseq3 = vec4(1.0, 1.0, 1.0, 1.0);
+ pix = res = s0;
+ }
+ else
+ {
+ pix = res = E.xyz;
+ }
+
+ vec4 yes = (yeseq3 * lt_coeff2(e, mix(f, h, px)));
+
+ vec4 final45 = nc45 * fx45;
+ vec4 final30 = nc30 * fx30;
+ vec4 final60 = nc60 * fx60;
+
+ vec4 maximo = max(max(final30, final60), final45);
+
+ if (nc.x > 0.0) {pix = px.x > 0.0 ? F.xyz : H.xyz; blend = maximo.x; if (yes.x > 0.0) pix = res = s0; else res = E.xyz;}
+ else if (nc.y > 0.0) {pix = px.y > 0.0 ? B.xyz : F.xyz; blend = maximo.y; if (yes.y > 0.0) pix = res = s0; else res = E.xyz;}
+ else if (nc.z > 0.0) {pix = px.z > 0.0 ? D.xyz : B.xyz; blend = maximo.z; if (yes.z > 0.0) pix = res = s0; else res = E.xyz;}
+ else if (nc.w > 0.0) {pix = px.w > 0.0 ? H.xyz : D.xyz; blend = maximo.w; if (yes.w > 0.0) pix = res = s0; else res = E.xyz;}
+
+ res = GAMMA_IN(res);
+ pix = GAMMA_IN(pix);
+
+ res = mix(res, pix, blend);
+
+ gl_FragColor = vec4(clamp(GAMMA_OUT(res), 0.0, 1.0), 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid.sc
new file mode 100644
index 00000000000..bf3af2de385
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/fs_2xbr-hybrid.sc
@@ -0,0 +1,341 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
+
+// license:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.7c+ReverseAA (squared) Shader
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+uniform vec4 u_tex_size0;
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+vec4 lt_coeff(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ge_coeff(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), vec4(15.0, 15.0, 15.0, 15.0)));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec3 lt3(vec3 A, vec3 B)
+{
+ return vec3(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec3 le3(vec3 A, vec3 B)
+{
+ return vec3(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec3 gt3(vec3 A, vec3 B)
+{
+ return vec3(greaterThan(A, B));
+}
+
+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()
+{
+ 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 interp_restriction_lv1 = clamp((ne(e,f) * ne(e,h) * (ge_coeff(f,b) * ge_coeff(f,c) + ge_coeff(h,d) * ge_coeff(h,g) + lt_coeff(e,i) * (ge_coeff(f,f4) * ge_coeff(f,i4) + ge_coeff(h,h5) * ge_coeff(h,i5)) + lt_coeff(e,g) + lt_coeff(e,c))), 0.0, 1.0);
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 edr = lt(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec4 P[4];
+ P[0] = px.x > 0.0 ? F : H;
+ P[1] = px.y > 0.0 ? B : F;
+ P[2] = px.z > 0.0 ? D : B;
+ P[3] = px.w > 0.0 ? H : D;
+
+ vec4 res = E;
+
+ vec3 threshold = vec3(0.4, 0.4, 0.4);
+ vec3 xx = vec3(0.0, 0.0, 0.0);
+
+ vec3 n1 = B1.xyz;
+ vec3 n2 = B.xyz;
+ vec3 s = E.xyz;
+ vec3 n3 = H.xyz;
+ vec3 n4 = H5.xyz;
+
+ vec3 aa = n2 - n1;
+ vec3 bb = s - n2;
+ vec3 cc = n3 - s;
+ vec3 dd = n4 - n3;
+
+ vec3 t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ vec3 m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, 2.0 * abs(bb));
+ m = min(m, 2.0 * abs(cc));
+ vec3 sim1 = (gt3(abs(bb) * 2.0, threshold) + gt3(abs(cc) * 2.0, threshold) + le3(abs(bb) * 2.0, xx) + le3(abs(cc) * 2.0, xx));
+ t = clamp(t, -m, m);
+
+ vec3 s1 = (2.0 * fp.y - 1.0) * t + s;
+
+ n1 = D0.xyz;
+ n2 = D.xyz;
+ s = s1;
+ n3 = F.xyz;
+ n4 = F4.xyz;
+
+ aa = n2 - n1;
+ bb = s - n2;
+ cc = n3 - s;
+ dd = n4 - n3;
+
+ t = (7.0 * (bb + cc) - 3.0 * (aa + dd)) / 16.0;
+ m = mix(2.0 * (1.0 - s), 2.0 * s, lt3(s, vec3(0.5, 0.5, 0.5)));
+
+ m = min(m, 2.0 * abs(bb));
+ m = min(m, 2.0 * abs(cc));
+ vec3 sim2 = (gt3(abs(bb) * 2.0, threshold) + gt3(abs(cc) * 2.0, threshold) + le3(abs(bb) * 2.0, xx) + le3(abs(cc) * 2.0, xx));
+ t = clamp(t, -m, m);
+
+ vec3 s0 = (2.0 * fp.x - 1.0) * t + s;
+
+ res = vec4(s0, 1.0);
+
+ if ((sim1.x > 0.0 || sim1.y > 0.0 || sim1.z > 0.0) && (sim2.x > 0.0 || sim2.y > 0.0 || sim2.z > 0.0))
+ {
+ if (fp.x >= 0.5)
+ {
+ if (fp.y >= 0.5)
+ {
+ if (edr.x > 0.0 && edr_left.x > 0.0 && edr_up.x > 0.0)
+ {
+ res = mix(E , P[0], 0.833333);
+ }
+ else if (edr.x > 0.0 && (edr_left.x > 0.0 || edr_up.x > 0.0))
+ {
+ res = mix(E , P[0], 0.75);
+ }
+ else if (edr.y > 0.0 && edr_left.y > 0.0 && edr.w > 0.0 && edr_up.w > 0.0)
+ {
+ res = mix(E , P[1], 0.25);
+ res = mix(E , P[3], 0.25);
+ }
+ else if (edr.y > 0.0 && edr_left.y > 0.0)
+ {
+ res = mix(E , P[1], 0.25);
+ }
+ else if (edr.w > 0.0 && edr_up.w > 0.0)
+ {
+ res = mix(E , P[3], 0.25);
+ }
+ else if (edr.x > 0.0)
+ {
+ res = mix(E , P[0], 0.5);
+ }
+ }
+ else
+ {
+ if (edr.y > 0.0 && edr_left.y > 0.0 && edr_up.y > 0.0)
+ {
+ res = mix(E , P[1], 0.833333);
+ }
+ else if (edr.y > 0.0 && (edr_left.y > 0.0 || edr_up.y > 0.0))
+ {
+ res = mix(E , P[1], 0.75);
+ }
+ else if (edr.z > 0.0 && edr_left.z > 0.0 && edr.x > 0.0 && edr_up.x > 0.0)
+ {
+ res = mix(E , P[2], 0.25);
+ res = mix(E , P[0], 0.25);
+ }
+ else if (edr.z > 0.0 && edr_left.z > 0.0)
+ {
+ res = mix(E , P[2], 0.25);
+ }
+ else if (edr.x > 0.0 && edr_up.x > 0.0)
+ {
+ res = mix(E , P[0], 0.25);
+ }
+ else if (edr.y > 0.0)
+ {
+ res = mix(E , P[1], 0.5);
+ }
+ }
+ }
+ else
+ {
+ if (fp.y >= 0.5)
+ {
+ if (edr.w > 0.0 && edr_left.w > 0.0 && edr_up.w > 0.0)
+ {
+ res = mix(E , P[3], 0.833333);
+ }
+ else if (edr.w > 0.0 && (edr_left.w > 0.0 || edr_up.w > 0.0))
+ {
+ res = mix(E , P[3], 0.75);
+ }
+ else if (edr.x > 0.0 && edr_left.x > 0.0 && edr.z > 0.0 && edr_up.z > 0.0)
+ {
+ res = mix(E , P[0], 0.25);
+ res = mix(E , P[2], 0.25);
+ }
+ else if (edr.x > 0.0 && edr_left.x > 0.0)
+ {
+ res = mix(E , P[0], 0.25);
+ }
+ else if (edr.z > 0.0 && edr_up.z > 0.0)
+ {
+ res = mix(E , P[2], 0.25);
+ }
+ else if (edr.w > 0.0)
+ {
+ res = mix(E , P[3], 0.5);
+ }
+ }
+ else
+ {
+ if (edr.z > 0.0 && edr_left.z > 0.0 && edr_up.z > 0.0)
+ {
+ res = mix(E , P[2], 0.833333);
+ }
+ else if (edr.z > 0.0 && (edr_left.z > 0.0 || edr_up.z > 0.0))
+ {
+ res = mix(E , P[2], 0.75);
+ }
+ else if (edr.w > 0.0 && edr_left.w > 0.0 && edr.y > 0.0 && edr_up.y > 0.0)
+ {
+ res = mix(E , P[3], 0.25);
+ res = mix(E , P[1], 0.25);
+ }
+ else if (edr.w > 0.0 && edr_left.w > 0.0)
+ {
+ res = mix(E , P[3], 0.25);
+ }
+ else if (edr.y > 0.0 && edr_up.y > 0.0)
+ {
+ res = mix(E , P[1], 0.25);
+ }
+ else if (edr.z > 0.0)
+ {
+ res = mix(E, P[2], 0.5);
+ }
+ }
+ }
+ }
+
+ gl_FragColor = vec4(res.xyz, 1.0);
+} \ No newline at end of file
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/xbr-hybrid/varying.def.sc
index c65b5426733..92c3034f498 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-lv1-noblend/varying.def.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/varying.def.sc
@@ -4,6 +4,9 @@ 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;
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-sharp.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-sharp.sc
new file mode 100644
index 00000000000..339c44e284c
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-sharp.sc
@@ -0,0 +1,72 @@
+$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:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.7c+ReverseAA (squared) Shader
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#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;
+
+ // A1 B1 C1
+ // A0 A B C C4
+ // D0 D E F F4
+ // G0 G H I I4
+ // G5 H5 I5
+
+ // This line fix a bug in ATI cards.
+ vec2 texCoord = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ 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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v2-gamma.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v2-gamma.sc
new file mode 100644
index 00000000000..9d5468107dd
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v2-gamma.sc
@@ -0,0 +1,72 @@
+$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:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - beta1
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#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;
+
+ // A1 B1 C1
+ // A0 A B C C4
+ // D0 D E F F4
+ // G0 G H I I4
+ // G5 H5 I5
+
+ // This line fix a bug in ATI cards.
+ vec2 texCoord = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ 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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v2.sc
new file mode 100644
index 00000000000..8e73b14f713
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v2.sc
@@ -0,0 +1,72 @@
+$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:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - Dithering preserved
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#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;
+
+ // A1 B1 C1
+ // A0 A B C C4
+ // D0 D E F F4
+ // G0 G H I I4
+ // G5 H5 I5
+
+ // This line fix a bug in ATI cards.
+ vec2 texCoord = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ 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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4-gamma.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4-gamma.sc
new file mode 100644
index 00000000000..b4509adf38c
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4-gamma.sc
@@ -0,0 +1,72 @@
+$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:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - beta3
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#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;
+
+ // A1 B1 C1
+ // A0 A B C C4
+ // D0 D E F F4
+ // G0 G H I I4
+ // G5 H5 I5
+
+ // This line fix a bug in ATI cards.
+ vec2 texCoord = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ 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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4.sc
new file mode 100644
index 00000000000..b00c03fbce3
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4.sc
@@ -0,0 +1,72 @@
+$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:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - v4
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#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;
+
+ // A1 B1 C1
+ // A0 A B C C4
+ // D0 D E F F4
+ // G0 G H I I4
+ // G5 H5 I5
+
+ // This line fix a bug in ATI cards.
+ vec2 texCoord = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ 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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4b.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4b.sc
new file mode 100644
index 00000000000..2a33ced4126
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v4b.sc
@@ -0,0 +1,72 @@
+$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:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8b+ReverseAA (semi-rounded) Shader - v4
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#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;
+
+ // A1 B1 C1
+ // A0 A B C C4
+ // D0 D E F F4
+ // G0 G H I I4
+ // G5 H5 I5
+
+ // This line fix a bug in ATI cards.
+ vec2 texCoord = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ 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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v5-gamma.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v5-gamma.sc
new file mode 100644
index 00000000000..b4509adf38c
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid-v5-gamma.sc
@@ -0,0 +1,72 @@
+$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:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.8c+ReverseAA (squared) Shader - beta3
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#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;
+
+ // A1 B1 C1
+ // A0 A B C C4
+ // D0 D E F F4
+ // G0 G H I I4
+ // G5 H5 I5
+
+ // This line fix a bug in ATI cards.
+ vec2 texCoord = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ 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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid.sc
new file mode 100644
index 00000000000..339c44e284c
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-hybrid/vs_2xbr-hybrid.sc
@@ -0,0 +1,72 @@
+$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:GPL-2.0+
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's 2xBR v3.7c+ReverseAA (squared) Shader
+
+ Copyright (C) 2011/2012 Hyllian/Jararaca - sergiogdb@gmail.com
+*/
+
+/*
+ * ReverseAA part of the code
+ *
+ * Copyright (c) 2012, Christoph Feck <christoph@maxiom.de>
+ * All Rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#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;
+
+ // A1 B1 C1
+ // A0 A B C C4
+ // D0 D E F F4
+ // G0 G H I I4
+ // G5 H5 I5
+
+ // This line fix a bug in ATI cards.
+ vec2 texCoord = a_texcoord0 + vec2(0.0000001, 0.0000001);
+ 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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-a-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-a-pass0.sc
new file mode 100644
index 00000000000..5af6ea86cc4
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-a-pass0.sc
@@ -0,0 +1,159 @@
+$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 A (squared) - pass0 Shader
+
+ 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"
+
+SAMPLER2D(decal, 0);
+
+#define round(X) floor((X)+0.5)
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const float y_weight = 48.0;
+const float u_weight = 7.0;
+const float v_weight = 6.0;
+const mat4 yuv = mat4(
+ 0.299, 0.587, 0.114, 0.0,
+ -0.169, -0.331, 0.499, 0.0,
+ 0.499, -0.418, -0.0813, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+);
+
+const mat4 yuv_weighted = mat4(
+ 48.0 * vec4( 0.299, 0.587, 0.114, 0.0),
+ 7.0 * vec4(-0.169, -0.331, 0.499, 0.0),
+ 6.0 * vec4( 0.499, -0.418, -0.0813, 0.0),
+ 0.0 * vec4( 0.0, 0.0, 0.0, 0.0)
+);
+const vec4 delta = vec4(0.4, 0.4, 0.4, 0.4);
+
+vec3 remapTo01(vec3 v, vec3 low, vec3 high)
+{
+ return saturate((v - low) / (high-low));
+}
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+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 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 interp_restriction_lv1 = (ne(e,f) * ne(e,h));
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ vec4 edr = lt(weighted_distance(e, c, g, i, h5, f4, h, f), weighted_distance(h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up * edr;
+
+ vec3 info;
+
+ info.x = dot(edr, vec4(8.0, 4.0, 2.0, 1.0));
+ info.y = dot(edr_left, vec4(8.0, 4.0, 2.0, 1.0));
+ info.z = dot(edr_up, vec4(8.0, 4.0, 2.0, 1.0));
+
+ gl_FragColor = vec4(remapTo01(info, vec3(0.0, 0.0, 0.0), vec3(255.0, 255.0, 255.0)), 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-accuracy-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-accuracy-pass0.sc
new file mode 100644
index 00000000000..668922ec18c
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-accuracy-pass0.sc
@@ -0,0 +1,174 @@
+$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 Accuracy - pass0 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"
+
+SAMPLER2D(decal, 0);
+
+uniform vec4 XBR_EQ_THRESHOLD;
+uniform vec4 XBR_LV2_COEFFICIENT;
+
+#define XBR_RED_COEF 17.0
+#define XBR_GREEN_COEF 20.0
+#define XBR_BLUE_COEF 3.0
+
+#define coef XBR_LV2_COEFFICIENT.xxxx
+
+const vec4 dtt = vec4(65536.0, 256.0, 1.0, 0.0);
+
+vec4 remapTo01(vec4 v, vec4 low, vec4 high)
+{
+ return saturate((v - low)/(high-low));
+}
+
+float df1(vec4 A, vec4 B)
+{
+ float rmean = (A.r + B.r) / 2.0;
+ vec4 diff = A - B;
+ vec4 K = vec4(XBR_RED_COEF + rmean, XBR_GREEN_COEF, XBR_BLUE_COEF - rmean, 0.0);
+
+ return sqrt(dot(K * diff, diff));
+}
+
+vec4 df(mat4 A, mat4 B)
+{
+ return vec4(df1(A[0],B[0]), df1(A[1],B[1]), df1(A[2],B[2]), df1(A[3],B[3]));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 lt4(mat4 A, mat4 B)
+{
+ return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD.xxxx));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+vec4 weighted_distance(mat4 a, mat4 b, mat4 c, mat4 d, mat4 e, mat4 f, mat4 g, mat4 h)
+{
+ return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
+}
+
+void main()
+{
+ 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), dtt);
+ vec4 c_ = mul(mat4(C, A, G, I), dtt);
+ vec4 e_ = mul(mat4(E, E, E, E), dtt);
+ 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), dtt);
+ vec4 i5_ = mul(mat4(I5, C4, A1, G0), dtt);
+ vec4 h5_ = mul(mat4(H5, F4, B1, D0), dtt);
+ vec4 f4_ = h5_.yzwx;
+
+ mat4 b = mat4(B, D, H, F);
+ mat4 c = mat4(C, A, G, I);
+ mat4 e = mat4(E, E, E, E);
+ mat4 d = mat4(D, H, F, B);
+ mat4 f = mat4(F, B, D, H);
+ mat4 g = mat4(G, I, C, A);
+ mat4 h = mat4(H, F, B, D);
+ mat4 i = mat4(I, C, A, G);
+
+ mat4 i4 = mat4(I4, C1, A0, G5);
+ mat4 i5 = mat4(I5, C4, A1, G0);
+ mat4 h5 = mat4(H5, F4, B1, D0);
+ mat4 f4 = mat4(F4, B1, D0, H5);
+
+ vec4 interp_restriction_lv1 = ne(e_,f_) * ne(e_,h_);
+ vec4 interp_restriction_lv2_left = ne(e_,g_) * ne(d_,g_);
+ vec4 interp_restriction_lv2_up = ne(e_,c_) * ne(b_,c_);
+
+ 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 edri = le(wd1,wd2) * interp_restriction_lv1;
+ vec4 edr = clamp(lt(wd1,wd2) * ((one - edri.yzwx) + (one - edri.wxyz)) * interp_restriction_lv1, 0.0, 1.0);
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr * (one - edri.yzwx) * lt4(e, c);
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up * edr * (one - edri.wxyz) * lt4(e, g);
+
+ vec4 info;
+ info.x = dot(edr, vec4(8.0, 4.0, 2.0, 1.0));
+ info.y = dot(edr_left, vec4(8.0, 4.0, 2.0, 1.0));
+ info.z = dot(edr_up, vec4(8.0, 4.0, 2.0, 1.0));
+ info.w = dot(edri, vec4(8.0, 4.0, 2.0, 1.0));
+
+ gl_FragColor = remapTo01(info, vec4(0.0, 0.0, 0.0, 0.0), vec4(255.0, 255.0, 255.0, 255.0));
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-accuracy-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-accuracy-pass1.sc
new file mode 100644
index 00000000000..a32605fca4e
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-accuracy-pass1.sc
@@ -0,0 +1,160 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 Accuracy - pass1 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"
+
+SAMPLER2D(decal, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 XBR_SCALE;
+uniform vec4 u_tex_size0;
+
+#define XBR_RED_COEF 17.0
+#define XBR_GREEN_COEF 20.0
+#define XBR_BLUE_COEF 3.0
+
+#define round(X) floor((X)+0.5)
+
+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);
+
+
+float df1(vec4 A, vec4 B)
+{
+ float rmean = (A.r + B.r)/2.0;
+ vec4 diff = A - B;
+ vec4 K = vec4(XBR_RED_COEF+rmean, XBR_GREEN_COEF, XBR_BLUE_COEF-rmean, 0.0);
+
+ return sqrt(dot(K * diff, diff));
+}
+
+vec4 df(mat4 A, mat4 B)
+{
+ return vec4(df1(A[0],B[0]), df1(A[1],B[1]), df1(A[2],B[2]), df1(A[3],B[3]));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 remapFrom01(vec4 v, vec4 low, vec4 high)
+{
+ return round(mix(low, high, v));
+}
+
+vec4 unpack_info(float i)
+{
+ vec4 info;
+ float frac_val = fract(i / 2.0f);
+ info.w = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.z = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.y = round(frac_val);
+ info.x = i / 2.0f - frac_val;
+
+ return info;
+}
+
+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 B = texture2D(ORIG_texture, v_texcoord1.xy);
+ vec4 D = texture2D(ORIG_texture, v_texcoord2.xw);
+ vec4 E = texture2D(ORIG_texture, v_texcoord2.yw);
+ vec4 F = texture2D(ORIG_texture, v_texcoord2.zw);
+ vec4 H = texture2D(ORIG_texture, v_texcoord1.xw);
+
+ mat4 b = mat4(B, D, H, F);
+ mat4 e = mat4(E, E, E, E);
+ mat4 d = mat4(D, H, F, B);
+ mat4 f = mat4(F, B, D, H);
+ mat4 h = mat4(H, F, B, D);
+
+ // 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 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 info = texture2D(decal, v_texcoord0);
+
+ vec4 i = remapFrom01(info, vec4(0.0, 0.0, 0.0, 0.0), vec4(255.0, 255.0, 255.0, 255.0));
+
+ vec4 edr = unpack_info(i.x);
+ vec4 edr_left = unpack_info(i.y);
+ vec4 edr_up = unpack_info(i.z);
+ vec4 edri = unpack_info(i.w);
+
+ fx45i = edri * fx45i;
+ fx45 = edr * fx45;
+ fx30 = edr_left * fx30;
+ fx60 = edr_up * fx60;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
+
+ vec4 res1 = E;
+ res1 = mix(res1, mix(H, F, px.x), maximos.x);
+ res1 = mix(res1, mix(B, D, px.z), maximos.z);
+
+ vec4 res2 = E;
+ res2 = mix(res2, mix(F, B, px.y), maximos.y);
+ res2 = mix(res2, mix(D, H, px.w), maximos.w);
+
+ vec3 E_mix = (df1(E, res2) >= df1(E, res1)) ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
+ vec3 res = mix(res1.xyz, res2.xyz, 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/xbr-lv2-multipass/fs_xbr-lv2-b-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-b-pass0.sc
new file mode 100644
index 00000000000..9f9c2836454
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-b-pass0.sc
@@ -0,0 +1,160 @@
+$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 B (squared) - pass0 Shader
+
+ 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"
+
+SAMPLER2D(decal, 0);
+
+#define round(X) floor((X)+0.5)
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const float y_weight = 48.0;
+const float u_weight = 7.0;
+const float v_weight = 6.0;
+const mat4 yuv = mat4(
+ 0.299, 0.587, 0.114, 0.0,
+ -0.169, -0.331, 0.499, 0.0,
+ 0.499, -0.418, -0.0813, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+);
+
+const mat4 yuv_weighted = mat4(
+ 48.0 * vec4( 0.299, 0.587, 0.114, 0.0),
+ 7.0 * vec4(-0.169, -0.331, 0.499, 0.0),
+ 6.0 * vec4( 0.499, -0.418, -0.0813, 0.0),
+ 0.0 * vec4( 0.0, 0.0, 0.0, 0.0)
+);
+const vec4 delta = vec4(0.4, 0.4, 0.4, 0.4);
+
+vec3 remapTo01(vec3 v, vec3 low, vec3 high)
+{
+ return saturate((v - low) / (high-low));
+}
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+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 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), yuv_weighted[0] );
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0] );
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0] );
+ 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), yuv_weighted[0] );
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0] );
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0] );
+ vec4 f4 = h5.yzwx;
+
+ vec4 interp_restriction_lv1 = ne(e,f) * ne(e,h) * ( ge(f,b) * ge(h,d) + lt(e,i) * ge(f,i4) * ge(h,i5) + lt(e,g) + lt(e,c));
+ vec4 interp_restriction_lv2_left = ne(e,g) * ne(d,g);
+ vec4 interp_restriction_lv2_up = ne(e,c) * ne(b,c);
+
+ interp_restriction_lv1 = clamp(interp_restriction_lv1, 0.0, 1.0);
+
+ vec4 edr = lt(weighted_distance(e, c, g, i, h5, f4, h, f), weighted_distance(h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up * edr;
+
+ vec3 info;
+ info.x = dot(edr, vec4(8.0, 4.0, 2.0, 1.0));
+ info.y = dot(edr_left, vec4(8.0, 4.0, 2.0, 1.0));
+ info.z = dot(edr_up, vec4(8.0, 4.0, 2.0, 1.0));
+
+ gl_FragColor = vec4(remapTo01(info, vec3(0.0, 0.0, 0.0), vec3(255.0, 255.0, 255.0)), 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-c-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-c-pass0.sc
new file mode 100644
index 00000000000..05b2398ad9c
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-c-pass0.sc
@@ -0,0 +1,158 @@
+$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 C (squared) - pass0 Shader
+
+ 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"
+
+SAMPLER2D(decal, 0);
+
+#define round(X) floor((X)+0.5)
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const float y_weight = 48.0;
+const float u_weight = 7.0;
+const float v_weight = 6.0;
+const mat4 yuv = mat4(
+ 0.299, 0.587, 0.114, 0.0,
+ -0.169, -0.331, 0.499, 0.0,
+ 0.499, -0.418, -0.0813, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+);
+
+const mat4 yuv_weighted = mat4(
+ 48.0 * vec4( 0.299, 0.587, 0.114, 0.0),
+ 7.0 * vec4(-0.169, -0.331, 0.499, 0.0),
+ 6.0 * vec4( 0.499, -0.418, -0.0813, 0.0),
+ 0.0 * vec4( 0.0, 0.0, 0.0, 0.0)
+);
+const vec4 delta = vec4(0.4, 0.4, 0.4, 0.4);
+
+vec3 remapTo01(vec3 v, vec3 low, vec3 high)
+{
+ return saturate((v - low) / (high-low));
+}
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+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 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 interp_restriction_lv1 = clamp(ne(e,f) * ne(e,h) * (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)), 0.0, 1.0);
+ vec4 interp_restriction_lv2_left = ne(e,g) * ne(d,g);
+ vec4 interp_restriction_lv2_up = ne(e,c) * ne(b,c);
+
+ vec4 edr = lt(weighted_distance(e, c, g, i, h5, f4, h, f), weighted_distance(h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up * edr;
+
+ vec3 info;
+ info.x = dot(edr, vec4(8.0, 4.0, 2.0, 1.0));
+ info.y = dot(edr_left, vec4(8.0, 4.0, 2.0, 1.0));
+ info.z = dot(edr_up, vec4(8.0, 4.0, 2.0, 1.0));
+
+ gl_FragColor = vec4(remapTo01(info, vec3(0.0, 0.0, 0.0), vec3(255.0, 255.0, 255.0)), 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-d-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-d-pass0.sc
new file mode 100644
index 00000000000..c168b2622a7
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-d-pass0.sc
@@ -0,0 +1,163 @@
+$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 D (squared) - pass0 Shader
+
+ 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"
+
+SAMPLER2D(decal, 0);
+
+#define round(X) floor((X)+0.5)
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const float y_weight = 48.0;
+const float u_weight = 7.0;
+const float v_weight = 6.0;
+const mat4 yuv = mat4(
+ 0.299, 0.587, 0.114, 0.0,
+ -0.169, -0.331, 0.499, 0.0,
+ 0.499, -0.418, -0.0813, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+);
+
+const mat4 yuv_weighted = mat4(
+ 48.0 * vec4( 0.299, 0.587, 0.114, 0.0),
+ 7.0 * vec4(-0.169, -0.331, 0.499, 0.0),
+ 6.0 * vec4( 0.499, -0.418, -0.0813, 0.0),
+ 0.0 * vec4( 0.0, 0.0, 0.0, 0.0)
+);
+const vec4 delta = vec4(0.4, 0.4, 0.4, 0.4);
+
+vec3 remapTo01(vec3 v, vec3 low, vec3 high)
+{
+ return saturate((v - low) / (high-low));
+}
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+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 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 c1 = i4.yzwx;
+ vec4 g0 = i5.wxyz;
+
+ vec4 interp_restriction_lv1 = (ne(e,f) * ne(e,h) * (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)));
+ vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
+ vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+
+ interp_restriction_lv1 = clamp(interp_restriction_lv1, 0.0, 1.0);
+
+ vec4 edr = lt(weighted_distance(e, c, g, i, h5, f4, h, f), weighted_distance(h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up * edr;
+
+ vec3 info;
+ info.x = dot(vec4(edr ), vec4(8.0, 4.0, 2.0, 1.0));
+ info.y = dot(vec4(edr_left), vec4(8.0, 4.0, 2.0, 1.0));
+ info.z = dot(vec4(edr_up ), vec4(8.0, 4.0, 2.0, 1.0));
+
+ gl_FragColor = vec4(remapTo01(info, vec3(0.0, 0.0, 0.0), vec3(255.0, 255.0, 255.0)), 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-noblend-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-noblend-pass1.sc
new file mode 100644
index 00000000000..c46dd90ba0a
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-noblend-pass1.sc
@@ -0,0 +1,162 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 - noblend - pass1 Shader
+
+ 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.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 u_tex_size0;
+
+#define round(X) floor((X) + 0.5)
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const float y_weight = 48.0;
+const float u_weight = 7.0;
+const float v_weight = 6.0;
+const mat4 yuv = mat4(
+ 0.299, 0.587, 0.114, 0.0,
+ -0.169, -0.331, 0.499, 0.0,
+ 0.499, -0.418, -0.0813, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+);
+
+const mat4 yuv_weighted = mat4(
+ 48.0 * vec4( 0.299, 0.587, 0.114, 0.0),
+ 7.0 * vec4(-0.169, -0.331, 0.499, 0.0),
+ 6.0 * vec4( 0.499, -0.418, -0.0813, 0.0),
+ 0.0 * vec4( 0.0, 0.0, 0.0, 0.0)
+);
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+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));
+}
+
+
+vec3 remapFrom01(vec3 v, vec3 low, vec3 high)
+{
+ return round(mix(low, high, v));
+}
+
+vec4 unpack_info(float i)
+{
+ vec4 info;
+ float frac_val = fract(i / 2.0f);
+ info.w = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.z = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.y = round(frac_val);
+ info.x = i / 2.0f - frac_val;
+
+ return info;
+}
+
+void main()
+{
+ vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
+
+ vec4 B = texture2D(ORIG_texture, v_texcoord1.xy);
+ vec4 D = texture2D(ORIG_texture, v_texcoord2.xw);
+ vec4 E = texture2D(ORIG_texture, v_texcoord2.yw);
+ vec4 F = texture2D(ORIG_texture, v_texcoord2.zw);
+ vec4 H = texture2D(ORIG_texture, v_texcoord1.xw);
+
+ vec4 b = mul(mat4(B, D, H, F), yuv_weighted[0] );
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0] );
+ vec4 d = b.yzwx;
+ vec4 f = b.wxyz;
+ vec4 h = b.zwxy;
+
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+
+ // These inequations define the line below which interpolation occurs.
+ vec4 fx = ge(Co, Ao*fp.y+Bo*fp.x);
+ vec4 fx_left = ge(Cx, Ax*fp.y+Bx*fp.x);
+ vec4 fx_up = ge(Cy, Ay*fp.y+By*fp.x);
+
+ vec4 info = texture2D(decal, v_texcoord0);
+
+ vec3 i = remapFrom01(info.xyz, vec3(0.0, 0.0, 0.0), vec3(15.0, 15.0, 15.0));
+
+ vec4 edr = unpack_info(i.x);
+ vec4 edr_left = unpack_info(i.y);
+ vec4 edr_up = unpack_info(i.z);
+
+ fx = edr * fx;
+ fx_left = edr_left * fx_left;
+ fx_up = edr_up * fx_up;
+
+ vec4 nc = max(fx, max(fx_left, fx_up));
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec3 res1 = nc.x > 0.0 ? px.x > 0.0 ? F.xyz : H.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : E.xyz;
+ vec3 res2 = nc.w > 0.0 ? px.w > 0.0 ? H.xyz : D.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : E.xyz;
+
+ vec2 df12 = abs(mul(mat3(res1, res2, vec3(0.0, 0.0, 0.0)), yuv_weighted[0].xyz).xy - e.xy);
+ vec3 res = mix(res1, res2, step(df12.x, df12.y));
+
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-pass1.sc
new file mode 100644
index 00000000000..b34ad4fe005
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/fs_xbr-lv2-pass1.sc
@@ -0,0 +1,185 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 - pass1 Shader
+
+ 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"
+
+SAMPLER2D(decal, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 u_tex_size0;
+uniform vec4 u_tex_size1;
+uniform vec4 u_target_dims;
+
+#define round(X) floor((X)+0.5)
+
+const float coef = 2.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const float y_weight = 48.0;
+const float u_weight = 7.0;
+const float v_weight = 6.0;
+const mat4 yuv = mat4(
+ 0.299, 0.587, 0.114, 0.0,
+ -0.169, -0.331, 0.499, 0.0,
+ 0.499, -0.418, -0.0813, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+);
+
+const mat4 yuv_weighted = mat4(
+ 48.0 * vec4( 0.299, 0.587, 0.114, 0.0),
+ 7.0 * vec4(-0.169, -0.331, 0.499, 0.0),
+ 6.0 * vec4( 0.499, -0.418, -0.0813, 0.0),
+ 0.0 * vec4( 0.0, 0.0, 0.0, 0.0)
+);
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+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));
+}
+
+
+vec3 remapFrom01(vec3 v, vec3 low, vec3 high)
+{
+ return round(mix(low, high, v));
+}
+
+vec4 unpack_info(float i)
+{
+ vec4 info;
+ float frac_val = fract(i / 2.0f);
+ info.w = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.z = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.y = round(frac_val);
+ info.x = i / 2.0f - frac_val;
+
+ return info;
+}
+
+void main()
+{
+ vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
+
+ vec4 B = texture2D(ORIG_texture, v_texcoord1.xy);
+ vec4 D = texture2D(ORIG_texture, v_texcoord2.xw);
+ vec4 E = texture2D(ORIG_texture, v_texcoord2.yw);
+ vec4 F = texture2D(ORIG_texture, v_texcoord2.zw);
+ vec4 H = texture2D(ORIG_texture, v_texcoord1.xw);
+
+ vec4 b = mul(mat4(B, D, H, F), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ vec4 d = b.yzwx;
+ vec4 f = b.wxyz;
+ vec4 h = b.zwxy;
+
+ vec4 Ao = vec4(1.0, -1.0, -1.0, 1.0);
+ vec4 Bo = vec4(1.0, 1.0, -1.0, -1.0);
+ vec4 Co = vec4(1.5, 0.5, -0.5, 0.5);
+ vec4 Ax = vec4(1.0, -1.0, -1.0, 1.0);
+ vec4 Bx = vec4(0.5, 2.0, -0.5, -2.0);
+ vec4 Cx = vec4(1.0, 1.0, -0.5, 0.0);
+ vec4 Ay = vec4(1.0, -1.0, -1.0, 1.0);
+ vec4 By = vec4(2.0, 0.5, -2.0, -0.5);
+ vec4 Cy = vec4(2.0, 0.0, -1.0, 0.5);
+
+ // 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);
+
+ vec2 delta = vec2(u_tex_size1.x / u_target_dims.x, 0.5 * u_tex_size1.x / u_target_dims.x);
+
+ vec4 fx45 = saturate((fx + delta.xxxx - Co) / (2.0 * delta.xxxx));
+ vec4 fx30 = saturate((fx_left + delta.yxyx - Cx) / (2.0 * delta.yxyx));
+ vec4 fx60 = saturate((fx_up + delta.xyxy - Cy) / (2.0 * delta.xyxy));
+
+ vec4 info = texture2D(decal, v_texcoord0);
+
+ vec3 i = remapFrom01(info.xyz, vec3(0.0, 0.0, 0.0), vec3(255.0, 255.0, 255.0));
+
+ vec4 edr = unpack_info(i.x);
+ vec4 edr_left = unpack_info(i.y);
+ vec4 edr_up = unpack_info(i.z);
+
+ fx45 = edr * fx45;
+ fx30 = edr_left * fx30;
+ fx60 = edr_up * fx60;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec4 maximo = max(max(fx30, fx60), fx45);
+
+ mat4 pix = mat4(mix(E, mix(H, F, px.x), maximo.x), mix(E, mix(F, B, px.y), maximo.y), mix(E, mix(B, D, px.z), maximo.z), mix(E, mix(D, H, px.w), maximo.w));
+ vec4 pixel = mul(pix, yuv_weighted[0]);
+
+ vec4 diff = df(pixel,e);
+
+ vec3 res = pix[0].xyz;
+ float mx = diff.x;
+
+ if (diff.y > mx)
+ {
+ res = pix[1].xyz;
+ mx = diff.y;
+ }
+ if (diff.z > mx)
+ {
+ res = pix[2].xyz;
+ mx = diff.z;
+ }
+ if (diff.w > mx)
+ {
+ res = pix[3].xyz;
+ }
+
+ gl_FragColor = vec4(res, 1.0);
+} \ No newline at end of file
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/xbr/xbr-lv2-multipass/varying.def.sc
index c65b5426733..92c3034f498 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-6p-smoother/varying.def.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/varying.def.sc
@@ -4,6 +4,9 @@ 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;
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-a-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-a-pass0.sc
new file mode 100644
index 00000000000..3a80bf6f7bb
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-a-pass0.sc
@@ -0,0 +1,60 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 A (squared) - pass0 Shader
+
+ 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 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, -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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-accuracy-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-accuracy-pass0.sc
new file mode 100644
index 00000000000..4cd8b064523
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-accuracy-pass0.sc
@@ -0,0 +1,59 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 Accuracy - pass0 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 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, -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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-accuracy-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-accuracy-pass1.sc
new file mode 100644
index 00000000000..c20050aa1f4
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-accuracy-pass1.sc
@@ -0,0 +1,55 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 Accuracy - pass1 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 u_tex_size1;
+
+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_size1.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xyyy + vec4(0.0, -dy, 0.0, dy); // B
+ v_texcoord2 = v_texcoord0.xxxy + vec4(-dx, 0.0, dx, 0.0); //D E F
+ // H
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-b-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-b-pass0.sc
new file mode 100644
index 00000000000..5515f4f4904
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-b-pass0.sc
@@ -0,0 +1,60 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 B (squared) - pass0 Shader
+
+ 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 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, -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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-c-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-c-pass0.sc
new file mode 100644
index 00000000000..9d0b7161844
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-c-pass0.sc
@@ -0,0 +1,60 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 C (squared) - pass0 Shader
+
+ 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 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, -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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-d-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-d-pass0.sc
new file mode 100644
index 00000000000..8f9b4f316d9
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-d-pass0.sc
@@ -0,0 +1,60 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 D (squared) - pass0 Shader
+
+ 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 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, -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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-noblend-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-noblend-pass1.sc
new file mode 100644
index 00000000000..86df31a48e4
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-noblend-pass1.sc
@@ -0,0 +1,54 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 - noblend - pass1 Shader
+
+ 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.
+
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size1;
+
+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_size1.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xyyy + vec4( 0.0, -dy, 0.0, dy); // B
+ v_texcoord2 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, 0.0); //D E F
+ // H
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-pass1.sc
new file mode 100644
index 00000000000..d678e8b0541
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv2-multipass/vs_xbr-lv2-pass1.sc
@@ -0,0 +1,56 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR LV2 - pass1 Shader
+
+ 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 u_tex_size1;
+
+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_size1.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = v_texcoord0.xyyy + vec4( 0.0, -dy, 0.0, dy); // B
+ v_texcoord2 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, 0.0); //D E F
+ // H
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/fs_xbr-lv3-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/fs_xbr-lv3-pass0.sc
new file mode 100644
index 00000000000..e9328bb4015
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/fs_xbr-lv3-pass0.sc
@@ -0,0 +1,216 @@
+$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 level 3 pass0 Shader
+
+ 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"
+
+SAMPLER2D(decal, 0);
+
+const float coef = 2.0;
+const float cf = 4.0;
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+vec4 remapTo01(vec4 v, vec4 high)
+{
+ return (v/high);
+}
+
+vec4 remapFrom01(vec4 v, vec4 high)
+{
+ return (high*v + vec4(0.5, 0.5, 0.5, 0.5));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+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));
+}
+
+#define FILTRO(EDR0, EDR, LEFT, UP, LEFT3, UP3, PX0, PX3, PX1, LIN0, LIN3, LIN1, PX) \
+ if (LEFT > 0.0 && UP == 0.0) \
+ { \
+ PX0 = vec2(0.0, PX); \
+ PX3 = vec2( PX, 0.0); \
+ if (LEFT3 > 0.0) \
+ { \
+ LIN0 = vec4(0.0, 1.0, 0.0, 0.0);\
+ LIN3 = vec4(1.0, 0.0, 0.0, 0.0);\
+ } \
+ else \
+ { \
+ LIN0 = vec4(0.0, 0.0, 1.0, 0.0);\
+ LIN3 = vec4(0.0, 1.0, 1.0, 0.0);\
+ } \
+ } \
+ else if (UP > 0.0 && LEFT == 0.0) \
+ { \
+ PX0 = vec2(0.0, 1.0 - PX); \
+ PX1 = vec2(1.0 - PX, 0.0); \
+ if (UP3 > 0.0) \
+ { \
+ LIN0 = vec4(0.0, 1.0, 0.0, 1.0);\
+ LIN1 = vec4(1.0, 0.0, 0.0, 1.0);\
+ } \
+ else \
+ { \
+ LIN0 = vec4(0.0, 0.0, 1.0, 1.0);\
+ LIN1 = vec4(0.0, 1.0, 1.0, 1.0);\
+ } \
+ } \
+ else if (EDR > 0.0) \
+ { \
+ LEFT = UP = LEFT3 = UP3 = 0.0; \
+ PX0 = vec2(0.0, PX); \
+ LIN0 = vec4(0.0, 0.0, 0.0, 1.0); \
+ } \
+ else if (EDR0 > 0.0) \
+ { \
+ LEFT = UP = LEFT3 = UP3 = 0.0; \
+ PX0 = vec2(0.0, PX); \
+ LIN0 = vec4(0.0, 0.0, 0.0, 0.0); \
+ } \
+
+
+
+void main()
+{
+ vec2 px0, px1, px2, px3;
+
+ 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), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 c1 = i4.yzwx;
+ vec4 g0 = i5.wxyz;
+ vec4 b1 = h5.zwxy;
+ vec4 d0 = h5.wxyz;
+
+ vec4 interp_restriction_lv0 = ne(e,f) * ne(e,h);
+ vec4 interp_restriction_lv1 = (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));
+ vec4 interp_restriction_lv2_left = ne(e,g) * ne(d,g);
+ vec4 interp_restriction_lv2_up = ne(e,c) * ne(b,c);
+ vec4 interp_restriction_lv3_left = ne(e,g0) * ne(d0,g0);
+ vec4 interp_restriction_lv3_up = ne(e,c1) * ne(b1,c1);
+
+ vec4 edr0 = lt(weighted_distance(e, c, g, i, h5, f4, h, f), weighted_distance(h, d, i5, f, i4, b, e, i)) * interp_restriction_lv0;
+
+ vec4 edr = edr0 * interp_restriction_lv1;
+ vec4 edr_left = le(coef * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = ge(df(f,g), coef * df(h,c)) * interp_restriction_lv2_up * edr;
+ vec4 edr3_left = le(cf * df(f,g0), df(h,c1)) * interp_restriction_lv3_left * edr_left;
+ vec4 edr3_up = ge(df(f,g0), cf * df(h,c1)) * interp_restriction_lv3_up * edr_up;
+
+ vec4 px = le(df(e,f), df(e,h));
+
+ vec4 lin0 = vec4(1.0, 1.0, 1.0, 1.0);
+ vec4 lin1 = lin0;
+ vec4 lin2 = lin0;
+ vec4 lin3 = lin0;
+
+ FILTRO(edr0.x, edr.x, edr_left.x, edr_up.x, edr3_left.x, edr3_up.x, px0, px3, px1, lin0, lin3, lin1, px.x);
+ FILTRO(edr0.y, edr.y, edr_left.y, edr_up.y, edr3_left.y, edr3_up.y, px1, px0, px2, lin1, lin0, lin2, px.y);
+ FILTRO(edr0.z, edr.z, edr_left.z, edr_up.z, edr3_left.z, edr3_up.z, px2, px1, px3, lin2, lin1, lin3, px.z);
+ FILTRO(edr0.w, edr.w, edr_left.w, edr_up.w, edr3_left.w, edr3_up.w, px3, px2, px0, lin3, lin2, lin0, px.w);
+
+ vec4 info = mul(vec4(1.0, 2.0, 4.0, 8.0), mat4( edr3_left,
+ edr3_up,
+ px0.x, px1.x, px2.x, px3.x,
+ px0.y, px1.y, px2.y, px3.y));
+
+ info += mul(vec4(16.0, 32.0, 64.0, 128.0), mat4(lin0.x, lin1.x, lin2.x, lin3.x,
+ lin0.y, lin1.y, lin2.y, lin3.y,
+ lin0.z, lin1.z, lin2.z, lin3.z,
+ lin0.w, lin1.w, lin2.w, lin3.w));
+
+ gl_FragColor = vec4(remapTo01(info, vec4(255.0, 255.0, 255.0, 255.0)));
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/fs_xbr-lv3-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/fs_xbr-lv3-pass1.sc
new file mode 100644
index 00000000000..df6d0a72265
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/fs_xbr-lv3-pass1.sc
@@ -0,0 +1,180 @@
+$input v_texcoord0, v_texcoord1, v_texcoord2, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR level 3 pass1 Shader
+
+ 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.
+*/
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 u_tex_size0;
+
+#define round(X) floor((X)+0.5)
+
+const mat4 sym_vectors = mat4(1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+
+const vec3 lines0 = vec3(1.0, 1.0, 0.75);
+const vec3 lines1 = vec3(1.0, 1.0, 0.5);
+const vec3 lines2 = vec3(2.0, 1.0, 0.5);
+const vec3 lines3 = vec3(1.0, 2.0, 0.5);
+const vec3 lines4 = vec3(3.0, 1.0, 0.5);
+const vec3 lines5 = vec3(1.0, 3.0, 0.5);
+
+const vec3 lines6 = vec3(-1.0, 2.0, 0.5);
+const vec3 lines7 = vec3( 2.0, -1.0, 0.5);
+const vec3 lines8 = vec3(-1.0, 3.0, 0.5);
+const vec3 lines9 = vec3( 3.0, -1.0, 0.5);
+
+const vec3 lines10 = vec3(3.0, 1.0, 1.5);
+const vec3 lines11 = vec3(1.0, 3.0, 1.5);
+
+float remapFrom01(float v, float high)
+{
+ return (high*v + 0.5);
+}
+
+
+vec3 remapFrom01(vec3 v, vec3 low, vec3 high)
+{
+ return round(mix(low, high, v));
+}
+
+vec4 unpack_info(float i)
+{
+ vec4 info;
+ float frac_val = fract(i / 2.0f);
+ info.w = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.z = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.y = round(frac_val);
+ info.x = i / 2.0f - frac_val;
+
+ return info;
+}
+
+void main()
+{
+ vec2 pos = fract(v_texcoord0 * u_tex_size0.xy) - vec2(0.5, 0.5); // pos = pixel position
+ vec4 dir = vec4(sign(pos), 0.0, 0.0); // dir = pixel direction
+
+ vec2 g1 = dir.xy *( saturate(-dir.y * dir.x) * v_texcoord1.zw + saturate( dir.y * dir.x) * v_texcoord1.xy);
+ vec2 g2 = dir.xy *( saturate( dir.y * dir.x) * v_texcoord1.zw + saturate(-dir.y * dir.x) * v_texcoord1.xy);
+
+ vec4 F = texture2D(ORIG_texture, v_texcoord0 +g1);
+ vec4 B = texture2D(ORIG_texture, v_texcoord0 -g2);
+ vec4 D = texture2D(ORIG_texture, v_texcoord0 -g1);
+ vec4 H = texture2D(ORIG_texture, v_texcoord0 +g2);
+ vec4 E = texture2D(ORIG_texture, v_texcoord0 );
+
+ vec4 F4 = texture2D(ORIG_texture, v_texcoord0 +2.0*g1);
+ vec4 I = texture2D(ORIG_texture, v_texcoord0 +g1+g2);
+ vec4 H5 = texture2D(ORIG_texture, v_texcoord0 +2.0*g2);
+
+ vec4 icomp = round(saturate(mul(dir, sym_vectors))); // choose info component
+ float info = remapFrom01(dot(texture2D(decal, v_texcoord0 ), icomp), 255.0); // retrieve 1st pass info
+ float info_nr = remapFrom01(dot(texture2D(decal, v_texcoord0 + g1), icomp), 255.0); // 1st pass info from neighbor r
+ float info_nd = remapFrom01(dot(texture2D(decal, v_texcoord0 + g2), icomp), 255.0); // 1st pass info from neighbor d
+
+ info = info / 2.0 - fract(info / 2.0);
+ info = info / 2.0 - fract(info / 2.0);
+ vec2 px;
+
+ float frac_val = fract(info / 2.0);
+ px.x = round(frac_val);
+ info = info / 2.0 - frac_val;
+
+ frac_val = fract(info / 2.0);
+ px.y = round(frac_val);
+ info = info / 2.0 - frac_val;
+
+ vec4 flags = unpack_info(info); // retrieve 1st pass flags
+
+ frac_val = fract(info_nr / 2.0);
+ float edr3_nrl = round(frac_val);
+ info_nr = info_nr / 2.0 - frac_val;
+ info_nr = info_nr / 2.0 - fract(info_nr / 2.0);
+ info_nr = info_nr / 2.0 - fract(info_nr / 2.0);
+
+ frac_val = fract(info_nr / 2.0);
+ float pxr = round(frac_val);
+ info_nr = info_nr / 2.0 - frac_val;
+
+ info_nd = info_nd / 2.0 - fract(info_nd / 2.0);
+
+ frac_val = fract(info_nd / 2.0);
+ float edr3_ndu = round(frac_val);
+ info_nd = info_nd / 2.0 - frac_val;
+
+ info_nd = info_nd / 2.0 - fract(info_nd / 2.0);
+
+ frac_val = fract(info_nd / 2.0);
+ float pxd = round(frac_val);
+ info_nd = info_nd / 2.0 - frac_val;
+
+ float aux = round(dot(vec4(8.0, 4.0, 2.0, 1.0), flags));
+ vec3 slep;
+
+ if (aux >= 6.0)
+ {
+ slep = (aux == 6.0 ? lines6 : (aux == 7.0 ? lines7 : (aux == 8.0 ? lines8 : (aux == 9.0 ? lines9 : (aux == 10.0 ? lines10 : lines11)))));
+ }
+ else
+ {
+ slep = (aux == 0.0 ? lines0 : (aux == 1.0 ? lines1 : (aux == 2.0 ? lines2 : (aux == 3.0 ? lines3 : (aux == 4.0 ? lines4 : lines5)))));
+ }
+
+ vec2 fp = (dir.x * dir.y) > 0.0 ? abs(pos) : abs(pos.yx);
+
+ vec3 fp1 = vec3(fp.yx, -1);
+
+ vec3 color = E.xyz;
+ float fx;
+
+ if (aux < 10.0)
+ {
+ fx = saturate(dot(fp1, slep) / (2.0 * v_texcoord2.x) + 0.5);
+ color = mix(E.xyz, mix(mix(H.xyz, F.xyz, px.y), mix(D.xyz, B.xyz, px.y), px.x), fx); // interpolate if there's edge
+ }
+ else if (edr3_nrl > 0.0)
+ {
+ fx = saturate(dot(fp1, lines10) / (2.0 * v_texcoord2.x) + 0.5);
+ color = mix(E.xyz, mix(I.xyz, F4.xyz, pxr), fx); // interpolate if there's edge
+ }
+ else if (edr3_ndu > 0.0)
+ {
+ fx = saturate(dot(fp1, lines11) / (2.0 * v_texcoord2.x) + 0.5);
+ color = mix(E.xyz, mix(H5.xyz, I.xyz, pxd), fx); // interpolate if there's edge
+ }
+
+ gl_FragColor = vec4(color, 1.0);
+} \ No newline at end of file
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/xbr/xbr-lv3-multipass/varying.def.sc
index c65b5426733..92c3034f498 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/super-4xbr-3d-4p/varying.def.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/varying.def.sc
@@ -4,6 +4,9 @@ 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;
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/vs_xbr-lv3-pass0.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/vs_xbr-lv3-pass0.sc
new file mode 100644
index 00000000000..d4420512bd4
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/vs_xbr-lv3-pass0.sc
@@ -0,0 +1,60 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR level 3 pass0 Shader
+
+ 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 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,-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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/vs_xbr-lv3-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/vs_xbr-lv3-pass1.sc
new file mode 100644
index 00000000000..edfd9fa3dd9
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-lv3-multipass/vs_xbr-lv3-pass1.sc
@@ -0,0 +1,55 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_texcoord2, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+ Hyllian's xBR level 3 pass1 Shader
+
+ 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.
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size1;
+uniform vec4 u_target_dims;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ // A3 B3 C3
+ // A1 B1 C1
+ //A2 A0 A B C C4 C6
+ //D2 D0 D E F F4 F6
+ //G2 G0 G H I I4 I6
+ // G5 H5 I5
+ // G7 H7 I7
+
+ vec2 ps = 1.0 / u_tex_size1.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = vec4(dx, 0, 0, dy); // F H
+ v_texcoord2 = vec4(u_tex_size1.x / u_target_dims.x, 0.5 * u_tex_size1.x / u_target_dims.x, 0.0, 0.0);
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass1.sc
new file mode 100644
index 00000000000..fe2e3188052
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass1.sc
@@ -0,0 +1,208 @@
+$input v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ Hyllian's xBR MultiLevel4 Shader - Pass1
+
+ Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+
+#define round(X) floor((X)+0.5)
+#define TEX(dx,dy) texture2D(decal, v_texcoord0 + vec2(dx,dy) * v_texcoord1.xy)
+
+const float cf2 = 2.0;
+const float cf3 = 4.0;
+const float cf4 = 4.0;
+const vec4 eq_thresholdold = vec4(15.0, 15.0, 15.0, 15.0);
+const vec4 eq_threshold = vec4( 2.0, 2.0, 2.0, 2.0);
+const vec4 eq_threshold3 = vec4(25.0, 25.0, 25.0, 25.0);
+const vec4 yuv_weight = vec4( 4.0, 1.0, 2.0, 0.0);
+const mat4 yuvT = mat4(0.299, -0.169, 0.499, 0.0, 0.587, -0.331, -0.418, 0.0, 0.114, 0.499, -0.0813, 0.0, 0.0, 0.0, 0.0, 0.0);
+const mat4 yuv = mat4(0.299, 0.587, 0.114, 0.0, -0.169, -0.331, 0.499, 0.0, 0.499, -0.418, -0.0813, 0.0, 0.0, 0.0, 0.0, 0.0);
+const mat4 yuv_weighted = mat4(4.0 * vec4(0.299, 0.587, 0.114, 0.0), 2.0 * vec4(-0.169, -0.331, 0.499, 0.0), vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+const vec4 maximo = vec4(255.0, 255.0, 255.0, 255.0);
+
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+vec4 rd(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return vec4(greaterThan(df(C,D) / (df(A,B) + 0.000000001), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 id(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return vec4(greaterThan(df(C,D), df(A,B)));
+}
+
+vec4 nid(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return vec4(lessThanEqual(df(C,D), df(A,B)));
+}
+
+vec4 remapTo01(vec4 v, vec4 high)
+{
+ return (v/high);
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 ltt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), eq_threshold));
+}
+
+vec4 get(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), eq_threshold3));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+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 A3 = TEX(-1,-3); vec4 B3 = TEX( 0,-3); vec4 C3 = TEX( 1,-3);
+ vec4 A1 = TEX(-1,-2); vec4 B1 = TEX( 0,-2); vec4 C1 = TEX( 1,-2);
+ vec4 A2 = TEX(-3,-1); vec4 A0 = TEX(-2,-1); vec4 A = TEX(-1,-1);
+ vec4 B = TEX( 0,-1); vec4 C = TEX( 1,-1); vec4 C4 = TEX( 2,-1); vec4 C6 = TEX( 3,-1);
+ vec4 D2 = TEX(-3, 0); vec4 D0 = TEX(-2, 0); vec4 D = TEX(-1, 0); vec4 E = TEX( 0, 0);
+ vec4 F = TEX( 1, 0); vec4 F4 = TEX( 2, 0); vec4 F6 = TEX( 3, 0);
+ vec4 G2 = TEX(-3, 1); vec4 G0 = TEX(-2, 1); vec4 G = TEX(-1, 1); vec4 H = TEX( 0, 1);
+ vec4 I = TEX( 1, 1); vec4 I4 = TEX( 2, 1); vec4 I6 = TEX( 3, 1);
+ vec4 G5 = TEX(-1, 2); vec4 H5 = TEX( 0, 2); vec4 I5 = TEX( 1, 2);
+ vec4 G7 = TEX(-1, 3); vec4 H7 = TEX( 0, 3); vec4 I7 = TEX( 1, 3);
+
+ mat4 bdhf = mul(mat4(B, D, H, F), yuvT);
+ bdhf = mat4(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
+ vec4 b = mul(bdhf, yuv_weight);
+
+ bdhf = mul(mat4(C, A, G, I), yuvT);
+ bdhf = mat4(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
+ vec4 c = mul(bdhf, yuv_weight);
+
+ bdhf = mul(mat4(E, E, E, E), yuvT);
+ bdhf = mat4(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
+ vec4 e = mul(bdhf, yuv_weight);
+
+ vec4 d = b.yzwx;
+ vec4 f = b.wxyz;
+ vec4 g = c.zwxy;
+ vec4 h = b.zwxy;
+ vec4 i = c.wxyz;
+
+ bdhf = mul(mat4(I4, C1, A0, G5), yuvT);
+ bdhf = mat4(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
+ vec4 i4 = mul(bdhf, yuv_weight);
+
+ bdhf = mul(mat4(I5, C4, A1, G0), yuvT);
+ bdhf = mat4(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
+ vec4 i5 = mul(bdhf, yuv_weight);
+
+ bdhf = mul(mat4(H5, F4, B1, D0), yuvT);
+ bdhf = mat4(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
+ vec4 h5 = mul(bdhf, yuv_weight);
+
+ vec4 f4 = h5.yzwx;
+
+ vec4 c1 = i4.yzwx;
+ vec4 g0 = i5.wxyz;
+ vec4 b1 = h5.zwxy;
+ vec4 d0 = h5.wxyz;
+
+ bdhf = mul(mat4(I6, C3, A2, G7), yuvT);
+ bdhf = mat4(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
+ vec4 i6 = mul(bdhf, yuv_weight);
+
+ bdhf = mul(mat4(I7, C6, A3, G2), yuvT);
+ bdhf = mat4(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
+ vec4 i7 = mul(bdhf, yuv_weight);
+
+ bdhf = mul(mat4(H7, F6, B3, D2), yuvT);
+ bdhf = mat4(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
+ vec4 h7 = mul(bdhf, yuv_weight);
+
+ vec4 f6 = h7.yzwx;
+
+ vec4 c3 = i6.yzwx;
+ vec4 g2 = i7.wxyz;
+ vec4 b3 = h7.zwxy;
+ vec4 d2 = h7.wxyz;
+
+ vec4 interp_restriction_lv1 = ne(e,f ) * ne(e ,h );
+ vec4 interp_restriction_lv2_left = ne(e,g ) * ne(d ,g ) * (ltt(e, d ) + ltt(h ,g ));
+ vec4 interp_restriction_lv2_up = ne(e,c ) * ne(b ,c ) * (ltt(e, b ) + ltt(f ,c ));
+ vec4 interp_restriction_lv3_left = ne(e,g0) * ne(d0,g0) * (ltt(d ,d0) + ltt(g ,g0));
+ vec4 interp_restriction_lv3_up = ne(e,c1) * ne(b1,c1) * (ltt(b ,b1) + ltt(c ,c1));
+ vec4 interp_restriction_lv4_left = ne(e,g2) * ne(d2,g2) * (ltt(d0,d2) + ltt(g0,g2));
+ vec4 interp_restriction_lv4_up = ne(e,c3) * ne(b3,c3) * (ltt(b1,b3) + ltt(c1,c3));
+
+ vec4 wd1 = weighted_distance(e, c, g, i, h5, f4, h, f);
+ vec4 wd2 = weighted_distance(h, d, i5, f, i4, b, e, i);
+
+ vec4 edr0 = le(wd1, wd2) * interp_restriction_lv1;
+ vec4 edr = lt(wd1, wd2) * interp_restriction_lv1 * (ge(f,b) * nid(f,c,f,b) + ge(h,d) * nid(h,g,h,d) + lt(e,g) + lt(e,c));
+ vec4 edr_left = le(cf2 * df(f,g ), df(h,c )) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = ge(df(f,g ), cf2 * df(h,c )) * interp_restriction_lv2_up * edr;
+ vec4 edr3_left = le(cf3 * df(f,g0), df(h,c1)) * interp_restriction_lv3_left * edr_left;
+ vec4 edr3_up = ge(df(f,g0), cf3 * df(h,c1)) * interp_restriction_lv3_up * edr_up;
+ vec4 edr4_left = le(cf4 * df(f,g2), df(h,c3)) * interp_restriction_lv4_left * edr3_left;
+ vec4 edr4_up = ge(df(f,g2), cf4 * df(h,c3)) * interp_restriction_lv4_up * edr3_up;
+
+ vec4 info;
+ info.x = (edr4_left.x > 0.0 && edr4_up.x == 0.0) ? 8.0 : ((edr4_up.x > 0.0 && edr4_left.x == 0.0) ? 7.0 : ((edr3_left.x > 0.0 && edr3_up.x == 0.0) ? 6.0 : ((edr3_up.x > 0.0 && edr3_left.x == 0.0) ? 5.0 : ((edr_left.x > 0.0 && edr_up.x == 0.0) ? 4.0 : ((edr_up.x > 0.0 && edr_left.x == 0.0) ? 3.0 : (edr.x > 0.0 ? 2.0 : (edr0.x > 0.0 ? 1.0 : 0.0)))))));
+ info.y = (edr4_left.y > 0.0 && edr4_up.y == 0.0) ? 8.0 : ((edr4_up.y > 0.0 && edr4_left.y == 0.0) ? 7.0 : ((edr3_left.y > 0.0 && edr3_up.y == 0.0) ? 6.0 : ((edr3_up.y > 0.0 && edr3_left.y == 0.0) ? 5.0 : ((edr_left.y > 0.0 && edr_up.y == 0.0) ? 4.0 : ((edr_up.y > 0.0 && edr_left.y == 0.0) ? 3.0 : (edr.y > 0.0 ? 2.0 : (edr0.y > 0.0 ? 1.0 : 0.0)))))));
+ info.z = (edr4_left.z > 0.0 && edr4_up.z == 0.0) ? 8.0 : ((edr4_up.z > 0.0 && edr4_left.z == 0.0) ? 7.0 : ((edr3_left.z > 0.0 && edr3_up.z == 0.0) ? 6.0 : ((edr3_up.z > 0.0 && edr3_left.z == 0.0) ? 5.0 : ((edr_left.z > 0.0 && edr_up.z == 0.0) ? 4.0 : ((edr_up.z > 0.0 && edr_left.z == 0.0) ? 3.0 : (edr.z > 0.0 ? 2.0 : (edr0.z > 0.0 ? 1.0 : 0.0)))))));
+ info.w = (edr4_left.w > 0.0 && edr4_up.w == 0.0) ? 8.0 : ((edr4_up.w > 0.0 && edr4_left.w == 0.0) ? 7.0 : ((edr3_left.w > 0.0 && edr3_up.w == 0.0) ? 6.0 : ((edr3_up.w > 0.0 && edr3_left.w == 0.0) ? 5.0 : ((edr_left.w > 0.0 && edr_up.w == 0.0) ? 4.0 : ((edr_up.w > 0.0 && edr_left.w == 0.0) ? 3.0 : (edr.w > 0.0 ? 2.0 : (edr0.w > 0.0 ? 1.0 : 0.0)))))));
+
+ gl_FragColor = vec4(remapTo01(info, maximo));
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass2.sc
new file mode 100644
index 00000000000..b0e0edf7778
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass2.sc
@@ -0,0 +1,235 @@
+$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 MultiLevel4 Shader - Pass2
+
+ Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+#define round(X) floor((X)+0.5)
+
+const float cf2 = 2.0;
+const float cf3 = 4.0;
+const float cf4 = 4.0;
+const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
+const vec4 eq_threshold2 = vec4( 5.0, 5.0, 5.0, 5.0);
+const vec4 eq_threshold3 = vec4(25.0, 25.0, 25.0, 25.0);
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+const vec4 maximo = vec4(255.0, 255.0, 255.0, 255.0);
+
+vec4 df(vec4 A, vec4 B)
+{
+ return vec4(abs(A-B));
+}
+
+vec4 rd(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return vec4(greaterThan(df(C,D) / (df(A,B) + 0.000000001), vec4(2.0, 2.0, 2.0, 2.0)));
+}
+
+vec4 id(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return vec4(greaterThan(df(C,D), df(A,B)));
+}
+
+vec4 nid(vec4 A, vec4 B, vec4 C, vec4 D)
+{
+ return vec4(lessThanEqual(df(C,D), df(A,B)));
+}
+
+vec4 remapTo01(vec4 v, vec4 high)
+{
+ return (v/high);
+}
+
+vec4 remapFrom01(vec4 v, vec4 high)
+{
+ return round(high*v);
+}
+
+vec4 eq(vec4 A, vec4 B)
+{
+ return vec4(equal(A, B));
+}
+
+vec4 lt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(A, B));
+}
+
+vec4 ltt(vec4 A, vec4 B)
+{
+ return vec4(lessThan(df(A, B), eq_threshold));
+}
+
+vec4 get(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(df(A, B), eq_threshold3));
+}
+
+vec4 le(vec4 A, vec4 B)
+{
+ return vec4(lessThanEqual(A, B));
+}
+
+vec4 ge(vec4 A, vec4 B)
+{
+ return vec4(greaterThanEqual(A, B));
+}
+
+vec4 gt(vec4 A, vec4 B)
+{
+ return vec4(greaterThan(A, B));
+}
+
+vec4 ne(vec4 A, vec4 B)
+{
+ return vec4(notEqual(A, B));
+}
+
+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));
+}
+
+vec4 select(vec4 A, vec4 B, vec4 C)
+{
+ vec4 result;
+ result.x = ((A.x > 0.0) ? B.x : C.x);
+ result.y = ((A.y > 0.0) ? B.y : C.y);
+ result.z = ((A.z > 0.0) ? B.z : C.z);
+ result.w = ((A.w > 0.0) ? B.w : C.w);
+ return result;
+}
+
+vec4 pe_check(vec4 pe, vec4 jag, float cf1, float cf2)
+{
+ pe.x = (pe.x == cf1 || pe.x == cf2) ? (jag.x > 0.0 ? pe.x : (pe.x - 2.0)) : pe.x;
+ pe.y = (pe.y == cf1 || pe.y == cf2) ? (jag.y > 0.0 ? pe.y : (pe.y - 2.0)) : pe.y;
+ pe.z = (pe.z == cf1 || pe.z == cf2) ? (jag.z > 0.0 ? pe.z : (pe.z - 2.0)) : pe.z;
+ pe.w = (pe.w == cf1 || pe.w == cf2) ? (jag.w > 0.0 ? pe.w : (pe.w - 2.0)) : pe.w;
+ return pe;
+}
+
+void main()
+{
+ vec4 PA = texture2D(decal, v_texcoord2.xw);
+ vec4 PB = texture2D(decal, v_texcoord2.yw);
+ vec4 PC = texture2D(decal, v_texcoord2.zw);
+
+ vec4 PD = texture2D(decal, v_texcoord3.xw);
+ vec4 PE = texture2D(decal, v_texcoord3.yw);
+ vec4 PF = texture2D(decal, v_texcoord3.zw);
+
+ vec4 PG = texture2D(decal, v_texcoord4.xw);
+ vec4 PH = texture2D(decal, v_texcoord4.yw);
+ vec4 PI = texture2D(decal, v_texcoord4.zw);
+
+ vec4 A1 = texture2D(ORIG_texture, v_texcoord1.xw);
+ vec4 B1 = texture2D(ORIG_texture, v_texcoord1.yw);
+ vec4 C1 = texture2D(ORIG_texture, v_texcoord1.zw);
+
+ vec4 A = texture2D(ORIG_texture, v_texcoord2.xw);
+ vec4 B = texture2D(ORIG_texture, v_texcoord2.yw);
+ vec4 C = texture2D(ORIG_texture, v_texcoord2.zw);
+
+ vec4 D = texture2D(ORIG_texture, v_texcoord3.xw);
+ vec4 E = texture2D(ORIG_texture, v_texcoord3.yw);
+ vec4 F = texture2D(ORIG_texture, v_texcoord3.zw);
+
+ vec4 G = texture2D(ORIG_texture, v_texcoord4.xw);
+ vec4 H = texture2D(ORIG_texture, v_texcoord4.yw);
+ vec4 I = texture2D(ORIG_texture, v_texcoord4.zw);
+
+ vec4 G5 = texture2D(ORIG_texture, v_texcoord5.xw);
+ vec4 H5 = texture2D(ORIG_texture, v_texcoord5.yw);
+ vec4 I5 = texture2D(ORIG_texture, v_texcoord5.zw);
+
+ vec4 A0 = texture2D(ORIG_texture, v_texcoord6.xy);
+ vec4 D0 = texture2D(ORIG_texture, v_texcoord6.xz);
+ vec4 G0 = texture2D(ORIG_texture, v_texcoord6.xw);
+
+ vec4 C4 = texture2D(ORIG_texture, v_texcoord7.xy);
+ vec4 F4 = texture2D(ORIG_texture, v_texcoord7.xz);
+ vec4 I4 = texture2D(ORIG_texture, v_texcoord7.xw);
+
+ vec4 b = mul(mat4(B, D, H, F), yuv_weighted[0]);
+ vec4 c = mul(mat4(C, A, G, I), yuv_weighted[0]);
+ vec4 e = mul(mat4(E, E, E, E), yuv_weighted[0]);
+ 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), yuv_weighted[0]);
+ vec4 i5 = mul(mat4(I5, C4, A1, G0), yuv_weighted[0]);
+ vec4 h5 = mul(mat4(H5, F4, B1, D0), yuv_weighted[0]);
+ vec4 f4 = h5.yzwx;
+
+ vec4 pe = remapFrom01(PE, maximo);
+ vec4 pf = remapFrom01(PF, maximo);
+ vec4 ph = remapFrom01(PH, maximo);
+ vec4 pb = remapFrom01(PB, maximo);
+ vec4 pd = remapFrom01(PD, maximo);
+
+ vec4 f2 = vec4(pf.z, pb.w, pd.x, ph.y);
+ vec4 h2 = vec4(ph.z, pf.w, pb.x, pd.y);
+ vec4 f1 = vec4(pf.y, pb.z, pd.w, ph.x);
+ vec4 h3 = vec4(ph.w, pf.x, pb.y, pd.z);
+
+ vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
+ vec4 one = vec4(1.0, 1.0, 1.0, 1.0);
+ vec4 two = vec4(2.0, 2.0, 2.0, 2.0);
+ vec4 four = vec4(4.0, 4.0, 4.0, 4.0);
+ vec4 nbrs = select(gt(pe.yzwx, one) + gt(pe.wxyz, one), one, zero);
+ vec4 jag1 = select(gt( f2, one) + gt( h2, one), one, zero);
+ vec4 jag2 = select(gt( f2, two) + gt( h2, two), one, zero);
+ vec4 jag3 = select(gt( f2, four) + gt( h2, four), one, zero);
+
+ pe = pe_check(pe, jag3, 7.0, 8.0);
+ pe = pe_check(pe, jag2, 5.0, 6.0);
+
+ vec4 jag91 = clamp((id(h,i,e,h) + id(i4,i,f4,i4)) * gt(f2, one) * gt(f1, one), 0.0, 1.0);
+ vec4 jag92 = clamp((id(f,i,e,f) + id(i5,i,h5,i5)) * gt(h2, one) * gt(h3, one), 0.0, 1.0);
+ vec4 jag93 = clamp(rd(h,g,e,g) , 0.0, 1.0);
+ vec4 jag94 = clamp(rd(f,c,e,c) , 0.0, 1.0);
+ vec4 jag9 = clamp(jag91 * jag93 + jag92 * jag94 , 0.0, 1.0);
+
+ vec4 pe_select = eq(pe, zero) + ((one - nbrs) + jag1) * jag9;
+
+ pe.x = pe_select.x > 0.0 ? pe.x : 1.0;
+ pe.y = pe_select.y > 0.0 ? pe.y : 1.0;
+ pe.z = pe_select.z > 0.0 ? pe.z : 1.0;
+ pe.w = pe_select.w > 0.0 ? pe.w : 1.0;
+
+ gl_FragColor = vec4(remapTo01(pe, maximo));
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass3.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass3.sc
new file mode 100644
index 00000000000..00391c77120
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass3.sc
@@ -0,0 +1,172 @@
+$input v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ Hyllian's xBR MultiLevel4 Shader - Pass3
+
+ Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 u_tex_size1;
+
+#define round(X) floor((X)+0.5)
+
+const float coef = 2.0;
+const float cf = 4.0;
+const float eq_threshold = 15.0;
+const mat4 yuv_weighted = mat4(48.0 * vec4(0.299, 0.587, 0.114, 0.0), 7.0 * vec4(-0.169, -0.331, 0.499, 0.0), 6.0 * vec4(0.499, -0.418, -0.0813, 0.0), vec4(0.0, 0.0, 0.0, 0.0));
+const vec4 maximo = vec4(255.0, 255.0, 255.0, 255.0);
+const vec4 low = vec4(-64.0, -64.0, -64.0, -64.0);
+const vec4 high = vec4( 64.0, 64.0, 64.0, 64.0);
+
+const mat4 sym_vectors = mat4(1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+
+// Bx, Ay, C
+const vec3 lines0 = vec3( 4.0, 4.0, 4.0); // 0 NL
+const vec3 lines1 = vec3( 4.0, 4.0, 3.0); // 1 LV0
+const vec3 lines2 = vec3( 4.0, 4.0, 2.0); // 2 LV1
+const vec3 lines3 = vec3( 8.0, 4.0, 2.0); // 3 LV2u
+const vec3 lines4 = vec3( 4.0, 8.0, 2.0); // 4 LV2l
+const vec3 lines5 = vec3(12.0, 4.0, 2.0); // 5 LV3u
+const vec3 lines6 = vec3( 4.0,12.0, 2.0); // 6 LV3l
+const vec3 lines7 = vec3(16.0, 4.0, 2.0); // 7 LV4u
+const vec3 lines8 = vec3( 4.0,16.0, 2.0); // 8 LV4l
+
+const vec3 lines9 = vec3(12.0, 4.0, 6.0); // 9 LV3u
+const vec3 lines10 = vec3( 4.0,12.0, 6.0); // 10 LV3l
+const vec3 lines11 = vec3(16.0, 4.0, 6.0); // 11 LV4u
+const vec3 lines12 = vec3( 4.0,16.0, 6.0); // 12 LV4l
+
+vec4 remapTo01(vec4 v, vec4 low, vec4 high)
+{
+ return saturate((v - low)/(high-low));
+}
+
+float remapFrom01(float v, float high)
+{
+ return round(high*v);
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+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));
+}
+
+void main()
+{
+ vec2 pos = fract(v_texcoord0 * u_tex_size1.xy) - vec2(0.5, 0.5); // pos = pixel position
+ vec4 dir = vec4(sign(pos), 0.0, 0.0);
+
+ vec2 g1 = dir.xy * (saturate(-dir.y * dir.x) * v_texcoord1.zw + saturate( dir.y * dir.x) * v_texcoord1.xy);
+ vec2 g2 = dir.xy * (saturate( dir.y * dir.x) * v_texcoord1.zw + saturate(-dir.y * dir.x) * v_texcoord1.xy);
+
+ vec4 E = texture2D(ORIG_texture, v_texcoord0 );
+ vec4 F = texture2D(ORIG_texture, v_texcoord0 +g1);
+ vec4 H = texture2D(ORIG_texture, v_texcoord0 +g2);
+ vec4 I = texture2D(ORIG_texture, v_texcoord0 +g1+g2);
+ vec4 F4 = texture2D(ORIG_texture, v_texcoord0 +2.0*g1);
+ vec4 H5 = texture2D(ORIG_texture, v_texcoord0 +2.0*g2);
+
+ float e = dot(E, yuv_weighted[0]);
+ float f = dot(F, yuv_weighted[0]);
+ float h = dot(H, yuv_weighted[0]);
+ float i = dot(I, yuv_weighted[0]);
+ float f4= dot(F4, yuv_weighted[0]);
+ float h5= dot(H5, yuv_weighted[0]);
+
+ vec4 icomp = round(saturate(mul(dir, sym_vectors))); // choose info component
+
+ float infoE = remapFrom01(dot(texture2D(decal, v_texcoord0 ), icomp), 255.0); // retrieve 1st pass info
+ float infoF = remapFrom01(dot(texture2D(decal, v_texcoord0+g1), icomp), 255.0); // 1st pass info from neighbor r
+ float infoH = remapFrom01(dot(texture2D(decal, v_texcoord0+g2), icomp), 255.0); // 1st pass info from neighbor d
+
+ vec4 lparam;
+ float px;
+ vec2 addr;
+
+ if (infoF == 8.0)
+ {
+ lparam.xyz = lines12;
+ px = float(df(f,f4) <= df(f,i));
+ addr.x = 2.0 * px + saturate(1.0 - px);
+ addr.y = saturate(1.0-px);
+ }
+ else if (infoH == 7.0)
+ {
+ lparam.xyz = lines11;
+ px = float(df(h,h5) <= df(h,i));
+ addr.x = saturate(1.0-px);
+ addr.y = 2.0 * px + saturate(1.0 - px);
+ }
+ else if (infoF == 6.0)
+ {
+ lparam.xyz = lines10;
+ px = float(df(f,f4) <= df(f,i));
+ addr.x = 2.0 * px + saturate(1.0 - px);
+ addr.y = saturate(1.0-px);
+ }
+ else if (infoH == 5.0)
+ {
+ lparam.xyz = lines9;
+ px = float(df(h,h5) <= df(h,i));
+ addr.x = saturate(1.0 - px);
+ addr.y = 2.0 * px + saturate(1.0 - px);
+ }
+ else
+ {
+ px = float(df(e,f) <= df(e,h));
+ addr.x = px;
+ addr.y = saturate(1.0 - px);
+
+ lparam.xyz = (infoE == 8.0) ? lines8 : ((infoE == 7.0) ? lines7 : ((infoE == 6.0) ? lines6 : ((infoE == 5.0) ? lines5 : ((infoE == 4.0) ? lines4 : ((infoE == 3.0) ? lines3 : ((infoE == 2.0) ? lines2 : ((infoE == 1.0) ? lines1 : lines0)))))));
+ }
+
+ bool inv = ((dir.x * dir.y) < 0.0);
+
+ // Rotate address from relative to absolute.
+ addr = addr * dir.yx;
+ addr = (inv ? addr.yx : addr);
+
+ // Rotate straight line equation from relative to absolute.
+ lparam.xy = lparam.xy * dir.yx;
+ lparam.xy = (inv ? lparam.yx : lparam.xy);
+
+ addr.x += 2.0;
+ addr.y += 2.0;
+
+ lparam.w = addr.x * 8.0 + addr.y;
+
+ gl_FragColor = vec4(remapTo01(lparam, low, high));
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass4.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass4.sc
new file mode 100644
index 00000000000..535f70a5a7d
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/fs_xbr-mlv4-pass4.sc
@@ -0,0 +1,164 @@
+$input v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ Hyllian's xBR MultiLevel4 Shader - Pass3
+
+ Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+*/
+
+#include "common.sh"
+
+SAMPLER2D(decal, 0);
+SAMPLER2D(ORIG_texture, 1);
+
+uniform vec4 u_tex_size1;
+uniform vec4 u_target_size;
+
+#define round(X) floor((X)+0.5)
+
+const vec3 bin = vec3( 4.0f, 2.0f, 1.0f);
+const vec4 low = vec4(-64.0f, -64.0f, -64.0f, -64.0f);
+const vec4 high = vec4( 64.0f, 64.0f, 64.0f, 64.0f);
+
+const mat4 sym_vectors = mat4 (1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+
+vec4 remapFrom01(vec4 v, vec4 low, vec4 high)
+{
+ return round(mix(low, high, v));
+}
+
+float c_df(vec3 c1, vec3 c2)
+{
+ vec3 df = abs(c1 - c2);
+ return df.r + df.g + df.b;
+}
+
+vec4 unpack_info(float i)
+{
+ vec4 info;
+ float frac_val = fract(i / 2.0f);
+ info.w = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.z = round(frac_val);
+ i = i / 2.0f - frac_val;
+
+ frac_val = fract(i / 2.0f);
+ info.y = round(frac_val);
+ info.x = i / 2.0f - frac_val;
+
+ return info;
+}
+
+float df(float A, float B)
+{
+ return abs(A-B);
+}
+
+vec3 color_mix(vec3 c, vec3 color, vec3 E)
+{
+ return (c_df(c, E) > c_df(color, E) ? c : color);
+}
+
+#define GET_PIXEL(PARAM, PIXEL) \
+ info = PARAM; \
+ \
+ frac_val = fract(info / 2.0); \
+ ay.z = round(frac_val); \
+ info = info / 2.0 - frac_val; \
+ \
+ frac_val = fract(info / 2.0); \
+ ay.y = round(frac_val); \
+ info = info / 2.0 - frac_val; \
+ \
+ frac_val = fract(info / 2.0); \
+ ay.x = round(frac_val); \
+ info = info / 2.0 - frac_val; \
+ \
+ frac_val = fract(info / 2.0); \
+ ax.z = round(frac_val); \
+ info = info / 2.0 - frac_val; \
+ \
+ frac_val = fract(info / 2.0); \
+ ax.y = round(frac_val); \
+ info = info / 2.0 - frac_val; \
+ \
+ ax.x = round(info); \
+ iq.x = dot(ax, bin) - 2.0; \
+ iq.y = dot(ay, bin) - 2.0; \
+ PIXEL = texture2D(ORIG_texture, v_texcoord0 + iq.x * v_texcoord1.xy + iq.y * v_texcoord1.zw).xyz; \
+
+
+void main()
+{
+ float scale_factor = u_target_size.x / u_tex_size1.x;
+
+ vec2 fp = fract(v_texcoord0 * u_tex_size1.xy) - vec2(0.5, 0.5); // pos = pixel position
+
+ vec4 UL = texture2D(decal, v_texcoord0 + 0.25 * v_texcoord1.xy + 0.25 * v_texcoord1.zw);
+ vec4 UR = texture2D(decal, v_texcoord0 + 0.75 * v_texcoord1.xy + 0.25 * v_texcoord1.zw);
+ vec4 DL = texture2D(decal, v_texcoord0 + 0.25 * v_texcoord1.xy + 0.75 * v_texcoord1.zw);
+ vec4 DR = texture2D(decal, v_texcoord0 + 0.75 * v_texcoord1.xy + 0.75 * v_texcoord1.zw);
+
+ vec4 ulparam = remapFrom01(UL, low, high); // retrieve 1st pass info
+ vec4 urparam = remapFrom01(UR, low, high); // retrieve 1st pass info
+ vec4 dlparam = remapFrom01(DL, low, high); // retrieve 1st pass info
+ vec4 drparam = remapFrom01(DR, low, high); // retrieve 1st pass info
+
+ vec4 E = texture2D(ORIG_texture, v_texcoord0);
+
+ float info, frac_val;
+ vec2 iq;
+ vec3 ax, ay, PX, PY, PZ, PW;
+ GET_PIXEL(ulparam.w, PX);
+ GET_PIXEL(urparam.w, PY);
+ GET_PIXEL(dlparam.w, PZ);
+ GET_PIXEL(drparam.w, PW);
+
+ vec3 fp1 = vec3(fp, -1);
+
+ vec4 inc = vec4(abs(ulparam.x / ulparam.y), abs(urparam.x / urparam.y), abs(dlparam.x / dlparam.y), abs(drparam.x / drparam.y));
+ vec4 level = max(inc, 1.0 / inc);
+
+ vec4 fx;
+ fx.x = saturate(dot(fp1, ulparam.xyz) * scale_factor / (8.0 * level.x) + 0.5);
+ fx.y = saturate(dot(fp1, urparam.xyz) * scale_factor / (8.0 * level.y) + 0.5);
+ fx.z = saturate(dot(fp1, dlparam.xyz) * scale_factor / (8.0 * level.z) + 0.5);
+ fx.w = saturate(dot(fp1, drparam.xyz) * scale_factor / (8.0 * level.w) + 0.5);
+
+ vec3 c1 = mix(E.xyz, PX, fx.x);
+ vec3 c2 = mix(E.xyz, PY, fx.y);
+ vec3 c3 = mix(E.xyz, PZ, fx.z);
+ vec3 c4 = mix(E.xyz, PW, fx.w);
+
+ vec3 color = c1;
+ color = color_mix(c2, color, E.xyz);
+ color = color_mix(c3, color, E.xyz);
+ color = color_mix(c4, 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-hybrid/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/varying.def.sc
index c65b5426733..92c3034f498 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr-hybrid/varying.def.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/varying.def.sc
@@ -4,6 +4,9 @@ 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;
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass1.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass1.sc
new file mode 100644
index 00000000000..bab183ddd30
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass1.sc
@@ -0,0 +1,52 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ Hyllian's xBR MultiLevel4 Shader - Pass1
+
+ Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+*/
+
+#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;
+
+ // A3 B3 C3
+ // A1 B1 C1
+ //A2 A0 A B C C4 C6
+ //D2 D0 D E F F4 F6
+ //G2 G0 G H I I4 I6
+ // G5 H5 I5
+ // G7 H7 I7
+
+ v_texcoord1 = 1.0 / u_tex_size0.xyyy; // F H
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass2.sc
new file mode 100644
index 00000000000..71ebf7d574a
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass2.sc
@@ -0,0 +1,59 @@
+$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:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ Hyllian's xBR MultiLevel4 Shader - Pass2
+
+ Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+*/
+
+#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, -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;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass3.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass3.sc
new file mode 100644
index 00000000000..19195ba5b27
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass3.sc
@@ -0,0 +1,55 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ Hyllian's xBR MultiLevel4 Shader - Pass3
+
+ Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size1;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ // A3 B3 C3
+ // A1 B1 C1
+ //A2 A0 A B C C4 C6
+ //D2 D0 D E F F4 F6
+ //G2 G0 G H I I4 I6
+ // G5 H5 I5
+ // G7 H7 I7
+
+ vec2 ps = 1.0 / u_tex_size1.xy;
+ float dx = ps.x;
+ float dy = ps.y;
+ v_texcoord1 = vec4(dx, 0.0, 0.0, dy); // F H
+ v_color0 = a_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass4.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass4.sc
new file mode 100644
index 00000000000..bf9f297ec9d
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/xbr-mlv4-multipass/vs_xbr-mlv4-pass4.sc
@@ -0,0 +1,53 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_texcoord1, v_color0
+
+// license:MIT
+// copyright-holders:Hyllian
+
+/*
+
+ Hyllian's xBR MultiLevel4 Shader - Pass4
+
+ Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+*/
+
+#include "common.sh"
+
+uniform vec4 u_tex_size1;
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0;
+
+ // A3 B3 C3
+ // A1 B1 C1
+ //A2 A0 A B C C4 C6
+ //D2 D0 D E F F4 F6
+ //G2 G0 G H I I4 I6
+ // G5 H5 I5
+ // G7 H7 I7
+
+ vec2 ps = 1.0 / u_tex_size1.xy;
+ v_texcoord1 = vec4(ps.x, 0.0, 0.0, ps.y); // F H
+ v_color0 = a_color0;
+}