r300: bo and cs abstraction.
[mesa.git] / src / mesa / drivers / dri / r300 / r300_mipmap_tree.h
1 /*
2 * Copyright (C) 2008 Nicolai Haehnle.
3 *
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a 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, sublicense, 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
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 */
27
28 #ifndef __R300_MIPMAP_TREE_H_
29 #define __R300_MIPMAP_TREE_H_
30
31 #include "r300_context.h"
32
33 typedef struct _r300_mipmap_tree r300_mipmap_tree;
34 typedef struct _r300_mipmap_level r300_mipmap_level;
35 typedef struct _r300_mipmap_image r300_mipmap_image;
36
37 struct _r300_mipmap_image {
38 GLuint offset; /** Offset of this image from the start of mipmap tree buffer, in bytes */
39 };
40
41 struct _r300_mipmap_level {
42 GLuint width;
43 GLuint height;
44 GLuint depth;
45 GLuint size; /** Size of each image, in bytes */
46 GLuint rowstride; /** in bytes */
47 r300_mipmap_image faces[6];
48 };
49
50
51 /**
52 * A mipmap tree contains texture images in the layout that the hardware
53 * expects.
54 *
55 * The meta-data of mipmap trees is immutable, i.e. you cannot change the
56 * layout on-the-fly; however, the texture contents (i.e. texels) can be
57 * changed.
58 */
59 struct _r300_mipmap_tree {
60 r300ContextPtr r300;
61 r300TexObj *t;
62 struct radeon_bo *bo;
63 GLuint refcount;
64
65 GLuint totalsize; /** total size of the miptree, in bytes */
66
67 GLenum target; /** GL_TEXTURE_xxx */
68 GLuint faces; /** # of faces: 6 for cubemaps, 1 otherwise */
69 GLuint firstLevel; /** First mip level stored in this mipmap tree */
70 GLuint lastLevel; /** Last mip level stored in this mipmap tree */
71
72 GLuint width0; /** Width of firstLevel image */
73 GLuint height0; /** Height of firstLevel image */
74 GLuint depth0; /** Depth of firstLevel image */
75
76 GLuint bpp; /** Bytes per texel */
77 GLuint tilebits; /** R300_TXO_xxx_TILE */
78 GLuint compressed; /** MESA_FORMAT_xxx indicating a compressed format, or 0 if uncompressed */
79
80 r300_mipmap_level levels[RADEON_MAX_TEXTURE_LEVELS];
81 };
82
83 r300_mipmap_tree* r300_miptree_create(r300ContextPtr rmesa, r300TexObj *t,
84 GLenum target, GLuint firstLevel, GLuint lastLevel,
85 GLuint width0, GLuint height0, GLuint depth0,
86 GLuint bpp, GLuint tilebits, GLuint compressed);
87 void r300_miptree_reference(r300_mipmap_tree *mt);
88 void r300_miptree_unreference(r300_mipmap_tree *mt);
89
90 GLboolean r300_miptree_matches_image(r300_mipmap_tree *mt,
91 struct gl_texture_image *texImage, GLuint face, GLuint level);
92 GLboolean r300_miptree_matches_texture(r300_mipmap_tree *mt, struct gl_texture_object *texObj);
93 void r300_try_alloc_miptree(r300ContextPtr rmesa, r300TexObj *t,
94 struct gl_texture_image *texImage, GLuint face, GLuint level);
95
96
97 #endif /* __R300_MIPMAP_TREE_H_ */