summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_pbo.c
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-04-26 13:19:28 -0500
committerNicolai Hähnle <[email protected]>2016-06-01 22:37:51 +0200
commited0e9862c56d13381f0414b5a835fd31960edfe6 (patch)
tree22e63b01c43ee3a6b09af1b6e4a77cf22f0b055d /src/mesa/state_tracker/st_pbo.c
parentf3b62d4c74414c002d25e65decb9d0bda41ab5b6 (diff)
st/mesa: implement PBO downloads for ReadPixels
v2: require PIPE_CAP_SAMPLER_VIEW_TARGET; technically only needed for some of the texture targets, but all hardware that has shader images should also have this cap. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_pbo.c')
-rw-r--r--src/mesa/state_tracker/st_pbo.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c
index f8787148ea6..ca6bdea1b66 100644
--- a/src/mesa/state_tracker/st_pbo.c
+++ b/src/mesa/state_tracker/st_pbo.c
@@ -153,6 +153,22 @@ st_pbo_addresses_pixelstore(struct st_context *st,
return true;
}
+/* For download from a framebuffer, we may have to invert the Y axis. The
+ * setup is as follows:
+ * - set viewport to inverted, so that the position sysval is correct for
+ * texel fetches
+ * - this function adjusts the fragment shader's constant buffer to compute
+ * the correct destination addresses.
+ */
+void
+st_pbo_addresses_invert_y(struct st_pbo_addresses *addr,
+ unsigned viewport_height)
+{
+ addr->constants.xoffset +=
+ (viewport_height - 1 + 2 * addr->constants.yoffset) * addr->constants.stride;
+ addr->constants.stride = -addr->constants.stride;
+}
+
/* Setup all vertex pipeline state, rasterizer state, and fragment shader
* constants, and issue the draw call for PBO upload/download.
*
@@ -530,6 +546,7 @@ st_init_pbo_helpers(struct st_context *st)
st->pbo.download_enabled =
st->pbo.upload_enabled &&
+ screen->get_param(screen, PIPE_CAP_SAMPLER_VIEW_TARGET) &&
screen->get_param(screen, PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT) &&
screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
PIPE_SHADER_CAP_MAX_SHADER_IMAGES) >= 1;