From 9284d85b2f5c8da5ae5555c1cf24b5af0dbcc285 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 23 Feb 2016 01:41:44 +0100 Subject: [PATCH] Fix fence behavior in H.264 encoder. This was all broken, but happened to work when all the work was done on a (single-stream) GPU anyway. It broke horribly when the CPU actually needed to look at the data (for non-zerocopy H.264 encoding). This is, as far as I know, the last fix needed to run Nageru on NVIDIA GPUs (tested with a GTX 950). Encoding is still done by Quick Sync, not NVENC. --- h264encode.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/h264encode.cpp b/h264encode.cpp index 9660a1a..7845316 100644 --- a/h264encode.cpp +++ b/h264encode.cpp @@ -1949,7 +1949,12 @@ void H264EncoderImpl::encode_frame(H264EncoderImpl::PendingFrame frame, int enco int frame_type, int64_t pts, int64_t dts) { // Wait for the GPU to be done with the frame. - glClientWaitSync(frame.fence.get(), 0, 0); + GLenum sync_status; + do { + sync_status = glClientWaitSync(frame.fence.get(), 0, 1000000000); + check_error(); + } while (sync_status == GL_TIMEOUT_EXPIRED); + assert(sync_status != GL_WAIT_FAILED); // Release back any input frames we needed to render this frame. frame.input_frames.clear(); -- 2.39.2