1 martin 1.6 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h,v 1.5 2000/12/15 22:48:43 dawes Exp $ */
|
2 tsi 1.1 /*
|
3 tsi 1.3 * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
|
4 martin 1.2 * Precision Insight, Inc., Cedar Park, Texas, and
5 * VA Linux Systems Inc., Fremont, California.
|
6 tsi 1.1 *
7 * All Rights Reserved.
8 *
|
9 martin 1.2 * Permission is hereby granted, free of charge, to any person obtaining
10 * a copy of this software and associated documentation files (the
11 * "Software"), to deal in the Software without restriction, including
12 * without limitation on the rights to use, copy, modify, merge,
13 * publish, distribute, sublicense, and/or sell copies of the Software,
14 * and to permit persons to whom the Software is furnished to do so,
15 * subject to the following conditions:
|
16 tsi 1.1 *
|
17 martin 1.2 * The above copyright notice and this permission notice (including the
18 * next paragraph) shall be included in all copies or substantial
19 * portions of the Software.
|
20 tsi 1.1 *
|
21 martin 1.2 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
24 tsi 1.3 * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
|
25 martin 1.2 * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
|
29 tsi 1.1 */
30
31 /*
32 * Authors:
|
33 martin 1.2 * Kevin E. Martin <martin@valinux.com>
|
34 dawes 1.4 * Gareth Hughes <gareth@valinux.com>
|
35 tsi 1.1 *
36 */
37
38 #ifndef _R128_SAREA_H_
39 #define _R128_SAREA_H_
|
40 tsi 1.3
41 #include "Xmd.h"
|
42 tsi 1.1
|
43 dawes 1.4 /* WARNING: If you change any of these defines, make sure to change the
44 * defines in the kernel file (r128_drm.h)
45 */
46 #ifndef __R128_SAREA_DEFINES__
47 #define __R128_SAREA_DEFINES__
48
49 /* What needs to be changed for the current vertex buffer?
50 */
51 #define R128_UPLOAD_CONTEXT 0x001
52 #define R128_UPLOAD_SETUP 0x002
53 #define R128_UPLOAD_TEX0 0x004
54 #define R128_UPLOAD_TEX1 0x008
55 #define R128_UPLOAD_TEX0IMAGES 0x010
56 #define R128_UPLOAD_TEX1IMAGES 0x020
57 #define R128_UPLOAD_CORE 0x040
58 #define R128_UPLOAD_MASKS 0x080
59 #define R128_UPLOAD_WINDOW 0x100
60 #define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */
61 #define R128_REQUIRE_QUIESCENCE 0x400
62 #define R128_UPLOAD_ALL 0x7ff
63
64 dawes 1.4 #define R128_FRONT 0x1
65 #define R128_BACK 0x2
66 #define R128_DEPTH 0x4
67
68 /* Primitive types
69 */
70 #define R128_POINTS 0x1
71 #define R128_LINES 0x2
72 #define R128_LINE_STRIP 0x3
73 #define R128_TRIANGLES 0x4
74 #define R128_TRIANGLE_FAN 0x5
75 #define R128_TRIANGLE_STRIP 0x6
76
77 /* Vertex/indirect buffer size
78 */
79 #define R128_BUFFER_SIZE 16384
80
81 /* Byte offsets for indirect buffer data
82 */
83 #define R128_INDEX_PRIM_OFFSET 20
84 #define R128_HOSTDATA_BLIT_OFFSET 32
85 dawes 1.4
86 /* Keep these small for testing
87 */
88 #define R128_NR_SAREA_CLIPRECTS 12
89
|
90 tsi 1.1 /* There are 2 heaps (local/AGP). Each region within a heap is a
|
91 dawes 1.4 * minimum of 64k, and there are at most 64 of them per heap.
92 */
|
93 martin 1.6 #define R128_CARD_HEAP 0
94 #define R128_AGP_HEAP 1
|
95 dawes 1.4 #define R128_NR_TEX_HEAPS 2
96 #define R128_NR_TEX_REGIONS 64
97 #define R128_LOG_TEX_GRANULARITY 16
98
99 #define R128_NR_CONTEXT_REGS 12
|
100 martin 1.6
101 #define R128_MAX_TEXTURE_LEVELS 11
102 #define R128_MAX_TEXTURE_UNITS 2
|
103 tsi 1.1
|
104 dawes 1.4 #endif /* __R128_SAREA_DEFINES__ */
105
106 typedef struct {
107 /* Context state - can be written in one large chunk */
|
108 dawes 1.5 unsigned int dst_pitch_offset_c;
109 unsigned int dp_gui_master_cntl_c;
110 unsigned int sc_top_left_c;
111 unsigned int sc_bottom_right_c;
112 unsigned int z_offset_c;
113 unsigned int z_pitch_c;
114 unsigned int z_sten_cntl_c;
115 unsigned int tex_cntl_c;
116 unsigned int misc_3d_state_cntl_reg;
117 unsigned int texture_clr_cmp_clr_c;
118 unsigned int texture_clr_cmp_msk_c;
119 unsigned int fog_color_c;
|
120 dawes 1.4
121 /* Texture state */
|
122 dawes 1.5 unsigned int tex_size_pitch_c;
123 unsigned int constant_color_c;
|
124 dawes 1.4
125 /* Setup state */
|
126 dawes 1.5 unsigned int pm4_vc_fpu_setup;
127 unsigned int setup_cntl;
|
128 dawes 1.4
129 /* Mask state */
|
130 dawes 1.5 unsigned int dp_write_mask;
131 unsigned int sten_ref_mask_c;
132 unsigned int plane_3d_mask_c;
|
133 dawes 1.4
134 /* Window state */
|
135 dawes 1.5 unsigned int window_xy_offset;
|
136 dawes 1.4
137 /* Core state */
|
138 dawes 1.5 unsigned int scale_3d_cntl;
|
139 dawes 1.4 } r128_context_regs_t;
140
141 /* Setup registers for each texture unit
142 */
|
143 tsi 1.1 typedef struct {
|
144 dawes 1.5 unsigned int tex_cntl;
145 unsigned int tex_combine_cntl;
146 unsigned int tex_size_pitch;
|
147 martin 1.6 unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
|
148 dawes 1.5 unsigned int tex_border_color;
|
149 dawes 1.4 } r128_texture_regs_t;
|
150 tsi 1.1
151 typedef struct {
|
152 dawes 1.4 unsigned char next, prev; /* indices to form a circular LRU */
153 unsigned char in_use; /* owned by a client, or free? */
|
154 martin 1.6 int age; /* tracked by clients to update local LRU's */
|
155 dawes 1.4 } r128_tex_region_t;
156
157 typedef struct {
158 /* The channel for communication of state information to the kernel
159 * on firing a vertex buffer.
160 */
161 r128_context_regs_t ContextState;
|
162 martin 1.6 r128_texture_regs_t TexState[R128_MAX_TEXTURE_UNITS];
163 unsigned int dirty;
164 unsigned int vertsize;
165 unsigned int vc_format;
|
166 dawes 1.4
167 /* The current cliprects, or a subset thereof.
168 */
|
169 martin 1.6 XF86DRIClipRectRec boxes[R128_NR_SAREA_CLIPRECTS];
170 unsigned int nbox;
|
171 dawes 1.4
172 /* Counters for throttling of rendering clients.
173 */
|
174 martin 1.6 unsigned int last_frame;
175 unsigned int last_dispatch;
|
176 dawes 1.4
|
177 martin 1.2 /* Maintain an LRU of contiguous regions of texture space. If you
|
178 tsi 1.1 * think you own a region of texture memory, and it has an age
179 * different to the one you set, then you are mistaken and it has
180 * been stolen by another client. If global texAge hasn't changed,
181 * there is no need to walk the list.
182 *
183 * These regions can be used as a proxy for the fine-grained texture
184 * information of other clients - by maintaining them in the same
185 * lru which is used to age their own textures, clients have an
186 * approximate lru for the whole of global texture space, and can
187 * make informed decisions as to which areas to kick out. There is
188 * no need to choose whether to kick out your own texture or someone
189 * else's - simply eject them all in LRU order.
190 */
191 /* Last elt is sentinal */
|
192 martin 1.6 r128_tex_region_t texList[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
|
193 tsi 1.1 /* last time texture was uploaded */
|
194 martin 1.6 int texAge[R128_NR_TEX_HEAPS];
|
195 tsi 1.1
|
196 martin 1.6 int ctxOwner; /* last context to upload state */
|
197 tsi 1.1 } R128SAREAPriv, *R128SAREAPrivPtr;
198
199 #endif
|