mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 22:50:57 +00:00
Use DMA_BUF_IOCTL_SYNC to synchronize swframe copies
This commit is contained in:
@@ -10,6 +10,8 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include <libdrm/drm_fourcc.h>
|
#include <libdrm/drm_fourcc.h>
|
||||||
|
#include <linux/dma-buf.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
// Special Rockchip type
|
// Special Rockchip type
|
||||||
#ifndef DRM_FORMAT_NA12
|
#ifndef DRM_FORMAT_NA12
|
||||||
@@ -768,6 +770,11 @@ bool DrmRenderer::mapSoftwareFrame(AVFrame *frame, AVDRMFrameDescriptor *mappedF
|
|||||||
auto &layer = mappedFrame->layers[0];
|
auto &layer = mappedFrame->layers[0];
|
||||||
layer.format = drmFormat;
|
layer.format = drmFormat;
|
||||||
|
|
||||||
|
// Prepare to write to the dumb buffer from the CPU
|
||||||
|
struct dma_buf_sync sync;
|
||||||
|
sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_WRITE;
|
||||||
|
ioctl(drmFrame->primeFd, DMA_BUF_IOCTL_SYNC, &sync);
|
||||||
|
|
||||||
int lastPlaneSize = 0;
|
int lastPlaneSize = 0;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (frame->data[i] != nullptr) {
|
if (frame->data[i] != nullptr) {
|
||||||
@@ -811,6 +818,10 @@ bool DrmRenderer::mapSoftwareFrame(AVFrame *frame, AVDRMFrameDescriptor *mappedF
|
|||||||
lastPlaneSize = drmFrame->pitch * planeHeight;
|
lastPlaneSize = drmFrame->pitch * planeHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// End the CPU write to the dumb buffer
|
||||||
|
sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_WRITE;
|
||||||
|
ioctl(drmFrame->primeFd, DMA_BUF_IOCTL_SYNC, &sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user