Skip to content

Commit 4f24bbc

Browse files
committed
Add workaround for hardware accel under X11
1 parent 32e744a commit 4f24bbc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

browser-client.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#endif
3232

3333
#if !defined(_WIN32) && !defined(__APPLE__)
34+
#include <obs-nix-platform.h>
35+
3436
#include "drm-format.hpp"
3537
#endif
3638

@@ -369,6 +371,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t
369371
return;
370372

371373
struct obs_cef_video_format format = obs_cef_format_from_cef_type(info.format);
374+
uint64_t modifier = info.modifier;
372375

373376
if (format.gs_format == GS_UNKNOWN)
374377
return;
@@ -378,14 +381,19 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t
378381
uint64_t *modifiers = (uint64_t *)alloca(info.plane_count * sizeof(uint64_t));
379382
int *fds = (int *)alloca(info.plane_count * sizeof(int));
380383

384+
/* NOTE: This a workaround under X11 where the modifier is always invalid where it can mean "no modifier" in
385+
* Chromium's code. */
386+
if (obs_get_nix_platform() == OBS_NIX_PLATFORM_X11_EGL && modifier == DRM_FORMAT_MOD_INVALID)
387+
modifier = DRM_FORMAT_MOD_LINEAR;
388+
381389
for (size_t i = 0; i < kAcceleratedPaintMaxPlanes; i++) {
382390
auto *plane = &info.planes[i];
383391

384392
strides[i] = plane->stride;
385393
offsets[i] = plane->offset;
386394
fds[i] = plane->fd;
387395

388-
modifiers[i] = info.modifier;
396+
modifiers[i] = modifier;
389397
}
390398
#endif
391399

@@ -423,7 +431,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t
423431
#else
424432
bs->texture = gs_texture_create_from_dmabuf(bs->width, bs->height, format.drm_format, format.gs_format,
425433
info.plane_count, fds, strides, offsets,
426-
info.modifier != DRM_FORMAT_MOD_INVALID ? modifiers : NULL);
434+
modifier != DRM_FORMAT_MOD_INVALID ? modifiers : NULL);
427435
#endif
428436
UpdateExtraTexture();
429437
obs_leave_graphics();

0 commit comments

Comments
 (0)