Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
68f8d1ce
Commit
68f8d1ce
authored
Aug 13, 2015
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5164 from vladimir-dudnik:test-umat-copyTo-issue
parents
53a92983
6bb8afde
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
15 deletions
+80
-15
ocl.cpp
modules/core/src/ocl.cpp
+79
-14
test_umat.cpp
modules/core/test/test_umat.cpp
+1
-1
No files found.
modules/core/src/ocl.cpp
View file @
68f8d1ce
...
@@ -4197,6 +4197,61 @@ private:
...
@@ -4197,6 +4197,61 @@ private:
AlignedDataPtr
(
const
AlignedDataPtr
&
);
// disabled
AlignedDataPtr
(
const
AlignedDataPtr
&
);
// disabled
AlignedDataPtr
&
operator
=
(
const
AlignedDataPtr
&
);
// disabled
AlignedDataPtr
&
operator
=
(
const
AlignedDataPtr
&
);
// disabled
};
};
template
<
bool
readAccess
,
bool
writeAccess
>
class
AlignedDataPtr2D
{
protected
:
const
size_t
size_
;
uchar
*
const
originPtr_
;
const
size_t
alignment_
;
uchar
*
ptr_
;
uchar
*
allocatedPtr_
;
size_t
rows_
;
size_t
cols_
;
size_t
step_
;
public
:
AlignedDataPtr2D
(
uchar
*
ptr
,
size_t
rows
,
size_t
cols
,
size_t
step
,
size_t
alignment
)
:
size_
(
rows
*
step
),
originPtr_
(
ptr
),
alignment_
(
alignment
),
ptr_
(
ptr
),
allocatedPtr_
(
NULL
),
rows_
(
rows
),
cols_
(
cols
),
step_
(
step
)
{
CV_DbgAssert
((
alignment
&
(
alignment
-
1
))
==
0
);
// check for 2^n
if
(((
size_t
)
ptr_
&
(
alignment
-
1
))
!=
0
)
{
allocatedPtr_
=
new
uchar
[
size_
+
alignment
-
1
];
ptr_
=
(
uchar
*
)(((
uintptr_t
)
allocatedPtr_
+
(
alignment
-
1
))
&
~
(
alignment
-
1
));
if
(
readAccess
)
{
for
(
size_t
i
=
0
;
i
<
rows_
;
i
++
)
memcpy
(
ptr_
+
i
*
step_
,
originPtr_
+
i
*
step_
,
cols_
);
}
}
}
uchar
*
getAlignedPtr
()
const
{
CV_DbgAssert
(((
size_t
)
ptr_
&
(
alignment_
-
1
))
==
0
);
return
ptr_
;
}
~
AlignedDataPtr2D
()
{
if
(
allocatedPtr_
)
{
if
(
writeAccess
)
{
for
(
size_t
i
=
0
;
i
<
rows_
;
i
++
)
memcpy
(
originPtr_
+
i
*
step_
,
ptr_
+
i
*
step_
,
cols_
);
}
delete
[]
allocatedPtr_
;
allocatedPtr_
=
NULL
;
}
ptr_
=
NULL
;
}
private
:
AlignedDataPtr2D
(
const
AlignedDataPtr2D
&
);
// disabled
AlignedDataPtr2D
&
operator
=
(
const
AlignedDataPtr2D
&
);
// disabled
};
#if defined _MSC_VER
#if defined _MSC_VER
#pragma warning(default:4127) // conditional expression is constant
#pragma warning(default:4127) // conditional expression is constant
#endif
#endif
...
@@ -4930,17 +4985,22 @@ public:
...
@@ -4930,17 +4985,22 @@ public:
else
else
#endif
#endif
{
{
AlignedDataPtr
<
false
,
true
>
alignedPtr
((
uchar
*
)
dstptr
,
sz
[
0
]
*
dststep
[
0
],
CV_OPENCL_DATA_PTR_ALIGNMENT
);
if
(
iscontinuous
)
if
(
iscontinuous
)
{
{
CV_Assert
(
clEnqueueReadBuffer
(
q
,
(
cl_mem
)
u
->
handle
,
CL_TRUE
,
AlignedDataPtr
<
false
,
true
>
alignedPtr
((
uchar
*
)
dstptr
,
total
,
CV_OPENCL_DATA_PTR_ALIGNMENT
);
srcrawofs
,
total
,
alignedPtr
.
getAlignedPtr
(),
0
,
0
,
0
)
>=
0
);
CV_Assert
(
clEnqueueReadBuffer
(
q
,
(
cl_mem
)
u
->
handle
,
CL_TRUE
,
srcrawofs
,
total
,
alignedPtr
.
getAlignedPtr
(),
0
,
0
,
0
)
>=
0
);
}
}
else
else
{
{
AlignedDataPtr2D
<
false
,
true
>
alignedPtr
((
uchar
*
)
dstptr
,
new_sz
[
1
],
new_sz
[
0
],
new_dststep
[
0
],
CV_OPENCL_DATA_PTR_ALIGNMENT
);
uchar
*
ptr
=
alignedPtr
.
getAlignedPtr
();
CV_Assert
(
clEnqueueReadBufferRect
(
q
,
(
cl_mem
)
u
->
handle
,
CL_TRUE
,
CV_Assert
(
clEnqueueReadBufferRect
(
q
,
(
cl_mem
)
u
->
handle
,
CL_TRUE
,
new_srcofs
,
new_dstofs
,
new_sz
,
new_srcstep
[
0
],
new_srcstep
[
1
],
new_srcofs
,
new_dstofs
,
new_sz
,
new_dststep
[
0
],
new_dststep
[
1
],
alignedPtr
.
getAlignedPtr
(),
0
,
0
,
0
)
>=
0
);
new_srcstep
[
0
],
0
,
new_dststep
[
0
],
0
,
ptr
,
0
,
0
,
0
)
>=
0
);
}
}
}
}
}
}
...
@@ -5042,17 +5102,22 @@ public:
...
@@ -5042,17 +5102,22 @@ public:
else
else
#endif
#endif
{
{
AlignedDataPtr
<
true
,
false
>
alignedPtr
((
uchar
*
)
srcptr
,
sz
[
0
]
*
srcstep
[
0
],
CV_OPENCL_DATA_PTR_ALIGNMENT
);
if
(
iscontinuous
)
if
(
iscontinuous
)
{
{
CV_Assert
(
clEnqueueWriteBuffer
(
q
,
(
cl_mem
)
u
->
handle
,
AlignedDataPtr
<
true
,
false
>
alignedPtr
((
uchar
*
)
srcptr
,
total
,
CV_OPENCL_DATA_PTR_ALIGNMENT
);
CL_TRUE
,
dstrawofs
,
total
,
alignedPtr
.
getAlignedPtr
(),
0
,
0
,
0
)
>=
0
);
CV_Assert
(
clEnqueueWriteBuffer
(
q
,
(
cl_mem
)
u
->
handle
,
CL_TRUE
,
dstrawofs
,
total
,
alignedPtr
.
getAlignedPtr
(),
0
,
0
,
0
)
>=
0
);
}
}
else
else
{
{
CV_Assert
(
clEnqueueWriteBufferRect
(
q
,
(
cl_mem
)
u
->
handle
,
CL_TRUE
,
AlignedDataPtr2D
<
true
,
false
>
alignedPtr
((
uchar
*
)
srcptr
,
new_sz
[
1
],
new_sz
[
0
],
new_srcstep
[
0
],
CV_OPENCL_DATA_PTR_ALIGNMENT
);
new_dstofs
,
new_srcofs
,
new_sz
,
new_dststep
[
0
],
new_dststep
[
1
],
uchar
*
ptr
=
alignedPtr
.
getAlignedPtr
();
new_srcstep
[
0
],
new_srcstep
[
1
],
alignedPtr
.
getAlignedPtr
(),
0
,
0
,
0
)
>=
0
);
CV_Assert
(
clEnqueueWriteBufferRect
(
q
,
(
cl_mem
)
u
->
handle
,
CL_TRUE
,
new_dstofs
,
new_srcofs
,
new_sz
,
new_dststep
[
0
],
0
,
new_srcstep
[
0
],
0
,
ptr
,
0
,
0
,
0
)
>=
0
);
}
}
}
}
u
->
markHostCopyObsolete
(
true
);
u
->
markHostCopyObsolete
(
true
);
...
@@ -5199,8 +5264,8 @@ public:
...
@@ -5199,8 +5264,8 @@ public:
{
{
CV_Assert
(
(
retval
=
clEnqueueCopyBufferRect
(
q
,
(
cl_mem
)
src
->
handle
,
(
cl_mem
)
dst
->
handle
,
CV_Assert
(
(
retval
=
clEnqueueCopyBufferRect
(
q
,
(
cl_mem
)
src
->
handle
,
(
cl_mem
)
dst
->
handle
,
new_srcofs
,
new_dstofs
,
new_sz
,
new_srcofs
,
new_dstofs
,
new_sz
,
new_srcstep
[
0
],
new_srcstep
[
1
]
,
new_srcstep
[
0
],
0
,
new_dststep
[
0
],
new_dststep
[
1
]
,
new_dststep
[
0
],
0
,
0
,
0
,
0
))
==
CL_SUCCESS
);
0
,
0
,
0
))
==
CL_SUCCESS
);
}
}
}
}
...
@@ -5211,7 +5276,7 @@ public:
...
@@ -5211,7 +5276,7 @@ public:
#ifdef HAVE_OPENCL_SVM
#ifdef HAVE_OPENCL_SVM
if
((
dst
->
allocatorFlags_
&
svm
::
OPENCL_SVM_BUFFER_MASK
)
==
svm
::
OPENCL_SVM_FINE_GRAIN_BUFFER
||
if
((
dst
->
allocatorFlags_
&
svm
::
OPENCL_SVM_BUFFER_MASK
)
==
svm
::
OPENCL_SVM_FINE_GRAIN_BUFFER
||
(
dst
->
allocatorFlags_
&
svm
::
OPENCL_SVM_BUFFER_MASK
)
==
svm
::
OPENCL_SVM_FINE_GRAIN_SYSTEM
)
(
dst
->
allocatorFlags_
&
svm
::
OPENCL_SVM_BUFFER_MASK
)
==
svm
::
OPENCL_SVM_FINE_GRAIN_SYSTEM
)
{
{
// nothing
// nothing
}
}
...
...
modules/core/test/test_umat.cpp
View file @
68f8d1ce
...
@@ -173,7 +173,7 @@ TEST_P(UMatBasicTests, base)
...
@@ -173,7 +173,7 @@ TEST_P(UMatBasicTests, base)
ASSERT_EQ
(
ub
.
total
(),
total
);
ASSERT_EQ
(
ub
.
total
(),
total
);
}
}
TEST_P
(
UMatBasicTests
,
DISABLED_
copyTo
)
TEST_P
(
UMatBasicTests
,
copyTo
)
{
{
int
i
;
int
i
;
if
(
useRoi
)
if
(
useRoi
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment