[intel-GEM] Add tiling support to swrast.
[mesa.git] / src / mesa / drivers / dri / intel / intel_span.c
1 /**************************************************************************
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include "glheader.h"
29 #include "macros.h"
30 #include "mtypes.h"
31 #include "colormac.h"
32
33 #include "intel_fbo.h"
34 #include "intel_screen.h"
35 #include "intel_span.h"
36 #include "intel_regions.h"
37 #include "intel_ioctl.h"
38 #include "intel_tex.h"
39
40 #include "swrast/swrast.h"
41
42 /*
43 * Deal with tiled surfaces
44 */
45
46 #if 0
47 /* These are pre-965 tile swizzling functions -- power of two widths */
48 static uintptr_t x_tile_swizzle_pow2 (uintptr_t addr, int n)
49 {
50 uintptr_t a = addr;
51 uintptr_t base_mask = (((~0) << (n + 4)) | 0xff);
52 uintptr_t x_mask = ((~0) << 12) & ~base_mask;
53
54 a = ((a & base_mask) |
55 ((a >> (n-8)) & 0x7) |
56 ((a << 3) & x_mask));
57 _mesa_printf ("x_swizzle %08x (base %x yrow %x tile#x %x xsword %x byte %x) %08x\n",
58 addr,
59 addr >> (n + 4),
60 (addr >> (n + 1)) & 0x7,
61 (addr >> 9) & ((1 << (n-8)) - 1),
62 (addr >> 5) & 0xf,
63 (addr & 0x1f),
64 a);
65 return a;
66 }
67
68 static uintptr_t y_tile_swizzle_pow2 (uintptr_t addr, int n)
69 {
70 uintptr_t a = (uintptr_t) addr;
71 uintptr_t base_mask = (((~0) << (n + 6)) | 0xf);
72 uintptr_t x_mask = ((~0) << 9) & ~base_mask;
73
74 a = ((a & base_mask) |
75 ((a >> (n-3)) & 0x1f) |
76 ((a << 5) & x_mask));
77 _mesa_printf ("y_swizzle %08x (base %x yrow %x tile#x %x xoword %x byte %x) %08x\n",
78 addr,
79 addr >> (n + 6),
80 (addr >> (n + 1)) & 0x01f,
81 (addr >> 7) & ((1 << (n-6)) - 1),
82 (addr >> 4) & 0x7,
83 (addr & 0xf),
84 a);
85 return a;
86 }
87 #endif
88
89 static GLubyte *x_tile_swizzle(struct intel_renderbuffer *irb, struct intel_context *intel,
90 int x, int y)
91 {
92 GLubyte *buf = (GLubyte *) irb->pfMap;
93 int tile_stride;
94 int xbyte;
95 int x_tile_off, y_tile_off;
96 int x_tile_number, y_tile_number;
97 int tile_off, tile_base;
98
99 tile_stride = (irb->pfPitch * irb->region->cpp) << 3;
100
101 x += intel->drawX;
102 y += intel->drawY;
103
104 xbyte = x * irb->region->cpp;
105
106 x_tile_off = xbyte & 0x1ff;
107 y_tile_off = y & 7;
108
109 x_tile_number = xbyte >> 9;
110 y_tile_number = y >> 3;
111
112 tile_off = (y_tile_off << 9) + x_tile_off;
113 tile_base = (x_tile_number << 12) + y_tile_number * tile_stride;
114
115 return buf + tile_base + tile_off;
116 }
117
118 static GLubyte *y_tile_swizzle(struct intel_renderbuffer *irb, struct intel_context *intel,
119 int x, int y)
120 {
121 GLubyte *buf = (GLubyte *) irb->pfMap;
122 int tile_stride;
123 int xbyte;
124 int x_tile_off, y_tile_off;
125 int x_tile_number, y_tile_number;
126 int tile_off, tile_base;
127
128 tile_stride = (irb->pfPitch * irb->region->cpp) << 3;
129
130 x += intel->drawX;
131 y += intel->drawY;
132
133 xbyte = x * irb->region->cpp;
134
135 x_tile_off = xbyte & 0x7f;
136 y_tile_off = y & 0x1f;
137
138 x_tile_number = xbyte >> 7;
139 y_tile_number = y >> 5;
140
141 tile_off = ((x_tile_off & ~0xf) << 5) + (y_tile_off << 4) + (x_tile_off & 0xf);
142 tile_base = (x_tile_number << 12) + y_tile_number * tile_stride;
143
144 return buf + tile_base + tile_off;
145 }
146
147 /*
148 break intelWriteRGBASpan_ARGB8888
149 */
150
151 #undef DBG
152 #define DBG 0
153
154 #define LOCAL_VARS \
155 struct intel_context *intel = intel_context(ctx); \
156 struct intel_renderbuffer *irb = intel_renderbuffer(rb); \
157 const GLint yScale = irb->RenderToTexture ? 1 : -1; \
158 const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1; \
159 GLubyte *buf = (GLubyte *) irb->pfMap \
160 + (intel->drawY * irb->pfPitch + intel->drawX) * irb->region->cpp;\
161 GLuint p; \
162 assert(irb->pfMap);\
163 (void) p; (void) buf;
164
165 /* XXX FBO: this is identical to the macro in spantmp2.h except we get
166 * the cliprect info from the context, not the driDrawable.
167 * Move this into spantmp2.h someday.
168 */
169 #define HW_CLIPLOOP() \
170 do { \
171 int _nc = intel->numClipRects; \
172 while ( _nc-- ) { \
173 int minx = intel->pClipRects[_nc].x1 - intel->drawX; \
174 int miny = intel->pClipRects[_nc].y1 - intel->drawY; \
175 int maxx = intel->pClipRects[_nc].x2 - intel->drawX; \
176 int maxy = intel->pClipRects[_nc].y2 - intel->drawY;
177
178 #if 0
179 }}
180 #endif
181
182 #define Y_FLIP(_y) ((_y) * yScale + yBias)
183
184 /* XXX with GEM, these need to tell the kernel */
185 #define HW_LOCK()
186
187 #define HW_UNLOCK()
188
189 /* 16 bit, RGB565 color spanline and pixel functions
190 */
191 #define SPANTMP_PIXEL_FMT GL_RGB
192 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
193
194 #define TAG(x) intel##x##_RGB565
195 #define TAG2(x,y) intel##x##_RGB565##y
196 #define GET_PTR(X,Y) (buf + ((Y) * irb->pfPitch + (X)) * 2)
197 #include "spantmp2.h"
198
199 /* 32 bit, ARGB8888 color spanline and pixel functions
200 */
201 #define SPANTMP_PIXEL_FMT GL_BGRA
202 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
203
204 #define TAG(x) intel##x##_ARGB8888
205 #define TAG2(x,y) intel##x##_ARGB8888##y
206 #define GET_PTR(X,Y) (buf + ((Y) * irb->pfPitch + (X)) * 4)
207 #include "spantmp2.h"
208
209 /* 16 bit RGB565 color tile spanline and pixel functions
210 */
211
212 #define SPANTMP_PIXEL_FMT GL_RGB
213 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
214
215 #define TAG(x) intel_XTile_##x##_RGB565
216 #define TAG2(x,y) intel_XTile_##x##_RGB565##y
217 #define GET_PTR(X,Y) x_tile_swizzle(irb, intel, X, Y)
218 #include "spantmp2.h"
219
220 #define SPANTMP_PIXEL_FMT GL_RGB
221 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
222
223 #define TAG(x) intel_YTile_##x##_RGB565
224 #define TAG2(x,y) intel_YTile_##x##_RGB565##y
225 #define GET_PTR(X,Y) y_tile_swizzle(irb, intel, X, Y)
226 #include "spantmp2.h"
227
228 /* 32 bit ARGB888 color tile spanline and pixel functions
229 */
230
231 #define SPANTMP_PIXEL_FMT GL_BGRA
232 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
233
234 #define TAG(x) intel_XTile_##x##_ARGB8888
235 #define TAG2(x,y) intel_XTile_##x##_ARGB8888##y
236 #define GET_PTR(X,Y) x_tile_swizzle(irb, intel, X, Y)
237 #include "spantmp2.h"
238
239 #define SPANTMP_PIXEL_FMT GL_BGRA
240 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
241
242 #define TAG(x) intel_YTile_##x##_ARGB8888
243 #define TAG2(x,y) intel_YTile_##x##_ARGB8888##y
244 #define GET_PTR(X,Y) y_tile_swizzle(irb, intel, X, Y)
245 #include "spantmp2.h"
246
247 #define LOCAL_DEPTH_VARS \
248 struct intel_context *intel = intel_context(ctx); \
249 struct intel_renderbuffer *irb = intel_renderbuffer(rb); \
250 const GLuint pitch = irb->pfPitch/***XXX region->pitch*/; /* in pixels */ \
251 const GLint yScale = irb->RenderToTexture ? 1 : -1; \
252 const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1; \
253 char *buf = (char *) irb->pfMap/*XXX use region->map*/ + \
254 (intel->drawY * pitch + intel->drawX) * irb->region->cpp; (void) buf;
255
256
257 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
258
259 /**
260 ** 16-bit depthbuffer functions.
261 **/
262 #define WRITE_DEPTH( _x, _y, d ) \
263 ((GLushort *)buf)[(_x) + (_y) * pitch] = d;
264
265 #define READ_DEPTH( d, _x, _y ) \
266 d = ((GLushort *)buf)[(_x) + (_y) * pitch];
267
268
269 #define TAG(x) intel##x##_z16
270 #include "depthtmp.h"
271
272
273 /**
274 ** 16-bit x tile depthbuffer functions.
275 **/
276 #define WRITE_DEPTH( _x, _y, d ) \
277 (*((GLushort *)x_tile_swizzle (irb, intel, _x, _y)) = d)
278
279 #define READ_DEPTH( d, _x, _y ) \
280 d = *((GLushort *)x_tile_swizzle (irb, intel, _x, _y))
281
282
283 #define TAG(x) intel_XTile_##x##_z16
284 #include "depthtmp.h"
285
286 /**
287 ** 16-bit y tile depthbuffer functions.
288 **/
289 #define WRITE_DEPTH( _x, _y, d ) \
290 (*((GLushort *)y_tile_swizzle (irb, intel, _x, _y)) = d)
291
292 #define READ_DEPTH( d, _x, _y ) \
293 (d = *((GLushort *)y_tile_swizzle (irb, intel, _x, _y)))
294
295
296 #define TAG(x) intel_YTile_##x##_z16
297 #include "depthtmp.h"
298
299
300 /**
301 ** 24/8-bit interleaved depth/stencil functions
302 ** Note: we're actually reading back combined depth+stencil values.
303 ** The wrappers in main/depthstencil.c are used to extract the depth
304 ** and stencil values.
305 **/
306 /* Change ZZZS -> SZZZ */
307 #define WRITE_DEPTH( _x, _y, d ) { \
308 GLuint tmp = ((d) >> 8) | ((d) << 24); \
309 ((GLuint *)buf)[(_x) + (_y) * pitch] = tmp; \
310 }
311
312 /* Change SZZZ -> ZZZS */
313 #define READ_DEPTH( d, _x, _y ) { \
314 GLuint tmp = ((GLuint *)buf)[(_x) + (_y) * pitch]; \
315 d = (tmp << 8) | (tmp >> 24); \
316 }
317
318 #define TAG(x) intel##x##_z24_s8
319 #include "depthtmp.h"
320
321
322 /**
323 ** 24/8-bit x-tile interleaved depth/stencil functions
324 ** Note: we're actually reading back combined depth+stencil values.
325 ** The wrappers in main/depthstencil.c are used to extract the depth
326 ** and stencil values.
327 **/
328 /* Change ZZZS -> SZZZ */
329 #define WRITE_DEPTH( _x, _y, d ) { \
330 GLuint tmp = ((d) >> 8) | ((d) << 24); \
331 *((GLuint *)x_tile_swizzle (irb, intel, _x, _y)) = tmp; \
332 }
333
334 /* Change SZZZ -> ZZZS */
335 #define READ_DEPTH( d, _x, _y ) { \
336 GLuint tmp = *((GLuint *)x_tile_swizzle (irb, intel, _x, _y)); \
337 d = (tmp << 8) | (tmp >> 24); \
338 }
339
340 #define TAG(x) intel_XTile_##x##_z24_s8
341 #include "depthtmp.h"
342
343 /**
344 ** 24/8-bit y-tile interleaved depth/stencil functions
345 ** Note: we're actually reading back combined depth+stencil values.
346 ** The wrappers in main/depthstencil.c are used to extract the depth
347 ** and stencil values.
348 **/
349 /* Change ZZZS -> SZZZ */
350 #define WRITE_DEPTH( _x, _y, d ) { \
351 GLuint tmp = ((d) >> 8) | ((d) << 24); \
352 *((GLuint *)y_tile_swizzle (irb, intel, _x, _y)) = tmp; \
353 }
354
355 /* Change SZZZ -> ZZZS */
356 #define READ_DEPTH( d, _x, _y ) { \
357 GLuint tmp = *((GLuint *)y_tile_swizzle (irb, intel, _x, _y)); \
358 d = (tmp << 8) | (tmp >> 24); \
359 }
360
361 #define TAG(x) intel_YTile_##x##_z24_s8
362 #include "depthtmp.h"
363
364
365 /**
366 ** 8-bit stencil function (XXX FBO: This is obsolete)
367 **/
368 #define WRITE_STENCIL( _x, _y, d ) { \
369 GLuint tmp = ((GLuint *)buf)[(_x) + (_y) * pitch]; \
370 tmp &= 0xffffff; \
371 tmp |= ((d) << 24); \
372 ((GLuint *) buf)[(_x) + (_y) * pitch] = tmp; \
373 }
374
375 #define READ_STENCIL( d, _x, _y ) \
376 d = ((GLuint *)buf)[(_x) + (_y) * pitch] >> 24;
377
378 #define TAG(x) intel##x##_z24_s8
379 #include "stenciltmp.h"
380
381 /**
382 ** 8-bit x-tile stencil function (XXX FBO: This is obsolete)
383 **/
384 #define WRITE_STENCIL( _x, _y, d ) { \
385 GLuint *a = (GLuint *) x_tile_swizzle (irb, intel, _x, _y); \
386 GLuint tmp = *a; \
387 tmp &= 0xffffff; \
388 tmp |= ((d) << 24); \
389 *a = tmp; \
390 }
391
392 #define READ_STENCIL( d, _x, _y ) \
393 (d = *((GLuint*) x_tile_swizzle (irb, intel, _x, _y)) >> 24)
394
395 #define TAG(x) intel_XTile_##x##_z24_s8
396 #include "stenciltmp.h"
397
398 /**
399 ** 8-bit y-tile stencil function (XXX FBO: This is obsolete)
400 **/
401 #define WRITE_STENCIL( _x, _y, d ) { \
402 GLuint *a = (GLuint *) y_tile_swizzle (irb, intel, _x, _y); \
403 GLuint tmp = *a; \
404 tmp &= 0xffffff; \
405 tmp |= ((d) << 24); \
406 *a = tmp; \
407 }
408
409 #define READ_STENCIL( d, _x, _y ) \
410 (d = *((GLuint*) y_tile_swizzle (irb, intel, _x, _y)) >> 24)
411
412 #define TAG(x) intel_YTile_##x##_z24_s8
413 #include "stenciltmp.h"
414
415
416
417 /**
418 * Map or unmap all the renderbuffers which we may need during
419 * software rendering.
420 * XXX in the future, we could probably convey extra information to
421 * reduce the number of mappings needed. I.e. if doing a glReadPixels
422 * from the depth buffer, we really only need one mapping.
423 *
424 * XXX Rewrite this function someday.
425 * We can probably just loop over all the renderbuffer attachments,
426 * map/unmap all of them, and not worry about the _ColorDrawBuffers
427 * _ColorReadBuffer, _DepthBuffer or _StencilBuffer fields.
428 */
429 static void
430 intel_map_unmap_buffers(struct intel_context *intel, GLboolean map)
431 {
432 GLcontext *ctx = &intel->ctx;
433 GLuint i, j;
434 struct intel_renderbuffer *irb;
435
436 /* color draw buffers */
437 for (j = 0; j < ctx->DrawBuffer->_NumColorDrawBuffers; j++) {
438 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[j];
439 irb = intel_renderbuffer(rb);
440 if (irb) {
441 /* this is a user-created intel_renderbuffer */
442 if (irb->region) {
443 if (map)
444 intel_region_map(intel, irb->region);
445 else
446 intel_region_unmap(intel, irb->region);
447 irb->pfMap = irb->region->map;
448 irb->pfPitch = irb->region->pitch;
449 }
450 }
451 }
452
453 /* check for render to textures */
454 for (i = 0; i < BUFFER_COUNT; i++) {
455 struct gl_renderbuffer_attachment *att =
456 ctx->DrawBuffer->Attachment + i;
457 struct gl_texture_object *tex = att->Texture;
458 if (tex) {
459 /* render to texture */
460 ASSERT(att->Renderbuffer);
461 if (map) {
462 struct gl_texture_image *texImg;
463 texImg = tex->Image[att->CubeMapFace][att->TextureLevel];
464 intel_tex_map_images(intel, intel_texture_object(tex));
465 }
466 else {
467 intel_tex_unmap_images(intel, intel_texture_object(tex));
468 }
469 }
470 }
471
472 /* color read buffers */
473 irb = intel_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
474 if (irb && irb->region) {
475 if (map)
476 intel_region_map(intel, irb->region);
477 else
478 intel_region_unmap(intel, irb->region);
479 irb->pfMap = irb->region->map;
480 irb->pfPitch = irb->region->pitch;
481 }
482
483 /* Account for front/back color page flipping.
484 * The span routines use the pfMap and pfPitch fields which will
485 * swap the front/back region map/pitch if we're page flipped.
486 * Do this after mapping, above, so the map field is valid.
487 */
488 #if 0
489 if (map && ctx->DrawBuffer->Name == 0) {
490 struct intel_renderbuffer *irbFront
491 = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_FRONT_LEFT);
492 struct intel_renderbuffer *irbBack
493 = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_BACK_LEFT);
494 if (irbBack) {
495 /* double buffered */
496 if (intel->sarea->pf_current_page == 0) {
497 irbFront->pfMap = irbFront->region->map;
498 irbFront->pfPitch = irbFront->region->pitch;
499 irbBack->pfMap = irbBack->region->map;
500 irbBack->pfPitch = irbBack->region->pitch;
501 }
502 else {
503 irbFront->pfMap = irbBack->region->map;
504 irbFront->pfPitch = irbBack->region->pitch;
505 irbBack->pfMap = irbFront->region->map;
506 irbBack->pfPitch = irbFront->region->pitch;
507 }
508 }
509 }
510 #endif
511
512 /* depth buffer (Note wrapper!) */
513 if (ctx->DrawBuffer->_DepthBuffer) {
514 irb = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped);
515 if (irb && irb->region) {
516 if (map) {
517 intel_region_map(intel, irb->region);
518 irb->pfMap = irb->region->map;
519 irb->pfPitch = irb->region->pitch;
520 }
521 else {
522 intel_region_unmap(intel, irb->region);
523 irb->pfMap = irb->region->map;
524 irb->pfPitch = irb->region->pitch;
525 }
526 }
527 }
528
529 /* stencil buffer (Note wrapper!) */
530 if (ctx->DrawBuffer->_StencilBuffer) {
531 irb = intel_renderbuffer(ctx->DrawBuffer->_StencilBuffer->Wrapped);
532 if (irb && irb->region) {
533 if (map) {
534 intel_region_map(intel, irb->region);
535 irb->pfMap = irb->region->map;
536 irb->pfPitch = irb->region->pitch;
537 }
538 else {
539 intel_region_unmap(intel, irb->region);
540 irb->pfMap = irb->region->map;
541 irb->pfPitch = irb->region->pitch;
542 }
543 }
544 }
545 }
546
547
548
549 /**
550 * Prepare for softare rendering. Map current read/draw framebuffers'
551 * renderbuffes and all currently bound texture objects.
552 *
553 * Old note: Moved locking out to get reasonable span performance.
554 */
555 void
556 intelSpanRenderStart(GLcontext * ctx)
557 {
558 struct intel_context *intel = intel_context(ctx);
559 GLuint i;
560
561 intelFinish(&intel->ctx);
562 LOCK_HARDWARE(intel);
563
564 #if 0
565 /* Just map the framebuffer and all textures. Bufmgr code will
566 * take care of waiting on the necessary fences:
567 */
568 intel_region_map(intel, intel->front_region);
569 intel_region_map(intel, intel->back_region);
570 intel_region_map(intel, intel->depth_region);
571 #endif
572
573 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
574 if (ctx->Texture.Unit[i]._ReallyEnabled) {
575 struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
576 intel_tex_map_images(intel, intel_texture_object(texObj));
577 }
578 }
579
580 intel_map_unmap_buffers(intel, GL_TRUE);
581 }
582
583 /**
584 * Called when done softare rendering. Unmap the buffers we mapped in
585 * the above function.
586 */
587 void
588 intelSpanRenderFinish(GLcontext * ctx)
589 {
590 struct intel_context *intel = intel_context(ctx);
591 GLuint i;
592
593 _swrast_flush(ctx);
594
595 /* Now unmap the framebuffer:
596 */
597 #if 0
598 intel_region_unmap(intel, intel->front_region);
599 intel_region_unmap(intel, intel->back_region);
600 intel_region_unmap(intel, intel->depth_region);
601 #endif
602
603 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
604 if (ctx->Texture.Unit[i]._ReallyEnabled) {
605 struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
606 intel_tex_unmap_images(intel, intel_texture_object(texObj));
607 }
608 }
609
610 intel_map_unmap_buffers(intel, GL_FALSE);
611
612 UNLOCK_HARDWARE(intel);
613 }
614
615
616 void
617 intelInitSpanFuncs(GLcontext * ctx)
618 {
619 struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
620 swdd->SpanRenderStart = intelSpanRenderStart;
621 swdd->SpanRenderFinish = intelSpanRenderFinish;
622 }
623
624
625 /**
626 * Plug in appropriate span read/write functions for the given renderbuffer.
627 * These are used for the software fallbacks.
628 */
629 void
630 intel_set_span_functions(struct gl_renderbuffer *rb, int tiling)
631 {
632 if (rb->_ActualFormat == GL_RGB5) {
633 /* 565 RGB */
634 switch (tiling) {
635 case INTEL_TILE_NONE:
636 default:
637 intelInitPointers_RGB565(rb);
638 break;
639 case INTEL_TILE_X:
640 intel_XTile_InitPointers_RGB565(rb);
641 break;
642 case INTEL_TILE_Y:
643 intel_YTile_InitPointers_RGB565(rb);
644 break;
645 }
646 }
647 else if (rb->_ActualFormat == GL_RGBA8) {
648 /* 8888 RGBA */
649 switch (tiling) {
650 case INTEL_TILE_NONE:
651 default:
652 intelInitPointers_ARGB8888(rb);
653 break;
654 case INTEL_TILE_X:
655 intel_XTile_InitPointers_ARGB8888(rb);
656 break;
657 case INTEL_TILE_Y:
658 intel_YTile_InitPointers_ARGB8888(rb);
659 break;
660 }
661 }
662 else if (rb->_ActualFormat == GL_DEPTH_COMPONENT16) {
663 switch (tiling) {
664 case INTEL_TILE_NONE:
665 default:
666 intelInitDepthPointers_z16(rb);
667 break;
668 case INTEL_TILE_X:
669 intel_XTile_InitDepthPointers_z16(rb);
670 break;
671 case INTEL_TILE_Y:
672 intel_YTile_InitDepthPointers_z16(rb);
673 break;
674 }
675 }
676 else if (rb->_ActualFormat == GL_DEPTH_COMPONENT24 || /* XXX FBO remove */
677 rb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
678 switch (tiling) {
679 case INTEL_TILE_NONE:
680 default:
681 intelInitDepthPointers_z24_s8(rb);
682 break;
683 case INTEL_TILE_X:
684 intel_XTile_InitDepthPointers_z24_s8(rb);
685 break;
686 case INTEL_TILE_Y:
687 intel_YTile_InitDepthPointers_z24_s8(rb);
688 break;
689 }
690 }
691 else if (rb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
692 switch (tiling) {
693 case INTEL_TILE_NONE:
694 default:
695 intelInitStencilPointers_z24_s8(rb);
696 break;
697 case INTEL_TILE_X:
698 intel_XTile_InitStencilPointers_z24_s8(rb);
699 break;
700 case INTEL_TILE_Y:
701 intel_YTile_InitStencilPointers_z24_s8(rb);
702 break;
703 }
704 }
705 else {
706 _mesa_problem(NULL,
707 "Unexpected _ActualFormat in intelSetSpanFunctions");
708 }
709 }