Commit graph

252 commits

Author SHA1 Message Date
jpark37 2e7f7acfeb libobs-d3d11: Log monitor color depth 2023-01-24 19:39:42 -08:00
tytan652 107b2a8f27 libobs-d3d11,libobs-opengl,plugins: Remove unneeded cast in switches
Those casts were usually used to workaround switch warnings.
2023-01-16 11:52:26 +01:00
Ryan Foster 88ea0bbb56 Revert "libobs-d3d11: Default to Intel IGPU on IGPU+DGPU systems"
This reverts commit c83eaaa51c.
2022-12-30 21:14:15 -08:00
Ryan Foster 19abcbcd3c Revert "libobs-d3d11: Make sure libobs knows the new adapter index"
This reverts commit e62759a3fa.
2022-12-30 21:14:15 -08:00
Jim e62759a3fa libobs-d3d11: Make sure libobs knows the new adapter index
Because Intel has wonderful code which forces it to run on the iGPU if
there are both an Intel iGPU and an Intel dGPU on the same system, the
adapter index OBS is set to internally will no longer be valid, thus if
anyone calls `obs_get_video_info()` to try to find out what adapter
index OBS is running on, it will be invalid on those computers.
Wonderful.

So, basically, this code here just fixe it so if you want to call
`obs_get_video_info()`, it'll actually have a valid adapter index now,
that way we can reference the adapter index when determining what GPU
we're actually running on without having to like, do anything super
complicated and silly like comparing adapter GUIDs just to figure out
what adapter OBS is actually runing on. I don't want the code to be a
mess anymore.

(I like how in any other situation on the face of the planet, there's no
need to force OBS to run on an integrated adapter. *Normally* OBS
*should* run on the dedicated adapter, that way it can actually capture
games properly. You can probably guess as to why they're forcing it to
run on the integrated adapter rather than the dedicated adapter. But you
know what? Whatever. I don't really care anymore I guess. Just...
whatever. Here we are I guess. Also I was in a bad mood while writing
this just as a disclaimer.)

(I hate that this commit exist. I hate that the commit c83eaaa51c exists
even more.)
2022-11-21 08:47:36 -08:00
PatTheMav 49ad848514
libobs-d3d11: Replace invocations of sprintf with snprintf
Fixes deprecation warnings in Xcode 14/clang on macOS and reduces
chance of buffer overflows.
2022-11-11 19:51:27 +01:00
jpark37 d9fe6977a6 libobs-d3d11: Support advanced SDR window preview
Displays more than 8 bpc if monitor is configured to be higher.
2022-11-09 22:35:24 -08:00
jpark37 2d0e312b30 libobs-d3d11: Unbind framebuffer before Present
D3D debug layer would INFO spam about RTV0 unbind for FLIP chains.
2022-08-17 23:20:13 -07:00
jpark37 b4f7499b33 libobs-d3d11: Force SDR for legacy swap chain
Legacy DISCARD does not support HDR, so prevent HDR preview.
2022-08-10 03:44:34 -07:00
jpark37 4fe6803fe4 libobs: Prevent D3D11 projectors from tearing
Some users stream projectors, so don't let them tear. Use the waitable
object to check the flip queue, and only flip if there's space.

Metal and Vulkan can probably perform similar flip throttling once OBS
starts using them.
2022-08-06 16:16:20 -07:00
jpark37 d9d4b69a59 libobs-d3d11: Add monitor to HDR status cache
Requesting HDR status is surprisingly expensive.
2022-04-14 09:36:09 -07:00
jpark37 eccde48926 libobs/graphics: Add gs_is_monitor_hdr
Only Windows is implemented for now. Mac/Linux return false for now.
2022-03-23 22:35:26 -07:00
jpark37 abddfead2f libobs/graphics: Add color space support 2022-03-23 22:35:26 -07:00
jpark37 fee3703f40 libobs/graphics, libobs-d3d11: Add P010 support 2022-03-20 17:22:13 -07:00
jpark37 484881fe2e libobs-d3d11: Remove Intel NV12 whitelist
List is not necessary now that NV12 is only used for GPU encoders.
2022-03-19 15:39:09 -07:00
jpark37 1c4148408f libobs-d3d11: Make gs_clear honor FRAMEBUFFER_SRGB
This matches the behavior of glClearColor/glClear on OpenGL.
2022-03-19 15:37:26 -07:00
PatTheMav 1fd7770548
libobs: Update CMakeLists.txt for libobs and associated libraries
Also updates libobs-opengl, libobs-d3d11, libobs-winrt
2022-03-16 23:11:08 +01:00
jpark37 b7ab8cf838 libobs-d3d11: Simplify duplicator formats
Remove DXGI_FORMAT_R10G10B10A2_UNORM since it can be ambiguous whether
it is Rec. 2020 PQ, or high-precision sRGB. We can revisit later.
2022-03-09 23:05:45 -08:00
jpark37 ed70de55cf libobs-d3d11: Relax minimum Windows for flip model
We'll need flip model swap chains in the future for HDR, and we don't
want to limit HDR to WIndows 11. The new test is the existence of
IDXGIFactory5, which was introduced in Windows 10 1607. This should be
enough for HDR, for which we use APIs in Windows 10 1703.

Hopefully having SetMaximumFrameLatency(40) this time will make enough
of a difference to not bring back reports of degraded performance when
using flip model on Windows 10.
2022-03-08 13:01:09 -08:00
jpark37 63db2265dc libobs, libobs-d3d11, libobs-opengl: Add GS_RG16
This format will be useful for P010 chroma in the future.
2022-01-29 15:12:00 -08:00
Richard Stanway 3240b05cec libobs-d3d11: Fix formatting 2022-01-15 00:38:02 +01:00
Richard Stanway 74b5bed116 libobs-d3d11: Fix incorrect format string
Detected by PVS Studio.
2022-01-15 00:16:39 +01:00
jpark37 b4b396411a libobs-d3d11: Log display nit range
May be useful for setting display range metadata.

Also span info across multiple lines. Single line had become too long.
2022-01-12 05:36:48 -08:00
jpark37 83c89d06b5 libobs-d3d11: Log display color space info
Add DXGI_COLOR_SPACE_TYPE and SDR white level when available for HDR
characteristics.

GetPathInfo/IsInternalVideoOutput functions were copied from MS docs.
2022-01-07 15:18:16 -08:00
jpark37 e77421a805 libobs-d3d11: DuplicateOutput1 for DXGI capture
Despite DuplicateOutput deing documented to always return BGRA8, it is
seen fluctuating between BGRA8 and RGBA16F when HDR is enabled.
DuplicateOutput1 seems to provide a stable format whether SDR or HDR.

Also update the texture recreation logic to check for format changes.
2021-12-21 02:38:42 -08:00
jw0z96 33a6d2a5fd libobs: Expose blending operation types 2021-12-20 09:06:38 -08:00
qiongzai.sun 0d8c98851e libobs: Fix gs_texture_2d::BackupTexture with GS_TEXTURE_CUBE 2021-11-23 20:52:40 -08:00
VodBox c8e417057a libobs, libobs-d3d11: Add support for NT Handle shared textures
Adds support for using shared textures that were made with the
D3D11_RESOURCE_MISC_SHARED_NTHANDLE flag.

This increases the minimum required Windows version to Windows 8 or the
Platform Update for Windows 7. As official support is only for Win 8+
this does not change official support.
2021-11-20 16:34:28 +13:00
jpark37 a9958b96d2 libobs-d3d11: Fix present skip comment
It's about the CPU being ahead of the GPU, not flip queue being full.

Also fix variable typo.
2021-09-15 15:09:25 -07:00
jpark37 608cd3867e libobs-d3d11: Use waitable object to avoid stalls
Skip Present if the waitable object says the swap chain isn't ready.
2021-09-15 02:52:12 -07:00
jpark37 fbe3e7e14b libobs-d3d11: Simplify DXGI factory creation
QueryInterface probably supplies all factories on OS. We'll see.
2021-09-15 02:52:12 -07:00
jpark37 01b5571c47 libobs-d3d11: Prefer ComPtr Clear() over Release() 2021-09-15 02:52:12 -07:00
jpark37 00941ffc84 libobs-d3d11: Use ALLOW_TEARING if supported 2021-09-11 01:33:55 -07:00
jpark37 7ce2a60a1d libobs-d3d11: Use FLIP_DISCARD on Windows 11
Windows 11 support for DISCARD swap effect seems to be buggy and slow.
Use FLIP_DISCARD instead. Staying with DISCARD on Windows 10 because of
reports of flickering that hopefully won't happen on Windows 11.

We're also not using ALLOW_TEARING because it seems to break after an
OBS cycle of minimize/restore on both Windows 10 and 11. The swap chain
displays a stale image. Not sure if ALLOW_TEARING would be beneficial
even if it was working.
2021-09-10 20:19:24 -07:00
jpark37 5457524f5a libobs-d3d11: Avoid vector usage
Allocations need global heap lock, which is bad.
2021-08-15 00:12:14 -07:00
jpark37 993c46c8a2 libobs-d3d11: Relax texture format copy check
SRGB and non-SRGB formats are compatible for copy.
2021-07-11 08:26:29 -07:00
jpark37 6d59cf19e9 libobs-d3d11: Use typeless texture for duplicator
This allows us to use an SRGB SRV for automatic decompression.
2021-07-11 08:26:29 -07:00
Lin c83eaaa51c libobs-d3d11: Default to Intel IGPU on IGPU+DGPU systems
On systems that have both Intel iGPU and Intel dGPU at the same time,
default/prioritize running OBS the iGPU instead to improve performance.
The user can still choose the dGPU if they change the adapter index, but
the adapter index will now be the second value instead of the first
value. (-Jim)
2021-03-21 22:45:08 -07:00
Lin 1e106c8bb8 libobs-d3d11: Split InitFactory to InitAdapter
Splits off the adapter initialization to its own function so we can
modify what happens in between those actions. (-Jim)
2021-03-21 22:45:08 -07:00
jpark37 c03320cfc2 libobs: Add function to count GPU adapters
Only implemented for D3D11 for now.
2021-03-12 20:59:31 -08:00
Richard Stanway 13cfd95fef libobs-d3d11: Avoid temporary ComPtr objects
The ternary operator promotes both sides to the same type if possible,
so it created and destroyed a temporary ComPtr. Found by PVS Studio.
2021-03-04 19:29:00 +01:00
jpark37 2b652cc763 libobs: gs_duplicator_get_monitor_index
Helper function to find DXGI output index of HMONITOR.
2021-01-26 17:11:04 -08:00
jpark37 66259560e0 libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.

A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.

Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.

Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.

Update obs_source_draw to use linear SRGB as needed.

Update render_filter_tex to use linear SRGB as needed.

Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.

Add SRGB helpers for vec4 struct.

Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-21 07:42:13 -08:00
jpark37 c72b5de23e libobs-d3d11: Support typeless textures
In the future, we may share or wrap typeless textures to support SRGB
and non-SRGB views.
2021-01-11 14:18:12 -08:00
jpark37 2d547cf669 libobs: Allow wrapping D3D11 object with gs_texture_t
This can be useful for reading from textures provided by middleware.
2020-11-24 14:39:56 -08:00
jp9000 7993179466 cmake: Add cmake folders 2020-05-13 06:52:37 -07:00
Colin Edwards 55e2985026
Merge pull request #1944 from WizardCM/windows-rc-definition
CMake: Build Windows modules with file descriptors
2020-04-18 18:27:22 -05:00
Richard Stanway 54c5ac250f libobs-d3d11: Log device PCI IDs
This will help identify devices sharing the same names (eg "Intel HD
Graphics") for potentially adding to the blacklists should they have
issues.
2020-03-23 20:54:38 +01:00
jp9000 8ecfb405ce Revert "win-capture, libobs: Show names of displays in Display Capture"
This reverts commit 9931f22ff4.
2020-03-19 06:43:57 -07:00
jp9000 b31c166814 Revert "graphics: libobs-d3d11: Use DXGI_SWAP_EFFECT_FLIP_DISCARD on Windows 10"
This reverts commit 4da73445c3.

This is being reverted because apparently it causes flickering displays
for some people.  Bad drivers or something?  Not sure.  Very annoying.
2020-03-11 09:35:47 -07:00