Skip to content

Commit

Permalink
update wlroots dep
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Mar 3, 2023
1 parent fe007fd commit a34b747
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 37 deletions.
44 changes: 8 additions & 36 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,48 +746,20 @@ void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) {
return;
}

const auto RENDERERDRMFD = wlr_renderer_get_drm_fd(g_pCompositor->m_sWLRRenderer);
const auto BACKENDDRMFD = wlr_backend_get_drm_fd(g_pCompositor->m_sWLRBackend);
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);

if (RENDERERDRMFD < 0 || BACKENDDRMFD < 0)
return;

auto deviceIDFromFD = [](int fd, unsigned long* deviceID) -> bool {
struct stat stat;
if (fstat(fd, &stat) != 0) {
return false;
}
*deviceID = stat.st_rdev;
return true;
const wlr_linux_dmabuf_feedback_v1_init_options INIT_OPTIONS = {
.main_renderer = g_pCompositor->m_sWLRRenderer,
.scanout_primary_output = PMONITOR->output,
};

unsigned long rendererDevice, scanoutDevice;
if (!deviceIDFromFD(RENDERERDRMFD, &rendererDevice) || !deviceIDFromFD(BACKENDDRMFD, &scanoutDevice))
return;

const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
wlr_linux_dmabuf_feedback_v1 feedback = {0};

const auto POUTPUTFORMATS = wlr_output_get_primary_formats(PMONITOR->output, WLR_BUFFER_CAP_DMABUF);
if (!POUTPUTFORMATS)
if (!wlr_linux_dmabuf_feedback_v1_init_with_options(&feedback, &INIT_OPTIONS))
return;

const auto PRENDERERFORMATS = wlr_renderer_get_dmabuf_texture_formats(g_pCompositor->m_sWLRRenderer);
wlr_drm_format_set scanoutFormats = {0};

if (!wlr_drm_format_set_intersect(&scanoutFormats, POUTPUTFORMATS, PRENDERERFORMATS))
return;

const wlr_linux_dmabuf_feedback_v1_tranche TRANCHES[] = {
{.target_device = scanoutDevice, .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT, .formats = &scanoutFormats},
{.target_device = rendererDevice, .formats = PRENDERERFORMATS}};

const wlr_linux_dmabuf_feedback_v1 FEEDBACK = {.main_device = rendererDevice, .tranches_len = sizeof(TRANCHES) / sizeof(TRANCHES[0]), .tranches = TRANCHES};

if (!wlr_linux_dmabuf_v1_set_surface_feedback(g_pCompositor->m_sWLRLinuxDMABuf, g_pXWaylandManager->getWindowSurface(pWindow), &FEEDBACK)) {
Debug::log(ERR, "Error in scanout mode setting: wlr_linux_dmabuf_v1_set_surface_feedback returned false.");
}

wlr_drm_format_set_finish(&scanoutFormats);
wlr_linux_dmabuf_v1_set_surface_feedback(g_pCompositor->m_sWLRLinuxDMABuf, g_pXWaylandManager->getWindowSurface(pWindow), &feedback);
wlr_linux_dmabuf_feedback_v1_finish(&feedback);

Debug::log(LOG, "Scanout mode ON set for %x", pWindow);
}
Expand Down
2 changes: 1 addition & 1 deletion subprojects/wlroots
Submodule wlroots updated from 677a3f to 5ae17d

0 comments on commit a34b747

Please sign in to comment.