aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Fedchin <anightik@gmail.com>2017-04-17 11:42:44 +0300
committerAnton Fedchin <anightik@gmail.com>2017-07-17 11:43:02 +0300
commit159b839dc3fbc9b40f7f956ab5fc7b82c67c1458 (patch)
tree818a7b264990a4b0f9eb243d325c510f153cdd9d
parent320d0c55ecc48445c3e6d9f1bf7fa2a15c3d58f2 (diff)
[shaders] fx: re-factor shaders.
-rw-r--r--system/shaders/convolution-4x4_d3d.fx45
-rw-r--r--system/shaders/convolution-6x6_d3d.fx45
-rw-r--r--system/shaders/convolution_d3d.fx61
-rw-r--r--system/shaders/convolutionsep-4x4_d3d.fx47
-rw-r--r--system/shaders/convolutionsep-6x6_d3d.fx47
-rw-r--r--system/shaders/output_d3d.fx74
-rw-r--r--system/shaders/yuv2rgb_d3d.fx4
7 files changed, 156 insertions, 167 deletions
diff --git a/system/shaders/convolution-4x4_d3d.fx b/system/shaders/convolution-4x4_d3d.fx
index f7d87b7e47..19c2fece08 100644
--- a/system/shaders/convolution-4x4_d3d.fx
+++ b/system/shaders/convolution-4x4_d3d.fx
@@ -18,11 +18,8 @@
*
*/
-texture2D g_Texture;
-texture2D g_KernelTexture;
-float2 g_StepXY;
-float2 g_viewPort;
-float2 g_colorRange;
+#include "convolution_d3d.fx"
+#include "output_d3d.fx"
SamplerState RGBSampler : IMMUTABLE
{
@@ -31,40 +28,6 @@ SamplerState RGBSampler : IMMUTABLE
Filter = MIN_MAG_MIP_POINT;
};
-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;
-}
-
inline half4 weight(float pos)
{
#ifdef HAS_RGBA
@@ -112,14 +75,14 @@ float4 CONVOLUTION4x4(float2 TextureUV : TEXCOORD0) : SV_TARGET
getLine(ypos.z, xpos, linetaps) * columntaps.b +
getLine(ypos.w, xpos, linetaps) * columntaps.a;
- return float4(g_colorRange.x + g_colorRange.y * saturate(rgb), 1.0);
+ return output(g_colorRange.x + g_colorRange.y * saturate(rgb));
}
technique11 SCALER_T
{
pass P0
{
- SetVertexShader( CompileShader( vs_4_0_level_9_1, VS() ) );
+ 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
index 9ef8c080d8..6ca6f04354 100644
--- a/system/shaders/convolution-6x6_d3d.fx
+++ b/system/shaders/convolution-6x6_d3d.fx
@@ -18,11 +18,8 @@
*
*/
-texture2D g_Texture;
-texture2D g_KernelTexture;
-float2 g_StepXY;
-float2 g_viewPort;
-float2 g_colorRange;
+#include "convolution_d3d.fx"
+#include "output_d3d.fx"
SamplerState RGBSampler : IMMUTABLE
{
@@ -31,40 +28,6 @@ SamplerState RGBSampler : IMMUTABLE
Filter = MIN_MAG_MIP_POINT;
};
-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;
-}
-
half3 weight(float pos)
{
#ifdef HAS_RGBA
@@ -120,14 +83,14 @@ float4 CONVOLUTION6x6(in float2 TextureUV : TEXCOORD0) : SV_TARGET
getLine(ypos2.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b +
getLine(ypos2.z, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b;
- return float4(g_colorRange.x + g_colorRange.y * saturate(rgb), 1.0);
+ return output(g_colorRange.x + g_colorRange.y * saturate(rgb));
}
technique11 SCALER_T
{
pass P0
{
- SetVertexShader( CompileShader( vs_4_0_level_9_1, VS() ) );
+ 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 0000000000..6ff6150854
--- /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
index 40c14b632f..ca861ba740 100644
--- a/system/shaders/convolutionsep-4x4_d3d.fx
+++ b/system/shaders/convolutionsep-4x4_d3d.fx
@@ -18,11 +18,8 @@
*
*/
-texture2D g_Texture;
-texture2D g_KernelTexture;
-float4 g_StepXY;
-float2 g_viewPort;
-float2 g_colorRange;
+#include "convolution_d3d.fx"
+#include "output_d3d.fx"
SamplerState RGBSampler : IMMUTABLE
{
@@ -31,40 +28,6 @@ SamplerState RGBSampler : IMMUTABLE
Filter = MIN_MAG_POINT_MIP_LINEAR;
};
-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;
-}
-
inline half4 weight(float pos)
{
#ifdef HAS_RGBA
@@ -127,19 +90,19 @@ float4 CONVOLUTION4x4Vert(in float2 TextureUV : TEXCOORD0) : SV_TARGET
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 float4(g_colorRange.x + g_colorRange.y * saturate(getRow(TextureUV.x, ypos, columntaps)), 1.0);
+ return output(g_colorRange.x + g_colorRange.y * saturate(getRow(TextureUV.x, ypos, columntaps)));
}
technique11 SCALER_T
{
pass P0
{
- SetVertexShader( CompileShader( vs_4_0_level_9_1, VS() ) );
+ SetVertexShader( VS_SHADER );
SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION4x4Horiz() ) );
}
pass P1
{
- SetVertexShader( CompileShader( vs_4_0_level_9_1, VS() ) );
+ 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
index 376963571f..1864ae3f01 100644
--- a/system/shaders/convolutionsep-6x6_d3d.fx
+++ b/system/shaders/convolutionsep-6x6_d3d.fx
@@ -18,11 +18,8 @@
*
*/
-texture2D g_Texture;
-texture2D g_KernelTexture;
-float4 g_StepXY;
-float2 g_viewPort;
-float2 g_colorRange;
+#include "convolution_d3d.fx"
+#include "output_d3d.fx"
SamplerState RGBSampler : IMMUTABLE
{
@@ -31,40 +28,6 @@ SamplerState RGBSampler : IMMUTABLE
Filter = MIN_MAG_POINT_MIP_LINEAR;
};
-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;
-}
-
inline half3 weight(float pos)
{
#ifdef HAS_RGBA
@@ -140,19 +103,19 @@ float4 CONVOLUTION6x6Vert(in float2 TextureUV : TEXCOORD0) : SV_TARGET
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 float4(g_colorRange.x + g_colorRange.y * saturate(getRow(TextureUV.x, ypos1, ypos2, columntaps1, columntaps2)), 1.0);
+ return output(g_colorRange.x + g_colorRange.y * saturate(getRow(TextureUV.x, ypos1, ypos2, columntaps1, columntaps2)));
}
technique11 SCALER_T
{
pass P0
{
- SetVertexShader( CompileShader( vs_4_0_level_9_1, VS() ) );
+ SetVertexShader( VS_SHADER );
SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION6x6Horiz() ) );
}
pass P1
{
- SetVertexShader( CompileShader( vs_4_0_level_9_1, VS() ) );
+ SetVertexShader( VS_SHADER );
SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION6x6Vert() ) );
}
};
diff --git a/system/shaders/output_d3d.fx b/system/shaders/output_d3d.fx
new file mode 100644
index 0000000000..47536dc574
--- /dev/null
+++ b/system/shaders/output_d3d.fx
@@ -0,0 +1,74 @@
+/*
+ * 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)
+float m_CLUTsize;
+texture3D m_CLUT;
+
+SamplerState LutSampler : IMMUTABLE
+{
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+ Filter = MIN_MAG_MIP_LINEAR;
+};
+#endif
+
+float4 output4(float4 color)
+{
+#if defined(KODI_3DLUT)
+ half3 scale = (m_CLUTsize - 1.0) / m_CLUTsize;
+ half3 offset = 1.0 / (2.0 * m_CLUTsize);
+ color.rgb = m_CLUT.Sample(LutSampler, color.rgb*scale + offset).rgb;
+#endif
+ return color;
+}
+
+float4 output(float3 color)
+{
+ return output4(float4(color, 1.0));
+}
+
+#if defined(KODI_OUTPUT_T)
+#include "convolution_d3d.fx"
+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);
+ 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);
+}
+
+technique11 OUTPUT_T
+{
+ pass P0
+ {
+ SetVertexShader( VS_SHADER );
+ SetPixelShader( CompileShader( ps_4_0_level_9_1, OUTPUT_PS() ) );
+ }
+};
+#endif \ No newline at end of file
diff --git a/system/shaders/yuv2rgb_d3d.fx b/system/shaders/yuv2rgb_d3d.fx
index 221de95e7f..c20d1d1fed 100644
--- a/system/shaders/yuv2rgb_d3d.fx
+++ b/system/shaders/yuv2rgb_d3d.fx
@@ -18,6 +18,8 @@
*
*/
+#include "output_d3d.fx"
+
texture2D g_Texture[3];
float4x4 g_ColorMatrix;
float2 g_StepXY;
@@ -123,7 +125,7 @@ float4 YUV2RGB(VS_OUTPUT In) : SV_TARGET
float4 YUV = float4(outY, outUV, 1.0);
#endif
- return mul(YUV, g_ColorMatrix);
+ return output4(mul(YUV, g_ColorMatrix));
}
technique11 YUV2RGB_T