Commit Graph

161 Commits (master)

Author SHA1 Message Date
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 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 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
jw0z96 33a6d2a5fd libobs: Expose blending operation types 2021-12-20 09:06:38 -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 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
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 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 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
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 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
brittneysclark b8754f89fb libobs-d3d11: Enable NV12 for Intel on newer platforms
Check Intel Device IDs and only disable NV12 on legacy Intel GPUs. NV12
copy times on new platforms (ICL+) is minimal.
2020-02-26 05:49:13 -08:00
jpark37 f27f858ab3 libobs: Support device loss registration
Complex external systems using the D3D11 device may need to perform
their own device loss handling, the upcoming Windows Graphics Capture
support for example.
2020-02-22 21:02:33 -08:00
Jim 4df9ce0cdf
Merge pull request #2251 from jpark37/lut-volume-texture
Use volume textures for LUT filter
2019-12-29 11:04:20 -08:00
jpark37 b5b6f24d5b libobs-d3d11: Increase the frame queue capacity
Sometimes Present stalls are seen when multiple swap chains are active.
This seems to fix that.
2019-12-19 10:08:21 -08:00
jpark37 8f6984e345 libobs: Add support for volume textures
Also fix some mip calculations along the way.
2019-12-15 14:38:26 -08:00
Jim fa5454d1b8
Merge pull request #2124 from notr1ch/pci-device-ids
Use PCI database IDs instead of string matching for devices
2019-11-22 23:15:55 -08:00
Jim 3e01fdf3e5
Merge pull request #2116 from jpark37/begin-frame
libobs: Add gs_begin_frame for duplicators
2019-10-15 22:23:34 -07:00
Jim 3ccc63c14b
Merge pull request #2090 from jpark37/dxgi-refresh-rate
Log display refresh rates, and monitor names on D3D11
2019-10-15 10:04:49 -07:00
Jim 65e0fee6d0
Merge pull request #2089 from jpark37/dxgi-driver-version
libobs-d3d11: Add GPU driver version to log
2019-10-15 10:03:44 -07:00
Richard Stanway 323638e704 libobs-d3d11: Use vendor ID instead of string match 2019-10-14 23:06:33 +02:00
Jim 6b08c064f6
Merge pull request #2066 from jpark37/feature-level-baseline
Use D3D_FEATURE_LEVEL_10_0 as baseline
2019-10-12 20:55:33 -07:00
Jim 09c7ec487b
Merge pull request #2064 from jpark37/bgra-swap-chain
D3D swap chain enhancements
2019-10-12 20:54:33 -07:00
jp9000 dd48a99f03 libobs-d3d11: Fix code styling 2019-10-11 17:40:50 -07:00
jp9000 0f75f963ad libobs-d3d11: Fix calling convention of loaded func
Because this did not have WINAPI (stdcall) specified as the calling
convention on the gdi32 export, caused a crash due to stack corruption
on the 32bit version of OBS.
2019-10-11 17:21:11 -07:00
jpark37 ade65df2aa libobs: Add gs_begin_frame for duplicators
We really shouldn't be resetting duplicator state as part of gs_flush.
gs_begin_scene is not ideal because it is called twice per frame, and
only after duplicators have been ticked. Even though it makes no
user-facing difference, it makes more logical sense to reset at the top
of the frame than the bottom.
2019-10-10 21:06:01 -07:00
jp9000 b7d094a532 libobs-d3d11: Don't set GPU priority on Intel adapters 2019-10-10 03:03:38 -07:00
jp9000 ec769ef008 libobs-d3d11: Set maximum GPU priority
(This commit also modifies the UI)

This solves the issue where OBS would be deprioritized by Windows over
fullscreen games, causing OBS to lag out whereas the games would still
run fine.
2019-10-10 00:51:47 -07:00
jpark37 84d0fdc576 libobs-d3d11: Disable NV12 format support for WARP
Speculative fix. Don't have easy ability to reproduce this locally.
2019-10-06 20:30:49 -07:00
jpark37 8d36685599 libobs-d3d11: Add GPU driver version to log
DX version string is not the nicest, but no need for IHV library.
2019-10-05 15:03:23 -07:00
jpark37 4b0826cf5d libobs-d3d11: Log monitor names 2019-10-01 20:00:43 -07:00