Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / gallium / drivers / nvc0 / nvc0_resource.h
1
2 #ifndef __NVC0_RESOURCE_H__
3 #define __NVC0_RESOURCE_H__
4
5 #include "util/u_transfer.h"
6 #include "util/u_double_list.h"
7 #define NOUVEAU_NVC0
8 #include "nouveau/nouveau_winsys.h"
9 #include "nouveau/nouveau_fence.h"
10 #include "nouveau/nouveau_buffer.h"
11 #undef NOUVEAU_NVC0
12
13 void
14 nvc0_init_resource_functions(struct pipe_context *pcontext);
15
16 void
17 nvc0_screen_init_resource_functions(struct pipe_screen *pscreen);
18
19 #define NVC0_TILE_DIM_SHIFT(m, d) (((m) >> (d * 4)) & 0xf)
20
21 #define NVC0_TILE_PITCH(m)  (64 << NVC0_TILE_DIM_SHIFT(m, 0))
22 #define NVC0_TILE_HEIGHT(m) ( 8 << NVC0_TILE_DIM_SHIFT(m, 1))
23 #define NVC0_TILE_DEPTH(m)  ( 1 << NVC0_TILE_DIM_SHIFT(m, 2))
24
25 #define NVC0_TILE_SIZE_2D(m) (((64 * 8) <<                     \
26                                NVC0_TILE_DIM_SHIFT(m, 0)) <<   \
27                               NVC0_TILE_DIM_SHIFT(m, 1))
28
29 #define NVC0_TILE_SIZE(m) (NVC0_TILE_SIZE_2D(m) << NVC0_TILE_DIM_SHIFT(m, 2))
30
31 struct nvc0_miptree_level {
32    uint32_t offset;
33    uint32_t pitch;
34    uint32_t tile_mode;
35 };
36
37 #define NVC0_MAX_TEXTURE_LEVELS 16
38
39 struct nvc0_miptree {
40    struct nv04_resource base;
41    struct nvc0_miptree_level level[NVC0_MAX_TEXTURE_LEVELS];
42    uint32_t total_size;
43    uint32_t layer_stride;
44    boolean layout_3d; /* TRUE if layer count varies with mip level */
45 };
46
47 static INLINE struct nvc0_miptree *
48 nvc0_miptree(struct pipe_resource *pt)
49 {
50    return (struct nvc0_miptree *)pt;
51 }
52
53 /* Internal functions:
54  */
55 struct pipe_resource *
56 nvc0_miptree_create(struct pipe_screen *pscreen,
57                     const struct pipe_resource *tmp);
58
59 struct pipe_resource *
60 nvc0_miptree_from_handle(struct pipe_screen *pscreen,
61                          const struct pipe_resource *template,
62                          struct winsys_handle *whandle);
63
64 struct pipe_surface *
65 nvc0_miptree_surface_new(struct pipe_context *,
66                          struct pipe_resource *,
67                          const struct pipe_surface *templ);
68
69 void
70 nvc0_miptree_surface_del(struct pipe_context *, struct pipe_surface *);
71
72 uint32_t
73 nvc0_miptree_zslice_offset(struct nvc0_miptree *, unsigned l, unsigned z);
74
75 #endif