                 { \
                     const dim3 block(32, 8); \
                     const dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y)); \
-                    bindTexture(&tex_resize_ ## type, srcWhole); \
-                    tex_resize_ ## type ## _reader texSrc; \
-                    texSrc.xoff = xoff; \
-                    texSrc.yoff = yoff; \
-                    if (srcWhole.cols == src.cols && srcWhole.rows == src.rows) \
+                    if (srcWhole.data == src.data) \
                     { \
+                        bindTexture(&tex_resize_ ## type, src); \
+                        tex_resize_ ## type ## _reader texSrc; \
+                        texSrc.xoff = 0; \
+                        texSrc.yoff = 0; \
                         Filter<tex_resize_ ## type ## _reader> filteredSrc(texSrc); \
                         resize<<<grid, block>>>(filteredSrc, fx, fy, dst); \
                     } \
                     else \
                     { \
+                        bindTexture(&tex_resize_ ## type, srcWhole); \
+                        tex_resize_ ## type ## _reader texSrc; \
+                        texSrc.xoff = xoff; \
+                        texSrc.yoff = yoff; \
                         BrdReplicate< type > brd(src.rows, src.cols); \
                         BorderReader<tex_resize_ ## type ## _reader, BrdReplicate< type > > brdSrc(texSrc, brd); \
                         Filter< BorderReader<tex_resize_ ## type ## _reader, BrdReplicate< type > > > filteredSrc(brdSrc); \

                    tex_resize_ ## type ## _reader texSrc; \
                    texSrc.xoff = xoff; \
                    texSrc.yoff = yoff; \
                    if (srcWhole.cols == src.cols && srcWhole.rows == src.rows) \
                    { \
                        PointFilter<tex_resize_ ## type ## _reader> filteredSrc(texSrc); \
                        resize<<<grid, block>>>(filteredSrc, fx, fy, dst); \
                    } \
                    else \
                    { \
                        BrdReplicate< type > brd(src.rows, src.cols); \
                        BorderReader<tex_resize_ ## type ## _reader, BrdReplicate< type > > brdSrc(texSrc, brd); \
                        PointFilter< BorderReader<tex_resize_ ## type ## _reader, BrdReplicate< type > > > filteredSrc(brdSrc); \
                        resize<<<grid, block>>>(filteredSrc, fx, fy, dst); \
                    } \
                    cudaSafeCall( cudaGetLastError() ); \
                    cudaSafeCall( cudaDeviceSynchronize() ); \
                } \

                { \
                    const dim3 block(32, 8); \
                    const dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y)); \
                    if (srcWhole.data == src.data) \
                    { \
                        bindTexture(&tex_resize_ ## type, src); \
                        tex_resize_ ## type ## _reader texSrc; \
                        texSrc.xoff = 0; \
                        texSrc.yoff = 0; \
                        LinearFilter<tex_resize_ ## type ## _reader> filteredSrc(texSrc); \
                        resize<<<grid, block>>>(filteredSrc, fx, fy, dst); \
                    } \
                    else \
                    { \
                        bindTexture(&tex_resize_ ## type, srcWhole); \
                        tex_resize_ ## type ## _reader texSrc; \
                        texSrc.xoff = xoff; \
                        texSrc.yoff = yoff; \
                        BrdReplicate< type > brd(src.rows, src.cols); \
                        BorderReader<tex_resize_ ## type ## _reader, BrdReplicate< type > > brdSrc(texSrc, brd); \
                        LinearFilter< BorderReader<tex_resize_ ## type ## _reader, BrdReplicate< type > > > filteredSrc(brdSrc); \
