Commit graph

149 commits

Author SHA1 Message Date
Seungha Yang 2e574a80d9 d3d11: Don't use g_alloca()
_alloca CRT function is deprecated. Moreover, stack allocation
for string is not a good idea. We can use _malloca inline
function instead, but all use of _alloca in d3d11 library/plugin
are not performance critical path at all.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3652>
2023-01-24 20:27:43 +00:00
Seungha Yang 467a2408a1 d3d11compositor: Workaround blending artifacts on Intel platform
Disable vendor implemented converter in d3d11compositor to workaround
artifacts

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3770>
2023-01-23 23:34:04 +09:00
Seungha Yang 7c92ed0bd0 d3d11videosink: Fixing focus lost on desktop layout change
Watch all message on the window thread, instead of internal window only.
Otherwise, some global window messages, such as desktop layout change,
wouldn't be handled by our window.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3593>
2022-12-17 11:17:28 +00:00
Seungha Yang 068a5c1053 d3d11videosink: Move potentially time-consuming operations to ::prepare()
Move following tasks to ::prepare() from ::show_frame()
* CPU -> GPU upload
* GstD3D11Window object setup, including input caps change handling

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3574>
2022-12-17 02:11:07 +09:00
Seungha Yang 04451b108a d3d11videosink: Call ShowWindow() from window thread
... when rendering on external HWND. ShowWindow() will cause
synchronous message passing to window thread and then can be blocked.
At the same time, window thread can wait for GStreamer thread.
Instead of the synchronous call, queue the task to window message
and performs from the window thread.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3583>
2022-12-16 22:18:14 +09:00
Seungha Yang a27c5c81df d3d11videosink: Fix deadlock when parent window is busy
Deadlock sequence:
* From a streaming thread, d3d11videosink sends synchronous message
  to the parent window, so that internal (child) window can be
  constructed on the parent window's thread
* App thread (parent window thread) is waiting for pipeline's
  state change (to GST_STATE_NULL) but streaming thread is
  blocked and waiting for app thread

To avoid the deadlock, GstD3D11WindowWin32 should send message
to the parent window asynchronously.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3570>
2022-12-15 17:37:48 +00:00
Seungha Yang ac6b3e9a45 d3d11av1dec: Promote rank to primary + 1
... so that this element can have higher rank than the other software
AV1 decoders

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3495>
2022-12-02 17:56:22 +00:00
Seungha Yang b9b3a9c4e1 d3d11: Use correct ref/unref methods
Those objects are GstObject subclasses

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3479>
2022-11-28 18:50:03 +00:00
Seungha Yang 349f8de13e d3d11decoder: Handle input caps change
Update output caps if it's notified by baseclass

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3328>
2022-11-16 13:12:38 +00:00
Seungha Yang 219c5cf330 meson: d3d11: Clarify the message for WGC support check
Even Windows10 SDK seems to have required symbols depending on installed
SDK version

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3376>
2022-11-11 19:42:19 +00:00
Seungha Yang 12a2c1dffe d3d11screencapturesrc: Fix build error with MSVC x86
Delete the code for now. Note that the code block is unnecessary already

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3375>
2022-11-11 18:58:54 +00:00
Seungha Yang 99b83f33f7 d3d11screencapturesrc: Specify PAR 1/1 to template caps
... otherwise PAR can be wrongly signalled during the negotiation

Fixing below pipeline when desktop resolution is not 640x480
gst-launch-1.0.exe \
  d3d11screencapturesrc ! videoscale !
  video/x-raw,width=640,height=480,pixel-aspect-ratio=1/1 ! d3d11videosink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3360>
2022-11-09 11:22:06 +00:00
Seungha Yang 0405e0cfc7 d3d11videosink: Always clear back buffer on resize
Swapchain may not need to be resized if the size of backbuffer
is equal to the previous size. Then previously rendered frame will be stay
on the screen. Do clear back buffer whenever resize() is called

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3341>
2022-11-05 17:23:24 +00:00
Seungha Yang 92e03ba869 d3d11decoder: Fix for VP9 decoding with odd resolution
Fixing off by one mismatch when width and/or height of stream
is odd number

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3302>
2022-10-31 20:45:25 +00:00
Seungha Yang d8bdd9429b d3d11vp9dec: Disallow Profile2 12bits stream
Since DXVA does not support the format, specify bit-depth field
to sinkpad template caps so that d3d11vp9dec can be skipped
during autoplugging

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3297>
2022-10-31 11:29:39 +00:00
Seungha Yang 6974b6f6ff d3d11: Update for documentation
* Use GST_PARAM_DOC_SHOW_DEFAULT flags for GPU ID related
  properties
* Add doc caps
* Increase deinterlace max resolution

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3250>
2022-10-24 12:42:51 +00:00
Seungha Yang 31be056b6e d3d11: Run indent
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3250>
2022-10-24 12:42:51 +00:00
Seungha Yang 426535f3a6 d3d11screencapture: Add WinRT API based capture mode
Add Windows Graphics Capture (WGC) API based screen capture mode.
The conditions where this mode is used:
* Explicitly requested by user (capture-api property)
* To capture specific window
* When DXGI desktop duplication API does not work on hybrid graphics systems
  (e.g., multi-gpu laptop)

Full features of this implementation require Windows 11. And Windows 11
SDK is required to build this feature.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3144>
2022-10-21 14:21:28 +00:00
Seungha Yang 087e335006 d3d11screencapture: Subclassing capture implementation
Preparation to use WinRT capture API

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3144>
2022-10-21 14:21:28 +00:00
Seungha Yang 573a0489f6 d3d11videosink: Add "emit-present" property
Controls the decision for "present" signal use, and
allows delayed "present" signal handler install via the property

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3176>
2022-10-18 21:19:01 +00:00
Thibault Saunier 6a4425e46a meson: Call pkgconfig.generate in the loop where we declare plugins dependencies
Removing some copy pasted code

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2970>
2022-09-01 21:17:35 +00:00
Seungha Yang c3cf9521a5 d3d11: Update library doc
* Private header name is changed to gstd3d11-private.h to follow
  naming convention
* Add Since mark everywhere
* Update member variable names to be consistent with the other
  object implementations in this library
* Correct outdated documentation

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2945>
2022-08-27 22:40:34 +09:00
Seungha Yang 0a65aaa6d2 d3d11videosink: Add display-format property
Make swapchian's display format configurable, since some DXGI formats
we can use for swapchain are not API interop compatible.
For instance, BGRA format should be used for Direct2D interop.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2923>
2022-08-24 17:44:49 +00:00
Seungha Yang 470436d7e6 d3d11videosink: Add present signal
The "present" signal will be emitted just before the
IDXGISwapChain::Present() call. The client can perform additional
GPU operation with given GstD3D11Device object and
ID3D11RenderTargetView handle. Or, the client can read back
the scene to be displayed on window using the signal.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2923>
2022-08-24 17:44:49 +00:00
Seungha Yang 7bcfccd0bd d3d11: Use CRITICAL_SECTION instead of GRecMutex
The GRecMutex abstraction (and heap allocation happens in GLib)
is unnecessary for this plugin.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2914>
2022-08-18 17:48:57 +00:00
Seungha Yang df64226e71 d3d11decoder: Do timer based DecoderBeginFrame retry
... instead of retry count based one, because the precision of Sleep()
varies depending on system and application configuration.
Also, don't retry DecoderBeginFrame if decoder is doing flush.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2886>
2022-08-15 19:16:16 +00:00
Seungha Yang 9b4fafb882 d3d11decoder: Do not use miniobject qdata
The miniobject qdata uses global mutex.
Use ID3D11DeviceChild::{Set,Get}PrivateData methods instead.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2885>
2022-08-15 02:50:18 +09:00
Corentin Damman 0d07ff60c9 d3d11window: fix DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING swap chain flag for full screen
Fixes #1372 (regression introduced in 5eeec165)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2866>
2022-08-12 09:35:40 +00:00
Seungha Yang 05dae94352 d3d11: Use WIN32 API directly for locking with RAII pattern
Such abstraction is unnecessary for this library/plugin.
Use WIN32 API directly instead of GLib wrappers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2848>
2022-08-08 20:13:51 +00:00
Seungha Yang 66d504ee58 d3d11: Don't find global default allocator
We were using global default allocator already. Pass null
allocator object to *_alloc() methods then the method will
use default allocator.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2843>
2022-08-06 23:55:18 +09:00
Seungha Yang 74f56632c3 d3d11: Use std::call_once()
g_once_init_enter() always takes global mutex for non-GCC build.
Use C++ once call implementation

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2843>
2022-08-06 23:27:23 +09:00
Seungha Yang b8010e41a1 d3d11compositor: Add gamma-mode and primaries-mode properties
Allows controlling gamma remap and/or chromatic adaptation behavior.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2831>
2022-08-04 03:19:42 +09:00
Seungha Yang f89cb98495 d3d11videosink: Add gamma-mode and primaries-mode properties
Allows controlling gamma remap and/or chromatic adaptation behavior.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2831>
2022-08-04 02:48:57 +09:00
Seungha Yang 0ac7077d2d d3d11convert: Add gamma-mode and primaries-mode properties
Allows controlling gamma remap and/or chromatic adaptation behavior.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2831>
2022-08-04 02:48:57 +09:00
Seungha Yang bc065d2cc2 d3d11videosink: Translate mouse position
Converts mouse cursor position represented in display coordinates to
stream coordinates.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2824>
2022-08-02 14:24:22 +00:00
Seungha Yang 7d4a1a5beb d3d11videosink: Early terminate mouse/keyboard event handling
... and add missing null check (plus coding style fix)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2824>
2022-08-02 14:24:22 +00:00
Seungha Yang 6fff608f27 d3d11: Port to GstD3D11Fence
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2790>
2022-07-23 16:53:14 +00:00
Seungha Yang ac6577e2a9 d3d11compositor: Add support for crop meta
GstD3D11Converter supports cropping already. Cropping is just
a matter of setting source rectangle area to converter,
from d3d11 point of view

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2782>
2022-07-22 05:07:23 +09:00
Seungha Yang 1c3fac818d d3d11: Move GstD3D11Converter to gst-libs
The object is equivalent to GstVideoConverter but for D3D11.
Application can use this object directly for various conversions,
such as color space conversion, rescale, crop and flip/rotation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2767>
2022-07-22 00:08:51 +09:00
Seungha Yang ee289a65ce d3d11converter: Use GstStructure to set initialization options
Runtime updatable options are exposed via object properties
but there are a few options which should be known at initialization
time. Use GstStructure to signal it and to be easily extensible

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2776>
2022-07-20 07:05:51 +09:00
Seungha Yang d3d8820359 d3d11converter: Use primaries and transfer function compare methods
Different enum values could be functionally equal, then we don't need
to do full conversion.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2776>
2022-07-20 07:05:51 +09:00
Seungha Yang 16f4567a50 d3d11format: Move DXGI color space mapping method to gst-libs
Expose color space mapping method to public so that application
can configure GstCaps or GstVideoInfo using DXGI color space

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2776>
2022-07-20 07:05:46 +09:00
Seungha Yang 687f9feac6 d3d11convert: Use new colorimetry compare function
Avoid conversion if both are functionally identical

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2765>
2022-07-18 08:56:45 +00:00
Seungha Yang 35994eb5c9 d3d11testsrc: Fix SMPTE pattern rendering
It was wrong vertex shader code

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2766>
2022-07-17 23:59:04 +09:00
Seungha Yang 1dd29a2564 d3d11: Move HLSL compiler to gst-libs
We should move this functionality to gst-libs so that GstD3D11Converter
can be moved to gst-libs.
Another advantage is that applications can call our
HLSL compiler wrapper method without any worry about OS version
dependent system installed HLSL library.
Note that there are multiple HLSL compiler library versions
on Windows and system installed one would be OS version dependent.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2760>
2022-07-15 06:31:51 +09:00
Seungha Yang b09ca8635f d3d11: Use scoped device lock
Make code simpler and more deadlock-free

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2728>
2022-07-09 03:36:17 +09:00
Seungha Yang 6cc6494287 d3d11screencapturesrc: Set colorimetry to caps
Make use of reported DXGI colorspace if possible

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2729>
2022-07-08 21:05:25 +09:00
Seungha Yang 2476678b3c d3d11: Update colorspace map
Map DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 to sRGB colorimetry

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2729>
2022-07-08 20:15:28 +09:00
Seungha Yang 59d92ea62c d3d11: Add an utility method for DXGI colorspace conversion
Add a method for DXGI_COLOR_SPACE_TYPE -> GstVideoColorimetry conversion

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2729>
2022-07-08 20:03:06 +09:00
Seungha Yang e0d1b98827 d3d11converter: Remove convert() method
Expose only single convert_buffer() method. It's safer approach than
passing arbitrary list of SRV/RTV pointers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2713>
2022-07-04 18:46:51 +00:00