nvc0: import nvc0 gallium driver
[mesa.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 #undef NOUVEAU_NVC0
10
11 #include "nvc0_fence.h"
12
13 struct pipe_resource;
14 struct nouveau_bo;
15
16 /* Resources, if mapped into the GPU's address space, are guaranteed to
17 * have constant virtual addresses.
18 * The address of a resource will lie within the nouveau_bo referenced,
19 * and this bo should be added to the memory manager's validation list.
20 */
21 struct nvc0_resource {
22 struct pipe_resource base;
23 const struct u_resource_vtbl *vtbl;
24 uint64_t address;
25
26 uint8_t *data;
27 struct nouveau_bo *bo;
28 uint32_t offset;
29
30 uint8_t status;
31 uint8_t domain;
32 struct nvc0_fence *fence;
33 struct list_head list;
34 };
35
36 #define NVC0_TILE_H(m) (8 << ((m >> 4) & 0xf))
37 #define NVC0_TILE_D(m) (1 << (m >> 8))
38
39 struct nvc0_miptree_level {
40 int *image_offset;
41 uint32_t pitch;
42 uint32_t tile_mode;
43 };
44
45 #define NVC0_MAX_TEXTURE_LEVELS 16
46
47 struct nvc0_miptree {
48 struct nvc0_resource base;
49 struct nvc0_miptree_level level[NVC0_MAX_TEXTURE_LEVELS];
50 int image_nr;
51 int total_size;
52 };
53
54 static INLINE struct nvc0_miptree *
55 nvc0_miptree(struct pipe_resource *pt)
56 {
57 return (struct nvc0_miptree *)pt;
58 }
59
60 static INLINE struct nvc0_resource *
61 nvc0_resource(struct pipe_resource *resource)
62 {
63 return (struct nvc0_resource *)resource;
64 }
65
66 /* is resource mapped into the GPU's address space (i.e. VRAM or GART) ? */
67 static INLINE boolean
68 nvc0_resource_mapped_by_gpu(struct pipe_resource *resource)
69 {
70 return nvc0_resource(resource)->bo->offset != 0ULL;
71 }
72
73 void
74 nvc0_init_resource_functions(struct pipe_context *pcontext);
75
76 void
77 nvc0_screen_init_resource_functions(struct pipe_screen *pscreen);
78
79 /* Internal functions:
80 */
81 struct pipe_resource *
82 nvc0_miptree_create(struct pipe_screen *pscreen,
83 const struct pipe_resource *tmp);
84
85 struct pipe_resource *
86 nvc0_miptree_from_handle(struct pipe_screen *pscreen,
87 const struct pipe_resource *template,
88 struct winsys_handle *whandle);
89
90 struct pipe_resource *
91 nvc0_buffer_create(struct pipe_screen *pscreen,
92 const struct pipe_resource *templ);
93
94 struct pipe_resource *
95 nvc0_user_buffer_create(struct pipe_screen *screen,
96 void *ptr,
97 unsigned bytes,
98 unsigned usage);
99
100
101 struct pipe_surface *
102 nvc0_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_resource *pt,
103 unsigned face, unsigned level, unsigned zslice,
104 unsigned flags);
105
106 void
107 nvc0_miptree_surface_del(struct pipe_surface *ps);
108
109 #endif