Commit Graph

322 Commits (b3870476324e2dc79a9d30371a1199376bcd0ad7)

Author SHA1 Message Date
Norihiro Kamae 76f7a0c1c0 libobs-opengl: Use PBO in device_stage_texture on macOS
Previously glReadPixels was used to stage surfaces because Mac OS X at
that time supported some hardwares that didn't implement glGetTexImage.
However, OBS Studio now requires OpenGL 3.3 so that glGetTexImage on
macOS should work the same as on Linux.
The code using glReadPixels was introduced at 30af7dc. The minimum
requirements of the original OBS Studio for OSX was 10.8, which supports
hardwares with OpenGL 1.4. However, the function glGetTexImage requires
OpenGL >= 2.0.
2021-11-02 06:05:18 -07:00
Ryan Foster 5f68991911 clang-format: Commit file changes for clang-format 12 2021-10-13 20:00:04 +11:00
jpark37 3c45ae2e9d libobs, libobs-opengl: Consistent near/far undef 2021-10-10 19:12:45 -07:00
columbarius e071b5e300 libobs-opengl: Load EGL via Glad on Wayland platform
We need to have EGL extensions loaded when dealing with DMA-BUFs.

EGL_EXT_image_dma_buf_import: This extension is required to import
DMA-BUFs with the modifier-less path. It is limited to buffers with 3
planes. [1]

EGL_EXT_image_dma_buf_import_modifiers: This extension is required to
import DMA-BUFs with an explicit modifier. It raises the limit of buffer
planes to 4, which is the maximum planecount for DMA-BUFs. [2]

[1] https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
[2] https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt
2021-09-21 12:57:49 -03:00
jpark37 ebfbe1a78e libobs-opengl: Fix GS_R10G10B10A2 format 2021-07-11 08:26:29 -07:00
Kurt Kartaltepe 705a47b0e4 libobs, libobs-opengl: add drm format param
This adds the drmbuf format as a parameter separate from the obs texture
format that will be used. drmbuf's may have a variety of formats that we
need to pass correctly to get a usable texture which may correspond to
multi-platform texture formats.
2021-03-29 17:00:31 -03:00
Georges Basile Stavracas Neto 7867d16e6b libobs-opengl: Implement DMA-BUF importing on EGL renderers
Implement device_texture_create_from_dmabuf for EGL/X11 and EGL/Wayland.
The code is shared between them, in a new gl-egl-common.c file.

This is currently limited to a few common RGB(A) formats for now, which
seems to cover most use cases.
2021-02-13 19:48:56 -03:00
Georges Basile Stavracas Neto f7a55f45fd libobs/graphics: Add Linux-only gs_texture_create_from_dmabuf()
DMA-BUF is a widespread Linux buffer sharing mechanism. It is what's
commonly used zero-copy screen sharing by Wayland compositors.

Add a new 'device_texture_create_from_dmabuf' vfunc to gs_exports,
and stub implementations to libobs-opengl. Add a new public method
gs_texture_create_from_dmabuf() that calls this vfunc.
2021-02-13 19:13:54 -03:00
Georges Basile Stavracas Neto eab27571d2 libobs-opengl: Introduce an EGL/Wayland renderer
Introduce a new Wayland/EGL renderer.
2021-02-09 09:39:17 -03:00
Georges Basile Stavracas Neto 137966e01f libobs-opengl: Try to use the platform display if available
We need to ensure we're running all X11 code on the same display.
2021-02-09 09:39:04 -03:00
Georges Basile Stavracas Neto 2b3cb54771 libobs: Add a Wayland platform
Introduce the OBS_NIX_PLATFORM_WAYLAND enum value, and try to detect
it when OBS Studio runs by looking into the platform name.
2021-02-09 09:39:04 -03:00
Georges Basile Stavracas Neto 27d0182fdb UI: Set the Unix platform on startup
Move the OBS_USE_EGL environment variable check to obs-app.cpp,
and set the OBS platform to be either OBS_NIX_PLATFORM_X11_GLX
or OBS_NIX_PLATFORM_X11_EGL.
2021-02-01 19:05:11 -03:00
Georges Basile Stavracas Neto 2fd8a6df55 libobs-opengl: Introduce the X11/EGL winsys
Introduce the EGL/X11 winsys, and use it when the OBS_USE_EGL environment
variable is defined. This variable is only temporary, for future commits
will add a proper concept of platform.

All the EGL/X11 code is authored by Ivan Avdeev <me@w23.ru>.
2021-02-01 19:03:14 -03:00
Georges Basile Stavracas Neto 647415ec4f libobs-opengl: Factor out GLX winsys
Move the GLX-related code to gl-x11-glx, and introduce gl-nix as
a winsys-agnostic abstraction layer. gl-nix serves as the runtime
selector of which winsys going to be used. Only the X11/GLX winsys
is available now, but later commits will introduce the X11/EGL
winsys as well.

The gl-nix code was originally written by Jason Francis <cycl0ps@tuta.io>
2021-02-01 19:03:14 -03:00
Georges Basile Stavracas Neto 83ae6f6f43 libobs-opengl: Rename gl-x11.c to gl-x11-glx.c
This is in preparation for the future abstraction layer (gl-x11-*)
and also to match the actual name of the windowing system. When
running under X11, we can glue OpenGL through GLX or EGL, so the
new file name matches that now.
2021-02-01 19:03:14 -03:00
jpark37 dd62bd05fb libobs-opengl: Fix unused parameters 2021-01-29 21:50:19 -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 7427272062 libobs-opengl: SRGB-safe GLSL path for raw loads
texelFetch ignores SKIP_DECODE_EXT. Replace implementation with
textureSize and textureLod.
2021-01-19 12:24:36 -08:00
PatTheMav 61ea6e0247
libobs: Add texture sharing support for macOS/OpenGL 2020-12-18 17:44:03 +01:00
PatTheMav fb27900e94 CI: Remove explicit LANGUAGE flags for cmake 3.19+ 2020-11-21 12:00:52 -08:00
Jim 04e6a39de9
Merge pull request #2551 from jpark37/cube-lut-enhance
Implement CUBE LUT domain properly, tetrahedral interpolation for 3D LUTs
2020-05-20 18:09:56 -07:00
jp9000 7993179466 cmake: Add cmake folders 2020-05-13 06:52:37 -07:00
jpark37 0a296bb12f libobs-opengl: Lock Mac parent context during present
Parent context lock keeps GL commands serialized.

Fixes race that causes crash when resizing multiview.
2020-05-02 12:00:11 -07:00
Colin Edwards d795905138
Merge pull request #2749 from jpark37/gl-viewport-flip
libobs-opengl: Fix viewport flip
2020-04-19 15:56:17 -05:00
jpark37 44ebde553d libobs-opengl: Fix viewport flip
Flip viewport in coordination with update_viewproj_matrix.
2020-04-18 22:13:03 -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
jp9000 2a318d915f libobs-opengl: Fix atan2 HLSL->GLSL transpile 2020-04-07 23:59:14 -07:00
jp9000 6ca52db8ce libobs-opengl: Add sincos to HLSL->GLSL transpile 2020-04-07 23:59:14 -07:00
jpark37 ff2b07c032 libobs-opengl: Support 3D texelFetch 2020-03-23 20:38:43 -07:00
jpark37 1733705070 libobs-opengl: Fix Mac VAO created without context 2020-02-24 22:08:28 -08:00
Jim d75245f017
Merge pull request #2264 from jpark37/mac-context-share
Fix OpenGL thread-safety on Mac to use latest Xcode
2020-02-05 14:33:27 -08:00
jpark37 50c53e3c39 libobs-opengl: Fix missing GL_HALF_FLOAT usages 2020-01-12 20:02:24 -08:00
jpark37 882687934c libobs-opengl: Fix volume texture leak 2020-01-04 01:28:16 -08:00
jpark37 846be2063c libobs-opengl: Don't allow volume render targets
Unlikely to be necessary. Disable for simplicity.
2020-01-01 12:39:53 -08:00
jpark37 9f330050ef libobs-opengl: OpenGL thread-safety on Mac
Attempt to fix threading issues that cause OBS to force-crash when
compiled with latest Xcode. There are two places where the new SDK
introduces a force-crash because operations are not happening on the
main thread: when we modify the context view to switch swap chains, and
when we resize a swap chain.

Instead of using just one context for all rendering, we create an
additional context for each swap chain, set each view once on
initialization, and switch contexts only in present to blit the final
framebuffer. This is an extra copy, but it's pretty hairy to optimize
away, and it's not worth potential regressions just to speed up Mac.

For resizing, we schedule the update code to run on the main thread from
the render thread. Ideally, we wouldn't have to round trip the logic
from main thread to graphics thread and back, but I don't think we want
to hack up the interface for this, especially since OpenGL will give way
to Metal soon enough.
2019-12-26 01:45:48 -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 3e01fdf3e5
Merge pull request #2116 from jpark37/begin-frame
libobs: Add gs_begin_frame for duplicators
2019-10-15 22:23:34 -07:00
Matt Gajownik 51be039cf8 CMake: Build Windows modules with file descriptors 2019-10-15 21:34:12 +11:00
Jim 09c7ec487b
Merge pull request #2064 from jpark37/bgra-swap-chain
D3D swap chain enhancements
2019-10-12 20:54:33 -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
jpark37 6eca70a529 libobs-opengl: Require OpenGL 3.3 instead of 3.2
There don't appear to be any GPUs that support 3.2, but not 3.3. GLSL
330 maps to HLSL Shader Model 4, so this will theoretically make shaders
programs less likely to diverge, particularly for behavior around NaNs.
2019-09-12 21:28:26 -07:00
jpark37 2ae9d6f683 libobs-opengl: Support BGRA swap chains on Windows 2019-09-05 23:34:23 -07:00
jp9000 bf41fd5a6b libobs: Add graphics API to get graphics object pointer 2019-08-29 12:43:10 -07:00
Jim 021defd962
Merge pull request #2036 from jpark37/gl-warnings
libobs-opengl: Fix Clang warnings
2019-08-17 12:11:46 -07:00
jpark37 2af98bf483 libobs-opengl: Fix Clang warnings 2019-08-17 11:02:03 -07:00
jpark37 a6af549155 libobs-opengl: Redundant cast 2019-08-17 08:48:28 -07:00
jpark37 4aaef353d4 libobs-opengl: Fix gl_error_to_str
Tweaked function to address some issues: compiler warnings, skipped
entries, and type safety.
2019-08-12 08:05:38 -07:00
Kurt Kartaltepe 9bc39c7617 libobs-opengl: Fix DUMMY textures left bound 2019-08-11 19:40:24 -07:00
Kurt Kartaltepe 491b6ec035 Revert "libobs-opengl: Add GS_RGBX format"
This reverts commit d940b9e580.
2019-08-11 18:30:28 -07:00
Jim 0546d18855
Merge pull request #1934 from kkartaltepe/alpha-linux
linux-capture: Correct XCompCap glxFBConfigs alpha check
2019-08-11 05:00:35 -07:00