Nouveau: name replace for nv20.
[mesa.git] / src / gallium / drivers / i965simple / brw_wm_iz.c
1 /*
2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
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 * Authors:
29 * Keith Whitwell <keith@tungstengraphics.com>
30 */
31
32 #include "brw_wm.h"
33
34
35 #undef P /* prompted depth */
36 #undef C /* computed */
37 #undef N /* non-promoted? */
38
39 #define P 0
40 #define C 1
41 #define N 2
42
43 const struct {
44 unsigned mode:2;
45 unsigned sd_present:1;
46 unsigned sd_to_rt:1;
47 unsigned dd_present:1;
48 unsigned ds_present:1;
49 } wm_iz_table[IZ_BIT_MAX] =
50 {
51 { P, 0, 0, 0, 0 },
52 { P, 0, 0, 0, 0 },
53 { C, 0, 1, 0, 0 },
54 { C, 0, 1, 0, 0 },
55 { C, 1, 1, 0, 0 },
56 { C, 1, 1, 0, 0 },
57 { C, 0, 1, 0, 0 },
58 { C, 0, 1, 0, 0 },
59 { C, 1, 1, 1, 0 },
60 { C, 1, 1, 1, 0 },
61 { C, 0, 1, 1, 0 },
62 { C, 0, 1, 1, 0 },
63 { C, 1, 1, 1, 0 },
64 { C, 1, 1, 1, 0 },
65 { C, 0, 1, 1, 0 },
66 { C, 0, 1, 1, 0 },
67 { P, 0, 0, 0, 0 },
68 { P, 0, 0, 0, 0 },
69 { C, 0, 1, 0, 0 },
70 { C, 0, 1, 0, 0 },
71 { C, 1, 1, 0, 0 },
72 { C, 1, 1, 0, 0 },
73 { C, 0, 1, 0, 0 },
74 { C, 0, 1, 0, 0 },
75 { C, 1, 1, 1, 0 },
76 { C, 1, 1, 1, 0 },
77 { C, 0, 1, 1, 0 },
78 { C, 0, 1, 1, 0 },
79 { C, 1, 1, 1, 0 },
80 { C, 1, 1, 1, 0 },
81 { C, 0, 1, 1, 0 },
82 { C, 0, 1, 1, 0 },
83 { C, 0, 0, 0, 1 },
84 { C, 0, 0, 0, 1 },
85 { C, 0, 1, 0, 1 },
86 { C, 0, 1, 0, 1 },
87 { C, 1, 1, 0, 1 },
88 { C, 1, 1, 0, 1 },
89 { C, 0, 1, 0, 1 },
90 { C, 0, 1, 0, 1 },
91 { C, 1, 1, 1, 1 },
92 { C, 1, 1, 1, 1 },
93 { C, 0, 1, 1, 1 },
94 { C, 0, 1, 1, 1 },
95 { C, 1, 1, 1, 1 },
96 { C, 1, 1, 1, 1 },
97 { C, 0, 1, 1, 1 },
98 { C, 0, 1, 1, 1 },
99 { C, 0, 0, 0, 1 },
100 { C, 0, 0, 0, 1 },
101 { C, 0, 1, 0, 1 },
102 { C, 0, 1, 0, 1 },
103 { C, 1, 1, 0, 1 },
104 { C, 1, 1, 0, 1 },
105 { C, 0, 1, 0, 1 },
106 { C, 0, 1, 0, 1 },
107 { C, 1, 1, 1, 1 },
108 { C, 1, 1, 1, 1 },
109 { C, 0, 1, 1, 1 },
110 { C, 0, 1, 1, 1 },
111 { C, 1, 1, 1, 1 },
112 { C, 1, 1, 1, 1 },
113 { C, 0, 1, 1, 1 },
114 { C, 0, 1, 1, 1 },
115 { P, 0, 0, 0, 0 },
116 { P, 0, 0, 0, 0 },
117 { P, 0, 0, 0, 0 },
118 { P, 0, 0, 0, 0 },
119 { P, 0, 0, 0, 0 },
120 { N, 1, 1, 0, 0 },
121 { N, 0, 1, 0, 0 },
122 { N, 0, 1, 0, 0 },
123 { P, 0, 0, 0, 0 },
124 { P, 0, 0, 0, 0 },
125 { C, 0, 1, 1, 0 },
126 { C, 0, 1, 1, 0 },
127 { P, 0, 0, 0, 0 },
128 { N, 1, 1, 0, 0 },
129 { C, 0, 1, 1, 0 },
130 { C, 0, 1, 1, 0 },
131 { P, 0, 0, 0, 0 },
132 { P, 0, 0, 0, 0 },
133 { P, 0, 0, 0, 0 },
134 { P, 0, 0, 0, 0 },
135 { P, 0, 0, 0, 0 },
136 { N, 1, 1, 0, 0 },
137 { N, 0, 1, 0, 0 },
138 { N, 0, 1, 0, 0 },
139 { P, 0, 0, 0, 0 },
140 { P, 0, 0, 0, 0 },
141 { C, 0, 1, 1, 0 },
142 { C, 0, 1, 1, 0 },
143 { P, 0, 0, 0, 0 },
144 { N, 1, 1, 0, 0 },
145 { C, 0, 1, 1, 0 },
146 { C, 0, 1, 1, 0 },
147 { P, 0, 0, 0, 0 },
148 { P, 0, 0, 0, 0 },
149 { P, 0, 0, 0, 0 },
150 { P, 0, 0, 0, 0 },
151 { P, 0, 0, 0, 0 },
152 { N, 1, 1, 0, 1 },
153 { N, 0, 1, 0, 1 },
154 { N, 0, 1, 0, 1 },
155 { P, 0, 0, 0, 0 },
156 { P, 0, 0, 0, 0 },
157 { C, 0, 1, 1, 1 },
158 { C, 0, 1, 1, 1 },
159 { P, 0, 0, 0, 0 },
160 { N, 1, 1, 0, 1 },
161 { C, 0, 1, 1, 1 },
162 { C, 0, 1, 1, 1 },
163 { P, 0, 0, 0, 0 },
164 { C, 0, 0, 0, 1 },
165 { P, 0, 0, 0, 0 },
166 { C, 0, 1, 0, 1 },
167 { P, 0, 0, 0, 0 },
168 { C, 1, 1, 0, 1 },
169 { C, 0, 1, 0, 1 },
170 { C, 0, 1, 0, 1 },
171 { P, 0, 0, 0, 0 },
172 { C, 1, 1, 1, 1 },
173 { C, 0, 1, 1, 1 },
174 { C, 0, 1, 1, 1 },
175 { P, 0, 0, 0, 0 },
176 { C, 1, 1, 1, 1 },
177 { C, 0, 1, 1, 1 },
178 { C, 0, 1, 1, 1 }
179 };
180
181 void brw_wm_lookup_iz( unsigned line_aa,
182 unsigned lookup,
183 struct brw_wm_prog_key *key )
184 {
185 unsigned reg = 2;
186
187 assert (lookup < IZ_BIT_MAX);
188
189 if (lookup & IZ_PS_COMPUTES_DEPTH_BIT)
190 key->computes_depth = 1;
191
192 if (wm_iz_table[lookup].sd_present) {
193 key->source_depth_reg = reg;
194 reg += 2;
195 }
196
197 if (wm_iz_table[lookup].sd_to_rt)
198 key->source_depth_to_render_target = 1;
199
200 if (wm_iz_table[lookup].ds_present || line_aa != AA_NEVER) {
201 key->aa_dest_stencil_reg = reg;
202 key->runtime_check_aads_emit = (!wm_iz_table[lookup].ds_present &&
203 line_aa == AA_SOMETIMES);
204 reg++;
205 }
206
207 if (wm_iz_table[lookup].dd_present) {
208 key->dest_depth_reg = reg;
209 reg+=2;
210 }
211
212 key->nr_depth_regs = (reg+1)/2;
213 }
214