[virglrenderer-devel] coherent memory access for virgl

Gerd Hoffmann kraxel at redhat.com
Wed Sep 26 10:35:43 UTC 2018


  Hi,

> For host GL buffers, the copies are done in
> {vrend_renderer_transfer_write_iov, vrend_renderer_transfer_send_iov}.
> If there are N iovecs backing the guest resource, we will have N
> copies (see vrend_write_to_iovec, vrend_read_from_iovec).

Yes.

> udmabuf could be helpful, since it bundles up the iovecs and it will
> make the N small copies into one big copy.

That isn't much of a win I guess, the amount of data copyed over will be
the same.

> udmabuf could also eliminate some copies for textures completely.

Yes, that'll be more interesting of course.

> Right now, for most
> textures, virglrenderer copies iovecs into a temporary buffer (see
> read_transfer_data), and then calls glTexSubImage2D*.

Is virglrenderer clever enough to skip the temporary buffer copy in case
it finds niov == 1 ?

> Just mmaping the udmabuf and calling glTexSubImage2D* is definite win.

Can virglrenderer just import the dmabuf as texture instead of creating
a new one and copying pixels with glTexSubImage2D?

> But making host memory guest visible will bring the worst-case buffer
> copies from 3 to 1.  For textures, if we start counting when the GPU
> buffer gets detiled, there will be 5 copies currently, 3 with udmabuf,
> and 1 with host exposed memory.

5 copies?  verbose please.  I can see three:

  (1) glTexSubImage in guest.
  (2) the temporary buffer to linearize the iov.
  (3) glTexSubImage again, this time in the host.

udmabuf will kill (2) easily.  And possibly (3) with some more effort
if virglrender gets support for importing dmabufs.

> i) virtio_gpu_resource_create_coherent -- for strictly coherent needs
> (i.e, no unmap needed)

Why no unmap?  Because they just show up in the pci bar, which the guest
driver has permanently mapped anyway?

> ii) virtio_gpu_resource_create_3d  -- may or may not be host backed
> (depends on the PCI bar size, platform-specific information -- guest
> doesn't need to know)

Hmm?  How can this work in a way which is transparent for the guest?

cheers,
  Gerd



More information about the virglrenderer-devel mailing list