Skip to content

Commit

Permalink
Add workarround for hardware accel under X11
Browse files Browse the repository at this point in the history
  • Loading branch information
tytan652 committed Sep 12, 2024
1 parent e4c3efe commit 3ee8f81
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 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 @@ -398,6 +400,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>,

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 @@ -410,14 +413,20 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>,
(uint64_t *)alloca(info.plane_count * sizeof(uint64_t));
int *fds = (int *)alloca(info.plane_count * sizeof(int));

/* NOTE: This a workarround 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 @@ -460,7 +469,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>,
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 3ee8f81

Please sign in to comment.