456 Commits

Author SHA1 Message Date
jp9000
bdd6562a94 win-capture: Put window capture update data in a mutex
Because the window capture source updates its data whenever certain
properties are modified, this would cause a race condition because
source updates normally happen in the graphics thread.  To solve this
for the time being, put access to that data within a mutex when updating
or updating visibility.
2020-09-03 05:49:58 -07:00
jpark37
94475b8795 win-capture: Fix Vulkan crash on minimize restore
Set uninitialized data members to avoid crash coming back from minimize.
2020-09-01 20:20:59 -07:00
jpark37
7a66466efc win-capture: Add Vulkan instance creation fallback
Fall back to original arguments if our 1.1 API request doesn't work.
2020-09-01 18:59:13 -07:00
jpark37
e905b4cb6e win-capture: Vulkan variable naming consistency 2020-09-01 18:56:14 -07:00
Jim
6efd70fc01
Merge pull request #3260 from jpark37/vulkan-cts-hack-remove
win-capture: Remove Vulkan CTS workaround
2020-08-27 10:18:08 -07:00
jp9000
bf4a917751 win-capture: Fix excessive window capture logging 2020-08-25 10:18:45 -07:00
jpark37
a713a5b433 win-capture: Robust Vulkan swap chain handling
Not all surfaces support VK_IMAGE_USAGE_TRANSFER_SRC_BIT. Only
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT is required by spec. Add fall back.
2020-08-23 11:23:12 -07:00
jp9000
36f8903da1 win-capture: Update graphics hook version 2020-08-22 13:03:05 -07:00
Ryan Foster
d49e14d8a6 win-capture: Remove unused strings
After PR #3074, the following strings are no longer used:
 * GameCapture.ForceScaling="Force Scaling"
 * GameCapture.ScaleRes="Scale Resolution"

Commits from PR #3074:
 * 9497589b1603dcacf07e3b81d2f60291eafb3590
 * 63933997586bf88c862159bf5cb20be56b713283
2020-08-20 02:21:30 -04:00
jpark37
9d177d0969 win-capture: Remove Vulkan CTS workaround
CTS has been fixed, so the workaround is no longer necessary.
2020-08-07 22:58:49 -07:00
jpark37
04b9b9fea3 win-capture: Make Vulkan frame data local to queue
Prevents multiple queues in the same family from racing on frame data.

Removal of vk_family_data also fixes broken capacity calculation. Two
queue families can share the same index if one is "protected-capable"
and the other isn't.
2020-07-26 13:33:01 -07:00
jpark37
e6896d79e3 win-capture: Hide Vulkan linked list internals 2020-07-26 13:32:53 -07:00
jpark37
44fb61b1f2 win-capture: Improve Vulkan hook stability
Make fixes mostly to stabilize CTS. Tested on Windows with RTX 2080 Ti.

Use separate linked-list maps for devices and queues.

Process queues upfront in OBS_CreateDevice, and not lazily in
OBS_GetDeviceQueue.

Handle failed node allocation for OBS_CreateInstance, OBS_CreateDevice,
and OBS_CreateSwapchainKHR.

Handle VK_NULL_HANDLE for OBS_DestroySurfaceKHR and
OBS_DestroySwapchainKHR.

Add temporary code path CTS_WORKAROUND to deal with CTS sharing surfaces
between instances.

Fix return value for OBS_DestroyInstance.

Add missing _freea calls, required for _malloca.

Make sure the queue passed to OBS_QueuePresentKHR supports transfer to
safely call vkCmdCopyImage.

Update GetInstanceProcAddr/GetDeviceProcAddr to conform closer to spec.

Remove extra macros because I dislike indirection more than verbosity.
2020-07-24 09:30:05 -07:00
Jim
cd865a0be8
Merge pull request #3150 from jpark37/vulkan-dynamic-arrays
win-capture: Remove fixed-size Vulkan arrays
2020-07-18 10:46:22 -07:00
Matt Gajownik
0e07e034a0 win-capture: Log duplicator display when updating properties 2020-07-14 22:40:15 +10:00
jpark37
afbad3b337 win-capture: Remove fixed-size Vulkan arrays
Use linked lists in place of fixed-size arrays in an attempt to fix
behavior when programs generate lots of non-resource objects.
2020-07-10 20:41:00 -07:00
Jim
5728df6cef
Merge pull request #3149 from jpark37/vulkan-32bit
win-capture Fix 32-bit Vulkan capture
2020-07-10 20:39:13 -07:00
Jim
97ecf23df0
Merge pull request #3121 from jpark37/chrome-window-priority
win-capture: Don't use Chrome classes for priority
2020-07-10 20:20:26 -07:00
Jim
6c37f6faea
Merge pull request #3113 from jpark37/vulkan-swap-decouple
win-capture: Decouple swap and frame indices
2020-07-10 20:15:38 -07:00
jpark37
7772a56a97 win-capture: Fix 32-bit Vulkan capture
Vulkan loader needs pure name, which needs manual fix-up on 32-bit.
2020-07-09 22:10:34 -07:00
jpark37
4ec9081f3a win-capture: Don't use Chrome classes for priority
Avoids accidental fallback to Discord for example.
2020-07-03 00:12:21 -07:00
jpark37
3ac17d11c4 win-capture: Decouple swap and frame indices
The swap image index may not be a rotating value, so manage a separate
index to avoid reusing frame data early and stalling.
2020-06-30 08:22:34 -07:00
jpark37
6393399758 win-capture: Remove game capture scaling
The performance save is not worth accidental usage support.

Also remove unnecessary copies from the shmem paths.
2020-06-22 15:07:07 -07:00
Jim
088a72129a
Merge pull request #3061 from jpark37/vulkan-best-practices
win-capture: Reset command pool rather than buffer
2020-06-21 11:21:33 -07:00
Jim
76ea0336ad
Merge pull request #2882 from RytoEX/log-window-capture-method
win-capture: Log window capture method
2020-06-21 07:00:36 -07:00
jpark37
cdd912b162 win-capture: Reset command pool rather than buffer
Reorganize data to avoid best practices layer warning. Sort of a false
positive in our case because we only have one buffer per pool now, but
implicit layers should be clean citizens.
2020-06-21 06:47:22 -07:00
Jim
9c107738f6
Merge pull request #3015 from jpark37/vulkan-external-fixes
win-capture: Improve Vulkan synchronization
2020-06-21 05:02:20 -07:00
jpark37
a7813c9f87 win-capture: Remove dead VkResult values 2020-06-07 15:22:13 -07:00
jpark37
83dd9c8540 win-capture: Improve Vulkan synchronization
Use general layout and 0 access masks for external synchronization as
specified in the spec.

Also set pipeline stages for maximum synchronization just in case
because it doesn't seem like the pipeline stages are specified.

"Vulkan-incompatible APIs will require the image to be in the GENERAL
layout whenever they are accessing them."

"Whilst it is not invalid to provide destination or source access masks
for memory barriers used for release or acquire operations,
respectively, they have no practical effect. Access after a release
operation has undefined results, and so visibility for those accesses
has no practical effect. Similarly, write access before an acquire
operation will produce undefined results for future access, so
availability of those writes has no practical use. In an earlier version
of the specification, these were required to match on both sides - but
this was subsequently relaxed. These masks should be set to 0."
2020-05-31 22:31:39 -07:00
Richard Stanway
50e1d17615 win-capture: Better matching of internal UWP windows
All strings were treated as partial matches before, which caused a
false positive with any executable beginning with "time", notably
affecting the game "Timelie" which used Timelie.exe.
2020-05-23 01:50:38 +02:00
Jim
665180350d
Merge pull request #2657 from hselasky/improvement
libobs: Implement and use better scaling function for 64-bit integers
2020-05-21 18:07:53 -07:00
Jim
ad919b47ea
Merge pull request #2921 from jpark37/vulkan-format-fail
win-capture: Fail on unsupported Vulkan formats
2020-05-21 17:29:57 -07:00
Jim
c5187aef16
Merge pull request #2908 from jpark37/wgc-minimize
Fix WGC minimize handling
2020-05-21 17:29:04 -07:00
Jim
cb98f456eb
Merge pull request #2595 from jpark37/vulkan-cleanup
Vulkan hook COM clean up, and extension check
2020-05-20 18:20:05 -07:00
Jim
23ee7aebc6
Merge pull request #2589 from jpark37/vulkan-alloc
win-capture: Use VkAllocationCallbacks
2020-05-20 18:17:20 -07:00
jpark37
e933e20b7c win-capture: Ignore cloaked windows
Fixes issue where there are two window handles for minimized Calculator,
and OBS picks the wrong one.
2020-05-17 10:45:10 -07:00
jpark37
477f90620d win-capture: Reset WGC fail flag for new window
WGC will give up on a window that it fails to capture, but that
shouldn't stop it from attempting to capture new windows.

Fixes #2928.
2020-05-13 07:54:41 -07:00
jp9000
7993179466 cmake: Add cmake folders 2020-05-13 06:52:37 -07:00
jpark37
30f6870b23 win-capture: Fail on unsupported Vulkan formats
Don't allow unsupported Vulkan formats to fall back to B8G8R8A8.
Probably better to fail completely than do an illegal copy.

Also remove bad conversion for VK_FORMAT_A2R10G10B10_UNORM_PACK32.
Red and blue channels were reversed, and there's no DXGI equivalent.

Addresses #2796. We can do more later if justified.
2020-05-12 12:06:03 -07:00
Ryan Foster
0a89446ba4 win-capture: Log window capture method 2020-05-08 04:16:28 -04:00
jpark37
097ea77488 libobs-winrt: win-capture: Detect GraphicsCaptureItem closure
Make WGC window capture recover from GraphicsCaptureItem closure, which
can occur when following links in fullscreen Chrome for example.
2020-05-06 21:42:26 -07:00
Hans Petter Selasky
0e4ea14ba1 libobs: Implement and use better scaling function for 64-bit integers
As os_gettime_ns() gets large the current scaling methods, mostly by casting
to uint64_t, may lead to numerical overflows. Sweep the code and use
util_mul_div64() where applicable.

Signed-off-by: Hans Petter Selasky <hps@selasky.org>
2020-04-05 20:27:28 +02:00
jp9000
83991a1345 win-capture: Update graphics hook version to 1.1.4 2020-04-05 03:48:34 -07:00
jpark37
8987fc6c81 win-capture: Verify VK_KHR_external_memory_win32 support
Good practice to verify necessary extensions exist. We'll probably need
keyed mutex extension in the future to support Intel.
2020-03-29 10:08:03 -07:00
jpark37
21dc1f573b win-capture: Cleaner COM usage
Remove hard-coded GUIDs, call correct functions, and clean up
unnecessary casts.
2020-03-29 10:00:36 -07:00
jpark37
348fcd5b00 win-capture: Fix crash if GPU can't Vulkan capture 2020-03-28 09:01:26 -07:00
jpark37
e1739707d0 win-capture: Use VkAllocationCallbacks 2020-03-27 23:59:37 -07:00
jp9000
8ecfb405ce Revert "win-capture, libobs: Show names of displays in Display Capture"
This reverts commit 9931f22ff4292e7e0a69c05cadaee474520b4786.
2020-03-19 06:43:57 -07:00
jp9000
b3ca1bd059 win-capture: Retry with last known window if first fails
This fixes a bug where games like "Don't Starve Together" wouldn't
capture because their actual render window is a completely different
window than their actual window on the screen.

So, because we already have the hook info by this point with the last
known window handle available, instead of using 0 here, we can just use
the window handle provided by the shared memory.  And we didn't even
have to change the hook!  That's nice.
2020-03-18 07:53:21 -07:00
jpark37
e4e96c5cef libobs-winrt: win-capture: Clean up error handling
Use proper check to fix false positive on 1809, and rework error spew to
remove output parameters from winrt_capture_init.
2020-03-18 00:33:12 -07:00