aboutsummaryrefslogtreecommitdiff
path: root/system/shaders
diff options
context:
space:
mode:
authorwiso <wiso@svn>2010-01-17 20:26:55 +0000
committerwiso <wiso@svn>2010-01-17 20:26:55 +0000
commit59d93fa9b5998da3b51910a05b5016da225382aa (patch)
tree8f36c98b1c2319cc1e46e2e7ef701998d0e99605 /system/shaders
parente16e287038c55ec8af2bd556df1616faf6e520d8 (diff)
[WIN32] added: D3D Pixel Shader Video Scalers #8412 (thanks ArtVandelae)
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@26952 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'system/shaders')
-rw-r--r--system/shaders/yuv2rgb_4x4_d3d.fx132
-rw-r--r--system/shaders/yuv2rgb_6x6_d3d.fx141
2 files changed, 273 insertions, 0 deletions
diff --git a/system/shaders/yuv2rgb_4x4_d3d.fx b/system/shaders/yuv2rgb_4x4_d3d.fx
new file mode 100644
index 0000000000..18ae0257f0
--- /dev/null
+++ b/system/shaders/yuv2rgb_4x4_d3d.fx
@@ -0,0 +1,132 @@
+texture g_YTexture;
+texture g_UTexture;
+texture g_VTexture;
+texture g_KernelTexture;
+
+float2 g_YStep;
+float2 g_UVStep;
+
+float4x4 g_ColorMatrix;
+
+sampler YSampler =
+ sampler_state {
+ Texture = <g_YTexture>;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ MipFilter = LINEAR;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ };
+
+sampler USampler =
+ sampler_state {
+ Texture = <g_UTexture>;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ MipFilter = LINEAR;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ };
+
+sampler VSampler =
+ sampler_state
+ {
+ Texture = <g_VTexture>;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ MipFilter = LINEAR;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ };
+
+sampler KernelSampler =
+ sampler_state
+ {
+ Texture = <g_KernelTexture>;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ };
+
+struct VS_OUTPUT
+{
+ float4 Position : POSITION;
+ float2 TextureY : TEXCOORD0;
+ float2 TextureU : TEXCOORD1;
+ float2 TextureV : TEXCOORD2;
+};
+
+struct PS_OUTPUT
+{
+ float4 RGBColor : COLOR0;
+};
+
+float4 weight(float pos)
+{
+ return tex1D(KernelSampler, pos);
+}
+
+float pixel(sampler tex, float xpos, float ypos)
+{
+ return tex2D(tex, float2(xpos, ypos)).r;
+}
+
+float getLine(sampler tex, float ypos, float4 xpos, float4 linetaps)
+{
+ float pixels;
+
+ pixels = pixel(tex, xpos.r, ypos) * linetaps.r;
+ pixels += pixel(tex, xpos.g, ypos) * linetaps.g;
+ pixels += pixel(tex, xpos.b, ypos) * linetaps.b;
+ pixels += pixel(tex, xpos.a, ypos) * linetaps.a;
+
+ return pixels;
+}
+
+float getPixel(sampler tex, float2 texCoord, float2 step)
+{
+ float xf = frac(texCoord.x / step.x);
+ float yf = frac(texCoord.y / step.y);
+
+ float4 linetaps = weight(1.0 - xf);
+ float4 columntaps = weight(1.0 - yf);
+
+ float4 xpos = float4(
+ (-0.5 - xf) * step.x + texCoord.x,
+ ( 0.5 - xf) * step.x + texCoord.x,
+ ( 1.5 - xf) * step.x + texCoord.x,
+ ( 2.5 - xf) * step.x + texCoord.x);
+
+ float fragColor;
+ fragColor = getLine(tex, (-0.5 - yf) * step.y + texCoord.y, xpos, linetaps) * columntaps.r;
+ fragColor += getLine(tex, ( 0.5 - yf) * step.y + texCoord.y, xpos, linetaps) * columntaps.g;
+ fragColor += getLine(tex, ( 1.5 - yf) * step.y + texCoord.y, xpos, linetaps) * columntaps.b;
+ fragColor += getLine(tex, ( 2.5 - yf) * step.y + texCoord.y, xpos, linetaps) * columntaps.a;
+
+ return fragColor;
+}
+
+PS_OUTPUT YUV2RGB(VS_OUTPUT In)
+{
+ PS_OUTPUT OUT;
+ float4 YUV = float4(getPixel (YSampler, In.TextureY, g_YStep)
+ , getPixel (USampler, In.TextureU, g_UVStep)
+ , getPixel (VSampler, In.TextureV, g_UVStep)
+ , 1.0);
+ OUT.RGBColor = mul(YUV, g_ColorMatrix);
+ OUT.RGBColor.a = 1.0;
+ return OUT;
+}
+
+technique YUV2RGB_T
+{
+ pass P0
+ {
+ PixelShader = compile ps_3_0 YUV2RGB();
+ ZEnable = False;
+ FillMode = Solid;
+ FogEnable = False;
+ }
+};
diff --git a/system/shaders/yuv2rgb_6x6_d3d.fx b/system/shaders/yuv2rgb_6x6_d3d.fx
new file mode 100644
index 0000000000..9fce0b2c49
--- /dev/null
+++ b/system/shaders/yuv2rgb_6x6_d3d.fx
@@ -0,0 +1,141 @@
+texture g_YTexture;
+texture g_UTexture;
+texture g_VTexture;
+texture g_KernelTexture;
+
+float2 g_YStep;
+float2 g_UVStep;
+
+float4x4 g_ColorMatrix;
+
+sampler YSampler =
+ sampler_state {
+ Texture = <g_YTexture>;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ MipFilter = LINEAR;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ };
+
+sampler USampler =
+ sampler_state {
+ Texture = <g_UTexture>;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ MipFilter = LINEAR;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ };
+
+sampler VSampler =
+ sampler_state
+ {
+ Texture = <g_VTexture>;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ MipFilter = LINEAR;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ };
+
+sampler KernelSampler =
+ sampler_state
+ {
+ Texture = <g_KernelTexture>;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ };
+
+struct VS_OUTPUT
+{
+ float4 Position : POSITION;
+ float2 TextureY : TEXCOORD0;
+ float2 TextureU : TEXCOORD1;
+ float2 TextureV : TEXCOORD2;
+};
+
+struct PS_OUTPUT
+{
+ float4 RGBColor : COLOR0;
+};
+
+float3 weight(float pos)
+{
+ return tex1D(KernelSampler, pos).rgb;
+}
+
+float pixel(sampler tex, float xpos, float ypos)
+{
+ return tex2D(tex, float2(xpos, ypos)).r;
+}
+
+float getLine(sampler tex, float ypos, float3 xpos1, float3 xpos2, float3 linetaps1, float3 linetaps2)
+{
+ float pixels;
+
+ pixels = pixel(tex, xpos1.r, ypos) * linetaps1.r;
+ pixels += pixel(tex, xpos1.g, ypos) * linetaps2.r;
+ pixels += pixel(tex, xpos1.b, ypos) * linetaps1.g;
+ pixels += pixel(tex, xpos2.r, ypos) * linetaps2.g;
+ pixels += pixel(tex, xpos2.g, ypos) * linetaps1.b;
+ pixels += pixel(tex, xpos2.b, ypos) * linetaps2.b;
+
+ return pixels;
+}
+
+float getPixel(sampler tex, float2 texCoord, float2 step)
+{
+ float xf = frac(texCoord.x / step.x);
+ float yf = frac(texCoord.y / step.y);
+
+ float3 linetaps1 = weight((1.0 - xf) / 2.0);
+ float3 linetaps2 = weight((1.0 - xf) / 2.0 + 0.5);
+ float3 columntaps1 = weight((1.0 - yf) / 2.0);
+ float3 columntaps2 = weight((1.0 - yf) / 2.0 + 0.5);
+
+ float3 xpos1 = float3(
+ (-1.5 - xf) * step.x + texCoord.x,
+ (-0.5 - xf) * step.x + texCoord.x,
+ ( 0.5 - xf) * step.x + texCoord.x);
+ float3 xpos2 = float3(
+ ( 1.5 - xf) * step.x + texCoord.x,
+ ( 2.5 - xf) * step.x + texCoord.x,
+ ( 3.5 - xf) * step.x + texCoord.x);
+
+ float fragColor;
+ fragColor = getLine(tex, (-1.5 - yf) * step.y + texCoord.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r;
+ fragColor += getLine(tex, (-0.5 - yf) * step.y + texCoord.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r;
+ fragColor += getLine(tex, ( 0.5 - yf) * step.y + texCoord.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g;
+ fragColor += getLine(tex, ( 1.5 - yf) * step.y + texCoord.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g;
+ fragColor += getLine(tex, ( 2.5 - yf) * step.y + texCoord.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b;
+ fragColor += getLine(tex, ( 3.5 - yf) * step.y + texCoord.y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b;
+
+ return fragColor;
+}
+
+PS_OUTPUT YUV2RGB(VS_OUTPUT In)
+{
+ PS_OUTPUT OUT;
+ float4 YUV = float4(getPixel (YSampler, In.TextureY, g_YStep)
+ , getPixel (USampler, In.TextureU, g_UVStep)
+ , getPixel (VSampler, In.TextureV, g_UVStep)
+ , 1.0);
+ OUT.RGBColor = mul(YUV, g_ColorMatrix);
+ OUT.RGBColor.a = 1.0;
+ return OUT;
+}
+
+technique YUV2RGB_T
+{
+ pass P0
+ {
+ PixelShader = compile ps_3_0 YUV2RGB();
+ ZEnable = False;
+ FillMode = Solid;
+ FogEnable = False;
+ }
+};