Brian Paul wrote:
Stephane Marchesin wrote:
Hi,
The attached patch adds readpixel acceleration to the r100 based on what's done for the r200.
This speeds-up readpix by a factor of 2 on x86, and much more on non-x86 systems which don't benefit from Ian's patch (like 8 times on itanium 2).
I only glanced over the patch but I think that the _clip_pixelrect() routine is wrong.
It doesn't use/observe the GL_PACK_SKIP_ROWS and GL_PACK_SKIP_PIXELS parameters. They determine where the image starts in the user's destination buffer.
Also, suppose we clip the ReadPixels against the left edge of the screen (or window), that means we effectively need to adjust the GL_PIXEL_SKIP_PIXELS parameter so the pixels which are read get put into the correct position in the dest buffer.
Someone should test with Mesa/demos/readpix.c - move the window off the left edge of the screen, then move it to the right a little. The 2nd and 3rd images should show undefined pixels for the region of the 1st image that's off-screen.
The _swrast_clip_pixelrect() routine in s_drawpix.c adjusts the SKIP_PIXELS and SKIP_ROWS parameters to compensate for clipping.
The xmesa_DrawPixels_8R8G8B() routine in xm_dd.c shows how set up for and call the _swrast_clip_pixelrect() function.
Unfortunately, I just tested Mesa/demos/readpix with the Xlib driver and it appears to do top/bottom clipping somewhat wrong (sigh). I'll look into that.
Oops, I was accidentally using NVIDIA's driver at the time. Looks like their driver has the bug.
But, Mesa has a (different) bug. First, press 'f' to select front-buffer reading/drawing. Then, test clipping against the left edge of the screen. The middle image turns black. It looks like XGetImage() returns NULL when the source image is clipped. I think I can fix that.
I'll be checking in a fix for this soon.
I've replaced the _swrast_clip_pixelrect() functions with two new functions: _mesa_clip_readpixels() and _mesa_clip_drawpixels(). The main difference is the later one obeys the scissor rectangle.
The DRI drivers might use _mesa_clip_readpixels() but a second stage of clipping which takes place in screen space (instead of window space) is needed too. Otherwise, someone could try to read pixels outside of the framebuffer's bounds.
I'd suggest writing a screen-space clipping routine and putting it in the src/mesa/drivers/common/ or src/mesa/drivers/dri/common/ directory.
-Brian
------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click -- _______________________________________________ Dri-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dri-devel
