Commit Graph

278 Commits

Author SHA1 Message Date
PatTheMav
4dab2c51b8 libobs: Add prerequisites for Metal and Swift support 2025-09-04 17:58:27 -04:00
Alex Luccisano
ef3e7b2563 libobs: Add checks to some graphics API functions
A few recently introduced graphics API functions needed for Enhanced
Broadcasting were marked as `GRAPHICS_IMPORT_OPTIONAL`. Add the
proper checks in the wrapper to ensure they are safe on platforms
that do not implement the underlying function.
2025-05-09 13:08:10 -04:00
Lain
775ac56bc8 libobs/graphics: Add gs_draw_quadf()
Adds a function to draw a sprite or quad using floating point sizes
rather than integer sizes. Also named it more appropriately.
2025-04-23 15:23:29 -04:00
Lain
7b8b51b29f libobs/graphics: Improve sprite drawing perf
Sprites were unnecessarily updating a dynamic vertex buffer every single
draw call. This creates static vertex buffers for common vertex buffer
dimensions/uvs and only uses a dynamic vertex buffer when the texture
coordinates actually change.

Porbably not a significant perf change considering the very few number
of traingles we draw per frame but still nice to do.
2025-04-23 15:23:29 -04:00
Lain
d25e2c18e4 libobs/graphics: Optimize certain matrix4 functions
Optimizes certain 4x4 matrix functions by minimizing unnecessary math
operations. This ends up optimizing gs_matrix_transform() and
gs_matrix_rotate() functions and makes positional/rotational operations
a bit more optimal and requiring much less math than they would
otherwise.
2025-04-23 15:23:29 -04:00
Lain
9fa3b045a3 libobs/graphics: Remove some unnecessary checks
These checks are redundant because the base function they all lead to
does the same check.
2025-04-23 15:23:29 -04:00
Lain
40f0543488 libobs/graphics: Separate some sections via comments 2025-04-23 15:23:29 -04:00
Alex Luccisano
abb8cdf0da libobs, libobs-opengl: Add memory and identification APIs
Add graphics APIs to obtain the GPU driver version and renderer
strings, as well as GDDR memory sizes. The GDDR memory sizes
include the dmem (dedicated memory on the GPU) and smem
(shared CPU memory used by the GPU but resides in the CPU DDR).

The version and renderer strings are needed for identification
purposes, for example enhanced broadcasting used by Twitch, to
associate the GPU used by OBS with the PCIe-based identification
values such as device_id and vendor_id.
2025-04-01 23:18:15 -04:00
Doğukan Korkmaztürk
68ca91b21d libobs,libobs-opengl: Add gs_sync_t
This change adds a new type named gs_sync_t and related functions to X11
and Wayland EGL backends to abstract DRM syncobjs and their various
uses.

Signed-off-by: Doğukan Korkmaztürk <dkorkmazturk@nvidia.com>
2025-02-05 16:20:15 -05:00
Norihiro Kamae
b082e1be33 libobs/graphics: Remove unused source file graphics-magick.c 2024-10-08 13:25:05 -04:00
Ryan Foster
a1fbf1015f clang-format: Increase column limit from 80 to 120 2024-10-04 18:19:27 -04:00
Norihiro Kamae
71736ffb7d libobs/graphics: Add inline qualifier to functions in header files 2024-08-07 17:27:49 -04:00
Ryan Foster
02c1742b30 libobs/graphics: Prevent heap overflow in libnsgif
See upstream commit:
https://source.netsurf-browser.org/libnsgif.git/commit/?id=a268d2c15252ac58c19f1b19771822c66bcf73b2
2024-07-18 14:34:31 -04:00
Kurt Kartaltepe
10bfa99365 libobs: Export NV12/P010 functions
NV12 and P010 device functions were not exported on all platforms.
Windows was exporting from C files instead. After CMake 3.0 we started
hiding symbols and resolution failed.
2024-04-19 15:23:56 -04:00
PatTheMav
f4733ec6a2 Update source code formatting with clang-format 17.0.3
Added SCDisplayRef type alias to fix a quirk of this specific
clang-format version with ObjC block syntax.
2024-03-11 15:55:30 -04:00
Kurt Kartaltepe
3e49e89611 libobs,libobs-opengl,libobs-d3d11: Add opengl gs_enum_adapters
This adds gs_enum_adapters and gs_get_adapter_count to the opengl
backend and promotes these to multiplatform graphics functions.

However we need to make an internal device change, device_enum_adapters
must pass in the current device on opengl to ensure that adapter #0 is
the display adapter. We do this to avoid changes to plugins already
checking against obs_video_info.adapter which is always 0 and expected
to be the device OBS was initialized on.

The actual implementation reports the dri render node (or /Software).
This allows plugins to query non-video features of the adapters like
VA-API/NVENC/etc or other cross device functionality. `/Software` is
chosen to avoid opening random files in the current directory if its
passed along as a file path like the regular dri render nodes.
2024-01-27 17:51:33 -06:00
Kurt Kartaltepe
02c90207fc libobs,libobs-opengl: enable GPU encoding for OpenGL
Enable all of the previously Windows only paths for OpenGL backends that
support encode_texture2

Co-authored-by: Torge Matthies <openglfreak@googlemail.com>
2024-01-26 20:01:58 -05:00
Exeldro
82864559f2 libobs: Fix errors for gs_effect_create 2023-10-06 10:51:15 -06:00
Neal Gompa
491d7c0e98 libobs: Add license declaration files 2023-09-19 13:35:49 -04:00
Ryan Foster
e5d5df879c libobs: Add function to check fast clear capability 2023-07-29 16:34:47 -07:00
derrod
c939525f77 libobs: Remove legacy FFmpeg compatibility 2023-07-12 15:57:43 -04:00
Norihiro Kamae
c8e3794a35 libobs/graphics: Remove undefined function declarations
These functions were declared but never defined. Let's just remove them.
- effect_upload_shader_params
- ep_param_writevar
- effect_upload_params
2023-07-01 00:39:13 -07:00
Norihiro Kamae
fa02582db6 libobs/graphics: Define DARRAY macro types used in effect 2023-07-01 00:39:13 -07:00
Lain
106c7aa61f Update copyrights/names 2023-05-20 01:31:18 -07:00
Jim
e9ef38e3d3 Merge pull request #7978 from jpark37/dxgi-display-sdr-on-hdr
libobs-d3d11,win-capture: Add Force SDR for DXGI duplicator
2023-03-20 01:43:14 -07:00
PatTheMav
e23455dc74 libobs: Fix device functions not marked as EXPORT
As clang and gcc use "default" visibility (as in "not hidden") when
no visibility is specified, all functions are implicitly exported.

When changing default visibility to "hidden", the corresponding symbols
are not exposed anymore and linking fails. This PR updates all
functions signatures that were added in recent commits but not set to
be EXPORTed.

Also makes required OpenGL imports for texture sharing on macOS
mandatory.
2023-03-01 12:02:33 -05:00
jpark37
7bfde66578 libobs-d3d11: Support color spaces for duplicator
Need this plumbing to make decisions about duplicator colors.
2023-02-19 11:40:32 -08:00
PatTheMav
fb7a9edadc libobs: Fix non-exhaustive switch statements 2023-02-18 15:22:33 -08:00
Norihiro Kamae
2b4bc03b4c libobs/graphics: Remove unused macros for inputs 2023-01-28 19:03:55 -08:00
Norihiro Kamae
d18a6f1039 libobs/graphics: Remove unused macros
The macros BOUNDS_MAX_X, BOUNDS_MAX_Y, and BOUNDS_MAX_Z are never used
and they are never defined how to use.
2023-01-28 19:03:55 -08:00
Jan Beich
c082c4a74d libobs/graphics: Enable DMABUF on FreeBSD and DragonFly
Required under Wayland (wlrobs) on FreeBSD and DragonFly. DMABUF was
already partially exposed after c50c625555.
2023-01-24 11:50:13 -05:00
tytan652
cf5c68b773 UI,libobs,libobs-opengl,obs-ffmpeg: Remove unneeded cast in switches
Those casts were usually used to workaround switch warnings.

Also adds default to OBS frontend event switches that had this
workaround.
2023-01-16 11:52:26 +01:00
jpark37
2a76ffaf02 libobs/graphics: Precompute more accurate matrix
This is generated with .NET BigInteger fractions, and late divide.
2022-10-05 08:36:29 -07:00
Norihiro Kamae
33e6ad3cc9 libobs: Remove unnecessary UTF characters 2022-08-13 00:49:17 -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
tytan652
17ba8359e4 deps,libobs,plugins: Fix discarded-qualifiers warnings with FFmpeg 5 2022-07-22 08:50:36 -04:00
tytan652
348cf1b872 libobs: Remove unused parameters 2022-07-20 08:21:20 +02:00
PatTheMav
ff7f756886 libobs: Explicitly mark variables as unused 2022-07-10 09:59:55 +10:00
Kurt Kartaltepe
d78b27961c libobs-opengl: Add create_texture_from_pixmap for EGL
create_texture_from_pixmap is only implemented for X11/EGL where it will
bind the provided X11 pixmap to a texture with glEGLImageTargetTexture2DOES
2022-05-15 09:08:53 -03:00
jpark37
4af20cf080 libobs/graphics: Add color space and WIC support
Only add support for PQ and CCCS JXR images, e.g. Xbox Series X, and
Xbox Game Bar screenshots on Windows.
2022-05-08 15:25:01 -07:00
PatTheMav
d0d0fe00d8 libobs: Fix compiler warnings 2022-05-04 12:09:04 -04:00
VodBox
6d0e61d40a libobs: Orient images based on EXIF metadata 2022-05-04 01:58:40 -07:00
jpark37
06111d5b10 libobs: Add high-precision sRGB support 2022-04-08 17:19:23 -07:00
wangshaohui
db8145e8a2 obs-ffmpeg, win-dshow, deps/media-playback: Use recommended API for AVCodecContext 2022-04-07 01:59:30 -07:00
wangshaohui
1ec70ddf2b libobs: Fix image source not loading upper case file extensions 2022-04-07 01:58:13 -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
16637baf88 libobs/graphics: Add gs_texrender_get_format 2022-03-08 12:56:35 -08:00
obiwac
c50c625555 libobs/graphics: gs_query_dmabuf_* on FreeBSD too 2022-02-26 15:36:08 -08:00