From 18953026cff8473da43275ba49c5471d4ce33b9f Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Wed, 27 Sep 2017 08:34:58 +0200 Subject: OpenGL: move shaders to version dpendent subfolder --- system/shaders/GL/1.2/gl_convolution-4x4.glsl | 113 +++++++++++++++++++ system/shaders/GL/1.2/gl_convolution-6x6.glsl | 124 +++++++++++++++++++++ system/shaders/GL/1.2/gl_output.glsl | 58 ++++++++++ system/shaders/GL/1.2/gl_shader_frag_default.glsl | 29 +++++ system/shaders/GL/1.2/gl_shader_frag_fonts.glsl | 34 ++++++ system/shaders/GL/1.2/gl_shader_frag_multi.glsl | 32 ++++++ .../GL/1.2/gl_shader_frag_multi_blendcolor.glsl | 33 ++++++ system/shaders/GL/1.2/gl_shader_frag_texture.glsl | 31 ++++++ .../GL/1.2/gl_shader_frag_texture_noblend.glsl | 30 +++++ system/shaders/GL/1.2/gl_shader_vert.glsl | 40 +++++++ system/shaders/GL/1.2/gl_shader_vert_default.glsl | 31 ++++++ system/shaders/GL/1.2/gl_streatch.glsl | 40 +++++++ system/shaders/GL/1.2/gl_videofilter_frag.glsl | 30 +++++ system/shaders/GL/1.2/gl_videofilter_vertex.glsl | 34 ++++++ system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl | 122 ++++++++++++++++++++ system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl | 38 +++++++ system/shaders/gl_convolution-4x4.glsl | 113 ------------------- system/shaders/gl_convolution-6x6.glsl | 124 --------------------- system/shaders/gl_output.glsl | 58 ---------- system/shaders/gl_shader_frag_default.glsl | 29 ----- system/shaders/gl_shader_frag_fonts.glsl | 34 ------ system/shaders/gl_shader_frag_multi.glsl | 32 ------ .../shaders/gl_shader_frag_multi_blendcolor.glsl | 33 ------ system/shaders/gl_shader_frag_texture.glsl | 31 ------ system/shaders/gl_shader_frag_texture_noblend.glsl | 30 ----- system/shaders/gl_shader_vert.glsl | 40 ------- system/shaders/gl_shader_vert_default.glsl | 31 ------ system/shaders/gl_streatch.glsl | 40 ------- system/shaders/gl_videofilter_frag.glsl | 30 ----- system/shaders/gl_videofilter_vertex.glsl | 34 ------ system/shaders/gl_yuv2rgb_basic.glsl | 122 -------------------- system/shaders/gl_yuv2rgb_vertex.glsl | 38 ------- xbmc/guilib/Shader.cpp | 15 ++- xbmc/rendering/RenderSystem.h | 2 + xbmc/rendering/gl/RenderSystemGL.cpp | 6 + xbmc/rendering/gl/RenderSystemGL.h | 2 + 36 files changed, 838 insertions(+), 825 deletions(-) create mode 100644 system/shaders/GL/1.2/gl_convolution-4x4.glsl create mode 100644 system/shaders/GL/1.2/gl_convolution-6x6.glsl create mode 100644 system/shaders/GL/1.2/gl_output.glsl create mode 100644 system/shaders/GL/1.2/gl_shader_frag_default.glsl create mode 100644 system/shaders/GL/1.2/gl_shader_frag_fonts.glsl create mode 100644 system/shaders/GL/1.2/gl_shader_frag_multi.glsl create mode 100644 system/shaders/GL/1.2/gl_shader_frag_multi_blendcolor.glsl create mode 100644 system/shaders/GL/1.2/gl_shader_frag_texture.glsl create mode 100644 system/shaders/GL/1.2/gl_shader_frag_texture_noblend.glsl create mode 100644 system/shaders/GL/1.2/gl_shader_vert.glsl create mode 100644 system/shaders/GL/1.2/gl_shader_vert_default.glsl create mode 100644 system/shaders/GL/1.2/gl_streatch.glsl create mode 100644 system/shaders/GL/1.2/gl_videofilter_frag.glsl create mode 100644 system/shaders/GL/1.2/gl_videofilter_vertex.glsl create mode 100644 system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl create mode 100644 system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl delete mode 100644 system/shaders/gl_convolution-4x4.glsl delete mode 100644 system/shaders/gl_convolution-6x6.glsl delete mode 100644 system/shaders/gl_output.glsl delete mode 100644 system/shaders/gl_shader_frag_default.glsl delete mode 100644 system/shaders/gl_shader_frag_fonts.glsl delete mode 100644 system/shaders/gl_shader_frag_multi.glsl delete mode 100644 system/shaders/gl_shader_frag_multi_blendcolor.glsl delete mode 100644 system/shaders/gl_shader_frag_texture.glsl delete mode 100644 system/shaders/gl_shader_frag_texture_noblend.glsl delete mode 100644 system/shaders/gl_shader_vert.glsl delete mode 100644 system/shaders/gl_shader_vert_default.glsl delete mode 100644 system/shaders/gl_streatch.glsl delete mode 100644 system/shaders/gl_videofilter_frag.glsl delete mode 100644 system/shaders/gl_videofilter_vertex.glsl delete mode 100644 system/shaders/gl_yuv2rgb_basic.glsl delete mode 100644 system/shaders/gl_yuv2rgb_vertex.glsl 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 0000000000..cf2a0f5378 --- /dev/null +++ b/system/shaders/GL/1.2/gl_convolution-4x4.glsl @@ -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 + * . + * + */ + +uniform sampler2D img; +uniform vec2 stepxy; +uniform float m_stretch; +varying vec2 m_cord; + +#if (USE1DTEXTURE) + uniform sampler1D kernelTex; +#else + uniform sampler2D kernelTex; +#endif + +//nvidia's half is a 16 bit float and can bring some speed improvements +//without affecting quality +#ifndef __GLSL_CG_DATA_TYPES + #define half float + #define half3 vec3 + #define half4 vec4 +#endif + +half4 weight(float pos) +{ +#if (HAS_FLOAT_TEXTURE) + #if (USE1DTEXTURE) + return texture1D(kernelTex, pos); + #else + return texture2D(kernelTex, vec2(pos, 0.5)); + #endif +#else + #if (USE1DTEXTURE) + return texture1D(kernelTex, pos) * 2.0 - 1.0; + #else + return texture2D(kernelTex, vec2(pos, 0.5)) * 2.0 - 1.0; + #endif +#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 +} + +half3 pixel(float xpos, float ypos) +{ + return texture2D(img, vec2(xpos, ypos)).rgb; +} + +half3 line (float ypos, vec4 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; +} + +vec4 process() +{ + vec4 rgb; + vec2 pos = stretch(m_cord) + stepxy * 0.5; + vec2 f = fract(pos / stepxy); + + half4 linetaps = weight(1.0 - f.x); + half4 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; + +#ifdef GL_ES + rgb.a = m_alpha; +#else + rgb.a = gl_Color.a; +#endif + + 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 0000000000..c4f51fd431 --- /dev/null +++ b/system/shaders/GL/1.2/gl_convolution-6x6.glsl @@ -0,0 +1,124 @@ +/* + * 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 + * . + * + */ + +uniform sampler2D img; +uniform vec2 stepxy; +uniform float m_stretch; +varying vec2 m_cord; + +#if (USE1DTEXTURE) + uniform sampler1D kernelTex; +#else + uniform sampler2D kernelTex; +#endif + +//nvidia's half is a 16 bit float and can bring some speed improvements +//without affecting quality +#ifndef __GLSL_CG_DATA_TYPES + #define half float + #define half3 vec3 + #define half4 vec4 +#endif + +half3 weight(float pos) +{ +#if (HAS_FLOAT_TEXTURE) + #if (USE1DTEXTURE) + return texture1D(kernelTex, pos).rgb; + #else + return texture2D(kernelTex, vec2(pos, 0.5)).rgb; + #endif +#else + #if (USE1DTEXTURE) + return texture1D(kernelTex, pos).rgb * 2.0 - 1.0; + #else + return texture2D(kernelTex, vec2(pos, 0.5)).rgb * 2.0 - 1.0; + #endif +#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 +} + +half3 pixel(float xpos, float ypos) +{ + return texture2D(img, vec2(xpos, ypos)).rgb; +} + +half3 line (float ypos, vec3 xpos1, vec3 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; +} + +vec4 process() +{ + vec4 rgb; + vec2 pos = stretch(m_cord) + stepxy * 0.5; + vec2 f = fract(pos / stepxy); + + 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); + + //make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur + half 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; + +#ifdef GL_ES + rgb.a = m_alpha; +#else + rgb.a = gl_Color.a; +#endif + + 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 0000000000..d3294a8bb5 --- /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 + * . + * + */ + + +#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 0000000000..d9aba5f5fe --- /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 + * . + * + */ + +#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 0000000000..fdc50c1130 --- /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 + * . + * + */ + +#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).a; +} 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 0000000000..804a716ea3 --- /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 + * . + * + */ + +#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 0000000000..20622d2375 --- /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 + * . + * + */ + +#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 0000000000..c15681f85c --- /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 + * . + * + */ + +#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 0000000000..16a1f8bed9 --- /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 + * . + * + */ + +#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 0000000000..7c10b5f1bf --- /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 + * . + * + */ + +#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 0000000000..554e15c3fd --- /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 + * . + * + */ + +#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_streatch.glsl b/system/shaders/GL/1.2/gl_streatch.glsl new file mode 100644 index 0000000000..dc42318d50 --- /dev/null +++ b/system/shaders/GL/1.2/gl_streatch.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 + * . + * + */ + +#version 120 + +uniform sampler2D img; +uniform float m_stretch; +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 = gl_Color.a; +} 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 0000000000..ff7af3b678 --- /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 + * . + * + */ + +#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 0000000000..aa124b5350 --- /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 + * . + * + */ + +#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 0000000000..268d8c6682 --- /dev/null +++ b/system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl @@ -0,0 +1,122 @@ +/* + * 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 + * . + * + */ + +#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; + +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) || defined(XBMC_NV12) + + vec4 yuv; + yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r + , texture2D(m_sampU, stretch(m_cordU)).g + , texture2D(m_sampV, stretch(m_cordV)).a + , 1.0 ); + + rgb = m_yuvmat * yuv; + rgb.a = gl_Color.a; + +#elif defined(XBMC_NV12_RRG) + + 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)).g + , 1.0 ); + + rgb = m_yuvmat * yuv; + rgb.a = gl_Color.a; + +#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 = gl_Color.a; + +#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 0000000000..cdf3c56a71 --- /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 + * . + * + */ + +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_convolution-4x4.glsl b/system/shaders/gl_convolution-4x4.glsl deleted file mode 100644 index cf2a0f5378..0000000000 --- a/system/shaders/gl_convolution-4x4.glsl +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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 - * . - * - */ - -uniform sampler2D img; -uniform vec2 stepxy; -uniform float m_stretch; -varying vec2 m_cord; - -#if (USE1DTEXTURE) - uniform sampler1D kernelTex; -#else - uniform sampler2D kernelTex; -#endif - -//nvidia's half is a 16 bit float and can bring some speed improvements -//without affecting quality -#ifndef __GLSL_CG_DATA_TYPES - #define half float - #define half3 vec3 - #define half4 vec4 -#endif - -half4 weight(float pos) -{ -#if (HAS_FLOAT_TEXTURE) - #if (USE1DTEXTURE) - return texture1D(kernelTex, pos); - #else - return texture2D(kernelTex, vec2(pos, 0.5)); - #endif -#else - #if (USE1DTEXTURE) - return texture1D(kernelTex, pos) * 2.0 - 1.0; - #else - return texture2D(kernelTex, vec2(pos, 0.5)) * 2.0 - 1.0; - #endif -#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 -} - -half3 pixel(float xpos, float ypos) -{ - return texture2D(img, vec2(xpos, ypos)).rgb; -} - -half3 line (float ypos, vec4 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; -} - -vec4 process() -{ - vec4 rgb; - vec2 pos = stretch(m_cord) + stepxy * 0.5; - vec2 f = fract(pos / stepxy); - - half4 linetaps = weight(1.0 - f.x); - half4 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; - -#ifdef GL_ES - rgb.a = m_alpha; -#else - rgb.a = gl_Color.a; -#endif - - return rgb; -} diff --git a/system/shaders/gl_convolution-6x6.glsl b/system/shaders/gl_convolution-6x6.glsl deleted file mode 100644 index c4f51fd431..0000000000 --- a/system/shaders/gl_convolution-6x6.glsl +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 - * . - * - */ - -uniform sampler2D img; -uniform vec2 stepxy; -uniform float m_stretch; -varying vec2 m_cord; - -#if (USE1DTEXTURE) - uniform sampler1D kernelTex; -#else - uniform sampler2D kernelTex; -#endif - -//nvidia's half is a 16 bit float and can bring some speed improvements -//without affecting quality -#ifndef __GLSL_CG_DATA_TYPES - #define half float - #define half3 vec3 - #define half4 vec4 -#endif - -half3 weight(float pos) -{ -#if (HAS_FLOAT_TEXTURE) - #if (USE1DTEXTURE) - return texture1D(kernelTex, pos).rgb; - #else - return texture2D(kernelTex, vec2(pos, 0.5)).rgb; - #endif -#else - #if (USE1DTEXTURE) - return texture1D(kernelTex, pos).rgb * 2.0 - 1.0; - #else - return texture2D(kernelTex, vec2(pos, 0.5)).rgb * 2.0 - 1.0; - #endif -#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 -} - -half3 pixel(float xpos, float ypos) -{ - return texture2D(img, vec2(xpos, ypos)).rgb; -} - -half3 line (float ypos, vec3 xpos1, vec3 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; -} - -vec4 process() -{ - vec4 rgb; - vec2 pos = stretch(m_cord) + stepxy * 0.5; - vec2 f = fract(pos / stepxy); - - 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); - - //make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur - half 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; - -#ifdef GL_ES - rgb.a = m_alpha; -#else - rgb.a = gl_Color.a; -#endif - - return rgb; -} diff --git a/system/shaders/gl_output.glsl b/system/shaders/gl_output.glsl deleted file mode 100644 index d3294a8bb5..0000000000 --- a/system/shaders/gl_output.glsl +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 - * . - * - */ - - -#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_shader_frag_default.glsl b/system/shaders/gl_shader_frag_default.glsl deleted file mode 100644 index d9aba5f5fe..0000000000 --- a/system/shaders/gl_shader_frag_default.glsl +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 - * . - * - */ - -#version 120 - -uniform vec4 m_unicol; - -// SM_DEFAULT shader -void main () -{ - gl_FragColor = m_unicol; -} diff --git a/system/shaders/gl_shader_frag_fonts.glsl b/system/shaders/gl_shader_frag_fonts.glsl deleted file mode 100644 index fdc50c1130..0000000000 --- a/system/shaders/gl_shader_frag_fonts.glsl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - * . - * - */ - -#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).a; -} diff --git a/system/shaders/gl_shader_frag_multi.glsl b/system/shaders/gl_shader_frag_multi.glsl deleted file mode 100644 index 804a716ea3..0000000000 --- a/system/shaders/gl_shader_frag_multi.glsl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 - * . - * - */ - -#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_shader_frag_multi_blendcolor.glsl b/system/shaders/gl_shader_frag_multi_blendcolor.glsl deleted file mode 100644 index 20622d2375..0000000000 --- a/system/shaders/gl_shader_frag_multi_blendcolor.glsl +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 - * . - * - */ - -#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_shader_frag_texture.glsl b/system/shaders/gl_shader_frag_texture.glsl deleted file mode 100644 index c15681f85c..0000000000 --- a/system/shaders/gl_shader_frag_texture.glsl +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 - * . - * - */ - -#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_shader_frag_texture_noblend.glsl b/system/shaders/gl_shader_frag_texture_noblend.glsl deleted file mode 100644 index 16a1f8bed9..0000000000 --- a/system/shaders/gl_shader_frag_texture_noblend.glsl +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 - * . - * - */ - -#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_shader_vert.glsl b/system/shaders/gl_shader_vert.glsl deleted file mode 100644 index 7c10b5f1bf..0000000000 --- a/system/shaders/gl_shader_vert.glsl +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 - * . - * - */ - -#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_shader_vert_default.glsl b/system/shaders/gl_shader_vert_default.glsl deleted file mode 100644 index 554e15c3fd..0000000000 --- a/system/shaders/gl_shader_vert_default.glsl +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 - * . - * - */ - -#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_streatch.glsl b/system/shaders/gl_streatch.glsl deleted file mode 100644 index dc42318d50..0000000000 --- a/system/shaders/gl_streatch.glsl +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 - * . - * - */ - -#version 120 - -uniform sampler2D img; -uniform float m_stretch; -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 = gl_Color.a; -} diff --git a/system/shaders/gl_videofilter_frag.glsl b/system/shaders/gl_videofilter_frag.glsl deleted file mode 100644 index ff7af3b678..0000000000 --- a/system/shaders/gl_videofilter_frag.glsl +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 - * . - * - */ - -#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_videofilter_vertex.glsl b/system/shaders/gl_videofilter_vertex.glsl deleted file mode 100644 index aa124b5350..0000000000 --- a/system/shaders/gl_videofilter_vertex.glsl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - * . - * - */ - -#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_yuv2rgb_basic.glsl b/system/shaders/gl_yuv2rgb_basic.glsl deleted file mode 100644 index 268d8c6682..0000000000 --- a/system/shaders/gl_yuv2rgb_basic.glsl +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 - * . - * - */ - -#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; - -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) || defined(XBMC_NV12) - - vec4 yuv; - yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r - , texture2D(m_sampU, stretch(m_cordU)).g - , texture2D(m_sampV, stretch(m_cordV)).a - , 1.0 ); - - rgb = m_yuvmat * yuv; - rgb.a = gl_Color.a; - -#elif defined(XBMC_NV12_RRG) - - 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)).g - , 1.0 ); - - rgb = m_yuvmat * yuv; - rgb.a = gl_Color.a; - -#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 = gl_Color.a; - -#endif - - return rgb; -} diff --git a/system/shaders/gl_yuv2rgb_vertex.glsl b/system/shaders/gl_yuv2rgb_vertex.glsl deleted file mode 100644 index cdf3c56a71..0000000000 --- a/system/shaders/gl_yuv2rgb_vertex.glsl +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 - * . - * - */ - -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/xbmc/guilib/Shader.cpp b/xbmc/guilib/Shader.cpp index 803ec50965..93bc427b7f 100644 --- a/xbmc/guilib/Shader.cpp +++ b/xbmc/guilib/Shader.cpp @@ -20,12 +20,11 @@ #include "system.h" -#if defined(HAS_GL) || HAS_GLES >= 2 - #include "Shader.h" #include "filesystem/File.h" #include "utils/log.h" #include "utils/GLUtils.h" +#include "windowing/WindowingFactory.h" #ifdef HAS_GLES #define GLchar char @@ -46,7 +45,10 @@ bool CShader::LoadSource(const std::string& filename, const std::string& prefix) CFileStream file; - if(!file.Open("special://xbmc/system/shaders/" + filename)) + std::string path = "special://xbmc/system/shaders/"; + path += g_Windowing.GetShaderPath(); + path += filename; + if(!file.Open(path)) { CLog::Log(LOGERROR, "CYUVShaderGLSL::CYUVShaderGLSL - failed to open file %s", filename.c_str()); return false; @@ -64,7 +66,10 @@ bool CShader::AppendSource(const std::string& filename) CFileStream file; std::string temp; - if(!file.Open("special://xbmc/system/shaders/" + filename)) + std::string path = "special://xbmc/system/shaders/"; + path += g_Windowing.GetShaderPath(); + path += filename; + if(!file.Open(path)) { CLog::Log(LOGERROR, "CShader::AppendSource - failed to open file %s", filename.c_str()); return false; @@ -480,5 +485,3 @@ void CARBShaderProgram::Disable() } #endif - -#endif diff --git a/xbmc/rendering/RenderSystem.h b/xbmc/rendering/RenderSystem.h index 91a6fae817..51e164ffb6 100644 --- a/xbmc/rendering/RenderSystem.h +++ b/xbmc/rendering/RenderSystem.h @@ -98,6 +98,8 @@ public: */ virtual void Project(float &x, float &y, float &z) { } + virtual std::string GetShaderPath() { return ""; } + void GetRenderVersion(unsigned int& major, unsigned int& minor) const; const std::string& GetRenderVendor() const { return m_RenderVendor; } const std::string& GetRenderRenderer() const { return m_RenderRenderer; } diff --git a/xbmc/rendering/gl/RenderSystemGL.cpp b/xbmc/rendering/gl/RenderSystemGL.cpp index 026d66ee46..cbe4972de3 100644 --- a/xbmc/rendering/gl/RenderSystemGL.cpp +++ b/xbmc/rendering/gl/RenderSystemGL.cpp @@ -810,3 +810,9 @@ GLint CRenderSystemGL::ShaderGetModel() return -1; } + +std::string CRenderSystemGL::GetShaderPath() +{ + std::string path = "GL/1.2/"; + return path; +} diff --git a/xbmc/rendering/gl/RenderSystemGL.h b/xbmc/rendering/gl/RenderSystemGL.h index ec4eb79e54..b5d86ec2ec 100644 --- a/xbmc/rendering/gl/RenderSystemGL.h +++ b/xbmc/rendering/gl/RenderSystemGL.h @@ -77,6 +77,8 @@ public: void Project(float &x, float &y, float &z) override; + std::string GetShaderPath() override; + void GetGLSLVersion(int& major, int& minor); void ResetGLErrors(); -- cgit v1.2.3