             int dy2 = __float2int_rn(ratio * src[k][3]);
 
             real_t t = 0;
-            t += tex2D(tex, x + dx1, y + dy1);
-            t -= tex2D(tex, x + dx1, y + dy2);
-            t -= tex2D(tex, x + dx2, y + dy1);
-            t += tex2D(tex, x + dx2, y + dy2);
+            t += tex2D(sumTex, x + dx1, y + dy1);
+            t -= tex2D(sumTex, x + dx1, y + dy2);
+            t -= tex2D(sumTex, x + dx2, y + dy1);
+            t += tex2D(sumTex, x + dx2, y + dy2);
 
             d += t * src[k][4] / ((dx2 - dx1) * (dy2 - dy1));
         }

        __shared__ float N9[3][3][3];
        __shared__ KeyPoint_GPU p;

         N9[threadIdx.z][threadIdx.y][threadIdx.x] = det.ptr(c_layer_rows * layer + i)[j];
        __syncthreads();

        if (threadIdx.x == 0 && threadIdx.y == 0 && threadIdx.z == 0)


                    if ((unsigned)y < (unsigned)((c_img_rows + 1) - grad_wav_size) && (unsigned)x < (unsigned)((c_img_cols + 1) - grad_wav_size))
                    {
                        X = c_aptW[tid] * icvCalcHaarPatternSum<2>(c_NX, 4, grad_wav_size, y, x);
                        Y = c_aptW[tid] * icvCalcHaarPatternSum<2>(c_NY, 4, grad_wav_size, y, x);
                    
                        angle = atan2f(Y, X);
                        if (angle < 0)
