Use write posting in the kickoff function too.
[mesa.git] / src / mesa / pipe / nv40 / nv40_miptree.c
1 #include "pipe/p_state.h"
2 #include "pipe/p_defines.h"
3 #include "pipe/p_util.h"
4
5 #include "nv40_context.h"
6
7 boolean
8 nv40_miptree_layout(struct pipe_context *pipe, struct pipe_mipmap_tree *mt)
9 {
10 struct nv40_context *nv40 = (struct nv40_context *)pipe;
11 boolean swizzled = FALSE;
12 uint width = mt->width0, height = mt->height0, depth = mt->depth0;
13 uint offset;
14 int nr_faces, l, f;
15
16 mt->pitch = mt->width0;
17 mt->total_height = 0;
18
19 if (mt->target == PIPE_TEXTURE_CUBE) {
20 nr_faces = 6;
21 } else
22 if (mt->target == PIPE_TEXTURE_3D) {
23 nr_faces = mt->depth0;
24 } else {
25 nr_faces = 1;
26 }
27
28 for (l = mt->first_level; l <= mt->last_level; l++) {
29 mt->level[l].width = width;
30 mt->level[l].height = height;
31 mt->level[l].depth = depth;
32 mt->level[l].level_offset = 0;
33
34 mt->level[l].nr_images = nr_faces;
35 mt->level[l].image_offset = malloc(nr_faces * sizeof(unsigned));
36 for (f = 0; f < nr_faces; f++)
37 mt->total_height += height;
38
39 width = MAX2(1, width >> 1);
40 height = MAX2(1, height >> 1);
41 depth = MAX2(1, depth >> 1);
42 }
43
44 offset = 0;
45 for (f = 0; f < nr_faces; f++) {
46 for (l = mt->first_level; l <= mt->last_level; l++) {
47 if (f == 0) {
48 mt->level[l].level_offset = offset;
49 }
50
51 uint pitch;
52
53 if (swizzled)
54 pitch = mt->level[l].width * mt->cpp;
55 else
56 pitch = mt->width0 * mt->cpp;
57 pitch = (pitch + 63) & ~63;
58
59 mt->level[l].image_offset[f] =
60 (offset - mt->level[l].level_offset) / mt->cpp;
61 offset += pitch * mt->level[l].height;
62 }
63 }
64
65 return TRUE;
66 }
67