Alexander Slobodeniuk
0cb12db96c
d3d11device: protect device_lock vs device_new
...
It seems that when D3D11CreateDevice collides in time
with other D3D11 calls, in particular the proccess of
creating a shader, it can corrupt the memory in the driver.
D3D11 spec doesn't seem to require any thread safety from
D3D11CreateDevice. Following MSDN, it is supposed to be called
in the beginning of the proccess, while GStreamer calls it with each
new pipeline.
Such crashes in the driver were frequently reproducing on the
Intel UHD 630 machine.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6702 >
2024-04-20 20:49:34 +00:00
Seungha Yang
11eb88178b
meson: d3d11: Add support for MinGW DirectXMath package
...
Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3428
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6503 >
2024-04-02 12:55:24 +00:00
Seungha Yang
98ed7a8201
meson: d3d11: Disable library build if DirectXMath header was not found
...
DirectXMath header library is a hard dependency
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6472 >
2024-03-28 19:06:57 +00:00
Seungha Yang
470bcd4ec9
d3d11device: Fix adapter LUID comparison in wrapped device mode
...
Fix integer type mismatching
Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3382
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6364 >
2024-03-14 00:35:19 +00:00
Seungha Yang
44d4eb096d
cuda,d3d11,d3d12bufferpool: Disable preallocation
...
Do not chain up to parent's GstBufferPool::start() which will do
preallocation. We don't want it to be preallocated
since there are various cases where negotiated downstream buffer pool is
not used at all (e.g., zero-copy decoding, IPC elements).
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6345 >
2024-03-13 02:29:42 +00:00
Seungha Yang
d0713e029c
d3d11memory, d3d12memory: Fix outstanding memory count tracing
...
Gets being released memory back to queue even if allocator is flushing
in order to count the number of outstanding memory objects.
Also, clear queue if there's no outstanding memory object and
allocator is flushing
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6240 >
2024-02-29 11:57:50 +00:00
Seungha Yang
801492b334
d3d11: Add RBGA format support
...
Allocates DXGI_FORMAT_AYUV texture for RBGA so that it can be used
by video decoders.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5703 >
2023-11-29 16:54:16 +00:00
Seungha Yang
6992e14eee
d3d11: Fix string version shader code
...
RGBA to BGRA conversion code should have written in compute
shader.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5723 >
2023-11-28 21:02:44 +09:00
Seungha Yang
461c4bc32c
d3d11: Add support for more packed formats using compute shader
...
Adding below listed formats support, and reorders supported format
list based on preference
<YUV 4:2:2>
UYVY, VYUY, YVYU, v210, v216
<YUV 4:4:4>
v308, IYU2
<RGB 16bits per pixel>
RGB16, RGB15, BGR16, BGR15
<RGB 8bits per channel>
ARGB, xRGB, ABGR, xBGR, RGB, BGR
<RGB 10bits per channel>
r210, BGR10A2
<RGB 16bits per channel>
BGRA64
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5717 >
2023-11-27 15:14:09 +00:00
Seungha Yang
845f5d4856
d3d11: Rework memory allocation params signalling
...
Hide GstD3D11AllocationParams detail from public header and
set setter methods.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5717 >
2023-11-27 15:14:09 +00:00
Seungha Yang
721533d042
d3d11: Use shader model 4
...
Since shader model 4 is sufficient for the current pixel shader
implementations, prebuild HLSL with shader model 4 as well.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5709 >
2023-11-25 20:27:43 +09:00
Seungha Yang
df0e6c4140
d3d11converter: Do not use R32_UINT UAV
...
It does not work well with YUY2 texture on some GPUs. Always use
the same DXGI formats for each SRV and UAV
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5709 >
2023-11-25 20:27:43 +09:00
Seungha Yang
030800905b
d3d11device: Remove outdated comment
...
We do support 4:2:2 YUV formats using compute shader now
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5709 >
2023-11-25 20:27:43 +09:00
Seungha Yang
3ab8d520fb
d3d11: Drop legacy device support
...
Direct3D feature level 10 supported GPUs were released
more than 15 years ago, around the time when Windows
Vista / 7 were released. Also our d3d11 plugin/library
does not support feature level 9.x very well already.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5709 >
2023-11-25 20:27:43 +09:00
Nirbheek Chauhan
ec3962f9c7
directxmath.wrap: Fix cpuid mismatch on MinGW
...
This fixes a build failure with meson 1.3.0, which was caused by
a bugfix in Meson that made the cc.compile() check succeed on MSYS2
MinGW and enable DirectXMath SIMD, which in turn triggered the broken
`__cpuid()` issue mentioned in the meson.build file.
Upstream fix: https://github.com/microsoft/DirectXMath/pull/172
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5690 >
2023-11-20 20:08:57 +00:00
Nirbheek Chauhan
f65d074354
meson: Rework d3d11 checks, add new d3d11-math option
...
This allows us to ensure that directxmath SIMD is enabled.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5690 >
2023-11-20 18:49:13 +00:00
Seungha Yang
b42b45af46
d3d11: Add Y412 format support
...
It's mapped to DXGI_FORMAT_Y416 and major format for 12bits 4:4:4
video decoding. Since DXGI_FORMAT_Y416 format cannot be a render target,
adding corresponding compute shader code too.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5692 >
2023-11-21 02:40:10 +09:00
Seungha Yang
522d883fc3
d3d11: Add support for Y210 and Y212 formats
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5691 >
2023-11-20 20:29:13 +09:00
Seungha Yang
ca14eeeeaa
d3d11convert: Add support for YUY2 and Y410 output
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5691 >
2023-11-20 20:29:13 +09:00
Seungha Yang
2afa0fe7d0
d3d11converter: Port to converter helper
...
... add support YUY2 and Y410 output
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5691 >
2023-11-20 20:29:13 +09:00
Seungha Yang
c57fe82a93
d3d11: Implement helper object for converter
...
This object will upload system memory to GPU and preprocess
texture using compute shader or software converter if needed
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5691 >
2023-11-20 20:29:13 +09:00
Seungha Yang
cb3c1390f2
d3d11: Avoid ID3D11DeviceContext::Map if possible
...
Allocate resource with initial date instead of calling Map/Unmap
after allocation
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5660 >
2023-11-15 23:38:59 +09:00
Seungha Yang
0bcddfc894
d3d11: Enable DirectXMath SIMD
...
* Enable SIMD except for x86 target
* Use aligned matrix struct
* Remove unnecessary matrix copy operations
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5602 >
2023-11-07 11:19:31 +00:00
Seungha Yang
bf05cfea45
d3d11: Fix build with GST_DISABLE_GST_DEBUG
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5585 >
2023-11-03 13:31:03 +00:00
Seungha Yang
033f98ad86
d3d11: Set MaxAnisotropy value for the best quality
...
... and use anisotropic filter without comparison, which is actually
intended one.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5580 >
2023-11-01 15:41:08 +00:00
Seungha Yang
0e9fdabb1b
d3d11converter: Simplify private struct ctor
...
Initialize transform matrix using memcpy
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5580 >
2023-11-01 15:41:08 +00:00
Seungha Yang
e134cd8e09
d3d11device: Store device formats in hash map
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5580 >
2023-11-01 15:41:08 +00:00
Seungha Yang
443f205c38
d3d11converter: Don't update vertex buffer on transform matrix change
...
Transform matrix change requires only constant buffer update
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5575 >
2023-10-30 11:15:35 +00:00
Seungha Yang
f32bb06e32
d3d11converter: Fallback to linear sampler if filter is not supported
...
Use linear sampler if requested filter is not supported
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5572 >
2023-10-29 01:07:45 +09:00
Seungha Yang
b16665dc75
d3d11convert: Add support for sampling with anisotropic filter
...
Anisotropic filtering might produce better quality than linear filtering
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5572 >
2023-10-28 22:56:28 +09:00
Seungha Yang
5f44390b3e
d3d11converter: Reuse rasterizer state object
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5572 >
2023-10-28 22:12:17 +09:00
Seungha Yang
b7c49f8e9f
d3d11converter: Add support for MSAA render target
...
Create multi-sample render target view if sample count > 1
and MSAA enabled rasterizer for multi-sample render target
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5532 >
2023-10-28 09:58:16 +00:00
Seungha Yang
eac65d248a
d3d11converter: Add support for custom transform matrix
...
Adding gst_d3d11_converter_set_transform_matrix() method so that
user specified transform matrix can be applied when "video-direction=custom"
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5532 >
2023-10-28 09:58:16 +00:00
Seungha Yang
769c6a62a4
d3d11converter: Use transform matrix for rotation/flip
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5532 >
2023-10-28 09:58:16 +00:00
Seungha Yang
269ab85881
d3d11converter: Fix deadlock on taking property mutex
...
SRWLOCK should be zero initialized, but since we changed the private
struct to C++, use C++ mutex instead.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5498 >
2023-10-17 12:50:55 +00:00
Seungha Yang
65aa1b8faa
d3d11converter: Create ID3D11Buffer with initial data
...
... and remove unnecessary device lock
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5492 >
2023-10-17 10:48:49 +00:00
Seungha Yang
4e3d87edf5
d3d11converter: Don't set unnecessary constant buffer
...
Skip PSSetConstantBuffers() if it's not used by pixel shader
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5492 >
2023-10-17 10:48:49 +00:00
Seungha Yang
66bb9ee866
d3d11converter: Update shader code to make 4_0_level_9_1 compatible
...
4_0_level_9_1 target requires float4 SV_TARGET
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5483 >
2023-10-15 19:02:24 +09:00
Seungha Yang
a35c4fd5c5
d3d11converter: Fix 10/12bits planar output
...
Simple division can result in 10/12bits overflow.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5483 >
2023-10-15 01:47:29 +09:00
Seungha Yang
5ea1f8a548
d3d11converter: Print calculated matrix for debugging
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5483 >
2023-10-15 00:27:27 +09:00
Seungha Yang
ba02e94dde
d3d11converter: Calculate gamma LUT only once
...
Reuse calculated gamma lookup table and use immutable 1D texture
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5482 >
2023-10-14 13:37:08 +00:00
Seungha Yang
6f8c474293
d3d11converter: Remove unused variable
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5482 >
2023-10-14 13:37:08 +00:00
Seungha Yang
f52ecb9607
d3d11converter: Add support for HLSL precompile and bytecode caching
...
Precompile pixel shaders for simple conversion path
(without gamma/primaries conversion) in case of MSVC build.
Even if runtime compile is required (cross-compiled or complex conversion
path), do it only once and reuse the compiled bytecode.
This precompile/caching can save about 95% of time taken by
gst_d3d11_converter_new() call.
Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3004
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5457 >
2023-10-11 18:40:46 +00:00
Seungha Yang
83a576e854
d3d11: Reuse sampler object
...
The linear sampler object can be reused
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5457 >
2023-10-11 18:40:46 +00:00
Seungha Yang
92cc5722c8
d3d11: Pass HLSL source size to compile function
...
The string size is known at build time
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5457 >
2023-10-11 18:40:46 +00:00
Seungha Yang
bfdea297d2
d3d11converter: Set alpha-mode using config
...
... and disallow runtime alpha-mode update for now
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5457 >
2023-10-11 18:40:46 +00:00
Seungha Yang
cf1286b0e9
d3d11: Add support for HLSL precompile and shader caching
...
Compile HLSL at build time in case of MSVC, and use it if device
supports shader model 5. Also cache/reuse pixel shader and vertex
shader objects.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5426 >
2023-10-03 09:42:03 +00:00
Seungha Yang
d731a7c2fc
d3d11: Add support for GBR_16LE format
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5375 >
2023-09-23 13:12:55 +00:00
Seungha Yang
2aa88033b2
d3d11memory: Allow CreateSharedHandle() without keyed mutex
...
For d3d11 resource to be shared with d3d12, keyed mutex shouldn't
be enabled since d3d12 resource does not expose the keyed mutex
interface
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5356 >
2023-09-20 10:34:54 +00:00
Seungha Yang
b18bd5ec2b
d3d11bufferpool: Fix heavy CPU usage in case of fixed-size pool
...
There's no reason to release GstMemory manually at all.
If we do release GstMemory, corresponding GstBuffer will be
discarded by GstBufferPool baseclass because the size is changed
to zero.
Actual cause of heavy CPU usage in case of fixed-size pool
(i.e., decoder output buffer pool) and if we remove GstMemory from
GstBuffer is that GstBufferPool baseclass is doing busy wait in acquire_buffer()
for some reason. That needs to be investigated though, discarding
and re-alloc every GstBuffer is not ideal already.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4935 >
2023-06-27 23:25:09 +00:00