Merge commit 'origin/master' into drm-gem
[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 #ifndef I915
110 /* The documentation says that X tile layout is arranged in 8 512-byte
111 * lines of pixel data. However, that doesn't appear to be the case
112 * on GM965, tested by drawing a 128x8 quad in no_rast mode. For lines
113 * 1,2,4, and 7 of each tile, each consecutive pair of 64-byte spans
114 * has the locations of those spans swapped.
115 */
116 switch (y_tile_off) {
117 case 1:
118 case 2:
119 case 4:
120 case 7:
121 x_tile_off ^= 64;
122 break;
123 default:
124 break;
125 }
126 #endif
127
128 x_tile_number = xbyte >> 9;
129 y_tile_number = y >> 3;
130
131 tile_off = (y_tile_off << 9) + x_tile_off;
132 tile_base = (x_tile_number << 12) + y_tile_number * tile_stride;
133
134 #if 0
135 printf("(%d,%d) -> %d + %d = %d (pitch = %d, tstride = %d)\n",
136 x, y, tile_off, tile_base,
137 tile_off + tile_base,
138 irb->pfPitch, tile_stride);
139 #endif
140
141 return buf + tile_base + tile_off;
142 }
143
144 static GLubyte *y_tile_swizzle(struct intel_renderbuffer *irb, struct intel_context *intel,
145 int x, int y)
146 {
147 GLubyte *buf = (GLubyte *) irb->pfMap;
148 int tile_stride;
149 int xbyte;
150 int x_tile_off, y_tile_off;
151 int x_tile_number, y_tile_number;
152 int tile_off, tile_base;
153
154 tile_stride = (irb->pfPitch * irb->region->cpp) << 3;
155
156 x += intel->drawX;
157 y += intel->drawY;
158
159 xbyte = x * irb->region->cpp;
160
161 x_tile_off = xbyte & 0x7f;
162 y_tile_off = y & 0x1f;
163
164 x_tile_number = xbyte >> 7;
165 y_tile_number = y >> 5;
166
167 tile_off = ((x_tile_off & ~0xf) << 5) + (y_tile_off << 4) + (x_tile_off & 0xf);
168 tile_base = (x_tile_number << 12) + y_tile_number * tile_stride;
169
170 return buf + tile_base + tile_off;
171 }
172
173 /*
174 break intelWriteRGBASpan_ARGB8888
175 */
176
177 #undef DBG
178 #define DBG 0
179
180 #define LOCAL_VARS \
181 struct intel_context *intel = intel_context(ctx); \
182 struct intel_renderbuffer *irb = intel_renderbuffer(rb); \
183 const GLint yScale = irb->RenderToTexture ? 1 : -1; \
184 const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1; \
185 GLubyte *buf = (GLubyte *) irb->pfMap \
186 + (intel->drawY * irb->pfPitch + intel->drawX) * irb->region->cpp;\
187 GLuint p; \
188 assert(irb->pfMap);\
189 (void) p; (void) buf;
190
191 /* XXX FBO: this is identical to the macro in spantmp2.h except we get
192 * the cliprect info from the context, not the driDrawable.
193 * Move this into spantmp2.h someday.
194 */
195 #define HW_CLIPLOOP() \
196 do { \
197 int _nc = intel->numClipRects; \
198 while ( _nc-- ) { \
199 int minx = intel->pClipRects[_nc].x1 - intel->drawX; \
200 int miny = intel->pClipRects[_nc].y1 - intel->drawY; \
201 int maxx = intel->pClipRects[_nc].x2 - intel->drawX; \
202 int maxy = intel->pClipRects[_nc].y2 - intel->drawY;
203
204 #if 0
205 }}
206 #endif
207
208 #define Y_FLIP(_y) ((_y) * yScale + yBias)
209
210 /* XXX with GEM, these need to tell the kernel */
211 #define HW_LOCK()
212
213 #define HW_UNLOCK()
214
215 /* 16 bit, RGB565 color spanline and pixel functions
216 */
217 #define SPANTMP_PIXEL_FMT GL_RGB
218 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
219
220 #define TAG(x) intel##x##_RGB565
221 #define TAG2(x,y) intel##x##_RGB565##y
222 #define GET_PTR(X,Y) (buf + ((Y) * irb->pfPitch + (X)) * 2)
223 #include "spantmp2.h"
224
225 /* 32 bit, ARGB8888 color spanline and pixel functions
226 */
227 #define SPANTMP_PIXEL_FMT GL_BGRA
228 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
229
230 #define TAG(x) intel##x##_ARGB8888
231 #define TAG2(x,y) intel##x##_ARGB8888##y
232 #define GET_PTR(X,Y) (buf + ((Y) * irb->pfPitch + (X)) * 4)
233 #include "spantmp2.h"
234
235 /* 16 bit RGB565 color tile spanline and pixel functions
236 */
237
238 #define SPANTMP_PIXEL_FMT GL_RGB
239 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
240
241 #define TAG(x) intel_XTile_##x##_RGB565
242 #define TAG2(x,y) intel_XTile_##x##_RGB565##y
243 #define GET_PTR(X,Y) x_tile_swizzle(irb, intel, X, Y)
244 #include "spantmp2.h"
245
246 #define SPANTMP_PIXEL_FMT GL_RGB
247 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
248
249 #define TAG(x) intel_YTile_##x##_RGB565
250 #define TAG2(x,y) intel_YTile_##x##_RGB565##y
251 #define GET_PTR(X,Y) y_tile_swizzle(irb, intel, X, Y)
252 #include "spantmp2.h"
253
254 /* 32 bit ARGB888 color tile spanline and pixel functions
255 */
256
257 #define SPANTMP_PIXEL_FMT GL_BGRA
258 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
259
260 #define TAG(x) intel_XTile_##x##_ARGB8888
261 #define TAG2(x,y) intel_XTile_##x##_ARGB8888##y
262 #define GET_PTR(X,Y) x_tile_swizzle(irb, intel, X, Y)
263 #include "spantmp2.h"
264
265 #define SPANTMP_PIXEL_FMT GL_BGRA
266 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
267
268 #define TAG(x) intel_YTile_##x##_ARGB8888
269 #define TAG2(x,y) intel_YTile_##x##_ARGB8888##y
270 #define GET_PTR(X,Y) y_tile_swizzle(irb, intel, X, Y)
271 #include "spantmp2.h"
272
273 #define LOCAL_DEPTH_VARS \
274 struct intel_context *intel = intel_context(ctx); \
275 struct intel_renderbuffer *irb = intel_renderbuffer(rb); \
276 const GLuint pitch = irb->pfPitch/***XXX region->pitch*/; /* in pixels */ \
277 const GLint yScale = irb->RenderToTexture ? 1 : -1; \
278 const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1; \
279 char *buf = (char *) irb->pfMap/*XXX use region->map*/ + \
280 (intel->drawY * pitch + intel->drawX) * irb->region->cpp; (void) buf;
281
282
283 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
284
285 /**
286 ** 16-bit depthbuffer functions.
287 **/
288 #define WRITE_DEPTH( _x, _y, d ) \
289 ((GLushort *)buf)[(_x) + (_y) * pitch] = d;
290
291 #define READ_DEPTH( d, _x, _y ) \
292 d = ((GLushort *)buf)[(_x) + (_y) * pitch];
293
294
295 #define TAG(x) intel##x##_z16
296 #include "depthtmp.h"
297
298
299 /**
300 ** 16-bit x tile depthbuffer functions.
301 **/
302 #define WRITE_DEPTH( _x, _y, d ) \
303 (*((GLushort *)x_tile_swizzle (irb, intel, _x, _y)) = d)
304
305 #define READ_DEPTH( d, _x, _y ) \
306 d = *((GLushort *)x_tile_swizzle (irb, intel, _x, _y))
307
308
309 #define TAG(x) intel_XTile_##x##_z16
310 #include "depthtmp.h"
311
312 /**
313 ** 16-bit y tile depthbuffer functions.
314 **/
315 #define WRITE_DEPTH( _x, _y, d ) \
316 (*((GLushort *)y_tile_swizzle (irb, intel, _x, _y)) = d)
317
318 #define READ_DEPTH( d, _x, _y ) \
319 (d = *((GLushort *)y_tile_swizzle (irb, intel, _x, _y)))
320
321
322 #define TAG(x) intel_YTile_##x##_z16
323 #include "depthtmp.h"
324
325
326 /**
327 ** 24/8-bit interleaved depth/stencil functions
328 ** Note: we're actually reading back combined depth+stencil values.
329 ** The wrappers in main/depthstencil.c are used to extract the depth
330 ** and stencil values.
331 **/
332 /* Change ZZZS -> SZZZ */
333 #define WRITE_DEPTH( _x, _y, d ) { \
334 GLuint tmp = ((d) >> 8) | ((d) << 24); \
335 ((GLuint *)buf)[(_x) + (_y) * pitch] = tmp; \
336 }
337
338 /* Change SZZZ -> ZZZS */
339 #define READ_DEPTH( d, _x, _y ) { \
340 GLuint tmp = ((GLuint *)buf)[(_x) + (_y) * pitch]; \
341 d = (tmp << 8) | (tmp >> 24); \
342 }
343
344 #define TAG(x) intel##x##_z24_s8
345 #include "depthtmp.h"
346
347
348 /**
349 ** 24/8-bit x-tile interleaved depth/stencil functions
350 ** Note: we're actually reading back combined depth+stencil values.
351 ** The wrappers in main/depthstencil.c are used to extract the depth
352 ** and stencil values.
353 **/
354 /* Change ZZZS -> SZZZ */
355 #define WRITE_DEPTH( _x, _y, d ) { \
356 GLuint tmp = ((d) >> 8) | ((d) << 24); \
357 *((GLuint *)x_tile_swizzle (irb, intel, _x, _y)) = tmp; \
358 }
359
360 /* Change SZZZ -> ZZZS */
361 #define READ_DEPTH( d, _x, _y ) { \
362 GLuint tmp = *((GLuint *)x_tile_swizzle (irb, intel, _x, _y)); \
363 d = (tmp << 8) | (tmp >> 24); \
364 }
365
366 #define TAG(x) intel_XTile_##x##_z24_s8
367 #include "depthtmp.h"
368
369 /**
370 ** 24/8-bit y-tile interleaved depth/stencil functions
371 ** Note: we're actually reading back combined depth+stencil values.
372 ** The wrappers in main/depthstencil.c are used to extract the depth
373 ** and stencil values.
374 **/
375 /* Change ZZZS -> SZZZ */
376 #define WRITE_DEPTH( _x, _y, d ) { \
377 GLuint tmp = ((d) >> 8) | ((d) << 24); \
378 *((GLuint *)y_tile_swizzle (irb, intel, _x, _y)) = tmp; \
379 }
380
381 /* Change SZZZ -> ZZZS */
382 #define READ_DEPTH( d, _x, _y ) { \
383 GLuint tmp = *((GLuint *)y_tile_swizzle (irb, intel, _x, _y)); \
384 d = (tmp << 8) | (tmp >> 24); \
385 }
386
387 #define TAG(x) intel_YTile_##x##_z24_s8
388 #include "depthtmp.h"
389
390
391 /**
392 ** 8-bit stencil function (XXX FBO: This is obsolete)
393 **/
394 #define WRITE_STENCIL( _x, _y, d ) { \
395 GLuint tmp = ((GLuint *)buf)[(_x) + (_y) * pitch]; \
396 tmp &= 0xffffff; \
397 tmp |= ((d) << 24); \
398 ((GLuint *) buf)[(_x) + (_y) * pitch] = tmp; \
399 }
400
401 #define READ_STENCIL( d, _x, _y ) \
402 d = ((GLuint *)buf)[(_x) + (_y) * pitch] >> 24;
403
404 #define TAG(x) intel##x##_z24_s8
405 #include "stenciltmp.h"
406
407 /**
408 ** 8-bit x-tile stencil function (XXX FBO: This is obsolete)
409 **/
410 #define WRITE_STENCIL( _x, _y, d ) { \
411 GLuint *a = (GLuint *) x_tile_swizzle (irb, intel, _x, _y); \
412 GLuint tmp = *a; \
413 tmp &= 0xffffff; \
414 tmp |= ((d) << 24); \
415 *a = tmp; \
416 }
417
418 #define READ_STENCIL( d, _x, _y ) \
419 (d = *((GLuint*) x_tile_swizzle (irb, intel, _x, _y)) >> 24)
420
421 #define TAG(x) intel_XTile_##x##_z24_s8
422 #include "stenciltmp.h"
423
424 /**
425 ** 8-bit y-tile stencil function (XXX FBO: This is obsolete)
426 **/
427 #define WRITE_STENCIL( _x, _y, d ) { \
428 GLuint *a = (GLuint *) y_tile_swizzle (irb, intel, _x, _y); \
429 GLuint tmp = *a; \
430 tmp &= 0xffffff; \
431 tmp |= ((d) << 24); \
432 *a = tmp; \
433 }
434
435 #define READ_STENCIL( d, _x, _y ) \
436 (d = *((GLuint*) y_tile_swizzle (irb, intel, _x, _y)) >> 24)
437
438 #define TAG(x) intel_YTile_##x##_z24_s8
439 #include "stenciltmp.h"
440
441
442
443 /**
444 * Map or unmap all the renderbuffers which we may need during
445 * software rendering.
446 * XXX in the future, we could probably convey extra information to
447 * reduce the number of mappings needed. I.e. if doing a glReadPixels
448 * from the depth buffer, we really only need one mapping.
449 *
450 * XXX Rewrite this function someday.
451 * We can probably just loop over all the renderbuffer attachments,
452 * map/unmap all of them, and not worry about the _ColorDrawBuffers
453 * _ColorReadBuffer, _DepthBuffer or _StencilBuffer fields.
454 */
455 static void
456 intel_map_unmap_buffers(struct intel_context *intel, GLboolean map)
457 {
458 GLcontext *ctx = &intel->ctx;
459 GLuint i, j;
460 struct intel_renderbuffer *irb;
461
462 /* color draw buffers */
463 for (j = 0; j < ctx->DrawBuffer->_NumColorDrawBuffers; j++) {
464 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[j];
465 irb = intel_renderbuffer(rb);
466 if (irb) {
467 /* this is a user-created intel_renderbuffer */
468 if (irb->region) {
469 if (map)
470 intel_region_map(intel, irb->region);
471 else
472 intel_region_unmap(intel, irb->region);
473 irb->pfMap = irb->region->map;
474 irb->pfPitch = irb->region->pitch;
475 }
476 }
477 }
478
479 /* check for render to textures */
480 for (i = 0; i < BUFFER_COUNT; i++) {
481 struct gl_renderbuffer_attachment *att =
482 ctx->DrawBuffer->Attachment + i;
483 struct gl_texture_object *tex = att->Texture;
484 if (tex) {
485 /* render to texture */
486 ASSERT(att->Renderbuffer);
487 if (map) {
488 struct gl_texture_image *texImg;
489 texImg = tex->Image[att->CubeMapFace][att->TextureLevel];
490 intel_tex_map_images(intel, intel_texture_object(tex));
491 }
492 else {
493 intel_tex_unmap_images(intel, intel_texture_object(tex));
494 }
495 }
496 }
497
498 /* color read buffers */
499 irb = intel_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
500 if (irb && irb->region) {
501 if (map)
502 intel_region_map(intel, irb->region);
503 else
504 intel_region_unmap(intel, irb->region);
505 irb->pfMap = irb->region->map;
506 irb->pfPitch = irb->region->pitch;
507 }
508
509 /* Account for front/back color page flipping.
510 * The span routines use the pfMap and pfPitch fields which will
511 * swap the front/back region map/pitch if we're page flipped.
512 * Do this after mapping, above, so the map field is valid.
513 */
514 #if 0
515 if (map && ctx->DrawBuffer->Name == 0) {
516 struct intel_renderbuffer *irbFront
517 = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_FRONT_LEFT);
518 struct intel_renderbuffer *irbBack
519 = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_BACK_LEFT);
520 if (irbBack) {
521 /* double buffered */
522 if (intel->sarea->pf_current_page == 0) {
523 irbFront->pfMap = irbFront->region->map;
524 irbFront->pfPitch = irbFront->region->pitch;
525 irbBack->pfMap = irbBack->region->map;
526 irbBack->pfPitch = irbBack->region->pitch;
527 }
528 else {
529 irbFront->pfMap = irbBack->region->map;
530 irbFront->pfPitch = irbBack->region->pitch;
531 irbBack->pfMap = irbFront->region->map;
532 irbBack->pfPitch = irbFront->region->pitch;
533 }
534 }
535 }
536 #endif
537
538 /* depth buffer (Note wrapper!) */
539 if (ctx->DrawBuffer->_DepthBuffer) {
540 irb = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped);
541 if (irb && irb->region) {
542 if (map) {
543 intel_region_map(intel, irb->region);
544 irb->pfMap = irb->region->map;
545 irb->pfPitch = irb->region->pitch;
546 }
547 else {
548 intel_region_unmap(intel, irb->region);
549 irb->pfMap = irb->region->map;
550 irb->pfPitch = irb->region->pitch;
551 }
552 }
553 }
554
555 /* stencil buffer (Note wrapper!) */
556 if (ctx->DrawBuffer->_StencilBuffer) {
557 irb = intel_renderbuffer(ctx->DrawBuffer->_StencilBuffer->Wrapped);
558 if (irb && irb->region) {
559 if (map) {
560 intel_region_map(intel, irb->region);
561 irb->pfMap = irb->region->map;
562 irb->pfPitch = irb->region->pitch;
563 }
564 else {
565 intel_region_unmap(intel, irb->region);
566 irb->pfMap = irb->region->map;
567 irb->pfPitch = irb->region->pitch;
568 }
569 }
570 }
571 }
572
573
574
575 /**
576 * Prepare for softare rendering. Map current read/draw framebuffers'
577 * renderbuffes and all currently bound texture objects.
578 *
579 * Old note: Moved locking out to get reasonable span performance.
580 */
581 void
582 intelSpanRenderStart(GLcontext * ctx)
583 {
584 struct intel_context *intel = intel_context(ctx);
585 GLuint i;
586
587 intelFinish(&intel->ctx);
588 LOCK_HARDWARE(intel);
589
590 #if 0
591 /* Just map the framebuffer and all textures. Bufmgr code will
592 * take care of waiting on the necessary fences:
593 */
594 intel_region_map(intel, intel->front_region);
595 intel_region_map(intel, intel->back_region);
596 intel_region_map(intel, intel->depth_region);
597 #endif
598
599 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
600 if (ctx->Texture.Unit[i]._ReallyEnabled) {
601 struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
602 intel_tex_map_images(intel, intel_texture_object(texObj));
603 }
604 }
605
606 intel_map_unmap_buffers(intel, GL_TRUE);
607 }
608
609 /**
610 * Called when done softare rendering. Unmap the buffers we mapped in
611 * the above function.
612 */
613 void
614 intelSpanRenderFinish(GLcontext * ctx)
615 {
616 struct intel_context *intel = intel_context(ctx);
617 GLuint i;
618
619 _swrast_flush(ctx);
620
621 /* Now unmap the framebuffer:
622 */
623 #if 0
624 intel_region_unmap(intel, intel->front_region);
625 intel_region_unmap(intel, intel->back_region);
626 intel_region_unmap(intel, intel->depth_region);
627 #endif
628
629 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
630 if (ctx->Texture.Unit[i]._ReallyEnabled) {
631 struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
632 intel_tex_unmap_images(intel, intel_texture_object(texObj));
633 }
634 }
635
636 intel_map_unmap_buffers(intel, GL_FALSE);
637
638 UNLOCK_HARDWARE(intel);
639 }
640
641
642 void
643 intelInitSpanFuncs(GLcontext * ctx)
644 {
645 struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
646 swdd->SpanRenderStart = intelSpanRenderStart;
647 swdd->SpanRenderFinish = intelSpanRenderFinish;
648 }
649
650
651 /**
652 * Plug in appropriate span read/write functions for the given renderbuffer.
653 * These are used for the software fallbacks.
654 */
655 void
656 intel_set_span_functions(struct gl_renderbuffer *rb, int tiling)
657 {
658 if (rb->_ActualFormat == GL_RGB5) {
659 /* 565 RGB */
660 switch (tiling) {
661 case INTEL_TILE_NONE:
662 default:
663 intelInitPointers_RGB565(rb);
664 break;
665 case INTEL_TILE_X:
666 intel_XTile_InitPointers_RGB565(rb);
667 break;
668 case INTEL_TILE_Y:
669 intel_YTile_InitPointers_RGB565(rb);
670 break;
671 }
672 }
673 else if (rb->_ActualFormat == GL_RGBA8) {
674 /* 8888 RGBA */
675 switch (tiling) {
676 case INTEL_TILE_NONE:
677 default:
678 intelInitPointers_ARGB8888(rb);
679 break;
680 case INTEL_TILE_X:
681 intel_XTile_InitPointers_ARGB8888(rb);
682 break;
683 case INTEL_TILE_Y:
684 intel_YTile_InitPointers_ARGB8888(rb);
685 break;
686 }
687 }
688 else if (rb->_ActualFormat == GL_DEPTH_COMPONENT16) {
689 switch (tiling) {
690 case INTEL_TILE_NONE:
691 default:
692 intelInitDepthPointers_z16(rb);
693 break;
694 case INTEL_TILE_X:
695 intel_XTile_InitDepthPointers_z16(rb);
696 break;
697 case INTEL_TILE_Y:
698 intel_YTile_InitDepthPointers_z16(rb);
699 break;
700 }
701 }
702 else if (rb->_ActualFormat == GL_DEPTH_COMPONENT24 || /* XXX FBO remove */
703 rb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
704 switch (tiling) {
705 case INTEL_TILE_NONE:
706 default:
707 intelInitDepthPointers_z24_s8(rb);
708 break;
709 case INTEL_TILE_X:
710 intel_XTile_InitDepthPointers_z24_s8(rb);
711 break;
712 case INTEL_TILE_Y:
713 intel_YTile_InitDepthPointers_z24_s8(rb);
714 break;
715 }
716 }
717 else if (rb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
718 switch (tiling) {
719 case INTEL_TILE_NONE:
720 default:
721 intelInitStencilPointers_z24_s8(rb);
722 break;
723 case INTEL_TILE_X:
724 intel_XTile_InitStencilPointers_z24_s8(rb);
725 break;
726 case INTEL_TILE_Y:
727 intel_YTile_InitStencilPointers_z24_s8(rb);
728 break;
729 }
730 }
731 else {
732 _mesa_problem(NULL,
733 "Unexpected _ActualFormat in intelSetSpanFunctions");
734 }
735 }