[i915] Include header to pick up intel_ttm_bo_create_from_handle() proto.
[mesa.git] / src / mesa / drivers / dri / i965 / intel_mipmap_tree.h
1 /**************************************************************************
2 *
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef INTEL_MIPMAP_TREE_H
29 #define INTEL_MIPMAP_TREE_H
30
31 #include "intel_regions.h"
32
33 /* A layer on top of the intel_regions code which adds:
34 *
35 * - Code to size and layout a region to hold a set of mipmaps.
36 * - Query to determine if a new image fits in an existing tree.
37 *
38 * The fixed mipmap layout of intel hardware where one offset
39 * specifies the position of all images in a mipmap hierachy
40 * complicates the implementation of GL texture image commands,
41 * compared to hardware where each image is specified with an
42 * independent offset.
43 *
44 * In an ideal world, each texture object would be associated with a
45 * single bufmgr buffer or 2d intel_region, and all the images within
46 * the texture object would slot into the tree as they arrive. The
47 * reality can be a little messier, as images can arrive from the user
48 * with sizes that don't fit in the existing tree, or in an order
49 * where the tree layout cannot be guessed immediately.
50 *
51 * This structure encodes an idealized mipmap tree. The GL image
52 * commands build these where possible, otherwise store the images in
53 * temporary system buffers.
54 */
55
56
57 struct intel_mipmap_level {
58 GLuint level_offset;
59 GLuint width;
60 GLuint height;
61 GLuint depth;
62 GLuint nr_images;
63
64 /* Explicitly store the offset of each image for each cube face or
65 * depth value. Pretty much have to accept that hardware formats
66 * are going to be so diverse that there is no unified way to
67 * compute the offsets of depth/cube images within a mipmap level,
68 * so have to store them as a lookup table:
69 */
70 GLuint *image_offset;
71 };
72
73 struct intel_mipmap_tree {
74 /* Effectively the key:
75 */
76 GLenum target;
77 GLenum internal_format;
78
79 GLuint first_level;
80 GLuint last_level;
81
82 GLuint width0, height0, depth0;
83 GLuint cpp;
84 GLboolean compressed;
85
86 /* Derived from the above:
87 */
88 GLuint pitch;
89 GLuint depth_pitch; /* per-image on i945? */
90 GLuint total_height;
91
92 /* Includes image offset tables:
93 */
94 struct intel_mipmap_level level[MAX_TEXTURE_LEVELS];
95
96 /* The data is held here:
97 */
98 struct intel_region *region;
99
100 /* These are also refcounted:
101 */
102 GLuint refcount;
103 };
104
105
106
107 struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel,
108 GLenum target,
109 GLenum internal_format,
110 GLuint first_level,
111 GLuint last_level,
112 GLuint width0,
113 GLuint height0,
114 GLuint depth0,
115 GLuint cpp,
116 GLboolean compressed);
117
118 void intel_miptree_destroy( struct intel_context *intel,
119 struct intel_mipmap_tree *mt );
120
121
122 /* Return the linear offset of an image relative to the start of the
123 * tree:
124 */
125 GLuint intel_miptree_image_offset( struct intel_mipmap_tree *mt,
126 GLuint face,
127 GLuint level );
128
129 /* Return pointers to each 2d slice within an image. Indexed by depth
130 * value.
131 */
132 const GLuint *intel_miptree_depth_offsets(struct intel_mipmap_tree *mt,
133 GLuint level);
134
135
136 void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
137 GLuint level,
138 GLuint nr_images,
139 GLuint x, GLuint y,
140 GLuint w, GLuint h, GLuint d);
141
142 void intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
143 GLuint level,
144 GLuint img,
145 GLuint x, GLuint y);
146
147
148 /* Upload an image into a tree
149 */
150 GLboolean intel_miptree_image_data(struct intel_context *intel,
151 struct intel_mipmap_tree *dst,
152 GLuint face,
153 GLuint level,
154 const void *src,
155 GLuint src_row_pitch,
156 GLuint src_image_pitch);
157
158 /* i915_mipmap_tree.c:
159 */
160 GLboolean i915_miptree_layout( struct intel_mipmap_tree *mt );
161 GLboolean i945_miptree_layout( struct intel_mipmap_tree *mt );
162 GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt );
163
164
165
166 #endif