1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #include "main/glheader.h"
29 #include "main/macros.h"
30 #include "main/mtypes.h"
31 #include "main/colormac.h"
33 #include "intel_buffers.h"
34 #include "intel_fbo.h"
35 #include "intel_screen.h"
36 #include "intel_span.h"
37 #include "intel_regions.h"
38 #include "intel_tex.h"
40 #include "swrast/swrast.h"
43 intel_set_span_functions(struct intel_context
*intel
,
44 struct gl_renderbuffer
*rb
);
46 #define SPAN_CACHE_SIZE 4096
49 get_span_cache(struct intel_renderbuffer
*irb
, uint32_t offset
)
51 if (irb
->span_cache
== NULL
) {
52 irb
->span_cache
= _mesa_malloc(SPAN_CACHE_SIZE
);
53 irb
->span_cache_offset
= -1;
56 if ((offset
& ~(SPAN_CACHE_SIZE
- 1)) != irb
->span_cache_offset
) {
57 irb
->span_cache_offset
= offset
& ~(SPAN_CACHE_SIZE
- 1);
58 dri_bo_get_subdata(irb
->region
->buffer
, irb
->span_cache_offset
,
59 SPAN_CACHE_SIZE
, irb
->span_cache
);
64 clear_span_cache(struct intel_renderbuffer
*irb
)
66 irb
->span_cache_offset
= -1;
70 pread_32(struct intel_renderbuffer
*irb
, uint32_t offset
)
72 get_span_cache(irb
, offset
);
74 return *(uint32_t *)(irb
->span_cache
+ (offset
& (SPAN_CACHE_SIZE
- 1)));
78 pread_xrgb8888(struct intel_renderbuffer
*irb
, uint32_t offset
)
80 get_span_cache(irb
, offset
);
82 return *(uint32_t *)(irb
->span_cache
+ (offset
& (SPAN_CACHE_SIZE
- 1))) |
87 pread_16(struct intel_renderbuffer
*irb
, uint32_t offset
)
89 get_span_cache(irb
, offset
);
91 return *(uint16_t *)(irb
->span_cache
+ (offset
& (SPAN_CACHE_SIZE
- 1)));
95 pread_8(struct intel_renderbuffer
*irb
, uint32_t offset
)
97 get_span_cache(irb
, offset
);
99 return *(uint8_t *)(irb
->span_cache
+ (offset
& (SPAN_CACHE_SIZE
- 1)));
103 pwrite_32(struct intel_renderbuffer
*irb
, uint32_t offset
, uint32_t val
)
105 clear_span_cache(irb
);
107 dri_bo_subdata(irb
->region
->buffer
, offset
, 4, &val
);
111 pwrite_xrgb8888(struct intel_renderbuffer
*irb
, uint32_t offset
, uint32_t val
)
113 clear_span_cache(irb
);
115 dri_bo_subdata(irb
->region
->buffer
, offset
, 3, &val
);
119 pwrite_16(struct intel_renderbuffer
*irb
, uint32_t offset
, uint16_t val
)
121 clear_span_cache(irb
);
123 dri_bo_subdata(irb
->region
->buffer
, offset
, 2, &val
);
127 pwrite_8(struct intel_renderbuffer
*irb
, uint32_t offset
, uint8_t val
)
129 clear_span_cache(irb
);
131 dri_bo_subdata(irb
->region
->buffer
, offset
, 1, &val
);
134 static uint32_t no_tile_swizzle(struct intel_renderbuffer
*irb
,
137 return (y
* irb
->region
->pitch
+ x
) * irb
->region
->cpp
;
141 * Deal with tiled surfaces
144 static uint32_t x_tile_swizzle(struct intel_renderbuffer
*irb
,
149 int x_tile_off
, y_tile_off
;
150 int x_tile_number
, y_tile_number
;
151 int tile_off
, tile_base
;
153 tile_stride
= (irb
->pfPitch
* irb
->region
->cpp
) << 3;
155 xbyte
= x
* irb
->region
->cpp
;
157 x_tile_off
= xbyte
& 0x1ff;
160 x_tile_number
= xbyte
>> 9;
161 y_tile_number
= y
>> 3;
163 tile_off
= (y_tile_off
<< 9) + x_tile_off
;
165 switch (irb
->region
->bit_6_swizzle
) {
166 case I915_BIT_6_SWIZZLE_NONE
:
168 case I915_BIT_6_SWIZZLE_9
:
169 tile_off
^= ((tile_off
>> 3) & 64);
171 case I915_BIT_6_SWIZZLE_9_10
:
172 tile_off
^= ((tile_off
>> 3) & 64) ^ ((tile_off
>> 4) & 64);
174 case I915_BIT_6_SWIZZLE_9_11
:
175 tile_off
^= ((tile_off
>> 3) & 64) ^ ((tile_off
>> 5) & 64);
177 case I915_BIT_6_SWIZZLE_9_10_11
:
178 tile_off
^= ((tile_off
>> 3) & 64) ^ ((tile_off
>> 4) & 64) ^
179 ((tile_off
>> 5) & 64);
182 fprintf(stderr
, "Unknown tile swizzling mode %d\n",
183 irb
->region
->bit_6_swizzle
);
187 tile_base
= (x_tile_number
<< 12) + y_tile_number
* tile_stride
;
190 printf("(%d,%d) -> %d + %d = %d (pitch = %d, tstride = %d)\n",
191 x
, y
, tile_off
, tile_base
,
192 tile_off
+ tile_base
,
193 irb
->pfPitch
, tile_stride
);
196 return tile_base
+ tile_off
;
199 static uint32_t y_tile_swizzle(struct intel_renderbuffer
*irb
,
204 int x_tile_off
, y_tile_off
;
205 int x_tile_number
, y_tile_number
;
206 int tile_off
, tile_base
;
208 tile_stride
= (irb
->pfPitch
* irb
->region
->cpp
) << 5;
210 xbyte
= x
* irb
->region
->cpp
;
212 x_tile_off
= xbyte
& 0x7f;
213 y_tile_off
= y
& 0x1f;
215 x_tile_number
= xbyte
>> 7;
216 y_tile_number
= y
>> 5;
218 tile_off
= ((x_tile_off
& ~0xf) << 5) + (y_tile_off
<< 4) +
221 switch (irb
->region
->bit_6_swizzle
) {
222 case I915_BIT_6_SWIZZLE_NONE
:
224 case I915_BIT_6_SWIZZLE_9
:
225 tile_off
^= ((tile_off
>> 3) & 64);
227 case I915_BIT_6_SWIZZLE_9_10
:
228 tile_off
^= ((tile_off
>> 3) & 64) ^ ((tile_off
>> 4) & 64);
230 case I915_BIT_6_SWIZZLE_9_11
:
231 tile_off
^= ((tile_off
>> 3) & 64) ^ ((tile_off
>> 5) & 64);
233 case I915_BIT_6_SWIZZLE_9_10_11
:
234 tile_off
^= ((tile_off
>> 3) & 64) ^ ((tile_off
>> 4) & 64) ^
235 ((tile_off
>> 5) & 64);
238 fprintf(stderr
, "Unknown tile swizzling mode %d\n",
239 irb
->region
->bit_6_swizzle
);
243 tile_base
= (x_tile_number
<< 12) + y_tile_number
* tile_stride
;
245 return tile_base
+ tile_off
;
249 break intelWriteRGBASpan_ARGB8888
256 struct intel_context *intel = intel_context(ctx); \
257 struct intel_renderbuffer *irb = intel_renderbuffer(rb); \
258 const GLint yScale = irb->RenderToTexture ? 1 : -1; \
259 const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1; \
260 unsigned int num_cliprects; \
261 struct drm_clip_rect *cliprects; \
265 intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
267 /* XXX FBO: this is identical to the macro in spantmp2.h except we get
268 * the cliprect info from the context, not the driDrawable.
269 * Move this into spantmp2.h someday.
271 #define HW_CLIPLOOP() \
273 int _nc = num_cliprects; \
275 int minx = cliprects[_nc].x1 - x_off; \
276 int miny = cliprects[_nc].y1 - y_off; \
277 int maxx = cliprects[_nc].x2 - x_off; \
278 int maxy = cliprects[_nc].y2 - y_off;
284 #define Y_FLIP(_y) ((_y) * yScale + yBias)
286 /* XXX with GEM, these need to tell the kernel */
291 /* Convenience macros to avoid typing the swizzle argument over and over */
292 #define NO_TILE(_X, _Y) no_tile_swizzle(irb, (_X) + x_off, (_Y) + y_off)
293 #define X_TILE(_X, _Y) x_tile_swizzle(irb, (_X) + x_off, (_Y) + y_off)
294 #define Y_TILE(_X, _Y) y_tile_swizzle(irb, (_X) + x_off, (_Y) + y_off)
296 /* 16 bit, RGB565 color spanline and pixel functions
298 #define SPANTMP_PIXEL_FMT GL_RGB
299 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
301 #define TAG(x) intel##x##_RGB565
302 #define TAG2(x,y) intel##x##_RGB565##y
303 #define GET_VALUE(X, Y) pread_16(irb, NO_TILE(X, Y))
304 #define PUT_VALUE(X, Y, V) pwrite_16(irb, NO_TILE(X, Y), V)
305 #include "spantmp2.h"
307 /* 32 bit, ARGB8888 color spanline and pixel functions
309 #define SPANTMP_PIXEL_FMT GL_BGRA
310 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
312 #define TAG(x) intel##x##_ARGB8888
313 #define TAG2(x,y) intel##x##_ARGB8888##y
314 #define GET_VALUE(X, Y) pread_32(irb, NO_TILE(X, Y))
315 #define PUT_VALUE(X, Y, V) pwrite_32(irb, NO_TILE(X, Y), V)
316 #include "spantmp2.h"
318 /* 32 bit, xRGB8888 color spanline and pixel functions
320 #define SPANTMP_PIXEL_FMT GL_BGRA
321 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
323 #define TAG(x) intel##x##_xRGB8888
324 #define TAG2(x,y) intel##x##_xRGB8888##y
325 #define GET_VALUE(X, Y) pread_xrgb8888(irb, NO_TILE(X, Y))
326 #define PUT_VALUE(X, Y, V) pwrite_xrgb8888(irb, NO_TILE(X, Y), V)
327 #include "spantmp2.h"
329 /* 16 bit RGB565 color tile spanline and pixel functions
332 #define SPANTMP_PIXEL_FMT GL_RGB
333 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
335 #define TAG(x) intel_XTile_##x##_RGB565
336 #define TAG2(x,y) intel_XTile_##x##_RGB565##y
337 #define GET_VALUE(X, Y) pread_16(irb, X_TILE(X, Y))
338 #define PUT_VALUE(X, Y, V) pwrite_16(irb, X_TILE(X, Y), V)
339 #include "spantmp2.h"
341 #define SPANTMP_PIXEL_FMT GL_RGB
342 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
344 #define TAG(x) intel_YTile_##x##_RGB565
345 #define TAG2(x,y) intel_YTile_##x##_RGB565##y
346 #define GET_VALUE(X, Y) pread_16(irb, Y_TILE(X, Y))
347 #define PUT_VALUE(X, Y, V) pwrite_16(irb, Y_TILE(X, Y), V)
348 #include "spantmp2.h"
350 /* 32 bit ARGB888 color tile spanline and pixel functions
353 #define SPANTMP_PIXEL_FMT GL_BGRA
354 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
356 #define TAG(x) intel_XTile_##x##_ARGB8888
357 #define TAG2(x,y) intel_XTile_##x##_ARGB8888##y
358 #define GET_VALUE(X, Y) pread_32(irb, X_TILE(X, Y))
359 #define PUT_VALUE(X, Y, V) pwrite_32(irb, X_TILE(X, Y), V)
360 #include "spantmp2.h"
362 #define SPANTMP_PIXEL_FMT GL_BGRA
363 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
365 #define TAG(x) intel_YTile_##x##_ARGB8888
366 #define TAG2(x,y) intel_YTile_##x##_ARGB8888##y
367 #define GET_VALUE(X, Y) pread_32(irb, Y_TILE(X, Y))
368 #define PUT_VALUE(X, Y, V) pwrite_32(irb, Y_TILE(X, Y), V)
369 #include "spantmp2.h"
371 /* 32 bit xRGB888 color tile spanline and pixel functions
374 #define SPANTMP_PIXEL_FMT GL_BGRA
375 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
377 #define TAG(x) intel_XTile_##x##_xRGB8888
378 #define TAG2(x,y) intel_XTile_##x##_xRGB8888##y
379 #define GET_VALUE(X, Y) pread_xrgb8888(irb, X_TILE(X, Y))
380 #define PUT_VALUE(X, Y, V) pwrite_xrgb8888(irb, X_TILE(X, Y), V)
381 #include "spantmp2.h"
383 #define SPANTMP_PIXEL_FMT GL_BGRA
384 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
386 #define TAG(x) intel_YTile_##x##_xRGB8888
387 #define TAG2(x,y) intel_YTile_##x##_xRGB8888##y
388 #define GET_VALUE(X, Y) pread_xrgb8888(irb, Y_TILE(X, Y))
389 #define PUT_VALUE(X, Y, V) pwrite_xrgb8888(irb, Y_TILE(X, Y), V)
390 #include "spantmp2.h"
392 #define LOCAL_DEPTH_VARS \
393 struct intel_context *intel = intel_context(ctx); \
394 struct intel_renderbuffer *irb = intel_renderbuffer(rb); \
395 const GLint yScale = irb->RenderToTexture ? 1 : -1; \
396 const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1; \
397 unsigned int num_cliprects; \
398 struct drm_clip_rect *cliprects; \
400 intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
403 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
406 ** 16-bit depthbuffer functions.
408 #define VALUE_TYPE GLushort
409 #define WRITE_DEPTH(_x, _y, d) pwrite_16(irb, NO_TILE(_x, _y), d)
410 #define READ_DEPTH(d, _x, _y) d = pread_16(irb, NO_TILE(_x, _y))
411 #define TAG(x) intel##x##_z16
412 #include "depthtmp.h"
416 ** 16-bit x tile depthbuffer functions.
418 #define VALUE_TYPE GLushort
419 #define WRITE_DEPTH(_x, _y, d) pwrite_16(irb, X_TILE(_x, _y), d)
420 #define READ_DEPTH(d, _x, _y) d = pread_16(irb, X_TILE(_x, _y))
421 #define TAG(x) intel_XTile_##x##_z16
422 #include "depthtmp.h"
425 ** 16-bit y tile depthbuffer functions.
427 #define VALUE_TYPE GLushort
428 #define WRITE_DEPTH(_x, _y, d) pwrite_16(irb, Y_TILE(_x, _y), d)
429 #define READ_DEPTH(d, _x, _y) d = pread_16(irb, Y_TILE(_x, _y))
430 #define TAG(x) intel_YTile_##x##_z16
431 #include "depthtmp.h"
435 ** 24/8-bit interleaved depth/stencil functions
436 ** Note: we're actually reading back combined depth+stencil values.
437 ** The wrappers in main/depthstencil.c are used to extract the depth
438 ** and stencil values.
440 #define VALUE_TYPE GLuint
442 /* Change ZZZS -> SZZZ */
443 #define WRITE_DEPTH(_x, _y, d) \
444 pwrite_32(irb, NO_TILE(_x, _y), ((d) >> 8) | ((d) << 24))
446 /* Change SZZZ -> ZZZS */
447 #define READ_DEPTH( d, _x, _y ) { \
448 GLuint tmp = pread_32(irb, NO_TILE(_x, _y)); \
449 d = (tmp << 8) | (tmp >> 24); \
452 #define TAG(x) intel##x##_z24_s8
453 #include "depthtmp.h"
457 ** 24/8-bit x-tile interleaved depth/stencil functions
458 ** Note: we're actually reading back combined depth+stencil values.
459 ** The wrappers in main/depthstencil.c are used to extract the depth
460 ** and stencil values.
462 #define VALUE_TYPE GLuint
464 /* Change ZZZS -> SZZZ */
465 #define WRITE_DEPTH(_x, _y, d) \
466 pwrite_32(irb, X_TILE(_x, _y), ((d) >> 8) | ((d) << 24))
468 /* Change SZZZ -> ZZZS */
469 #define READ_DEPTH( d, _x, _y ) { \
470 GLuint tmp = pread_32(irb, X_TILE(_x, _y)); \
471 d = (tmp << 8) | (tmp >> 24); \
474 #define TAG(x) intel_XTile_##x##_z24_s8
475 #include "depthtmp.h"
478 ** 24/8-bit y-tile interleaved depth/stencil functions
479 ** Note: we're actually reading back combined depth+stencil values.
480 ** The wrappers in main/depthstencil.c are used to extract the depth
481 ** and stencil values.
483 #define VALUE_TYPE GLuint
485 /* Change ZZZS -> SZZZ */
486 #define WRITE_DEPTH(_x, _y, d) \
487 pwrite_32(irb, Y_TILE(_x, _y), ((d) >> 8) | ((d) << 24))
489 /* Change SZZZ -> ZZZS */
490 #define READ_DEPTH( d, _x, _y ) { \
491 GLuint tmp = pread_32(irb, Y_TILE(_x, _y)); \
492 d = (tmp << 8) | (tmp >> 24); \
495 #define TAG(x) intel_YTile_##x##_z24_s8
496 #include "depthtmp.h"
500 ** 8-bit stencil function (XXX FBO: This is obsolete)
502 #define WRITE_STENCIL(_x, _y, d) pwrite_8(irb, NO_TILE(_x, _y) + 3, d)
503 #define READ_STENCIL(d, _x, _y) d = pread_8(irb, NO_TILE(_x, _y) + 3);
504 #define TAG(x) intel##x##_z24_s8
505 #include "stenciltmp.h"
508 ** 8-bit x-tile stencil function (XXX FBO: This is obsolete)
510 #define WRITE_STENCIL(_x, _y, d) pwrite_8(irb, X_TILE(_x, _y) + 3, d)
511 #define READ_STENCIL(d, _x, _y) d = pread_8(irb, X_TILE(_x, _y) + 3);
512 #define TAG(x) intel_XTile_##x##_z24_s8
513 #include "stenciltmp.h"
516 ** 8-bit y-tile stencil function (XXX FBO: This is obsolete)
518 #define WRITE_STENCIL(_x, _y, d) pwrite_8(irb, Y_TILE(_x, _y) + 3, d)
519 #define READ_STENCIL(d, _x, _y) d = pread_8(irb, Y_TILE(_x, _y) + 3)
520 #define TAG(x) intel_YTile_##x##_z24_s8
521 #include "stenciltmp.h"
524 intel_renderbuffer_map(struct intel_context
*intel
, struct gl_renderbuffer
*rb
)
526 struct intel_renderbuffer
*irb
= intel_renderbuffer(rb
);
528 if (irb
== NULL
|| irb
->region
== NULL
)
531 irb
->pfPitch
= irb
->region
->pitch
;
533 intel_set_span_functions(intel
, rb
);
537 intel_renderbuffer_unmap(struct intel_context
*intel
,
538 struct gl_renderbuffer
*rb
)
540 struct intel_renderbuffer
*irb
= intel_renderbuffer(rb
);
542 if (irb
== NULL
|| irb
->region
== NULL
)
545 clear_span_cache(irb
);
553 * Map or unmap all the renderbuffers which we may need during
554 * software rendering.
555 * XXX in the future, we could probably convey extra information to
556 * reduce the number of mappings needed. I.e. if doing a glReadPixels
557 * from the depth buffer, we really only need one mapping.
559 * XXX Rewrite this function someday.
560 * We can probably just loop over all the renderbuffer attachments,
561 * map/unmap all of them, and not worry about the _ColorDrawBuffers
562 * _ColorReadBuffer, _DepthBuffer or _StencilBuffer fields.
565 intel_map_unmap_buffers(struct intel_context
*intel
, GLboolean map
)
567 GLcontext
*ctx
= &intel
->ctx
;
570 /* color draw buffers */
571 for (j
= 0; j
< ctx
->DrawBuffer
->_NumColorDrawBuffers
; j
++) {
573 intel_renderbuffer_map(intel
, ctx
->DrawBuffer
->_ColorDrawBuffers
[j
]);
575 intel_renderbuffer_unmap(intel
, ctx
->DrawBuffer
->_ColorDrawBuffers
[j
]);
578 /* check for render to textures */
579 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
580 struct gl_renderbuffer_attachment
*att
=
581 ctx
->DrawBuffer
->Attachment
+ i
;
582 struct gl_texture_object
*tex
= att
->Texture
;
584 /* render to texture */
585 ASSERT(att
->Renderbuffer
);
587 intel_tex_map_images(intel
, intel_texture_object(tex
));
589 intel_tex_unmap_images(intel
, intel_texture_object(tex
));
593 /* color read buffers */
595 intel_renderbuffer_map(intel
, ctx
->ReadBuffer
->_ColorReadBuffer
);
597 intel_renderbuffer_unmap(intel
, ctx
->ReadBuffer
->_ColorReadBuffer
);
599 /* depth buffer (Note wrapper!) */
600 if (ctx
->DrawBuffer
->_DepthBuffer
) {
602 intel_renderbuffer_map(intel
, ctx
->DrawBuffer
->_DepthBuffer
->Wrapped
);
604 intel_renderbuffer_unmap(intel
,
605 ctx
->DrawBuffer
->_DepthBuffer
->Wrapped
);
608 /* stencil buffer (Note wrapper!) */
609 if (ctx
->DrawBuffer
->_StencilBuffer
) {
611 intel_renderbuffer_map(intel
,
612 ctx
->DrawBuffer
->_StencilBuffer
->Wrapped
);
614 intel_renderbuffer_unmap(intel
,
615 ctx
->DrawBuffer
->_StencilBuffer
->Wrapped
);
622 * Prepare for softare rendering. Map current read/draw framebuffers'
623 * renderbuffes and all currently bound texture objects.
625 * Old note: Moved locking out to get reasonable span performance.
628 intelSpanRenderStart(GLcontext
* ctx
)
630 struct intel_context
*intel
= intel_context(ctx
);
633 intelFlush(&intel
->ctx
);
634 LOCK_HARDWARE(intel
);
636 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
637 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
) {
638 struct gl_texture_object
*texObj
= ctx
->Texture
.Unit
[i
]._Current
;
639 intel_tex_map_images(intel
, intel_texture_object(texObj
));
643 intel_map_unmap_buffers(intel
, GL_TRUE
);
647 * Called when done softare rendering. Unmap the buffers we mapped in
648 * the above function.
651 intelSpanRenderFinish(GLcontext
* ctx
)
653 struct intel_context
*intel
= intel_context(ctx
);
658 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
659 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
) {
660 struct gl_texture_object
*texObj
= ctx
->Texture
.Unit
[i
]._Current
;
661 intel_tex_unmap_images(intel
, intel_texture_object(texObj
));
665 intel_map_unmap_buffers(intel
, GL_FALSE
);
667 UNLOCK_HARDWARE(intel
);
672 intelInitSpanFuncs(GLcontext
* ctx
)
674 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference(ctx
);
675 swdd
->SpanRenderStart
= intelSpanRenderStart
;
676 swdd
->SpanRenderFinish
= intelSpanRenderFinish
;
681 * Plug in appropriate span read/write functions for the given renderbuffer.
682 * These are used for the software fallbacks.
685 intel_set_span_functions(struct intel_context
*intel
,
686 struct gl_renderbuffer
*rb
)
688 struct intel_renderbuffer
*irb
= (struct intel_renderbuffer
*) rb
;
691 /* If in GEM mode, we need to do the tile address swizzling ourselves,
692 * instead of the fence registers handling it.
695 tiling
= irb
->region
->tiling
;
697 tiling
= I915_TILING_NONE
;
699 if (rb
->_ActualFormat
== GL_RGB5
) {
702 case I915_TILING_NONE
:
704 intelInitPointers_RGB565(rb
);
707 intel_XTile_InitPointers_RGB565(rb
);
710 intel_YTile_InitPointers_RGB565(rb
);
714 else if (rb
->_ActualFormat
== GL_RGB8
) {
717 case I915_TILING_NONE
:
719 intelInitPointers_xRGB8888(rb
);
722 intel_XTile_InitPointers_xRGB8888(rb
);
725 intel_YTile_InitPointers_xRGB8888(rb
);
729 else if (rb
->_ActualFormat
== GL_RGBA8
) {
732 case I915_TILING_NONE
:
734 intelInitPointers_ARGB8888(rb
);
737 intel_XTile_InitPointers_ARGB8888(rb
);
740 intel_YTile_InitPointers_ARGB8888(rb
);
744 else if (rb
->_ActualFormat
== GL_DEPTH_COMPONENT16
) {
746 case I915_TILING_NONE
:
748 intelInitDepthPointers_z16(rb
);
751 intel_XTile_InitDepthPointers_z16(rb
);
754 intel_YTile_InitDepthPointers_z16(rb
);
758 else if (rb
->_ActualFormat
== GL_DEPTH_COMPONENT24
|| /* XXX FBO remove */
759 rb
->_ActualFormat
== GL_DEPTH24_STENCIL8_EXT
) {
761 case I915_TILING_NONE
:
763 intelInitDepthPointers_z24_s8(rb
);
766 intel_XTile_InitDepthPointers_z24_s8(rb
);
769 intel_YTile_InitDepthPointers_z24_s8(rb
);
773 else if (rb
->_ActualFormat
== GL_STENCIL_INDEX8_EXT
) {
775 case I915_TILING_NONE
:
777 intelInitStencilPointers_z24_s8(rb
);
780 intel_XTile_InitStencilPointers_z24_s8(rb
);
783 intel_YTile_InitStencilPointers_z24_s8(rb
);
789 "Unexpected _ActualFormat in intelSetSpanFunctions");