diff options
Diffstat (limited to 'src/gallium/drivers/nvfx/nvfx_resource.h')
-rw-r--r-- | src/gallium/drivers/nvfx/nvfx_resource.h | 194 |
1 files changed, 0 insertions, 194 deletions
diff --git a/src/gallium/drivers/nvfx/nvfx_resource.h b/src/gallium/drivers/nvfx/nvfx_resource.h deleted file mode 100644 index 4a663583b46..00000000000 --- a/src/gallium/drivers/nvfx/nvfx_resource.h +++ /dev/null | |||
@@ -1,194 +0,0 @@ | |||
1 | #ifndef NVFX_RESOURCE_H | ||
2 | #define NVFX_RESOURCE_H | ||
3 | |||
4 | #include "util/u_transfer.h" | ||
5 | #include "util/u_format.h" | ||
6 | #include "util/u_math.h" | ||
7 | #include "util/u_double_list.h" | ||
8 | #include "util/u_surfaces.h" | ||
9 | #include "util/u_dirty_surfaces.h" | ||
10 | #include <nouveau/nouveau_bo.h> | ||
11 | |||
12 | struct pipe_resource; | ||
13 | struct nv04_region; | ||
14 | |||
15 | struct nvfx_resource { | ||
16 | struct pipe_resource base; | ||
17 | struct nouveau_bo *bo; | ||
18 | }; | ||
19 | |||
20 | static INLINE | ||
21 | struct nvfx_resource *nvfx_resource(struct pipe_resource *resource) | ||
22 | { | ||
23 | return (struct nvfx_resource *)resource; | ||
24 | } | ||
25 | |||
26 | #define NVFX_RESOURCE_FLAG_USER (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 0) | ||
27 | |||
28 | /* is resource mapped into the GPU's address space (i.e. VRAM or GART) ? */ | ||
29 | static INLINE boolean | ||
30 | nvfx_resource_mapped_by_gpu(struct pipe_resource *resource) | ||
31 | { | ||
32 | return nvfx_resource(resource)->bo->handle; | ||
33 | } | ||
34 | |||
35 | /* is resource in VRAM? */ | ||
36 | static inline int | ||
37 | nvfx_resource_on_gpu(struct pipe_resource* pr) | ||
38 | { | ||
39 | #if 0 | ||
40 | // a compiler error here means you need to apply libdrm-nouveau-add-domain.patch to libdrm | ||
41 | // TODO: return FALSE if not VRAM and on a PCI-E system | ||
42 | return ((struct nvfx_resource*)pr)->bo->domain & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART); | ||
43 | #else | ||
44 | return TRUE; | ||
45 | #endif | ||
46 | } | ||
47 | |||
48 | #define NVFX_MAX_TEXTURE_LEVELS 16 | ||
49 | |||
50 | struct nvfx_miptree { | ||
51 | struct nvfx_resource base; | ||
52 | |||
53 | unsigned linear_pitch; /* for linear textures, 0 for swizzled and compressed textures with level-dependent minimal pitch */ | ||
54 | unsigned face_size; /* 128-byte aligned face/total size */ | ||
55 | unsigned level_offset[NVFX_MAX_TEXTURE_LEVELS]; | ||
56 | |||
57 | struct util_surfaces surfaces; | ||
58 | }; | ||
59 | |||
60 | struct nvfx_surface { | ||
61 | struct pipe_surface base; | ||
62 | unsigned pitch; | ||
63 | unsigned offset; | ||
64 | }; | ||
65 | |||
66 | static INLINE struct nouveau_bo * | ||
67 | nvfx_surface_buffer(struct pipe_surface *surf) | ||
68 | { | ||
69 | struct nvfx_resource *mt = nvfx_resource(surf->texture); | ||
70 | |||
71 | return mt->bo; | ||
72 | } | ||
73 | |||
74 | void | ||
75 | nvfx_init_resource_functions(struct pipe_context *pipe); | ||
76 | |||
77 | void | ||
78 | nvfx_screen_init_resource_functions(struct pipe_screen *pscreen); | ||
79 | |||
80 | |||
81 | /* Internal: | ||
82 | */ | ||
83 | |||
84 | struct pipe_resource * | ||
85 | nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt); | ||
86 | |||
87 | void | ||
88 | nvfx_miptree_destroy(struct pipe_screen *pscreen, | ||
89 | struct pipe_resource *presource); | ||
90 | |||
91 | struct pipe_resource * | ||
92 | nvfx_miptree_from_handle(struct pipe_screen *pscreen, | ||
93 | const struct pipe_resource *template, | ||
94 | struct winsys_handle *whandle); | ||
95 | |||
96 | void | ||
97 | nvfx_miptree_surface_del(struct pipe_context *pipe, struct pipe_surface *ps); | ||
98 | |||
99 | struct pipe_surface * | ||
100 | nvfx_miptree_surface_new(struct pipe_context *pipe, struct pipe_resource *pt, | ||
101 | const struct pipe_surface *surf_tmpl); | ||
102 | |||
103 | /* only for miptrees, don't use for buffers */ | ||
104 | |||
105 | /* NOTE: for swizzled 3D textures, this just returns the offset of the mipmap level */ | ||
106 | static inline unsigned | ||
107 | nvfx_subresource_offset(struct pipe_resource* pt, unsigned face, unsigned level, unsigned zslice) | ||
108 | { | ||
109 | if(pt->target == PIPE_BUFFER) | ||
110 | return 0; | ||
111 | else | ||
112 | { | ||
113 | struct nvfx_miptree *mt = (struct nvfx_miptree *)pt; | ||
114 | |||
115 | unsigned offset = mt->level_offset[level]; | ||
116 | if (pt->target == PIPE_TEXTURE_CUBE) | ||
117 | offset += mt->face_size * face; | ||
118 | else if (pt->target == PIPE_TEXTURE_3D && mt->linear_pitch) | ||
119 | offset += zslice * util_format_get_2d_size(pt->format, (mt->linear_pitch ? mt->linear_pitch : util_format_get_stride(pt->format, u_minify(pt->width0, level))), u_minify(pt->height0, level)); | ||
120 | return offset; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | static inline unsigned | ||
125 | nvfx_subresource_pitch(struct pipe_resource* pt, unsigned level) | ||
126 | { | ||
127 | if(pt->target == PIPE_BUFFER) | ||
128 | return ((struct nvfx_resource*)pt)->bo->size; | ||
129 | else | ||
130 | { | ||
131 | struct nvfx_miptree *mt = (struct nvfx_miptree *)pt; | ||
132 | |||
133 | if(mt->linear_pitch) | ||
134 | return mt->linear_pitch; | ||
135 | else | ||
136 | return util_format_get_stride(pt->format, u_minify(pt->width0, level)); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | struct nvfx_buffer | ||
141 | { | ||
142 | struct nvfx_resource base; | ||
143 | uint8_t* data; | ||
144 | unsigned size; | ||
145 | |||
146 | /* the range of data not yet uploaded to the GPU bo */ | ||
147 | unsigned dirty_begin; | ||
148 | unsigned dirty_end; | ||
149 | |||
150 | /* whether all transfers were unsynchronized */ | ||
151 | boolean dirty_unsynchronized; | ||
152 | |||
153 | /* whether it would have been profitable to upload | ||
154 | * the latest updated data to the GPU immediately */ | ||
155 | boolean last_update_static; | ||
156 | |||
157 | /* how many bytes we need to draw before we deem | ||
158 | * the buffer to be static | ||
159 | */ | ||
160 | long long bytes_to_draw_until_static; | ||
161 | }; | ||
162 | |||
163 | static inline struct nvfx_buffer* nvfx_buffer(struct pipe_resource* pr) | ||
164 | { | ||
165 | return (struct nvfx_buffer*)pr; | ||
166 | } | ||
167 | |||
168 | /* this is an heuristic to determine whether we are better off uploading the | ||
169 | * buffer to the GPU, or just continuing pushing it on the FIFO | ||
170 | */ | ||
171 | static inline boolean nvfx_buffer_seems_static(struct nvfx_buffer* buffer) | ||
172 | { | ||
173 | return buffer->last_update_static | ||
174 | || buffer->bytes_to_draw_until_static < 0; | ||
175 | } | ||
176 | |||
177 | struct pipe_resource * | ||
178 | nvfx_buffer_create(struct pipe_screen *pscreen, | ||
179 | const struct pipe_resource *template); | ||
180 | |||
181 | void | ||
182 | nvfx_buffer_destroy(struct pipe_screen *pscreen, | ||
183 | struct pipe_resource *presource); | ||
184 | |||
185 | struct pipe_resource * | ||
186 | nvfx_user_buffer_create(struct pipe_screen *screen, | ||
187 | void *ptr, | ||
188 | unsigned bytes, | ||
189 | unsigned usage); | ||
190 | |||
191 | void | ||
192 | nvfx_buffer_upload(struct nvfx_buffer* buffer); | ||
193 | |||
194 | #endif | ||