]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2:
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 28 Nov 2010 00:45:16 +0000 (00:45 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 28 Nov 2010 00:45:16 +0000 (00:45 +0000)
 - gpu bicubic scaling.

git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@264 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

common/gl/pixel_buffer_object.cpp
core/processor/frame_shader.cpp
shell/caspar.config
shell/shell.vcxproj

index 4cf8f82f01d184c3d77c8795bfb4fdc3cb4b1b10..2684061698e35d19bcf14702d7a11065016f7c4f 100644 (file)
@@ -68,8 +68,8 @@ struct pixel_buffer_object::implementation : boost::noncopyable
 \r
                        GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
 \r
-                       GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));\r
-                       GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));\r
+                       GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));\r
+                       GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));\r
                        GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));\r
                        GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));\r
 \r
index 70b388c0d01c675b6a6473603883e49f2b1e12a6..f69057333d7bd398a6dd7c009e676102998370f0 100644 (file)
@@ -89,6 +89,8 @@ public:
        {       \r
                GL(glUseProgramObjectARB(program_));            \r
        }\r
+\r
+       GLuint program() { return program_; }\r
        \r
 private:\r
        GLuint program_;\r
@@ -120,13 +122,71 @@ struct frame_shader::implementation
                        "       color.a = a;                                                                                                            "\r
                        "                                                                                                                                               "\r
                        "       return color;                                                                                                           "\r
-                       "}                                                                                                                                              ";\r
+                       "}                                                                                                                                              "\r
+                       "                                                                                                                                               "\r
+                       "vec4 texture2DBilinear(sampler2D sampler, vec2 uv, vec4 size)                  "\r
+                       "{                                                                                                                                              "\r
+                       "       vec4 x0 = texture2D(sampler, uv + size.zw * vec2(0.0, 0.0));            "\r
+                       "       vec4 x1 = texture2D(sampler, uv + size.zw * vec2(1.0, 0.0));            "\r
+                       "       vec4 x2 = texture2D(sampler, uv + size.zw * vec2(0.0, 1.0));            "\r
+                       "       vec4 x3 = texture2D(sampler, uv + size.zw * vec2(1.0, 1.0));            "\r
+                       "       vec2 f  = fract(uv.xy * size.xy );                                                                      "\r
+                       "       vec4 y0 = mix(x0, x1, f.x);                                                                                     "\r
+                       "       vec4 y1 = mix(x2, x3, f.x);                                                                                     "\r
+                       "       return mix(y0, y1, f.y);                                                                                        "\r
+                       "}                                                                                                                                              "\r
+                       "                                                                                                                                                                       "\r
+                       "vec4 computeWeights(float x)                                                                                                           "\r
+                       "{                                                                                                                                                                      "\r
+                       "       vec4 x1 = x*vec4(1.0, 1.0, -1.0, -1.0) + vec4(1.0, 0.0, 1.0, 2.0);                              "\r
+                       "       vec4 x2 = x1*x1;                                                                                                                                "\r
+                       "       vec4 x3 = x2*x1;                                                                                                                                "\r
+                       "                                                                                                                                                                       "\r
+                       "       const float A = -0.75;                                                                                                                  "       \r
+                       "       vec4 w;                                                                                                                                                 "\r
+                       "       w =  x3 * vec2(  A,      A+2.0).xyyx;                                                                                   "\r
+                       "       w += x2 * vec2( -5.0*A, -(A+3.0)).xyyx;                                                                                 "\r
+                       "       w += x1 * vec2(  8.0*A,  0).xyyx;                                                                                               "\r
+                       "       w +=      vec2( -4.0*A,  1.0).xyyx;                                                                                             "\r
+                       "       return w;                                                                                                                                               "\r
+                       "}                                                                                                                                                                      "\r
+                       "                                                                                                                                                                       "\r
+                       "vec4 cubicFilter(vec4 w, vec4 c0, vec4 c1, vec4 c2, vec4 c3)                                           "\r
+                       "{                                                                                                                                                                      "\r
+                       "       return c0*w[0] + c1*w[1] + c2*w[2] + c3*w[3];                                                                   "\r
+                       "}                                                                                                                                                                      "\r
+                       "                                                                                                                                                                       "\r
+                       "vec4 texture2DBicubic(sampler2D sampler, vec2 uv, vec4 size)                                           "\r
+                       "{                                                                                                                                                                      "\r
+                       "       vec2 f = fract(uv*size.xy);                                                                                                             "\r
+                       "                                                                                                                                                                       "\r
+                       "       vec4 w = computeWeights(f.x);                                                                                                   "\r
+                       "       vec4 t0 = cubicFilter(w,        texture2D(sampler, uv + vec2(-1.0, -1.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 0.0, -1.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 1.0, -1.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 2.0, -1.0) * size.zw));"\r
+                       "       vec4 t1 = cubicFilter(w,        texture2D(sampler, uv + vec2(-1.0,  0.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 0.0,  0.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 1.0,  0.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 2.0,  0.0) * size.zw));"\r
+                       "       vec4 t2 = cubicFilter(w,        texture2D(sampler, uv + vec2(-1.0,  1.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 0.0,  1.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 1.0,  1.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 2.0,  1.0) * size.zw));"\r
+                       "       vec4 t3 = cubicFilter(w,        texture2D(sampler, uv + vec2(-1.0,  2.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 0.0,  2.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 1.0,  2.0) * size.zw),"\r
+                       "                                                               texture2D(sampler, uv + vec2( 2.0,  2.0) * size.zw));"\r
+                       "                                                                                                                                                                       "\r
+                       "       w = computeWeights(f.y);                                                                                                                "\r
+                       "       return cubicFilter(w, t0, t1, t2, t3);                                                                                  "\r
+                       "}                                                                                                                                                                      ";\r
                        \r
                shaders_[pixel_format::abgr] = common +\r
 \r
                        "void main()                                                                                                                    "\r
                        "{                                                                                                                                              "\r
-                               "vec4 abgr = texture2D(plane[0], gl_TexCoord[0].st);                            "\r
+                       "       vec4 abgr = texture2DBicubic(plane[0], gl_TexCoord[0].st+plane_size[0].zw*0.5, plane_size[0]);"\r
                                "gl_FragColor = abgr.argb * gl_Color;                                                           "\r
                        "}                                                                                                                                              ";\r
                \r
@@ -134,7 +194,7 @@ struct frame_shader::implementation
 \r
                        "void main()                                                                                                                    "       \r
                        "{                                                                                                                                              "\r
-                               "vec4 argb = texture2D(plane[0], gl_TexCoord[0].st);                            "\r
+                               "vec4 argb = texture2DBicubic(plane[0], gl_TexCoord[0].st+plane_size[0].zw*0.5, plane_size[0]);"\r
                                "gl_FragColor = argb.grab * gl_Color;                                                           "       \r
                        "}                                                                                                                                              ";\r
                \r
@@ -142,7 +202,7 @@ struct frame_shader::implementation
 \r
                        "void main()                                                                                                                    "\r
                        "{                                                                                                                                              "\r
-                               "vec4 bgra = texture2D(plane[0], gl_TexCoord[0].st);                            "\r
+                               "vec4 bgra = texture2DBicubic(plane[0], gl_TexCoord[0].st+plane_size[0].zw*0.5, plane_size[0]);"\r
                                "gl_FragColor = bgra.rgba * gl_Color;                                                           "\r
                        "}                                                                                                                                              ";\r
                \r
@@ -150,7 +210,7 @@ struct frame_shader::implementation
 \r
                        "void main()                                                                                                                    "\r
                        "{                                                                                                                                              "\r
-                               "vec4 rgba = texture2D(plane[0], gl_TexCoord[0].st);                            "\r
+                               "vec4 rgba = texture2DBicubic(plane[0], gl_TexCoord[0].st+plane_size[0].zw*0.5, plane_size[0]);"\r
                                "gl_FragColor = rgba.bgra * gl_Color;                                                           "\r
                        "}                                                                                                                                              ";\r
                \r
@@ -158,9 +218,9 @@ struct frame_shader::implementation
 \r
                        "void main()                                                                                                                    "\r
                        "{                                                                                                                                              "\r
-                               "float y  = texture2D(plane[0], gl_TexCoord[0].st).r;                           "\r
-                               "float cb = texture2D(plane[1], gl_TexCoord[0].st).r;                           "\r
-                               "float cr = texture2D(plane[2], gl_TexCoord[0].st).r;                           "\r
+                               "float y  = texture2DBicubic(plane[0], gl_TexCoord[0].st+plane_size[0].zw*0.5, plane_size[0]).r;"\r
+                               "float cb = texture2DBicubic(plane[1], gl_TexCoord[0].st+plane_size[1].zw*0.5, plane_size[1]).r;"\r
+                               "float cr = texture2DBicubic(plane[2], gl_TexCoord[0].st+plane_size[2].zw*0.5, plane_size[2]).r;"\r
                                "float a = 1.0;                                                                                                         "       \r
                                "gl_FragColor = ycbcra_to_bgra(y, cb, cr, a) * gl_Color;                        "\r
                        "}                                                                                                                                              ";\r
@@ -169,10 +229,10 @@ struct frame_shader::implementation
 \r
                        "void main()                                                                                                                    "\r
                        "{                                                                                                                                              "\r
-                               "float y  = texture2D(plane[0], gl_TexCoord[0].st).r;                           "\r
-                               "float cb = texture2D(plane[1], gl_TexCoord[0].st).r;                           "\r
-                               "float cr = texture2D(plane[2], gl_TexCoord[0].st).r;                           "\r
-                               "float a  = texture2D(plane[3], gl_TexCoord[0].st).r;                           "\r
+                               "float y  = texture2DBicubic(plane[0], gl_TexCoord[0].st+plane_size[0].zw*0.5, plane_size[0]).r;"\r
+                               "float cb = texture2DBicubic(plane[1], gl_TexCoord[0].st+plane_size[1].zw*0.5, plane_size[1]).r;"\r
+                               "float cr = texture2DBicubic(plane[2], gl_TexCoord[0].st+plane_size[2].zw*0.5, plane_size[2]).r;"\r
+                               "float a  = texture2DBicubic(plane[3], gl_TexCoord[0].st+plane_size[3].zw*0.5, plane_size[3]).r;"\r
                                "gl_FragColor = ycbcra_to_bgra(y, cb, cr, a) * gl_Color;                        "\r
                        "}                                                                                                                                              ";\r
        }\r
@@ -180,6 +240,7 @@ struct frame_shader::implementation
        void use(const pixel_format_desc& desc)\r
        {\r
                set_pixel_format(desc.pix_fmt);\r
+               set_planes(desc.planes);\r
        }\r
 \r
        void set_pixel_format(pixel_format::type format)\r
@@ -190,6 +251,13 @@ struct frame_shader::implementation
                shaders_[format].use();\r
        }\r
 \r
+       void set_planes(const std::vector<pixel_format_desc::plane>& planes)\r
+       {\r
+               for(size_t n = 0; n < planes.size(); ++n)\r
+                       glUniform4f(glGetUniformLocation(shaders_[current_].program(), std::string("plane_size[" + boost::lexical_cast<std::string>(n) + "]").c_str()), \r
+                               static_cast<float>(planes[n].width), static_cast<float>(planes[n].height), 1.0f/static_cast<float>(planes[n].width), 1.0f/static_cast<float>(planes[n].height));\r
+       }\r
+\r
        //void set_size(pixel_format_desc& desc)\r
        //{\r
        //      for(int n = 0; n < 4; ++n)\r
index 2992db7801998897de7c07030cf6c9c5c0e408e1..ed39aad43a5f828d9266e8f5d676985890ddf8fe 100644 (file)
@@ -8,7 +8,7 @@
   </paths>\r
   <channels>\r
     <channel>\r
-      <videomode>720p2500</videomode>\r
+      <videomode>1080p2500</videomode>\r
       <consumers>\r
         <ogl>\r
           <device>1</device>\r
index 4220941575a67fe77551364f4940c2e600411214..0b67ff821f0023fabbb5b299b290abc30f05c969 100644 (file)
       <DataExecutionPrevention>\r
       </DataExecutionPrevention>\r
       <TargetMachine>MachineX86</TargetMachine>\r
-      <LinkTimeCodeGeneration>\r
-      </LinkTimeCodeGeneration>\r
+      <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\r
     </Link>\r
     <PostBuildEvent>\r
       <Command>\r