nouveau/nvc0: Extract common tile mode macro
[mesa.git] / src / gallium / drivers / nouveau / nvc0 / nvc0_resource.h
1
2 #ifndef __NVC0_RESOURCE_H__
3 #define __NVC0_RESOURCE_H__
4
5 #include "nv50/nv50_resource.h"
6
7 #define NVC0_RESOURCE_FLAG_VIDEO (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 0)
8
9 #define NVC0_TILE_MODE_X(m) (((m) >> 0) & 0xf)
10 #define NVC0_TILE_MODE_Y(m) (((m) >> 4) & 0xf)
11 #define NVC0_TILE_MODE_Z(m) (((m) >> 8) & 0xf)
12
13 #define NVC0_TILE_SHIFT_X(m) (NVC0_TILE_MODE_X(m) + 6)
14 #define NVC0_TILE_SHIFT_Y(m) (NVC0_TILE_MODE_Y(m) + 3)
15 #define NVC0_TILE_SHIFT_Z(m) (NVC0_TILE_MODE_Z(m) + 0)
16
17 #define NVC0_TILE_SIZE_X(m) (64 << NVC0_TILE_MODE_X(m))
18 #define NVC0_TILE_SIZE_Y(m) ( 8 << NVC0_TILE_MODE_Y(m))
19 #define NVC0_TILE_SIZE_Z(m) ( 1 << NVC0_TILE_MODE_Z(m))
20
21 /* it's ok to mask only in the end because max value is 3 * 5 */
22
23 #define NVC0_TILE_SIZE_2D(m) ((64 * 8) << (((m) + ((m) >> 4)) & 0xf))
24
25 #define NVC0_TILE_SIZE(m) ((64 * 8) << (((m) + ((m) >> 4) + ((m) >> 8)) & 0xf))
26
27
28 void
29 nvc0_init_resource_functions(struct pipe_context *pcontext);
30
31 void
32 nvc0_screen_init_resource_functions(struct pipe_screen *pscreen);
33
34 /* Internal functions:
35 */
36 struct pipe_resource *
37 nvc0_miptree_create(struct pipe_screen *pscreen,
38 const struct pipe_resource *tmp);
39
40 const struct u_resource_vtbl nvc0_miptree_vtbl;
41
42 struct pipe_surface *
43 nvc0_miptree_surface_new(struct pipe_context *,
44 struct pipe_resource *,
45 const struct pipe_surface *templ);
46
47 unsigned
48 nvc0_mt_zslice_offset(const struct nv50_miptree *, unsigned l, unsigned z);
49
50 void *
51 nvc0_miptree_transfer_map(struct pipe_context *pctx,
52 struct pipe_resource *res,
53 unsigned level,
54 unsigned usage,
55 const struct pipe_box *box,
56 struct pipe_transfer **ptransfer);
57 void
58 nvc0_miptree_transfer_unmap(struct pipe_context *pcontext,
59 struct pipe_transfer *ptx);
60
61 #endif