Skip to content

Commit be8e590

Browse files
tytan652RytoEX
authored andcommitted
Add workaround for hardware accel under X11
1 parent c5a2092 commit be8e590

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

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

@@ -378,6 +380,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t
378380
return;
379381

380382
struct obs_cef_video_format format = obs_cef_format_from_cef_type(info.format);
383+
uint64_t modifier = info.modifier;
381384

382385
if (format.gs_format == GS_UNKNOWN)
383386
return;
@@ -387,14 +390,19 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t
387390
uint64_t *modifiers = (uint64_t *)alloca(info.plane_count * sizeof(uint64_t));
388391
int *fds = (int *)alloca(info.plane_count * sizeof(int));
389392

393+
/* NOTE: This a workaround under X11 where the modifier is always invalid where it can mean "no modifier" in
394+
* Chromium's code. */
395+
if (obs_get_nix_platform() == OBS_NIX_PLATFORM_X11_EGL && modifier == DRM_FORMAT_MOD_INVALID)
396+
modifier = DRM_FORMAT_MOD_LINEAR;
397+
390398
for (size_t i = 0; i < kAcceleratedPaintMaxPlanes; i++) {
391399
auto *plane = &info.planes[i];
392400

393401
strides[i] = plane->stride;
394402
offsets[i] = plane->offset;
395403
fds[i] = plane->fd;
396404

397-
modifiers[i] = info.modifier;
405+
modifiers[i] = modifier;
398406
}
399407
#endif
400408

@@ -432,7 +440,7 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t
432440
#else
433441
bs->texture = gs_texture_create_from_dmabuf(bs->width, bs->height, format.drm_format, format.gs_format,
434442
info.plane_count, fds, strides, offsets,
435-
info.modifier != DRM_FORMAT_MOD_INVALID ? modifiers : NULL);
443+
modifier != DRM_FORMAT_MOD_INVALID ? modifiers : NULL);
436444
#endif
437445
UpdateExtraTexture();
438446
obs_leave_graphics();

0 commit comments

Comments
 (0)