1 #include "pipe/p_state.h"
2 #include "pipe/p_defines.h"
3 #include "pipe/p_util.h"
5 #include "nv40_context.h"
8 nv40_miptree_layout(struct pipe_context
*pipe
, struct pipe_mipmap_tree
*mt
)
10 struct nv40_context
*nv40
= (struct nv40_context
*)pipe
;
11 boolean swizzled
= FALSE
;
12 uint width
= mt
->width0
, height
= mt
->height0
, depth
= mt
->depth0
;
16 mt
->pitch
= mt
->width0
;
19 if (mt
->target
== PIPE_TEXTURE_CUBE
) {
22 if (mt
->target
== PIPE_TEXTURE_3D
) {
23 nr_faces
= mt
->depth0
;
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;
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
;
39 width
= MAX2(1, width
>> 1);
40 height
= MAX2(1, height
>> 1);
41 depth
= MAX2(1, depth
>> 1);
45 for (f
= 0; f
< nr_faces
; f
++) {
46 for (l
= mt
->first_level
; l
<= mt
->last_level
; l
++) {
48 mt
->level
[l
].level_offset
= offset
;
54 pitch
= mt
->level
[l
].width
* mt
->cpp
;
56 pitch
= mt
->width0
* mt
->cpp
;
57 pitch
= (pitch
+ 63) & ~63;
59 mt
->level
[l
].image_offset
[f
] =
60 (offset
- mt
->level
[l
].level_offset
) / mt
->cpp
;
61 offset
+= pitch
* mt
->level
[l
].height
;