Commit 8c39b4e8 authored by Alexander Karsakov's avatar Alexander Karsakov

Fixed stereoBM for Intel CPU.

parent 9e1124d2
......@@ -147,6 +147,7 @@ __kernel void stereoBM(__global const uchar * leftptr, __global const uchar * ri
__local int best_disp[2];
__local int best_cost[2];
best_cost[nthread] = MAX_VAL;
barrier(CLK_LOCAL_MEM_FENCE);
short costbuf[wsz];
int head = 0;
......@@ -159,7 +160,7 @@ __kernel void stereoBM(__global const uchar * leftptr, __global const uchar * ri
int costIdx = calcLocalIdx(lx, ly, d, sizeY);
cost = costFunc + costIdx;
short tempcost = 0;
int tempcost = 0;
if(x < cols-wsz2-mindisp && y < rows-wsz2)
{
int shift = 1*nthread + cols*(1-nthread);
......@@ -186,7 +187,11 @@ __kernel void stereoBM(__global const uchar * leftptr, __global const uchar * ri
if(nthread==1)
{
cost[0] = tempcost;
#ifndef CPU
atomic_min(best_cost+nthread, tempcost);
#else
*(best_cost+nthread) = min(*(best_cost+nthread), tempcost);
#endif
}
barrier(CLK_LOCAL_MEM_FENCE);
......@@ -223,7 +228,11 @@ __kernel void stereoBM(__global const uchar * leftptr, __global const uchar * ri
cost[0], cost[1], cost[-1], winsize);
}
cost[0] = tempcost;
#ifndef CPU
atomic_min(best_cost + nthread, tempcost);
#else
*(best_cost + nthread) = min(*(best_cost + nthread), tempcost);
#endif
barrier(CLK_LOCAL_MEM_FENCE);
if(best_cost[nthread] == tempcost)
......
......@@ -744,8 +744,9 @@ static bool ocl_stereobm( InputArray _left, InputArray _right,
int wsz2 = wsz/2;
int sizeX = std::max(11, 27 - ocl::Device::getDefault().maxComputeUnits() ), sizeY = sizeX-1, N = ndisp*2;
bool is_cpu = cv::ocl::Device::getDefault().type() == cv::ocl::Device::TYPE_CPU;
ocl::Kernel k("stereoBM", ocl::calib3d::stereobm_oclsrc, cv::format("-D csize=%d -D wsz=%d", (2*sizeY)*ndisp, wsz) );
ocl::Kernel k("stereoBM", ocl::calib3d::stereobm_oclsrc, cv::format("-D csize=%d -D wsz=%d%s", (2*sizeY)*ndisp, wsz, is_cpu ? " -D CPU" : ""));
if(k.empty())
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment