Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
3d394943
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 9 个月
通知
993
Star
71100
Fork
55581
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3d394943
编写于
5月 28, 2021
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core(ocl): avoid limit of Image kernel args
上级
212815a1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
1 deletion
+65
-1
modules/core/src/ocl.cpp
modules/core/src/ocl.cpp
+0
-1
modules/core/test/ocl/test_opencl.cpp
modules/core/test/ocl/test_opencl.cpp
+65
-0
未找到文件。
modules/core/src/ocl.cpp
浏览文件 @
3d394943
...
...
@@ -2806,7 +2806,6 @@ struct Kernel::Impl
void
registerImageArgument
(
int
arg
,
const
Image2D
&
image
)
{
CV_CheckGE
(
arg
,
0
,
""
);
CV_CheckLT
(
arg
,
(
int
)
MAX_ARRS
,
""
);
if
(
arg
<
(
int
)
shadow_images
.
size
()
&&
shadow_images
[
arg
].
ptr
()
!=
image
.
ptr
())
// TODO future: replace ptr => impl (more strong check)
{
CV_Check
(
arg
,
!
isInProgress
,
"ocl::Kernel: clearing of pending Image2D arguments is not allowed"
);
...
...
modules/core/test/ocl/test_opencl.cpp
浏览文件 @
3d394943
...
...
@@ -127,4 +127,69 @@ TEST(OpenCL, support_SPIR_programs)
testOpenCLKernel
(
k
);
}
TEST
(
OpenCL
,
image2Dcount_regression_19334
)
{
cv
::
ocl
::
Context
ctx
=
cv
::
ocl
::
Context
::
getDefault
();
if
(
!
ctx
.
ptr
())
{
throw
cvtest
::
SkipTestException
(
"OpenCL is not available"
);
}
cv
::
ocl
::
Device
device
=
cv
::
ocl
::
Device
::
getDefault
();
if
(
!
device
.
compilerAvailable
())
{
throw
cvtest
::
SkipTestException
(
"OpenCL compiler is not available"
);
}
std
::
string
module_name
;
// empty to disable OpenCL cache
static
const
char
*
opencl_kernel_src
=
"__kernel void test_kernel(int a,
\n
"
" __global const uchar* src0, int src0_step, int src0_offset, int src0_rows, int src0_cols,
\n
"
" __global const uchar* src1, int src1_step, int src1_offset, int src1_rows, int src1_cols,
\n
"
" __global const uchar* src2, int src2_step, int src2_offset, int src2_rows, int src2_cols,
\n
"
" __read_only image2d_t image)
\n
"
"{
\n
"
"}"
;
cv
::
ocl
::
ProgramSource
src
(
module_name
,
"test_opencl_image_arg"
,
opencl_kernel_src
,
""
);
cv
::
String
errmsg
;
cv
::
ocl
::
Program
program
(
src
,
""
,
errmsg
);
ASSERT_TRUE
(
program
.
ptr
()
!=
NULL
);
cv
::
ocl
::
Kernel
k
(
"test_kernel"
,
program
);
ASSERT_FALSE
(
k
.
empty
());
std
::
vector
<
UMat
>
images
(
4
);
for
(
size_t
i
=
0
;
i
<
images
.
size
();
++
i
)
images
[
i
]
=
UMat
(
10
,
10
,
CV_8UC1
);
cv
::
ocl
::
Image2D
image
;
try
{
cv
::
ocl
::
Image2D
image_
(
images
.
back
());
image
=
image_
;
}
catch
(
const
cv
::
Exception
&
)
{
throw
cvtest
::
SkipTestException
(
"OpenCL images are not supported"
);
}
int
nargs
=
0
;
int
a
=
0
;
nargs
=
k
.
set
(
nargs
,
a
);
ASSERT_EQ
(
1
,
nargs
);
nargs
=
k
.
set
(
nargs
,
images
[
0
]);
ASSERT_EQ
(
6
,
nargs
);
nargs
=
k
.
set
(
nargs
,
images
[
1
]);
ASSERT_EQ
(
11
,
nargs
);
nargs
=
k
.
set
(
nargs
,
images
[
2
]);
ASSERT_EQ
(
16
,
nargs
);
// do not throw (issue of #19334)
ASSERT_NO_THROW
(
nargs
=
k
.
set
(
nargs
,
image
));
ASSERT_EQ
(
17
,
nargs
);
// allow to replace image argument if kernel is not running
UMat
image2
(
10
,
10
,
CV_8UC1
);
ASSERT_NO_THROW
(
nargs
=
k
.
set
(
16
,
cv
::
ocl
::
Image2D
(
image2
)));
ASSERT_EQ
(
17
,
nargs
);
}
}}
// namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录