Skip to content

Commit

Permalink
Add workaround for hardware accel under X11
Browse files Browse the repository at this point in the history
  • Loading branch information
tytan652 committed Oct 27, 2024
1 parent 3e8bbab commit 7c2b9f2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions browser-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#endif

#if !defined(_WIN32) && !defined(__APPLE__)
#include <obs-nix-platform.h>

#include "drm-format.hpp"
#endif

Expand Down Expand Up @@ -361,6 +363,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t
return;

struct obs_cef_video_format format = obs_cef_format_from_cef_type(info.format);
uint64_t modifier = info.modifier;

if (format.gs_format == GS_UNKNOWN)
return;
Expand All @@ -370,14 +373,19 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t
uint64_t *modifiers = (uint64_t *)alloca(info.plane_count * sizeof(uint64_t));
int *fds = (int *)alloca(info.plane_count * sizeof(int));

/* NOTE: This a workaround under X11 where the modifier is always
invalid where it can mean "no modifier" in Chromium's code. */
if (obs_get_nix_platform() == OBS_NIX_PLATFORM_X11_EGL && modifier == DRM_FORMAT_MOD_INVALID)
modifier = DRM_FORMAT_MOD_LINEAR;

for (size_t i = 0; i < kAcceleratedPaintMaxPlanes; i++) {
auto *plane = &info.planes[i];

strides[i] = plane->stride;
offsets[i] = plane->offset;
fds[i] = plane->fd;

modifiers[i] = info.modifier;
modifiers[i] = modifier;
}
#endif

Expand Down Expand Up @@ -415,7 +423,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t
#else
bs->texture = gs_texture_create_from_dmabuf(bs->width, bs->height, format.drm_format, format.gs_format,
info.plane_count, fds, strides, offsets,
info.modifier != DRM_FORMAT_MOD_INVALID ? modifiers : NULL);
modifier != DRM_FORMAT_MOD_INVALID ? modifiers : NULL);
#endif
UpdateExtraTexture();
obs_leave_graphics();
Expand Down

0 comments on commit 7c2b9f2

Please sign in to comment.