456 Commits

Author SHA1 Message Date
jpark37
0f2c1447ab graphics-hook: Fix D3D11On12 usages
Use D3D12_RESOURCE_STATE_PRESENT for CreateWrappedResource arguments. We
should assume the application will set the backbuffer to PRESENT, and
expect that to be preserved across the Present() call.

Remove unnecessary calls to ReleaseWrappedResources.

Clean up (void**) casts with modern patterns.
2021-08-15 15:58:09 -07:00
Richard Stanway
ff0350b515 win-capture: Fix formatting 2021-07-24 23:21:02 +02:00
Richard Stanway
320177926d win-capture: Use better defaults in thread_is_suspended
On my system with ~250 processes running, this loop has to run over 500
times before allocating enough memory. Use better initial and increment
values to avoid thrashing the heap.
2021-07-24 23:15:45 +02:00
Richard Stanway
b2e30c955d win-capture: Move NT functions to shared file
Having them declared statically in a header included by multiple
compilation units results in duplicate functions being created.
2021-07-24 23:15:45 +02:00
jpark37
bf27941f5f libobs-winrt, win-capture: Linear SRGB support
Update window, display, and game capture to always bilinear filter in
linear space, even if the source texture is not SRGB typed. This helps
resolve confusion in situations where we were filtering in nonlinear
space vs. linear space, like when toggling an empty crop filter.
2021-07-11 08:26:30 -07:00
Ryan Foster
85ffdd57f4 win-capture: Return early in property callbacks if param is null
When obs_get_source_properties is called, it calls the property modified
callbacks without a source instantiation. The callbacks set in
.get_properties for display capture and window capture would then result
in exceptions when anything is dereferenced on the source, such as
wgc_supported or update_mutex, because the source itself is null. Let's
make the callbacks return early if the property param is null.
2021-06-30 01:45:42 -07:00
Ryan Foster
1da97fb0d0 win-capture: Check for WGC support on plugin load
We shouldn't have to check WGC support for every display capture or
window capture source. Either the system supports it or it doesn't.
Check when the plugin loads and use that result.
2021-06-30 01:45:42 -07:00
Ryan Foster
2f3c0911fa win-capture: Determine D3D11 usage once per run
The device type (OBS renderer) cannot change without restarting OBS, so
we should only have to check if we're using D3D11 once instead of
checking every time a new display capture or window capture source is
created.
2021-06-30 01:45:42 -07:00
Translation
ef2b1eb1c6 Update translations from Crowdin 2021-06-11 07:18:15 -07:00
Gol-D-Ace
90df8d44df Update translations from Crowdin 2021-05-30 20:33:35 +02:00
jpark37
0ffcb66526 graphics-hook: Add Detours include dir 2021-05-19 19:52:49 -07:00
jpark37
924d9a7d9c win-capture: Remove D3D12 fix toggle
The new D3D12 path seems stable enough. Remove the old path.
2021-05-18 12:47:25 -07:00
jpark37
a05b6f7280 win-capture: Bump graphics hook version to 1.5.0 2021-05-17 02:28:11 -07:00
jpark37
c6cee82c92 graphics-hook: Try multiple D3D12 queues
Keep trying queues until one of them passes D3D11On12CreateDevice.
2021-05-17 02:28:11 -07:00
jpark37
5290326b77 graphics-hook: Do not persist device unnecessarily 2021-05-17 02:28:11 -07:00
jpark37
7439e1c4b8 graphics-hook: More logging to help debugging 2021-05-17 02:28:11 -07:00
jpark37
d9d87e6502 graphics-hook: Kill early return 2021-05-17 02:28:11 -07:00
jpark37
c160a6ff3e graphics-hook: Give up on DXGI swap chain
If a swap chain hasn't been seen in a while, assume it no longer exists,
and reset the capture.
2021-05-17 02:28:11 -07:00
jpark37
3412f6fece graphics-hook: Reduce variable scopes 2021-05-17 02:28:11 -07:00
jpark37
32f9fc120a graphics-hook: Prevent recursive free
Make sure to set data.swap to null before calling data.free().
Otherwise, we may call data.free() again in the Release() hook.
2021-05-17 02:28:11 -07:00
jpark37
b899f06877 graphics-hook: Fix potential D3D12 device leak 2021-05-17 02:28:11 -07:00
jpark37
2e7b0e3340 graphics-hook: Use Detours for D3D12 hook
Will attempt to fully use Detours after 27 ships.
2021-05-17 02:28:11 -07:00
jpark37
4de5863d07 graphics-hook: Link Detours library 2021-05-17 02:28:11 -07:00
jpark37
366b716f20 libobs-winrt,win-capture: Cursor toggle exceptions
A user has reported that toggling the cursor can cause exceptions.

Propagate that information upward, so we can reset the capture.

Display capture never needed to call the function in the first place.

Shuffle around window capture code to make a common reset function.

Builds on PR #4663.
2021-05-07 23:50:13 -07:00
jpark37
3514f4fea5 win-capture: Fix WGC disable index for display
Previously disabled DXGI because the index is wrong.
2021-05-06 13:58:14 -07:00
jpark37
01d065fa7d win-capture: Remove SRGB code
Not having OBS_SOURCE_SRGB is good enough now.
2021-05-03 01:19:56 -07:00
jpark37
78711fa648 win-capture: Add OBS_SOURCE_SRGB flag 2021-05-03 01:19:56 -07:00
jpark37
2472529520 win-capture: Restore GL capture deduplication
Previous fix attempted to place swap_recurse count in gl_data struct,
where it could be unexpectedly memset to 0. Separate member from struct,
and make thread-local for additional safety.
2021-03-31 02:35:22 -07:00
wangshaohui
0069562cca win-capture: Fix window capture stuck last frame
Fixes obsproject/obs-studio#2321
2021-03-30 05:49:43 -07:00
jpark37
7e263ab775 win-capture: Better laptop test for auto-selection
Only auto-select WGC for desktop capture if a battery exists and
multiple GPU adapters are present. May false-positive on desktops with
a smart UPS attached, but we don't know of a better test.
2021-03-12 20:59:31 -08:00
jpark37
17cb0acdd7 graphics-hook: Fix build without COMPILE_D3D12_HOOK
Just need to forward declare D3D12 type.
2021-02-14 22:20:14 -08:00
jpark37
23e9d4153e win-capture: D3D12 swap chain queue usage
Attempt to schedule shared texture copies against the command queue that
the game's swap chain uses to try to reduce artifacts. The heuristics
for obtaining the queue are not perfect, so provide a toggle to use the
previous behavior.
2021-02-14 02:06:02 -08:00
jpark37
80b4a65cd2 win-capture: Add WGC desktop capture
Copy patterns from WGC window capture, and BitBlt monitor capture.
2021-01-26 17:11:12 -08:00
jpark37
db35a022cd libobs-winrt,win-capture: Support desktop capture
Add display capture support via winrt_capture_init_monitor. Almost all
of the existing window capture code is reused.

Rename winrt_capture_init to winrt_capture_init_window for symmetry.
2021-01-26 15:57:20 -08:00
jpark37
a311299606 win-capture: Support linear SRGB
For game capture, neither GL nor D3D9 support SRGB shared textures, so
disable linear SRGB support if the texture format doesn't support it.

Similarly, DXGI display capture doesn't work with SRGB at the moment.
Unsure if it will with more work, but disable for now.

Also force linear SRGB off if using GDI-compatible textures.
2021-01-21 07:42:57 -08:00
jpark37
535f6b0adc win-capture: Typeless game capture textures
Modify game capture shared textures to be typeless if they could
potentially need SRGB and non-SRGB views in the future.

These capture APIs have been updated: D3D 10/11/12, Vulkan.

D3D8 capture does not use shared textures.

D3D9 and GL interop do not support typeless textures.

The new game capture DLL should be compatible with old versions of OBS.

Also removed a lot of dead code around pointless SRV/RTV support.
2021-01-11 14:18:12 -08:00
Gol-D-Ace
7368a2c7cc Update translations from Crowdin 2020-12-14 00:29:44 +01:00
Gol-D-Ace
7ab98ca00f Update translations from Crowdin 2020-11-25 20:11:39 +01:00
jp9000
6d181d97ca win-capture: Update hook version 2020-11-16 14:39:04 -08:00
jpark37
484084abb5 win-capture: Clean up remaining /W4 warnings 2020-11-15 06:03:18 -08:00
jpark37
013dd5a7a3 win-capture: Fix our own Vulkan spec violation
Pass valid instance when looking up VkCreateDevice.
2020-11-14 12:03:36 -08:00
jpark37
a164a75ed6 win-capture: Warning fixes
Add explicit casts to convert data pointers to function pointers.

Add references for unused parameters.

Replace accidental BOOL* return values with BOOL.
2020-11-13 13:21:10 -08:00
jpark37
526c54fbba win-capture: Fix unused variables 2020-11-11 12:02:03 -08:00
jpark37
dad861b036 win-capture: Fix D3D leaks on swap chain release
For game capture, hook DXGI release function to release D3D objects if
the related swap chain is also being destroyed.

An added bonus is that the game capture hook will handle swap chain
recreation for applications that don't use ResizeBuffers.
2020-10-13 18:47:35 -07:00
jp9000
c66fa09b46 win-capture: Update hook version 2020-10-04 11:41:19 -07:00
jpark37
9ba768837b win-capture: Violate Vulkan spec for compatibility
Rivatuner Statistics Server calls vkGetInstanceProcAddr for
vkCreateDevice with a NULL instance. According to spec, this should
return NULL, but RTSS will dereference this and crash.

This change returns function pointers for every intercepted function
regardless of instance, which is enough to keep RTSS alive.
2020-10-03 22:41:11 -07:00
windwakr
884c43f8c0 win-capture: Fix mask handling on some color cursors 2020-10-03 05:55:30 -07:00
Gol-D-Ace
c66ebde080 Update translations from Crowdin 2020-09-27 23:07:27 +02:00
jp9000
107a85cc59 win-capture: Increment graphics hook version 2020-09-09 10:32:57 -07:00
jpark37
7cf148e013 win-capture: Improve game capture messages
Tag debug output in the game process with "[OBS]" and mention that
graphics-hook.dll is ours.
2020-09-08 09:55:46 -07:00