Squashed commit of the following:
[profile/ivi/mesa.git] / src / gallium / drivers / nvfx / nvfx_resource.h
1
2 #ifndef NVFX_RESOURCE_H
3 #define NVFX_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 nvfx_resource {
18         struct pipe_resource base;
19         struct u_resource_vtbl *vtbl;
20         struct nouveau_bo *bo;
21 };
22
23 #define NVFX_MAX_TEXTURE_LEVELS  16
24
25 struct nvfx_miptree {
26         struct nvfx_resource base;
27         uint total_size;
28
29         struct {
30                 uint pitch;
31                 uint *image_offset;
32         } level[NVFX_MAX_TEXTURE_LEVELS];
33
34         unsigned image_nr;
35 };
36
37 static INLINE 
38 struct nvfx_resource *nvfx_resource(struct pipe_resource *resource)
39 {
40         return (struct nvfx_resource *)resource;
41 }
42
43 static INLINE struct nouveau_bo *
44 nvfx_surface_buffer(struct pipe_surface *surf)
45 {
46         struct nvfx_resource *mt = nvfx_resource(surf->texture);
47
48         return mt->bo;
49 }
50
51
52 void
53 nvfx_init_resource_functions(struct pipe_context *pipe);
54
55 void
56 nvfx_screen_init_resource_functions(struct pipe_screen *pscreen);
57
58
59 /* Internal:
60  */
61
62 struct pipe_resource *
63 nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt);
64
65 struct pipe_resource *
66 nvfx_miptree_from_handle(struct pipe_screen *pscreen,
67                          const struct pipe_resource *template,
68                          struct winsys_handle *whandle);
69
70 struct pipe_resource *
71 nvfx_buffer_create(struct pipe_screen *pscreen,
72                    const struct pipe_resource *template);
73
74 struct pipe_resource *
75 nvfx_user_buffer_create(struct pipe_screen *screen,
76                         void *ptr,
77                         unsigned bytes,
78                         unsigned usage);
79
80
81
82 void
83 nvfx_miptree_surface_del(struct pipe_surface *ps);
84
85 struct pipe_surface *
86 nvfx_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_resource *pt,
87                          unsigned face, unsigned level, unsigned zslice,
88                          unsigned flags);
89
90
91 #endif