Skip to content

Commit

Permalink
headless/wayland: emit present events after commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Jan 28, 2025
1 parent 7fe0069 commit a0553cd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/allocator/GBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ static SDRMFormat guessFormatFrom(std::vector<SDRMFormat> formats, bool cursor,
For cursors, don't, as these almost never support that.
*/
if (!scanout) {
if (auto it =
std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB2101010 || f.drmFormat == DRM_FORMAT_ABGR2101010; });
if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB2101010 || f.drmFormat == DRM_FORMAT_ABGR2101010; });
it != formats.end())
return *it;
}
Expand All @@ -36,13 +35,11 @@ static SDRMFormat guessFormatFrom(std::vector<SDRMFormat> formats, bool cursor,
}

if (!scanout || cursor /* don't set opaque for cursor plane */) {
if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB8888 || f.drmFormat == DRM_FORMAT_ABGR8888; });
it != formats.end())
if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB8888 || f.drmFormat == DRM_FORMAT_ABGR8888; }); it != formats.end())
return *it;
}

if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB8888 || f.drmFormat == DRM_FORMAT_XBGR8888; });
it != formats.end())
if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB8888 || f.drmFormat == DRM_FORMAT_XBGR8888; }); it != formats.end())
return *it;

for (auto const& f : formats) {
Expand Down
1 change: 1 addition & 0 deletions src/backend/Headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ bool Aquamarine::CHeadlessOutput::commit() {
events.commit.emit();
state->onCommit();
needsFrame = false;
events.present.emit(IOutput::SPresentEvent{.presented = true});
return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/backend/Wayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ void Aquamarine::CWaylandOutput::sendFrameAndSetCallback() {
void Aquamarine::CWaylandOutput::onFrameDone() {
waylandState.frameCallback.reset();
readyForFrameCallback = false;
events.present.emit(IOutput::SPresentEvent{.presented = true});

// FIXME: this is wrong, but otherwise we get bugs.
// thanks @phonetic112
Expand Down
25 changes: 20 additions & 5 deletions src/backend/drm/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,26 @@ EGLImageKHR CDRMRenderer::createEGLImage(const SDMABUFAttrs& attrs) {
EGLint pitch;
EGLint modlo;
EGLint modhi;
} attrNames[4] = {
{.fd = EGL_DMA_BUF_PLANE0_FD_EXT, .offset = EGL_DMA_BUF_PLANE0_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE0_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT},
{.fd = EGL_DMA_BUF_PLANE1_FD_EXT, .offset = EGL_DMA_BUF_PLANE1_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE1_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT},
{.fd = EGL_DMA_BUF_PLANE2_FD_EXT, .offset = EGL_DMA_BUF_PLANE2_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE2_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT},
{.fd = EGL_DMA_BUF_PLANE3_FD_EXT, .offset = EGL_DMA_BUF_PLANE3_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE3_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT}};
} attrNames[4] = {{.fd = EGL_DMA_BUF_PLANE0_FD_EXT,
.offset = EGL_DMA_BUF_PLANE0_OFFSET_EXT,
.pitch = EGL_DMA_BUF_PLANE0_PITCH_EXT,
.modlo = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT,
.modhi = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT},
{.fd = EGL_DMA_BUF_PLANE1_FD_EXT,
.offset = EGL_DMA_BUF_PLANE1_OFFSET_EXT,
.pitch = EGL_DMA_BUF_PLANE1_PITCH_EXT,
.modlo = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT,
.modhi = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT},
{.fd = EGL_DMA_BUF_PLANE2_FD_EXT,
.offset = EGL_DMA_BUF_PLANE2_OFFSET_EXT,
.pitch = EGL_DMA_BUF_PLANE2_PITCH_EXT,
.modlo = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT,
.modhi = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT},
{.fd = EGL_DMA_BUF_PLANE3_FD_EXT,
.offset = EGL_DMA_BUF_PLANE3_OFFSET_EXT,
.pitch = EGL_DMA_BUF_PLANE3_PITCH_EXT,
.modlo = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT,
.modhi = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT}};

for (int i = 0; i < attrs.planes; i++) {
attribs.push_back(attrNames[i].fd);
Expand Down

0 comments on commit a0553cd

Please sign in to comment.