summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeonsi/radeonsi_pipe.h
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-02-19 17:43:08 +0100
committerMichel Dänzer <[email protected]>2013-02-20 12:30:32 +0100
commita84c4edeede12a1275a37a61408f578481bd4355 (patch)
tree4aa651510fe1fd37fb71a03ff0ec5cda9a7f1cf2 /src/gallium/drivers/radeonsi/radeonsi_pipe.h
parentc4faab63c45aad579ef324fcc076c88a7cebbef6 (diff)
radeonsi: add assertions to prevent creation of invalid surfaces
[ Cherry-picked from r600g commit ef11ed61a0414d0405c3faf7f48fa3f1d083f82e ] NOTE: This is a candidate for the 9.1 branch. Reviewed-by: Alex Deucher <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/radeonsi_pipe.h')
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_pipe.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index d0f04f40562..8c6d9081266 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -277,4 +277,20 @@ static INLINE uint64_t r600_resource_va(struct pipe_screen *screen, struct pipe_
return rscreen->ws->buffer_get_virtual_address(rresource->cs_buf);
}
+static INLINE unsigned u_max_layer(struct pipe_resource *r, unsigned level)
+{
+ switch (r->target) {
+ case PIPE_TEXTURE_CUBE:
+ return 6 - 1;
+ case PIPE_TEXTURE_3D:
+ return u_minify(r->depth0, level) - 1;
+ case PIPE_TEXTURE_1D_ARRAY:
+ case PIPE_TEXTURE_2D_ARRAY:
+ case PIPE_TEXTURE_CUBE_ARRAY:
+ return r->array_size - 1;
+ default:
+ return 0;
+ }
+}
+
#endif