Commit graph

62 commits

Author SHA1 Message Date
Seungha Yang
f04f6f43c3 d3d12frame: Fix frame copy method
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7243>
2024-07-27 04:18:47 +09:00
Seungha Yang
28a7adf4dd d3d12memory: Check heap flag before trying to create NT handle
CreateSharedHandle() will fail eventually if the resource was created
with non-shared heap. Instead of trying to create handle blindly,
validate resource first.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7243>
2024-07-27 04:17:03 +09:00
Seungha Yang
4a6daad517 d3d12: Suppress fence data object leak report
We don't release GstD3D12Device intentionally, thus
a GstD3D12FenceDataPool owned by a device will not be released
but that's expected leak.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7243>
2024-07-27 03:23:22 +09:00
Seungha Yang
9a8d7db5de d3d12: Fix debug category name
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7243>
2024-07-27 03:23:22 +09:00
Seungha Yang
9a06330d09 d3d12converter: Update internal method names
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7193>
2024-07-18 14:17:43 +00:00
Seungha Yang
b37bfc02f5 d3d12: Remove unnecessary event handles
null event NT handle to ID3D12Fence::SetEventOnCompletion()
will block the calling CPU thread already, thus it has no point that
creating an event NT handle in order to immediate wait for fence at CPU-side.
Note that passing a valid event NT handle to the fence API might be useful
when we need to wait for the fence value later (or timeout is required),
or want to wait for multiple fences at once via WaitForMultipleObjects().
But it's not a considered use case for now.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7176>
2024-07-16 19:17:15 +00:00
Seungha Yang
6cac053549 d3d12bufferpool: Use shared heap by default
... to make cross-api resource sharing possible

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7119>
2024-07-01 20:18:42 +00:00
Seungha Yang
c2531853fc d3d12commandallocatorpool: Remove unused methods
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7108>
2024-06-29 20:47:39 +09:00
Seungha Yang
e71ffe978a d3d12converter: Make sure data upload before executing compute shader
Use read d3d12 map, so that upload can happen if needed

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7093>
2024-06-24 20:49:19 +09:00
Seungha Yang
245e15eab0 d3d12: Add ARGB64_LE format support
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7093>
2024-06-24 20:11:21 +09:00
Seungha Yang
8c538c8122 d3d12: Add AV12 format support
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7093>
2024-06-24 20:11:13 +09:00
Seungha Yang
2703f41da6 d3d12: Add NV16, NV61, and NV24 format support
Can reuse NV12 shader for the formats

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7093>
2024-06-24 20:10:50 +09:00
Seungha Yang
bb0f95a67f d3d12: Add A420, A422 and A444 format support
Adding A420/A422/A444 and its 10/12/16 bits format support

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7093>
2024-06-24 20:10:50 +09:00
Seungha Yang
52bc28c93d d3d12: Add YUV 4:1:0 and 4:1:1 format support
Adding Y41B, YUV9, and YVU9 format support

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7093>
2024-06-24 20:10:50 +09:00
Seungha Yang
25514c8fc1 d3d12: Add v216, v210, r210, v308, IYU2, RGB, BGR format support
Reuse the compute shader implemented for d3d11

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7092>
2024-06-23 22:30:40 +09:00
Seungha Yang
c1498851b3 d3d12: Add support for UYVY, VYUY, and YVYU
Use already implemented compute shaders

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7092>
2024-06-23 22:30:40 +09:00
Seungha Yang
6fcb5f6ae7 d3d12: Add RGB{16,15} and BGR{16,15} format support
d3d12 device can support B5G6R5_UNORM and B5G5R5A1_UNORM formats
in pixel shader. If the format is not supported by device,
U16_UINT format with compute shader will be used, like d3d11converter

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7092>
2024-06-23 22:30:40 +09:00
Seungha Yang
94bb9fec58 d3d12: Add BGRA64 and BGR10A2 format support
Map BGRA64 and BGR10A2 to Y416 and Y410, respectively,
since it's possible RGB space decoder output

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7092>
2024-06-23 22:30:30 +09:00
Seungha Yang
66cc3ff84e d3d12: Add support for DXGI native packed YUV formats
Adding YUY2, Y210, Y216, and Y416 format support

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7092>
2024-06-23 22:11:32 +09:00
Seungha Yang
dd4d85272e d3d12converter: Fix Y410 conversion
Adding format conversion helper and use compute shader in case that
output format does not support RTV.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7088>
2024-06-23 10:53:18 +00:00
Seungha Yang
f432e61bdc d3d12memory: Add support for UAV descriptor cache
Cache shader invisible UAV descriptor in memory

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7088>
2024-06-23 10:53:18 +00:00
Seungha Yang
ec06b0445e d3d12: Format table refactoring
Hide format table from header. This is a preparation for compute
shader based format support

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7088>
2024-06-23 10:53:18 +00:00
Seungha Yang
5d18d8a109 d3d12converter: Upload shader buffer resources earlier
Schedule (semi-)static resource upload at converter creation time.
And use single resource for all vertex, index, and constant
buffers, since separate resources will waste GPU memory.
Note that size and address of a committed resource are 64K aligned
even if requested buffer size is small.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7081>
2024-06-21 20:16:19 +09:00
Seungha Yang
c5785fbeec d3d12converter: Make gamma remap work as intended
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7073>
2024-06-20 17:54:12 +00:00
Seungha Yang
e90880e988 d3d12device: Don't warn for out of range device index
It can happen during enumeration as well, and it's expected error

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7070>
2024-06-20 14:23:13 +00:00
Seungha Yang
2983c50a9f d3d12device: Dump device feature support
... and use CD3DX12FeatureSupport helper class in d3dx12.h

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7070>
2024-06-20 14:23:13 +00:00
Seungha Yang
bdb12db5c6 d3d12device: Prevent too many in-flight GPU commands
Even if each element is checking its own in-flight commands,
total number of commands can get larger in case of complex pipeline.
Limits total number of in-flight commands at command queue level

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7066>
2024-06-20 00:58:45 +09:00
Seungha Yang
143efa2f86 d3d12commandqueue: Detect device removed event
Early return if device removed event is detected

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7066>
2024-06-20 00:07:41 +09:00
Seungha Yang
2ec7d82bd7 d3d12: Move fence setter helper method to gst-libs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7057>
2024-06-19 13:19:48 +00:00
Seungha Yang
fa7c4a2e39 d3d12converter: Update API signature
Always use device's main direct queue, and control gpu waiting
behavior by using boolean value

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7057>
2024-06-19 13:19:48 +00:00
Seungha Yang
f6eb3a01c0 d3d12memory: Hide fence value from header
Instead of exposing fence value to wait in header, user setter/getter
methods.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7057>
2024-06-19 13:19:47 +00:00
Seungha Yang
49c4247cb3 d3d12device: Add helper method for getting fence handle
Add get_fence_handle() method so that caller can get command queue's
dedicated fence handle from device

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7057>
2024-06-19 13:19:47 +00:00
Seungha Yang
289bc1d440 d3d12: Remove notify_com and notify_mini_object helper methods
Use private macros instead of exposing multiple APIs for the same thing

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7057>
2024-06-19 13:19:47 +00:00
Seungha Yang
6942868bda d3d12commandqueue: Update API name and arguments
Accepts multiple fences since single command list may have
multiple dependent resources which are associated with
different GPU engines

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7057>
2024-06-19 13:19:47 +00:00
Seungha Yang
713ea313f8 d3d12device: Use HRESULT return code if possible
Make function signature consistent with that of command queue

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7057>
2024-06-19 13:19:47 +00:00
Seungha Yang
37e1847464 d3d12videosink: Add support for window handle update
A large refactoring commit for adding features and improve performance

* Reuse internal converter and overlay compositor:
  Converter can be reused as long as input and display formats are not
  changed. Also overlay compositor reconstruction is required only if
  display format is changed

* Don't wait for full GPU flush on resize or close:
  D3D12 swapchain requires GPU idle in order to resize backbuffer.
  Thus CPU side waiting is required for swapchain related commands
  to be finished. However, don't need to wait for full GPU flushing.

* Support multiple sink on a single external window
  Keep installed subclass window procedure even if there's no associated
  our internal HWND. This will make window procedure hooking less racy.
  Then parent HWND's message will be transferred to our internal HWNDs
  if needed.

* Adding support for window handle update
  Application can change target HWND even when videosink is playing or
  paused state. So, users can call gst_video_overlay_set_window_handle()
  against d3d12videosink anytime. The videosink will be able to update
  internal state and setup resource upon requested.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7013>
2024-06-17 16:05:00 +00:00
Seungha Yang
db47f46ad7 d3d12commandqueue: Fix deadlock on drain()
Don't take lock if the drain() is called from the GC thread

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7013>
2024-06-17 16:05:00 +00:00
Seungha Yang
a2df44da7d d3d12: Workaround for Intel iGPU decoder crash
Observed Intel GPU driver crash when multiple decoders are
configured in a process. It might be because of frequent
command queue alloc/free or too many in-flight decoding commands.
In order to make command queue persistent and limit the number of
in-flight command lists, holds global decoding command queue.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7019>
2024-06-17 15:15:07 +00:00
Seungha Yang
6449bc3171 d3d12: Add support for DXGI debug layer
Will be enabled if GST_ENABLE_D3D12_DXGI_DEBUG env is set
and dxgidebug.dll is available.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7016>
2024-06-15 13:24:24 +00:00
Seungha Yang
e9cefde479 d3d12memory: Fix staging buffer alignment
Not all GPUs can support arbitrary offset of
D3D12_PLACED_SUBRESOURCE_FOOTPRINT when copying GPU memory between
texture and buffer. Instead of calculating size/offset per plane,
calculate the entire size and offsets at once.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6967>
2024-05-30 10:40:44 +00:00
Seungha Yang
ec11bb8253 d3d12memory: Allow null allocator in alloc()
Update code as documented

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6940>
2024-05-29 09:45:26 +00:00
Seungha Yang
c1b1c849f2 d3d12: Add support for Device Removed Extended Data (DRED)
Enable DRED if "d3d12dred > GST_LEVEL_ERROR", and print
DRED debug information on device removed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6718>
2024-05-28 15:09:21 +00:00
Sebastian Dröge
0ef396359c gst: Move GstQueueArray as GstVecDeque to core
And change lengths and indices from guint to gsize for a more correct type.

Also deprecate GstQueueArray and implement it in terms of GstVecDeque.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6779>
2024-05-06 18:25:42 +00:00
Seungha Yang
3e08cdeebe d3d12memory: Do not wait external fence on map()
Only wait for external fence if upload or download is required.
Waiting for external fence in case of d3d12 mapping is caller's
responsibility

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6749>
2024-04-28 12:49:07 +00:00
Seungha Yang
2a14793ee1 d3d12converter: Add support for GPU-side external fence waiting
Ideally, GPU waiting should be scheduled just before executing command list.
But handling the case outside of converter is a bit complicated.
Under an assumption that constructed command list will be executed
immediately, schedules GPU-side waiting inside of conversion method
to simplify the flow.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6749>
2024-04-28 12:49:07 +00:00
Seungha Yang
c95725bb79 d3d12memory: Use explicit type for GST_MAP_D3D12 define
C++ compiler will complain about different type between int and GstMapFlags

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6749>
2024-04-28 12:49:07 +00:00
Seungha Yang
87f43c25cc d3d12frame: Extract external fence from memory and wait helper function
Adding gst_d3d12_frame_fence_{gpu,cpu}_wait() methods

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6749>
2024-04-28 12:49:07 +00:00
Seungha Yang
478e49dd73 d3d12: Update copy_texture_region() method
Pass external fence value if any and allow passing fence
data so that dependent resources can be released
once copy is done

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6749>
2024-04-28 12:49:07 +00:00
Seungha Yang
d8aa2eea83 d3d12commandqueue: Add execute_wait_and_command_lists() method
... so that GPU-side waiting and executing can be scheduled at once

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6749>
2024-04-28 12:49:07 +00:00
Seungha Yang
ebb64dfd0d d3d12memory: Add get_external_fence() method
Required for caller to wait external fence without map() method

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6749>
2024-04-28 12:49:07 +00:00