From 36fb79024392d3d39ceab90dfe2639646f87b95a Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sun, 16 Feb 2020 17:11:29 +0900 Subject: [PATCH] d3d11videosink: Ensure upload staging texture to fallback render texture gst_video_frame_copy will copy input frame to stating texture of fallback frame. Then, we need to map fallback texture with GST_MAP_D3D11 flag to upload the staging texture to render texture. Otherwise the render texture wouldn't be updated. --- sys/d3d11/gstd3d11videosink.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/d3d11/gstd3d11videosink.c b/sys/d3d11/gstd3d11videosink.c index 3eb9e35a50..84297faec1 100644 --- a/sys/d3d11/gstd3d11videosink.c +++ b/sys/d3d11/gstd3d11videosink.c @@ -735,6 +735,7 @@ gst_d3d11_video_sink_upload_frame (GstD3D11VideoSink * self, GstBuffer * inbuf, { GstVideoFrame in_frame, out_frame; gboolean ret; + gint i; if (!gst_video_frame_map (&in_frame, &self->info, inbuf, GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) @@ -751,6 +752,22 @@ gst_d3d11_video_sink_upload_frame (GstD3D11VideoSink * self, GstBuffer * inbuf, gst_video_frame_unmap (&in_frame); gst_video_frame_unmap (&out_frame); + if (ret) { + /* map to upload staging texture to render texture */ + for (i = 0; i < gst_buffer_n_memory (outbuf); i++) { + GstMemory *mem; + GstMapInfo map; + + mem = gst_buffer_peek_memory (outbuf, i); + if (!gst_memory_map (mem, &map, (GST_MAP_READ | GST_MAP_D3D11))) { + GST_ERROR_OBJECT (self, "cannot upload staging texture"); + ret = FALSE; + break; + } + gst_memory_unmap (mem, &map); + } + } + return ret; /* ERRORS */