| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2003 Tungsten Graphics, inc. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * on the rights to use, copy, modify, merge, publish, distribute, sub |
| 9 | * license, and/or sell copies of the Software, and to permit persons to whom |
| 10 | * the Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 19 | * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, |
| 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 22 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
| 25 | * Keith Whitwell <keithw@tungstengraphics.com> |
| 26 | */ |
| 27 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 28 | #include "glheader.h" |
| 29 | #include "context.h" |
| 30 | #include "colormac.h" |
| 31 | |
| 32 | #include "t_context.h" |
| 33 | #include "t_vertex.h" |
| 34 | |
| 35 | |
| 36 | /* Build and manage clipspace/ndc/window vertices. |
| 37 | * |
| 38 | * Another new mechanism designed and crying out for codegen. Before |
| 39 | * that, it would be very interesting to investigate the merger of |
| 40 | * these vertices and those built in t_vtx_*. |
| 41 | */ |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 42 | |
| 43 | |
| 44 | |
| Keith Whitwell | 203dca4 | 2004-01-06 20:13:41 +0000 | [diff] [blame] | 45 | |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 46 | |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 47 | |
| 48 | /* |
| 49 | * These functions take the NDC coordinates pointed to by 'in', apply the |
| 50 | * NDC->Viewport mapping and store the results at 'v'. |
| 51 | */ |
| 52 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 53 | static INLINE void insert_4f_viewport_4( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 54 | const GLfloat *in ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 55 | { |
| 56 | GLfloat *out = (GLfloat *)v; |
| 57 | const GLfloat * const vp = a->vp; |
| 58 | |
| 59 | out[0] = vp[0] * in[0] + vp[12]; |
| 60 | out[1] = vp[5] * in[1] + vp[13]; |
| 61 | out[2] = vp[10] * in[2] + vp[14]; |
| 62 | out[3] = in[3]; |
| 63 | } |
| 64 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 65 | static INLINE void insert_4f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 66 | const GLfloat *in ) |
| 67 | { |
| 68 | GLfloat *out = (GLfloat *)v; |
| 69 | const GLfloat * const vp = a->vp; |
| 70 | |
| 71 | out[0] = vp[0] * in[0] + vp[12]; |
| 72 | out[1] = vp[5] * in[1] + vp[13]; |
| 73 | out[2] = vp[10] * in[2] + vp[14]; |
| 74 | out[3] = 1; |
| 75 | } |
| 76 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 77 | static INLINE void insert_4f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 78 | const GLfloat *in ) |
| 79 | { |
| 80 | GLfloat *out = (GLfloat *)v; |
| 81 | const GLfloat * const vp = a->vp; |
| 82 | |
| 83 | out[0] = vp[0] * in[0] + vp[12]; |
| 84 | out[1] = vp[5] * in[1] + vp[13]; |
| 85 | out[2] = vp[14]; |
| 86 | out[3] = 1; |
| 87 | } |
| 88 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 89 | static INLINE void insert_4f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 90 | const GLfloat *in ) |
| 91 | { |
| 92 | GLfloat *out = (GLfloat *)v; |
| 93 | const GLfloat * const vp = a->vp; |
| 94 | |
| 95 | out[0] = vp[0] * in[0] + vp[12]; |
| 96 | out[1] = vp[13]; |
| 97 | out[2] = vp[14]; |
| 98 | out[3] = 1; |
| 99 | } |
| 100 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 101 | static INLINE void insert_3f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 102 | const GLfloat *in ) |
| 103 | { |
| 104 | GLfloat *out = (GLfloat *)v; |
| 105 | const GLfloat * const vp = a->vp; |
| 106 | |
| 107 | out[0] = vp[0] * in[0] + vp[12]; |
| 108 | out[1] = vp[5] * in[1] + vp[13]; |
| 109 | out[2] = vp[10] * in[2] + vp[14]; |
| 110 | } |
| 111 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 112 | static INLINE void insert_3f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 113 | const GLfloat *in ) |
| 114 | { |
| 115 | GLfloat *out = (GLfloat *)v; |
| 116 | const GLfloat * const vp = a->vp; |
| 117 | |
| 118 | out[0] = vp[0] * in[0] + vp[12]; |
| 119 | out[1] = vp[5] * in[1] + vp[13]; |
| 120 | out[2] = vp[10] * in[2] + vp[14]; |
| 121 | } |
| 122 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 123 | static INLINE void insert_3f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 124 | const GLfloat *in ) |
| 125 | { |
| 126 | GLfloat *out = (GLfloat *)v; |
| 127 | const GLfloat * const vp = a->vp; |
| 128 | |
| 129 | out[0] = vp[0] * in[0] + vp[12]; |
| 130 | out[1] = vp[13]; |
| 131 | out[2] = vp[14]; |
| 132 | } |
| 133 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 134 | static INLINE void insert_2f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 135 | const GLfloat *in ) |
| 136 | { |
| 137 | GLfloat *out = (GLfloat *)v; |
| 138 | const GLfloat * const vp = a->vp; |
| 139 | |
| 140 | out[0] = vp[0] * in[0] + vp[12]; |
| 141 | out[1] = vp[5] * in[1] + vp[13]; |
| 142 | } |
| 143 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 144 | static INLINE void insert_2f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 145 | const GLfloat *in ) |
| 146 | { |
| 147 | GLfloat *out = (GLfloat *)v; |
| 148 | const GLfloat * const vp = a->vp; |
| 149 | |
| 150 | out[0] = vp[0] * in[0] + vp[12]; |
| 151 | out[1] = vp[13]; |
| 152 | } |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 153 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 154 | |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 155 | /* |
| 156 | * These functions do the same as above, except for the viewport mapping. |
| 157 | */ |
| 158 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 159 | static INLINE void insert_4f_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 160 | { |
| 161 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 162 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 163 | |
| 164 | out[0] = in[0]; |
| 165 | out[1] = in[1]; |
| 166 | out[2] = in[2]; |
| 167 | out[3] = in[3]; |
| 168 | } |
| 169 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 170 | static INLINE void insert_4f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 171 | { |
| 172 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 173 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 174 | |
| 175 | out[0] = in[0]; |
| 176 | out[1] = in[1]; |
| 177 | out[2] = in[2]; |
| 178 | out[3] = 1; |
| 179 | } |
| 180 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 181 | static INLINE void insert_4f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 182 | { |
| 183 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 184 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 185 | |
| 186 | out[0] = in[0]; |
| 187 | out[1] = in[1]; |
| 188 | out[2] = 0; |
| 189 | out[3] = 1; |
| 190 | } |
| 191 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 192 | static INLINE void insert_4f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 193 | { |
| 194 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 195 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 196 | |
| 197 | out[0] = in[0]; |
| 198 | out[1] = 0; |
| 199 | out[2] = 0; |
| 200 | out[3] = 1; |
| 201 | } |
| 202 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 203 | static INLINE void insert_3f_xyw_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 204 | { |
| 205 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 206 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 207 | |
| 208 | out[0] = in[0]; |
| 209 | out[1] = in[1]; |
| 210 | out[2] = in[3]; |
| 211 | } |
| 212 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 213 | static INLINE void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 214 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 215 | (void) a; (void) v; (void) in; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 216 | abort(); |
| 217 | } |
| 218 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 219 | static INLINE void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 220 | { |
| 221 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 222 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 223 | |
| 224 | out[0] = in[0]; |
| 225 | out[1] = in[1]; |
| 226 | out[2] = in[2]; |
| 227 | } |
| 228 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 229 | static INLINE void insert_3f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 230 | { |
| 231 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 232 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 233 | |
| 234 | out[0] = in[0]; |
| 235 | out[1] = in[1]; |
| 236 | out[2] = 0; |
| 237 | } |
| 238 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 239 | static INLINE void insert_3f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 240 | { |
| 241 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 242 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 243 | |
| 244 | out[0] = in[0]; |
| 245 | out[1] = 0; |
| 246 | out[2] = 0; |
| 247 | } |
| 248 | |
| 249 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 250 | static INLINE void insert_2f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 251 | { |
| 252 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 253 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 254 | |
| 255 | out[0] = in[0]; |
| 256 | out[1] = in[1]; |
| 257 | } |
| 258 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 259 | static INLINE void insert_2f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 260 | { |
| 261 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 262 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 263 | |
| 264 | out[0] = in[0]; |
| 265 | out[1] = 0; |
| 266 | } |
| 267 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 268 | static INLINE void insert_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 269 | { |
| 270 | GLfloat *out = (GLfloat *)(v); |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 271 | (void) a; |
| 272 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 273 | out[0] = in[0]; |
| 274 | } |
| 275 | |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 276 | static INLINE void insert_null( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) |
| 277 | { |
| 278 | (void) a; (void) v; (void) in; |
| 279 | } |
| 280 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 281 | static INLINE void insert_4chan_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 282 | const GLfloat *in ) |
| 283 | { |
| 284 | GLchan *c = (GLchan *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 285 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 286 | UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); |
| 287 | UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); |
| 288 | UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]); |
| 289 | UNCLAMPED_FLOAT_TO_CHAN(c[3], in[3]); |
| 290 | } |
| 291 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 292 | static INLINE void insert_4chan_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 293 | const GLfloat *in ) |
| 294 | { |
| 295 | GLchan *c = (GLchan *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 296 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 297 | UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); |
| 298 | UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); |
| 299 | UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]); |
| 300 | c[3] = CHAN_MAX; |
| 301 | } |
| 302 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 303 | static INLINE void insert_4chan_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 304 | const GLfloat *in ) |
| 305 | { |
| 306 | GLchan *c = (GLchan *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 307 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 308 | UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); |
| 309 | UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); |
| 310 | c[2] = 0; |
| 311 | c[3] = CHAN_MAX; |
| 312 | } |
| 313 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 314 | static INLINE void insert_4chan_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 315 | const GLfloat *in ) |
| 316 | { |
| 317 | GLchan *c = (GLchan *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 318 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 319 | UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); |
| 320 | c[1] = 0; |
| 321 | c[2] = 0; |
| 322 | c[3] = CHAN_MAX; |
| 323 | } |
| 324 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 325 | static INLINE void insert_4ub_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 326 | const GLfloat *in ) |
| 327 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 328 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 329 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); |
| 330 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 331 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]); |
| 332 | UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]); |
| 333 | } |
| 334 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 335 | static INLINE void insert_4ub_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 336 | const GLfloat *in ) |
| 337 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 338 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 339 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); |
| 340 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 341 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]); |
| 342 | v[3] = 0xff; |
| 343 | } |
| 344 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 345 | static INLINE void insert_4ub_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 346 | const GLfloat *in ) |
| 347 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 348 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 349 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); |
| 350 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 351 | v[2] = 0; |
| 352 | v[3] = 0xff; |
| 353 | } |
| 354 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 355 | static INLINE void insert_4ub_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 356 | const GLfloat *in ) |
| 357 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 358 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 359 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); |
| 360 | v[1] = 0; |
| 361 | v[2] = 0; |
| 362 | v[3] = 0xff; |
| 363 | } |
| 364 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 365 | static INLINE void insert_4ub_4f_bgra_4( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 366 | const GLfloat *in ) |
| 367 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 368 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 369 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); |
| 370 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 371 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]); |
| 372 | UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]); |
| 373 | } |
| 374 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 375 | static INLINE void insert_4ub_4f_bgra_3( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 376 | const GLfloat *in ) |
| 377 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 378 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 379 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); |
| 380 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 381 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]); |
| 382 | v[3] = 0xff; |
| 383 | } |
| 384 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 385 | static INLINE void insert_4ub_4f_bgra_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 386 | const GLfloat *in ) |
| 387 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 388 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 389 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); |
| 390 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 391 | v[0] = 0; |
| 392 | v[3] = 0xff; |
| 393 | } |
| 394 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 395 | static INLINE void insert_4ub_4f_bgra_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 396 | const GLfloat *in ) |
| 397 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 398 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 399 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); |
| 400 | v[1] = 0; |
| 401 | v[0] = 0; |
| 402 | v[3] = 0xff; |
| 403 | } |
| 404 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 405 | static INLINE void insert_4ub_4f_argb_4( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Ian Romanick | 40e8522 | 2004-10-17 21:53:43 +0000 | [diff] [blame] | 406 | const GLfloat *in ) |
| 407 | { |
| 408 | (void) a; |
| 409 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); |
| 410 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); |
| 411 | UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]); |
| 412 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]); |
| 413 | } |
| 414 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 415 | static INLINE void insert_4ub_4f_argb_3( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Ian Romanick | 40e8522 | 2004-10-17 21:53:43 +0000 | [diff] [blame] | 416 | const GLfloat *in ) |
| 417 | { |
| 418 | (void) a; |
| 419 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); |
| 420 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); |
| 421 | UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]); |
| 422 | v[0] = 0xff; |
| 423 | } |
| 424 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 425 | static INLINE void insert_4ub_4f_argb_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Ian Romanick | 40e8522 | 2004-10-17 21:53:43 +0000 | [diff] [blame] | 426 | const GLfloat *in ) |
| 427 | { |
| 428 | (void) a; |
| 429 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); |
| 430 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); |
| 431 | v[3] = 0x00; |
| 432 | v[0] = 0xff; |
| 433 | } |
| 434 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 435 | static INLINE void insert_4ub_4f_argb_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Ian Romanick | 40e8522 | 2004-10-17 21:53:43 +0000 | [diff] [blame] | 436 | const GLfloat *in ) |
| 437 | { |
| 438 | (void) a; |
| 439 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); |
| 440 | v[2] = 0x00; |
| 441 | v[3] = 0x00; |
| 442 | v[0] = 0xff; |
| 443 | } |
| 444 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 445 | static INLINE void insert_4ub_4f_abgr_4( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Ian Romanick | 74b0080 | 2004-10-23 00:42:17 +0000 | [diff] [blame] | 446 | const GLfloat *in ) |
| 447 | { |
| 448 | (void) a; |
| 449 | UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); |
| 450 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); |
| 451 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]); |
| 452 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]); |
| 453 | } |
| 454 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 455 | static INLINE void insert_4ub_4f_abgr_3( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Ian Romanick | 74b0080 | 2004-10-23 00:42:17 +0000 | [diff] [blame] | 456 | const GLfloat *in ) |
| 457 | { |
| 458 | (void) a; |
| 459 | UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); |
| 460 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); |
| 461 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]); |
| 462 | v[0] = 0xff; |
| 463 | } |
| 464 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 465 | static INLINE void insert_4ub_4f_abgr_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Ian Romanick | 74b0080 | 2004-10-23 00:42:17 +0000 | [diff] [blame] | 466 | const GLfloat *in ) |
| 467 | { |
| 468 | (void) a; |
| 469 | UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); |
| 470 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); |
| 471 | v[1] = 0x00; |
| 472 | v[0] = 0xff; |
| 473 | } |
| 474 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 475 | static INLINE void insert_4ub_4f_abgr_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Ian Romanick | 74b0080 | 2004-10-23 00:42:17 +0000 | [diff] [blame] | 476 | const GLfloat *in ) |
| 477 | { |
| 478 | (void) a; |
| 479 | UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); |
| 480 | v[2] = 0x00; |
| 481 | v[1] = 0x00; |
| 482 | v[0] = 0xff; |
| 483 | } |
| 484 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 485 | static INLINE void insert_3ub_3f_rgb_3( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 486 | const GLfloat *in ) |
| 487 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 488 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 489 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); |
| 490 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 491 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]); |
| 492 | } |
| 493 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 494 | static INLINE void insert_3ub_3f_rgb_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 495 | const GLfloat *in ) |
| 496 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 497 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 498 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); |
| 499 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 500 | v[2] = 0; |
| 501 | } |
| 502 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 503 | static INLINE void insert_3ub_3f_rgb_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 504 | const GLfloat *in ) |
| 505 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 506 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 507 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); |
| 508 | v[1] = 0; |
| 509 | v[2] = 0; |
| 510 | } |
| 511 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 512 | static INLINE void insert_3ub_3f_bgr_3( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 513 | const GLfloat *in ) |
| 514 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 515 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 516 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); |
| 517 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 518 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]); |
| 519 | } |
| 520 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 521 | static INLINE void insert_3ub_3f_bgr_2( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 522 | const GLfloat *in ) |
| 523 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 524 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 525 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); |
| 526 | UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); |
| 527 | v[0] = 0; |
| 528 | } |
| 529 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 530 | static INLINE void insert_3ub_3f_bgr_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 531 | const GLfloat *in ) |
| 532 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 533 | (void) a; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 534 | UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); |
| 535 | v[1] = 0; |
| Keith Whitwell | ef167c6 | 2004-01-26 21:34:28 +0000 | [diff] [blame] | 536 | v[0] = 0; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 537 | } |
| 538 | |
| 539 | |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 540 | static INLINE void insert_1ub_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 541 | const GLfloat *in ) |
| 542 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 543 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 544 | UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); |
| 545 | } |
| 546 | |
| 547 | |
| 548 | /*********************************************************************** |
| 549 | * Functions to perform the reverse operations to the above, for |
| 550 | * swrast translation and clip-interpolation. |
| 551 | * |
| 552 | * Currently always extracts a full 4 floats. |
| 553 | */ |
| 554 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 555 | static void extract_4f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 556 | const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 557 | { |
| 558 | const GLfloat *in = (const GLfloat *)v; |
| 559 | const GLfloat * const vp = a->vp; |
| 560 | |
| Keith Whitwell | ef167c6 | 2004-01-26 21:34:28 +0000 | [diff] [blame] | 561 | /* Although included for completeness, the position coordinate is |
| 562 | * usually handled differently during clipping. |
| 563 | */ |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 564 | out[0] = (in[0] - vp[12]) / vp[0]; |
| 565 | out[1] = (in[1] - vp[13]) / vp[5]; |
| 566 | out[2] = (in[2] - vp[14]) / vp[10]; |
| 567 | out[3] = in[3]; |
| 568 | } |
| 569 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 570 | static void extract_3f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 571 | const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 572 | { |
| 573 | const GLfloat *in = (const GLfloat *)v; |
| 574 | const GLfloat * const vp = a->vp; |
| 575 | |
| 576 | out[0] = (in[0] - vp[12]) / vp[0]; |
| 577 | out[1] = (in[1] - vp[13]) / vp[5]; |
| 578 | out[2] = (in[2] - vp[14]) / vp[10]; |
| 579 | out[3] = 1; |
| 580 | } |
| 581 | |
| 582 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 583 | static void extract_2f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 584 | const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 585 | { |
| 586 | const GLfloat *in = (const GLfloat *)v; |
| 587 | const GLfloat * const vp = a->vp; |
| 588 | |
| 589 | out[0] = (in[0] - vp[12]) / vp[0]; |
| 590 | out[1] = (in[1] - vp[13]) / vp[5]; |
| 591 | out[2] = 0; |
| 592 | out[3] = 1; |
| 593 | } |
| 594 | |
| 595 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 596 | static void extract_4f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 597 | { |
| 598 | const GLfloat *in = (const GLfloat *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 599 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 600 | |
| 601 | out[0] = in[0]; |
| 602 | out[1] = in[1]; |
| 603 | out[2] = in[2]; |
| 604 | out[3] = in[3]; |
| 605 | } |
| 606 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 607 | static void extract_3f_xyw( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 608 | { |
| 609 | const GLfloat *in = (const GLfloat *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 610 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 611 | |
| 612 | out[0] = in[0]; |
| 613 | out[1] = in[1]; |
| Keith Whitwell | bacd9d1 | 2004-01-30 11:16:12 +0000 | [diff] [blame] | 614 | out[2] = 0; |
| 615 | out[3] = in[2]; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 619 | static void extract_3f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 620 | { |
| 621 | const GLfloat *in = (const GLfloat *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 622 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 623 | |
| 624 | out[0] = in[0]; |
| 625 | out[1] = in[1]; |
| 626 | out[2] = in[2]; |
| 627 | out[3] = 1; |
| 628 | } |
| 629 | |
| 630 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 631 | static void extract_2f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 632 | { |
| 633 | const GLfloat *in = (const GLfloat *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 634 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 635 | |
| 636 | out[0] = in[0]; |
| 637 | out[1] = in[1]; |
| 638 | out[2] = 0; |
| 639 | out[3] = 1; |
| 640 | } |
| 641 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 642 | static void extract_1f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 643 | { |
| 644 | const GLfloat *in = (const GLfloat *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 645 | (void) a; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 646 | |
| 647 | out[0] = in[0]; |
| 648 | out[1] = 0; |
| 649 | out[2] = 0; |
| 650 | out[3] = 1; |
| 651 | } |
| 652 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 653 | static void extract_4chan_4f_rgba( const struct tnl_clipspace_attr *a, GLfloat *out, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 654 | const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 655 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 656 | GLchan *c = (GLchan *)v; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 657 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 658 | |
| 659 | out[0] = CHAN_TO_FLOAT(c[0]); |
| 660 | out[1] = CHAN_TO_FLOAT(c[1]); |
| 661 | out[2] = CHAN_TO_FLOAT(c[2]); |
| 662 | out[3] = CHAN_TO_FLOAT(c[3]); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 663 | } |
| 664 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 665 | static void extract_4ub_4f_rgba( const struct tnl_clipspace_attr *a, GLfloat *out, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 666 | const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 667 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 668 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 669 | out[0] = UBYTE_TO_FLOAT(v[0]); |
| 670 | out[1] = UBYTE_TO_FLOAT(v[1]); |
| 671 | out[2] = UBYTE_TO_FLOAT(v[2]); |
| 672 | out[3] = UBYTE_TO_FLOAT(v[3]); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 673 | } |
| 674 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 675 | static void extract_4ub_4f_bgra( const struct tnl_clipspace_attr *a, GLfloat *out, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 676 | const GLubyte *v ) |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 677 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 678 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 679 | out[2] = UBYTE_TO_FLOAT(v[0]); |
| 680 | out[1] = UBYTE_TO_FLOAT(v[1]); |
| 681 | out[0] = UBYTE_TO_FLOAT(v[2]); |
| 682 | out[3] = UBYTE_TO_FLOAT(v[3]); |
| 683 | } |
| 684 | |
| Ian Romanick | 40e8522 | 2004-10-17 21:53:43 +0000 | [diff] [blame] | 685 | static void extract_4ub_4f_argb( const struct tnl_clipspace_attr *a, GLfloat *out, |
| 686 | const GLubyte *v ) |
| 687 | { |
| 688 | (void) a; |
| 689 | out[3] = UBYTE_TO_FLOAT(v[0]); |
| 690 | out[0] = UBYTE_TO_FLOAT(v[1]); |
| 691 | out[1] = UBYTE_TO_FLOAT(v[2]); |
| 692 | out[2] = UBYTE_TO_FLOAT(v[3]); |
| 693 | } |
| 694 | |
| Ian Romanick | 74b0080 | 2004-10-23 00:42:17 +0000 | [diff] [blame] | 695 | static void extract_4ub_4f_abgr( const struct tnl_clipspace_attr *a, GLfloat *out, |
| 696 | const GLubyte *v ) |
| 697 | { |
| 698 | (void) a; |
| 699 | out[3] = UBYTE_TO_FLOAT(v[0]); |
| 700 | out[2] = UBYTE_TO_FLOAT(v[1]); |
| 701 | out[1] = UBYTE_TO_FLOAT(v[2]); |
| 702 | out[0] = UBYTE_TO_FLOAT(v[3]); |
| 703 | } |
| 704 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 705 | static void extract_3ub_3f_rgb( const struct tnl_clipspace_attr *a, GLfloat *out, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 706 | const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 707 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 708 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 709 | out[0] = UBYTE_TO_FLOAT(v[0]); |
| 710 | out[1] = UBYTE_TO_FLOAT(v[1]); |
| 711 | out[2] = UBYTE_TO_FLOAT(v[2]); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 712 | out[3] = 1; |
| 713 | } |
| 714 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 715 | static void extract_3ub_3f_bgr( const struct tnl_clipspace_attr *a, GLfloat *out, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 716 | const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 717 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 718 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 719 | out[2] = UBYTE_TO_FLOAT(v[0]); |
| 720 | out[1] = UBYTE_TO_FLOAT(v[1]); |
| 721 | out[0] = UBYTE_TO_FLOAT(v[2]); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 722 | out[3] = 1; |
| 723 | } |
| 724 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 725 | static void extract_1ub_1f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 726 | { |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 727 | (void) a; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 728 | out[0] = UBYTE_TO_FLOAT(v[0]); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 729 | out[1] = 0; |
| 730 | out[2] = 0; |
| 731 | out[3] = 1; |
| 732 | } |
| 733 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 734 | |
| Daniel Borca | b6082fd | 2005-02-14 08:02:50 +0000 | [diff] [blame] | 735 | static const struct { |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 736 | const char *name; |
| Keith Whitwell | 3d38361 | 2004-07-01 13:14:05 +0000 | [diff] [blame] | 737 | tnl_extract_func extract; |
| 738 | tnl_insert_func insert[4]; |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 739 | const GLuint attrsize; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 740 | } format_info[EMIT_MAX] = { |
| 741 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 742 | { "1f", |
| 743 | extract_1f, |
| 744 | { insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 745 | sizeof(GLfloat) }, |
| 746 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 747 | { "2f", |
| 748 | extract_2f, |
| 749 | { insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 750 | 2 * sizeof(GLfloat) }, |
| 751 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 752 | { "3f", |
| 753 | extract_3f, |
| 754 | { insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 755 | 3 * sizeof(GLfloat) }, |
| 756 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 757 | { "4f", |
| 758 | extract_4f, |
| 759 | { insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 760 | 4 * sizeof(GLfloat) }, |
| 761 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 762 | { "2f_viewport", |
| 763 | extract_2f_viewport, |
| 764 | { insert_2f_viewport_1, insert_2f_viewport_2, insert_2f_viewport_2, |
| 765 | insert_2f_viewport_2 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 766 | 2 * sizeof(GLfloat) }, |
| 767 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 768 | { "3f_viewport", |
| 769 | extract_3f_viewport, |
| 770 | { insert_3f_viewport_1, insert_3f_viewport_2, insert_3f_viewport_3, |
| 771 | insert_3f_viewport_3 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 772 | 3 * sizeof(GLfloat) }, |
| 773 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 774 | { "4f_viewport", |
| 775 | extract_4f_viewport, |
| 776 | { insert_4f_viewport_1, insert_4f_viewport_2, insert_4f_viewport_3, |
| 777 | insert_4f_viewport_4 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 778 | 4 * sizeof(GLfloat) }, |
| 779 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 780 | { "3f_xyw", |
| 781 | extract_3f_xyw, |
| 782 | { insert_3f_xyw_err, insert_3f_xyw_err, insert_3f_xyw_err, |
| 783 | insert_3f_xyw_4 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 784 | 3 * sizeof(GLfloat) }, |
| 785 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 786 | { "1ub_1f", |
| 787 | extract_1ub_1f, |
| 788 | { insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 789 | sizeof(GLubyte) }, |
| 790 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 791 | { "3ub_3f_rgb", |
| 792 | extract_3ub_3f_rgb, |
| 793 | { insert_3ub_3f_rgb_1, insert_3ub_3f_rgb_2, insert_3ub_3f_rgb_3, |
| 794 | insert_3ub_3f_rgb_3 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 795 | 3 * sizeof(GLubyte) }, |
| 796 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 797 | { "3ub_3f_bgr", |
| 798 | extract_3ub_3f_bgr, |
| 799 | { insert_3ub_3f_bgr_1, insert_3ub_3f_bgr_2, insert_3ub_3f_bgr_3, |
| 800 | insert_3ub_3f_bgr_3 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 801 | 3 * sizeof(GLubyte) }, |
| 802 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 803 | { "4ub_4f_rgba", |
| 804 | extract_4ub_4f_rgba, |
| 805 | { insert_4ub_4f_rgba_1, insert_4ub_4f_rgba_2, insert_4ub_4f_rgba_3, |
| 806 | insert_4ub_4f_rgba_4 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 807 | 4 * sizeof(GLubyte) }, |
| 808 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 809 | { "4ub_4f_bgra", |
| 810 | extract_4ub_4f_bgra, |
| 811 | { insert_4ub_4f_bgra_1, insert_4ub_4f_bgra_2, insert_4ub_4f_bgra_3, |
| 812 | insert_4ub_4f_bgra_4 }, |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 813 | 4 * sizeof(GLubyte) }, |
| 814 | |
| Ian Romanick | 40e8522 | 2004-10-17 21:53:43 +0000 | [diff] [blame] | 815 | { "4ub_4f_argb", |
| 816 | extract_4ub_4f_argb, |
| 817 | { insert_4ub_4f_argb_1, insert_4ub_4f_argb_2, insert_4ub_4f_argb_3, |
| 818 | insert_4ub_4f_argb_4 }, |
| 819 | 4 * sizeof(GLubyte) }, |
| 820 | |
| Ian Romanick | 74b0080 | 2004-10-23 00:42:17 +0000 | [diff] [blame] | 821 | { "4ub_4f_abgr", |
| 822 | extract_4ub_4f_abgr, |
| 823 | { insert_4ub_4f_abgr_1, insert_4ub_4f_abgr_2, insert_4ub_4f_abgr_3, |
| 824 | insert_4ub_4f_abgr_4 }, |
| 825 | 4 * sizeof(GLubyte) }, |
| 826 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 827 | { "4chan_4f_rgba", |
| 828 | extract_4chan_4f_rgba, |
| 829 | { insert_4chan_4f_rgba_1, insert_4chan_4f_rgba_2, insert_4chan_4f_rgba_3, |
| 830 | insert_4chan_4f_rgba_4 }, |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 831 | 4 * sizeof(GLchan) }, |
| 832 | |
| 833 | { "pad", |
| Keith Whitwell | b97e478 | 2005-02-10 10:57:22 +0000 | [diff] [blame] | 834 | NULL, |
| 835 | { NULL, NULL, NULL, NULL }, |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 836 | 0 } |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 837 | |
| 838 | }; |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 839 | |
| 840 | |
| 841 | |
| 842 | |
| 843 | /*********************************************************************** |
| 844 | * Hardwired fastpaths for emitting whole vertices or groups of |
| 845 | * vertices |
| 846 | */ |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 847 | static void choose_emit_func( GLcontext *ctx, GLuint count, GLubyte *dest); |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 848 | |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 849 | |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 850 | #define EMIT5(NR, F0, F1, F2, F3, F4, NAME) \ |
| 851 | static void NAME( GLcontext *ctx, \ |
| 852 | GLuint count, \ |
| 853 | GLubyte *v ) \ |
| 854 | { \ |
| 855 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); \ |
| 856 | struct tnl_clipspace_attr *a = vtx->attr; \ |
| 857 | GLuint i; \ |
| 858 | \ |
| 859 | if (vtx->attr_count != NR || \ |
| 860 | (NR > 0 && a[0].emit != F0) || \ |
| 861 | (NR > 1 && a[1].emit != F1) || \ |
| 862 | (NR > 2 && a[2].emit != F2) || \ |
| 863 | (NR > 3 && a[3].emit != F3) || \ |
| 864 | (NR > 4 && a[4].emit != F4)) { \ |
| 865 | choose_emit_func( ctx, count, v ); \ |
| 866 | return; \ |
| 867 | } \ |
| 868 | \ |
| 869 | for (i = 0 ; i < count ; i++, v += vtx->vertex_size) { \ |
| 870 | if (NR > 0) { \ |
| 871 | F0( &a[0], v + a[0].vertoffset, (GLfloat *)a[0].inputptr ); \ |
| 872 | a[0].inputptr += a[0].inputstride; \ |
| 873 | } \ |
| 874 | \ |
| 875 | if (NR > 1) { \ |
| 876 | F1( &a[1], v + a[1].vertoffset, (GLfloat *)a[1].inputptr ); \ |
| 877 | a[1].inputptr += a[1].inputstride; \ |
| 878 | } \ |
| 879 | \ |
| 880 | if (NR > 2) { \ |
| Keith Whitwell | f0e4f5e | 2005-01-07 16:43:39 +0000 | [diff] [blame] | 881 | F2( &a[2], v + a[2].vertoffset, (GLfloat *)a[2].inputptr ); \ |
| 882 | a[2].inputptr += a[2].inputstride; \ |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 883 | } \ |
| 884 | \ |
| 885 | if (NR > 3) { \ |
| Keith Whitwell | f0e4f5e | 2005-01-07 16:43:39 +0000 | [diff] [blame] | 886 | F3( &a[3], v + a[3].vertoffset, (GLfloat *)a[3].inputptr ); \ |
| 887 | a[3].inputptr += a[3].inputstride; \ |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 888 | } \ |
| 889 | \ |
| 890 | if (NR > 4) { \ |
| Keith Whitwell | f0e4f5e | 2005-01-07 16:43:39 +0000 | [diff] [blame] | 891 | F4( &a[4], v + a[4].vertoffset, (GLfloat *)a[4].inputptr ); \ |
| 892 | a[4].inputptr += a[4].inputstride; \ |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 893 | } \ |
| 894 | } \ |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 895 | } |
| 896 | |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 897 | |
| 898 | #define EMIT2(F0, F1, NAME) EMIT5(2, F0, F1, insert_null, \ |
| 899 | insert_null, insert_null, NAME) |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 900 | |
| Keith Whitwell | f0e4f5e | 2005-01-07 16:43:39 +0000 | [diff] [blame] | 901 | #define EMIT3(F0, F1, F2, NAME) EMIT5(3, F0, F1, F2, insert_null, \ |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 902 | insert_null, NAME) |
| 903 | |
| Keith Whitwell | f0e4f5e | 2005-01-07 16:43:39 +0000 | [diff] [blame] | 904 | #define EMIT4(F0, F1, F2, F3, NAME) EMIT5(4, F0, F1, F2, F3, \ |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 905 | insert_null, NAME) |
| 906 | |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 907 | |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 908 | EMIT2(insert_3f_viewport_3, insert_4ub_4f_rgba_4, emit_viewport3_rgba4) |
| 909 | EMIT2(insert_3f_viewport_3, insert_4ub_4f_bgra_4, emit_viewport3_bgra4) |
| 910 | EMIT2(insert_3f_3, insert_4ub_4f_rgba_4, emit_xyz3_rgba4) |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 911 | |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 912 | EMIT3(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_viewport4_rgba4_st2) |
| 913 | EMIT3(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, emit_viewport4_bgra4_st2) |
| 914 | EMIT3(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_xyzw4_rgba4_st2) |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 915 | |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 916 | EMIT4(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_viewport4_rgba4_st2_st2) |
| 917 | EMIT4(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, insert_2f_2, emit_viewport4_bgra4_st2_st2) |
| 918 | EMIT4(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_xyzw4_rgba4_st2_st2) |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 919 | |
| 920 | |
| Keith Whitwell | ae73b3d | 2005-01-07 16:25:40 +0000 | [diff] [blame] | 921 | |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 922 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 923 | |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 924 | /*********************************************************************** |
| 925 | * Generic (non-codegen) functions for whole vertices or groups of |
| 926 | * vertices |
| 927 | */ |
| 928 | |
| 929 | static void generic_emit( GLcontext *ctx, |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 930 | GLuint count, |
| 931 | GLubyte *v ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 932 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 933 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 934 | struct tnl_clipspace_attr *a = vtx->attr; |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 935 | const GLuint attr_count = vtx->attr_count; |
| 936 | const GLuint stride = vtx->vertex_size; |
| Karl Schultz | c6c4cd8 | 2004-01-13 01:11:09 +0000 | [diff] [blame] | 937 | GLuint i, j; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 938 | |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 939 | for (i = 0 ; i < count ; i++, v += stride) { |
| 940 | for (j = 0; j < attr_count; j++) { |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 941 | GLfloat *in = (GLfloat *)a[j].inputptr; |
| 942 | a[j].inputptr += a[j].inputstride; |
| 943 | a[j].emit( &a[j], v + a[j].vertoffset, in ); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 944 | } |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | |
| 949 | static void generic_interp( GLcontext *ctx, |
| 950 | GLfloat t, |
| 951 | GLuint edst, GLuint eout, GLuint ein, |
| 952 | GLboolean force_boundary ) |
| 953 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 954 | TNLcontext *tnl = TNL_CONTEXT(ctx); |
| 955 | struct vertex_buffer *VB = &tnl->vb; |
| 956 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 957 | const GLubyte *vin = vtx->vertex_buf + ein * vtx->vertex_size; |
| 958 | const GLubyte *vout = vtx->vertex_buf + eout * vtx->vertex_size; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 959 | GLubyte *vdst = vtx->vertex_buf + edst * vtx->vertex_size; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 960 | const struct tnl_clipspace_attr *a = vtx->attr; |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 961 | const GLuint attr_count = vtx->attr_count; |
| 962 | GLuint j; |
| Brian Paul | a6c423d | 2004-08-25 15:59:48 +0000 | [diff] [blame] | 963 | (void) force_boundary; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 964 | |
| 965 | if (tnl->NeedNdcCoords) { |
| 966 | const GLfloat *dstclip = VB->ClipPtr->data[edst]; |
| Keith Whitwell | fb2a95b | 2004-01-08 13:55:24 +0000 | [diff] [blame] | 967 | if (dstclip[3] != 0.0) { |
| Karl Schultz | c6c4cd8 | 2004-01-13 01:11:09 +0000 | [diff] [blame] | 968 | const GLfloat w = 1.0f / dstclip[3]; |
| Keith Whitwell | fb2a95b | 2004-01-08 13:55:24 +0000 | [diff] [blame] | 969 | GLfloat pos[4]; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 970 | |
| Keith Whitwell | fb2a95b | 2004-01-08 13:55:24 +0000 | [diff] [blame] | 971 | pos[0] = dstclip[0] * w; |
| 972 | pos[1] = dstclip[1] * w; |
| 973 | pos[2] = dstclip[2] * w; |
| 974 | pos[3] = w; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 975 | |
| Keith Whitwell | fb2a95b | 2004-01-08 13:55:24 +0000 | [diff] [blame] | 976 | a[0].insert[4-1]( &a[0], vdst, pos ); |
| 977 | } |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 978 | } |
| 979 | else { |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 980 | a[0].insert[4-1]( &a[0], vdst, VB->ClipPtr->data[edst] ); |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | |
| 984 | for (j = 1; j < attr_count; j++) { |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 985 | GLfloat fin[4], fout[4], fdst[4]; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 986 | |
| 987 | a[j].extract( &a[j], fin, vin + a[j].vertoffset ); |
| 988 | a[j].extract( &a[j], fout, vout + a[j].vertoffset ); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 989 | |
| 990 | INTERP_F( t, fdst[3], fout[3], fin[3] ); |
| 991 | INTERP_F( t, fdst[2], fout[2], fin[2] ); |
| 992 | INTERP_F( t, fdst[1], fout[1], fin[1] ); |
| 993 | INTERP_F( t, fdst[0], fout[0], fin[0] ); |
| 994 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 995 | a[j].insert[4-1]( &a[j], vdst + a[j].vertoffset, fdst ); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 996 | } |
| 997 | } |
| 998 | |
| 999 | |
| 1000 | /* Extract color attributes from one vertex and insert them into |
| 1001 | * another. (Shortcircuit extract/insert with memcpy). |
| 1002 | */ |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1003 | static void generic_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1004 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1005 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 1006 | GLubyte *vsrc = vtx->vertex_buf + esrc * vtx->vertex_size; |
| 1007 | GLubyte *vdst = vtx->vertex_buf + edst * vtx->vertex_size; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1008 | const struct tnl_clipspace_attr *a = vtx->attr; |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 1009 | const GLuint attr_count = vtx->attr_count; |
| 1010 | GLuint j; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1011 | |
| 1012 | for (j = 0; j < attr_count; j++) { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1013 | if (a[j].attrib == VERT_ATTRIB_COLOR0 || |
| 1014 | a[j].attrib == VERT_ATTRIB_COLOR1) { |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1015 | |
| Brian Paul | 3663c0f | 2004-01-15 00:29:51 +0000 | [diff] [blame] | 1016 | _mesa_memcpy( vdst + a[j].vertoffset, |
| 1017 | vsrc + a[j].vertoffset, |
| 1018 | a[j].vertattrsize ); |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1019 | } |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1020 | } |
| 1021 | } |
| 1022 | |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1023 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1024 | /* Helper functions for hardware which doesn't put back colors and/or |
| 1025 | * edgeflags into vertices. |
| 1026 | */ |
| 1027 | static void generic_interp_extras( GLcontext *ctx, |
| 1028 | GLfloat t, |
| 1029 | GLuint dst, GLuint out, GLuint in, |
| 1030 | GLboolean force_boundary ) |
| 1031 | { |
| 1032 | struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
| 1033 | |
| Keith Whitwell | a887a44 | 2005-01-10 12:30:08 +0000 | [diff] [blame] | 1034 | /* If stride is zero, ColorPtr[1] is constant across the VB, so |
| 1035 | * there is no point interpolating between two values as they will |
| 1036 | * be identical. In all other cases, this value is generated by |
| 1037 | * t_vb_lighttmp.h and has a stride of 4 dwords. |
| 1038 | */ |
| 1039 | if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1040 | assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat)); |
| 1041 | |
| 1042 | INTERP_4F( t, |
| 1043 | VB->ColorPtr[1]->data[dst], |
| 1044 | VB->ColorPtr[1]->data[out], |
| 1045 | VB->ColorPtr[1]->data[in] ); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1046 | } |
| Keith Whitwell | a887a44 | 2005-01-10 12:30:08 +0000 | [diff] [blame] | 1047 | |
| 1048 | if (VB->SecondaryColorPtr[1]) { |
| 1049 | assert(VB->SecondaryColorPtr[1]->stride == 4 * sizeof(GLfloat)); |
| 1050 | |
| 1051 | INTERP_3F( t, |
| 1052 | VB->SecondaryColorPtr[1]->data[dst], |
| 1053 | VB->SecondaryColorPtr[1]->data[out], |
| 1054 | VB->SecondaryColorPtr[1]->data[in] ); |
| 1055 | } |
| 1056 | |
| 1057 | if (VB->IndexPtr[1]) { |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 1058 | VB->IndexPtr[1]->data[dst][0] = LINTERP( t, |
| 1059 | VB->IndexPtr[1]->data[out][0], |
| 1060 | VB->IndexPtr[1]->data[in][0] ); |
| 1061 | } |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1062 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1063 | if (VB->EdgeFlag) { |
| 1064 | VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary; |
| 1065 | } |
| 1066 | |
| 1067 | generic_interp(ctx, t, dst, out, in, force_boundary); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1068 | } |
| 1069 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1070 | static void generic_copy_pv_extras( GLcontext *ctx, |
| 1071 | GLuint dst, GLuint src ) |
| 1072 | { |
| 1073 | struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
| 1074 | |
| Keith Whitwell | a887a44 | 2005-01-10 12:30:08 +0000 | [diff] [blame] | 1075 | /* See above comment: |
| 1076 | */ |
| 1077 | if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1078 | COPY_4FV( VB->ColorPtr[1]->data[dst], |
| 1079 | VB->ColorPtr[1]->data[src] ); |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1080 | } |
| Keith Whitwell | a887a44 | 2005-01-10 12:30:08 +0000 | [diff] [blame] | 1081 | |
| 1082 | if (VB->SecondaryColorPtr[1]) { |
| 1083 | COPY_4FV( VB->SecondaryColorPtr[1]->data[dst], |
| 1084 | VB->SecondaryColorPtr[1]->data[src] ); |
| 1085 | } |
| 1086 | |
| 1087 | if (VB->IndexPtr[1]) { |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 1088 | VB->IndexPtr[1]->data[dst][0] = VB->IndexPtr[1]->data[src][0]; |
| 1089 | } |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1090 | |
| Keith Whitwell | ef167c6 | 2004-01-26 21:34:28 +0000 | [diff] [blame] | 1091 | generic_copy_pv(ctx, dst, src); |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1092 | } |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1093 | |
| 1094 | |
| 1095 | |
| 1096 | |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1097 | /*********************************************************************** |
| 1098 | * Build codegen functions or return generic ones: |
| 1099 | */ |
| 1100 | |
| 1101 | |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1102 | static void choose_emit_func( GLcontext *ctx, GLuint count, GLubyte *dest) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1103 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1104 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1105 | struct tnl_clipspace_attr *a = vtx->attr; |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1106 | const GLuint attr_count = vtx->attr_count; |
| 1107 | |
| Keith Whitwell | b97e478 | 2005-02-10 10:57:22 +0000 | [diff] [blame] | 1108 | vtx->emit = NULL; |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1109 | |
| 1110 | if (0) |
| 1111 | vtx->emit = _tnl_codegen_emit(ctx); |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1112 | |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 1113 | /* Does it fit a hardwired fastpath? Help! this is growing out of |
| 1114 | * control! |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1115 | */ |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 1116 | switch (attr_count) { |
| 1117 | case 2: |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1118 | if (a[0].emit == insert_3f_viewport_3) { |
| 1119 | if (a[1].emit == insert_4ub_4f_bgra_4) |
| 1120 | vtx->emit = emit_viewport3_bgra4; |
| 1121 | else if (a[1].emit == insert_4ub_4f_rgba_4) |
| 1122 | vtx->emit = emit_viewport3_rgba4; |
| 1123 | } |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 1124 | else if (a[0].emit == insert_3f_3 && |
| 1125 | a[1].emit == insert_4ub_4f_rgba_4) { |
| 1126 | vtx->emit = emit_xyz3_rgba4; |
| 1127 | } |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 1128 | break; |
| 1129 | case 3: |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 1130 | if (a[2].emit == insert_2f_2) { |
| 1131 | if (a[1].emit == insert_4ub_4f_rgba_4) { |
| 1132 | if (a[0].emit == insert_4f_viewport_4) |
| 1133 | vtx->emit = emit_viewport4_rgba4_st2; |
| 1134 | else if (a[0].emit == insert_4f_4) |
| 1135 | vtx->emit = emit_xyzw4_rgba4_st2; |
| 1136 | } |
| 1137 | else if (a[1].emit == insert_4ub_4f_bgra_4 && |
| 1138 | a[0].emit == insert_4f_viewport_4) |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 1139 | vtx->emit = emit_viewport4_bgra4_st2; |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 1140 | } |
| Felix Kuehling | e4499ed | 2005-01-08 15:51:11 +0000 | [diff] [blame] | 1141 | break; |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 1142 | case 4: |
| 1143 | if (a[2].emit == insert_2f_2 && |
| 1144 | a[3].emit == insert_2f_2) { |
| 1145 | if (a[1].emit == insert_4ub_4f_rgba_4) { |
| 1146 | if (a[0].emit == insert_4f_viewport_4) |
| 1147 | vtx->emit = emit_viewport4_rgba4_st2_st2; |
| 1148 | else if (a[0].emit == insert_4f_4) |
| 1149 | vtx->emit = emit_xyzw4_rgba4_st2_st2; |
| 1150 | } |
| 1151 | else if (a[1].emit == insert_4ub_4f_bgra_4 && |
| 1152 | a[0].emit == insert_4f_viewport_4) |
| 1153 | vtx->emit = emit_viewport4_bgra4_st2_st2; |
| Keith Whitwell | 699fc6b | 2005-01-05 20:56:05 +0000 | [diff] [blame] | 1154 | } |
| 1155 | break; |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1156 | } |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1157 | |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1158 | /* Otherwise use the generic version: |
| 1159 | */ |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1160 | if (!vtx->emit) |
| 1161 | vtx->emit = generic_emit; |
| 1162 | |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1163 | vtx->emit( ctx, count, dest ); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1164 | } |
| 1165 | |
| 1166 | |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1167 | |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1168 | static void choose_interp_func( GLcontext *ctx, |
| 1169 | GLfloat t, |
| 1170 | GLuint edst, GLuint eout, GLuint ein, |
| 1171 | GLboolean force_boundary ) |
| 1172 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1173 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1174 | |
| 1175 | if (vtx->need_extras && |
| 1176 | (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { |
| 1177 | vtx->interp = generic_interp_extras; |
| 1178 | } else { |
| 1179 | vtx->interp = generic_interp; |
| 1180 | } |
| 1181 | |
| 1182 | vtx->interp( ctx, t, edst, eout, ein, force_boundary ); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1186 | static void choose_copy_pv_func( GLcontext *ctx, GLuint edst, GLuint esrc ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1187 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1188 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1189 | |
| 1190 | if (vtx->need_extras && |
| 1191 | (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { |
| 1192 | vtx->copy_pv = generic_copy_pv_extras; |
| 1193 | } else { |
| 1194 | vtx->copy_pv = generic_copy_pv; |
| 1195 | } |
| 1196 | |
| 1197 | vtx->copy_pv( ctx, edst, esrc ); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1198 | } |
| 1199 | |
| 1200 | |
| 1201 | /*********************************************************************** |
| 1202 | * Public entrypoints, mostly dispatch to the above: |
| 1203 | */ |
| 1204 | |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1205 | |
| 1206 | /* Interpolate between two vertices to produce a third: |
| 1207 | */ |
| 1208 | void _tnl_interp( GLcontext *ctx, |
| 1209 | GLfloat t, |
| 1210 | GLuint edst, GLuint eout, GLuint ein, |
| 1211 | GLboolean force_boundary ) |
| 1212 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1213 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1214 | vtx->interp( ctx, t, edst, eout, ein, force_boundary ); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1215 | } |
| 1216 | |
| 1217 | /* Copy colors from one vertex to another: |
| 1218 | */ |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1219 | void _tnl_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1220 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1221 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1222 | vtx->copy_pv( ctx, edst, esrc ); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | |
| 1226 | /* Extract a named attribute from a hardware vertex. Will have to |
| 1227 | * reverse any viewport transformation, swizzling or other conversions |
| 1228 | * which may have been applied: |
| 1229 | */ |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1230 | void _tnl_get_attr( GLcontext *ctx, const void *vin, |
| 1231 | GLenum attr, GLfloat *dest ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1232 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1233 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1234 | const struct tnl_clipspace_attr *a = vtx->attr; |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 1235 | const GLuint attr_count = vtx->attr_count; |
| 1236 | GLuint j; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1237 | |
| 1238 | for (j = 0; j < attr_count; j++) { |
| Brian Paul | bdd15b5 | 2004-05-04 15:11:06 +0000 | [diff] [blame] | 1239 | if (a[j].attrib == attr) { |
| Keith Whitwell | 44d4a8f | 2004-01-06 00:18:03 +0000 | [diff] [blame] | 1240 | a[j].extract( &a[j], dest, (GLubyte *)vin + a[j].vertoffset ); |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1241 | return; |
| 1242 | } |
| 1243 | } |
| 1244 | |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 1245 | /* Else return the value from ctx->Current. |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1246 | */ |
| Brian Paul | 3663c0f | 2004-01-15 00:29:51 +0000 | [diff] [blame] | 1247 | _mesa_memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat)); |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1248 | } |
| 1249 | |
| Keith Whitwell | 4773634 | 2004-02-16 15:15:24 +0000 | [diff] [blame] | 1250 | |
| 1251 | /* Complementary operation to the above. |
| 1252 | */ |
| 1253 | void _tnl_set_attr( GLcontext *ctx, void *vout, |
| 1254 | GLenum attr, const GLfloat *src ) |
| 1255 | { |
| 1256 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1257 | const struct tnl_clipspace_attr *a = vtx->attr; |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 1258 | const GLuint attr_count = vtx->attr_count; |
| 1259 | GLuint j; |
| Keith Whitwell | 4773634 | 2004-02-16 15:15:24 +0000 | [diff] [blame] | 1260 | |
| 1261 | for (j = 0; j < attr_count; j++) { |
| Brian Paul | bdd15b5 | 2004-05-04 15:11:06 +0000 | [diff] [blame] | 1262 | if (a[j].attrib == attr) { |
| Keith Whitwell | 4773634 | 2004-02-16 15:15:24 +0000 | [diff] [blame] | 1263 | a[j].insert[4-1]( &a[j], (GLubyte *)vout + a[j].vertoffset, src ); |
| 1264 | return; |
| 1265 | } |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1270 | void *_tnl_get_vertex( GLcontext *ctx, GLuint nr ) |
| 1271 | { |
| 1272 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1273 | |
| 1274 | return vtx->vertex_buf + nr * vtx->vertex_size; |
| 1275 | } |
| 1276 | |
| 1277 | void _tnl_invalidate_vertex_state( GLcontext *ctx, GLuint new_state ) |
| 1278 | { |
| 1279 | if (new_state & (_DD_NEW_TRI_LIGHT_TWOSIDE|_DD_NEW_TRI_UNFILLED) ) { |
| 1280 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1281 | vtx->new_inputs = ~0; |
| 1282 | vtx->interp = choose_interp_func; |
| 1283 | vtx->copy_pv = choose_copy_pv_func; |
| 1284 | } |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1288 | GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map, |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 1289 | GLuint nr, const GLfloat *vp, |
| 1290 | GLuint unpacked_size ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1291 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1292 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 1293 | GLuint offset = 0; |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 1294 | GLuint i, j; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1295 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1296 | assert(nr < _TNL_ATTRIB_MAX); |
| 1297 | assert(nr == 0 || map[0].attrib == VERT_ATTRIB_POS); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1298 | |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 1299 | if (vtx->emit == generic_emit) |
| 1300 | vtx->emit = choose_emit_func; |
| 1301 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1302 | vtx->interp = choose_interp_func; |
| 1303 | vtx->copy_pv = choose_copy_pv_func; |
| 1304 | vtx->new_inputs = ~0; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1305 | |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 1306 | for (j = 0, i = 0; i < nr; i++) { |
| Brian Paul | fde4c53 | 2004-03-13 18:27:06 +0000 | [diff] [blame] | 1307 | const GLuint format = map[i].format; |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 1308 | if (format == EMIT_PAD) { |
| Brian Paul | bbea6ec | 2004-07-02 14:35:50 +0000 | [diff] [blame] | 1309 | /* |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1310 | fprintf(stderr, "%d: pad %d, offset %d\n", i, |
| 1311 | map[i].offset, offset); |
| Brian Paul | bbea6ec | 2004-07-02 14:35:50 +0000 | [diff] [blame] | 1312 | */ |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1313 | offset += map[i].offset; |
| Keith Whitwell | 16f5421 | 2004-01-05 15:55:01 +0000 | [diff] [blame] | 1314 | |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 1315 | } |
| 1316 | else { |
| 1317 | vtx->attr[j].attrib = map[i].attrib; |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1318 | vtx->attr[j].format = format; |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 1319 | vtx->attr[j].vp = vp; |
| 1320 | vtx->attr[j].insert = format_info[format].insert; |
| 1321 | vtx->attr[j].extract = format_info[format].extract; |
| 1322 | vtx->attr[j].vertattrsize = format_info[format].attrsize; |
| Keith Whitwell | 44d4a8f | 2004-01-06 00:18:03 +0000 | [diff] [blame] | 1323 | |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 1324 | if (unpacked_size) |
| 1325 | vtx->attr[j].vertoffset = map[i].offset; |
| 1326 | else |
| 1327 | vtx->attr[j].vertoffset = offset; |
| 1328 | |
| Brian Paul | bbea6ec | 2004-07-02 14:35:50 +0000 | [diff] [blame] | 1329 | /* |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1330 | fprintf(stderr, "%d: %s, vp %p, offset %d\n", i, |
| 1331 | format_info[format].name, (void *)vp, |
| 1332 | vtx->attr[j].vertoffset); |
| Brian Paul | bbea6ec | 2004-07-02 14:35:50 +0000 | [diff] [blame] | 1333 | */ |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 1334 | offset += format_info[format].attrsize; |
| 1335 | j++; |
| 1336 | } |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1337 | } |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1338 | |
| Keith Whitwell | 4d36f33 | 2004-01-21 15:31:46 +0000 | [diff] [blame] | 1339 | vtx->attr_count = j; |
| 1340 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 1341 | if (unpacked_size) |
| 1342 | vtx->vertex_size = unpacked_size; |
| 1343 | else |
| 1344 | vtx->vertex_size = offset; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1345 | |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 1346 | assert(vtx->vertex_size <= vtx->max_vertex_size); |
| 1347 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1348 | return vtx->vertex_size; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1349 | } |
| 1350 | |
| 1351 | |
| 1352 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1353 | void _tnl_invalidate_vertices( GLcontext *ctx, GLuint newinputs ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1354 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1355 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1356 | vtx->new_inputs |= newinputs; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1357 | } |
| 1358 | |
| 1359 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1360 | void _tnl_build_vertices( GLcontext *ctx, |
| Keith Whitwell | 8d97ad1 | 2004-01-19 23:29:40 +0000 | [diff] [blame] | 1361 | GLuint start, |
| 1362 | GLuint end, |
| 1363 | GLuint newinputs ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1364 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1365 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1366 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1367 | newinputs |= vtx->new_inputs; |
| 1368 | vtx->new_inputs = 0; |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1369 | |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1370 | if (newinputs) { |
| 1371 | struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
| 1372 | struct tnl_clipspace_attr *a = vtx->attr; |
| 1373 | const GLuint stride = vtx->vertex_size; |
| 1374 | const GLuint count = vtx->attr_count; |
| 1375 | GLuint j; |
| 1376 | |
| 1377 | for (j = 0; j < count; j++) { |
| 1378 | GLvector4f *vptr = VB->AttribPtr[a[j].attrib]; |
| 1379 | a[j].inputstride = vptr->stride; |
| 1380 | a[j].inputptr = ((GLubyte *)vptr->data) + start * vptr->stride; |
| 1381 | a[j].emit = a[j].insert[vptr->size - 1]; |
| 1382 | } |
| 1383 | |
| 1384 | vtx->emit( ctx, end - start, |
| 1385 | (GLubyte *)vtx->vertex_buf + start * stride ); |
| 1386 | } |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1387 | } |
| 1388 | |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 1389 | /* Emit VB vertices start..end to dest. Note that VB vertex at |
| 1390 | * postion start will be emitted to dest at position zero. |
| 1391 | */ |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1392 | void *_tnl_emit_vertices_to_buffer( GLcontext *ctx, |
| Keith Whitwell | 8d97ad1 | 2004-01-19 23:29:40 +0000 | [diff] [blame] | 1393 | GLuint start, |
| 1394 | GLuint end, |
| 1395 | void *dest ) |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1396 | { |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1397 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| Keith Whitwell | 9a8a9fb | 2005-01-05 12:58:14 +0000 | [diff] [blame] | 1398 | struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
| 1399 | struct tnl_clipspace_attr *a = vtx->attr; |
| 1400 | const GLuint count = vtx->attr_count; |
| 1401 | GLuint j; |
| 1402 | |
| 1403 | for (j = 0; j < count; j++) { |
| 1404 | GLvector4f *vptr = VB->AttribPtr[a[j].attrib]; |
| 1405 | a[j].inputstride = vptr->stride; |
| 1406 | a[j].inputptr = ((GLubyte *)vptr->data) + start * vptr->stride; |
| 1407 | a[j].emit = a[j].insert[vptr->size - 1]; |
| 1408 | } |
| 1409 | |
| 1410 | /* Note: dest should not be adjusted for non-zero 'start' values: |
| 1411 | */ |
| 1412 | vtx->emit( ctx, end - start, dest ); |
| 1413 | |
| Keith Whitwell | 8d97ad1 | 2004-01-19 23:29:40 +0000 | [diff] [blame] | 1414 | return (void *)((GLubyte *)dest + vtx->vertex_size * (end - start)); |
| Keith Whitwell | fabb973 | 2003-12-21 17:54:31 +0000 | [diff] [blame] | 1415 | } |
| 1416 | |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1417 | |
| 1418 | void _tnl_init_vertices( GLcontext *ctx, |
| 1419 | GLuint vb_size, |
| 1420 | GLuint max_vertex_size ) |
| 1421 | { |
| 1422 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1423 | |
| Keith Whitwell | b97e478 | 2005-02-10 10:57:22 +0000 | [diff] [blame] | 1424 | _tnl_install_attrs( ctx, NULL, 0, NULL, 0 ); |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1425 | |
| 1426 | vtx->need_extras = GL_TRUE; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 1427 | if (max_vertex_size > vtx->max_vertex_size) { |
| 1428 | _tnl_free_vertices( ctx ); |
| 1429 | vtx->max_vertex_size = max_vertex_size; |
| Brian Paul | cb7c689 | 2004-01-26 16:16:16 +0000 | [diff] [blame] | 1430 | vtx->vertex_buf = (GLubyte *)ALIGN_CALLOC(vb_size * max_vertex_size, 32 ); |
| Keith Whitwell | fa13622 | 2005-01-07 15:54:48 +0000 | [diff] [blame] | 1431 | vtx->emit = choose_emit_func; |
| Keith Whitwell | 5882257 | 2004-01-05 15:24:53 +0000 | [diff] [blame] | 1432 | } |
| Keith Whitwell | 009aa3e | 2004-06-30 11:48:21 +0000 | [diff] [blame] | 1433 | |
| 1434 | _tnl_init_c_codegen( &vtx->codegen ); |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | |
| 1438 | void _tnl_free_vertices( GLcontext *ctx ) |
| 1439 | { |
| 1440 | struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); |
| 1441 | if (vtx->vertex_buf) { |
| 1442 | ALIGN_FREE(vtx->vertex_buf); |
| Keith Whitwell | b97e478 | 2005-02-10 10:57:22 +0000 | [diff] [blame] | 1443 | vtx->vertex_buf = NULL; |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1444 | } |
| Keith Whitwell | 0aca086 | 2005-01-12 19:38:41 +0000 | [diff] [blame] | 1445 | |
| 1446 | _tnl_free_c_codegen( &vtx->codegen ); |
| Keith Whitwell | 7907340 | 2004-01-05 09:43:42 +0000 | [diff] [blame] | 1447 | } |