Bug 25921 - glReadPixels to PBOs not reliable (seems related to 1x1 FBOs being read from)
Summary: glReadPixels to PBOs not reliable (seems related to 1x1 FBOs being read from)
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: git
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Eric Anholt
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-06 13:41 UTC by bob@o-hand.com
Modified: 2010-01-26 16:31 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description bob@o-hand.com 2010-01-06 13:41:18 UTC
In adding support for asynchronous picking in Clutter we are redirecting our glReadPixel requests into PBOs so we don't block the CPU.

The renders for picking used to be done to the ClutterStage back buffer and just never presented, but we've now given pick renders a dedicated framebuffer object for rendering. So we don't waste too much memory though we only allocate a 1x1 FBO and we fiddle the projection matrix before rendering the pick scene so that the point of interest lands on the FBO.

The branch for Clutter that implements this (async-pbo-picking-uprof-2010-01-06) seems to run as expected if running through the software rasterizer via LIBGL_ALWAYS_SOFTWARE=1. It also seems to run if I use a full size FBO instead of 1x1 or if I disable the use of PBOs and instead issue synchronous glReadPixel requests instead.

Misc notes:
- I'm just using clutter/tests/interactive/test-actors to verify this.
- exporting COGL_DEBUG=read-pixels is a quick way to get Cogl to print out the value of the first pixel read for each cogl_read_pixels or _cogl_read_pixels_finish call.
- exporting COGL_DEBUG=disable-pbos is a quick way to make Cogl fallback to synchronous glReadPixel requests.
- exporting CLUTTER_DEBUG=dump-pick-buffers is a quick way to disable the use of a 1x1 FBO (though I recommend #if 0'ing out the call too read_pixels_to_file() in clutter-main.c:_clutter_do_pick_async() if you use this since the huge amount of IO makes this debug option very slow/choppy)

mesa: Jesse's git master: 762660de244a05
drm: fd.o master: 5dbc1b333b856
kernel: drm-intel-next: 4f8d619cc3ab805
xserver: Jesse's git from last month
hardware: X61s i965
Comment 1 bob@o-hand.com 2010-01-12 07:48:35 UTC
(In reply to comment #0)
> In adding support for asynchronous picking in Clutter we are redirecting our
> glReadPixel requests into PBOs so we don't block the CPU.
> 
> The renders for picking used to be done to the ClutterStage back buffer and
> just never presented, but we've now given pick renders a dedicated framebuffer
> object for rendering. So we don't waste too much memory though we only allocate
> a 1x1 FBO and we fiddle the projection matrix before rendering the pick scene
> so that the point of interest lands on the FBO.
> 
> The branch for Clutter that implements this
> (async-pbo-picking-uprof-2010-01-06) seems to run as expected if running
> through the software rasterizer via LIBGL_ALWAYS_SOFTWARE=1. It also seems to
> run if I use a full size FBO instead of 1x1 or if I disable the use of PBOs and
> instead issue synchronous glReadPixel requests instead.
> 
> Misc notes:
> - I'm just using clutter/tests/interactive/test-actors to verify this.
> - exporting COGL_DEBUG=read-pixels is a quick way to get Cogl to print out the
> value of the first pixel read for each cogl_read_pixels or
> _cogl_read_pixels_finish call.
> - exporting COGL_DEBUG=disable-pbos is a quick way to make Cogl fallback to
> synchronous glReadPixel requests.
> - exporting CLUTTER_DEBUG=dump-pick-buffers is a quick way to disable the use
> of a 1x1 FBO (though I recommend #if 0'ing out the call too
> read_pixels_to_file() in clutter-main.c:_clutter_do_pick_async() if you use
> this since the huge amount of IO makes this debug option very slow/choppy)
> 
> mesa: Jesse's git master: 762660de244a05
> drm: fd.o master: 5dbc1b333b856
> kernel: drm-intel-next: 4f8d619cc3ab805
> xserver: Jesse's git from last month
> hardware: X61s i965
> 

I've just rebased this branch against master and renamed it since uprof support is in master now. Please refer to the "async-pbo-picking" branch instead.
Comment 2 Eric Anholt 2010-01-26 16:31:06 UTC
Wrote two new testcases for piglit and committed the resulting fix.  Should fix this bug.

commit 9c3329e4ec8061316291f934ecb70740dfb8e767
Author: Eric Anholt <eric@anholt.net>
Date:   Tue Jan 26 16:25:15 2010 -0800

    pbo-readpixels-small: Companion testcase to fbo-pbo-readpixels-small.

commit c86f764e3d11b72f4aba8fd743c8cdfa6fe166ee
Author: Eric Anholt <eric@anholt.net>
Date:   Tue Jan 26 16:08:46 2010 -0800

    fbo-pbo-readpixels-small: New testcase for bug #25921 found by clutter.

commit 63b10e8fe71c1de5b0ee9aac72fd7303551f59a0
Author: Eric Anholt <eric@anholt.net>
Date:   Tue Jan 26 16:22:10 2010 -0800

    intel: Fix PBO blit ReadPixels from an FBO.
    
    Bug #25921 -- clutter PBO usage gave unreliable results.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.