glReadPixel cost too much cpu

51 views
Skip to first unread message

宋嘉惟

unread,
May 18, 2021, 1:10:39 PM5/18/21
to angleproject
Hello, dear Angel engineer: 

 * Background: 

    We use angel as the cross-platform rendering engine (mac & windows). Use eglCreatePbufferSurface to achieve off-screen rendering. We need to support both "texture" and "cpu buffer" formats to output rendering results. 

 * Question: 

    When the result is given through the "cpu buffer", we use glReadPixel to read the off-screen rendering result into the memory, but the cpu usage of glReadPixel is too high. When running on a macbook with an m1 chip and 8g memory, the single This api (glReadPixel) has reached 101% of the cpu occupancy.

     Is there any other way to read the texture into the cpu buffer?
     Can eglCreatePbufferFromClientBuffer or using PBO achieve this goal?

Geoff Lang

unread,
May 18, 2021, 1:58:18 PM5/18/21
to sjw27...@gmail.com, angleproject
I would look into using a PBO. glReadPixels into the PBO, create a fence, do other things until the fence has been triggered and then map the PBO to read the data.

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angleproject/e7f248b8-101e-4322-b9f2-2e6ba19d4b39n%40googlegroups.com.

Jasper St. Pierre

unread,
May 18, 2021, 7:17:21 PM5/18/21
to sjw27...@gmail.com, angleproject
Yes, you should bind a GL_PIXEL_PACK_BUFFER, glReadPixels into that
(which will copy it into a CPU-readable buffer), and then use glSync
to figure out when the copy is done, and when the CPU can read from it
with no penalty. Otherwise, the CPU will spend all of its time
busy-looping or waiting for the GPU rendering to complete.
> --
> You received this message because you are subscribed to the Google Groups "angleproject" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/angleproject/e7f248b8-101e-4322-b9f2-2e6ba19d4b39n%40googlegroups.com.



--
Jasper
Reply all
Reply to author
Forward
0 new messages