Merge branch '7.8'
[mesa.git] / src / gallium / drivers / nv50 / nv50_resource.h
1
2 #ifndef NV50_RESOURCE_H
3 #define NV50_RESOURCE_H
4
5 #include "util/u_transfer.h"
6
7 struct pipe_resource;
8 struct nouveau_bo;
9
10
11 /* This gets further specialized into either buffer or texture
12 * structures. In the future we'll want to remove much of that
13 * distinction, but for now try to keep as close to the existing code
14 * as possible and use the vtbl struct to choose between the two
15 * underlying implementations.
16 */
17 struct nv50_resource {
18 struct pipe_resource base;
19 const struct u_resource_vtbl *vtbl;
20 struct nouveau_bo *bo;
21 };
22
23 struct nv50_miptree_level {
24 int *image_offset;
25 unsigned pitch;
26 unsigned tile_mode;
27 };
28
29 #define NV50_MAX_TEXTURE_LEVELS 16
30
31 struct nv50_miptree {
32 struct nv50_resource base;
33
34 struct nv50_miptree_level level[NV50_MAX_TEXTURE_LEVELS];
35 int image_nr;
36 int total_size;
37 };
38
39 static INLINE struct nv50_miptree *
40 nv50_miptree(struct pipe_resource *pt)
41 {
42 return (struct nv50_miptree *)pt;
43 }
44
45
46 static INLINE
47 struct nv50_resource *nv50_resource(struct pipe_resource *resource)
48 {
49 return (struct nv50_resource *)resource;
50 }
51
52
53 void
54 nv50_init_resource_functions(struct pipe_context *pcontext);
55
56 void
57 nv50_screen_init_resource_functions(struct pipe_screen *pscreen);
58
59 /* Internal functions
60 */
61 struct pipe_resource *
62 nv50_miptree_create(struct pipe_screen *pscreen,
63 const struct pipe_resource *tmp);
64
65 struct pipe_resource *
66 nv50_miptree_from_handle(struct pipe_screen *pscreen,
67 const struct pipe_resource *template,
68 struct winsys_handle *whandle);
69
70 struct pipe_resource *
71 nv50_buffer_create(struct pipe_screen *pscreen,
72 const struct pipe_resource *template);
73
74 struct pipe_resource *
75 nv50_user_buffer_create(struct pipe_screen *screen,
76 void *ptr,
77 unsigned bytes,
78 unsigned usage);
79
80
81 struct pipe_surface *
82 nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_resource *pt,
83 unsigned face, unsigned level, unsigned zslice,
84 unsigned flags);
85
86 void
87 nv50_miptree_surface_del(struct pipe_surface *ps);
88
89
90 #endif