Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Philippe Normand
gst-plugins-bad
Commits
c75907d2
Commit
c75907d2
authored
Nov 22, 2018
by
Seungha Yang
🐑
Committed by
Tim-Philipp Müller
Nov 25, 2018
Browse files
nvenc: Fix undefined reference build error on MSVC and CUDA 9.1
parent
3cd1d0c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
sys/nvenc/gstnvbaseenc.c
View file @
c75907d2
...
...
@@ -33,6 +33,7 @@
#include
<cuda.h>
#include
<cuda_runtime_api.h>
#include
<cuda_gl_interop.h>
#include
<cudaGL.h>
#include
<gst/gl/gl.h>
#endif
...
...
@@ -171,8 +172,8 @@ G_LOCK_DEFINE_STATIC (initialization_lock);
struct
gl_input_resource
{
GstGLMemory
*
gl_mem
[
GST_VIDEO_MAX_PLANES
];
struct
cudaG
raphicsResource
*
cuda_texture
;
gpointe
r
cuda_plane_pointers
[
GST_VIDEO_MAX_PLANES
];
CUg
raphicsResource
cuda_texture
;
CUdevicept
r
cuda_plane_pointers
[
GST_VIDEO_MAX_PLANES
];
gpointer
cuda_pointer
;
gsize
cuda_stride
;
gsize
cuda_num_bytes
;
...
...
@@ -1453,6 +1454,7 @@ _map_gl_input_buffer (GstGLContext * context, struct map_gl_input *data)
cudaError_t
cuda_ret
;
guint8
*
data_pointer
;
guint
i
;
CUDA_MEMCPY2D
param
;
cuCtxPushCurrent
(
data
->
nvenc
->
cuda_ctx
);
data_pointer
=
data
->
in_gl_resource
->
cuda_pointer
;
...
...
@@ -1480,7 +1482,7 @@ _map_gl_input_buffer (GstGLContext * context, struct map_gl_input *data)
gl_mem
->
mem
.
tex_id
);
cuda_ret
=
cu
da
GraphicsGLRegisterBuffer
(
&
data
->
in_gl_resource
->
cuda_texture
,
cuGraphicsGLRegisterBuffer
(
&
data
->
in_gl_resource
->
cuda_texture
,
gl_buf_obj
->
id
,
cudaGraphicsRegisterFlagsReadOnly
);
if
(
cuda_ret
!=
cudaSuccess
)
{
GST_ERROR_OBJECT
(
data
->
nvenc
,
"failed to register GL texture %u to cuda "
...
...
@@ -1489,7 +1491,7 @@ _map_gl_input_buffer (GstGLContext * context, struct map_gl_input *data)
}
cuda_ret
=
cu
da
GraphicsMapResources
(
1
,
&
data
->
in_gl_resource
->
cuda_texture
,
0
);
cuGraphicsMapResources
(
1
,
&
data
->
in_gl_resource
->
cuda_texture
,
0
);
if
(
cuda_ret
!=
cudaSuccess
)
{
GST_ERROR_OBJECT
(
data
->
nvenc
,
"failed to map GL texture %u into cuda "
"ret :%d"
,
gl_mem
->
mem
.
tex_id
,
cuda_ret
);
...
...
@@ -1497,7 +1499,7 @@ _map_gl_input_buffer (GstGLContext * context, struct map_gl_input *data)
}
cuda_ret
=
cu
da
GraphicsResourceGetMappedPointer
(
&
data
->
in_gl_resource
->
cuGraphicsResourceGetMappedPointer
(
&
data
->
in_gl_resource
->
cuda_plane_pointers
[
i
],
&
data
->
in_gl_resource
->
cuda_num_bytes
,
data
->
in_gl_resource
->
cuda_texture
);
if
(
cuda_ret
!=
cudaSuccess
)
{
...
...
@@ -1510,11 +1512,21 @@ _map_gl_input_buffer (GstGLContext * context, struct map_gl_input *data)
dest_stride
=
data
->
in_gl_resource
->
cuda_stride
;
/* copy into scratch buffer */
cuda_ret
=
cudaMemcpy2D
(
data_pointer
,
dest_stride
,
data
->
in_gl_resource
->
cuda_plane_pointers
[
i
],
src_stride
,
_get_plane_width
(
data
->
info
,
i
)
*
plane_n_components
,
_get_plane_height
(
data
->
info
,
i
),
cudaMemcpyDeviceToDevice
);
param
.
srcXInBytes
=
0
;
param
.
srcY
=
0
;
param
.
srcMemoryType
=
CU_MEMORYTYPE_DEVICE
;
param
.
srcDevice
=
data
->
in_gl_resource
->
cuda_plane_pointers
[
i
];
param
.
srcPitch
=
src_stride
;
param
.
dstXInBytes
=
0
;
param
.
dstY
=
0
;
param
.
dstMemoryType
=
CU_MEMORYTYPE_DEVICE
;
param
.
dstDevice
=
(
CUdeviceptr
)
data_pointer
;
param
.
dstPitch
=
dest_stride
;
param
.
WidthInBytes
=
_get_plane_width
(
data
->
info
,
i
)
*
plane_n_components
;
param
.
Height
=
_get_plane_height
(
data
->
info
,
i
);
cuda_ret
=
cuMemcpy2D
(
&
param
);
if
(
cuda_ret
!=
cudaSuccess
)
{
GST_ERROR_OBJECT
(
data
->
nvenc
,
"failed to copy GL texture %u into cuda "
"ret :%d"
,
gl_mem
->
mem
.
tex_id
,
cuda_ret
);
...
...
@@ -1522,7 +1534,7 @@ _map_gl_input_buffer (GstGLContext * context, struct map_gl_input *data)
}
cuda_ret
=
cu
da
GraphicsUnmapResources
(
1
,
&
data
->
in_gl_resource
->
cuda_texture
,
0
);
cuGraphicsUnmapResources
(
1
,
&
data
->
in_gl_resource
->
cuda_texture
,
0
);
if
(
cuda_ret
!=
cudaSuccess
)
{
GST_ERROR_OBJECT
(
data
->
nvenc
,
"failed to unmap GL texture %u from cuda "
"ret :%d"
,
gl_mem
->
mem
.
tex_id
,
cuda_ret
);
...
...
@@ -1530,7 +1542,7 @@ _map_gl_input_buffer (GstGLContext * context, struct map_gl_input *data)
}
cuda_ret
=
cu
da
GraphicsUnregisterResource
(
data
->
in_gl_resource
->
cuda_texture
);
cuGraphicsUnregisterResource
(
data
->
in_gl_resource
->
cuda_texture
);
if
(
cuda_ret
!=
cudaSuccess
)
{
GST_ERROR_OBJECT
(
data
->
nvenc
,
"failed to unregister GL texture %u from "
"cuda ret :%d"
,
gl_mem
->
mem
.
tex_id
,
cuda_ret
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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