[Mesa-dev] [PATCH] intel: Fix ReadPixels on buffers whose width >= 32kbytes

Eric Anholt eric at anholt.net
Thu Jan 24 11:47:31 PST 2013


Paul Berry <stereotype441 at gmail.com> writes:

> When possible, glReadPixels calls are performed using the hardware
> blitter.  However, according to the Ivy Bridge PRM, Vol1 Part4,
> section 1.2.1.2 (Graphics Data Size Limitations):
>
>     The BLT engine is capable of transferring very large quantities of
>     graphics data. Any graphics data read from and written to the
>     destination is permitted to represent a number of pixels that
>     occupies up to 65,536 scan lines and up to 32,768 bytes per scan
>     line at the destination. The maximum number of pixels that may be
>     represented per scan line’s worth of graphics data depends on the
>     color depth.
>
> With an RGBA32F color buffer (which has 16 bytes per pixel) this
> imposes a maximum width of 2048 pixels.
>
> To make matters worse, if the pitch of the buffer is 32k or greater,
> intel_miptree_map_blit's call to intelEmitCopyBlit will overflow
> intelEmitCopyBlit's src_pitch and dst_pitch parameters (which are
> 16-bit signed integers).
>
> We can conveniently avoid both problems by avoiding the readpixels
> blit path when the miptree's pitch is >= 32k.
>
> Fixes gles3conform "half_float" tests when the buffer width is greater
> than 2048.

Seconding that this comment in some way should make it into the code.

One possibility that would let the spec cite live in an appropriate
place would be to move this test into intel_miptree_map_blit() and fall
back to calling intel_miptree_map_gtt() and returning.  It would also
mean we could replace the "Failed to blit" there with that same fallback
path, which would be kind of neat even though I haven't seen it get hit.

I'd actually most like to get the copy blit function's args promoted to
ints from shorts, and have checks in that function for the limits.  But
I don't want to block this fix on that.

But even if the spec cite is just added right into this patch as-is,
Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130124/b1bf0b6f/attachment.pgp>


More information about the mesa-dev mailing list