2019-01-30 11:07:29 +00:00
|
|
|
d3d11_sources = [
|
2019-11-06 10:38:31 +00:00
|
|
|
'gstd3d11basefilter.c',
|
2019-08-18 12:01:55 +00:00
|
|
|
'gstd3d11colorconvert.c',
|
2019-12-03 11:35:06 +00:00
|
|
|
'gstd3d11colorconverter.c',
|
2020-06-02 16:26:12 +00:00
|
|
|
'gstd3d11compositor.c',
|
|
|
|
'gstd3d11compositorbin.c',
|
2020-12-20 17:47:45 +00:00
|
|
|
'gstd3d11download.c',
|
|
|
|
'gstd3d11overlaycompositor.c',
|
|
|
|
'gstd3d11pluginutils.c',
|
|
|
|
'gstd3d11shader.c',
|
|
|
|
'gstd3d11upload.c',
|
|
|
|
'gstd3d11videoprocessor.c',
|
|
|
|
'gstd3d11videosink.c',
|
|
|
|
'gstd3d11videosinkbin.c',
|
|
|
|
'gstd3d11window.cpp',
|
d3d11videosink: Add support for drawing on application's own texture
Add a way to support drawing on application's texture instead of
usual window handle.
To make use of this new feature, application should follow below step.
1) Enable this feature by using "draw-on-shared-texture" property
2) Watch "begin-draw" signal
3) On "begin-draw" signal handler, application can request drawing
by using "draw" signal action. Note that "draw" signal action
should be happen before "begin-draw" signal handler is returned
NOTE 1) For texture sharing, creating a texture with
D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX flag is strongly recommend
if possible because we cannot ensure sync a texture
which was created with D3D11_RESOURCE_MISC_SHARED
and it would cause glitch with ID3D11VideoProcessor use case.
NOTE 2) Direct9Ex doesn't support texture sharing which was
created with D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX. In other words,
D3D11_RESOURCE_MISC_SHARED is the only option for Direct3D11/Direct9Ex interop.
NOTE 3) Because of missing synchronization around ID3D11VideoProcessor,
If shared texture was created with D3D11_RESOURCE_MISC_SHARED,
d3d11videosink might use fallback texture to convert DXVA texture
to normal Direct3D texture. Then converted texture will be
copied to user-provided shared texture.
* Why not use generic appsink approach?
In order for application to be able to store video data
which was produced by GStreamer in application's own texture,
there would be two possible approaches,
one is copying our texture into application's own texture,
and the other is drawing on application's own texture directly.
The former (appsink way) cannot be a zero-copy by nature.
In order to support zero-copy processing, we need to draw on
application's own texture directly.
For example, assume that application wants RGBA texture.
Then we can imagine following case.
"d3d11h264dec ! d3d11convert ! video/x-raw(memory:D3D11Memory),format=RGBA ! appsink"
^
|_ allocate new Direct3D texture for RGBA format
In above case, d3d11convert will allocate new texture(s) for RGBA format
and then application will copy again the our RGBA texutre into
application's own texture. One texture allocation plus per frame GPU copy will hanppen
in that case therefore.
Moreover, in order for application to be able to access
our texture, we need to allocate texture with additional flags for
application's Direct3D11 device to be able to read texture data.
That would be another implementation burden on our side
But with this MR, we can configure pipeline in this way
"d3d11h264dec ! d3d11videosink".
In that way, we can save at least one texture allocation and
per frame texutre copy since d3d11videosink will convert incoming texture
into application's texture format directly without copy.
* What if we expose texture without conversion and application does
conversion by itself?
As mentioned above, for application to be able to access our texture
from application's Direct3D11 device, we need to allocate texture
in a special form. But in some case, that might not be possible.
Also, if a texture belongs to decoder DPB, exposing such texture
to application is unsafe and usual Direct3D11 shader cannot handle
such texture. To convert format, ID3D11VideoProcessor API needs to
be used but that would be a implementation burden for application.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1873>
2020-12-23 14:49:12 +00:00
|
|
|
'gstd3d11window_dummy.cpp',
|
2020-12-20 17:47:45 +00:00
|
|
|
'plugin.c',
|
2019-01-30 11:07:29 +00:00
|
|
|
]
|
|
|
|
|
2019-12-26 05:24:46 +00:00
|
|
|
d3d11_dec_sources = [
|
|
|
|
'gstd3d11decoder.c',
|
|
|
|
'gstd3d11h264dec.c',
|
2019-12-20 14:05:52 +00:00
|
|
|
'gstd3d11vp9dec.c',
|
2019-12-26 05:28:03 +00:00
|
|
|
'gstd3d11h265dec.c',
|
2021-01-10 16:06:24 +00:00
|
|
|
'gstd3d11mpeg2dec.c',
|
2020-02-28 09:14:51 +00:00
|
|
|
'gstd3d11vp8dec.c',
|
2019-12-26 05:24:46 +00:00
|
|
|
]
|
|
|
|
|
2020-12-20 17:47:45 +00:00
|
|
|
extra_c_args = ['-DCOBJMACROS', '-DGST_USE_UNSTABLE_API']
|
|
|
|
extra_cpp_args = ['-DGST_USE_UNSTABLE_API']
|
2019-01-30 11:07:29 +00:00
|
|
|
extra_dep = []
|
|
|
|
|
|
|
|
d3d11_option = get_option('d3d11')
|
|
|
|
if host_system != 'windows' or d3d11_option.disabled()
|
|
|
|
subdir_done()
|
|
|
|
endif
|
|
|
|
|
2020-12-20 17:47:45 +00:00
|
|
|
if not gstd3d11_dep.found()
|
|
|
|
if d3d11_option.enabled()
|
|
|
|
error('The d3d11 was enabled explicitly, but required dependencies were not found.')
|
2019-12-18 04:21:31 +00:00
|
|
|
endif
|
2020-12-20 17:47:45 +00:00
|
|
|
subdir_done()
|
|
|
|
endif
|
2019-12-18 04:21:31 +00:00
|
|
|
|
2020-12-20 17:47:45 +00:00
|
|
|
d3dcompiler_lib = cc.find_library('d3dcompiler', required: d3d11_option)
|
|
|
|
runtimeobject_lib = cc.find_library('runtimeobject', required : false)
|
2020-01-10 14:54:43 +00:00
|
|
|
|
2020-12-20 17:47:45 +00:00
|
|
|
have_d3d11 = cc.has_header('d3dcompiler.h')
|
2019-01-30 11:07:29 +00:00
|
|
|
if not have_d3d11
|
|
|
|
if d3d11_option.enabled()
|
|
|
|
error('The d3d11 plugin was enabled explicitly, but required dependencies were not found.')
|
|
|
|
endif
|
|
|
|
subdir_done()
|
|
|
|
endif
|
|
|
|
|
2019-12-26 05:24:46 +00:00
|
|
|
# d3d11 video api uses dxva structure for decoding, and dxva.h needs d3d9 types
|
|
|
|
if cc.has_header('dxva.h') and cc.has_header('d3d9.h')
|
|
|
|
d3d11_sources += d3d11_dec_sources
|
2020-12-20 17:47:45 +00:00
|
|
|
extra_c_args += ['-DHAVE_DXVA_H']
|
2020-01-31 22:54:57 +00:00
|
|
|
extra_dep += [gstcodecs_dep]
|
2019-12-26 05:24:46 +00:00
|
|
|
endif
|
|
|
|
|
2020-12-20 17:47:45 +00:00
|
|
|
if d3d11_winapi_only_app and (not d3dcompiler_lib.found() or not runtimeobject_lib.found())
|
|
|
|
if d3d11_option.enabled()
|
|
|
|
error('The d3d11 plugin was enabled explicitly, but required dependencies were not found.')
|
|
|
|
endif
|
|
|
|
subdir_done()
|
2019-12-30 09:58:59 +00:00
|
|
|
endif
|
|
|
|
|
2021-01-18 10:17:14 +00:00
|
|
|
# if build target is Windows 10 and WINAPI_PARTITION_APP is allowed,
|
|
|
|
# we can build UWP only modules as well
|
|
|
|
if d3d11_winapi_app
|
2019-12-30 09:58:59 +00:00
|
|
|
d3d11_sources += ['gstd3d11window_corewindow.cpp',
|
|
|
|
'gstd3d11window_swapchainpanel.cpp']
|
2020-06-19 12:24:59 +00:00
|
|
|
extra_dep += [runtimeobject_lib, d3dcompiler_lib]
|
2021-01-18 10:17:14 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
if d3d11_winapi_desktop
|
2019-12-30 09:58:59 +00:00
|
|
|
d3d11_sources += ['gstd3d11window_win32.cpp']
|
2020-12-20 17:47:45 +00:00
|
|
|
if d3d11_conf.get('GST_D3D11_DXGI_HEADER_VERSION') >= 6
|
2020-11-20 18:20:36 +00:00
|
|
|
# Desktop Duplication API is unavailable for UWP
|
|
|
|
# and MinGW is not supported due to some missing headers
|
2020-12-20 17:47:45 +00:00
|
|
|
extra_c_args += ['-DHAVE_DXGI_DESKTOP_DUP']
|
2020-11-20 18:20:36 +00:00
|
|
|
d3d11_sources += ['gstd3d11desktopdup.cpp', 'gstd3d11desktopdupsrc.c']
|
|
|
|
message('Enable D3D11 Desktop Duplication API')
|
|
|
|
endif
|
2019-12-30 09:58:59 +00:00
|
|
|
endif
|
|
|
|
|
2020-11-20 18:20:36 +00:00
|
|
|
# MinGW 32bits compiler seems to be complaining about redundant-decls
|
|
|
|
# when ComPtr is in use. Let's just disable the warning
|
|
|
|
if cc.get_id() != 'msvc'
|
|
|
|
extra_args = cc.get_supported_arguments([
|
|
|
|
'-Wno-redundant-decls',
|
|
|
|
])
|
|
|
|
|
|
|
|
extra_c_args += extra_args
|
|
|
|
extra_cpp_args += extra_args
|
|
|
|
endif
|
|
|
|
|
2019-01-30 11:07:29 +00:00
|
|
|
gstd3d11 = library('gstd3d11',
|
|
|
|
d3d11_sources,
|
|
|
|
c_args : gst_plugins_bad_args + extra_c_args,
|
2020-11-20 18:20:36 +00:00
|
|
|
cpp_args: gst_plugins_bad_args + extra_cpp_args,
|
2019-01-30 11:07:29 +00:00
|
|
|
include_directories : [configinc],
|
2020-12-20 17:47:45 +00:00
|
|
|
dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, gstcontroller_dep, gstd3d11_dep] + extra_dep,
|
2019-01-30 11:07:29 +00:00
|
|
|
install : true,
|
|
|
|
install_dir : plugins_install_dir,
|
|
|
|
)
|
|
|
|
pkgconfig.generate(gstd3d11, install_dir : plugins_pkgconfig_install_dir)
|
|
|
|
plugins += [gstd3d11]
|