mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 22:00:25 +08:00
Merge pull request #2492 from KonstantinMatskevich:ocl_fix_wrongdevice
This commit is contained in:
commit
87ae0f9990
@ -1410,7 +1410,7 @@ bool useOpenCL()
|
||||
{
|
||||
CoreTLSData* data = coreTlsData.get();
|
||||
if( data->useOpenCL < 0 )
|
||||
data->useOpenCL = (int)haveOpenCL();
|
||||
data->useOpenCL = (int)haveOpenCL() && Device::getDefault().ptr() != NULL;
|
||||
return data->useOpenCL > 0;
|
||||
}
|
||||
|
||||
@ -1419,7 +1419,7 @@ void setUseOpenCL(bool flag)
|
||||
if( haveOpenCL() )
|
||||
{
|
||||
CoreTLSData* data = coreTlsData.get();
|
||||
data->useOpenCL = flag ? 1 : 0;
|
||||
data->useOpenCL = (flag && Device::getDefault().ptr() != NULL) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2245,6 +2245,7 @@ not_found:
|
||||
std::cerr << deviceTypes[t] << " ";
|
||||
|
||||
std::cerr << std::endl << " Device name: " << (deviceName.length() == 0 ? "any" : deviceName) << std::endl;
|
||||
CV_Error(CL_INVALID_DEVICE, "Requested OpenCL device is not found");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ void UMatData::unlock()
|
||||
|
||||
MatAllocator* UMat::getStdAllocator()
|
||||
{
|
||||
if( ocl::haveOpenCL() )
|
||||
if( ocl::haveOpenCL() && ocl::useOpenCL() )
|
||||
return ocl::getOpenCLAllocator();
|
||||
return Mat::getStdAllocator();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user