EXT_texture_from_pixmap should allow us to use the pixels on the GPU for doing CSC and/or encoding without first needing to copy them to RAM (via XShmGetImage
or XGetImage
as we do now)
XShmGetImage
is pretty fast but then we have to upload the data again to the graphics card (assuming we do csc on the GPU - which is the fastest option) and then download the results. Quite wasteful, especially at high res.
Here's how I think this can work.
Note: it might be easier to test this using "xpra shadow" and a full display copy since the "root window" never goes away, and we already have code to override behaviour for the root window (see GTKRootWindowModel
).
window.get_image(x, y, w, h)
in WindowSource
, we can start copying the display pixels to a PBO (maybe even asynchronously!) using glCopyTexImage2D and return an image wrapper for the PBO
driver.memcpy_htod
in nvenc
, we can just skip that part and instead use gl functions to access the GL buffer (maybe it can be done as part of the NV12 CSC step anyway - even if we have to copy it to a CUDA aligned buffer, this is no big deal)
Obviously, we'll also need fallback code for dealing with non-nvenc encoders, and lots of other little details I can't foresee..
Links:
Scheduling for 0.16
Another API we could potentially use (maybe just on win32?) is NvIFROpenGL
, for which there is zero documentation...
Only this entry in the 319.49 driver changelog:
Added the NVIDIA OpenGL-based Inband Frame Readback (NvIFROpenGL) library to the Linux driver package. This library provides a high performance, low latency interface to capture and optionally encode an individual OpenGL framebuffer. NvIFROpenGL captures pixels rendered by OpenGL only and is ideally suited to application capture and remoting.
Although DRC seems to think it's not worth it: I determined that the IFR stuff is not any faster than using PBOs
Re-scheduling.
Milestone renamed
Milestone renamed
For win32 we now have an API we can use #1317 "nvidia capture sdk support"
Boom! Done for NVFBC (#1317) + NVENC v8 (#1552) in r16458! Improved in r16459, made the default in r16476.
Still TODO:
Will follow up in #1597. Closing at last!
Also done for Linux in r16492: needed new NVENC kernels as Linux uses a different pixel format (XRGB vs BGRX).
Regression: #1763
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/365