summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-04-26 11:33:33 -0500
committerNicolai Hähnle <[email protected]>2016-06-01 22:37:48 +0200
commitf3b62d4c74414c002d25e65decb9d0bda41ab5b6 (patch)
tree477842d934901aaebff4752ba2507bc6b1b8f871 /src/mesa/state_tracker
parent1cb4be94ae1b0ba83a941e707e962110c44b3f1a (diff)
st/mesa: hook up a no-op try_pbo_readpixels
For better bisectability given that the order of some of the fallback tests in the blit path are rearranged. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c57
1 files changed, 37 insertions, 20 deletions
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 393b881ea4c..62ddc99a947 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -25,6 +25,7 @@
*
**************************************************************************/
+#include "main/bufferobj.h"
#include "main/image.h"
#include "main/pbo.h"
#include "main/imports.h"
@@ -68,6 +69,15 @@ needs_integer_signed_unsigned_conversion(const struct gl_context *ctx,
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.
@@ -120,14 +130,6 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
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 !=
@@ -135,22 +137,10 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
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);
@@ -177,6 +167,33 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
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;