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