summaryrefslogtreecommitdiffstats
path: root/system/shaders
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /system/shaders
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'system/shaders')
-rw-r--r--system/shaders/GL/1.2/gl_convolution-4x4.glsl89
-rw-r--r--system/shaders/GL/1.2/gl_convolution-6x6.glsl100
-rw-r--r--system/shaders/GL/1.2/gl_output.glsl58
-rw-r--r--system/shaders/GL/1.2/gl_shader_frag_default.glsl29
-rw-r--r--system/shaders/GL/1.2/gl_shader_frag_fonts.glsl34
-rw-r--r--system/shaders/GL/1.2/gl_shader_frag_multi.glsl32
-rw-r--r--system/shaders/GL/1.2/gl_shader_frag_multi_blendcolor.glsl33
-rw-r--r--system/shaders/GL/1.2/gl_shader_frag_texture.glsl31
-rw-r--r--system/shaders/GL/1.2/gl_shader_frag_texture_noblend.glsl30
-rw-r--r--system/shaders/GL/1.2/gl_shader_vert.glsl40
-rw-r--r--system/shaders/GL/1.2/gl_shader_vert_default.glsl31
-rw-r--r--system/shaders/GL/1.2/gl_stretch.glsl41
-rw-r--r--system/shaders/GL/1.2/gl_videofilter_frag.glsl30
-rw-r--r--system/shaders/GL/1.2/gl_videofilter_vertex.glsl34
-rw-r--r--system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl131
-rw-r--r--system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl38
-rw-r--r--system/shaders/GL/1.5/gl_convolution-4x4.glsl71
-rw-r--r--system/shaders/GL/1.5/gl_convolution-6x6.glsl83
-rw-r--r--system/shaders/GL/1.5/gl_output.glsl37
-rw-r--r--system/shaders/GL/1.5/gl_shader_frag_default.glsl14
-rw-r--r--system/shaders/GL/1.5/gl_shader_frag_fonts.glsl19
-rw-r--r--system/shaders/GL/1.5/gl_shader_frag_multi.glsl17
-rw-r--r--system/shaders/GL/1.5/gl_shader_frag_multi_blendcolor.glsl18
-rw-r--r--system/shaders/GL/1.5/gl_shader_frag_texture.glsl16
-rw-r--r--system/shaders/GL/1.5/gl_shader_frag_texture_lim.glsl15
-rw-r--r--system/shaders/GL/1.5/gl_shader_frag_texture_noblend.glsl15
-rw-r--r--system/shaders/GL/1.5/gl_shader_vert.glsl20
-rw-r--r--system/shaders/GL/1.5/gl_shader_vert_default.glsl11
-rw-r--r--system/shaders/GL/1.5/gl_stretch.glsl22
-rw-r--r--system/shaders/GL/1.5/gl_tonemap.glsl50
-rw-r--r--system/shaders/GL/1.5/gl_videofilter_frag.glsl12
-rw-r--r--system/shaders/GL/1.5/gl_videofilter_vertex.glsl14
-rw-r--r--system/shaders/GL/1.5/gl_yuv2rgb_basic.glsl123
-rw-r--r--system/shaders/GL/1.5/gl_yuv2rgb_vertex.glsl20
-rw-r--r--system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl141
-rw-r--r--system/shaders/GLES/2.0/gles_convolution-4x4.frag78
-rw-r--r--system/shaders/GLES/2.0/gles_convolution-6x6.frag89
-rw-r--r--system/shaders/GLES/2.0/gles_shader.vert41
-rw-r--r--system/shaders/GLES/2.0/gles_shader_default.frag38
-rw-r--r--system/shaders/GLES/2.0/gles_shader_fonts.frag41
-rw-r--r--system/shaders/GLES/2.0/gles_shader_multi.frag41
-rw-r--r--system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag42
-rw-r--r--system/shaders/GLES/2.0/gles_shader_rgba.frag43
-rw-r--r--system/shaders/GLES/2.0/gles_shader_rgba_blendcolor.frag43
-rw-r--r--system/shaders/GLES/2.0/gles_shader_rgba_bob.frag56
-rw-r--r--system/shaders/GLES/2.0/gles_shader_rgba_bob_oes.frag58
-rw-r--r--system/shaders/GLES/2.0/gles_shader_rgba_oes.frag41
-rw-r--r--system/shaders/GLES/2.0/gles_shader_texture.frag40
-rw-r--r--system/shaders/GLES/2.0/gles_shader_texture_noalpha.frag25
-rw-r--r--system/shaders/GLES/2.0/gles_shader_texture_noblend.frag39
-rw-r--r--system/shaders/GLES/2.0/gles_tonemap.frag50
-rw-r--r--system/shaders/GLES/2.0/gles_videofilter.frag11
-rw-r--r--system/shaders/GLES/2.0/gles_videofilter.vert14
-rw-r--r--system/shaders/GLES/2.0/gles_yuv2rgb.vert40
-rw-r--r--system/shaders/GLES/2.0/gles_yuv2rgb_basic.frag93
-rw-r--r--system/shaders/GLES/2.0/gles_yuv2rgb_bob.frag113
-rw-r--r--system/shaders/convolution-4x4_d3d.fx88
-rw-r--r--system/shaders/convolution-6x6_d3d.fx96
-rw-r--r--system/shaders/convolution_d3d.fx61
-rw-r--r--system/shaders/convolutionsep-4x4_d3d.fx109
-rw-r--r--system/shaders/convolutionsep-6x6_d3d.fx121
-rw-r--r--system/shaders/guishader_checkerboard_left.hlsl40
-rw-r--r--system/shaders/guishader_checkerboard_right.hlsl40
-rw-r--r--system/shaders/guishader_common.hlsl116
-rw-r--r--system/shaders/guishader_default.hlsl28
-rw-r--r--system/shaders/guishader_fonts.hlsl31
-rw-r--r--system/shaders/guishader_interlaced_left.hlsl40
-rw-r--r--system/shaders/guishader_interlaced_right.hlsl40
-rw-r--r--system/shaders/guishader_multi_texture_blend.hlsl31
-rw-r--r--system/shaders/guishader_texture.hlsl30
-rw-r--r--system/shaders/guishader_texture_noblend.hlsl30
-rw-r--r--system/shaders/guishader_vert.hlsl32
-rw-r--r--system/shaders/output_d3d.fx197
-rw-r--r--system/shaders/rp_output_d3d.fx81
-rw-r--r--system/shaders/yuv2rgb_d3d.fx138
75 files changed, 3884 insertions, 0 deletions
diff --git a/system/shaders/GL/1.2/gl_convolution-4x4.glsl b/system/shaders/GL/1.2/gl_convolution-4x4.glsl
new file mode 100644
index 0000000..8c97423
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_convolution-4x4.glsl
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+uniform sampler2D img;
+uniform vec2 stepxy;
+uniform float m_stretch;
+uniform float m_alpha;
+varying vec2 m_cord;
+uniform sampler1D kernelTex;
+
+vec4 weight(float pos)
+{
+#if defined(HAS_FLOAT_TEXTURE)
+ return texture1D(kernelTex, pos);
+#else
+ return texture1D(kernelTex, pos) * 2.0 - 1.0;
+#endif
+}
+
+vec2 stretch(vec2 pos)
+{
+#if (XBMC_STRETCH)
+ // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b.
+ // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5
+ // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1)
+ float x = pos.x - 0.5;
+ return vec2(mix(x * abs(x) * 2.0, x, m_stretch) + 0.5, pos.y);
+#else
+ return pos;
+#endif
+}
+
+vec3 pixel(float xpos, float ypos)
+{
+ return texture2D(img, vec2(xpos, ypos)).rgb;
+}
+
+vec3 line (float ypos, vec4 xpos, vec4 linetaps)
+{
+ return
+ pixel(xpos.r, ypos) * linetaps.r +
+ pixel(xpos.g, ypos) * linetaps.g +
+ pixel(xpos.b, ypos) * linetaps.b +
+ pixel(xpos.a, ypos) * linetaps.a;
+}
+
+vec4 process()
+{
+ vec4 rgb;
+ vec2 pos = stretch(m_cord) + stepxy * 0.5;
+ vec2 f = fract(pos / stepxy);
+
+ vec4 linetaps = weight(1.0 - f.x);
+ vec4 columntaps = weight(1.0 - f.y);
+
+ //make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur
+ linetaps /= linetaps.r + linetaps.g + linetaps.b + linetaps.a;
+ columntaps /= columntaps.r + columntaps.g + columntaps.b + columntaps.a;
+
+ vec2 xystart = (-1.5 - f) * stepxy + pos;
+ vec4 xpos = vec4(xystart.x, xystart.x + stepxy.x, xystart.x + stepxy.x * 2.0, xystart.x + stepxy.x * 3.0);
+
+ rgb.rgb =
+ line(xystart.y , xpos, linetaps) * columntaps.r +
+ line(xystart.y + stepxy.y , xpos, linetaps) * columntaps.g +
+ line(xystart.y + stepxy.y * 2.0, xpos, linetaps) * columntaps.b +
+ line(xystart.y + stepxy.y * 3.0, xpos, linetaps) * columntaps.a;
+
+ rgb.a = m_alpha;
+
+ return rgb;
+}
diff --git a/system/shaders/GL/1.2/gl_convolution-6x6.glsl b/system/shaders/GL/1.2/gl_convolution-6x6.glsl
new file mode 100644
index 0000000..26c9f49
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_convolution-6x6.glsl
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+uniform sampler2D img;
+uniform vec2 stepxy;
+uniform float m_stretch;
+uniform float m_alpha;
+varying vec2 m_cord;
+uniform sampler1D kernelTex;
+
+vec3 weight(float pos)
+{
+#if defined(HAS_FLOAT_TEXTURE)
+ return texture1D(kernelTex, pos).rgb;
+#else
+ return texture1D(kernelTex, pos).rgb * 2.0 - 1.0;
+#endif
+}
+
+vec2 stretch(vec2 pos)
+{
+#if (XBMC_STRETCH)
+ // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b.
+ // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5
+ // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1)
+ float x = pos.x - 0.5;
+ return vec2(mix(x * abs(x) * 2.0, x, m_stretch) + 0.5, pos.y);
+#else
+ return pos;
+#endif
+}
+
+vec3 pixel(float xpos, float ypos)
+{
+ return texture2D(img, vec2(xpos, ypos)).rgb;
+}
+
+vec3 line (float ypos, vec3 xpos1, vec3 xpos2, vec3 linetaps1, vec3 linetaps2)
+{
+ return
+ pixel(xpos1.r, ypos) * linetaps1.r +
+ pixel(xpos1.g, ypos) * linetaps2.r +
+ pixel(xpos1.b, ypos) * linetaps1.g +
+ pixel(xpos2.r, ypos) * linetaps2.g +
+ pixel(xpos2.g, ypos) * linetaps1.b +
+ pixel(xpos2.b, ypos) * linetaps2.b;
+}
+
+vec4 process()
+{
+ vec4 rgb;
+ vec2 pos = stretch(m_cord) + stepxy * 0.5;
+ vec2 f = fract(pos / stepxy);
+
+ vec3 linetaps1 = weight((1.0 - f.x) / 2.0);
+ vec3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5);
+ vec3 columntaps1 = weight((1.0 - f.y) / 2.0);
+ vec3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5);
+
+ //make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur
+ float sum = linetaps1.r + linetaps1.g + linetaps1.b + linetaps2.r + linetaps2.g + linetaps2.b;
+ linetaps1 /= sum;
+ linetaps2 /= sum;
+ sum = columntaps1.r + columntaps1.g + columntaps1.b + columntaps2.r + columntaps2.g + columntaps2.b;
+ columntaps1 /= sum;
+ columntaps2 /= sum;
+
+ vec2 xystart = (-2.5 - f) * stepxy + pos;
+ vec3 xpos1 = vec3(xystart.x, xystart.x + stepxy.x, xystart.x + stepxy.x * 2.0);
+ vec3 xpos2 = vec3(xystart.x + stepxy.x * 3.0, xystart.x + stepxy.x * 4.0, xystart.x + stepxy.x * 5.0);
+
+ rgb.rgb =
+ line(xystart.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r +
+ line(xystart.y + stepxy.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r +
+ line(xystart.y + stepxy.y * 2.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g +
+ line(xystart.y + stepxy.y * 3.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g +
+ line(xystart.y + stepxy.y * 4.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b +
+ line(xystart.y + stepxy.y * 5.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b;
+
+ rgb.a = m_alpha;
+
+ return rgb;
+}
diff --git a/system/shaders/GL/1.2/gl_output.glsl b/system/shaders/GL/1.2/gl_output.glsl
new file mode 100644
index 0000000..d3294a8
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_output.glsl
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010-2017 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#if defined(XBMC_DITHER)
+uniform sampler2D m_dither;
+uniform float m_ditherquant;
+uniform vec2 m_dithersize;
+#endif
+#if defined(KODI_3DLUT)
+uniform float m_CLUTsize;
+uniform sampler3D m_CLUT;
+#endif
+
+void main()
+{
+ vec4 rgb = process();
+
+#if defined(KODI_3DLUT)
+ // FIXME: can this be optimized?
+ rgb = texture3D(m_CLUT, (rgb.rgb*(m_CLUTsize-1.0) + 0.5) / m_CLUTsize);
+#endif
+
+#if defined(XBMC_FULLRANGE)
+#if __VERSION__ <= 120
+ rgb = (rgb-(16.0/255.0)) * 255.0/219.0;
+#else
+ rgb = clamp((rgb-(16.0/255.0)) * 255.0/219.0, 0, 1);
+#endif
+#endif
+
+#if defined(XBMC_DITHER)
+ vec2 ditherpos = gl_FragCoord.xy / m_dithersize;
+ // ditherval is multiplied by 65536/(dither_size^2) to make it [0,1[
+ // FIXME: scale dither values before uploading?
+ float ditherval = texture2D(m_dither, ditherpos).r * 16.0;
+ rgb = floor(rgb * m_ditherquant + ditherval) / m_ditherquant;
+#endif
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GL/1.2/gl_shader_frag_default.glsl b/system/shaders/GL/1.2/gl_shader_frag_default.glsl
new file mode 100644
index 0000000..d9aba5f
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_frag_default.glsl
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+uniform vec4 m_unicol;
+
+// SM_DEFAULT shader
+void main ()
+{
+ gl_FragColor = m_unicol;
+}
diff --git a/system/shaders/GL/1.2/gl_shader_frag_fonts.glsl b/system/shaders/GL/1.2/gl_shader_frag_fonts.glsl
new file mode 100644
index 0000000..eed605f
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_frag_fonts.glsl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+uniform sampler2D m_samp0;
+varying vec4 m_cord0;
+varying vec4 m_colour;
+
+// SM_FONTS shader
+void main ()
+{
+ gl_FragColor.r = m_colour.r;
+ gl_FragColor.g = m_colour.g;
+ gl_FragColor.b = m_colour.b;
+ gl_FragColor.a = m_colour.a * texture2D(m_samp0, m_cord0.xy).r;
+}
diff --git a/system/shaders/GL/1.2/gl_shader_frag_multi.glsl b/system/shaders/GL/1.2/gl_shader_frag_multi.glsl
new file mode 100644
index 0000000..804a716
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_frag_multi.glsl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+uniform sampler2D m_samp0;
+uniform sampler2D m_samp1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+
+// SM_MULTI shader
+void main ()
+{
+ gl_FragColor.rgba = (texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy)).rgba;
+}
diff --git a/system/shaders/GL/1.2/gl_shader_frag_multi_blendcolor.glsl b/system/shaders/GL/1.2/gl_shader_frag_multi_blendcolor.glsl
new file mode 100644
index 0000000..20622d2
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_frag_multi_blendcolor.glsl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+uniform sampler2D m_samp0;
+uniform sampler2D m_samp1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+uniform vec4 m_unicol;
+
+// SM_MULTI shader
+void main ()
+{
+ gl_FragColor.rgba = m_unicol * texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy);
+}
diff --git a/system/shaders/GL/1.2/gl_shader_frag_texture.glsl b/system/shaders/GL/1.2/gl_shader_frag_texture.glsl
new file mode 100644
index 0000000..c15681f
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_frag_texture.glsl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+uniform sampler2D m_samp0;
+uniform vec4 m_unicol;
+varying vec4 m_cord0;
+
+// SM_TEXTURE shader
+void main ()
+{
+ gl_FragColor.rgba = vec4(texture2D(m_samp0, m_cord0.xy).rgba * m_unicol);
+}
diff --git a/system/shaders/GL/1.2/gl_shader_frag_texture_noblend.glsl b/system/shaders/GL/1.2/gl_shader_frag_texture_noblend.glsl
new file mode 100644
index 0000000..16a1f8b
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_frag_texture_noblend.glsl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+uniform sampler2D m_samp0;
+varying vec4 m_cord0;
+
+// SM_TEXTURE_NOBLEND shader
+void main ()
+{
+ gl_FragColor.rgba = vec4(texture2D(m_samp0, m_cord0.xy).rgba);
+}
diff --git a/system/shaders/GL/1.2/gl_shader_vert.glsl b/system/shaders/GL/1.2/gl_shader_vert.glsl
new file mode 100644
index 0000000..7c10b5f
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_vert.glsl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+attribute vec4 m_attrpos;
+attribute vec4 m_attrcol;
+attribute vec4 m_attrcord0;
+attribute vec4 m_attrcord1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+varying vec4 m_colour;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+ m_colour = m_attrcol;
+ m_cord0 = m_attrcord0;
+ m_cord1 = m_attrcord1;
+}
diff --git a/system/shaders/GL/1.2/gl_shader_vert_default.glsl b/system/shaders/GL/1.2/gl_shader_vert_default.glsl
new file mode 100644
index 0000000..554e15c
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_vert_default.glsl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+attribute vec4 m_attrpos;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+}
diff --git a/system/shaders/GL/1.2/gl_stretch.glsl b/system/shaders/GL/1.2/gl_stretch.glsl
new file mode 100644
index 0000000..9cc3388
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_stretch.glsl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+uniform sampler2D img;
+uniform float m_stretch;
+uniform float m_alpha;
+varying vec2 m_cord;
+
+vec2 stretch(vec2 pos)
+{
+ // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b.
+ // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5
+ // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1)
+ float x = pos.x - 0.5;
+ return vec2(mix(x * abs(x) * 2.0, x, m_stretch) + 0.5, pos.y);
+}
+
+void main()
+{
+ gl_FragColor.rgb = texture2D(img, stretch(m_cord)).rgb;
+ gl_FragColor.a = m_alpha;
+}
diff --git a/system/shaders/GL/1.2/gl_videofilter_frag.glsl b/system/shaders/GL/1.2/gl_videofilter_frag.glsl
new file mode 100644
index 0000000..ff7af3b
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_videofilter_frag.glsl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+uniform sampler2D img;
+varying vec2 m_cord;
+
+void main()
+{
+ gl_FragColor.rgb = texture2D(img, m_cord).rgb;
+ gl_FragColor.a = gl_Color.a;
+}
diff --git a/system/shaders/GL/1.2/gl_videofilter_vertex.glsl b/system/shaders/GL/1.2/gl_videofilter_vertex.glsl
new file mode 100644
index 0000000..aa124b5
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_videofilter_vertex.glsl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 120
+
+attribute vec4 m_attrpos;
+attribute vec2 m_attrcord;
+varying vec2 m_cord;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+ m_cord = m_attrcord;
+}
diff --git a/system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl b/system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl
new file mode 100644
index 0000000..57c3a17
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#if(XBMC_texture_rectangle)
+# extension GL_ARB_texture_rectangle : enable
+# define texture2D texture2DRect
+# define sampler2D sampler2DRect
+#endif
+
+uniform sampler2D m_sampY;
+uniform sampler2D m_sampU;
+uniform sampler2D m_sampV;
+varying vec2 m_cordY;
+varying vec2 m_cordU;
+varying vec2 m_cordV;
+uniform vec2 m_step;
+uniform mat4 m_yuvmat;
+uniform float m_stretch;
+uniform mat3 m_primMat;
+uniform float m_gammaDstInv;
+uniform float m_gammaSrc;
+uniform float m_alpha;
+
+vec2 stretch(vec2 pos)
+{
+#if (XBMC_STRETCH)
+ // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b.
+ // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5
+ // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1)
+ #if(XBMC_texture_rectangle)
+ float x = (pos.x * m_step.x) - 0.5;
+ return vec2((mix(2.0 * x * abs(x), x, m_stretch) + 0.5) / m_step.x, pos.y);
+ #else
+ float x = pos.x - 0.5;
+ return vec2(mix(2.0 * x * abs(x), x, m_stretch) + 0.5, pos.y);
+ #endif
+#else
+ return pos;
+#endif
+}
+
+vec4 process()
+{
+ vec4 rgb;
+#if defined(XBMC_YV12)
+
+ vec4 yuv;
+ yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r
+ , texture2D(m_sampU, stretch(m_cordU)).r
+ , texture2D(m_sampV, stretch(m_cordV)).r
+ , 1.0 );
+
+ rgb = m_yuvmat * yuv;
+ rgb.a = m_alpha;
+
+#elif defined(XBMC_NV12)
+
+ vec4 yuv;
+ yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r
+ , texture2D(m_sampU, stretch(m_cordU)).rg
+ , 1.0 );
+
+ rgb = m_yuvmat * yuv;
+ rgb.a = m_alpha;
+
+#elif defined(XBMC_YUY2) || defined(XBMC_UYVY)
+
+#if(XBMC_texture_rectangle)
+ vec2 stepxy = vec2(1.0, 1.0);
+ vec2 pos = stretch(m_cordY);
+ pos = vec2(pos.x - 0.25, pos.y);
+ vec2 f = fract(pos);
+#else
+ vec2 stepxy = m_step;
+ vec2 pos = stretch(m_cordY);
+ pos = vec2(pos.x - stepxy.x * 0.25, pos.y);
+ vec2 f = fract(pos / stepxy);
+#endif
+
+ //y axis will be correctly interpolated by opengl
+ //x axis will not, so we grab two pixels at the center of two columns and interpolate ourselves
+ vec4 c1 = texture2D(m_sampY, vec2(pos.x + (0.5 - f.x) * stepxy.x, pos.y));
+ vec4 c2 = texture2D(m_sampY, vec2(pos.x + (1.5 - f.x) * stepxy.x, pos.y));
+
+ /* each pixel has two Y subpixels and one UV subpixel
+ YUV Y YUV
+ check if we're left or right of the middle Y subpixel and interpolate accordingly*/
+#ifdef XBMC_YUY2 //BGRA = YUYV
+ float leftY = mix(c1.b, c1.r, f.x * 2.0);
+ float rightY = mix(c1.r, c2.b, f.x * 2.0 - 1.0);
+ vec2 outUV = mix(c1.ga, c2.ga, f.x);
+#else //BGRA = UYVY
+ float leftY = mix(c1.g, c1.a, f.x * 2.0);
+ float rightY = mix(c1.a, c2.g, f.x * 2.0 - 1.0);
+ vec2 outUV = mix(c1.br, c2.br, f.x);
+#endif //XBMC_YUY2
+
+ float outY = mix(leftY, rightY, step(0.5, f.x));
+
+ vec4 yuv = vec4(outY, outUV, 1.0);
+ rgb = m_yuvmat * yuv;
+
+ rgb.a = m_alpha;
+
+#endif
+
+#if defined(XBMC_COL_CONVERSION)
+ rgb.rgb = pow(max(vec3(0), rgb.rgb), vec3(m_gammaSrc));
+ rgb.rgb = max(vec3(0), m_primMat * rgb.rgb);
+ rgb.rgb = pow(rgb.rgb, vec3(m_gammaDstInv));
+#endif
+
+ return rgb;
+}
diff --git a/system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl b/system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl
new file mode 100644
index 0000000..cdf3c56
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+attribute vec4 m_attrpos;
+attribute vec2 m_attrcordY;
+attribute vec2 m_attrcordU;
+attribute vec2 m_attrcordV;
+varying vec2 m_cordY;
+varying vec2 m_cordU;
+varying vec2 m_cordV;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+ m_cordY = m_attrcordY;
+ m_cordU = m_attrcordU;
+ m_cordV = m_attrcordV;
+}
diff --git a/system/shaders/GL/1.5/gl_convolution-4x4.glsl b/system/shaders/GL/1.5/gl_convolution-4x4.glsl
new file mode 100644
index 0000000..2a6404e
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_convolution-4x4.glsl
@@ -0,0 +1,71 @@
+#version 150
+
+uniform sampler2D img;
+uniform vec2 stepxy;
+uniform float m_stretch;
+uniform float m_alpha;
+in vec2 m_cord;
+out vec4 fragColor;
+uniform sampler1D kernelTex;
+
+vec4 weight(float pos)
+{
+#if defined(HAS_FLOAT_TEXTURE)
+ return texture(kernelTex, pos);
+#else
+ return texture(kernelTex, pos) * 2.0 - 1.0;
+#endif
+}
+
+vec2 stretch(vec2 pos)
+{
+#if (XBMC_STRETCH)
+ // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b.
+ // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5
+ // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1)
+ float x = pos.x - 0.5;
+ return vec2(mix(x * abs(x) * 2.0, x, m_stretch) + 0.5, pos.y);
+#else
+ return pos;
+#endif
+}
+
+vec3 pixel(float xpos, float ypos)
+{
+ return texture(img, vec2(xpos, ypos)).rgb;
+}
+
+vec3 line (float ypos, vec4 xpos, vec4 linetaps)
+{
+ return
+ pixel(xpos.r, ypos) * linetaps.r +
+ pixel(xpos.g, ypos) * linetaps.g +
+ pixel(xpos.b, ypos) * linetaps.b +
+ pixel(xpos.a, ypos) * linetaps.a;
+}
+
+vec4 process()
+{
+ vec4 rgb;
+ vec2 pos = stretch(m_cord) + stepxy * 0.5;
+ vec2 f = fract(pos / stepxy);
+
+ vec4 linetaps = weight(1.0 - f.x);
+ vec4 columntaps = weight(1.0 - f.y);
+
+ //make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur
+ linetaps /= linetaps.r + linetaps.g + linetaps.b + linetaps.a;
+ columntaps /= columntaps.r + columntaps.g + columntaps.b + columntaps.a;
+
+ vec2 xystart = (-1.5 - f) * stepxy + pos;
+ vec4 xpos = vec4(xystart.x, xystart.x + stepxy.x, xystart.x + stepxy.x * 2.0, xystart.x + stepxy.x * 3.0);
+
+ rgb.rgb =
+ line(xystart.y , xpos, linetaps) * columntaps.r +
+ line(xystart.y + stepxy.y , xpos, linetaps) * columntaps.g +
+ line(xystart.y + stepxy.y * 2.0, xpos, linetaps) * columntaps.b +
+ line(xystart.y + stepxy.y * 3.0, xpos, linetaps) * columntaps.a;
+
+ rgb.a = m_alpha;
+ return rgb;
+}
diff --git a/system/shaders/GL/1.5/gl_convolution-6x6.glsl b/system/shaders/GL/1.5/gl_convolution-6x6.glsl
new file mode 100644
index 0000000..b4410cc
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_convolution-6x6.glsl
@@ -0,0 +1,83 @@
+#version 150
+
+uniform sampler2D img;
+uniform vec2 stepxy;
+uniform float m_stretch;
+uniform float m_alpha;
+in vec2 m_cord;
+out vec4 fragColor;
+uniform sampler1D kernelTex;
+
+vec3 weight(float pos)
+{
+#if defined(HAS_FLOAT_TEXTURE)
+ return texture(kernelTex, pos).rgb;
+#else
+ return texture(kernelTex, pos).rgb * 2.0 - 1.0;
+#endif
+}
+
+vec2 stretch(vec2 pos)
+{
+#if (XBMC_STRETCH)
+ // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b.
+ // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5
+ // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1)
+ float x = pos.x - 0.5;
+ return vec2(mix(x * abs(x) * 2.0, x, m_stretch) + 0.5, pos.y);
+#else
+ return pos;
+#endif
+}
+
+vec3 pixel(float xpos, float ypos)
+{
+ return texture(img, vec2(xpos, ypos)).rgb;
+}
+
+vec3 line (float ypos, vec3 xpos1, vec3 xpos2, vec3 linetaps1, vec3 linetaps2)
+{
+ return
+ pixel(xpos1.r, ypos) * linetaps1.r +
+ pixel(xpos1.g, ypos) * linetaps2.r +
+ pixel(xpos1.b, ypos) * linetaps1.g +
+ pixel(xpos2.r, ypos) * linetaps2.g +
+ pixel(xpos2.g, ypos) * linetaps1.b +
+ pixel(xpos2.b, ypos) * linetaps2.b;
+}
+
+vec4 process()
+{
+ vec4 rgb;
+ vec2 pos = stretch(m_cord) + stepxy * 0.5;
+ vec2 f = fract(pos / stepxy);
+
+ vec3 linetaps1 = weight((1.0 - f.x) / 2.0);
+ vec3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5);
+ vec3 columntaps1 = weight((1.0 - f.y) / 2.0);
+ vec3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5);
+
+ //make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur
+ float sum = linetaps1.r + linetaps1.g + linetaps1.b + linetaps2.r + linetaps2.g + linetaps2.b;
+ linetaps1 /= sum;
+ linetaps2 /= sum;
+ sum = columntaps1.r + columntaps1.g + columntaps1.b + columntaps2.r + columntaps2.g + columntaps2.b;
+ columntaps1 /= sum;
+ columntaps2 /= sum;
+
+ vec2 xystart = (-2.5 - f) * stepxy + pos;
+ vec3 xpos1 = vec3(xystart.x, xystart.x + stepxy.x, xystart.x + stepxy.x * 2.0);
+ vec3 xpos2 = vec3(xystart.x + stepxy.x * 3.0, xystart.x + stepxy.x * 4.0, xystart.x + stepxy.x * 5.0);
+
+ rgb.rgb =
+ line(xystart.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r +
+ line(xystart.y + stepxy.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r +
+ line(xystart.y + stepxy.y * 2.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g +
+ line(xystart.y + stepxy.y * 3.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g +
+ line(xystart.y + stepxy.y * 4.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b +
+ line(xystart.y + stepxy.y * 5.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b;
+
+ rgb.a = m_alpha;
+
+ return rgb;
+}
diff --git a/system/shaders/GL/1.5/gl_output.glsl b/system/shaders/GL/1.5/gl_output.glsl
new file mode 100644
index 0000000..9823102
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_output.glsl
@@ -0,0 +1,37 @@
+#if defined(XBMC_DITHER)
+uniform sampler2D m_dither;
+uniform float m_ditherquant;
+uniform vec2 m_dithersize;
+#endif
+#if defined(KODI_3DLUT)
+uniform float m_CLUTsize;
+uniform sampler3D m_CLUT;
+#endif
+
+void main()
+{
+ vec4 rgb = process();
+
+#if defined(KODI_3DLUT)
+ // FIXME: can this be optimized?
+ rgb = texture(m_CLUT, (rgb.rgb*(m_CLUTsize-1.0) + 0.5) / m_CLUTsize);
+#endif
+
+#if defined(XBMC_FULLRANGE)
+#if __VERSION__ <= 120
+ rgb = (rgb-(16.0/255.0)) * 255.0/219.0;
+#else
+ rgb = clamp((rgb-(16.0/255.0)) * 255.0/219.0, 0, 1);
+#endif
+#endif
+
+#if defined(XBMC_DITHER)
+ vec2 ditherpos = gl_FragCoord.xy / m_dithersize;
+ // ditherval is multiplied by 65536/(dither_size^2) to make it [0,1[
+ // FIXME: scale dither values before uploading?
+ float ditherval = texture(m_dither, ditherpos).r * 16.0;
+ rgb = floor(rgb * m_ditherquant + ditherval) / m_ditherquant;
+#endif
+
+ fragColor = rgb;
+}
diff --git a/system/shaders/GL/1.5/gl_shader_frag_default.glsl b/system/shaders/GL/1.5/gl_shader_frag_default.glsl
new file mode 100644
index 0000000..d57f576
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_frag_default.glsl
@@ -0,0 +1,14 @@
+#version 150
+
+uniform vec4 m_unicol;
+out vec4 fragColor;
+
+// SM_DEFAULT shader
+void main ()
+{
+ fragColor = m_unicol;
+#if defined(KODI_LIMITED_RANGE)
+ fragColor.rgb *= (235.0-16.0) / 255.0;
+ fragColor.rgb += 16.0 / 255.0;
+#endif
+}
diff --git a/system/shaders/GL/1.5/gl_shader_frag_fonts.glsl b/system/shaders/GL/1.5/gl_shader_frag_fonts.glsl
new file mode 100644
index 0000000..1de6ddc
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_frag_fonts.glsl
@@ -0,0 +1,19 @@
+#version 150
+
+uniform sampler2D m_samp0;
+in vec4 m_cord0;
+in vec4 m_colour;
+out vec4 fragColor;
+
+// SM_FONTS shader
+void main ()
+{
+ fragColor.r = m_colour.r;
+ fragColor.g = m_colour.g;
+ fragColor.b = m_colour.b;
+ fragColor.a = m_colour.a * texture(m_samp0, m_cord0.xy).r;
+#if defined(KODI_LIMITED_RANGE)
+ fragColor.rgb *= (235.0-16.0) / 255.0;
+ fragColor.rgb += 16.0 / 255.0;
+#endif
+}
diff --git a/system/shaders/GL/1.5/gl_shader_frag_multi.glsl b/system/shaders/GL/1.5/gl_shader_frag_multi.glsl
new file mode 100644
index 0000000..3e6412b
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_frag_multi.glsl
@@ -0,0 +1,17 @@
+#version 150
+
+uniform sampler2D m_samp0;
+uniform sampler2D m_samp1;
+in vec4 m_cord0;
+in vec4 m_cord1;
+out vec4 fragColor;
+
+// SM_MULTI shader
+void main ()
+{
+ fragColor.rgba = (texture(m_samp0, m_cord0.xy) * texture(m_samp1, m_cord1.xy)).rgba;
+#if defined(KODI_LIMITED_RANGE)
+ fragColor.rgb *= (235.0-16.0) / 255.0;
+ fragColor.rgb += 16.0 / 255.0;
+#endif
+}
diff --git a/system/shaders/GL/1.5/gl_shader_frag_multi_blendcolor.glsl b/system/shaders/GL/1.5/gl_shader_frag_multi_blendcolor.glsl
new file mode 100644
index 0000000..96310ce
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_frag_multi_blendcolor.glsl
@@ -0,0 +1,18 @@
+#version 150
+
+uniform sampler2D m_samp0;
+uniform sampler2D m_samp1;
+uniform vec4 m_unicol;
+in vec4 m_cord0;
+in vec4 m_cord1;
+out vec4 fragColor;
+
+// SM_MULTI shader
+void main ()
+{
+ fragColor.rgba = m_unicol * texture(m_samp0, m_cord0.xy) * texture(m_samp1, m_cord1.xy);
+#if defined(KODI_LIMITED_RANGE)
+ fragColor.rgb *= (235.0-16.0) / 255.0;
+ fragColor.rgb += 16.0 / 255.0;
+#endif
+}
diff --git a/system/shaders/GL/1.5/gl_shader_frag_texture.glsl b/system/shaders/GL/1.5/gl_shader_frag_texture.glsl
new file mode 100644
index 0000000..71b1d21
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_frag_texture.glsl
@@ -0,0 +1,16 @@
+#version 150
+
+uniform sampler2D m_samp0;
+uniform vec4 m_unicol;
+in vec4 m_cord0;
+out vec4 fragColor;
+
+// SM_TEXTURE shader
+void main ()
+{
+ fragColor.rgba = vec4(texture(m_samp0, m_cord0.xy).rgba * m_unicol);
+#if defined(KODI_LIMITED_RANGE)
+ fragColor.rgb *= (235.0-16.0) / 255.0;
+ fragColor.rgb += 16.0 / 255.0;
+#endif
+}
diff --git a/system/shaders/GL/1.5/gl_shader_frag_texture_lim.glsl b/system/shaders/GL/1.5/gl_shader_frag_texture_lim.glsl
new file mode 100644
index 0000000..def4349
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_frag_texture_lim.glsl
@@ -0,0 +1,15 @@
+#version 150
+
+uniform sampler2D m_samp0;
+uniform vec4 m_unicol;
+in vec4 m_cord0;
+out vec4 fragColor;
+
+// SM_TEXTURE shader
+void main ()
+{
+ fragColor.rgba = vec4(texture(m_samp0, m_cord0.xy).rgba * m_unicol);
+#if !defined(KODI_LIMITED_RANGE)
+ fragColor.rgb = clamp((fragColor.rgb-(16.0/255.0)) * 255.0/219.0, 0, 1);
+#endif
+}
diff --git a/system/shaders/GL/1.5/gl_shader_frag_texture_noblend.glsl b/system/shaders/GL/1.5/gl_shader_frag_texture_noblend.glsl
new file mode 100644
index 0000000..e5d627e
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_frag_texture_noblend.glsl
@@ -0,0 +1,15 @@
+#version 150
+
+uniform sampler2D m_samp0;
+in vec4 m_cord0;
+out vec4 fragColor;
+
+// SM_TEXTURE_NOBLEND shader
+void main ()
+{
+ fragColor.rgba = vec4(texture(m_samp0, m_cord0.xy).rgba);
+#if defined(KODI_LIMITED_RANGE)
+ fragColor.rgb *= (235.0-16.0) / 255.0;
+ fragColor.rgb += 16.0 / 255.0;
+#endif
+}
diff --git a/system/shaders/GL/1.5/gl_shader_vert.glsl b/system/shaders/GL/1.5/gl_shader_vert.glsl
new file mode 100644
index 0000000..a856831
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_vert.glsl
@@ -0,0 +1,20 @@
+#version 150
+
+in vec4 m_attrpos;
+in vec4 m_attrcol;
+in vec4 m_attrcord0;
+in vec4 m_attrcord1;
+out vec4 m_cord0;
+out vec4 m_cord1;
+out vec4 m_colour;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+ m_colour = m_attrcol;
+ m_cord0 = m_attrcord0;
+ m_cord1 = m_attrcord1;
+}
diff --git a/system/shaders/GL/1.5/gl_shader_vert_default.glsl b/system/shaders/GL/1.5/gl_shader_vert_default.glsl
new file mode 100644
index 0000000..e4f2d7c
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_vert_default.glsl
@@ -0,0 +1,11 @@
+#version 150
+
+in vec4 m_attrpos;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+}
diff --git a/system/shaders/GL/1.5/gl_stretch.glsl b/system/shaders/GL/1.5/gl_stretch.glsl
new file mode 100644
index 0000000..9a31e54
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_stretch.glsl
@@ -0,0 +1,22 @@
+#version 150
+
+uniform sampler2D img;
+uniform float m_stretch;
+uniform float m_alpha;
+in vec2 m_cord;
+out vec4 fragColor;
+
+vec2 stretch(vec2 pos)
+{
+ // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b.
+ // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5
+ // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1)
+ float x = pos.x - 0.5;
+ return vec2(mix(x * abs(x) * 2.0, x, m_stretch) + 0.5, pos.y);
+}
+
+void main()
+{
+ fragColor.rgb = texture(img, stretch(m_cord)).rgb;
+ fragColor.a = m_alpha;
+}
diff --git a/system/shaders/GL/1.5/gl_tonemap.glsl b/system/shaders/GL/1.5/gl_tonemap.glsl
new file mode 100644
index 0000000..a70dca2
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_tonemap.glsl
@@ -0,0 +1,50 @@
+#if (defined(KODI_TONE_MAPPING_REINHARD) || defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE))
+const float ST2084_m1 = 2610.0 / (4096.0 * 4.0);
+const float ST2084_m2 = (2523.0 / 4096.0) * 128.0;
+const float ST2084_c1 = 3424.0 / 4096.0;
+const float ST2084_c2 = (2413.0 / 4096.0) * 32.0;
+const float ST2084_c3 = (2392.0 / 4096.0) * 32.0;
+#endif
+
+#if defined(KODI_TONE_MAPPING_REINHARD)
+float reinhard(float x)
+{
+ return x * (1.0 + x / (m_toneP1 * m_toneP1)) / (1.0 + x);
+}
+#endif
+
+#if defined(KODI_TONE_MAPPING_ACES)
+vec3 aces(vec3 x)
+{
+ float A = 2.51;
+ float B = 0.03;
+ float C = 2.43;
+ float D = 0.59;
+ float E = 0.14;
+ return (x * (A * x + B)) / (x * (C * x + D) + E);
+}
+#endif
+
+#if defined(KODI_TONE_MAPPING_HABLE)
+vec3 hable(vec3 x)
+{
+ float A = 0.15;
+ float B = 0.5;
+ float C = 0.1;
+ float D = 0.2;
+ float E = 0.02;
+ float F = 0.3;
+ return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
+}
+#endif
+
+#if (defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE))
+vec3 inversePQ(vec3 x)
+{
+ x = pow(max(x, 0.0), vec3(1.0 / ST2084_m2));
+ x = max(x - ST2084_c1, 0.0) / (ST2084_c2 - ST2084_c3 * x);
+ x = pow(x, vec3(1.0 / ST2084_m1));
+ return x;
+}
+#endif
+
diff --git a/system/shaders/GL/1.5/gl_videofilter_frag.glsl b/system/shaders/GL/1.5/gl_videofilter_frag.glsl
new file mode 100644
index 0000000..2eb4155
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_videofilter_frag.glsl
@@ -0,0 +1,12 @@
+#version 150
+
+uniform sampler2D img;
+uniform float m_alpha;
+in vec2 m_cord;
+out vec4 fragColor;
+
+void main()
+{
+ fragColor = texture(img, m_cord);
+ fragColor.a = m_alpha;
+}
diff --git a/system/shaders/GL/1.5/gl_videofilter_vertex.glsl b/system/shaders/GL/1.5/gl_videofilter_vertex.glsl
new file mode 100644
index 0000000..edb8847
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_videofilter_vertex.glsl
@@ -0,0 +1,14 @@
+#version 150
+
+in vec4 m_attrpos;
+in vec2 m_attrcord;
+out vec2 m_cord;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+ m_cord = m_attrcord;
+}
diff --git a/system/shaders/GL/1.5/gl_yuv2rgb_basic.glsl b/system/shaders/GL/1.5/gl_yuv2rgb_basic.glsl
new file mode 100644
index 0000000..7d5605c
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_yuv2rgb_basic.glsl
@@ -0,0 +1,123 @@
+#version 150
+
+#if(XBMC_texture_rectangle)
+# define texture2D texture2DRect
+# define sampler2D sampler2DRect
+#endif
+
+uniform sampler2D m_sampY;
+uniform sampler2D m_sampU;
+uniform sampler2D m_sampV;
+uniform vec2 m_step;
+uniform mat4 m_yuvmat;
+uniform float m_stretch;
+uniform float m_alpha;
+uniform mat3 m_primMat;
+uniform float m_gammaDstInv;
+uniform float m_gammaSrc;
+uniform float m_toneP1;
+uniform float m_luminance;
+uniform vec3 m_coefsDst;
+in vec2 m_cordY;
+in vec2 m_cordU;
+in vec2 m_cordV;
+out vec4 fragColor;
+
+vec2 stretch(vec2 pos)
+{
+#if (XBMC_STRETCH)
+ // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b.
+ // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5
+ // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1)
+ #if(XBMC_texture_rectangle)
+ float x = (pos.x * m_step.x) - 0.5;
+ return vec2((mix(2.0 * x * abs(x), x, m_stretch) + 0.5) / m_step.x, pos.y);
+ #else
+ float x = pos.x - 0.5;
+ return vec2(mix(2.0 * x * abs(x), x, m_stretch) + 0.5, pos.y);
+ #endif
+#else
+ return pos;
+#endif
+}
+
+vec4 process()
+{
+ vec4 rgb;
+ vec4 yuv;
+
+#if defined(XBMC_YV12)
+
+ yuv.rgba = vec4( texture(m_sampY, stretch(m_cordY)).r
+ , texture(m_sampU, stretch(m_cordU)).r
+ , texture(m_sampV, stretch(m_cordV)).r
+ , 1.0 );
+
+#elif defined(XBMC_NV12)
+
+ yuv.rgba = vec4( texture(m_sampY, stretch(m_cordY)).r
+ , texture(m_sampU, stretch(m_cordU)).rg
+ , 1.0 );
+
+#elif defined(XBMC_YUY2) || defined(XBMC_UYVY)
+
+ vec2 stepxy = m_step;
+ vec2 pos = stretch(m_cordY);
+ pos = vec2(pos.x - stepxy.x * 0.25, pos.y);
+ vec2 f = fract(pos / stepxy);
+
+ //y axis will be correctly interpolated by opengl
+ //x axis will not, so we grab two pixels at the center of two columns and interpolate ourselves
+ vec4 c1 = texture(m_sampY, vec2(pos.x + (0.5 - f.x) * stepxy.x, pos.y));
+ vec4 c2 = texture(m_sampY, vec2(pos.x + (1.5 - f.x) * stepxy.x, pos.y));
+
+ /* each pixel has two Y subpixels and one UV subpixel
+ YUV Y YUV
+ check if we're left or right of the middle Y subpixel and interpolate accordingly*/
+#ifdef XBMC_YUY2 //BGRA = YUYV
+ float leftY = mix(c1.b, c1.r, f.x * 2.0);
+ float rightY = mix(c1.r, c2.b, f.x * 2.0 - 1.0);
+ vec2 outUV = mix(c1.ga, c2.ga, f.x);
+#else //BGRA = UYVY
+ float leftY = mix(c1.g, c1.a, f.x * 2.0);
+ float rightY = mix(c1.a, c2.g, f.x * 2.0 - 1.0);
+ vec2 outUV = mix(c1.br, c2.br, f.x);
+#endif //XBMC_YUY2
+
+ float outY = mix(leftY, rightY, step(0.5, f.x));
+
+ yuv = vec4(outY, outUV, 1.0);
+
+#endif
+
+ rgb = m_yuvmat * yuv;
+ rgb.a = m_alpha;
+
+#if defined(XBMC_COL_CONVERSION)
+ rgb.rgb = pow(max(vec3(0), rgb.rgb), vec3(m_gammaSrc));
+ rgb.rgb = max(vec3(0), m_primMat * rgb.rgb);
+ rgb.rgb = pow(rgb.rgb, vec3(m_gammaDstInv));
+
+#if defined(KODI_TONE_MAPPING_REINHARD)
+ float luma = dot(rgb.rgb, m_coefsDst);
+ rgb.rgb *= reinhard(luma) / luma;
+
+#elif defined(KODI_TONE_MAPPING_ACES)
+ rgb.rgb = inversePQ(rgb.rgb);
+ rgb.rgb *= (10000.0 / m_luminance) * (2.0 / m_toneP1);
+ rgb.rgb = aces(rgb.rgb);
+ rgb.rgb *= (1.24 / m_toneP1);
+ rgb.rgb = pow(rgb.rgb, vec3(0.27));
+
+#elif defined(KODI_TONE_MAPPING_HABLE)
+ rgb.rgb = inversePQ(rgb.rgb);
+ rgb.rgb *= m_toneP1;
+ float wp = m_luminance / 100.0;
+ rgb.rgb = hable(rgb.rgb * wp) / hable(vec3(wp));
+ rgb.rgb = pow(rgb.rgb, vec3(1.0 / 2.2));
+#endif
+
+#endif
+
+ return rgb;
+}
diff --git a/system/shaders/GL/1.5/gl_yuv2rgb_vertex.glsl b/system/shaders/GL/1.5/gl_yuv2rgb_vertex.glsl
new file mode 100644
index 0000000..4772bd4
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_yuv2rgb_vertex.glsl
@@ -0,0 +1,20 @@
+#version 150
+
+uniform mat4 m_proj;
+uniform mat4 m_model;
+in vec4 m_attrpos;
+in vec2 m_attrcordY;
+in vec2 m_attrcordU;
+in vec2 m_attrcordV;
+out vec2 m_cordY;
+out vec2 m_cordU;
+out vec2 m_cordV;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+ m_cordY = m_attrcordY;
+ m_cordU = m_attrcordU;
+ m_cordV = m_attrcordV;
+}
diff --git a/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl b/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl
new file mode 100644
index 0000000..8a4658c
--- /dev/null
+++ b/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl
@@ -0,0 +1,141 @@
+#version 400
+
+#if(XBMC_texture_rectangle)
+# define texture2D texture2DRect
+# define sampler2D sampler2DRect
+#endif
+
+uniform sampler2D m_sampY;
+uniform sampler2D m_sampU;
+uniform sampler2D m_sampV;
+uniform vec2 m_step;
+uniform mat4 m_yuvmat;
+uniform float m_stretch;
+uniform float m_alpha;
+uniform sampler1D m_kernelTex;
+uniform mat3 m_primMat;
+uniform float m_gammaDstInv;
+uniform float m_gammaSrc;
+uniform float m_toneP1;
+uniform float m_luminance;
+uniform vec3 m_coefsDst;
+in vec2 m_cordY;
+in vec2 m_cordU;
+in vec2 m_cordV;
+out vec4 fragColor;
+
+vec2 stretch(vec2 pos)
+{
+#if (XBMC_STRETCH)
+ // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b.
+ // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5
+ // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1)
+ #if(XBMC_texture_rectangle)
+ float x = (pos.x * m_step.x) - 0.5;
+ return vec2((mix(2.0 * x * abs(x), x, m_stretch) + 0.5) / m_step.x, pos.y);
+ #else
+ float x = pos.x - 0.5;
+ return vec2(mix(2.0 * x * abs(x), x, m_stretch) + 0.5, pos.y);
+ #endif
+#else
+ return pos;
+#endif
+}
+
+vec4[4] load4x4_0(sampler2D sampler, vec2 pos)
+{
+ vec4[4] tex4x4;
+ vec4 tex2x2 = textureGather(sampler, pos, 0);
+ tex4x4[0].xy = tex2x2.wz;
+ tex4x4[1].xy = tex2x2.xy;
+ tex2x2 = textureGatherOffset(sampler, pos, ivec2(2,0), 0);
+ tex4x4[0].zw = tex2x2.wz;
+ tex4x4[1].zw = tex2x2.xy;
+ tex2x2 = textureGatherOffset(sampler, pos, ivec2(0,2), 0);
+ tex4x4[2].xy = tex2x2.wz;
+ tex4x4[3].xy = tex2x2.xy;
+ tex2x2 = textureGatherOffset(sampler, pos, ivec2(2,2), 0);
+ tex4x4[2].zw = tex2x2.wz;
+ tex4x4[3].zw = tex2x2.xy;
+ return tex4x4;
+}
+
+float filter_0(sampler2D sampler, vec2 coord)
+{
+ vec2 pos = coord + m_step * 0.5;
+ vec2 f = fract(pos / m_step);
+
+ vec4 linetaps = texture(m_kernelTex, 1.0 - f.x);
+ vec4 coltaps = texture(m_kernelTex, 1.0 - f.y);
+ linetaps /= linetaps.r + linetaps.g + linetaps.b + linetaps.a;
+ coltaps /= coltaps.r + coltaps.g + coltaps.b + coltaps.a;
+ mat4 conv;
+ conv[0] = linetaps * coltaps.x;
+ conv[1] = linetaps * coltaps.y;
+ conv[2] = linetaps * coltaps.z;
+ conv[3] = linetaps * coltaps.w;
+
+ vec2 startPos = (-1.0 - f) * m_step + pos;
+ vec4[4] tex4x4 = load4x4_0(sampler, startPos);
+ vec4 imageLine0 = tex4x4[0];
+ vec4 imageLine1 = tex4x4[1];
+ vec4 imageLine2 = tex4x4[2];
+ vec4 imageLine3 = tex4x4[3];
+
+ return dot(imageLine0, conv[0]) +
+ dot(imageLine1, conv[1]) +
+ dot(imageLine2, conv[2]) +
+ dot(imageLine3, conv[3]);
+}
+
+vec4 process()
+{
+ vec4 rgb;
+ vec4 yuv;
+
+#if defined(XBMC_YV12)
+
+ yuv = vec4(filter_0(m_sampY, stretch(m_cordY)),
+ texture(m_sampU, stretch(m_cordU)).r,
+ texture(m_sampV, stretch(m_cordV)).r,
+ 1.0);
+
+#elif defined(XBMC_NV12)
+
+ yuv = vec4(filter_0(m_sampY, stretch(m_cordY)),
+ texture(m_sampU, stretch(m_cordU)).rg,
+ 1.0);
+
+#endif
+
+ rgb = m_yuvmat * yuv;
+ rgb.a = m_alpha;
+
+#if defined(XBMC_COL_CONVERSION)
+ rgb.rgb = pow(max(vec3(0), rgb.rgb), vec3(m_gammaSrc));
+ rgb.rgb = max(vec3(0), m_primMat * rgb.rgb);
+ rgb.rgb = pow(rgb.rgb, vec3(m_gammaDstInv));
+
+#if defined(KODI_TONE_MAPPING_REINHARD)
+ float luma = dot(rgb.rgb, m_coefsDst);
+ rgb.rgb *= reinhard(luma) / luma;
+
+#elif defined(KODI_TONE_MAPPING_ACES)
+ rgb.rgb = inversePQ(rgb.rgb);
+ rgb.rgb *= (10000.0 / m_luminance) * (2.0 / m_toneP1);
+ rgb.rgb = aces(rgb.rgb);
+ rgb.rgb *= (1.24 / m_toneP1);
+ rgb.rgb = pow(rgb.rgb, vec3(0.27));
+
+#elif defined(KODI_TONE_MAPPING_HABLE)
+ rgb.rgb = inversePQ(rgb.rgb);
+ rgb.rgb *= m_toneP1;
+ float wp = m_luminance / 100.0;
+ rgb.rgb = hable(rgb.rgb * wp) / hable(vec3(wp));
+ rgb.rgb = pow(rgb.rgb, vec3(1.0 / 2.2));
+#endif
+
+#endif
+
+ return rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_convolution-4x4.frag b/system/shaders/GLES/2.0/gles_convolution-4x4.frag
new file mode 100644
index 0000000..3043b10
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_convolution-4x4.frag
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision highp float;
+
+uniform sampler2D img;
+uniform vec2 stepxy;
+varying vec2 cord;
+uniform float m_alpha;
+uniform sampler2D kernelTex;
+
+vec4 weight(float pos)
+{
+#if defined(HAS_FLOAT_TEXTURE)
+ return texture2D(kernelTex, vec2(pos, 0.5));
+#else
+ return texture2D(kernelTex, vec2(pos - 0.5)) * 2.0 - 1.0;
+#endif
+}
+
+vec3 pixel(float xpos, float ypos)
+{
+ return texture2D(img, vec2(xpos, ypos)).rgb;
+}
+
+vec3 line (float ypos, vec4 xpos, vec4 linetaps)
+{
+ return pixel(xpos.r, ypos) * linetaps.r +
+ pixel(xpos.g, ypos) * linetaps.g +
+ pixel(xpos.b, ypos) * linetaps.b +
+ pixel(xpos.a, ypos) * linetaps.a;
+}
+
+void main()
+{
+ vec4 rgb;
+ vec2 pos = cord + stepxy * 0.5;
+ vec2 f = fract(pos / stepxy);
+
+ vec4 linetaps = weight(1.0 - f.x);
+ vec4 columntaps = weight(1.0 - f.y);
+
+ // make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur
+ linetaps /= linetaps.r + linetaps.g + linetaps.b + linetaps.a;
+ columntaps /= columntaps.r + columntaps.g + columntaps.b + columntaps.a;
+
+ vec2 xystart = (-1.5 - f) * stepxy + pos;
+ vec4 xpos = vec4(xystart.x, xystart.x + stepxy.x, xystart.x + stepxy.x * 2.0, xystart.x + stepxy.x * 3.0);
+
+ rgb.rgb = line(xystart.y, xpos, linetaps) * columntaps.r +
+ line(xystart.y + stepxy.y, xpos, linetaps) * columntaps.g +
+ line(xystart.y + stepxy.y * 2.0, xpos, linetaps) * columntaps.b +
+ line(xystart.y + stepxy.y * 3.0, xpos, linetaps) * columntaps.a;
+
+ rgb.a = m_alpha;
+
+ gl_FragColor = rgb;
+}
+
diff --git a/system/shaders/GLES/2.0/gles_convolution-6x6.frag b/system/shaders/GLES/2.0/gles_convolution-6x6.frag
new file mode 100644
index 0000000..d043c75
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_convolution-6x6.frag
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision highp float;
+
+uniform sampler2D img;
+uniform vec2 stepxy;
+varying vec2 cord;
+uniform float m_alpha;
+uniform sampler2D kernelTex;
+
+vec3 weight(float pos)
+{
+#if defined(HAS_FLOAT_TEXTURE)
+ return texture2D(kernelTex, vec2(pos, 0.5)).rgb;
+#else
+ return texture2D(kernelTex, vec2(pos - 0.5)).rgb * 2.0 - 1.0;
+#endif
+}
+
+vec3 pixel(float xpos, float ypos)
+{
+ return texture2D(img, vec2(xpos, ypos)).rgb;
+}
+
+vec3 line (float ypos, vec3 xpos1, vec3 xpos2, vec3 linetaps1, vec3 linetaps2)
+{
+ return pixel(xpos1.r, ypos) * linetaps1.r +
+ pixel(xpos1.g, ypos) * linetaps2.r +
+ pixel(xpos1.b, ypos) * linetaps1.g +
+ pixel(xpos2.r, ypos) * linetaps2.g +
+ pixel(xpos2.g, ypos) * linetaps1.b +
+ pixel(xpos2.b, ypos) * linetaps2.b;
+}
+
+void main()
+{
+ vec4 rgb;
+ vec2 pos = cord + stepxy * 0.5;
+ vec2 f = fract(pos / stepxy);
+
+ vec3 linetaps1 = weight((1.0 - f.x) / 2.0);
+ vec3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5);
+ vec3 columntaps1 = weight((1.0 - f.y) / 2.0);
+ vec3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5);
+
+ // make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur
+ float sum = linetaps1.r + linetaps1.g + linetaps1.b + linetaps2.r + linetaps2.g + linetaps2.b;
+ linetaps1 /= sum;
+ linetaps2 /= sum;
+ sum = columntaps1.r + columntaps1.g + columntaps1.b + columntaps2.r + columntaps2.g + columntaps2.b;
+ columntaps1 /= sum;
+ columntaps2 /= sum;
+
+ vec2 xystart = (-2.5 - f) * stepxy + pos;
+ vec3 xpos1 = vec3(xystart.x, xystart.x + stepxy.x, xystart.x + stepxy.x * 2.0);
+ vec3 xpos2 = vec3(xystart.x + stepxy.x * 3.0, xystart.x + stepxy.x * 4.0, xystart.x + stepxy.x * 5.0);
+
+ rgb.rgb = line(xystart.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r +
+ line(xystart.y + stepxy.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r +
+ line(xystart.y + stepxy.y * 2.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g +
+ line(xystart.y + stepxy.y * 3.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g +
+ line(xystart.y + stepxy.y * 4.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b +
+ line(xystart.y + stepxy.y * 5.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b;
+
+ rgb.a = m_alpha;
+
+ gl_FragColor = rgb;
+}
+
diff --git a/system/shaders/GLES/2.0/gles_shader.vert b/system/shaders/GLES/2.0/gles_shader.vert
new file mode 100644
index 0000000..890acbb
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader.vert
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+attribute vec4 m_attrpos;
+attribute vec4 m_attrcol;
+attribute vec4 m_attrcord0;
+attribute vec4 m_attrcord1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+varying lowp vec4 m_colour;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+uniform mat4 m_coord0Matrix;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+ m_colour = m_attrcol;
+ m_cord0 = m_coord0Matrix * m_attrcord0;
+ m_cord1 = m_attrcord1;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_default.frag b/system/shaders/GLES/2.0/gles_shader_default.frag
new file mode 100644
index 0000000..f213360
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_default.frag
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision mediump float;
+uniform lowp vec4 m_unicol;
+
+void main ()
+{
+ vec4 rgb;
+
+ rgb = m_unicol;
+
+#if defined(KODI_LIMITED_RANGE)
+ rgb.rgb *= (235.0 - 16.0) / 255.0;
+ rgb.rgb += 16.0 / 255.0;
+#endif
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_fonts.frag b/system/shaders/GLES/2.0/gles_shader_fonts.frag
new file mode 100644
index 0000000..075d26f
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_fonts.frag
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision mediump float;
+uniform sampler2D m_samp0;
+varying vec4 m_cord0;
+varying lowp vec4 m_colour;
+
+void main ()
+{
+ vec4 rgb;
+
+ rgb.rgb = m_colour.rgb;
+ rgb.a = m_colour.a * texture2D(m_samp0, m_cord0.xy).a;
+
+#if defined(KODI_LIMITED_RANGE)
+ rgb.rgb *= (235.0 - 16.0) / 255.0;
+ rgb.rgb += 16.0 / 255.0;
+#endif
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_multi.frag b/system/shaders/GLES/2.0/gles_shader_multi.frag
new file mode 100644
index 0000000..9f28898
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_multi.frag
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision mediump float;
+uniform sampler2D m_samp0;
+uniform sampler2D m_samp1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+
+void main ()
+{
+ vec4 rgb;
+
+ rgb = texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy);
+
+#if defined(KODI_LIMITED_RANGE)
+ rgb.rgb *= (235.0 - 16.0) / 255.0;
+ rgb.rgb += 16.0 / 255.0;
+#endif
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag b/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag
new file mode 100644
index 0000000..35153da
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision mediump float;
+uniform sampler2D m_samp0;
+uniform sampler2D m_samp1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+uniform lowp vec4 m_unicol;
+
+void main ()
+{
+ vec4 rgb;
+
+ rgb = m_unicol * texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy);
+
+#if defined(KODI_LIMITED_RANGE)
+ rgb.rgb *= (235.0 - 16.0) / 255.0;
+ rgb.rgb += 16.0 / 255.0;
+#endif
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_rgba.frag b/system/shaders/GLES/2.0/gles_shader_rgba.frag
new file mode 100644
index 0000000..cdbb076
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_rgba.frag
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision mediump float;
+uniform sampler2D m_samp0;
+uniform sampler2D m_samp1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+varying lowp vec4 m_colour;
+uniform int m_method;
+
+uniform float m_brightness;
+uniform float m_contrast;
+
+void main ()
+{
+ vec4 rgb;
+
+ rgb = texture2D(m_samp0, m_cord0.xy);
+ rgb *= m_contrast;
+ rgb += m_brightness;
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_rgba_blendcolor.frag b/system/shaders/GLES/2.0/gles_shader_rgba_blendcolor.frag
new file mode 100644
index 0000000..3f08da0
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_rgba_blendcolor.frag
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision mediump float;
+uniform sampler2D m_samp0;
+uniform sampler2D m_samp1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+varying lowp vec4 m_colour;
+uniform int m_method;
+
+void main ()
+{
+ vec4 rgb;
+
+ rgb = texture2D(m_samp0, m_cord0.xy).rgba * m_colour;
+
+#if defined(KODI_LIMITED_RANGE)
+ rgb.rgb *= (235.0 - 16.0) / 255.0;
+ rgb.rgb += 16.0 / 255.0;
+#endif
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_rgba_bob.frag b/system/shaders/GLES/2.0/gles_shader_rgba_bob.frag
new file mode 100644
index 0000000..fd4a83b
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_rgba_bob.frag
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision highp float;
+uniform sampler2D m_samp0;
+uniform sampler2D m_samp1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+varying lowp vec4 m_colour;
+uniform int m_method;
+uniform int m_field;
+uniform float m_step;
+
+uniform float m_brightness;
+uniform float m_contrast;
+
+void main ()
+{
+ vec2 source;
+ source = m_cord0.xy;
+
+ float temp1 = mod(source.y, 2.0 * m_step);
+ float temp2 = source.y - temp1;
+ source.y = temp2 + m_step / 2.0 - float(m_field) * m_step;
+
+ // Blend missing line
+ vec2 below;
+ float bstep = step(m_step, temp1);
+ below.x = source.x;
+ below.y = source.y + (2.0 * m_step * bstep);
+
+ vec4 color = mix(texture2D(m_samp0, source), texture2D(m_samp0, below), 0.5);
+ color *= m_contrast;
+ color += m_brightness;
+
+ gl_FragColor = color;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_rgba_bob_oes.frag b/system/shaders/GLES/2.0/gles_shader_rgba_bob_oes.frag
new file mode 100644
index 0000000..16894af
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_rgba_bob_oes.frag
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+#extension GL_OES_EGL_image_external : require
+
+precision highp float;
+uniform samplerExternalOES m_samp0;
+uniform samplerExternalOES m_samp1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+varying lowp vec4 m_colour;
+uniform int m_method;
+uniform int m_field;
+uniform float m_step;
+
+uniform float m_brightness;
+uniform float m_contrast;
+
+void main ()
+{
+ vec2 source;
+ source = m_cord0.xy;
+
+ float temp1 = mod(source.y, 2.0 * m_step);
+ float temp2 = source.y - temp1;
+ source.y = temp2 + m_step / 2.0 - float(m_field) * m_step;
+
+ // Blend missing line
+ vec2 below;
+ float bstep = step(m_step, temp1);
+ below.x = source.x;
+ below.y = source.y + (2.0*m_step * bstep);
+
+ vec4 color = mix(texture2D(m_samp0, source), texture2D(m_samp0, below), 0.5);
+ color *= m_contrast;
+ color += m_brightness;
+
+ gl_FragColor = color;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_rgba_oes.frag b/system/shaders/GLES/2.0/gles_shader_rgba_oes.frag
new file mode 100644
index 0000000..2936954
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_rgba_oes.frag
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+#extension GL_OES_EGL_image_external : require
+
+precision mediump float;
+uniform samplerExternalOES m_samp0;
+varying vec4 m_cord0;
+
+uniform float m_brightness;
+uniform float m_contrast;
+
+void main ()
+{
+ vec4 rgb;
+
+ rgb = texture2D(m_samp0, m_cord0.xy);
+ rgb *= m_contrast;
+ rgb += m_brightness;
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_texture.frag b/system/shaders/GLES/2.0/gles_shader_texture.frag
new file mode 100644
index 0000000..a2ac2de
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_texture.frag
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision mediump float;
+uniform sampler2D m_samp0;
+uniform lowp vec4 m_unicol;
+varying vec4 m_cord0;
+
+void main ()
+{
+ vec4 rgb;
+
+ rgb = texture2D(m_samp0, m_cord0.xy).rgba * m_unicol;
+
+#if defined(KODI_LIMITED_RANGE)
+ rgb.rgb *= (235.0 - 16.0) / 255.0;
+ rgb.rgb += 16.0 / 255.0;
+#endif
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_texture_noalpha.frag b/system/shaders/GLES/2.0/gles_shader_texture_noalpha.frag
new file mode 100644
index 0000000..9f478ed
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_texture_noalpha.frag
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2019 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#version 100
+
+precision mediump float;
+uniform sampler2D m_samp0;
+varying vec4 m_cord0;
+
+void main ()
+{
+ vec3 rgb = texture2D(m_samp0, m_cord0.xy).rgb;
+
+#if defined(KODI_LIMITED_RANGE)
+ rgb *= (235.0 - 16.0) / 255.0;
+ rgb += 16.0 / 255.0;
+#endif
+
+ gl_FragColor = vec4(rgb, 1.0);
+}
diff --git a/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag b/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag
new file mode 100644
index 0000000..8cc66c9
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision mediump float;
+uniform sampler2D m_samp0;
+varying vec4 m_cord0;
+
+void main ()
+{
+ vec4 rgb;
+
+ rgb = texture2D(m_samp0, m_cord0.xy);
+
+#if defined(KODI_LIMITED_RANGE)
+ rgb.rgb *= (235.0 - 16.0) / 255.0;
+ rgb.rgb += 16.0 / 255.0;
+#endif
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/GLES/2.0/gles_tonemap.frag b/system/shaders/GLES/2.0/gles_tonemap.frag
new file mode 100644
index 0000000..28b2402
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_tonemap.frag
@@ -0,0 +1,50 @@
+#if (defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE))
+const float ST2084_m1 = 2610.0 / (4096.0 * 4.0);
+const float ST2084_m2 = (2523.0 / 4096.0) * 128.0;
+const float ST2084_c1 = 3424.0 / 4096.0;
+const float ST2084_c2 = (2413.0 / 4096.0) * 32.0;
+const float ST2084_c3 = (2392.0 / 4096.0) * 32.0;
+#endif
+
+#if defined(KODI_TONE_MAPPING_REINHARD)
+float reinhard(float x)
+{
+ return x * (1.0 + x / (m_toneP1 * m_toneP1)) / (1.0 + x);
+}
+#endif
+
+#if defined(KODI_TONE_MAPPING_ACES)
+vec3 aces(vec3 x)
+{
+ float A = 2.51;
+ float B = 0.03;
+ float C = 2.43;
+ float D = 0.59;
+ float E = 0.14;
+ return (x * (A * x + B)) / (x * (C * x + D) + E);
+}
+#endif
+
+#if defined(KODI_TONE_MAPPING_HABLE)
+vec3 hable(vec3 x)
+{
+ float A = 0.15;
+ float B = 0.5;
+ float C = 0.1;
+ float D = 0.2;
+ float E = 0.02;
+ float F = 0.3;
+ return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
+}
+#endif
+
+#if (defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE))
+vec3 inversePQ(vec3 x)
+{
+ x = pow(max(x, 0.0), vec3(1.0 / ST2084_m2));
+ x = max(x - ST2084_c1, 0.0) / (ST2084_c2 - ST2084_c3 * x);
+ x = pow(x, vec3(1.0 / ST2084_m1));
+ return x;
+}
+#endif
+
diff --git a/system/shaders/GLES/2.0/gles_videofilter.frag b/system/shaders/GLES/2.0/gles_videofilter.frag
new file mode 100644
index 0000000..d4c15ee
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_videofilter.frag
@@ -0,0 +1,11 @@
+#version 100
+
+precision mediump float;
+
+uniform sampler2D img;
+varying vec2 cord;
+
+void main()
+{
+ gl_FragColor = texture2D(img, cord);
+} \ No newline at end of file
diff --git a/system/shaders/GLES/2.0/gles_videofilter.vert b/system/shaders/GLES/2.0/gles_videofilter.vert
new file mode 100644
index 0000000..2d5a0f9
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_videofilter.vert
@@ -0,0 +1,14 @@
+#version 100
+
+attribute vec4 m_attrpos;
+attribute vec2 m_attrcord;
+varying vec2 cord;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+ cord = m_attrcord.xy;
+}
diff --git a/system/shaders/GLES/2.0/gles_yuv2rgb.vert b/system/shaders/GLES/2.0/gles_yuv2rgb.vert
new file mode 100644
index 0000000..bc437af
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_yuv2rgb.vert
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+attribute vec4 m_attrpos;
+attribute vec2 m_attrcordY;
+attribute vec2 m_attrcordU;
+attribute vec2 m_attrcordV;
+varying vec2 m_cordY;
+varying vec2 m_cordU;
+varying vec2 m_cordV;
+uniform mat4 m_proj;
+uniform mat4 m_model;
+
+void main ()
+{
+ mat4 mvp = m_proj * m_model;
+ gl_Position = mvp * m_attrpos;
+ m_cordY = m_attrcordY;
+ m_cordU = m_attrcordU;
+ m_cordV = m_attrcordV;
+}
diff --git a/system/shaders/GLES/2.0/gles_yuv2rgb_basic.frag b/system/shaders/GLES/2.0/gles_yuv2rgb_basic.frag
new file mode 100644
index 0000000..d76a3b8
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_yuv2rgb_basic.frag
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision mediump float;
+
+uniform sampler2D m_sampY;
+uniform sampler2D m_sampU;
+uniform sampler2D m_sampV;
+varying vec2 m_cordY;
+varying vec2 m_cordU;
+varying vec2 m_cordV;
+uniform vec2 m_step;
+uniform mat4 m_yuvmat;
+uniform mat3 m_primMat;
+uniform float m_gammaDstInv;
+uniform float m_gammaSrc;
+uniform float m_toneP1;
+uniform float m_luminance;
+uniform vec3 m_coefsDst;
+uniform float m_alpha;
+
+void main()
+{
+ vec4 rgb;
+ vec4 yuv;
+
+#if defined(XBMC_YV12) || defined(XBMC_NV12)
+
+ yuv = vec4(texture2D(m_sampY, m_cordY).r,
+ texture2D(m_sampU, m_cordU).g,
+ texture2D(m_sampV, m_cordV).a,
+ 1.0);
+
+#elif defined(XBMC_NV12_RRG)
+
+ yuv = vec4(texture2D(m_sampY, m_cordY).r,
+ texture2D(m_sampU, m_cordU).r,
+ texture2D(m_sampV, m_cordV).g,
+ 1.0);
+
+#endif
+
+ rgb = m_yuvmat * yuv;
+ rgb.a = m_alpha;
+
+#if defined(XBMC_COL_CONVERSION)
+ rgb.rgb = pow(max(vec3(0), rgb.rgb), vec3(m_gammaSrc));
+ rgb.rgb = max(vec3(0), m_primMat * rgb.rgb);
+ rgb.rgb = pow(rgb.rgb, vec3(m_gammaDstInv));
+
+#if defined(KODI_TONE_MAPPING_REINHARD)
+ float luma = dot(rgb.rgb, m_coefsDst);
+ rgb.rgb *= reinhard(luma) / luma;
+
+#elif defined(KODI_TONE_MAPPING_ACES)
+ rgb.rgb = inversePQ(rgb.rgb);
+ rgb.rgb *= (10000.0 / m_luminance) * (2.0 / m_toneP1);
+ rgb.rgb = aces(rgb.rgb);
+ rgb.rgb *= (1.24 / m_toneP1);
+ rgb.rgb = pow(rgb.rgb, vec3(0.27));
+
+#elif defined(KODI_TONE_MAPPING_HABLE)
+ rgb.rgb = inversePQ(rgb.rgb);
+ rgb.rgb *= m_toneP1;
+ float wp = m_luminance / 100.0;
+ rgb.rgb = hable(rgb.rgb * wp) / hable(vec3(wp));
+ rgb.rgb = pow(rgb.rgb, vec3(1.0 / 2.2));
+#endif
+
+#endif
+
+ gl_FragColor = rgb;
+}
+
diff --git a/system/shaders/GLES/2.0/gles_yuv2rgb_bob.frag b/system/shaders/GLES/2.0/gles_yuv2rgb_bob.frag
new file mode 100644
index 0000000..a82de9d
--- /dev/null
+++ b/system/shaders/GLES/2.0/gles_yuv2rgb_bob.frag
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2010-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#version 100
+
+precision highp float;
+uniform sampler2D m_sampY;
+uniform sampler2D m_sampU;
+uniform sampler2D m_sampV;
+varying vec2 m_cordY;
+varying vec2 m_cordU;
+varying vec2 m_cordV;
+uniform float m_alpha;
+uniform mat4 m_yuvmat;
+uniform float m_stepX;
+uniform float m_stepY;
+uniform int m_field;
+uniform mat3 m_primMat;
+uniform float m_gammaDstInv;
+uniform float m_gammaSrc;
+uniform float m_toneP1;
+uniform float m_luminance;
+uniform vec3 m_coefsDst;
+
+void main()
+{
+ vec4 rgb;
+
+ vec2 offsetY;
+ vec2 offsetU;
+ vec2 offsetV;
+ float temp1 = mod(m_cordY.y, 2.0 * m_stepY);
+
+ offsetY = m_cordY;
+ offsetU = m_cordU;
+ offsetV = m_cordV;
+
+ offsetY.y -= (temp1 - m_stepY / 2.0 + float(m_field) * m_stepY);
+ offsetU.y -= (temp1 - m_stepY / 2.0 + float(m_field) * m_stepY) / 2.0;
+ offsetV.y -= (temp1 - m_stepY / 2.0 + float(m_field) * m_stepY) / 2.0;
+
+ float bstep = step(m_stepY, temp1);
+
+ // Blend missing line
+ vec2 belowY, belowU, belowV;
+
+ belowY.x = offsetY.x;
+ belowY.y = offsetY.y + (2.0 * m_stepY * bstep);
+ belowU.x = offsetU.x;
+ belowU.y = offsetU.y + (m_stepY * bstep);
+ belowV.x = offsetV.x;
+ belowV.y = offsetV.y + (m_stepY * bstep);
+
+ vec4 rgbAbove;
+ vec4 rgbBelow;
+ vec4 yuvAbove;
+ vec4 yuvBelow;
+
+ yuvAbove = vec4(texture2D(m_sampY, offsetY).r, texture2D(m_sampU, offsetU).g, texture2D(m_sampV, offsetV).a, 1.0);
+ rgbAbove = m_yuvmat * yuvAbove;
+ rgbAbove.a = m_alpha;
+
+ yuvBelow = vec4(texture2D(m_sampY, belowY).r, texture2D(m_sampU, belowU).g, texture2D(m_sampV, belowV).a, 1.0);
+ rgbBelow = m_yuvmat * yuvBelow;
+ rgbBelow.a = m_alpha;
+
+ rgb = mix(rgb, rgbBelow, 0.5);
+
+#if defined(XBMC_COL_CONVERSION)
+ rgb.rgb = pow(max(vec3(0), rgb.rgb), vec3(m_gammaSrc));
+ rgb.rgb = max(vec3(0), m_primMat * rgb.rgb);
+ rgb.rgb = pow(rgb.rgb, vec3(m_gammaDstInv));
+
+#if defined(KODI_TONE_MAPPING_REINHARD)
+ float luma = dot(rgb.rgb, m_coefsDst);
+ rgb.rgb *= reinhard(luma) / luma;
+
+#elif defined(KODI_TONE_MAPPING_ACES)
+ rgb.rgb = inversePQ(rgb.rgb);
+ rgb.rgb *= (10000.0 / m_luminance) * (2.0 / m_toneP1);
+ rgb.rgb = aces(rgb.rgb);
+ rgb.rgb *= (1.24 / m_toneP1);
+ rgb.rgb = pow(rgb.rgb, vec3(0.27));
+
+#elif defined(KODI_TONE_MAPPING_HABLE)
+ rgb.rgb = inversePQ(rgb.rgb);
+ rgb.rgb *= m_toneP1;
+ float wp = m_luminance / 100.0;
+ rgb.rgb = hable(rgb.rgb * wp) / hable(vec3(wp));
+ rgb.rgb = pow(rgb.rgb, vec3(1.0 / 2.2));
+#endif
+
+#endif
+
+ gl_FragColor = rgb;
+}
diff --git a/system/shaders/convolution-4x4_d3d.fx b/system/shaders/convolution-4x4_d3d.fx
new file mode 100644
index 0000000..cf9408b
--- /dev/null
+++ b/system/shaders/convolution-4x4_d3d.fx
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2005-2015 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "convolution_d3d.fx"
+#include "output_d3d.fx"
+
+SamplerState RGBSampler : IMMUTABLE
+{
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ Filter = MIN_MAG_MIP_POINT;
+};
+
+inline half4 weight(float pos)
+{
+#ifdef HAS_RGBA
+ half4 w = g_KernelTexture.Sample(KernelSampler, pos);
+#else
+ half4 w = g_KernelTexture.Sample(KernelSampler, pos).bgra;
+#endif
+
+#ifndef HAS_FLOAT_TEXTURE
+ w = w * 2.0 - 1.0;
+#endif
+ return w;
+}
+
+inline half3 pixel(float xpos, float ypos)
+{
+ return g_Texture.Sample(RGBSampler, float2(xpos, ypos)).rgb;
+}
+
+inline half3 getLine(float ypos, float4 xpos, half4 linetaps)
+{
+ return
+ pixel(xpos.r, ypos) * linetaps.r +
+ pixel(xpos.g, ypos) * linetaps.g +
+ pixel(xpos.b, ypos) * linetaps.b +
+ pixel(xpos.a, ypos) * linetaps.a;
+}
+
+float4 CONVOLUTION4x4(float2 TextureUV : TEXCOORD0) : SV_TARGET
+{
+ float2 f = frac(TextureUV / g_StepXY + float2(0.5, 0.5));
+
+ half4 linetaps = weight(1.0 - f.x);
+ half4 columntaps = weight(1.0 - f.y);
+
+ // kernel generation code made sure taps add up to 1, no need to adjust here.
+
+ float2 xystart = (-1.0 - f) * g_StepXY + TextureUV;
+ float4 xpos = xystart.x + g_StepXY.x * float4(0.0, 1.0, 2.0, 3.0);
+ float4 ypos = xystart.y + g_StepXY.y * float4(0.0, 1.0, 2.0, 3.0);
+
+ float3 rgb =
+ getLine(ypos.x, xpos, linetaps) * columntaps.r +
+ getLine(ypos.y, xpos, linetaps) * columntaps.g +
+ getLine(ypos.z, xpos, linetaps) * columntaps.b +
+ getLine(ypos.w, xpos, linetaps) * columntaps.a;
+
+ return output(g_colorRange.x + g_colorRange.y * saturate(rgb), TextureUV);
+}
+
+technique11 SCALER_T
+{
+ pass P0
+ {
+ SetVertexShader( VS_SHADER );
+ SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION4x4() ) );
+ }
+};
diff --git a/system/shaders/convolution-6x6_d3d.fx b/system/shaders/convolution-6x6_d3d.fx
new file mode 100644
index 0000000..253c225
--- /dev/null
+++ b/system/shaders/convolution-6x6_d3d.fx
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2005-2015 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "convolution_d3d.fx"
+#include "output_d3d.fx"
+
+SamplerState RGBSampler : IMMUTABLE
+{
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ Filter = MIN_MAG_MIP_POINT;
+};
+
+half3 weight(float pos)
+{
+#ifdef HAS_RGBA
+ half3 w = g_KernelTexture.Sample(KernelSampler, pos).rgb;
+#else
+ half3 w = g_KernelTexture.Sample(KernelSampler, pos).bgr;
+#endif
+
+#ifndef HAS_FLOAT_TEXTURE
+ w = w * 2.0 - 1.0;
+#endif
+ return w;
+}
+
+inline half3 pixel(float xpos, float ypos)
+{
+ return g_Texture.Sample(RGBSampler, float2(xpos, ypos)).rgb;
+}
+
+inline half3 getLine(float ypos, float3 xpos1, float3 xpos2, half3 linetaps1, half3 linetaps2)
+{
+ return
+ pixel(xpos1.r, ypos) * linetaps1.r +
+ pixel(xpos1.g, ypos) * linetaps2.r +
+ pixel(xpos1.b, ypos) * linetaps1.g +
+ pixel(xpos2.r, ypos) * linetaps2.g +
+ pixel(xpos2.g, ypos) * linetaps1.b +
+ pixel(xpos2.b, ypos) * linetaps2.b;
+}
+
+float4 CONVOLUTION6x6(in float2 TextureUV : TEXCOORD0) : SV_TARGET
+{
+ float2 f = frac(TextureUV / g_StepXY + 0.5);
+
+ half3 linetaps1 = weight((1.0 - f.x) / 2.0);
+ half3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5);
+ half3 columntaps1 = weight((1.0 - f.y) / 2.0);
+ half3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5);
+
+ // kernel generation code made sure taps add up to 1, no need to adjust here.
+
+ float2 xystart = (-2.0 - f) * g_StepXY + TextureUV;
+ float3 xpos1 = xystart.x + g_StepXY.x * float3(0.0, 1.0, 2.0);
+ float3 xpos2 = xystart.x + g_StepXY.x * float3(3.0, 4.0, 5.0);
+ float3 ypos1 = xystart.y + g_StepXY.y * float3(0.0, 1.0, 2.0);
+ float3 ypos2 = xystart.y + g_StepXY.y * float3(3.0, 4.0, 5.0);
+
+ float3 rgb =
+ getLine(ypos1.x, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r +
+ getLine(ypos1.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r +
+ getLine(ypos1.z, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g +
+ getLine(ypos2.x, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g +
+ getLine(ypos2.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b +
+ getLine(ypos2.z, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b;
+
+ return output(g_colorRange.x + g_colorRange.y * saturate(rgb), TextureUV);
+}
+
+technique11 SCALER_T
+{
+ pass P0
+ {
+ SetVertexShader( VS_SHADER );
+ SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION6x6() ) );
+ }
+};
diff --git a/system/shaders/convolution_d3d.fx b/system/shaders/convolution_d3d.fx
new file mode 100644
index 0000000..6ff6150
--- /dev/null
+++ b/system/shaders/convolution_d3d.fx
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2005-2015 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+texture2D g_Texture;
+texture2D g_KernelTexture;
+float4 g_StepXY;
+float2 g_viewPort;
+float2 g_colorRange;
+
+SamplerState KernelSampler : IMMUTABLE
+{
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ Filter = MIN_MAG_MIP_LINEAR;
+};
+
+struct VS_INPUT
+{
+ float4 Position : POSITION;
+ float2 TextureUV : TEXCOORD0;
+};
+
+struct VS_OUTPUT
+{
+ float2 TextureUV : TEXCOORD0;
+ float4 Position : SV_POSITION;
+};
+
+//
+// VS for rendering in screen space
+//
+VS_OUTPUT VS(VS_INPUT In)
+{
+ VS_OUTPUT output = (VS_OUTPUT)0;
+ output.Position.x = (In.Position.x / (g_viewPort.x / 2.0)) - 1;
+ output.Position.y = -(In.Position.y / (g_viewPort.y / 2.0)) + 1;
+ output.Position.z = output.Position.z;
+ output.Position.w = 1.0;
+ output.TextureUV = In.TextureUV;
+
+ return output;
+}
+
+#define VS_SHADER CompileShader( vs_4_0_level_9_1, VS() )
diff --git a/system/shaders/convolutionsep-4x4_d3d.fx b/system/shaders/convolutionsep-4x4_d3d.fx
new file mode 100644
index 0000000..af68b3b
--- /dev/null
+++ b/system/shaders/convolutionsep-4x4_d3d.fx
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2005-2015 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "convolution_d3d.fx"
+#include "output_d3d.fx"
+
+SamplerState RGBSampler : IMMUTABLE
+{
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ Filter = MIN_MAG_POINT_MIP_LINEAR;
+};
+
+inline half4 weight(float pos)
+{
+#ifdef HAS_RGBA
+ half4 w = g_KernelTexture.Sample(KernelSampler, pos);
+#else
+ half4 w = g_KernelTexture.Sample(KernelSampler, pos).bgra;
+#endif
+
+#ifndef HAS_FLOAT_TEXTURE
+ w = w * 2.0 - 1.0;
+#endif
+ return w;
+}
+
+inline half3 pixel(float xpos, float ypos)
+{
+ return g_Texture.Sample(RGBSampler, float2(xpos, ypos)).rgb;
+}
+
+// Code for first pass - horizontal
+
+inline half3 getLine(float ypos, float4 xpos, half4 linetaps)
+{
+ return
+ pixel(xpos.r, ypos) * linetaps.r +
+ pixel(xpos.g, ypos) * linetaps.g +
+ pixel(xpos.b, ypos) * linetaps.b +
+ pixel(xpos.a, ypos) * linetaps.a;
+}
+
+float4 CONVOLUTION4x4Horiz(in float2 TextureUV : TEXCOORD0) : SV_TARGET
+{
+ float2 f = frac(TextureUV / g_StepXY.xy + 0.5);
+ half4 linetaps = weight(1.0 - f.x);
+
+ // kernel generation code made sure taps add up to 1, no need to adjust here.
+ float xystart = (-1.0 - f.x) * g_StepXY.x + TextureUV.x;
+
+ float4 xpos = xystart + g_StepXY.x * float4(0.0, 1.0, 2.0, 3.0);
+ return float4(getLine(TextureUV.y, xpos, linetaps), 1.0f);
+}
+
+// Code for second pass - vertical
+
+inline half3 getRow(float xpos, float4 ypos, half4 columntaps)
+{
+ return
+ pixel(xpos, ypos.r) * columntaps.r +
+ pixel(xpos, ypos.g) * columntaps.g +
+ pixel(xpos, ypos.b) * columntaps.b +
+ pixel(xpos, ypos.a) * columntaps.a;
+}
+
+float4 CONVOLUTION4x4Vert(in float2 TextureUV : TEXCOORD0) : SV_TARGET
+{
+ float2 f = frac(TextureUV / g_StepXY.zw + 0.5);
+ half4 columntaps = weight(1.0 - f.y);
+
+ // kernel generation code made sure taps add up to 1, no need to adjust here.
+ float xystart = (-1.0 - f.y) * g_StepXY.w + TextureUV.y;
+
+ float4 ypos = xystart + g_StepXY.w * float4(0.0, 1.0, 2.0, 3.0);
+ return output(g_colorRange.x + g_colorRange.y * saturate(getRow(TextureUV.x, ypos, columntaps)), TextureUV);
+}
+
+technique11 SCALER_T
+{
+ pass P0
+ {
+ SetVertexShader( VS_SHADER );
+ SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION4x4Horiz() ) );
+ }
+ pass P1
+ {
+ SetVertexShader( VS_SHADER );
+ SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION4x4Vert() ) );
+ }
+
+};
diff --git a/system/shaders/convolutionsep-6x6_d3d.fx b/system/shaders/convolutionsep-6x6_d3d.fx
new file mode 100644
index 0000000..9db0d6b
--- /dev/null
+++ b/system/shaders/convolutionsep-6x6_d3d.fx
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2005-2015 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "convolution_d3d.fx"
+#include "output_d3d.fx"
+
+SamplerState RGBSampler : IMMUTABLE
+{
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ Filter = MIN_MAG_POINT_MIP_LINEAR;
+};
+
+inline half3 weight(float pos)
+{
+#ifdef HAS_RGBA
+ half3 w = g_KernelTexture.Sample(KernelSampler, pos).rgb;
+#else
+ half3 w = g_KernelTexture.Sample(KernelSampler, pos).bgr;
+#endif
+
+#ifndef HAS_FLOAT_TEXTURE
+ w = w * 2.0 - 1.0;
+#endif
+ return w;
+}
+
+inline half3 pixel(float xpos, float ypos)
+{
+ return g_Texture.Sample(RGBSampler, float2(xpos, ypos)).rgb;
+}
+
+half3 getLine(float ypos, float3 xpos1, float3 xpos2, half3 linetaps1, half3 linetaps2)
+{
+ return
+ pixel(xpos1.r, ypos) * linetaps1.r +
+ pixel(xpos1.g, ypos) * linetaps2.r +
+ pixel(xpos1.b, ypos) * linetaps1.g +
+ pixel(xpos2.r, ypos) * linetaps2.g +
+ pixel(xpos2.g, ypos) * linetaps1.b +
+ pixel(xpos2.b, ypos) * linetaps2.b;
+}
+
+// Code for first pass - horizontal
+float4 CONVOLUTION6x6Horiz(in float2 TextureUV : TEXCOORD0) : SV_TARGET
+{
+ float2 f = frac(TextureUV / g_StepXY.xy + 0.5);
+
+ half3 linetaps1 = weight((1.0 - f.x) / 2.0);
+ half3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5);
+
+ // kernel generation code made sure taps add up to 1, no need to adjust here.
+
+ float xstart = (-2.0 - f.x) * g_StepXY.x + TextureUV.x;
+
+ float3 xpos1 = xstart + g_StepXY.x * float3(0.0, 1.0, 2.0);
+ float3 xpos2 = xstart + g_StepXY.x * float3(3.0, 4.0, 5.0);
+
+ return float4(getLine(TextureUV.y, xpos1, xpos2, linetaps1, linetaps2), 1.0);
+}
+
+// Code for second pass - vertical
+
+half3 getRow(float xpos, float3 ypos1, float3 ypos2, half3 columntaps1, half3 columntaps2)
+{
+ return
+ pixel(xpos, ypos1.r) * columntaps1.r +
+ pixel(xpos, ypos1.g) * columntaps2.r +
+ pixel(xpos, ypos1.b) * columntaps1.g +
+ pixel(xpos, ypos2.r) * columntaps2.g +
+ pixel(xpos, ypos2.g) * columntaps1.b +
+ pixel(xpos, ypos2.b) * columntaps2.b;
+}
+
+float4 CONVOLUTION6x6Vert(in float2 TextureUV : TEXCOORD0) : SV_TARGET
+{
+ float2 f = frac(TextureUV / g_StepXY.zw + 0.5);
+
+ half3 columntaps1 = weight((1.0 - f.y) / 2.0);
+ half3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5);
+
+ // kernel generation code made sure taps add up to 1, no need to adjust here.
+
+ float ystart = (-2.0 - f.y) * g_StepXY.w + TextureUV.y;
+
+ float3 ypos1 = ystart + g_StepXY.w * float3(0.0, 1.0, 2.0);
+ float3 ypos2 = ystart + g_StepXY.w * float3(3.0, 4.0, 5.0);
+
+ return output(g_colorRange.x + g_colorRange.y * saturate(getRow(TextureUV.x, ypos1, ypos2, columntaps1, columntaps2)), TextureUV);
+}
+
+technique11 SCALER_T
+{
+ pass P0
+ {
+ SetVertexShader( VS_SHADER );
+ SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION6x6Horiz() ) );
+ }
+ pass P1
+ {
+ SetVertexShader( VS_SHADER );
+ SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION6x6Vert() ) );
+ }
+};
diff --git a/system/shaders/guishader_checkerboard_left.hlsl b/system/shaders/guishader_checkerboard_left.hlsl
new file mode 100644
index 0000000..7639a8c
--- /dev/null
+++ b/system/shaders/guishader_checkerboard_left.hlsl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define STEREO_MODE_SHADER
+
+Texture2D texView : register(t0);
+
+cbuffer cbViewPort : register(b1)
+{
+ float g_viewPortX;
+ float g_viewPortY;
+ float g_viewPortWidth;
+ float g_viewPortHeigh;
+};
+
+#include "guishader_common.hlsl"
+
+float4 PS(PS_INPUT input) : SV_TARGET
+{
+ return StereoCheckerboard(input, STEREO_LEFT_EYE_INDEX);
+}
+
+
diff --git a/system/shaders/guishader_checkerboard_right.hlsl b/system/shaders/guishader_checkerboard_right.hlsl
new file mode 100644
index 0000000..eb02a21
--- /dev/null
+++ b/system/shaders/guishader_checkerboard_right.hlsl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define STEREO_MODE_SHADER
+
+Texture2D texView : register(t0);
+
+cbuffer cbViewPort : register(b1)
+{
+ float g_viewPortX;
+ float g_viewPortY;
+ float g_viewPortWidth;
+ float g_viewPortHeigh;
+};
+
+#include "guishader_common.hlsl"
+
+float4 PS(PS_INPUT input) : SV_TARGET
+{
+ return StereoCheckerboard(input, STEREO_RIGHT_EYE_INDEX);
+}
+
+
diff --git a/system/shaders/guishader_common.hlsl b/system/shaders/guishader_common.hlsl
new file mode 100644
index 0000000..0dd01c5
--- /dev/null
+++ b/system/shaders/guishader_common.hlsl
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+struct VS_INPUT
+{
+ float4 pos : POSITION;
+ float4 color: COLOR0;
+ float2 tex : TEXCOORD0;
+ float2 tex2 : TEXCOORD1;
+};
+
+struct PS_INPUT
+{
+ float4 pos : SV_POSITION;
+ float4 color: COLOR0;
+ float2 tex : TEXCOORD0;
+ float2 tex2 : TEXCOORD1;
+};
+
+SamplerState LinearSampler : register(s0)
+{
+ Filter = MIN_MAG_MIP_LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ Comparison = NEVER;
+};
+
+cbuffer cbWorld : register(b0)
+{
+ float4x4 worldViewProj;
+ float blackLevel;
+ float colorRange;
+ float sdrPeakLum;
+ int PQ;
+};
+
+inline float3 transferPQ(float3 x)
+{
+ static const float ST2084_m1 = 2610.0f / (4096.0f * 4.0f);
+ static const float ST2084_m2 = (2523.0f / 4096.0f) * 128.0f;
+ static const float ST2084_c1 = 3424.0f / 4096.0f;
+ static const float ST2084_c2 = (2413.0f / 4096.0f) * 32.0f;
+ static const float ST2084_c3 = (2392.0f / 4096.0f) * 32.0f;
+ static const float3x3 matx =
+ {
+ 0.627402, 0.329292, 0.043306,
+ 0.069095, 0.919544, 0.011360,
+ 0.016394, 0.088028, 0.895578
+ };
+ // REC.709 to linear
+ x = pow(x, 1.0f / 0.45f);
+ // REC.709 to BT.2020
+ x = mul(matx, x);
+ // linear to PQ
+ x = pow(x / sdrPeakLum, ST2084_m1);
+ x = (ST2084_c1 + ST2084_c2 * x) / (1.0f + ST2084_c3 * x);
+ x = pow(x, ST2084_m2);
+ return x;
+}
+
+inline float4 tonemapHDR(float4 color)
+{
+ return (PQ) ? float4(transferPQ(color.rgb), color.a) : color;
+}
+
+inline float4 adjustColorRange(float4 color)
+{
+ return float4(blackLevel + colorRange * color.rgb, color.a);
+}
+
+#define STEREO_LEFT_EYE_INDEX 0
+#define STEREO_RIGHT_EYE_INDEX 1
+
+#ifdef STEREO_MODE_SHADER
+
+inline float4 StereoInterlaced(PS_INPUT input, int eye)
+{
+ uint pixelY = abs(trunc(input.tex.y * g_viewPortHeigh));
+ uint odd = pixelY % 2;
+
+ if ((odd == 0 && !eye) || (odd != 0 && eye))
+ return float4(texView.Sample(LinearSampler, input.tex).rgb, 1.0);
+ else
+ return float4(0.0, 0.0, 0.0, 0.0);
+}
+
+inline float4 StereoCheckerboard(PS_INPUT input, int eye)
+{
+ uint pixelX = abs(trunc(input.tex.x * g_viewPortWidth));
+ uint pixelY = abs(trunc(input.tex.y * g_viewPortHeigh));
+ uint odd = (pixelX + pixelY) % 2;
+
+ if ((odd == 0 && !eye) || (odd != 0 && eye))
+ return float4(texView.Sample(LinearSampler, input.tex).rgb, 1.0);
+ else
+ return float4(0.0, 0.0, 0.0, 0.0);
+}
+
+#endif \ No newline at end of file
diff --git a/system/shaders/guishader_default.hlsl b/system/shaders/guishader_default.hlsl
new file mode 100644
index 0000000..82b6510
--- /dev/null
+++ b/system/shaders/guishader_default.hlsl
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "guishader_common.hlsl"
+
+float4 PS(PS_INPUT input) : SV_TARGET
+{
+ return tonemapHDR(adjustColorRange(input.color));
+}
+
+
diff --git a/system/shaders/guishader_fonts.hlsl b/system/shaders/guishader_fonts.hlsl
new file mode 100644
index 0000000..59c2ffe
--- /dev/null
+++ b/system/shaders/guishader_fonts.hlsl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "guishader_common.hlsl"
+
+Texture2D texFont : register(t0);
+
+float4 PS(PS_INPUT input) : SV_TARGET
+{
+ input.color.a *= texFont.Sample(LinearSampler, input.tex).r;
+ return tonemapHDR(adjustColorRange(input.color));
+}
+
+
diff --git a/system/shaders/guishader_interlaced_left.hlsl b/system/shaders/guishader_interlaced_left.hlsl
new file mode 100644
index 0000000..41a7b92
--- /dev/null
+++ b/system/shaders/guishader_interlaced_left.hlsl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define STEREO_MODE_SHADER
+
+Texture2D texView : register(t0);
+
+cbuffer cbViewPort : register(b1)
+{
+ float g_viewPortX;
+ float g_viewPortY;
+ float g_viewPortWidth;
+ float g_viewPortHeigh;
+};
+
+#include "guishader_common.hlsl"
+
+float4 PS(PS_INPUT input) : SV_TARGET
+{
+ return StereoInterlaced(input, STEREO_LEFT_EYE_INDEX);
+}
+
+
diff --git a/system/shaders/guishader_interlaced_right.hlsl b/system/shaders/guishader_interlaced_right.hlsl
new file mode 100644
index 0000000..394d5b9
--- /dev/null
+++ b/system/shaders/guishader_interlaced_right.hlsl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define STEREO_MODE_SHADER
+
+Texture2D texView : register(t0);
+
+cbuffer cbViewPort : register(b1)
+{
+ float g_viewPortX;
+ float g_viewPortY;
+ float g_viewPortWidth;
+ float g_viewPortHeigh;
+};
+
+#include "guishader_common.hlsl"
+
+float4 PS(PS_INPUT input) : SV_TARGET
+{
+ return StereoInterlaced(input, STEREO_RIGHT_EYE_INDEX);
+}
+
+
diff --git a/system/shaders/guishader_multi_texture_blend.hlsl b/system/shaders/guishader_multi_texture_blend.hlsl
new file mode 100644
index 0000000..77c2e79
--- /dev/null
+++ b/system/shaders/guishader_multi_texture_blend.hlsl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "guishader_common.hlsl"
+
+Texture2D txDiffuse[2] : register(t0);
+
+float4 PS(PS_INPUT input) : SV_TARGET
+{
+ return tonemapHDR(adjustColorRange(input.color * txDiffuse[0].Sample(LinearSampler, input.tex) *
+ txDiffuse[1].Sample(LinearSampler, input.tex2)));
+}
+
+
diff --git a/system/shaders/guishader_texture.hlsl b/system/shaders/guishader_texture.hlsl
new file mode 100644
index 0000000..665aff0
--- /dev/null
+++ b/system/shaders/guishader_texture.hlsl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "guishader_common.hlsl"
+
+Texture2D texMain : register(t0);
+
+float4 PS(PS_INPUT input) : SV_TARGET
+{
+ return tonemapHDR(adjustColorRange(input.color * texMain.Sample(LinearSampler, input.tex)));
+}
+
+
diff --git a/system/shaders/guishader_texture_noblend.hlsl b/system/shaders/guishader_texture_noblend.hlsl
new file mode 100644
index 0000000..1daaa20
--- /dev/null
+++ b/system/shaders/guishader_texture_noblend.hlsl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "guishader_common.hlsl"
+
+Texture2D texMain : register(t0);
+
+float4 PS(PS_INPUT input) : SV_TARGET
+{
+ return texMain.Sample(LinearSampler, input.tex);
+}
+
+
diff --git a/system/shaders/guishader_vert.hlsl b/system/shaders/guishader_vert.hlsl
new file mode 100644
index 0000000..508cbb7
--- /dev/null
+++ b/system/shaders/guishader_vert.hlsl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2005-2015 Team Kodi
+ * http://kodi.tv
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "guishader_common.hlsl"
+
+PS_INPUT VS(VS_INPUT input)
+{
+ PS_INPUT output = (PS_INPUT)0;
+ output.pos = mul(input.pos, worldViewProj);
+ output.color = input.color;
+ output.tex = input.tex;
+ output.tex2 = input.tex2;
+
+ return output;
+}
diff --git a/system/shaders/output_d3d.fx b/system/shaders/output_d3d.fx
new file mode 100644
index 0000000..eebc200
--- /dev/null
+++ b/system/shaders/output_d3d.fx
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2005-2015 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#if defined(KODI_3DLUT)
+float2 m_LUTParams; // x- scale, y- offset
+texture3D m_LUT;
+
+SamplerState LutSampler : IMMUTABLE
+{
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+ Filter = MIN_MAG_MIP_LINEAR;
+};
+#endif
+#if defined(KODI_DITHER)
+float3 m_ditherParams;
+texture2D m_ditherMatrix;
+
+SamplerState DitherSampler : IMMUTABLE
+{
+ AddressU = WRAP;
+ AddressV = WRAP;
+ Filter = MIN_MAG_MIP_POINT;
+};
+#endif
+#if (defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE) || defined(KODI_HLG_TO_PQ))
+static const float ST2084_m1 = 2610.0f / (4096.0f * 4.0f);
+static const float ST2084_m2 = (2523.0f / 4096.0f) * 128.0f;
+static const float ST2084_c1 = 3424.0f / 4096.0f;
+static const float ST2084_c2 = (2413.0f / 4096.0f) * 32.0f;
+static const float ST2084_c3 = (2392.0f / 4096.0f) * 32.0f;
+#endif
+#if defined(KODI_TONE_MAPPING_REINHARD)
+float g_toneP1;
+float3 g_coefsDst;
+
+float reinhard(float x)
+{
+ return x * (1.0f + x / (g_toneP1 * g_toneP1)) / (1.0f + x);
+}
+#endif
+#if defined(KODI_TONE_MAPPING_ACES)
+float g_luminance;
+float g_toneP1;
+
+float3 aces(float3 x)
+{
+ const float A = 2.51f;
+ const float B = 0.03f;
+ const float C = 2.43f;
+ const float D = 0.59f;
+ const float E = 0.14f;
+ return (x * (A * x + B)) / (x * (C * x + D) + E);
+}
+#endif
+#if defined(KODI_TONE_MAPPING_HABLE)
+float g_toneP1;
+float g_toneP2;
+
+float3 hable(float3 x)
+{
+ const float A = 0.15f;
+ const float B = 0.5f;
+ const float C = 0.1f;
+ const float D = 0.2f;
+ const float E = 0.02f;
+ const float F = 0.3f;
+ return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
+}
+#endif
+#if (defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE))
+float3 inversePQ(float3 x)
+{
+ x = pow(max(x, 0.0f), 1.0f / ST2084_m2);
+ x = max(x - ST2084_c1, 0.0f) / (ST2084_c2 - ST2084_c3 * x);
+ x = pow(x, 1.0f / ST2084_m1);
+ return x;
+}
+#endif
+#if defined(KODI_HLG_TO_PQ)
+float3 inverseHLG(float3 x)
+{
+ const float B67_a = 0.17883277f;
+ const float B67_b = 0.28466892f;
+ const float B67_c = 0.55991073f;
+ const float B67_inv_r2 = 4.0f;
+ x = (x <= 0.5f) ? x * x * B67_inv_r2 : exp((x - B67_c) / B67_a) + B67_b;
+ return x;
+}
+
+float3 tranferPQ(float3 x)
+{
+ x = pow(x / 1000.0f, ST2084_m1);
+ x = (ST2084_c1 + ST2084_c2 * x) / (1.0f + ST2084_c3 * x);
+ x = pow(x, ST2084_m2);
+ return x;
+}
+#endif
+
+
+float4 output4(float4 color, float2 uv)
+{
+#if defined(KODI_TONE_MAPPING_REINHARD)
+ float luma = dot(color.rgb, g_coefsDst);
+ color.rgb *= reinhard(luma) / luma;
+#endif
+#if defined(KODI_TONE_MAPPING_ACES)
+ color.rgb = inversePQ(color.rgb);
+ color.rgb *= (10000.0f / g_luminance) * (2.0f / g_toneP1);
+ color.rgb = aces(color.rgb);
+ color.rgb *= (1.24f / g_toneP1);
+ color.rgb = pow(color.rgb, 0.27f);
+#endif
+#if defined(KODI_TONE_MAPPING_HABLE)
+ color.rgb = inversePQ(color.rgb);
+ color.rgb *= g_toneP1;
+ color.rgb = hable(color.rgb * g_toneP2) / hable(g_toneP2);
+ color.rgb = pow(color.rgb, 1.0f / 2.2f);
+#endif
+#if defined(KODI_HLG_TO_PQ)
+ color.rgb = inverseHLG(color.rgb);
+ float3 ootf_2020 = float3(0.2627f, 0.6780f, 0.0593f);
+ float ootf_ys = 2000.0f * dot(ootf_2020, color.rgb);
+ color.rgb *= pow(ootf_ys, 0.2f);
+ color.rgb = tranferPQ(color.rgb);
+#endif
+#if defined(KODI_3DLUT)
+ half3 scale = m_LUTParams.x;
+ half3 offset = m_LUTParams.y;
+ float3 lutRGB = m_LUT.Sample(LutSampler, color.rgb*scale + offset).rgb;
+ color.rgb = scale.x ? lutRGB : color.rgb;
+#endif
+#if defined(KODI_DITHER)
+ half2 ditherpos = uv * m_ditherParams.xy;
+ // scale ditherval to [0,1)
+ float ditherval = m_ditherMatrix.Sample(DitherSampler, ditherpos).r * 16.0f;
+ color.rgb = floor(color.rgb * m_ditherParams.z + ditherval) / m_ditherParams.z;
+#endif
+ return color;
+}
+
+float4 output(float3 color, float2 uv)
+{
+ return output4(float4(color, 1.0), uv);
+}
+
+#if defined(KODI_OUTPUT_T)
+#include "convolution_d3d.fx"
+
+#if (defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE) || defined(KODI_HLG_TO_PQ))
+#define PS_PROFILE ps_4_0_level_9_3
+#else
+#define PS_PROFILE ps_4_0_level_9_1
+#endif
+
+float3 m_params; // 0 - range (0 - full, 1 - limited), 1 - contrast, 2 - brightness
+
+float4 OUTPUT_PS(VS_OUTPUT In) : SV_TARGET
+{
+ float4 color = g_Texture.Sample(KernelSampler, In.TextureUV);
+ [flatten] if (m_params.x)
+ color = saturate(0.0625 + color * 219.0 / 255.0);
+
+ color *= m_params.y * 2.0;
+ color += m_params.z - 0.5;
+ color.a = 1.0;
+
+ return output4(color, In.TextureUV);
+}
+
+technique11 OUTPUT_T
+{
+ pass P0
+ {
+ SetVertexShader( VS_SHADER );
+ SetPixelShader( CompileShader( PS_PROFILE, OUTPUT_PS() ) );
+ }
+};
+#endif \ No newline at end of file
diff --git a/system/shaders/rp_output_d3d.fx b/system/shaders/rp_output_d3d.fx
new file mode 100644
index 0000000..69ca56d
--- /dev/null
+++ b/system/shaders/rp_output_d3d.fx
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2017 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+texture2D g_Texture;
+float2 g_viewPort;
+float m_params[1]; // 0 - range (0 - full, 1 - limited)
+
+SamplerState TextureSampler : IMMUTABLE
+{
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+#ifdef SAMP_NEAREST
+ Filter = MIN_MAG_MIP_POINT;
+#else
+ Filter = MIN_MAG_MIP_LINEAR;
+#endif
+};
+
+struct VS_INPUT
+{
+ float4 Position : POSITION;
+ float2 TextureUV : TEXCOORD0;
+};
+
+struct VS_OUTPUT
+{
+ float2 TextureUV : TEXCOORD0;
+ float4 Position : SV_POSITION;
+};
+
+//
+// VS for rendering in screen space
+//
+VS_OUTPUT OUTPUT_VS(VS_INPUT In)
+{
+ VS_OUTPUT output = (VS_OUTPUT)0;
+ output.Position.x = (In.Position.x / (g_viewPort.x / 2.0)) - 1;
+ output.Position.y = -(In.Position.y / (g_viewPort.y / 2.0)) + 1;
+ output.Position.z = output.Position.z;
+ output.Position.w = 1.0;
+ output.TextureUV = In.TextureUV;
+
+ return output;
+}
+
+float4 OUTPUT_PS(VS_OUTPUT In) : SV_TARGET
+{
+ float4 color = g_Texture.Sample(TextureSampler, In.TextureUV);
+ [flatten] if (m_params[0])
+ color = saturate(0.0625 + color * 219.0 / 255.0);
+
+ color.a = 1.0;
+
+ return color;
+}
+
+technique11 OUTPUT_T
+{
+ pass P0
+ {
+ SetVertexShader( CompileShader( vs_4_0_level_9_1, OUTPUT_VS()) );
+ SetPixelShader( CompileShader( ps_4_0_level_9_1, OUTPUT_PS() ) );
+ }
+};
diff --git a/system/shaders/yuv2rgb_d3d.fx b/system/shaders/yuv2rgb_d3d.fx
new file mode 100644
index 0000000..0500526
--- /dev/null
+++ b/system/shaders/yuv2rgb_d3d.fx
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "output_d3d.fx"
+
+texture2D g_Texture[3];
+float4x4 g_ColorMatrix;
+float2 g_StepXY;
+float2 g_viewPort;
+float4x4 g_primMat;
+float g_gammaDstInv;
+float g_gammaSrc;
+
+SamplerState YUVSampler : IMMUTABLE
+{
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ Filter = MIN_MAG_MIP_POINT;
+};
+
+struct VS_INPUT
+{
+ float4 Position : POSITION;
+ float2 TextureY : TEXCOORD0;
+ float2 TextureUV : TEXCOORD1;
+};
+
+struct VS_OUTPUT
+{
+ float2 TextureY : TEXCOORD0;
+ float2 TextureUV : TEXCOORD1;
+ float4 Position : SV_POSITION;
+};
+
+VS_OUTPUT VS(VS_INPUT In)
+{
+ VS_OUTPUT output = (VS_OUTPUT)0;
+ output.Position.x = (In.Position.x / (g_viewPort.x / 2.0)) - 1;
+ output.Position.y = -(In.Position.y / (g_viewPort.y / 2.0)) + 1;
+ output.Position.z = output.Position.z;
+ output.Position.w = 1.0;
+ output.TextureY = In.TextureY;
+ output.TextureUV = In.TextureUV;
+
+ return output;
+}
+
+#ifdef NV12_SNORM_UV
+inline float unormU(float c)
+{
+ c *= 0.5;
+ if (c < 0.0) c += 1.0;
+ return saturate(c);
+}
+inline float2 unormUV(float2 rg)
+{
+ return float2(unormU(rg.x), unormU(rg.y));
+}
+#endif
+
+float4 YUV2RGB(VS_OUTPUT In) : SV_TARGET
+{
+#if defined(XBMC_YV12) //|| defined(XBMC_NV12)
+ float4 YUV = float4(g_Texture[0].Sample(YUVSampler, In.TextureY ).r
+ , g_Texture[1].Sample(YUVSampler, In.TextureUV).r
+ , g_Texture[2].Sample(YUVSampler, In.TextureUV).r
+ , 1.0);
+#elif defined(XBMC_NV12)
+ float4 YUV = float4(g_Texture[0].Sample(YUVSampler, In.TextureY).r
+ #if defined(NV12_SNORM_UV)
+ , unormUV(g_Texture[1].Sample(YUVSampler, In.TextureUV).rg)
+ #else
+ , g_Texture[1].Sample(YUVSampler, In.TextureUV).rg
+ #endif
+ , 1.0);
+#elif defined(XBMC_YUY2) || defined(XBMC_UYVY)
+ // The HLSL compiler is smart enough to optimize away these redundant assignments.
+ // That way the code is almost identical to the OGL shader.
+ float2 stepxy = g_StepXY;
+ float2 pos = In.TextureY;
+ pos = float2(pos.x - (stepxy.x * 0.25), pos.y);
+ float2 f = frac(pos / stepxy);
+
+ //y axis will be correctly interpolated by opengl
+ //x axis will not, so we grab two pixels at the center of two columns and interpolate ourselves
+ float4 c1 = g_Texture[0].Sample(YUVSampler, float2(pos.x + ((0.5 - f.x) * stepxy.x), pos.y));
+ float4 c2 = g_Texture[0].Sample(YUVSampler, float2(pos.x + ((1.5 - f.x) * stepxy.x), pos.y));
+
+ /* each pixel has two Y subpixels and one UV subpixel
+ YUV Y YUV
+ check if we're left or right of the middle Y subpixel and interpolate accordingly*/
+ #if defined(XBMC_YUY2) // BGRA = YUYV
+ float leftY = lerp(c1.b, c1.r, f.x * 2.0);
+ float rightY = lerp(c1.r, c2.b, f.x * 2.0 - 1.0);
+ float2 outUV = lerp(c1.ga, c2.ga, f.x);
+ #elif defined(XBMC_UYVY) // BGRA = UYVY
+ float leftY = lerp(c1.g, c1.a, f.x * 2.0);
+ float rightY = lerp(c1.a, c2.g, f.x * 2.0 - 1.0);
+ float2 outUV = lerp(c1.br, c2.br, f.x);
+ #endif
+ float outY = lerp(leftY, rightY, step(0.5, f.x));
+ float4 YUV = float4(outY, outUV, 1.0);
+#endif
+
+ float4 rgb = mul(YUV, g_ColorMatrix);
+#if defined(XBMC_COL_CONVERSION)
+ rgb.rgb = pow(max(0.0, rgb.rgb), g_gammaSrc);
+ rgb.rgb = max(0.0, mul(rgb, g_primMat).rgb);
+ rgb.rgb = pow(rgb.rgb, g_gammaDstInv);
+#endif
+ return output4(rgb, In.TextureY);
+}
+
+technique11 YUV2RGB_T
+{
+ pass P0
+ {
+ SetVertexShader( CompileShader( vs_4_0_level_9_1, VS() ) );
+ SetPixelShader( CompileShader( ps_4_0_level_9_1, YUV2RGB() ) );
+ }
+};