mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2025-01-09 17:58:43 +00:00
Use DMA_BUF_IOCTL_SYNC to synchronize swframe copies
This commit is contained in:
parent
1d0b65f798
commit
c98289a9e7
1 changed files with 11 additions and 0 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue