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
f4fb7fe1
Commit
f4fb7fe1
authored
Oct 01, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed compilation error "ambiguous symbol" on CUDA 5.0:
disabled Texture Reference API for old CUDA toolkits
parent
ada858e1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
1 deletion
+78
-1
texture.hpp
modules/cudev/include/opencv2/cudev/ptr2d/texture.hpp
+78
-1
No files found.
modules/cudev/include/opencv2/cudev/ptr2d/texture.hpp
View file @
f4fb7fe1
...
...
@@ -52,6 +52,8 @@
#include "gpumat.hpp"
#include "traits.hpp"
#if CUDART_VERSION >= 5050
namespace
{
template
<
typename
T
>
struct
CvCudevTextureRef
...
...
@@ -78,7 +80,7 @@ namespace
__host__
static
void
unbind
()
{
CV_CUDEV_SAFE_CALL
(
cudaUnbindTexture
(
ref
)
);
cudaUnbindTexture
(
ref
);
}
};
...
...
@@ -86,8 +88,12 @@ namespace
typename
CvCudevTextureRef
<
T
>::
TexRef
CvCudevTextureRef
<
T
>::
ref
;
}
#endif
namespace
cv
{
namespace
cudev
{
#if CUDART_VERSION >= 5050
template
<
typename
T
>
struct
TexturePtr
{
typedef
T
value_type
;
...
...
@@ -171,6 +177,77 @@ template <typename T> struct PtrTraits< Texture<T> > : PtrTraitsBase<Texture<T>,
{
};
#else
template
<
typename
T
>
struct
TexturePtr
{
typedef
T
value_type
;
typedef
float
index_type
;
cudaTextureObject_t
texObj
;
__device__
__forceinline__
T
operator
()(
float
y
,
float
x
)
const
{
#if CV_CUDEV_ARCH >= 300
// Use the texture object
return
tex2D
<
T
>
(
texObj
,
x
,
y
);
#else
(
void
)
y
;
(
void
)
x
;
return
T
();
#endif
}
};
template
<
typename
T
>
struct
Texture
:
TexturePtr
<
T
>
{
int
rows
,
cols
;
__host__
explicit
Texture
(
const
GlobPtrSz
<
T
>&
mat
,
bool
normalizedCoords
=
false
,
cudaTextureFilterMode
filterMode
=
cudaFilterModePoint
,
cudaTextureAddressMode
addressMode
=
cudaAddressModeClamp
)
{
CV_Assert
(
deviceSupports
(
FEATURE_SET_COMPUTE_30
)
);
rows
=
mat
.
rows
;
cols
=
mat
.
cols
;
// Use the texture object
cudaResourceDesc
texRes
;
std
::
memset
(
&
texRes
,
0
,
sizeof
(
texRes
));
texRes
.
resType
=
cudaResourceTypePitch2D
;
texRes
.
res
.
pitch2D
.
devPtr
=
mat
.
data
;
texRes
.
res
.
pitch2D
.
height
=
mat
.
rows
;
texRes
.
res
.
pitch2D
.
width
=
mat
.
cols
;
texRes
.
res
.
pitch2D
.
pitchInBytes
=
mat
.
step
;
texRes
.
res
.
pitch2D
.
desc
=
cudaCreateChannelDesc
<
T
>
();
cudaTextureDesc
texDescr
;
std
::
memset
(
&
texDescr
,
0
,
sizeof
(
texDescr
));
texDescr
.
normalizedCoords
=
normalizedCoords
;
texDescr
.
filterMode
=
filterMode
;
texDescr
.
addressMode
[
0
]
=
addressMode
;
texDescr
.
addressMode
[
1
]
=
addressMode
;
texDescr
.
addressMode
[
2
]
=
addressMode
;
texDescr
.
readMode
=
cudaReadModeElementType
;
CV_CUDEV_SAFE_CALL
(
cudaCreateTextureObject
(
&
this
->
texObj
,
&
texRes
,
&
texDescr
,
0
)
);
}
__host__
~
Texture
()
{
// Use the texture object
cudaDestroyTextureObject
(
this
->
texObj
);
}
};
template
<
typename
T
>
struct
PtrTraits
<
Texture
<
T
>
>
:
PtrTraitsBase
<
Texture
<
T
>
,
TexturePtr
<
T
>
>
{
};
#endif
}}
#endif
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