]> git.sesse.net Git - nageru/commitdiff
Fix fence behavior in H.264 encoder.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 23 Feb 2016 00:41:44 +0000 (01:41 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 23 Feb 2016 00:41:44 +0000 (01:41 +0100)
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

index 9660a1afaf316bda61da4fda57608369f9faa139..784531663c3e6f7191f1847130b3291d34ee7203 100644 (file)
@@ -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();