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 **************************************************************************/
34 #include "intel_screen.h"
35 #include "intel_batchbuffer.h"
36 #include "intel_ioctl.h"
38 #include "i830_context.h"
41 /* A large amount of state doesn't need to be uploaded.
43 #define ACTIVE (I830_UPLOAD_TEXBLEND(0) | \
44 I830_UPLOAD_STIPPLE | \
46 I830_UPLOAD_BUFFERS | \
50 #define SET_STATE( i830, STATE ) \
52 i830->current->emitted &= ~ACTIVE; \
53 i830->current = &i830->STATE; \
54 i830->current->emitted &= ~ACTIVE; \
57 /* Operations where the 3D engine is decoupled temporarily from the
58 * current GL state and used for other purposes than simply rendering
61 static void set_initial_state( i830ContextPtr i830
)
63 memcpy(&i830
->meta
, &i830
->initial
, sizeof(i830
->meta
) );
64 i830
->meta
.active
= ACTIVE
;
65 i830
->meta
.emitted
= 0;
69 static void set_no_depth_stencil_write( i830ContextPtr i830
)
71 /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE )
73 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_1
] &= ~ENABLE_STENCIL_TEST
;
74 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] &= ~ENABLE_STENCIL_WRITE
;
75 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_1
] |= DISABLE_STENCIL_TEST
;
76 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] |= DISABLE_STENCIL_WRITE
;
79 /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
81 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_1
] &= ~ENABLE_DIS_DEPTH_TEST_MASK
;
82 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] &= ~ENABLE_DIS_DEPTH_WRITE_MASK
;
83 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_1
] |= DISABLE_DEPTH_TEST
;
84 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] |= DISABLE_DEPTH_WRITE
;
86 i830
->meta
.emitted
&= ~I830_UPLOAD_CTX
;
89 /* Set stencil unit to replace always with the reference value.
91 static void set_stencil_replace( i830ContextPtr i830
,
95 /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_TRUE )
97 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_1
] |= ENABLE_STENCIL_TEST
;
98 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] |= ENABLE_STENCIL_WRITE
;
101 /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
103 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_1
] &= ~ENABLE_DIS_DEPTH_TEST_MASK
;
104 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] &= ~ENABLE_DIS_DEPTH_WRITE_MASK
;
105 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_1
] |= DISABLE_DEPTH_TEST
;
106 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] |= DISABLE_DEPTH_WRITE
;
108 /* ctx->Driver.StencilMask( ctx, s_mask )
110 i830
->meta
.Ctx
[I830_CTXREG_STATE4
] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK
;
111 i830
->meta
.Ctx
[I830_CTXREG_STATE4
] |= (ENABLE_STENCIL_WRITE_MASK
|
112 STENCIL_WRITE_MASK((s_mask
&0xff)));
114 /* ctx->Driver.StencilOp( ctx, GL_REPLACE, GL_REPLACE, GL_REPLACE )
116 i830
->meta
.Ctx
[I830_CTXREG_STENCILTST
] &= ~(STENCIL_OPS_MASK
);
117 i830
->meta
.Ctx
[I830_CTXREG_STENCILTST
] |=
118 (ENABLE_STENCIL_PARMS
|
119 STENCIL_FAIL_OP(STENCILOP_REPLACE
) |
120 STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_REPLACE
) |
121 STENCIL_PASS_DEPTH_PASS_OP(STENCILOP_REPLACE
));
123 /* ctx->Driver.StencilFunc( ctx, GL_ALWAYS, s_clear, ~0 )
125 i830
->meta
.Ctx
[I830_CTXREG_STATE4
] &= ~MODE4_ENABLE_STENCIL_TEST_MASK
;
126 i830
->meta
.Ctx
[I830_CTXREG_STATE4
] |= (ENABLE_STENCIL_TEST_MASK
|
127 STENCIL_TEST_MASK(0xff));
129 i830
->meta
.Ctx
[I830_CTXREG_STENCILTST
] &= ~(STENCIL_REF_VALUE_MASK
|
130 ENABLE_STENCIL_TEST_FUNC_MASK
);
131 i830
->meta
.Ctx
[I830_CTXREG_STENCILTST
] |=
132 (ENABLE_STENCIL_REF_VALUE
|
133 ENABLE_STENCIL_TEST_FUNC
|
134 STENCIL_REF_VALUE((s_clear
&0xff)) |
135 STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS
));
139 i830
->meta
.emitted
&= ~I830_UPLOAD_CTX
;
143 static void set_color_mask( i830ContextPtr i830
, GLboolean state
)
145 const GLuint mask
= ((1 << WRITEMASK_RED_SHIFT
) |
146 (1 << WRITEMASK_GREEN_SHIFT
) |
147 (1 << WRITEMASK_BLUE_SHIFT
) |
148 (1 << WRITEMASK_ALPHA_SHIFT
));
151 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] &= ~mask
;
152 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] |=
153 (i830
->state
.Ctx
[I830_CTXREG_ENABLES_2
] & mask
);
156 i830
->meta
.Ctx
[I830_CTXREG_ENABLES_2
] |= mask
;
158 i830
->meta
.emitted
&= ~I830_UPLOAD_CTX
;
161 /* Installs a one-stage passthrough texture blend pipeline. Is there
162 * more that can be done to turn off texturing?
164 static void set_no_texture( i830ContextPtr i830
)
166 static const struct gl_tex_env_combine_state comb
= {
168 { GL_TEXTURE
, 0, 0, }, { GL_TEXTURE
, 0, 0, },
169 { GL_SRC_COLOR
, 0, 0 }, { GL_SRC_ALPHA
, 0, 0 },
173 i830
->meta
.TexBlendWordsUsed
[0] =
174 i830SetTexEnvCombine( i830
, & comb
, 0, TEXBLENDARG_TEXEL0
,
175 i830
->meta
.TexBlend
[0], NULL
);
177 i830
->meta
.TexBlend
[0][0] |= TEXOP_LAST_STAGE
;
178 i830
->meta
.emitted
&= ~I830_UPLOAD_TEXBLEND(0);
181 /* Set up a single element blend stage for 'replace' texturing with no
184 static void enable_texture_blend_replace( i830ContextPtr i830
,
187 static const struct gl_tex_env_combine_state comb
= {
188 GL_REPLACE
, GL_REPLACE
,
189 { GL_TEXTURE
, 0, 0, }, { GL_TEXTURE
, 0, 0, },
190 { GL_SRC_COLOR
, 0, 0 }, { GL_SRC_ALPHA
, 0, 0 },
194 i830
->meta
.TexBlendWordsUsed
[0] =
195 i830SetTexEnvCombine( i830
, & comb
, 0, TEXBLENDARG_TEXEL0
,
196 i830
->meta
.TexBlend
[0], NULL
);
198 i830
->meta
.TexBlend
[0][0] |= TEXOP_LAST_STAGE
;
199 i830
->meta
.emitted
&= ~I830_UPLOAD_TEXBLEND(0);
201 /* fprintf(stderr, "%s: TexBlendWordsUsed[0]: %d\n", */
202 /* __FUNCTION__, i830->meta.TexBlendWordsUsed[0]); */
207 /* Set up an arbitary piece of memory as a rectangular texture
208 * (including the front or back buffer).
210 static void set_tex_rect_source( i830ContextPtr i830
,
215 GLuint textureFormat
)
218 GLuint
*setup
= i830
->meta
.Tex
[0];
220 pitch
*= i830
->intel
.intelScreen
->cpp
;
222 /* fprintf(stderr, "%s: offset: %x w: %d h: %d pitch %d format %x\n", */
223 /* __FUNCTION__, offset, width, height, pitch, textureFormat ); */
225 setup
[I830_TEXREG_TM0LI
] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2
|
226 (LOAD_TEXTURE_MAP0
<< 0) | 4);
227 setup
[I830_TEXREG_TM0S0
] = (TM0S0_USE_FENCE
| offset
);
228 setup
[I830_TEXREG_TM0S1
] = (((height
- 1) << TM0S1_HEIGHT_SHIFT
) |
229 ((width
- 1) << TM0S1_WIDTH_SHIFT
) |
231 setup
[I830_TEXREG_TM0S2
] = ((((pitch
/ 4) - 1) << TM0S2_PITCH_SHIFT
));
232 setup
[I830_TEXREG_TM0S3
] &= ~TM0S3_MAX_MIP_MASK
;
233 setup
[I830_TEXREG_TM0S3
] &= ~TM0S3_MIN_MIP_MASK
;
234 setup
[I830_TEXREG_TM0S3
] |= ((numLevels
- 1)*4) << TM0S3_MIN_MIP_SHIFT
;
236 setup
[I830_TEXREG_MCS
] = (_3DSTATE_MAP_COORD_SET_CMD
|
238 ENABLE_TEXCOORD_PARAMS
|
239 TEXCOORDS_ARE_IN_TEXELUNITS
|
240 TEXCOORDTYPE_CARTESIAN
|
242 TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP
) |
244 TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP
));
246 i830
->meta
.emitted
&= ~I830_UPLOAD_TEX(0);
250 /* Select between front and back draw buffers.
252 static void set_draw_offset( i830ContextPtr i830
,
255 i830
->meta
.Buffer
[I830_DESTREG_CBUFADDR2
] = offset
;
256 i830
->meta
.emitted
&= ~I830_UPLOAD_BUFFERS
;
259 /* Setup an arbitary draw format, useful for targeting
260 * texture or agp memory.
262 static void set_draw_format( i830ContextPtr i830
,
266 i830
->meta
.Buffer
[I830_DESTREG_DV1
] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
267 DSTORG_VERT_BIAS(0x8) | /* .5 */
274 static void set_vertex_format( i830ContextPtr i830
)
276 i830
->meta
.Ctx
[I830_CTXREG_VF
] = (_3DSTATE_VFT0_CMD
|
281 i830
->meta
.Ctx
[I830_CTXREG_VF2
] = (_3DSTATE_VFT1_CMD
|
282 VFT1_TEX0_FMT(TEXCOORDFMT_2D
) |
283 VFT1_TEX1_FMT(TEXCOORDFMT_2D
) |
284 VFT1_TEX2_FMT(TEXCOORDFMT_2D
) |
285 VFT1_TEX3_FMT(TEXCOORDFMT_2D
));
286 i830
->meta
.emitted
&= ~I830_UPLOAD_CTX
;
290 static void draw_quad(i830ContextPtr i830
,
291 GLfloat x0
, GLfloat x1
,
292 GLfloat y0
, GLfloat y1
,
293 GLubyte red
, GLubyte green
,
294 GLubyte blue
, GLubyte alpha
,
295 GLfloat s0
, GLfloat s1
,
296 GLfloat t0
, GLfloat t1
)
298 GLuint vertex_size
= 8;
299 GLuint
*vb
= intelEmitInlinePrimitiveLocked( &i830
->intel
,
307 /* fprintf(stderr, "%s: %f,%f-%f,%f 0x%x%x%x%x %f,%f-%f,%f\n", */
309 /* x0,y0,x1,y1,red,green,blue,alpha,s0,t0,s1,t1); */
312 /* initial vertex, left bottom */
317 tmp
.v
.color
.red
= red
;
318 tmp
.v
.color
.green
= green
;
319 tmp
.v
.color
.blue
= blue
;
320 tmp
.v
.color
.alpha
= alpha
;
321 tmp
.v
.specular
.red
= 0;
322 tmp
.v
.specular
.green
= 0;
323 tmp
.v
.specular
.blue
= 0;
324 tmp
.v
.specular
.alpha
= 0;
327 for (i
= 0 ; i
< 8 ; i
++)
334 for (i
= 0 ; i
< 8 ; i
++)
341 for (i
= 0 ; i
< 8 ; i
++)
348 for (i
= 0 ; i
< 8 ; i
++)
351 /* fprintf(stderr, "%s: DV1: %x\n", */
352 /* __FUNCTION__, i830->meta.Buffer[I830_DESTREG_DV1]); */
356 i830ClearWithTris(intelContextPtr intel
, GLbitfield mask
,
358 GLint cx
, GLint cy
, GLint cw
, GLint ch
)
360 i830ContextPtr i830
= I830_CONTEXT( intel
);
361 __DRIdrawablePrivate
*dPriv
= intel
->driDrawable
;
362 intelScreenPrivate
*screen
= intel
->intelScreen
;
366 SET_STATE( i830
, meta
);
367 set_initial_state( i830
);
368 set_no_texture( i830
);
369 set_vertex_format( i830
);
371 LOCK_HARDWARE(intel
);
385 /* Don't do any clipping to screen - these are window coordinates.
386 * The active cliprects will be applied as for any other geometry.
389 if(mask
& DD_FRONT_LEFT_BIT
) {
390 set_no_depth_stencil_write( i830
);
391 set_color_mask( i830
, GL_TRUE
);
392 set_draw_offset( i830
, screen
->frontOffset
);
393 draw_quad(i830
, x0
, x1
, y0
, y1
,
394 intel
->clear_red
, intel
->clear_green
,
395 intel
->clear_blue
, intel
->clear_alpha
,
399 if(mask
& DD_BACK_LEFT_BIT
) {
400 set_no_depth_stencil_write( i830
);
401 set_color_mask( i830
, GL_TRUE
);
402 set_draw_offset( i830
, screen
->backOffset
);
404 draw_quad(i830
, x0
, x1
, y0
, y1
,
405 intel
->clear_red
, intel
->clear_green
,
406 intel
->clear_blue
, intel
->clear_alpha
,
410 if(mask
& DD_STENCIL_BIT
) {
411 set_stencil_replace( i830
,
412 intel
->ctx
.Stencil
.WriteMask
[0],
413 intel
->ctx
.Stencil
.Clear
);
415 set_color_mask( i830
, GL_FALSE
);
416 set_draw_offset( i830
, screen
->frontOffset
);
417 draw_quad( i830
, x0
, x1
, y0
, y1
, 0, 0, 0, 0, 0, 0, 0, 0 );
420 UNLOCK_HARDWARE(intel
);
422 SET_STATE( i830
, state
);
429 i830TryTextureReadPixels( GLcontext
*ctx
,
430 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
431 GLenum format
, GLenum type
,
432 const struct gl_pixelstore_attrib
*pack
,
435 i830ContextPtr i830
= I830_CONTEXT(ctx
);
436 intelContextPtr intel
= INTEL_CONTEXT(ctx
);
437 intelScreenPrivate
*screen
= i830
->intel
.intelScreen
;
438 GLint pitch
= pack
->RowLength
? pack
->RowLength
: width
;
439 __DRIdrawablePrivate
*dPriv
= i830
->intel
.driDrawable
;
441 GLenum glTextureFormat
;
442 int src_offset
= i830
->meta
.Buffer
[I830_DESTREG_CBUFADDR2
];
443 int destOffset
= intelAgpOffsetFromVirtual( &i830
->intel
, pixels
);
444 int destFormat
, depthFormat
, destPitch
;
447 if (INTEL_DEBUG
& DEBUG_PIXEL
)
448 fprintf(stderr
, "%s\n", __FUNCTION__
);
451 if ( ctx
->_ImageTransferState
||
455 fprintf(stderr
, "%s: check_color failed\n", __FUNCTION__
);
459 switch (screen
->fbFormat
) {
461 textureFormat
= MAPSURF_16BIT
| MT_16BIT_RGB565
;
462 glTextureFormat
= GL_RGB
;
465 textureFormat
= MAPSURF_16BIT
| MT_16BIT_ARGB1555
;
466 glTextureFormat
= GL_RGBA
;
469 textureFormat
= MAPSURF_32BIT
| MT_32BIT_ARGB8888
;
470 glTextureFormat
= GL_RGBA
;
473 fprintf(stderr
, "%s: textureFormat failed %x\n", __FUNCTION__
,
480 case GL_UNSIGNED_SHORT_5_6_5
:
481 if (format
!= GL_RGB
) return GL_FALSE
;
482 destFormat
= COLR_BUF_RGB565
;
483 depthFormat
= DEPTH_FRMT_16_FIXED
;
484 destPitch
= pitch
* 2;
486 case GL_UNSIGNED_INT_8_8_8_8_REV
:
487 if (format
!= GL_BGRA
) return GL_FALSE
;
488 destFormat
= COLR_BUF_ARGB8888
;
489 depthFormat
= DEPTH_FRMT_24_FIXED_8_OTHER
;
490 destPitch
= pitch
* 4;
493 fprintf(stderr
, "%s: destFormat failed %s\n", __FUNCTION__
,
494 _mesa_lookup_enum_by_nr(type
));
498 destFormat
|= (0x02<<24);
500 /* fprintf(stderr, "type: %s destFormat: %x\n", */
501 /* _mesa_lookup_enum_by_nr(type), */
506 SET_STATE( i830
, meta
);
507 set_initial_state( i830
);
508 set_no_depth_stencil_write( i830
);
510 LOCK_HARDWARE( intel
);
512 intelWaitForIdle( intel
); /* required by GL */
514 if (!driClipRectToFramebuffer(ctx
->ReadBuffer
, &x
, &y
, &width
, &height
)) {
515 UNLOCK_HARDWARE( intel
);
516 SET_STATE(i830
, state
);
517 fprintf(stderr
, "%s: cliprect failed\n", __FUNCTION__
);
522 /* FIXME -- Just emit the correct state
524 if (i830SetParam(i830
->driFd
, I830_SETPARAM_CBUFFER_PITCH
,
526 UNLOCK_HARDWARE( intel
);
527 SET_STATE(i830
, state
);
528 fprintf(stderr
, "%s: setparam failed\n", __FUNCTION__
);
534 y
= dPriv
->h
- y
- height
;
539 /* Set the frontbuffer up as a large rectangular texture.
541 set_tex_rect_source( i830
,
549 enable_texture_blend_replace( i830
, glTextureFormat
);
552 /* Set the 3d engine to draw into the agp memory
555 set_draw_offset( i830
, destOffset
);
556 set_draw_format( i830
, destFormat
, depthFormat
);
559 /* Draw a single quad, no cliprects:
561 i830
->intel
.numClipRects
= 1;
562 i830
->intel
.pClipRects
= &tmp
;
563 i830
->intel
.pClipRects
[0].x1
= 0;
564 i830
->intel
.pClipRects
[0].y1
= 0;
565 i830
->intel
.pClipRects
[0].x2
= width
;
566 i830
->intel
.pClipRects
[0].y2
= height
;
571 x
, x
+width
, y
, y
+height
);
573 intelWindowMoved( intel
);
575 UNLOCK_HARDWARE( intel
);
576 intelFinish( ctx
); /* required by GL */
578 SET_STATE( i830
, state
);
584 i830TryTextureDrawPixels( GLcontext
*ctx
,
585 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
586 GLenum format
, GLenum type
,
587 const struct gl_pixelstore_attrib
*unpack
,
588 const GLvoid
*pixels
)
590 intelContextPtr intel
= INTEL_CONTEXT(ctx
);
591 i830ContextPtr i830
= I830_CONTEXT(ctx
);
592 GLint pitch
= unpack
->RowLength
? unpack
->RowLength
: width
;
593 __DRIdrawablePrivate
*dPriv
= intel
->driDrawable
;
595 GLenum glTextureFormat
;
596 int dst_offset
= i830
->meta
.Buffer
[I830_DESTREG_CBUFADDR2
];
597 int src_offset
= intelAgpOffsetFromVirtual( intel
, pixels
);
599 if (INTEL_DEBUG
& DEBUG_PIXEL
)
600 fprintf(stderr
, "%s\n", __FUNCTION__
);
602 /* Todo -- upload images that aren't in agp space, then texture
606 if ( !intelIsAgpMemory( intel
, pixels
, pitch
*height
) ) {
607 fprintf(stderr
, "%s: intelIsAgpMemory failed\n", __FUNCTION__
);
611 /* Todo -- don't want to clobber all the drawing state like we do
612 * for readpixels -- most of this state can be handled just fine.
614 if ( ctx
->_ImageTransferState
||
617 ctx
->Color
.AlphaEnabled
||
620 ctx
->Scissor
.Enabled
||
621 ctx
->Stencil
.Enabled
||
622 !ctx
->Color
.ColorMask
[0] ||
623 !ctx
->Color
.ColorMask
[1] ||
624 !ctx
->Color
.ColorMask
[2] ||
625 !ctx
->Color
.ColorMask
[3] ||
626 ctx
->Color
.ColorLogicOpEnabled
||
627 ctx
->Texture
._EnabledUnits
||
628 ctx
->Depth
.OcclusionTest
) {
629 fprintf(stderr
, "%s: other tests failed\n", __FUNCTION__
);
633 /* Todo -- remove these restrictions:
635 if (ctx
->Pixel
.ZoomX
!= 1.0F
||
636 ctx
->Pixel
.ZoomY
!= -1.0F
)
642 case GL_UNSIGNED_SHORT_1_5_5_5_REV
:
643 if (format
!= GL_BGRA
) return GL_FALSE
;
644 textureFormat
= MAPSURF_16BIT
| MT_16BIT_ARGB1555
;
645 glTextureFormat
= GL_RGBA
;
647 case GL_UNSIGNED_SHORT_5_6_5
:
648 if (format
!= GL_RGB
) return GL_FALSE
;
649 textureFormat
= MAPSURF_16BIT
| MT_16BIT_RGB565
;
650 glTextureFormat
= GL_RGB
;
652 case GL_UNSIGNED_SHORT_8_8_MESA
:
653 if (format
!= GL_YCBCR_MESA
) return GL_FALSE
;
654 textureFormat
= (MAPSURF_422
| MT_422_YCRCB_SWAPY
655 /* | TM0S1_COLORSPACE_CONVERSION */
657 glTextureFormat
= GL_YCBCR_MESA
;
659 case GL_UNSIGNED_SHORT_8_8_REV_MESA
:
660 if (format
!= GL_YCBCR_MESA
) return GL_FALSE
;
661 textureFormat
= (MAPSURF_422
| MT_422_YCRCB_NORMAL
662 /* | TM0S1_COLORSPACE_CONVERSION */
664 glTextureFormat
= GL_YCBCR_MESA
;
666 case GL_UNSIGNED_INT_8_8_8_8_REV
:
667 if (format
!= GL_BGRA
) return GL_FALSE
;
668 textureFormat
= MAPSURF_32BIT
| MT_32BIT_ARGB8888
;
669 glTextureFormat
= GL_RGBA
;
672 fprintf(stderr
, "%s: destFormat failed\n", __FUNCTION__
);
678 SET_STATE( i830
, meta
);
680 LOCK_HARDWARE( intel
);
682 intelWaitForIdle( intel
); /* required by GL */
684 y
-= height
; /* cope with pixel zoom */
686 if (!driClipRectToFramebuffer(ctx
->ReadBuffer
, &x
, &y
, &width
, &height
)) {
687 UNLOCK_HARDWARE( intel
);
688 SET_STATE(i830
, state
);
689 fprintf(stderr
, "%s: cliprect failed\n", __FUNCTION__
);
694 y
= dPriv
->h
- y
- height
;
696 set_initial_state( i830
);
698 /* Set the pixel image up as a rectangular texture.
700 set_tex_rect_source( i830
,
704 pitch
, /* XXXX!!!! -- /2 sometimes */
708 enable_texture_blend_replace( i830
, glTextureFormat
);
711 /* Draw to the current draw buffer:
713 set_draw_offset( i830
, dst_offset
);
715 /* Draw a quad, use regular cliprects
717 /* fprintf(stderr, "x: %d y: %d width %d height %d\n", x, y, width, height); */
720 x
, x
+width
, y
, y
+height
,
722 0, width
, 0, height
);
724 intelWindowMoved( intel
);
726 UNLOCK_HARDWARE( intel
);
727 intelFinish( ctx
); /* required by GL */
729 SET_STATE(i830
, state
);