diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2016-05-17 23:45:24 -0500 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2016-05-18 10:19:28 -0500 |
commit | 85bebf6650026b7e2ec11e18e1ee83be73b8fced (patch) | |
tree | ec0cd4849d5a97b74593db1a3f3b635e98e5dd68 | |
parent | fdb21bb8dad0cd5e1c1bb0bab16d60aab15667e2 (diff) |
st/mesa: add layer_offset to PBO fragment shader
This will be used to select a slice of a 3D texture.
-rw-r--r-- | src/mesa/state_tracker/st_pbo.c | 19 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_pbo.h | 1 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c index c7735f752c..31a0c195ff 100644 --- a/src/mesa/state_tracker/st_pbo.c +++ b/src/mesa/state_tracker/st_pbo.c @@ -83,6 +83,7 @@ st_pbo_addresses_setup(struct st_context *st, addr->constants.yoffset = -addr->yoffset; addr->constants.stride = addr->pixels_per_row; addr->constants.image_size = addr->pixels_per_row * addr->image_height; + addr->constants.layer_offset = 0; return true; } @@ -370,6 +371,7 @@ create_fs(struct st_context *st, bool download, enum pipe_texture_target target) struct ureg_src pos; struct ureg_src layer; struct ureg_src const0; + struct ureg_src const1; struct ureg_dst temp0; have_layer = @@ -407,6 +409,7 @@ create_fs(struct st_context *st, bool download, enum pipe_texture_target target) TGSI_INTERPOLATE_CONSTANT); } const0 = ureg_DECL_constant(ureg, 0); + const1 = ureg_DECL_constant(ureg, 1); temp0 = ureg_DECL_temporary(ureg); /* Note: const0 = [ -xoffset + skip_pixels, -yoffset, stride, image_height ] */ @@ -456,11 +459,19 @@ create_fs(struct st_context *st, bool download, enum pipe_texture_target target) ureg_MOV(ureg, ureg_writemask(temp1, TGSI_WRITEMASK_ZW), ureg_imm1u(ureg, 0)); if (have_layer) { + struct ureg_dst temp1_layer = + ureg_writemask(temp1, target == PIPE_TEXTURE_1D_ARRAY ? TGSI_WRITEMASK_Y + : TGSI_WRITEMASK_Z); + /* temp1.y/z = layer */ - ureg_MOV(ureg, ureg_writemask(temp1, - target == PIPE_TEXTURE_1D_ARRAY ? TGSI_WRITEMASK_Y - : TGSI_WRITEMASK_Z), - ureg_scalar(layer, TGSI_SWIZZLE_X)); + ureg_MOV(ureg, temp1_layer, ureg_scalar(layer, TGSI_SWIZZLE_X)); + + if (target == PIPE_TEXTURE_3D) { + /* temp1.y/z += layer_offset */ + ureg_UADD(ureg, temp1_layer, + ureg_scalar(ureg_src(temp1), TGSI_SWIZZLE_Z), + ureg_scalar(const1, TGSI_SWIZZLE_X)); + } } /* temp1 = txf(sampler, temp1) */ diff --git a/src/mesa/state_tracker/st_pbo.h b/src/mesa/state_tracker/st_pbo.h index c17ac1702e..14ae6ba23e 100644 --- a/src/mesa/state_tracker/st_pbo.h +++ b/src/mesa/state_tracker/st_pbo.h @@ -54,6 +54,7 @@ struct st_pbo_addresses { int32_t yoffset; int32_t stride; int32_t image_size; + int32_t layer_offset; } constants; }; |