*
**************************************************************************/
+#include "main/bufferobj.h"
#include "main/image.h"
#include "main/pbo.h"
#include "main/imports.h"
return FALSE;
}
+static bool
+try_pbo_readpixels(struct st_context *st, struct st_renderbuffer *strb,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ enum pipe_format src_format, enum pipe_format dst_format,
+ const struct gl_pixelstore_attrib *pack, void *pixels)
+{
+ return false;
+}
+
/**
* This uses a blit to copy the read buffer to a texture format which matches
* the format and type combo and then a fast read-back is done using memcpy.
goto fallback;
}
- /* We are creating a texture of the size of the region being read back.
- * Need to check for NPOT texture support. */
- if (!screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES) &&
- (!util_is_power_of_two(width) ||
- !util_is_power_of_two(height))) {
- goto fallback;
- }
-
/* If the base internal format and the texture format don't match, we have
* to use the slow path. */
if (rb->_BaseFormat !=
goto fallback;
}
- /* See if the texture format already matches the format and type,
- * in which case the memcpy-based fast path will likely be used and
- * we don't have to blit. */
- if (_mesa_format_matches_format_and_type(rb->Format, format,
- type, pack->SwapBytes, NULL)) {
- goto fallback;
- }
-
if (_mesa_readpixels_needs_slow_path(ctx, format, type, GL_TRUE)) {
goto fallback;
}
- if (needs_integer_signed_unsigned_conversion(ctx, format, type)) {
- goto fallback;
- }
-
/* Convert the source format to what is expected by ReadPixels
* and see if it's supported. */
src_format = util_format_linear(src->format);
goto fallback;
}
+ if (_mesa_is_bufferobj(pack->BufferObj)) {
+ if (try_pbo_readpixels(st, strb, x, y, width, height,
+ src_format, dst_format,
+ pack, pixels))
+ return;
+ }
+
+ /* We are creating a texture of the size of the region being read back.
+ * Need to check for NPOT texture support. */
+ if (!screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES) &&
+ (!util_is_power_of_two(width) ||
+ !util_is_power_of_two(height))) {
+ goto fallback;
+ }
+
+ /* See if the texture format already matches the format and type,
+ * in which case the memcpy-based fast path will likely be used and
+ * we don't have to blit. */
+ if (_mesa_format_matches_format_and_type(rb->Format, format,
+ type, pack->SwapBytes, NULL)) {
+ goto fallback;
+ }
+
+ if (needs_integer_signed_unsigned_conversion(ctx, format, type)) {
+ goto fallback;
+ }
+
/* create the destination texture */
memset(&dst_templ, 0, sizeof(dst_templ));
dst_templ.target = PIPE_TEXTURE_2D;