2 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
4 The Weather Channel (TM) funded Tungsten Graphics to develop the
5 initial release of the Radeon 8500 driver under the XFree86 license.
6 This notice must be preserved.
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
16 The above copyright notice and this permission notice (including the
17 next paragraph) shall be included in all copies or substantial
18 portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
32 * Keith Whitwell <keith@tungstengraphics.com>
35 #include "main/glheader.h"
36 #include "main/imports.h"
37 #include "main/context.h"
38 #include "main/macros.h"
39 #include "main/teximage.h"
40 #include "main/texobj.h"
41 #include "main/enums.h"
43 #include "radeon_common.h"
44 #include "radeon_mipmap_tree.h"
45 #include "r200_context.h"
46 #include "r200_state.h"
47 #include "r200_ioctl.h"
48 #include "r200_swtcl.h"
53 #define R200_TXFORMAT_A8 R200_TXFORMAT_I8
54 #define R200_TXFORMAT_L8 R200_TXFORMAT_I8
55 #define R200_TXFORMAT_AL88 R200_TXFORMAT_AI88
56 #define R200_TXFORMAT_YCBCR R200_TXFORMAT_YVYU422
57 #define R200_TXFORMAT_YCBCR_REV R200_TXFORMAT_VYUY422
58 #define R200_TXFORMAT_RGB_DXT1 R200_TXFORMAT_DXT1
59 #define R200_TXFORMAT_RGBA_DXT1 R200_TXFORMAT_DXT1
60 #define R200_TXFORMAT_RGBA_DXT3 R200_TXFORMAT_DXT23
61 #define R200_TXFORMAT_RGBA_DXT5 R200_TXFORMAT_DXT45
64 [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, 0 }
65 #define _COLOR_REV(f) \
66 [ MESA_FORMAT_ ## f ## _REV ] = { R200_TXFORMAT_ ## f, 0 }
68 [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f | R200_TXFORMAT_ALPHA_IN_MAP, 0 }
69 #define _ALPHA_REV(f) \
70 [ MESA_FORMAT_ ## f ## _REV ] = { R200_TXFORMAT_ ## f | R200_TXFORMAT_ALPHA_IN_MAP, 0 }
72 [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, R200_YUV_TO_RGB }
74 [ MESA_FORMAT_ ## f ] = { 0xffffffff, 0 }
75 #define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5) \
76 && (tx_table_be[f].format != 0xffffffff) )
79 GLuint format
, filter
;
82 static const struct tx_table tx_table_be
[] =
84 [ MESA_FORMAT_RGBA8888
] = { R200_TXFORMAT_ABGR8888
| R200_TXFORMAT_ALPHA_IN_MAP
, 0 },
111 static const struct tx_table tx_table_le
[] =
114 [ MESA_FORMAT_RGBA8888_REV
] = { R200_TXFORMAT_ABGR8888
| R200_TXFORMAT_ALPHA_IN_MAP
, 0 },
116 _ALPHA_REV(ARGB8888
),
117 [ MESA_FORMAT_RGB888
] = { R200_TXFORMAT_ARGB8888
, 0 },
121 _ALPHA_REV(ARGB4444
),
123 _ALPHA_REV(ARGB1555
),
144 /* ================================================================
145 * Texture combine functions
148 /* GL_ARB_texture_env_combine support
151 /* The color tables have combine functions for GL_SRC_COLOR,
152 * GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
154 static GLuint r200_register_color
[][R200_MAX_TEXTURE_UNITS
] =
157 R200_TXC_ARG_A_R0_COLOR
,
158 R200_TXC_ARG_A_R1_COLOR
,
159 R200_TXC_ARG_A_R2_COLOR
,
160 R200_TXC_ARG_A_R3_COLOR
,
161 R200_TXC_ARG_A_R4_COLOR
,
162 R200_TXC_ARG_A_R5_COLOR
165 R200_TXC_ARG_A_R0_COLOR
| R200_TXC_COMP_ARG_A
,
166 R200_TXC_ARG_A_R1_COLOR
| R200_TXC_COMP_ARG_A
,
167 R200_TXC_ARG_A_R2_COLOR
| R200_TXC_COMP_ARG_A
,
168 R200_TXC_ARG_A_R3_COLOR
| R200_TXC_COMP_ARG_A
,
169 R200_TXC_ARG_A_R4_COLOR
| R200_TXC_COMP_ARG_A
,
170 R200_TXC_ARG_A_R5_COLOR
| R200_TXC_COMP_ARG_A
173 R200_TXC_ARG_A_R0_ALPHA
,
174 R200_TXC_ARG_A_R1_ALPHA
,
175 R200_TXC_ARG_A_R2_ALPHA
,
176 R200_TXC_ARG_A_R3_ALPHA
,
177 R200_TXC_ARG_A_R4_ALPHA
,
178 R200_TXC_ARG_A_R5_ALPHA
181 R200_TXC_ARG_A_R0_ALPHA
| R200_TXC_COMP_ARG_A
,
182 R200_TXC_ARG_A_R1_ALPHA
| R200_TXC_COMP_ARG_A
,
183 R200_TXC_ARG_A_R2_ALPHA
| R200_TXC_COMP_ARG_A
,
184 R200_TXC_ARG_A_R3_ALPHA
| R200_TXC_COMP_ARG_A
,
185 R200_TXC_ARG_A_R4_ALPHA
| R200_TXC_COMP_ARG_A
,
186 R200_TXC_ARG_A_R5_ALPHA
| R200_TXC_COMP_ARG_A
190 static GLuint r200_tfactor_color
[] =
192 R200_TXC_ARG_A_TFACTOR_COLOR
,
193 R200_TXC_ARG_A_TFACTOR_COLOR
| R200_TXC_COMP_ARG_A
,
194 R200_TXC_ARG_A_TFACTOR_ALPHA
,
195 R200_TXC_ARG_A_TFACTOR_ALPHA
| R200_TXC_COMP_ARG_A
198 static GLuint r200_tfactor1_color
[] =
200 R200_TXC_ARG_A_TFACTOR1_COLOR
,
201 R200_TXC_ARG_A_TFACTOR1_COLOR
| R200_TXC_COMP_ARG_A
,
202 R200_TXC_ARG_A_TFACTOR1_ALPHA
,
203 R200_TXC_ARG_A_TFACTOR1_ALPHA
| R200_TXC_COMP_ARG_A
206 static GLuint r200_primary_color
[] =
208 R200_TXC_ARG_A_DIFFUSE_COLOR
,
209 R200_TXC_ARG_A_DIFFUSE_COLOR
| R200_TXC_COMP_ARG_A
,
210 R200_TXC_ARG_A_DIFFUSE_ALPHA
,
211 R200_TXC_ARG_A_DIFFUSE_ALPHA
| R200_TXC_COMP_ARG_A
214 /* GL_ZERO table - indices 0-3
215 * GL_ONE table - indices 1-4
217 static GLuint r200_zero_color
[] =
220 R200_TXC_ARG_A_ZERO
| R200_TXC_COMP_ARG_A
,
222 R200_TXC_ARG_A_ZERO
| R200_TXC_COMP_ARG_A
,
226 /* The alpha tables only have GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
228 static GLuint r200_register_alpha
[][R200_MAX_TEXTURE_UNITS
] =
231 R200_TXA_ARG_A_R0_ALPHA
,
232 R200_TXA_ARG_A_R1_ALPHA
,
233 R200_TXA_ARG_A_R2_ALPHA
,
234 R200_TXA_ARG_A_R3_ALPHA
,
235 R200_TXA_ARG_A_R4_ALPHA
,
236 R200_TXA_ARG_A_R5_ALPHA
239 R200_TXA_ARG_A_R0_ALPHA
| R200_TXA_COMP_ARG_A
,
240 R200_TXA_ARG_A_R1_ALPHA
| R200_TXA_COMP_ARG_A
,
241 R200_TXA_ARG_A_R2_ALPHA
| R200_TXA_COMP_ARG_A
,
242 R200_TXA_ARG_A_R3_ALPHA
| R200_TXA_COMP_ARG_A
,
243 R200_TXA_ARG_A_R4_ALPHA
| R200_TXA_COMP_ARG_A
,
244 R200_TXA_ARG_A_R5_ALPHA
| R200_TXA_COMP_ARG_A
248 static GLuint r200_tfactor_alpha
[] =
250 R200_TXA_ARG_A_TFACTOR_ALPHA
,
251 R200_TXA_ARG_A_TFACTOR_ALPHA
| R200_TXA_COMP_ARG_A
254 static GLuint r200_tfactor1_alpha
[] =
256 R200_TXA_ARG_A_TFACTOR1_ALPHA
,
257 R200_TXA_ARG_A_TFACTOR1_ALPHA
| R200_TXA_COMP_ARG_A
260 static GLuint r200_primary_alpha
[] =
262 R200_TXA_ARG_A_DIFFUSE_ALPHA
,
263 R200_TXA_ARG_A_DIFFUSE_ALPHA
| R200_TXA_COMP_ARG_A
266 /* GL_ZERO table - indices 0-1
267 * GL_ONE table - indices 1-2
269 static GLuint r200_zero_alpha
[] =
272 R200_TXA_ARG_A_ZERO
| R200_TXA_COMP_ARG_A
,
277 /* Extract the arg from slot A, shift it into the correct argument slot
278 * and set the corresponding complement bit.
280 #define R200_COLOR_ARG( n, arg ) \
283 ((color_arg[n] & R200_TXC_ARG_A_MASK) \
284 << R200_TXC_ARG_##arg##_SHIFT); \
286 ((color_arg[n] >> R200_TXC_COMP_ARG_A_SHIFT) \
287 << R200_TXC_COMP_ARG_##arg##_SHIFT); \
290 #define R200_ALPHA_ARG( n, arg ) \
293 ((alpha_arg[n] & R200_TXA_ARG_A_MASK) \
294 << R200_TXA_ARG_##arg##_SHIFT); \
296 ((alpha_arg[n] >> R200_TXA_COMP_ARG_A_SHIFT) \
297 << R200_TXA_COMP_ARG_##arg##_SHIFT); \
301 /* ================================================================
302 * Texture unit state management
305 static GLboolean
r200UpdateTextureEnv( struct gl_context
*ctx
, int unit
, int slot
, GLuint replaceargs
)
307 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
308 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
309 GLuint color_combine
, alpha_combine
;
310 GLuint color_scale
= rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXCBLEND2
] &
311 ~(R200_TXC_SCALE_MASK
| R200_TXC_OUTPUT_REG_MASK
| R200_TXC_TFACTOR_SEL_MASK
|
312 R200_TXC_TFACTOR1_SEL_MASK
);
313 GLuint alpha_scale
= rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXABLEND2
] &
314 ~(R200_TXA_DOT_ALPHA
| R200_TXA_SCALE_MASK
| R200_TXA_OUTPUT_REG_MASK
|
315 R200_TXA_TFACTOR_SEL_MASK
| R200_TXA_TFACTOR1_SEL_MASK
);
317 /* texUnit->_Current can be NULL if and only if the texture unit is
318 * not actually enabled.
320 assert( (texUnit
->_ReallyEnabled
== 0)
321 || (texUnit
->_Current
!= NULL
) );
323 if ( R200_DEBUG
& RADEON_TEXTURE
) {
324 fprintf( stderr
, "%s( %p, %d )\n", __FUNCTION__
, (void *)ctx
, unit
);
327 /* Set the texture environment state. Isn't this nice and clean?
328 * The chip will automagically set the texture alpha to 0xff when
329 * the texture format does not include an alpha component. This
330 * reduces the amount of special-casing we have to do, alpha-only
331 * textures being a notable exception.
334 color_scale
|= ((rmesa
->state
.texture
.unit
[unit
].outputreg
+ 1) << R200_TXC_OUTPUT_REG_SHIFT
) |
335 (unit
<< R200_TXC_TFACTOR_SEL_SHIFT
) |
336 (replaceargs
<< R200_TXC_TFACTOR1_SEL_SHIFT
);
337 alpha_scale
|= ((rmesa
->state
.texture
.unit
[unit
].outputreg
+ 1) << R200_TXA_OUTPUT_REG_SHIFT
) |
338 (unit
<< R200_TXA_TFACTOR_SEL_SHIFT
) |
339 (replaceargs
<< R200_TXA_TFACTOR1_SEL_SHIFT
);
341 if ( !texUnit
->_ReallyEnabled
) {
343 color_combine
= R200_TXC_ARG_A_ZERO
| R200_TXC_ARG_B_ZERO
344 | R200_TXC_ARG_C_DIFFUSE_COLOR
| R200_TXC_OP_MADD
;
345 alpha_combine
= R200_TXA_ARG_A_ZERO
| R200_TXA_ARG_B_ZERO
346 | R200_TXA_ARG_C_DIFFUSE_ALPHA
| R200_TXA_OP_MADD
;
349 GLuint color_arg
[3], alpha_arg
[3];
351 const GLuint numColorArgs
= texUnit
->_CurrentCombine
->_NumArgsRGB
;
352 const GLuint numAlphaArgs
= texUnit
->_CurrentCombine
->_NumArgsA
;
353 GLuint RGBshift
= texUnit
->_CurrentCombine
->ScaleShiftRGB
;
354 GLuint Ashift
= texUnit
->_CurrentCombine
->ScaleShiftA
;
357 const GLint replaceoprgb
=
358 ctx
->Texture
.Unit
[replaceargs
]._CurrentCombine
->OperandRGB
[0] - GL_SRC_COLOR
;
359 const GLint replaceopa
=
360 ctx
->Texture
.Unit
[replaceargs
]._CurrentCombine
->OperandA
[0] - GL_SRC_ALPHA
;
363 * Extract the color and alpha combine function arguments.
365 for ( i
= 0 ; i
< numColorArgs
; i
++ ) {
366 GLint op
= texUnit
->_CurrentCombine
->OperandRGB
[i
] - GL_SRC_COLOR
;
367 const GLint srcRGBi
= texUnit
->_CurrentCombine
->SourceRGB
[i
];
372 color_arg
[i
] = r200_register_color
[op
][unit
];
375 color_arg
[i
] = r200_tfactor_color
[op
];
377 case GL_PRIMARY_COLOR
:
378 color_arg
[i
] = r200_primary_color
[op
];
381 if (replaceargs
!= unit
) {
382 const GLint srcRGBreplace
=
383 ctx
->Texture
.Unit
[replaceargs
]._CurrentCombine
->SourceRGB
[0];
385 op
= op
^ replaceopa
;
388 op
= op
^ replaceoprgb
;
390 switch (srcRGBreplace
) {
392 color_arg
[i
] = r200_register_color
[op
][replaceargs
];
395 color_arg
[i
] = r200_tfactor1_color
[op
];
397 case GL_PRIMARY_COLOR
:
398 color_arg
[i
] = r200_primary_color
[op
];
402 color_arg
[i
] = r200_primary_color
[op
];
404 color_arg
[i
] = r200_register_color
[op
]
405 [rmesa
->state
.texture
.unit
[replaceargs
- 1].outputreg
];
408 color_arg
[i
] = r200_zero_color
[op
];
411 color_arg
[i
] = r200_zero_color
[op
+1];
419 color_arg
[i
] = r200_register_color
[op
][srcRGBreplace
- GL_TEXTURE0
];
427 color_arg
[i
] = r200_primary_color
[op
];
429 color_arg
[i
] = r200_register_color
[op
]
430 [rmesa
->state
.texture
.unit
[unit
- 1].outputreg
];
434 color_arg
[i
] = r200_zero_color
[op
];
437 color_arg
[i
] = r200_zero_color
[op
+1];
445 color_arg
[i
] = r200_register_color
[op
][srcRGBi
- GL_TEXTURE0
];
452 for ( i
= 0 ; i
< numAlphaArgs
; i
++ ) {
453 GLint op
= texUnit
->_CurrentCombine
->OperandA
[i
] - GL_SRC_ALPHA
;
454 const GLint srcAi
= texUnit
->_CurrentCombine
->SourceA
[i
];
459 alpha_arg
[i
] = r200_register_alpha
[op
][unit
];
462 alpha_arg
[i
] = r200_tfactor_alpha
[op
];
464 case GL_PRIMARY_COLOR
:
465 alpha_arg
[i
] = r200_primary_alpha
[op
];
468 if (replaceargs
!= unit
) {
469 const GLint srcAreplace
=
470 ctx
->Texture
.Unit
[replaceargs
]._CurrentCombine
->SourceA
[0];
471 op
= op
^ replaceopa
;
472 switch (srcAreplace
) {
474 alpha_arg
[i
] = r200_register_alpha
[op
][replaceargs
];
477 alpha_arg
[i
] = r200_tfactor1_alpha
[op
];
479 case GL_PRIMARY_COLOR
:
480 alpha_arg
[i
] = r200_primary_alpha
[op
];
484 alpha_arg
[i
] = r200_primary_alpha
[op
];
486 alpha_arg
[i
] = r200_register_alpha
[op
]
487 [rmesa
->state
.texture
.unit
[replaceargs
- 1].outputreg
];
490 alpha_arg
[i
] = r200_zero_alpha
[op
];
493 alpha_arg
[i
] = r200_zero_alpha
[op
+1];
501 alpha_arg
[i
] = r200_register_alpha
[op
][srcAreplace
- GL_TEXTURE0
];
509 alpha_arg
[i
] = r200_primary_alpha
[op
];
511 alpha_arg
[i
] = r200_register_alpha
[op
]
512 [rmesa
->state
.texture
.unit
[unit
- 1].outputreg
];
516 alpha_arg
[i
] = r200_zero_alpha
[op
];
519 alpha_arg
[i
] = r200_zero_alpha
[op
+1];
527 alpha_arg
[i
] = r200_register_alpha
[op
][srcAi
- GL_TEXTURE0
];
535 * Build up the color and alpha combine functions.
537 switch ( texUnit
->_CurrentCombine
->ModeRGB
) {
539 color_combine
= (R200_TXC_ARG_A_ZERO
|
540 R200_TXC_ARG_B_ZERO
|
542 R200_COLOR_ARG( 0, C
);
545 color_combine
= (R200_TXC_ARG_C_ZERO
|
547 R200_COLOR_ARG( 0, A
);
548 R200_COLOR_ARG( 1, B
);
551 color_combine
= (R200_TXC_ARG_B_ZERO
|
552 R200_TXC_COMP_ARG_B
|
554 R200_COLOR_ARG( 0, A
);
555 R200_COLOR_ARG( 1, C
);
558 color_combine
= (R200_TXC_ARG_B_ZERO
|
559 R200_TXC_COMP_ARG_B
|
560 R200_TXC_BIAS_ARG_C
| /* new */
561 R200_TXC_OP_MADD
); /* was ADDSIGNED */
562 R200_COLOR_ARG( 0, A
);
563 R200_COLOR_ARG( 1, C
);
566 color_combine
= (R200_TXC_ARG_B_ZERO
|
567 R200_TXC_COMP_ARG_B
|
570 R200_COLOR_ARG( 0, A
);
571 R200_COLOR_ARG( 1, C
);
574 color_combine
= (R200_TXC_OP_LERP
);
575 R200_COLOR_ARG( 0, B
);
576 R200_COLOR_ARG( 1, A
);
577 R200_COLOR_ARG( 2, C
);
580 case GL_DOT3_RGB_EXT
:
581 case GL_DOT3_RGBA_EXT
:
582 /* The EXT version of the DOT3 extension does not support the
583 * scale factor, but the ARB version (and the version in OpenGL
591 /* DOT3 works differently on R200 than on R100. On R100, just
592 * setting the DOT3 mode did everything for you. On R200, the
593 * driver has to enable the biasing and scale in the inputs to
594 * put them in the proper [-1,1] range. This is what the 4x and
595 * the -0.5 in the DOT3 spec do. The post-scale is then set
599 color_combine
= (R200_TXC_ARG_C_ZERO
|
601 R200_TXC_BIAS_ARG_A
|
602 R200_TXC_BIAS_ARG_B
|
603 R200_TXC_SCALE_ARG_A
|
604 R200_TXC_SCALE_ARG_B
);
605 R200_COLOR_ARG( 0, A
);
606 R200_COLOR_ARG( 1, B
);
609 case GL_MODULATE_ADD_ATI
:
610 color_combine
= (R200_TXC_OP_MADD
);
611 R200_COLOR_ARG( 0, A
);
612 R200_COLOR_ARG( 1, C
);
613 R200_COLOR_ARG( 2, B
);
615 case GL_MODULATE_SIGNED_ADD_ATI
:
616 color_combine
= (R200_TXC_BIAS_ARG_C
| /* new */
617 R200_TXC_OP_MADD
); /* was ADDSIGNED */
618 R200_COLOR_ARG( 0, A
);
619 R200_COLOR_ARG( 1, C
);
620 R200_COLOR_ARG( 2, B
);
622 case GL_MODULATE_SUBTRACT_ATI
:
623 color_combine
= (R200_TXC_NEG_ARG_C
|
625 R200_COLOR_ARG( 0, A
);
626 R200_COLOR_ARG( 1, C
);
627 R200_COLOR_ARG( 2, B
);
633 switch ( texUnit
->_CurrentCombine
->ModeA
) {
635 alpha_combine
= (R200_TXA_ARG_A_ZERO
|
636 R200_TXA_ARG_B_ZERO
|
638 R200_ALPHA_ARG( 0, C
);
641 alpha_combine
= (R200_TXA_ARG_C_ZERO
|
643 R200_ALPHA_ARG( 0, A
);
644 R200_ALPHA_ARG( 1, B
);
647 alpha_combine
= (R200_TXA_ARG_B_ZERO
|
648 R200_TXA_COMP_ARG_B
|
650 R200_ALPHA_ARG( 0, A
);
651 R200_ALPHA_ARG( 1, C
);
654 alpha_combine
= (R200_TXA_ARG_B_ZERO
|
655 R200_TXA_COMP_ARG_B
|
656 R200_TXA_BIAS_ARG_C
| /* new */
657 R200_TXA_OP_MADD
); /* was ADDSIGNED */
658 R200_ALPHA_ARG( 0, A
);
659 R200_ALPHA_ARG( 1, C
);
662 alpha_combine
= (R200_TXA_ARG_B_ZERO
|
663 R200_TXA_COMP_ARG_B
|
666 R200_ALPHA_ARG( 0, A
);
667 R200_ALPHA_ARG( 1, C
);
670 alpha_combine
= (R200_TXA_OP_LERP
);
671 R200_ALPHA_ARG( 0, B
);
672 R200_ALPHA_ARG( 1, A
);
673 R200_ALPHA_ARG( 2, C
);
676 case GL_MODULATE_ADD_ATI
:
677 alpha_combine
= (R200_TXA_OP_MADD
);
678 R200_ALPHA_ARG( 0, A
);
679 R200_ALPHA_ARG( 1, C
);
680 R200_ALPHA_ARG( 2, B
);
682 case GL_MODULATE_SIGNED_ADD_ATI
:
683 alpha_combine
= (R200_TXA_BIAS_ARG_C
| /* new */
684 R200_TXA_OP_MADD
); /* was ADDSIGNED */
685 R200_ALPHA_ARG( 0, A
);
686 R200_ALPHA_ARG( 1, C
);
687 R200_ALPHA_ARG( 2, B
);
689 case GL_MODULATE_SUBTRACT_ATI
:
690 alpha_combine
= (R200_TXA_NEG_ARG_C
|
692 R200_ALPHA_ARG( 0, A
);
693 R200_ALPHA_ARG( 1, C
);
694 R200_ALPHA_ARG( 2, B
);
700 if ( (texUnit
->_CurrentCombine
->ModeRGB
== GL_DOT3_RGBA_EXT
)
701 || (texUnit
->_CurrentCombine
->ModeRGB
== GL_DOT3_RGBA
) ) {
702 alpha_scale
|= R200_TXA_DOT_ALPHA
;
707 * Apply the scale factor.
709 color_scale
|= (RGBshift
<< R200_TXC_SCALE_SHIFT
);
710 alpha_scale
|= (Ashift
<< R200_TXA_SCALE_SHIFT
);
716 if ( rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXCBLEND
] != color_combine
||
717 rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXABLEND
] != alpha_combine
||
718 rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXCBLEND2
] != color_scale
||
719 rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXABLEND2
] != alpha_scale
) {
720 R200_STATECHANGE( rmesa
, pix
[slot
] );
721 rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXCBLEND
] = color_combine
;
722 rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXABLEND
] = alpha_combine
;
723 rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXCBLEND2
] = color_scale
;
724 rmesa
->hw
.pix
[slot
].cmd
[PIX_PP_TXABLEND2
] = alpha_scale
;
730 void r200SetTexOffset(__DRIcontext
* pDRICtx
, GLint texname
,
731 unsigned long long offset
, GLint depth
, GLuint pitch
)
733 r200ContextPtr rmesa
= pDRICtx
->driverPrivate
;
734 struct gl_texture_object
*tObj
=
735 _mesa_lookup_texture(rmesa
->radeon
.glCtx
, texname
);
736 radeonTexObjPtr t
= radeon_tex_obj(tObj
);
741 t
->image_override
= GL_TRUE
;
747 t
->override_offset
= offset
;
748 t
->pp_txpitch
= pitch
- 32;
752 t
->pp_txformat
= tx_table_le
[MESA_FORMAT_ARGB8888
].format
;
753 t
->pp_txfilter
|= tx_table_le
[MESA_FORMAT_ARGB8888
].filter
;
757 t
->pp_txformat
= tx_table_le
[MESA_FORMAT_RGB888
].format
;
758 t
->pp_txfilter
|= tx_table_le
[MESA_FORMAT_RGB888
].filter
;
761 t
->pp_txformat
= tx_table_le
[MESA_FORMAT_RGB565
].format
;
762 t
->pp_txfilter
|= tx_table_le
[MESA_FORMAT_RGB565
].filter
;
767 void r200SetTexBuffer2(__DRIcontext
*pDRICtx
, GLint target
, GLint texture_format
,
768 __DRIdrawable
*dPriv
)
770 struct gl_texture_unit
*texUnit
;
771 struct gl_texture_object
*texObj
;
772 struct gl_texture_image
*texImage
;
773 struct radeon_renderbuffer
*rb
;
774 radeon_texture_image
*rImage
;
775 radeonContextPtr radeon
;
776 struct radeon_framebuffer
*rfb
;
781 radeon
= pDRICtx
->driverPrivate
;
783 rfb
= dPriv
->driverPrivate
;
784 texUnit
= &radeon
->glCtx
->Texture
.Unit
[radeon
->glCtx
->Texture
.CurrentUnit
];
785 texObj
= _mesa_select_tex_object(radeon
->glCtx
, texUnit
, target
);
786 texImage
= _mesa_get_tex_image(radeon
->glCtx
, texObj
, target
, 0);
788 rImage
= get_radeon_texture_image(texImage
);
789 t
= radeon_tex_obj(texObj
);
794 radeon_update_renderbuffers(pDRICtx
, dPriv
, GL_TRUE
);
795 rb
= rfb
->color_rb
[0];
796 if (rb
->bo
== NULL
) {
797 /* Failed to BO for the buffer */
801 _mesa_lock_texture(radeon
->glCtx
, texObj
);
803 radeon_bo_unref(t
->bo
);
807 radeon_bo_unref(rImage
->bo
);
811 radeon_miptree_unreference(&t
->mt
);
812 radeon_miptree_unreference(&rImage
->mt
);
815 radeon_bo_ref(rImage
->bo
);
817 radeon_bo_ref(t
->bo
);
819 t
->image_override
= GL_TRUE
;
820 t
->override_offset
= 0;
821 t
->pp_txpitch
&= (1 << 13) -1;
822 pitch_val
= rb
->pitch
;
825 if (texture_format
== __DRI_TEXTURE_FORMAT_RGB
) {
826 texFormat
= MESA_FORMAT_RGB888
;
827 t
->pp_txformat
= tx_table_le
[MESA_FORMAT_RGB888
].format
;
830 texFormat
= MESA_FORMAT_ARGB8888
;
831 t
->pp_txformat
= tx_table_le
[MESA_FORMAT_ARGB8888
].format
;
833 t
->pp_txfilter
|= tx_table_le
[MESA_FORMAT_ARGB8888
].filter
;
837 texFormat
= MESA_FORMAT_RGB888
;
838 t
->pp_txformat
= tx_table_le
[MESA_FORMAT_RGB888
].format
;
839 t
->pp_txfilter
|= tx_table_le
[MESA_FORMAT_RGB888
].filter
;
842 texFormat
= MESA_FORMAT_RGB565
;
843 t
->pp_txformat
= tx_table_le
[MESA_FORMAT_RGB565
].format
;
844 t
->pp_txfilter
|= tx_table_le
[MESA_FORMAT_RGB565
].filter
;
848 _mesa_init_teximage_fields(radeon
->glCtx
, target
, texImage
,
849 rb
->base
.Width
, rb
->base
.Height
, 1, 0,
851 texImage
->RowStride
= rb
->pitch
/ rb
->cpp
;
854 t
->pp_txsize
= ((rb
->base
.Width
- 1) << RADEON_TEX_USIZE_SHIFT
)
855 | ((rb
->base
.Height
- 1) << RADEON_TEX_VSIZE_SHIFT
);
857 if (target
== GL_TEXTURE_RECTANGLE_NV
) {
858 t
->pp_txformat
|= R200_TXFORMAT_NON_POWER2
;
859 t
->pp_txpitch
= pitch_val
;
862 t
->pp_txformat
&= ~(R200_TXFORMAT_WIDTH_MASK
|
863 R200_TXFORMAT_HEIGHT_MASK
|
864 R200_TXFORMAT_CUBIC_MAP_ENABLE
|
865 R200_TXFORMAT_F5_WIDTH_MASK
|
866 R200_TXFORMAT_F5_HEIGHT_MASK
);
867 t
->pp_txformat
|= ((texImage
->WidthLog2
<< R200_TXFORMAT_WIDTH_SHIFT
) |
868 (texImage
->HeightLog2
<< R200_TXFORMAT_HEIGHT_SHIFT
));
871 t
->validated
= GL_TRUE
;
872 _mesa_unlock_texture(radeon
->glCtx
, texObj
);
877 void r200SetTexBuffer(__DRIcontext
*pDRICtx
, GLint target
, __DRIdrawable
*dPriv
)
879 r200SetTexBuffer2(pDRICtx
, target
, __DRI_TEXTURE_FORMAT_RGBA
, dPriv
);
886 static GLboolean
r200UpdateAllTexEnv( struct gl_context
*ctx
)
888 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
889 GLint i
, j
, currslot
;
890 GLint maxunitused
= -1;
891 GLboolean texregfree
[6] = {GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
};
892 GLubyte stageref
[7] = {0, 0, 0, 0, 0, 0, 0};
893 GLint nextunit
[R200_MAX_TEXTURE_UNITS
] = {0, 0, 0, 0, 0, 0};
894 GLint currentnext
= -1;
897 /* find highest used unit */
898 for ( j
= 0; j
< R200_MAX_TEXTURE_UNITS
; j
++) {
899 if (ctx
->Texture
.Unit
[j
]._ReallyEnabled
) {
903 stageref
[maxunitused
+ 1] = REF_COLOR
| REF_ALPHA
;
905 for ( j
= maxunitused
; j
>= 0; j
-- ) {
906 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[j
];
908 rmesa
->state
.texture
.unit
[j
].outputreg
= -1;
910 if (stageref
[j
+ 1]) {
912 /* use the lowest available reg. That gets us automatically reg0 for the last stage.
913 need this even for disabled units, as it may get referenced due to the replace
915 for ( i
= 0 ; i
< R200_MAX_TEXTURE_UNITS
; i
++ ) {
917 rmesa
->state
.texture
.unit
[j
].outputreg
= i
;
921 if (rmesa
->state
.texture
.unit
[j
].outputreg
== -1) {
922 /* no more free regs we can use. Need a fallback :-( */
926 nextunit
[j
] = currentnext
;
928 if (!texUnit
->_ReallyEnabled
) {
929 /* the not enabled stages are referenced "indirectly",
930 must not cut off the lower stages */
931 stageref
[j
] = REF_COLOR
| REF_ALPHA
;
936 const GLuint numColorArgs
= texUnit
->_CurrentCombine
->_NumArgsRGB
;
937 const GLuint numAlphaArgs
= texUnit
->_CurrentCombine
->_NumArgsA
;
938 const GLboolean isdot3rgba
= (texUnit
->_CurrentCombine
->ModeRGB
== GL_DOT3_RGBA
) ||
939 (texUnit
->_CurrentCombine
->ModeRGB
== GL_DOT3_RGBA_EXT
);
942 /* check if we need the color part, special case for dot3_rgba
943 as if only the alpha part is referenced later on it still is using the color part */
944 if ((stageref
[j
+ 1] & REF_COLOR
) || isdot3rgba
) {
945 for ( i
= 0 ; i
< numColorArgs
; i
++ ) {
946 const GLuint srcRGBi
= texUnit
->_CurrentCombine
->SourceRGB
[i
];
947 const GLuint op
= texUnit
->_CurrentCombine
->OperandRGB
[i
];
950 /* op 0/1 are referencing color, op 2/3 alpha */
951 stageref
[j
] |= (op
>> 1) + 1;
954 texregfree
[j
] = GL_FALSE
;
962 texregfree
[srcRGBi
- GL_TEXTURE0
] = GL_FALSE
;
964 default: /* don't care about other sources here */
970 /* alpha args are ignored for dot3_rgba */
971 if ((stageref
[j
+ 1] & REF_ALPHA
) && !isdot3rgba
) {
973 for ( i
= 0 ; i
< numAlphaArgs
; i
++ ) {
974 const GLuint srcAi
= texUnit
->_CurrentCombine
->SourceA
[i
];
977 stageref
[j
] |= REF_ALPHA
;
980 texregfree
[j
] = GL_FALSE
;
988 texregfree
[srcAi
- GL_TEXTURE0
] = GL_FALSE
;
990 default: /* don't care about other sources here */
998 /* don't enable texture sampling for units if the result is not used */
999 for (i
= 0; i
< R200_MAX_TEXTURE_UNITS
; i
++) {
1000 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
&& !texregfree
[i
])
1001 rmesa
->state
.texture
.unit
[i
].unitneeded
= ctx
->Texture
.Unit
[i
]._ReallyEnabled
;
1002 else rmesa
->state
.texture
.unit
[i
].unitneeded
= 0;
1007 rmesa
->state
.envneeded
= 1;
1010 while ((i
<= maxunitused
) && (i
>= 0)) {
1011 /* only output instruction if the results are referenced */
1012 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
&& stageref
[i
+1]) {
1013 GLuint replaceunit
= i
;
1014 /* try to optimize GL_REPLACE away (only one level deep though) */
1015 if ( (ctx
->Texture
.Unit
[i
]._CurrentCombine
->ModeRGB
== GL_REPLACE
) &&
1016 (ctx
->Texture
.Unit
[i
]._CurrentCombine
->ModeA
== GL_REPLACE
) &&
1017 (ctx
->Texture
.Unit
[i
]._CurrentCombine
->ScaleShiftRGB
== 0) &&
1018 (ctx
->Texture
.Unit
[i
]._CurrentCombine
->ScaleShiftA
== 0) &&
1019 (nextunit
[i
] > 0) ) {
1020 /* yippie! can optimize it away! */
1025 /* need env instruction slot */
1026 rmesa
->state
.envneeded
|= 1 << currslot
;
1027 ok
= r200UpdateTextureEnv( ctx
, i
, currslot
, replaceunit
);
1028 if (!ok
) return GL_FALSE
;
1034 if (currslot
== 0) {
1035 /* need one stage at least */
1036 rmesa
->state
.texture
.unit
[0].outputreg
= 0;
1037 ok
= r200UpdateTextureEnv( ctx
, 0, 0, 0 );
1040 R200_STATECHANGE( rmesa
, ctx
);
1041 rmesa
->hw
.ctx
.cmd
[CTX_PP_CNTL
] &= ~(R200_TEX_BLEND_ENABLE_MASK
| R200_MULTI_PASS_ENABLE
);
1042 rmesa
->hw
.ctx
.cmd
[CTX_PP_CNTL
] |= rmesa
->state
.envneeded
<< R200_TEX_BLEND_0_ENABLE_SHIFT
;
1051 #define TEXOBJ_TXFILTER_MASK (R200_MAX_MIP_LEVEL_MASK | \
1052 R200_MIN_FILTER_MASK | \
1053 R200_MAG_FILTER_MASK | \
1054 R200_MAX_ANISO_MASK | \
1056 R200_YUV_TEMPERATURE_MASK | \
1057 R200_CLAMP_S_MASK | \
1058 R200_CLAMP_T_MASK | \
1059 R200_BORDER_MODE_D3D )
1061 #define TEXOBJ_TXFORMAT_MASK (R200_TXFORMAT_WIDTH_MASK | \
1062 R200_TXFORMAT_HEIGHT_MASK | \
1063 R200_TXFORMAT_FORMAT_MASK | \
1064 R200_TXFORMAT_F5_WIDTH_MASK | \
1065 R200_TXFORMAT_F5_HEIGHT_MASK | \
1066 R200_TXFORMAT_ALPHA_IN_MAP | \
1067 R200_TXFORMAT_CUBIC_MAP_ENABLE | \
1068 R200_TXFORMAT_NON_POWER2)
1070 #define TEXOBJ_TXFORMAT_X_MASK (R200_DEPTH_LOG2_MASK | \
1071 R200_TEXCOORD_MASK | \
1072 R200_MIN_MIP_LEVEL_MASK | \
1073 R200_CLAMP_Q_MASK | \
1074 R200_VOLUME_FILTER_MASK)
1077 static void disable_tex_obj_state( r200ContextPtr rmesa
,
1081 R200_STATECHANGE( rmesa
, vtx
);
1082 rmesa
->hw
.vtx
.cmd
[VTX_TCL_OUTPUT_VTXFMT_1
] &= ~(7 << (unit
* 3));
1084 R200_STATECHANGE( rmesa
, ctx
);
1085 rmesa
->hw
.ctx
.cmd
[CTX_PP_CNTL
] &= ~(R200_TEX_0_ENABLE
<< unit
);
1086 if (rmesa
->radeon
.TclFallback
& (R200_TCL_FALLBACK_TEXGEN_0
<<unit
)) {
1087 TCL_FALLBACK( rmesa
->radeon
.glCtx
, (R200_TCL_FALLBACK_TEXGEN_0
<<unit
), GL_FALSE
);
1090 /* Actually want to keep all units less than max active texture
1091 * enabled, right? Fix this for >2 texunits.
1095 GLuint tmp
= rmesa
->TexGenEnabled
;
1097 rmesa
->TexGenEnabled
&= ~(R200_TEXGEN_TEXMAT_0_ENABLE
<<unit
);
1098 rmesa
->TexGenEnabled
&= ~(R200_TEXMAT_0_ENABLE
<<unit
);
1099 rmesa
->TexGenNeedNormals
[unit
] = GL_FALSE
;
1100 rmesa
->TexGenCompSel
&= ~(R200_OUTPUT_TEX_0
<< unit
);
1102 if (tmp
!= rmesa
->TexGenEnabled
) {
1103 rmesa
->recheck_texgen
[unit
] = GL_TRUE
;
1104 rmesa
->radeon
.NewGLState
|= _NEW_TEXTURE_MATRIX
;
1108 static void import_tex_obj_state( r200ContextPtr rmesa
,
1110 radeonTexObjPtr texobj
)
1112 /* do not use RADEON_DB_STATE to avoid stale texture caches */
1113 GLuint
*cmd
= &rmesa
->hw
.tex
[unit
].cmd
[TEX_CMD_0
];
1115 R200_STATECHANGE( rmesa
, tex
[unit
] );
1117 cmd
[TEX_PP_TXFILTER
] &= ~TEXOBJ_TXFILTER_MASK
;
1118 cmd
[TEX_PP_TXFILTER
] |= texobj
->pp_txfilter
& TEXOBJ_TXFILTER_MASK
;
1119 cmd
[TEX_PP_TXFORMAT
] &= ~TEXOBJ_TXFORMAT_MASK
;
1120 cmd
[TEX_PP_TXFORMAT
] |= texobj
->pp_txformat
& TEXOBJ_TXFORMAT_MASK
;
1121 cmd
[TEX_PP_TXFORMAT_X
] &= ~TEXOBJ_TXFORMAT_X_MASK
;
1122 cmd
[TEX_PP_TXFORMAT_X
] |= texobj
->pp_txformat_x
& TEXOBJ_TXFORMAT_X_MASK
;
1123 cmd
[TEX_PP_TXSIZE
] = texobj
->pp_txsize
; /* NPOT only! */
1124 cmd
[TEX_PP_TXPITCH
] = texobj
->pp_txpitch
; /* NPOT only! */
1125 cmd
[TEX_PP_BORDER_COLOR
] = texobj
->pp_border_color
;
1127 if (texobj
->base
.Target
== GL_TEXTURE_CUBE_MAP
) {
1128 GLuint
*cube_cmd
= &rmesa
->hw
.cube
[unit
].cmd
[CUBE_CMD_0
];
1130 R200_STATECHANGE( rmesa
, cube
[unit
] );
1131 cube_cmd
[CUBE_PP_CUBIC_FACES
] = texobj
->pp_cubic_faces
;
1132 if (rmesa
->radeon
.radeonScreen
->drmSupportsFragShader
) {
1133 /* that value is submitted twice. could change cube atom
1134 to not include that command when new drm is used */
1135 cmd
[TEX_PP_CUBIC_FACES
] = texobj
->pp_cubic_faces
;
1141 static void set_texgen_matrix( r200ContextPtr rmesa
,
1143 const GLfloat
*s_plane
,
1144 const GLfloat
*t_plane
,
1145 const GLfloat
*r_plane
,
1146 const GLfloat
*q_plane
)
1170 _math_matrix_loadf( &(rmesa
->TexGenMatrix
[unit
]), m
);
1171 _math_matrix_analyse( &(rmesa
->TexGenMatrix
[unit
]) );
1172 rmesa
->TexGenEnabled
|= R200_TEXMAT_0_ENABLE
<<unit
;
1176 static GLuint
r200_need_dis_texgen(const GLbitfield texGenEnabled
,
1177 const GLfloat
*planeS
,
1178 const GLfloat
*planeT
,
1179 const GLfloat
*planeR
,
1180 const GLfloat
*planeQ
)
1182 GLuint needtgenable
= 0;
1184 if (!(texGenEnabled
& S_BIT
)) {
1185 if (((texGenEnabled
& T_BIT
) && planeT
[0] != 0.0) ||
1186 ((texGenEnabled
& R_BIT
) && planeR
[0] != 0.0) ||
1187 ((texGenEnabled
& Q_BIT
) && planeQ
[0] != 0.0)) {
1188 needtgenable
|= S_BIT
;
1191 if (!(texGenEnabled
& T_BIT
)) {
1192 if (((texGenEnabled
& S_BIT
) && planeS
[1] != 0.0) ||
1193 ((texGenEnabled
& R_BIT
) && planeR
[1] != 0.0) ||
1194 ((texGenEnabled
& Q_BIT
) && planeQ
[1] != 0.0)) {
1195 needtgenable
|= T_BIT
;
1198 if (!(texGenEnabled
& R_BIT
)) {
1199 if (((texGenEnabled
& S_BIT
) && planeS
[2] != 0.0) ||
1200 ((texGenEnabled
& T_BIT
) && planeT
[2] != 0.0) ||
1201 ((texGenEnabled
& Q_BIT
) && planeQ
[2] != 0.0)) {
1202 needtgenable
|= R_BIT
;
1205 if (!(texGenEnabled
& Q_BIT
)) {
1206 if (((texGenEnabled
& S_BIT
) && planeS
[3] != 0.0) ||
1207 ((texGenEnabled
& T_BIT
) && planeT
[3] != 0.0) ||
1208 ((texGenEnabled
& R_BIT
) && planeR
[3] != 0.0)) {
1209 needtgenable
|= Q_BIT
;
1213 return needtgenable
;
1218 * Returns GL_FALSE if fallback required.
1220 static GLboolean
r200_validate_texgen( struct gl_context
*ctx
, GLuint unit
)
1222 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1223 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
1224 GLuint inputshift
= R200_TEXGEN_0_INPUT_SHIFT
+ unit
*4;
1227 GLboolean mixed_fallback
= GL_FALSE
;
1228 static const GLfloat I
[16] = {
1233 static const GLfloat reflect
[16] = {
1239 rmesa
->TexGenCompSel
&= ~(R200_OUTPUT_TEX_0
<< unit
);
1240 rmesa
->TexGenEnabled
&= ~(R200_TEXGEN_TEXMAT_0_ENABLE
<<unit
);
1241 rmesa
->TexGenEnabled
&= ~(R200_TEXMAT_0_ENABLE
<<unit
);
1242 rmesa
->TexGenNeedNormals
[unit
] = GL_FALSE
;
1243 tgi
= rmesa
->hw
.tcg
.cmd
[TCG_TEX_PROC_CTL_1
] & ~(R200_TEXGEN_INPUT_MASK
<<
1245 tgcm
= rmesa
->hw
.tcg
.cmd
[TCG_TEX_PROC_CTL_2
] & ~(R200_TEXGEN_COMP_MASK
<<
1249 fprintf(stderr
, "%s unit %d\n", __FUNCTION__
, unit
);
1251 if (texUnit
->TexGenEnabled
& S_BIT
) {
1252 mode
= texUnit
->GenS
.Mode
;
1254 tgcm
|= R200_TEXGEN_COMP_S
<< (unit
* 4);
1257 if (texUnit
->TexGenEnabled
& T_BIT
) {
1258 if (texUnit
->GenT
.Mode
!= mode
)
1259 mixed_fallback
= GL_TRUE
;
1261 tgcm
|= R200_TEXGEN_COMP_T
<< (unit
* 4);
1263 if (texUnit
->TexGenEnabled
& R_BIT
) {
1264 if (texUnit
->GenR
.Mode
!= mode
)
1265 mixed_fallback
= GL_TRUE
;
1267 tgcm
|= R200_TEXGEN_COMP_R
<< (unit
* 4);
1270 if (texUnit
->TexGenEnabled
& Q_BIT
) {
1271 if (texUnit
->GenQ
.Mode
!= mode
)
1272 mixed_fallback
= GL_TRUE
;
1274 tgcm
|= R200_TEXGEN_COMP_Q
<< (unit
* 4);
1277 if (mixed_fallback
) {
1278 if (R200_DEBUG
& RADEON_FALLBACKS
)
1279 fprintf(stderr
, "fallback mixed texgen, 0x%x (0x%x 0x%x 0x%x 0x%x)\n",
1280 texUnit
->TexGenEnabled
, texUnit
->GenS
.Mode
, texUnit
->GenT
.Mode
,
1281 texUnit
->GenR
.Mode
, texUnit
->GenQ
.Mode
);
1285 /* we CANNOT do mixed mode if the texgen mode requires a plane where the input
1286 is not enabled for texgen, since the planes are concatenated into texmat,
1287 and thus the input will come from texcoord rather than tex gen equation!
1288 Either fallback or just hope that those texcoords aren't really needed...
1289 Assuming the former will cause lots of unnecessary fallbacks, the latter will
1290 generate bogus results sometimes - it's pretty much impossible to really know
1291 when a fallback is needed, depends on texmat and what sort of texture is bound
1292 etc, - for now fallback if we're missing either S or T bits, there's a high
1293 probability we need the texcoords in that case.
1294 That's a lot of work for some obscure texgen mixed mode fixup - why oh why
1295 doesn't the chip just directly accept the plane parameters :-(. */
1297 case GL_OBJECT_LINEAR
: {
1298 GLuint needtgenable
= r200_need_dis_texgen( texUnit
->TexGenEnabled
,
1299 texUnit
->GenS
.ObjectPlane
,
1300 texUnit
->GenT
.ObjectPlane
,
1301 texUnit
->GenR
.ObjectPlane
,
1302 texUnit
->GenQ
.ObjectPlane
);
1303 if (needtgenable
& (S_BIT
| T_BIT
)) {
1304 if (R200_DEBUG
& RADEON_FALLBACKS
)
1305 fprintf(stderr
, "fallback mixed texgen / obj plane, 0x%x\n",
1306 texUnit
->TexGenEnabled
);
1309 if (needtgenable
& (R_BIT
)) {
1310 tgcm
&= ~(R200_TEXGEN_COMP_R
<< (unit
* 4));
1312 if (needtgenable
& (Q_BIT
)) {
1313 tgcm
&= ~(R200_TEXGEN_COMP_Q
<< (unit
* 4));
1316 tgi
|= R200_TEXGEN_INPUT_OBJ
<< inputshift
;
1317 set_texgen_matrix( rmesa
, unit
,
1318 (texUnit
->TexGenEnabled
& S_BIT
) ? texUnit
->GenS
.ObjectPlane
: I
,
1319 (texUnit
->TexGenEnabled
& T_BIT
) ? texUnit
->GenT
.ObjectPlane
: I
+ 4,
1320 (texUnit
->TexGenEnabled
& R_BIT
) ? texUnit
->GenR
.ObjectPlane
: I
+ 8,
1321 (texUnit
->TexGenEnabled
& Q_BIT
) ? texUnit
->GenQ
.ObjectPlane
: I
+ 12);
1325 case GL_EYE_LINEAR
: {
1326 GLuint needtgenable
= r200_need_dis_texgen( texUnit
->TexGenEnabled
,
1327 texUnit
->GenS
.EyePlane
,
1328 texUnit
->GenT
.EyePlane
,
1329 texUnit
->GenR
.EyePlane
,
1330 texUnit
->GenQ
.EyePlane
);
1331 if (needtgenable
& (S_BIT
| T_BIT
)) {
1332 if (R200_DEBUG
& RADEON_FALLBACKS
)
1333 fprintf(stderr
, "fallback mixed texgen / eye plane, 0x%x\n",
1334 texUnit
->TexGenEnabled
);
1337 if (needtgenable
& (R_BIT
)) {
1338 tgcm
&= ~(R200_TEXGEN_COMP_R
<< (unit
* 4));
1340 if (needtgenable
& (Q_BIT
)) {
1341 tgcm
&= ~(R200_TEXGEN_COMP_Q
<< (unit
* 4));
1343 tgi
|= R200_TEXGEN_INPUT_EYE
<< inputshift
;
1344 set_texgen_matrix( rmesa
, unit
,
1345 (texUnit
->TexGenEnabled
& S_BIT
) ? texUnit
->GenS
.EyePlane
: I
,
1346 (texUnit
->TexGenEnabled
& T_BIT
) ? texUnit
->GenT
.EyePlane
: I
+ 4,
1347 (texUnit
->TexGenEnabled
& R_BIT
) ? texUnit
->GenR
.EyePlane
: I
+ 8,
1348 (texUnit
->TexGenEnabled
& Q_BIT
) ? texUnit
->GenQ
.EyePlane
: I
+ 12);
1352 case GL_REFLECTION_MAP_NV
:
1353 rmesa
->TexGenNeedNormals
[unit
] = GL_TRUE
;
1354 tgi
|= R200_TEXGEN_INPUT_EYE_REFLECT
<< inputshift
;
1355 /* pretty weird, must only negate when lighting is enabled? */
1356 if (ctx
->Light
.Enabled
)
1357 set_texgen_matrix( rmesa
, unit
,
1358 (texUnit
->TexGenEnabled
& S_BIT
) ? reflect
: I
,
1359 (texUnit
->TexGenEnabled
& T_BIT
) ? reflect
+ 4 : I
+ 4,
1360 (texUnit
->TexGenEnabled
& R_BIT
) ? reflect
+ 8 : I
+ 8,
1364 case GL_NORMAL_MAP_NV
:
1365 rmesa
->TexGenNeedNormals
[unit
] = GL_TRUE
;
1366 tgi
|= R200_TEXGEN_INPUT_EYE_NORMAL
<<inputshift
;
1370 rmesa
->TexGenNeedNormals
[unit
] = GL_TRUE
;
1371 tgi
|= R200_TEXGEN_INPUT_SPHERE
<<inputshift
;
1375 /* All texgen units were disabled, so just pass coords through. */
1376 tgi
|= unit
<< inputshift
;
1380 /* Unsupported mode, fallback:
1382 if (R200_DEBUG
& RADEON_FALLBACKS
)
1383 fprintf(stderr
, "fallback unsupported texgen, %d\n",
1384 texUnit
->GenS
.Mode
);
1388 rmesa
->TexGenEnabled
|= R200_TEXGEN_TEXMAT_0_ENABLE
<< unit
;
1389 rmesa
->TexGenCompSel
|= R200_OUTPUT_TEX_0
<< unit
;
1391 if (tgi
!= rmesa
->hw
.tcg
.cmd
[TCG_TEX_PROC_CTL_1
] ||
1392 tgcm
!= rmesa
->hw
.tcg
.cmd
[TCG_TEX_PROC_CTL_2
])
1394 R200_STATECHANGE(rmesa
, tcg
);
1395 rmesa
->hw
.tcg
.cmd
[TCG_TEX_PROC_CTL_1
] = tgi
;
1396 rmesa
->hw
.tcg
.cmd
[TCG_TEX_PROC_CTL_2
] = tgcm
;
1402 void set_re_cntl_d3d( struct gl_context
*ctx
, int unit
, GLboolean use_d3d
)
1404 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1408 re_cntl
= rmesa
->hw
.set
.cmd
[SET_RE_CNTL
] & ~(R200_VTX_STQ0_D3D
<< (2 * unit
));
1410 re_cntl
|= R200_VTX_STQ0_D3D
<< (2 * unit
);
1412 if ( re_cntl
!= rmesa
->hw
.set
.cmd
[SET_RE_CNTL
] ) {
1413 R200_STATECHANGE( rmesa
, set
);
1414 rmesa
->hw
.set
.cmd
[SET_RE_CNTL
] = re_cntl
;
1419 * Compute the cached hardware register values for the given texture object.
1421 * \param rmesa Context pointer
1422 * \param t the r300 texture object
1424 static void setup_hardware_state(r200ContextPtr rmesa
, radeonTexObj
*t
)
1426 const struct gl_texture_image
*firstImage
= t
->base
.Image
[0][t
->minLod
];
1427 GLint log2Width
, log2Height
, log2Depth
, texelBytes
;
1428 uint extra_size
= 0;
1434 log2Width
= firstImage
->WidthLog2
;
1435 log2Height
= firstImage
->HeightLog2
;
1436 log2Depth
= firstImage
->DepthLog2
;
1437 texelBytes
= _mesa_get_format_bytes(firstImage
->TexFormat
);
1439 radeon_print(RADEON_TEXTURE
, RADEON_TRACE
,
1440 "%s(%p, tex %p) log2(w %d, h %d, d %d), texelBytes %d. format %d\n",
1441 __func__
, rmesa
, t
, log2Width
, log2Height
,
1442 log2Depth
, texelBytes
, firstImage
->TexFormat
);
1444 if (!t
->image_override
) {
1445 if (VALID_FORMAT(firstImage
->TexFormat
)) {
1446 const struct tx_table
*table
= _mesa_little_endian() ? tx_table_le
:
1449 t
->pp_txformat
&= ~(R200_TXFORMAT_FORMAT_MASK
|
1450 R200_TXFORMAT_ALPHA_IN_MAP
);
1451 t
->pp_txfilter
&= ~R200_YUV_TO_RGB
;
1453 t
->pp_txformat
|= table
[ firstImage
->TexFormat
].format
;
1454 t
->pp_txfilter
|= table
[ firstImage
->TexFormat
].filter
;
1458 _mesa_problem(NULL
, "unexpected texture format in %s",
1464 t
->pp_txfilter
&= ~R200_MAX_MIP_LEVEL_MASK
;
1465 t
->pp_txfilter
|= ((t
->maxLod
) << R200_MAX_MIP_LEVEL_SHIFT
)
1466 & R200_MAX_MIP_LEVEL_MASK
;
1468 if ( t
->pp_txfilter
&
1469 (R200_MIN_FILTER_NEAREST_MIP_NEAREST
1470 | R200_MIN_FILTER_NEAREST_MIP_LINEAR
1471 | R200_MIN_FILTER_LINEAR_MIP_NEAREST
1472 | R200_MIN_FILTER_LINEAR_MIP_LINEAR
1473 | R200_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST
1474 | R200_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR
))
1475 extra_size
= t
->minLod
;
1477 t
->pp_txformat
&= ~(R200_TXFORMAT_WIDTH_MASK
|
1478 R200_TXFORMAT_HEIGHT_MASK
|
1479 R200_TXFORMAT_CUBIC_MAP_ENABLE
|
1480 R200_TXFORMAT_F5_WIDTH_MASK
|
1481 R200_TXFORMAT_F5_HEIGHT_MASK
);
1482 t
->pp_txformat
|= (((log2Width
+ extra_size
) << R200_TXFORMAT_WIDTH_SHIFT
) |
1483 ((log2Height
+ extra_size
)<< R200_TXFORMAT_HEIGHT_SHIFT
));
1487 t
->pp_txformat_x
&= ~(R200_DEPTH_LOG2_MASK
| R200_TEXCOORD_MASK
1488 | R200_MIN_MIP_LEVEL_MASK
);
1490 t
->pp_txformat_x
|= (t
->minLod
<< R200_MIN_MIP_LEVEL_SHIFT
)
1491 & R200_MIN_MIP_LEVEL_MASK
;
1493 if (t
->base
.Target
== GL_TEXTURE_3D
) {
1494 t
->pp_txformat_x
|= (log2Depth
<< R200_DEPTH_LOG2_SHIFT
);
1495 t
->pp_txformat_x
|= R200_TEXCOORD_VOLUME
;
1498 else if (t
->base
.Target
== GL_TEXTURE_CUBE_MAP
) {
1499 ASSERT(log2Width
== log2Height
);
1500 t
->pp_txformat
|= ((log2Width
<< R200_TXFORMAT_F5_WIDTH_SHIFT
) |
1501 (log2Height
<< R200_TXFORMAT_F5_HEIGHT_SHIFT
) |
1502 /* don't think we need this bit, if it exists at all - fglrx does not set it */
1503 (R200_TXFORMAT_CUBIC_MAP_ENABLE
));
1504 t
->pp_txformat_x
|= R200_TEXCOORD_CUBIC_ENV
;
1505 t
->pp_cubic_faces
= ((log2Width
<< R200_FACE_WIDTH_1_SHIFT
) |
1506 (log2Height
<< R200_FACE_HEIGHT_1_SHIFT
) |
1507 (log2Width
<< R200_FACE_WIDTH_2_SHIFT
) |
1508 (log2Height
<< R200_FACE_HEIGHT_2_SHIFT
) |
1509 (log2Width
<< R200_FACE_WIDTH_3_SHIFT
) |
1510 (log2Height
<< R200_FACE_HEIGHT_3_SHIFT
) |
1511 (log2Width
<< R200_FACE_WIDTH_4_SHIFT
) |
1512 (log2Height
<< R200_FACE_HEIGHT_4_SHIFT
));
1515 /* If we don't in fact send enough texture coordinates, q will be 1,
1516 * making TEXCOORD_PROJ act like TEXCOORD_NONPROJ (Right?)
1518 t
->pp_txformat_x
|= R200_TEXCOORD_PROJ
;
1520 /* FIXME: NPOT sizes, Is it correct realy? */
1521 t
->pp_txsize
= (((firstImage
->Width
- 1) << R200_PP_TX_WIDTHMASK_SHIFT
)
1522 | ((firstImage
->Height
- 1) << R200_PP_TX_HEIGHTMASK_SHIFT
));
1524 if ( !t
->image_override
) {
1525 if (_mesa_is_format_compressed(firstImage
->TexFormat
))
1526 t
->pp_txpitch
= (firstImage
->Width
+ 63) & ~(63);
1528 t
->pp_txpitch
= ((firstImage
->Width
* texelBytes
) + 63) & ~(63);
1529 t
->pp_txpitch
-= 32;
1532 if (t
->base
.Target
== GL_TEXTURE_RECTANGLE_NV
) {
1533 t
->pp_txformat
|= R200_TXFORMAT_NON_POWER2
;
1538 static GLboolean
r200_validate_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
, int unit
)
1540 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1541 radeonTexObj
*t
= radeon_tex_obj(texObj
);
1543 if (!radeon_validate_texture_miptree(ctx
, texObj
))
1546 r200_validate_texgen(ctx
, unit
);
1547 /* Configure the hardware registers (more precisely, the cached version
1548 * of the hardware registers). */
1549 setup_hardware_state(rmesa
, t
);
1551 if (texObj
->Target
== GL_TEXTURE_RECTANGLE_NV
||
1552 texObj
->Target
== GL_TEXTURE_2D
||
1553 texObj
->Target
== GL_TEXTURE_1D
)
1554 set_re_cntl_d3d( ctx
, unit
, GL_FALSE
);
1556 set_re_cntl_d3d( ctx
, unit
, GL_TRUE
);
1557 R200_STATECHANGE( rmesa
, ctx
);
1558 rmesa
->hw
.ctx
.cmd
[CTX_PP_CNTL
] |= R200_TEX_0_ENABLE
<< unit
;
1560 R200_STATECHANGE( rmesa
, vtx
);
1561 rmesa
->hw
.vtx
.cmd
[VTX_TCL_OUTPUT_VTXFMT_1
] &= ~(7 << (unit
* 3));
1562 rmesa
->hw
.vtx
.cmd
[VTX_TCL_OUTPUT_VTXFMT_1
] |= 4 << (unit
* 3);
1564 rmesa
->recheck_texgen
[unit
] = GL_TRUE
;
1565 import_tex_obj_state( rmesa
, unit
, t
);
1567 if (rmesa
->recheck_texgen
[unit
]) {
1568 GLboolean fallback
= !r200_validate_texgen( ctx
, unit
);
1569 TCL_FALLBACK( ctx
, (R200_TCL_FALLBACK_TEXGEN_0
<<unit
), fallback
);
1570 rmesa
->recheck_texgen
[unit
] = 0;
1571 rmesa
->radeon
.NewGLState
|= _NEW_TEXTURE_MATRIX
;
1574 t
->validated
= GL_TRUE
;
1576 FALLBACK( rmesa
, RADEON_FALLBACK_BORDER_MODE
, t
->border_fallback
);
1578 return !t
->border_fallback
;
1581 static GLboolean
r200UpdateTextureUnit(struct gl_context
*ctx
, int unit
)
1583 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1584 GLuint unitneeded
= rmesa
->state
.texture
.unit
[unit
].unitneeded
;
1587 /* disable the unit */
1588 disable_tex_obj_state(rmesa
, unit
);
1592 if (!r200_validate_texture(ctx
, ctx
->Texture
.Unit
[unit
]._Current
, unit
)) {
1594 "failed to validate texture for unit %d.\n",
1596 rmesa
->state
.texture
.unit
[unit
].texobj
= NULL
;
1600 rmesa
->state
.texture
.unit
[unit
].texobj
= radeon_tex_obj(ctx
->Texture
.Unit
[unit
]._Current
);
1605 void r200UpdateTextureState( struct gl_context
*ctx
)
1607 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1611 /* NOTE: must not manipulate rmesa->state.texture.unit[].unitneeded or
1612 rmesa->state.envneeded before a R200_STATECHANGE (or R200_NEWPRIM) since
1613 we use these to determine if we want to emit the corresponding state
1615 R200_NEWPRIM( rmesa
);
1617 if (ctx
->ATIFragmentShader
._Enabled
) {
1619 for (i
= 0; i
< R200_MAX_TEXTURE_UNITS
; i
++) {
1620 rmesa
->state
.texture
.unit
[i
].unitneeded
= ctx
->Texture
.Unit
[i
]._ReallyEnabled
;
1625 ok
= r200UpdateAllTexEnv( ctx
);
1628 ok
= (r200UpdateTextureUnit( ctx
, 0 ) &&
1629 r200UpdateTextureUnit( ctx
, 1 ) &&
1630 r200UpdateTextureUnit( ctx
, 2 ) &&
1631 r200UpdateTextureUnit( ctx
, 3 ) &&
1632 r200UpdateTextureUnit( ctx
, 4 ) &&
1633 r200UpdateTextureUnit( ctx
, 5 ));
1636 if (ok
&& ctx
->ATIFragmentShader
._Enabled
) {
1637 r200UpdateFragmentShader(ctx
);
1640 FALLBACK( rmesa
, R200_FALLBACK_TEXTURE
, !ok
);
1642 if (rmesa
->radeon
.TclFallback
)
1643 r200ChooseVertexState( ctx
);
1646 if (rmesa
->radeon
.radeonScreen
->chip_family
== CHIP_FAMILY_R200
) {
1649 * T0 hang workaround -------------
1650 * not needed for r200 derivatives
1652 if ((rmesa
->hw
.ctx
.cmd
[CTX_PP_CNTL
] & R200_TEX_ENABLE_MASK
) == R200_TEX_0_ENABLE
&&
1653 (rmesa
->hw
.tex
[0].cmd
[TEX_PP_TXFILTER
] & R200_MIN_FILTER_MASK
) > R200_MIN_FILTER_LINEAR
) {
1655 R200_STATECHANGE(rmesa
, ctx
);
1656 R200_STATECHANGE(rmesa
, tex
[1]);
1657 rmesa
->hw
.ctx
.cmd
[CTX_PP_CNTL
] |= R200_TEX_1_ENABLE
;
1658 if (!(rmesa
->hw
.cst
.cmd
[CST_PP_CNTL_X
] & R200_PPX_TEX_1_ENABLE
))
1659 rmesa
->hw
.tex
[1].cmd
[TEX_PP_TXFORMAT
] &= ~TEXOBJ_TXFORMAT_MASK
;
1660 rmesa
->hw
.tex
[1].cmd
[TEX_PP_TXFORMAT
] |= R200_TXFORMAT_LOOKUP_DISABLE
;
1662 else if (!ctx
->ATIFragmentShader
._Enabled
) {
1663 if ((rmesa
->hw
.ctx
.cmd
[CTX_PP_CNTL
] & R200_TEX_1_ENABLE
) &&
1664 (rmesa
->hw
.tex
[1].cmd
[TEX_PP_TXFORMAT
] & R200_TXFORMAT_LOOKUP_DISABLE
)) {
1665 R200_STATECHANGE(rmesa
, tex
[1]);
1666 rmesa
->hw
.tex
[1].cmd
[TEX_PP_TXFORMAT
] &= ~R200_TXFORMAT_LOOKUP_DISABLE
;
1669 /* do the same workaround for the first pass of a fragment shader.
1670 * completely unknown if necessary / sufficient.
1672 if ((rmesa
->hw
.cst
.cmd
[CST_PP_CNTL_X
] & R200_PPX_TEX_ENABLE_MASK
) == R200_PPX_TEX_0_ENABLE
&&
1673 (rmesa
->hw
.tex
[0].cmd
[TEX_PP_TXFILTER
] & R200_MIN_FILTER_MASK
) > R200_MIN_FILTER_LINEAR
) {
1675 R200_STATECHANGE(rmesa
, cst
);
1676 R200_STATECHANGE(rmesa
, tex
[1]);
1677 rmesa
->hw
.cst
.cmd
[CST_PP_CNTL_X
] |= R200_PPX_TEX_1_ENABLE
;
1678 if (!(rmesa
->hw
.ctx
.cmd
[CTX_PP_CNTL
] & R200_TEX_1_ENABLE
))
1679 rmesa
->hw
.tex
[1].cmd
[TEX_PP_TXFORMAT
] &= ~TEXOBJ_TXFORMAT_MASK
;
1680 rmesa
->hw
.tex
[1].cmd
[TEX_PP_TXMULTI_CTL
] |= R200_PASS1_TXFORMAT_LOOKUP_DISABLE
;
1683 /* maybe needs to be done pairwise due to 2 parallel (physical) tex units ?
1684 looks like that's not the case, if 8500/9100 owners don't complain remove this...
1685 for ( i = 0; i < ctx->Const.MaxTextureUnits; i += 2) {
1686 if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & ((R200_TEX_0_ENABLE |
1687 R200_TEX_1_ENABLE ) << i)) == (R200_TEX_0_ENABLE << i)) &&
1688 ((rmesa->hw.tex[i].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK) >
1689 R200_MIN_FILTER_LINEAR)) {
1690 R200_STATECHANGE(rmesa, ctx);
1691 R200_STATECHANGE(rmesa, tex[i+1]);
1692 rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= (R200_TEX_1_ENABLE << i);
1693 rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
1694 rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] |= 0x08000000;
1697 if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_1_ENABLE << i)) &&
1698 (rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] & 0x08000000)) {
1699 R200_STATECHANGE(rmesa, tex[i+1]);
1700 rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] &= ~0x08000000;
1706 * Texture cache LRU hang workaround -------------
1707 * not needed for r200 derivatives
1708 * hopefully this covers first pass of a shader as well
1711 /* While the cases below attempt to only enable the workaround in the
1712 * specific cases necessary, they were insufficient. See bugzilla #1519,
1713 * #729, #814. Tests with quake3 showed no impact on performance.
1718 if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE )) &&
1719 ((((rmesa->hw.tex[0].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
1721 ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_2_ENABLE) &&
1722 ((((rmesa->hw.tex[2].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
1724 ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_4_ENABLE) &&
1725 ((((rmesa->hw.tex[4].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
1731 if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_1_ENABLE )) &&
1732 ((((rmesa->hw.tex[1].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
1734 ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_3_ENABLE) &&
1735 ((((rmesa->hw.tex[3].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
1737 ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_5_ENABLE) &&
1738 ((((rmesa->hw.tex[5].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
1744 if (dbg
!= rmesa
->hw
.tam
.cmd
[TAM_DEBUG3
]) {
1745 R200_STATECHANGE( rmesa
, tam
);
1746 rmesa
->hw
.tam
.cmd
[TAM_DEBUG3
] = dbg
;
1747 if (0) printf("TEXCACHE LRU HANG WORKAROUND %x\n", dbg
);