2019-01-30 11:07:29 +00:00
|
|
|
d3d11_sources = [
|
2022-02-10 13:31:06 +00:00
|
|
|
'gstd3d11av1dec.cpp',
|
2021-03-13 08:40:57 +00:00
|
|
|
'gstd3d11basefilter.cpp',
|
|
|
|
'gstd3d11compositor.cpp',
|
2022-02-10 13:31:06 +00:00
|
|
|
'gstd3d11convert.cpp',
|
|
|
|
'gstd3d11decoder.cpp',
|
|
|
|
'gstd3d11deinterlace.cpp',
|
2021-03-13 08:40:57 +00:00
|
|
|
'gstd3d11download.cpp',
|
2022-02-10 13:31:06 +00:00
|
|
|
'gstd3d11h264dec.cpp',
|
|
|
|
'gstd3d11h265dec.cpp',
|
2023-04-30 11:42:56 +00:00
|
|
|
'gstd3d11ipc.cpp',
|
|
|
|
'gstd3d11ipcclient.cpp',
|
|
|
|
'gstd3d11ipcserver.cpp',
|
|
|
|
'gstd3d11ipcsink.cpp',
|
|
|
|
'gstd3d11ipcsrc.cpp',
|
2022-02-10 13:31:06 +00:00
|
|
|
'gstd3d11mpeg2dec.cpp',
|
2023-04-13 17:10:35 +00:00
|
|
|
'gstd3d11overlay.cpp',
|
2021-03-13 08:40:57 +00:00
|
|
|
'gstd3d11overlaycompositor.cpp',
|
|
|
|
'gstd3d11pluginutils.cpp',
|
2022-06-04 13:33:34 +00:00
|
|
|
'gstd3d11testsrc.cpp',
|
2021-03-13 08:40:57 +00:00
|
|
|
'gstd3d11upload.cpp',
|
|
|
|
'gstd3d11videosink.cpp',
|
2022-02-10 13:31:06 +00:00
|
|
|
'gstd3d11vp8dec.cpp',
|
|
|
|
'gstd3d11vp9dec.cpp',
|
2020-12-20 17:47:45 +00:00
|
|
|
'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',
|
2021-09-10 15:43:26 +00:00
|
|
|
'plugin.cpp',
|
2019-01-30 11:07:29 +00:00
|
|
|
]
|
|
|
|
|
2021-09-10 15:43:26 +00:00
|
|
|
extra_c_args = ['-DCOBJMACROS']
|
|
|
|
extra_args = ['-DGST_USE_UNSTABLE_API']
|
2019-01-30 11:07:29 +00:00
|
|
|
extra_dep = []
|
|
|
|
|
|
|
|
d3d11_option = get_option('d3d11')
|
2023-06-27 18:41:26 +00:00
|
|
|
d3d11_wgc_option = get_option('d3d11-wgc')
|
2019-01-30 11:07:29 +00:00
|
|
|
if host_system != 'windows' or d3d11_option.disabled()
|
|
|
|
subdir_done()
|
|
|
|
endif
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
if not gstd3d11_dep.found() or not gstdxva_dep.found()
|
2020-12-20 17:47:45 +00:00
|
|
|
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
|
|
|
runtimeobject_lib = cc.find_library('runtimeobject', required : false)
|
2021-03-23 07:26:13 +00:00
|
|
|
winmm_lib = cc.find_library('winmm', required: false)
|
2019-12-26 05:24:46 +00:00
|
|
|
|
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
|
|
|
|
|
2023-02-25 13:35:57 +00:00
|
|
|
d2d_dep = cc.find_library('d2d1', required: d3d11_option)
|
|
|
|
have_d2d_h = cc.has_header('d2d1.h', required: d3d11_option)
|
2023-06-27 18:41:26 +00:00
|
|
|
dwmapi_lib = cc.find_library('dwmapi', required: d3d11_wgc_option)
|
|
|
|
have_wgc = false
|
2023-02-25 13:35:57 +00:00
|
|
|
|
2023-06-27 18:41:26 +00:00
|
|
|
if not d3d11_wgc_option.disabled()
|
|
|
|
have_wgc = cxx.compiles('''
|
|
|
|
#include<windows.h>
|
|
|
|
#include<winstring.h>
|
|
|
|
#include<roapi.h>
|
|
|
|
#include<windows.graphics.capture.h>,
|
|
|
|
#include<windows.graphics.capture.interop.h>
|
|
|
|
#include<windows.graphics.directx.direct3d11.h>
|
|
|
|
#include<windows.graphics.directx.direct3d11.interop.h>
|
|
|
|
#include<wrl.h>
|
|
|
|
using namespace Microsoft::WRL;
|
|
|
|
using namespace ABI::Windows::Graphics::Capture;
|
|
|
|
ComPtr<IDirect3D11CaptureFramePoolStatics> pool_statics;
|
|
|
|
ComPtr<IDirect3D11CaptureFramePoolStatics2> pool_statics2;
|
|
|
|
ComPtr<IDirect3D11CaptureFramePool> pool;
|
|
|
|
ComPtr<IGraphicsCaptureSession> session;
|
|
|
|
ComPtr<IGraphicsCaptureSession2> session2;
|
|
|
|
ComPtr<IGraphicsCaptureSession3> session3;
|
|
|
|
''',
|
|
|
|
name: 'Windows Graphics Capture support in Windows SDK')
|
|
|
|
|
|
|
|
if d3d11_wgc_option.enabled() and not have_wgc
|
|
|
|
error('The Windows Graphics Capture feature is enabled but not supported by Windows SDK')
|
|
|
|
endif
|
|
|
|
endif
|
2022-10-06 19:20:29 +00:00
|
|
|
|
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']
|
2022-06-15 18:57:37 +00:00
|
|
|
extra_dep += [runtimeobject_lib]
|
2021-01-18 10:17:14 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
if d3d11_winapi_desktop
|
2022-10-06 14:54:14 +00:00
|
|
|
d3d11_sources += ['gstd3d11dxgicapture.cpp',
|
|
|
|
'gstd3d11screencapture.cpp',
|
2022-02-10 13:31:06 +00:00
|
|
|
'gstd3d11screencapturedevice.cpp',
|
2022-10-06 14:54:14 +00:00
|
|
|
'gstd3d11screencapturesrc.cpp',
|
|
|
|
'gstd3d11window_win32.cpp']
|
2022-02-10 13:31:06 +00:00
|
|
|
|
2021-03-23 07:26:13 +00:00
|
|
|
# multimedia clock is desktop only API
|
2022-04-11 16:01:23 +00:00
|
|
|
if winmm_lib.found() and cc.has_header('mmsystem.h')
|
2021-09-10 15:43:26 +00:00
|
|
|
extra_args += ['-DHAVE_WINMM']
|
2021-03-23 07:26:13 +00:00
|
|
|
extra_dep += [winmm_lib]
|
|
|
|
endif
|
2022-10-06 19:20:29 +00:00
|
|
|
|
2023-03-28 18:16:26 +00:00
|
|
|
if have_wgc and dwmapi_lib.found()
|
2022-10-06 19:20:29 +00:00
|
|
|
d3d11_sources += ['gstd3d11winrtcapture.cpp']
|
|
|
|
extra_args += ['-DHAVE_WINRT_CAPTURE']
|
2023-03-28 18:16:26 +00:00
|
|
|
extra_dep += [dwmapi_lib]
|
2022-10-06 19:20:29 +00:00
|
|
|
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'
|
2021-09-10 15:43:26 +00:00
|
|
|
extra_mingw_args = cc.get_supported_arguments([
|
2020-11-20 18:20:36 +00:00
|
|
|
'-Wno-redundant-decls',
|
|
|
|
])
|
|
|
|
|
2021-09-10 15:43:26 +00:00
|
|
|
extra_args += extra_mingw_args
|
2020-11-20 18:20:36 +00:00
|
|
|
endif
|
|
|
|
|
2023-09-30 13:21:40 +00:00
|
|
|
hlsl_precompiled = []
|
|
|
|
fxc = find_program ('fxc', required : get_option ('d3d11-hlsl-precompile'))
|
|
|
|
if cc.get_id() == 'msvc' and fxc.found()
|
|
|
|
subdir('hlsl')
|
|
|
|
extra_args += ['-DHLSL_PRECOMPILED']
|
|
|
|
endif
|
|
|
|
|
2023-10-21 16:10:54 +00:00
|
|
|
have_dx_math = cxx.compiles('''
|
|
|
|
#include <windows.h>
|
|
|
|
#include <DirectXMath.h>
|
|
|
|
using namespace DirectX;
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
XMMATRIX matrix;
|
|
|
|
XMFLOAT4X4 dump;
|
|
|
|
matrix = XMMatrixIdentity ();
|
|
|
|
XMStoreFloat4x4 (&dump, matrix);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
''',
|
|
|
|
name: 'DirectXMath suupport in Windows SDK')
|
|
|
|
|
|
|
|
if not have_dx_math
|
|
|
|
directxmath_dep = dependency('directxmath',
|
|
|
|
fallback: ['directxmath', 'directxmath_dep'],
|
|
|
|
required: d3d11_option)
|
|
|
|
if not directxmath_dep.found()
|
|
|
|
subdir_done ()
|
|
|
|
endif
|
|
|
|
|
|
|
|
extra_dep += [directxmath_dep]
|
|
|
|
endif
|
|
|
|
|
2019-01-30 11:07:29 +00:00
|
|
|
gstd3d11 = library('gstd3d11',
|
2023-09-30 13:21:40 +00:00
|
|
|
d3d11_sources + hlsl_precompiled,
|
2021-09-10 15:43:26 +00:00
|
|
|
c_args : gst_plugins_bad_args + extra_c_args + extra_args,
|
|
|
|
cpp_args: gst_plugins_bad_args + extra_args,
|
2019-01-30 11:07:29 +00:00
|
|
|
include_directories : [configinc],
|
2023-02-25 13:35:57 +00:00
|
|
|
dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, gstcontroller_dep,
|
2023-09-16 14:57:18 +00:00
|
|
|
gstd3d11_dep, gstdxva_dep, d2d_dep] + extra_dep,
|
2019-01-30 11:07:29 +00:00
|
|
|
install : true,
|
|
|
|
install_dir : plugins_install_dir,
|
|
|
|
)
|
|
|
|
plugins += [gstd3d11]
|